mirror of
https://github.com/internetee/registry.git
synced 2025-08-02 07:52:04 +02:00
Fully implemented prepayment Directo invoice forwarding, WIP on proformas
This commit is contained in:
parent
faeb50cad5
commit
d5662f42b8
10 changed files with 249 additions and 337 deletions
|
@ -102,6 +102,22 @@ class Invoice < ApplicationRecord
|
|||
generator.generate
|
||||
end
|
||||
|
||||
def as_directo_json
|
||||
inv = ActiveSupport::JSON.decode(ActiveSupport::JSON.encode(self))
|
||||
inv['customer_code'] = buyer.accounting_customer_code
|
||||
inv['issue_date'] = issue_date.strftime('%Y-%m-%d')
|
||||
inv['transaction_date'] = account_activity.bank_transaction&.paid_at&.strftime('%Y-%m-%d')
|
||||
inv['language'] = buyer.language
|
||||
inv['invoice_lines'] = [{
|
||||
'product_id': Setting.directo_receipt_product_name,
|
||||
'description': order,
|
||||
'quantity': 1,
|
||||
'price': ActionController::Base.helpers.number_with_precision(subtotal, precision: 2, separator: ".")
|
||||
}].as_json
|
||||
|
||||
inv
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def apply_default_buyer_vat_no
|
||||
|
@ -111,4 +127,4 @@ class Invoice < ApplicationRecord
|
|||
def calculate_total
|
||||
self.total = subtotal + vat_amount
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue