나는 거의 2 일 동안 머리를 부러 뜨 렸고 해결책을 찾지 못했습니다.레일 3. 인보이스의 광고 항목 및 광고 항목 이름에서 표를 작성하는 방법은 어떻게 다릅니 까?
송장 번호, 총액, 지불 금액 및 잔액이있는 송장 목록이있는 테이블이 있습니다. 잘 작동합니다. 이제 모든 광고 항목을 표에 추가해야합니다.
invoices 테이블에는 of_lax, air_rate_customer, pss라는 열이 있으므로 쉽게 사용할 수 있으므로 값이 있는지 확인해야합니다.
까다로운 부분가 fcl_variable_cost_1_amount
속성에 대해, 난 (fcl_variable_cost_1_amount, fcl_variable_cost_2_amount 등) 사람들의 팔을 얻었다.
fcl_variable_cost_1_amount
에는 해당하는 fcl_variable_cost_1_charge_id가 있으며 요금 테이블에 연결됩니다.
하나의 인보이스에서 fcl_variable_cost_1_id는 34이며 금액은 $ 100입니다 (ID 34는 "ISF"에 해당).
다른 송장에서 fcl_variable_cost_1_id는 12 일 수 있으며 $ 50 (ID 12는 "시험 수수료"에 해당)입니다.
변수 이름 광고 항목을 어떻게해야 열에 표시 할 수 있습니까?
이것은 내 코드입니다. 스크린 샷도 있습니다. 경우 사람의 미래 참고로
<% headings = Hash.new %>
<% @shipments.each do |shipment| %>
<% unless shipment.invoice.nil? %>
<% unless shipment.invoice.of_customer_amount_for_customer_inv.nil? %>
<% headings['of_customer_amount_for_customer_inv'] = "Ocean Freight (FCL)" %>
<% end %>
<% unless shipment.invoice.of_lax.nil? %>
<% headings['of_lax'] = "Ocean Freight (LCL)" %>
<% end %>
<% unless shipment.invoice.air_rate_customer.nil? %>
<% headings['air_rate_customer'] = "Air Freight" %>
<% end %>
<% unless shipment.invoice.pss.nil? %>
<% headings['pss'] = "PSS" %>
<% end %>
<% unless shipment.invoice.hc_lax.nil? %>
<% headings['hc_lax'] = "HC LAX" %>
<% end %>
<% unless shipment.invoice.fcl_variable_cost_1_amount.nil? %>
<% headings[(Charge.find(shipment.invoice.fcl_variable_cost_1_charge_id)).name] = Charge.find(shipment.invoice.fcl_variable_cost_1_charge_id).name %>
<% end %>
<% unless shipment.invoice.fcl_variable_cost_2_amount.nil? %>
<% headings[(Charge.find(shipment.invoice.fcl_variable_cost_2_charge_id)).name] = Charge.find(shipment.invoice.fcl_variable_cost_2_charge_id).name %>
<% end %>
<% unless shipment.invoice.fcl_variable_cost_3_amount.nil? %>
<% headings[(Charge.find(shipment.invoice.fcl_variable_cost_3_charge_id)).name] = Charge.find(shipment.invoice.fcl_variable_cost_3_charge_id).name %>
<% end %>
<% unless shipment.invoice.fcl_variable_cost_4_amount.nil? %>
<% headings[(Charge.find(shipment.invoice.fcl_variable_cost_4_charge_id)).name] = Charge.find(shipment.invoice.fcl_variable_cost_4_charge_id).name %>
<% end %>
<% unless shipment.invoice.fcl_variable_cost_5_amount.nil? %>
<% headings[(Charge.find(shipment.invoice.fcl_variable_cost_5_charge_id)).name] = Charge.find(shipment.invoice.fcl_variable_cost_5_charge_id).name %>
<% end %>
<% unless shipment.invoice.fcl_variable_cost_6_amount.nil? %>
<% headings[(Charge.find(shipment.invoice.fcl_variable_cost_6_charge_id)).name] = Charge.find(shipment.invoice.fcl_variable_cost_6_charge_id).name %>
<% end %>
<% unless shipment.invoice.fcl_variable_cost_7_amount.nil? %>
<% headings[(Charge.find(shipment.invoice.fcl_variable_cost_7_charge_id)).name] = Charge.find(shipment.invoice.fcl_variable_cost_7_charge_id).name %>
<% end %>
<% unless shipment.invoice.fcl_variable_cost_8_amount.nil? %>
<% headings[(Charge.find(shipment.invoice.fcl_variable_cost_8_charge_id)).name] = Charge.find(shipment.invoice.fcl_variable_cost_8_charge_id).name %>
<% end %>
<% end %>
<% end %>
<table>
<tr>
<th colspan="9">Customer AR Statement for <%= @customer.company_name %></th>
</tr>
<tr>
<th style="text-align:center;">MTY</th>
<th>Shipper</th>
<th>HBL</th>
<th>Container</th>
<th>Status</th>
<th>Age</th>
<th>Delivered Customer</th>
<th>Invoice Date</th>
<% headings.each_pair do |k,v|%>
<th><%= v %></th>
<% end %>
<th>Invoice Total</th>
<th>Amount Paid</th>
<th>Balance</th>
</tr>
<% @shipments.each do |shipment| %>
<tr>
<td style="text-align:center;"><%= shipment.file_number %></td>
<td><%= shipment.shipper.company_name %></td>
<td><%= shipment.hbl %></td>
<td><%= shipment.container %></td>
<td><%= shipment.status %></td>
<td><%= shipment.age %></td>
<td><%= shipment.invoice.delivered_customer ? "Yes" : "No" %></td>
<td><%= shipment.invoice.read_issued_at unless shipment.invoice.nil? %></td>
<% if shipment.invoice.nil? %>
<td colspan="<%= headings.count %>"></td>
<% else %>
<% headings.each_pair do |k,v| %>
<% if k == "of_lax" and !shipment.invoice.of_lax.nil? %>
<td><%= number_to_currency shipment.invoice.lcl_of_customer_total %>
<% elsif k == "of_customer_amount_for_customer_inv" and !shipment.invoice.of_customer_amount_for_customer_inv.nil? %>
<td><%= number_to_currency shipment.invoice.of_customer_amount_for_customer_inv %></td>
<% elsif k == "air_rate_customer" and !shipment.invoice.air_rate_customer.nil? %>
<td><%= number_to_currency (shipment.volweight * shipment.invoice.air_rate_customer.to_s.to_d) %></td>
<% elsif k == "pss" and !shipment.invoice.pss.nil? %>
<td><%= number_to_currency (shipment.invoice.pss.to_s.to_d * shipment.volweight) %></td>
<% elsif k == "hc_lax" and !shipment.invoice.hc_lax.nil? %>
<td><%= number_to_currency (shipment.invoice.hc_lax.to_s.to_d * shipment.volweight) %></td>
<% else %>
<td></td>
<% end %>
<% end %>
<% end %>
<td style="text-align:right;"><%= number_to_currency shipment.invoice.customer_total unless shipment.invoice.nil? %></td>
<td style="text-align:right;"><%= number_to_currency shipment.invoice.customer_amount_paid unless shipment.invoice.nil? %></td>
<td style="text-align:right;"><%= number_to_currency shipment.invoice.customer_open_balance unless shipment.invoice.nil? %></td>
</tr>
<% end %>
<tr>
<td colspan="<%= 7 + (headings.count) %>"></td>
<th>Totals</th>
<td style="text-align:right;"><%= number_to_currency @totals[:overall] %></td>
<td style="text-align:right;"><%= number_to_currency @totals[:paid] %></td>
<td style="text-align:right;"><%= number_to_currency @totals[:balance] %></td>
</tr>
</table>
질문은 무엇으로 실행? –
질문이 업데이트되었습니다. – leonel