@@ -57,6 +57,119 @@ def make_eu_invoice(tax_category: :REVERSECHARGE)
5757 )
5858 end
5959
60+ def make_eu_invoice_with_line_item_billing_period ( tax_category : :REVERSECHARGE )
61+ seller = TradeParty . new (
62+ name : 'Depfu inc' ,
63+ street1 : 'Quickbornstr. 46' ,
64+ city : 'Hamburg' ,
65+ postal_code : '20253' ,
66+ country_id : 'DE' ,
67+ vat_id : 'DE304755032'
68+ )
69+ buyer = TradeParty . new (
70+ name : 'Depfu inc' ,
71+ street1 : 'Quickbornstr. 46' ,
72+ city : 'Hamburg' ,
73+ postal_code : '20253' ,
74+ country_id : 'SE' ,
75+ vat_id : 'SE304755032'
76+ )
77+ line_item = LineItem . new (
78+ name : 'Depfu Premium Plan' ,
79+ quantity : 1 ,
80+ gross_amount : BigDecimal ( '29' ) ,
81+ net_amount : BigDecimal ( '29' ) ,
82+ unit : :YEAR ,
83+ charge_amount : BigDecimal ( '29' ) ,
84+ tax_category : tax_category ,
85+ tax_percent : 0 ,
86+ tax_amount : 0 ,
87+ origin_country_code : 'DE' ,
88+ currency_code : 'EUR' ,
89+ service_period_start : Date . today ,
90+ service_period_end : Date . today + 364 ,
91+ )
92+ Invoice . new (
93+ id : '12345' ,
94+ issue_date : Date . today ,
95+ # service_period on line_item. removed here to simplify testing of BillingSpecifiedPeriod presence
96+ # service_period_start: Date.today,
97+ # service_period_end: Date.today + 30,
98+ seller : seller ,
99+ buyer : buyer ,
100+ line_items : [ line_item ] ,
101+ currency_code : 'USD' ,
102+ payment_type : :CREDITCARD ,
103+ payment_text : 'Kreditkarte' ,
104+ tax_category : tax_category ,
105+ tax_amount : 0 ,
106+ basis_amount : BigDecimal ( '29' ) ,
107+ grand_total_amount : BigDecimal ( '29' ) ,
108+ due_amount : 0 ,
109+ paid_amount : 29 ,
110+ payment_due_date : Date . today + 14 ,
111+ notes : "This is a test invoice" ,
112+ )
113+ end
114+
115+ def make_eu_invoice_with_sepa_direct_debit ( tax_category : :REVERSECHARGE )
116+ seller = TradeParty . new (
117+ name : 'Depfu inc' ,
118+ street1 : 'Quickbornstr. 46' ,
119+ city : 'Hamburg' ,
120+ postal_code : '20253' ,
121+ country_id : 'DE' ,
122+ vat_id : 'DE304755032'
123+ )
124+ buyer = TradeParty . new (
125+ name : 'Depfu inc' ,
126+ street1 : 'Quickbornstr. 46' ,
127+ city : 'Hamburg' ,
128+ postal_code : '20253' ,
129+ country_id : 'SE' ,
130+ vat_id : 'SE304755032'
131+ )
132+ line_item = LineItem . new (
133+ name : 'Depfu Premium Plan' ,
134+ quantity : 1 ,
135+ gross_amount : BigDecimal ( '29' ) ,
136+ net_amount : BigDecimal ( '29' ) ,
137+ unit : :YEAR ,
138+ charge_amount : BigDecimal ( '29' ) ,
139+ tax_category : tax_category ,
140+ tax_percent : 0 ,
141+ tax_amount : 0 ,
142+ origin_country_code : 'DE' ,
143+ currency_code : 'EUR' ,
144+ service_period_start : Date . today ,
145+ service_period_end : Date . today + 364 ,
146+ )
147+ Invoice . new (
148+ id : '12345' ,
149+ issue_date : Date . today ,
150+ # service_period on line_item. removed here to simplify testing of BillingSpecifiedPeriod presence
151+ # service_period_start: Date.today,
152+ # service_period_end: Date.today + 30,
153+ seller : seller ,
154+ buyer : buyer ,
155+ line_items : [ line_item ] ,
156+ currency_code : 'USD' ,
157+ payment_type : :CREDITCARD ,
158+ payment_text : 'Kreditkarte' ,
159+ tax_category : tax_category ,
160+ tax_amount : 0 ,
161+ basis_amount : BigDecimal ( '29' ) ,
162+ grand_total_amount : BigDecimal ( '29' ) ,
163+ due_amount : 0 ,
164+ paid_amount : 29 ,
165+ payment_due_date : Date . today + 14 ,
166+ notes : "This is a test invoice" ,
167+ direct_debit_mandate_reference_id : "MANDATE REFERENCE" , # BT-89
168+ direct_debit_creditor_id : "DE98ZZZ09999999999" , # BT-90
169+ direct_debit_iban : "DE02120300000000202051" , # BT-91
170+ )
171+ end
172+
60173 def make_foreign_invoice ( tax_category : :TAXEXEMPT )
61174 seller = TradeParty . new (
62175 name : 'Depfu inc' ,
@@ -381,6 +494,31 @@ def test_simple_eu_invoice_v2
381494 puts e . errors
382495 end
383496
497+ def test_simple_eu_invoice_v2_with_line_item_billing_period
498+ begin
499+ xml = make_eu_invoice_with_line_item_billing_period . to_xml ( version : 2 )
500+ rescue ValidationError => e
501+ pp e . errors
502+ end
503+
504+ assert_match ( /<ram:CategoryCode>AE<\/ ram:CategoryCode>/ , xml )
505+ assert_match ( /<ram:ExemptionReason>Reverse Charge<\/ ram:ExemptionReason>/ , xml )
506+ assert_match ( /<ram:RateApplicablePercent>/ , xml )
507+ assert_match ( /<ram:BillingSpecifiedPeriod>/ , xml )
508+
509+ v = Validator . new ( xml , version : 2 )
510+ errors = v . validate_against_schema
511+ if !errors . empty?
512+ puts xml
513+ errors . each do |error |
514+ puts error
515+ end
516+ end
517+ assert_equal [ ] , errors
518+ rescue ValidationError => e
519+ puts e . errors
520+ end
521+
384522 def test_simple_foreign_invoice_v2_taxexpempt
385523 begin
386524 xml = make_foreign_invoice ( tax_category : :TAXEXEMPT ) . to_xml ( version : 2 )
0 commit comments