Skip to content

Commit

Permalink
fix: tarif usage issues
Browse files Browse the repository at this point in the history
  • Loading branch information
diegosteiner committed Jan 3, 2024
1 parent 8975530 commit 889020b
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions app/domain/booking_states/payment_due.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ def self.to_sym
invoice = booking.invoices.sent.kept.unsettled.ordered.last
next if invoice.blank?

payable_until = invoice.payable_until + booking.organisation.settings.payment_overdue_deadline
payable_until = invoice.payable_until&.+(booking.organisation.settings.payment_overdue_deadline)
postponable_for = booking.organisation.settings.deadline_postponable_for
booking.deadlines.create(at: payable_until, postponable_for:) unless booking.deadline
booking.deadlines.create(at: payable_until, postponable_for:) if payable_until.present? && !booking.deadline
end

infer_transition(to: :payment_overdue) do |booking|
Expand Down
2 changes: 1 addition & 1 deletion app/models/tarifs/price.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Price < Tarif
Tarif.register_subtype self

def unit
organisation.currency
super || organisation.currency
end

def breakdown(usage)
Expand Down
3 changes: 2 additions & 1 deletion app/services/export/pdf/contract_pdf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ def tarif_table_data
[[Tarif.model_name.human, Tarif.human_attribute_name(:unit), Tarif.human_attribute_name(:price_per_unit)]] +
@contract.usages.map do |usage|
tarif = usage.tarif
[tarif.label, tarif.unit, number_to_currency(usage.price_per_unit || 0, unit: @organisation.currency)]
price_per_unit = usage.price_per_unit || usage.price || 0
[tarif.label, tarif.unit, number_to_currency(price_per_unit, unit: @organisation.currency)]
end
end
end
Expand Down
5 changes: 2 additions & 3 deletions app/views/manage/invoices/index.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,8 @@
- unless invoice.is_a?(Invoices::LateNotice)
= link_to new_manage_booking_invoice_path(invoice.booking, invoice: { type: Invoices::LateNotice, supersede_invoice_id: invoice.to_param }), class: 'btn btn-default' do
= Invoices::LateNotice.model_name.human
- unless invoice.sent?
= link_to edit_manage_invoice_path(invoice), class: 'btn btn-default' do
span.fa.fa-edit
= link_to edit_manage_invoice_path(invoice), class: "btn btn-default #{invoice.sent? ? 'disabled text-muted' : ''} border-0 p-2" do
span.fa.fa-edit
= link_to manage_invoice_path(invoice), data: { confirm: t(:confirm) }, method: :delete, class: 'btn btn-default' do
span.fa.fa-trash

Expand Down
2 changes: 1 addition & 1 deletion app/views/manage/occupancies/index.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ h1.m-0= Occupancy.model_name.human(count: 2)
= link_to manage_occupancy_path(occupancy), data: { confirm: t(:confirm) }, method: :delete, class: 'btn btn-default' , title: t(:destroy) do
span.fa.fa-trash
- else
button.btn.btn-default[disabled]
button.btn.btn-default.border-0.text-muted[disabled]
span.fa.fa-trash

br
Expand Down

0 comments on commit 889020b

Please sign in to comment.