@@ -17,11 +18,50 @@ public class SellerOrBuyer { */ private String tradingName; + /** + * Seller/Buyer legal registration identifier (BT-30/BT-47) + *
+ * An identifier issued by an official registration authority that identifies the seller/buyer + * as a legal entity or legal person. + */ + private String legalRegistrationIdentifier; + + /** + * Seller/Buyer legal registration identifier scheme for (BT-30/BT-47) + *
+ * A code from ISO/IEC 17 6523 + * that describes the schema/type of the legal registration identifier. + *
+ * No schema is set for BT-30 if this is null or empty. + */ + private String legalRegistrationIdentifierScheme; + /** * Seller/Buyer VAT identifier (BT-31/BT-48) */ private String vatId; + /** + * Seller tax registration identifier (BT-32) + *
+ * A local tax identification of the seller (determined by their address) + * or a reference to their registered tax status. + * (If applicable, the indication "reverse charge" or the VAT exemption of + * the invoice issuer should be entered here.) + *
+ * Usually the Tax-ID. + *
+ * Only necessary if VAT identifier (BT-31) is not present. + */ + private String sellerTaxRegistrationIdentifier; + + /** + * Seller additional legal information (BT-33) + *
+ * Additional legal information that is relevant for the seller (such as share capital).
+ */
+ private String sellerAdditionalLegalInfo;
+
/**
* Seller/Buyer electronic address (BT-34/BT-49)
*/
@@ -89,6 +129,38 @@ public SellerOrBuyer vatId(String vatId) {
return this;
}
+ /**
+ * Sets the {@link #sellerTaxRegistrationIdentifier}.
+ */
+ public SellerOrBuyer sellerTaxRegistrationIdentifier(String taxId) {
+ this.sellerTaxRegistrationIdentifier = taxId;
+ return this;
+ }
+
+ /**
+ * Sets the {@link #legalRegistrationIdentifier}.
+ */
+ public SellerOrBuyer legalRegistrationIdentifier(String legalRegistrationIdentifier) {
+ this.legalRegistrationIdentifier = legalRegistrationIdentifier;
+ return this;
+ }
+
+ /**
+ * Sets the {@link #legalRegistrationIdentifierScheme}.
+ */
+ public SellerOrBuyer legalRegistrationIdentifierScheme(String legalRegistrationIdentifierScheme) {
+ this.legalRegistrationIdentifierScheme = legalRegistrationIdentifierScheme;
+ return this;
+ }
+
+ /**
+ * Sets the {@link #sellerAdditionalLegalInfo}.
+ */
+ public SellerOrBuyer sellerAdditionalLegalInfo(String info) {
+ this.sellerAdditionalLegalInfo = info;
+ return this;
+ }
+
/**
* Sets the {@link #electronicAddress}.
*/
@@ -142,6 +214,34 @@ public String getVatId() {
return vatId;
}
+ /**
+ * Gets the {@link #sellerTaxRegistrationIdentifier}
+ */
+ public String getSellerTaxRegistrationIdentifier() {
+ return sellerTaxRegistrationIdentifier;
+ }
+
+ /**
+ * Gets the {@link #legalRegistrationIdentifier}
+ */
+ public String getLegalRegistrationIdentifier() {
+ return legalRegistrationIdentifier;
+ }
+
+ /**
+ * Gets the {@link #legalRegistrationIdentifierScheme}
+ */
+ public String getLegalRegistrationIdentifierScheme() {
+ return legalRegistrationIdentifierScheme;
+ }
+
+ /**
+ * Gets the {@link #sellerAdditionalLegalInfo}
+ */
+ public String getSellerAdditionalLegalInfo() {
+ return sellerAdditionalLegalInfo;
+ }
+
/**
* Gets the {@link #electronicAddress}.
*/
diff --git a/src/test/java/de/codebarista/gallop/xrechnung/BuildInvoiceTest.java b/src/test/java/de/codebarista/gallop/xrechnung/BuildInvoiceTest.java
index 208a510..1fd128d 100644
--- a/src/test/java/de/codebarista/gallop/xrechnung/BuildInvoiceTest.java
+++ b/src/test/java/de/codebarista/gallop/xrechnung/BuildInvoiceTest.java
@@ -116,7 +116,8 @@ public void buildInvoice() {
.taxBasisTotalAmount(new BigDecimal("529.48")) // Tax basis total
.taxTotalAmount(new BigDecimal("100.60")) // Total VAT amount
.grandTotalAmount(new BigDecimal("630.08")) // Invoice total with VAT
- .duePayableAmount(new BigDecimal("630.08")) // Amount due for payment
+ .paidAmount(new BigDecimal("100.00")) // Already paid amount
+ .duePayableAmount(new BigDecimal("530.08")) // Amount due for payment
// Sales order reference
.salesOrderReference("SO-98765");
diff --git a/src/test/java/de/codebarista/gallop/xrechnung/XRechnungWriterScenariosTest.java b/src/test/java/de/codebarista/gallop/xrechnung/XRechnungWriterScenariosTest.java
index 471cb34..6a8c28e 100644
--- a/src/test/java/de/codebarista/gallop/xrechnung/XRechnungWriterScenariosTest.java
+++ b/src/test/java/de/codebarista/gallop/xrechnung/XRechnungWriterScenariosTest.java
@@ -48,7 +48,10 @@ public class XRechnungWriterScenariosTest {
"order_with_paypal_direct_debit",
"order_with_paypal_invoice",
"order_with_shipping_costs_with_multiple_taxes",
- "order_with_tax_free_product"
+ "order_with_tax_free_product",
+ "order_with_already_paid_amount",
+ "order_without_vatid",
+ "order_with_legal_registration_identifiers"
})
public void writeXRechnung(String testFile) throws ParserConfigurationException, TransformerException {
TestHelper testHelper = new TestHelper("invoice");
diff --git a/src/test/resources/invoice/order_with_already_paid_amount/invoice.json b/src/test/resources/invoice/order_with_already_paid_amount/invoice.json
new file mode 100644
index 0000000..e255e57
--- /dev/null
+++ b/src/test/resources/invoice/order_with_already_paid_amount/invoice.json
@@ -0,0 +1,121 @@
+{
+ "documentTypeCode": "380",
+ "documentId": "1012",
+ "leitwegId": null,
+ "currency": "EUR",
+ "paymentInstructions": {
+ "meansType": "10",
+ "meansText": "Cash on delivery",
+ "remittanceInfo": null,
+ "paymentTerms": "Die Ware bleibt, bis zur vollständigen Bezahlung, unser Eigentum.\nLeistungsdatum entspricht Rechnungsdatum",
+ "creditTransfers": [],
+ "paymentCardInformation": null,
+ "directDebit": null
+ },
+ "issueDate": "2024-11-30T13:12:11.781+00:00",
+ "seller": {
+ "name": "Example Company",
+ "tradingName": "Examply Company Doing Things",
+ "vatId": "DE987654321",
+ "electronicAddress": "mail@company.com",
+ "electronicAddressScheme": "EM",
+ "address": {
+ "addressLineOne": "Tribute Avenue 777",
+ "addressLineTwo": null,
+ "addressLineThree": null,
+ "city": "Taxora",
+ "zipCode": "12345",
+ "countryIsoCode": "DE"
+ },
+ "contact": {
+ "name": "Kim Elliot",
+ "phone": "123456789",
+ "email": "mail@company.com"
+ }
+ },
+ "buyer": {
+ "name": "Test Test",
+ "tradingName": null,
+ "vatId": null,
+ "electronicAddress": "test@test.test",
+ "electronicAddressScheme": null,
+ "address": {
+ "addressLineOne": "Test",
+ "addressLineTwo": null,
+ "addressLineThree": null,
+ "city": "Foo",
+ "zipCode": "11223",
+ "countryIsoCode": "BH"
+ },
+ "contact": null
+ },
+ "deliveryInfo": {
+ "name": "Test Test",
+ "deliveryAddress": {
+ "addressLineOne": "Test",
+ "addressLineTwo": null,
+ "addressLineThree": null,
+ "city": "Foo",
+ "zipCode": "11223",
+ "countryIsoCode": "BH"
+ },
+ "actualDeliveryDate": null
+ },
+ "items": [
+ {
+ "id": 1,
+ "quantity": 1,
+ "unitCode": "XPP",
+ "itemTotalNetAmount": 16.80,
+ "name": "Main product with properties",
+ "description": null,
+ "unitPrice": 16.8000,
+ "vat": {
+ "rate": 19,
+ "category": "S",
+ "taxableAmount": null,
+ "taxAmount": null,
+ "vatExemptionReasonText": null,
+ "vatExemptionReasonCode": null
+ },
+ "sellerAssignedId": "10007.1",
+ "itemAttributes": [
+ {
+ "name": "Size",
+ "value": "S"
+ }
+ ],
+ "netAmount": 16.80
+ }
+ ],
+ "vatTotals": [
+ {
+ "rate": 19,
+ "category": "S",
+ "taxableAmount": 16.80,
+ "taxAmount": 3.19,
+ "vatExemptionReasonText": null,
+ "vatExemptionReasonCode": null
+ }
+ ],
+ "precedingInvoiceReferences": [],
+ "lineTotalAmount": 16.80,
+ "allowanceTotalAmount": 0.00,
+ "chargeTotalAmount": 0.00,
+ "taxBasisTotalAmount": 16.80,
+ "taxTotalAmount": 3.19,
+ "grandTotalAmount": 19.99,
+ "paidAmount": 9.99,
+ "duePayableAmount": 10.00,
+ "salesOrderReference": "10000",
+ "invoiceNotes": [],
+ "allowances": [],
+ "charges": [
+ {
+ "netAmount": 0.00,
+ "vatCategory": "S",
+ "vatRate": 19,
+ "reason": "Shipping costs"
+ }
+ ]
+}
diff --git a/src/test/resources/invoice/order_with_already_paid_amount/xrechnung.xml b/src/test/resources/invoice/order_with_already_paid_amount/xrechnung.xml
new file mode 100644
index 0000000..77e25c7
--- /dev/null
+++ b/src/test/resources/invoice/order_with_already_paid_amount/xrechnung.xml
@@ -0,0 +1,147 @@
+
+