mirror of
https://github.com/internetee/registry.git
synced 2025-08-01 23:42:04 +02:00
Fix admin invoices CSV output
This commit is contained in:
parent
f44bdd1930
commit
7d79e6528d
4 changed files with 41 additions and 1 deletions
|
@ -117,6 +117,23 @@ class Invoice < ApplicationRecord
|
|||
e_invoice_sent_at.present?
|
||||
end
|
||||
|
||||
def as_csv_row
|
||||
[
|
||||
number,
|
||||
buyer,
|
||||
cancelled? ? I18n.t(:cancelled) : due_date,
|
||||
receipt_date_status,
|
||||
issue_date,
|
||||
total,
|
||||
currency,
|
||||
seller_name
|
||||
]
|
||||
end
|
||||
|
||||
def self.csv_header
|
||||
['Number', 'Buyer', 'Due Date', 'Receipt Date', 'Issue Date', 'Total', 'Currency', 'Seller Name'].freeze
|
||||
end
|
||||
|
||||
def self.create_from_transaction!(transaction)
|
||||
registrar_user = Registrar.find_by(reference_no: transaction.parsed_ref_number)
|
||||
return unless registrar_user
|
||||
|
@ -128,6 +145,16 @@ class Invoice < ApplicationRecord
|
|||
|
||||
private
|
||||
|
||||
def receipt_date_status
|
||||
if paid?
|
||||
receipt_date
|
||||
elsif cancelled?
|
||||
I18n.t(:cancelled)
|
||||
else
|
||||
I18n.t(:unpaid)
|
||||
end
|
||||
end
|
||||
|
||||
def apply_default_buyer_vat_no
|
||||
self.buyer_vat_no = buyer.vat_no
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue