Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Add Gallop to your project via [Maven Central](https://central.sonatype.com/arti

```groovy
dependencies {
implementation 'de.codebarista:gallop:2.1.0'
implementation 'de.codebarista:gallop:2.2.0'
}
```

Expand All @@ -53,7 +53,7 @@ dependencies {
<dependency>
<groupId>de.codebarista</groupId>
<artifactId>gallop</artifactId>
<version>2.1.0</version>
<version>2.2.0</version>
</dependency>
```

Expand Down Expand Up @@ -154,7 +154,8 @@ public class InvoiceGenerator {
.taxTotalAmount(new BigDecimal("100.60")) // Total VAT amount
.grandTotalAmount(new BigDecimal("630.08")) // Invoice total with VAT
.paidAmount(new BigDecimal("100.00")) // Already paid amount
.duePayableAmount(new BigDecimal("530.08")) // Amount due for payment
.roundingAmount(new BigDecimal("0.02")) // Rounding amount
.duePayableAmount(new BigDecimal("530.10")) // Amount due for payment

// Sales order reference
.salesOrderReference("SO-98765");
Expand All @@ -168,6 +169,7 @@ public class InvoiceGenerator {

### Changelog

- 2.2.0: Add BT-114 (Rounding amount)
- 2.1.0: Add BT-30/BT-47 (Seller/Buyer legal registration identifier),
BT-32 (Seller tax registration identifier),
BT-33 (Seller additional legal information),
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group = 'de.codebarista'
version = '2.1.0'
version = '2.2.0'

java {
toolchain {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,11 @@ private Element createTradeSettlement(XmlDocumentBuilder builder) {
taxTotal.setTextContent(invoice.getTaxTotalAmount().toString());
sum.appendChild(taxTotal);
}
if (invoice.getRoundingAmount() != null) {
Element roundingAmount = builder.createElement(NS_RAM, "RoundingAmount"); // BT-114
roundingAmount.setTextContent(invoice.getRoundingAmount().toString());
sum.appendChild(roundingAmount);
}
Element grandTotal = builder.createElement(NS_RAM, "GrandTotalAmount"); // BT-112
if (invoice.getGrandTotalAmount() != null) {
grandTotal.setTextContent(invoice.getGrandTotalAmount().toString());
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/de/codebarista/gallop/xrechnung/model/Invoice.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ public class Invoice {
*/
private BigDecimal paidAmount;

/**
* The amount by which the grand total amount was rounded (BT-114)
*/
private BigDecimal roundingAmount;

/**
* Amount due for payment (BT-115)
*/
Expand Down Expand Up @@ -346,6 +351,14 @@ public Invoice paidAmount(BigDecimal paidAmount) {
return this;
}

/**
* Sets the {@link #roundingAmount}
*/
public Invoice roundingAmount(BigDecimal roundingAmount) {
this.roundingAmount = roundingAmount;
return this;
}

/**
* Sets the {@link #duePayableAmount}
*/
Expand Down Expand Up @@ -564,6 +577,13 @@ public BigDecimal getPaidAmount() {
return paidAmount;
}

/**
* Gets the {@link #roundingAmount}.
*/
public BigDecimal getRoundingAmount() {
return roundingAmount;
}

/**
* Gets the {@link #duePayableAmount}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ public void buildInvoice() {
.taxTotalAmount(new BigDecimal("100.60")) // Total VAT amount
.grandTotalAmount(new BigDecimal("630.08")) // Invoice total with VAT
.paidAmount(new BigDecimal("100.00")) // Already paid amount
.duePayableAmount(new BigDecimal("530.08")) // Amount due for payment
.roundingAmount(new BigDecimal("0.02")) // Rounding amount
.duePayableAmount(new BigDecimal("530.10")) // Amount due for payment

// Sales order reference
.salesOrderReference("SO-98765");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class XRechnungWriterScenariosTest {
"order_with_shipping_costs_with_multiple_taxes",
"order_with_tax_free_product",
"order_with_already_paid_amount",
"order_with_rounding_amount",
"order_without_vatid",
"order_with_legal_registration_identifiers"
})
Expand Down
122 changes: 122 additions & 0 deletions src/test/resources/invoice/order_with_rounding_amount/invoice.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
{
"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,
"roundingAmount": 0.01,
"paidAmount": 10.00,
"duePayableAmount": 10.00,
"salesOrderReference": "10000",
"invoiceNotes": [],
"allowances": [],
"charges": [
{
"netAmount": 0.00,
"vatCategory": "S",
"vatRate": 19,
"reason": "Shipping costs"
}
]
}
148 changes: 148 additions & 0 deletions src/test/resources/invoice/order_with_rounding_amount/xrechnung.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
<?xml version="1.0" encoding="UTF-8"?>
<rsm:CrossIndustryInvoice xmlns:ram="urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100"
xmlns:rsm="urn:un:unece:uncefact:data:standard:CrossIndustryInvoice:100"
xmlns:udt="urn:un:unece:uncefact:data:standard:UnqualifiedDataType:100">
<rsm:ExchangedDocumentContext>
<ram:BusinessProcessSpecifiedDocumentContextParameter>
<ram:ID>urn:fdc:peppol.eu:2017:poacc:billing:01:1.0</ram:ID>
</ram:BusinessProcessSpecifiedDocumentContextParameter>
<ram:GuidelineSpecifiedDocumentContextParameter>
<ram:ID>urn:cen.eu:en16931:2017#compliant#urn:xeinkauf.de:kosit:xrechnung_3.0</ram:ID>
</ram:GuidelineSpecifiedDocumentContextParameter>
</rsm:ExchangedDocumentContext>
<rsm:ExchangedDocument>
<ram:ID>1012</ram:ID>
<ram:TypeCode>380</ram:TypeCode>
<ram:IssueDateTime>
<udt:DateTimeString format="102">20241130</udt:DateTimeString>
</ram:IssueDateTime>
</rsm:ExchangedDocument>
<rsm:SupplyChainTradeTransaction>
<ram:IncludedSupplyChainTradeLineItem>
<ram:AssociatedDocumentLineDocument>
<ram:LineID>1</ram:LineID>
</ram:AssociatedDocumentLineDocument>
<ram:SpecifiedTradeProduct>
<ram:SellerAssignedID>10007.1</ram:SellerAssignedID>
<ram:Name>Main product with properties</ram:Name>
<ram:ApplicableProductCharacteristic>
<ram:Description>Size</ram:Description>
<ram:Value>S</ram:Value>
</ram:ApplicableProductCharacteristic>
</ram:SpecifiedTradeProduct>
<ram:SpecifiedLineTradeAgreement>
<ram:NetPriceProductTradePrice>
<ram:ChargeAmount>16.8000</ram:ChargeAmount>
<ram:BasisQuantity unitCode="XPP">1</ram:BasisQuantity>
</ram:NetPriceProductTradePrice>
</ram:SpecifiedLineTradeAgreement>
<ram:SpecifiedLineTradeDelivery>
<ram:BilledQuantity unitCode="XPP">1</ram:BilledQuantity>
</ram:SpecifiedLineTradeDelivery>
<ram:SpecifiedLineTradeSettlement>
<ram:ApplicableTradeTax>
<ram:TypeCode>VAT</ram:TypeCode>
<ram:CategoryCode>S</ram:CategoryCode>
<ram:RateApplicablePercent>19</ram:RateApplicablePercent>
</ram:ApplicableTradeTax>
<ram:SpecifiedTradeSettlementLineMonetarySummation>
<ram:LineTotalAmount>16.80</ram:LineTotalAmount>
</ram:SpecifiedTradeSettlementLineMonetarySummation>
</ram:SpecifiedLineTradeSettlement>
</ram:IncludedSupplyChainTradeLineItem>
<ram:ApplicableHeaderTradeAgreement>
<ram:BuyerReference>N/A</ram:BuyerReference>
<ram:SellerTradeParty>
<ram:Name>Example Company</ram:Name>
<ram:DefinedTradeContact>
<ram:PersonName>Kim Elliot</ram:PersonName>
<ram:TelephoneUniversalCommunication>
<ram:CompleteNumber>123456789</ram:CompleteNumber>
</ram:TelephoneUniversalCommunication>
<ram:EmailURIUniversalCommunication>
<ram:URIID>mail@company.com</ram:URIID>
</ram:EmailURIUniversalCommunication>
</ram:DefinedTradeContact>
<ram:PostalTradeAddress>
<ram:PostcodeCode>12345</ram:PostcodeCode>
<ram:LineOne>Tribute Avenue 777</ram:LineOne>
<ram:CityName>Taxora</ram:CityName>
<ram:CountryID>DE</ram:CountryID>
</ram:PostalTradeAddress>
<ram:URIUniversalCommunication>
<ram:URIID schemeID="EM">mail@company.com</ram:URIID>
</ram:URIUniversalCommunication>
<ram:SpecifiedTaxRegistration>
<ram:ID schemeID="VA">DE987654321</ram:ID>
</ram:SpecifiedTaxRegistration>
</ram:SellerTradeParty>
<ram:BuyerTradeParty>
<ram:Name>Test Test</ram:Name>
<ram:PostalTradeAddress>
<ram:PostcodeCode>11223</ram:PostcodeCode>
<ram:LineOne>Test</ram:LineOne>
<ram:CityName>Foo</ram:CityName>
<ram:CountryID>BH</ram:CountryID>
</ram:PostalTradeAddress>
<ram:URIUniversalCommunication>
<ram:URIID schemeID="EM">test@test.test</ram:URIID>
</ram:URIUniversalCommunication>
</ram:BuyerTradeParty>
<ram:SellerOrderReferencedDocument>
<ram:IssuerAssignedID>10000</ram:IssuerAssignedID>
</ram:SellerOrderReferencedDocument>
</ram:ApplicableHeaderTradeAgreement>
<ram:ApplicableHeaderTradeDelivery>
<ram:ShipToTradeParty>
<ram:Name>Test Test</ram:Name>
<ram:PostalTradeAddress>
<ram:PostcodeCode>11223</ram:PostcodeCode>
<ram:LineOne>Test</ram:LineOne>
<ram:CityName>Foo</ram:CityName>
<ram:CountryID>BH</ram:CountryID>
</ram:PostalTradeAddress>
</ram:ShipToTradeParty>
</ram:ApplicableHeaderTradeDelivery>
<ram:ApplicableHeaderTradeSettlement>
<ram:InvoiceCurrencyCode>EUR</ram:InvoiceCurrencyCode>
<ram:SpecifiedTradeSettlementPaymentMeans>
<ram:TypeCode>10</ram:TypeCode>
<ram:Information>Cash on delivery</ram:Information>
</ram:SpecifiedTradeSettlementPaymentMeans>
<ram:ApplicableTradeTax>
<ram:CalculatedAmount>3.19</ram:CalculatedAmount>
<ram:TypeCode>VAT</ram:TypeCode>
<ram:BasisAmount>16.80</ram:BasisAmount>
<ram:CategoryCode>S</ram:CategoryCode>
<ram:RateApplicablePercent>19</ram:RateApplicablePercent>
</ram:ApplicableTradeTax>
<ram:SpecifiedTradeAllowanceCharge>
<ram:ChargeIndicator>
<udt:Indicator>true</udt:Indicator>
</ram:ChargeIndicator>
<ram:ActualAmount>0.00</ram:ActualAmount>
<ram:Reason>Shipping costs</ram:Reason>
<ram:CategoryTradeTax>
<ram:TypeCode>VAT</ram:TypeCode>
<ram:CategoryCode>S</ram:CategoryCode>
<ram:RateApplicablePercent>19</ram:RateApplicablePercent>
</ram:CategoryTradeTax>
</ram:SpecifiedTradeAllowanceCharge>
<ram:SpecifiedTradePaymentTerms>
<ram:Description>Die Ware bleibt, bis zur vollständigen Bezahlung, unser Eigentum.
Leistungsdatum entspricht Rechnungsdatum</ram:Description>
</ram:SpecifiedTradePaymentTerms>
<ram:SpecifiedTradeSettlementHeaderMonetarySummation>
<ram:LineTotalAmount>16.80</ram:LineTotalAmount>
<ram:ChargeTotalAmount>0.00</ram:ChargeTotalAmount>
<ram:AllowanceTotalAmount>0.00</ram:AllowanceTotalAmount>
<ram:TaxBasisTotalAmount>16.80</ram:TaxBasisTotalAmount>
<ram:TaxTotalAmount currencyID="EUR">3.19</ram:TaxTotalAmount>
<ram:RoundingAmount>0.01</ram:RoundingAmount>
<ram:GrandTotalAmount>19.99</ram:GrandTotalAmount>
<ram:TotalPrepaidAmount>10.00</ram:TotalPrepaidAmount>
<ram:DuePayableAmount>10.00</ram:DuePayableAmount>
</ram:SpecifiedTradeSettlementHeaderMonetarySummation>
</ram:ApplicableHeaderTradeSettlement>
</rsm:SupplyChainTradeTransaction>
</rsm:CrossIndustryInvoice>
Loading