mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-30 21:27:17 +00:00
Make sure that adjustments for billable periods have a valid order to attach to when creating/updating
This commit is contained in:
@@ -38,7 +38,7 @@ class UpdateAccountInvoices
|
||||
oldest_enterprise = billable_periods.first.enterprise
|
||||
address = oldest_enterprise.address.dup
|
||||
first, space, last = (oldest_enterprise.contact || "").partition(' ')
|
||||
address.update_attributes(phone: oldest_enterprise.phone || "none")
|
||||
address.update_attributes(phone: oldest_enterprise.phone) if oldest_enterprise.phone.present?
|
||||
address.update_attributes(firstname: first, lastname: last) if first.present? && last.present?
|
||||
account_invoice.order.update_attributes(bill_address: address, ship_address: address)
|
||||
end
|
||||
|
||||
@@ -44,6 +44,7 @@ class BillablePeriod < ActiveRecord::Base
|
||||
def ensure_correct_adjustment_for(invoice)
|
||||
if adjustment
|
||||
# adjustment.originator = enterprise.package
|
||||
adjustment.adjustable = invoice
|
||||
adjustment.update_attributes( label: adjustment_label, amount: bill )
|
||||
else
|
||||
self.adjustment = invoice.adjustments.new( adjustment_attrs, :without_protection => true )
|
||||
|
||||
Reference in New Issue
Block a user