Skip to content

Commit

Permalink
Support Billing References for Credit & Debit Notes
Browse files Browse the repository at this point in the history
  • Loading branch information
obahareth committed Nov 29, 2023
1 parent 51bc541 commit 10b4370
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/zatca/ubl/invoice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class ZATCA::UBL::Invoice < ZATCA::UBL::BaseComponent
option :uuid, type: Dry::Types["coercible.string"]
option :note, type: Dry::Types["coercible.string"].optional, optional: true, default: proc {}
option :instruction_note, type: Dry::Types["coercible.string"].optional, optional: true, default: proc {}
option :billing_reference, type: Dry::Types["coercible.string"].optional, optional: true, default: proc {}
option :note_language_id, type: Dry::Types["coercible.string"].optional, optional: true, default: proc {}
option :issue_date, type: Dry::Types["coercible.string"]
option :issue_time, type: Dry::Types["coercible.string"]
Expand Down Expand Up @@ -110,6 +111,9 @@ def elements
ZATCA::UBL::BaseComponent.new(name: "cbc:DocumentCurrencyCode", value: currency_code),
ZATCA::UBL::BaseComponent.new(name: "cbc:TaxCurrencyCode", value: currency_code),

# Billing reference for debit and credit notes
billing_reference_element,

# Line Count Numeric (Standard Invoice only)
line_count_numeric_element,

Expand Down Expand Up @@ -407,6 +411,16 @@ def instruction_note_element
ZATCA::UBL::BaseComponent.new(name: "cbc:InstructionNote", value: instruction_note)
end

def billing_reference_element
return nil if billing_reference.blank?

ZATCA::UBL::BaseComponent.new(name: "cac:BillingReference", elements: [
ZATCA::UBL::BaseComponent.new(name: "cac:InvoiceDocumentReference", elements: [
ZATCA::UBL::BaseComponent.new(name: "cbc:ID", value: billing_reference)
])
])
end

def add_sequential_ids
add_sequential_ids_to_allowance_charges
add_sequential_ids_to_invoice_lines
Expand Down

0 comments on commit 10b4370

Please sign in to comment.