Skip to content

Commit

Permalink
Apply "internal reference" as buyer reference in standard profile, an…
Browse files Browse the repository at this point in the history
…d only override in XRechnung profile if custom field is defined (Z#23104892) (#7)

* Apply "internal reference" as buyer reference in standard profile, and only override in XRechnung profile if custom field is defined

* Fix failing tests
  • Loading branch information
raphaelm authored Feb 6, 2025
1 parent 49f72cb commit a0d16f5
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pretix_zugferd/invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ def _zugferd_generate_document(self, invoice):
doc.header.notes.add(note)

if invoice.internal_reference:
doc.trade.agreement.buyer_reference = invoice.internal_reference
note = IncludedNote()
note.content.add(
pgettext("invoice", "Customer reference: {reference}").format(
Expand Down Expand Up @@ -504,5 +505,6 @@ class Modern1ZugferdXRechnungInvoiceRenderer(ZugferdMixin, Modern1Renderer):

def _zugferd_generate_document(self, invoice):
doc = super()._zugferd_generate_document(invoice)
doc.trade.agreement.buyer_reference = invoice.custom_field or "unknown"
if self.event.settings.invoice_address_custom_field:
doc.trade.agreement.buyer_reference = invoice.custom_field or "unknown"
return doc
1 change: 1 addition & 0 deletions tests/results/cancellation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Attendee: Peter</ram:Description>
</ram:SpecifiedLineTradeSettlement>
</ram:IncludedSupplyChainTradeLineItem>
<ram:ApplicableHeaderTradeAgreement>
<ram:BuyerReference>PO-12345</ram:BuyerReference>
<ram:SellerTradeParty>
<ram:Name>Musterfirma</ram:Name>
<ram:PostalTradeAddress>
Expand Down
1 change: 1 addition & 0 deletions tests/results/default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Attendee: Peter</ram:Description>
</ram:SpecifiedLineTradeSettlement>
</ram:IncludedSupplyChainTradeLineItem>
<ram:ApplicableHeaderTradeAgreement>
<ram:BuyerReference>PO-12345</ram:BuyerReference>
<ram:SellerTradeParty>
<ram:Name>Musterfirma</ram:Name>
<ram:PostalTradeAddress>
Expand Down
1 change: 1 addition & 0 deletions tests/results/delivery_date_off.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Attendee: Peter</ram:Description>
</ram:SpecifiedLineTradeSettlement>
</ram:IncludedSupplyChainTradeLineItem>
<ram:ApplicableHeaderTradeAgreement>
<ram:BuyerReference>PO-12345</ram:BuyerReference>
<ram:SellerTradeParty>
<ram:Name>Musterfirma</ram:Name>
<ram:PostalTradeAddress>
Expand Down
1 change: 1 addition & 0 deletions tests/results/paid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Attendee: Peter</ram:Description>
</ram:SpecifiedLineTradeSettlement>
</ram:IncludedSupplyChainTradeLineItem>
<ram:ApplicableHeaderTradeAgreement>
<ram:BuyerReference>PO-12345</ram:BuyerReference>
<ram:SellerTradeParty>
<ram:Name>Musterfirma</ram:Name>
<ram:PostalTradeAddress>
Expand Down
1 change: 1 addition & 0 deletions tests/results/tax_code_exempt.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Attendee: Peter</ram:Description>
</ram:SpecifiedLineTradeSettlement>
</ram:IncludedSupplyChainTradeLineItem>
<ram:ApplicableHeaderTradeAgreement>
<ram:BuyerReference>PO-12345</ram:BuyerReference>
<ram:SellerTradeParty>
<ram:Name>Musterfirma</ram:Name>
<ram:PostalTradeAddress>
Expand Down
1 change: 1 addition & 0 deletions tests/results/tax_code_guess_AU.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Attendee: Peter</ram:Description>
</ram:SpecifiedLineTradeSettlement>
</ram:IncludedSupplyChainTradeLineItem>
<ram:ApplicableHeaderTradeAgreement>
<ram:BuyerReference>PO-12345</ram:BuyerReference>
<ram:SellerTradeParty>
<ram:Name>Musterfirma</ram:Name>
<ram:PostalTradeAddress>
Expand Down
1 change: 1 addition & 0 deletions tests/results/tax_code_reverse_charge.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Attendee: Peter</ram:Description>
</ram:SpecifiedLineTradeSettlement>
</ram:IncludedSupplyChainTradeLineItem>
<ram:ApplicableHeaderTradeAgreement>
<ram:BuyerReference>PO-12345</ram:BuyerReference>
<ram:SellerTradeParty>
<ram:Name>Musterfirma</ram:Name>
<ram:PostalTradeAddress>
Expand Down

0 comments on commit a0d16f5

Please sign in to comment.