Change relationship of invoices #390
This change will allow us to have invoices for more than one order/delivery in the future. There are no UI changes for now.
This commit is contained in:
parent
9f919c3e54
commit
460cf1e82c
13 changed files with 70 additions and 38 deletions
|
|
@ -1,11 +1,11 @@
|
|||
= simple_form_for([:finance, @invoice]) do |f|
|
||||
= f.hidden_field :delivery_id
|
||||
= f.hidden_field :order_id
|
||||
= f.association :deliveries, multiple: true, as: :hidden
|
||||
= f.association :orders, multiple: true, as: :hidden
|
||||
|
||||
- if @invoice.delivery
|
||||
%p= t('finance.invoices.linked', what_link: link_to(t('finance.invoices.linked_delivery'), [@invoice.supplier,@invoice.delivery])).html_safe
|
||||
- if @invoice.order
|
||||
%p= t('finance.invoices.linked', what_link: link_to(t('finance.invoices.linked_order'), new_finance_order_path(order_id: @invoice.order.id))).html_safe
|
||||
- if @invoice.deliveries.first
|
||||
%p= t('finance.invoices.linked', what_link: link_to(t('finance.invoices.linked_delivery'), [@invoice.supplier,@invoice.deliveries.first])).html_safe
|
||||
- if @invoice.orders.first
|
||||
%p= t('finance.invoices.linked', what_link: link_to(t('finance.invoices.linked_order'), new_finance_order_path(order_id: @invoice.orders.first.id))).html_safe
|
||||
|
||||
- if @invoice.created_at
|
||||
= f.input :created_at do
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@
|
|||
%th= heading_helper Invoice, :date
|
||||
%th= heading_helper Invoice, :paid_on
|
||||
%th= heading_helper Invoice, :amount
|
||||
%th= heading_helper Invoice, :delivery
|
||||
%th= heading_helper Invoice, :order
|
||||
%th= heading_helper Invoice, :deliveries
|
||||
%th= heading_helper Invoice, :orders
|
||||
%th= heading_helper Invoice, :note
|
||||
%th
|
||||
%th
|
||||
|
|
@ -23,8 +23,14 @@
|
|||
%td= link_to h(format_date invoice.date), finance_invoice_path(invoice)
|
||||
%td= format_date invoice.paid_on
|
||||
%td= number_to_currency invoice.amount
|
||||
%td= link_to Delivery.model_name.human, [invoice.supplier,invoice.delivery] if invoice.delivery
|
||||
%td= link_to format_date(invoice.order.ends), new_finance_order_path(order_id: invoice.order_id) if invoice.order
|
||||
%td><
|
||||
- invoice.deliveries.each_with_index do |delivery, index|
|
||||
= ', ' if index > 0
|
||||
= link_to format_date(delivery.delivered_on), [delivery.supplier,delivery]
|
||||
%td><
|
||||
- invoice.orders.each_with_index do |order, index|
|
||||
= ', ' if index > 0
|
||||
= link_to format_date(order.ends), new_finance_order_path(order_id: order)
|
||||
%td= truncate(invoice.note)
|
||||
%td= link_to t('ui.edit'), edit_finance_invoice_path(invoice), class: 'btn btn-mini'
|
||||
%td= link_to t('ui.delete'), finance_invoice_path(invoice), :data => {:confirm => t('.confirm_delete')}, :method => :delete,
|
||||
|
|
|
|||
|
|
@ -10,14 +10,20 @@
|
|||
%b= heading_helper(Invoice, :supplier) + ':'
|
||||
= @invoice.supplier.name
|
||||
|
||||
- if @invoice.delivery
|
||||
- if @invoice.deliveries.count > 0
|
||||
%p
|
||||
%b= heading_helper(Invoice, :delivery) + ':'
|
||||
= t('finance.invoices.linked', what_link: link_to(t('finance.invoices.linked_delivery'), [@invoice.supplier,@invoice.delivery])).html_safe
|
||||
- if @invoice.order
|
||||
%b= heading_helper(Invoice, :deliveries) + ':'
|
||||
%span><
|
||||
- @invoice.deliveries.order(:delivered_on).each_with_index do |delivery, index|
|
||||
= ', ' if index > 0
|
||||
= link_to format_date(delivery.delivered_on), [delivery.supplier,delivery]
|
||||
- if @invoice.orders.count > 0
|
||||
%p
|
||||
%b= heading_helper(Invoice, :order) + ':'
|
||||
= t('finance.invoices.linked', what_link: link_to(t('finance.invoices.linked_order'), @invoice.order)).html_safe
|
||||
%b= heading_helper(Invoice, :orders) + ':'
|
||||
%span><
|
||||
- @invoice.orders.order(:ends).each_with_index do |order, index|
|
||||
= ', ' if index > 0
|
||||
= link_to format_date(order.ends), new_finance_order_path(order_id: order)
|
||||
|
||||
%p
|
||||
%b= heading_helper(Invoice, :number) + ':'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue