Skip to content

Commit 55b8fb0

Browse files
committed
add new information elements and NetAmount#getVatCategory
- BT-30/BT-47 (Seller/Buyer legal registration identifier) - BT-32 (Seller tax registration identifier) - BT-33 (Seller additional legal information) - BT-113 (Paid amount)
1 parent 3ca5de3 commit 55b8fb0

17 files changed

Lines changed: 1008 additions & 10 deletions

File tree

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Add Gallop to your project via [Maven Central](https://central.sonatype.com/arti
4242

4343
```groovy
4444
dependencies {
45-
implementation 'de.codebarista:gallop:2.0.0'
45+
implementation 'de.codebarista:gallop:2.1.0'
4646
}
4747
```
4848

@@ -53,7 +53,7 @@ dependencies {
5353
<dependency>
5454
<groupId>de.codebarista</groupId>
5555
<artifactId>gallop</artifactId>
56-
<version>2.0.0</version>
56+
<version>2.1.0</version>
5757
</dependency>
5858
```
5959

@@ -153,7 +153,8 @@ public class InvoiceGenerator {
153153
.taxBasisTotalAmount(new BigDecimal("529.48")) // Tax basis total
154154
.taxTotalAmount(new BigDecimal("100.60")) // Total VAT amount
155155
.grandTotalAmount(new BigDecimal("630.08")) // Invoice total with VAT
156-
.duePayableAmount(new BigDecimal("630.08")) // Amount due for payment
156+
.paidAmount(new BigDecimal("100.00")) // Already paid amount
157+
.duePayableAmount(new BigDecimal("530.08")) // Amount due for payment
157158

158159
// Sales order reference
159160
.salesOrderReference("SO-98765");
@@ -167,6 +168,11 @@ public class InvoiceGenerator {
167168

168169
### Changelog
169170

171+
- 2.1.0: Add BT-30/BT-47 (Seller/Buyer legal registration identifier),
172+
BT-32 (Seller tax registration identifier),
173+
BT-33 (Seller additional legal information),
174+
BT-113 (Paid amount)
175+
and `NetAmount#getVatCategory`
170176
- 2.0.0: Gallop no longer relies on lombok, introduce fluent api
171177
- 1.0.1: Add action to publish to maven central
172178
- 1.0.0: Initial version

build.gradle

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ plugins {
77
}
88

99
group = 'de.codebarista'
10-
version = '2.0.0'
10+
version = '2.1.0'
11+
12+
java {
13+
toolchain {
14+
languageVersion = JavaLanguageVersion.of(17)
15+
}
16+
}
1117

1218
repositories {
1319
mavenCentral()
@@ -59,7 +65,11 @@ mavenPublishing {
5965
}
6066

6167
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL)
62-
signAllPublications()
68+
69+
// Only sign if publishing to Maven Central (not for local)
70+
if (project.hasProperty("signing.keyId")) {
71+
signAllPublications()
72+
}
6373
}
6474

6575
tasks.register('printVersion') {

src/main/java/de/codebarista/gallop/xrechnung/XRechnungWriter.java

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,19 +220,41 @@ private Element createTradeHeader(XmlDocumentBuilder builder) {
220220
Element seller = builder.createElement(NS_RAM, "SellerTradeParty");
221221
tradeHeader.appendChild(seller);
222222
seller.appendChild(createName(builder, sellerInfo.getName()));
223+
if (XRechnungUtils.isNotNullOrBlank(sellerInfo.getSellerAdditionalLegalInfo())) {
224+
seller.appendChild(createDescription(builder, sellerInfo.getSellerAdditionalLegalInfo()));
225+
}
226+
if (XRechnungUtils.isNotNullOrBlank(sellerInfo.getLegalRegistrationIdentifier())) {
227+
Element specifiedLegalOrganization = builder.createElement(NS_RAM, "SpecifiedLegalOrganization");
228+
specifiedLegalOrganization.appendChild(
229+
createID(builder,
230+
sellerInfo.getLegalRegistrationIdentifier(),
231+
sellerInfo.getLegalRegistrationIdentifierScheme()));
232+
seller.appendChild(specifiedLegalOrganization);
233+
}
223234
seller.appendChild(createTradeContact(builder, sellerInfo.getContact()));
224235
seller.appendChild(createAddress(builder, sellerInfo.getAddress()));
225236
seller.appendChild(createElectronicAddressEmailElement(builder, sellerInfo.getElectronicAddress()));
226237
if (XRechnungUtils.isNotNullOrBlank(sellerInfo.getVatId())) {
227238
seller.appendChild(createTaxRegistration(builder, "VA", sellerInfo.getVatId()));
228239
}
240+
if (XRechnungUtils.isNotNullOrBlank(sellerInfo.getSellerTaxRegistrationIdentifier())) {
241+
seller.appendChild(createTaxRegistration(builder, "FC", sellerInfo.getSellerTaxRegistrationIdentifier()));
242+
}
229243
}
230244

231245
SellerOrBuyer buyerInfo = invoice.getBuyer();
232246
if (buyerInfo != null) {
233247
Element buyer = builder.createElement(NS_RAM, "BuyerTradeParty");
234248
tradeHeader.appendChild(buyer);
235249
buyer.appendChild(createName(builder, buyerInfo.getName()));
250+
if (XRechnungUtils.isNotNullOrBlank(buyerInfo.getLegalRegistrationIdentifier())) {
251+
Element specifiedLegalOrganization = builder.createElement(NS_RAM, "SpecifiedLegalOrganization");
252+
specifiedLegalOrganization.appendChild(
253+
createID(builder,
254+
buyerInfo.getLegalRegistrationIdentifier(),
255+
buyerInfo.getLegalRegistrationIdentifierScheme()));
256+
buyer.appendChild(specifiedLegalOrganization);
257+
}
236258
buyer.appendChild(createAddress(builder, buyerInfo.getAddress()));
237259
buyer.appendChild(createElectronicAddressEmailElement(builder, buyerInfo.getElectronicAddress()));
238260
if (XRechnungUtils.isNotNullOrBlank(buyerInfo.getVatId())) {
@@ -343,6 +365,11 @@ private Element createTradeSettlement(XmlDocumentBuilder builder) {
343365
grandTotal.setTextContent(invoice.getGrandTotalAmount().toString());
344366
}
345367
sum.appendChild(grandTotal);
368+
if (invoice.getPaidAmount() != null) {
369+
Element totalPrepaid = builder.createElement(NS_RAM, "TotalPrepaidAmount"); // BT-113
370+
totalPrepaid.setTextContent(invoice.getPaidAmount().toString());
371+
sum.appendChild(totalPrepaid);
372+
}
346373
Element duePayable = builder.createElement(NS_RAM, "DuePayableAmount");
347374
if (invoice.getDuePayableAmount() != null) {
348375
duePayable.setTextContent(invoice.getDuePayableAmount().toString());
@@ -472,8 +499,15 @@ private Element createCharge(XmlDocumentBuilder builder, Charge charge) {
472499
}
473500

474501
private static Element createID(XmlDocumentBuilder builder, String id) {
502+
return createID(builder, id, null);
503+
}
504+
505+
private static Element createID(XmlDocumentBuilder builder, String id, String schemeID) {
475506
Element element = builder.createElement(NS_RAM, "ID");
476507
element.setTextContent(id);
508+
if (XRechnungUtils.isNotNullOrBlank(schemeID)) {
509+
element.setAttribute("schemeID", schemeID);
510+
}
477511
return element;
478512
}
479513

@@ -506,9 +540,7 @@ private static Element createDateTimeString(XmlDocumentBuilder builder, OffsetDa
506540

507541
private static Element createTaxRegistration(XmlDocumentBuilder builder, String scheme, String id) {
508542
Element element = builder.createElement(NS_RAM, "SpecifiedTaxRegistration");
509-
Element idElement = createID(builder, id);
510-
idElement.setAttribute("schemeID", scheme);
511-
element.appendChild(idElement);
543+
element.appendChild(createID(builder, id, scheme));
512544
return element;
513545
}
514546

src/main/java/de/codebarista/gallop/xrechnung/model/Allowance.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public BigDecimal getNetAmount() {
8383
/**
8484
* Gets the {@link #vatCategory}.
8585
*/
86+
@Override
8687
public TaxCategory getVatCategory() {
8788
return vatCategory;
8889
}

src/main/java/de/codebarista/gallop/xrechnung/model/Charge.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ public BigDecimal getNetAmount() {
8080
return netAmount;
8181
}
8282

83+
@Override
8384
public TaxCategory getVatCategory() {
8485
return vatCategory;
8586
}

src/main/java/de/codebarista/gallop/xrechnung/model/Invoice.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ public class Invoice {
104104
*/
105105
private BigDecimal grandTotalAmount;
106106

107+
/**
108+
* Sum of the amount that has already been paid (BT-113)
109+
*/
110+
private BigDecimal paidAmount;
111+
107112
/**
108113
* Amount due for payment (BT-115)
109114
*/
@@ -333,6 +338,14 @@ public Invoice grandTotalAmount(BigDecimal grandTotalAmount) {
333338
return this;
334339
}
335340

341+
/**
342+
* Sets the {@link #paidAmount}
343+
*/
344+
public Invoice paidAmount(BigDecimal paidAmount) {
345+
this.paidAmount = paidAmount;
346+
return this;
347+
}
348+
336349
/**
337350
* Sets the {@link #duePayableAmount}
338351
*/
@@ -544,6 +557,13 @@ public BigDecimal getGrandTotalAmount() {
544557
return grandTotalAmount;
545558
}
546559

560+
/**
561+
* Gets the {@link #paidAmount}
562+
*/
563+
public BigDecimal getPaidAmount() {
564+
return paidAmount;
565+
}
566+
547567
/**
548568
* Gets the {@link #duePayableAmount}.
549569
*/

src/main/java/de/codebarista/gallop/xrechnung/model/Item.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,11 @@ public BigDecimal getVatRate() {
256256
return vat.getRate();
257257
}
258258

259+
@Override
260+
public TaxCategory getVatCategory() {
261+
return vat.getCategory();
262+
}
263+
259264
/**
260265
* Gets the {@link #sellerAssignedId}.
261266
*/

src/main/java/de/codebarista/gallop/xrechnung/model/NetAmount.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,9 @@ public interface NetAmount<T> {
2929
* @return the vat rate as a {@link BigDecimal}
3030
*/
3131
BigDecimal getVatRate();
32+
33+
/**
34+
* Returns the vat category.
35+
*/
36+
TaxCategory getVatCategory();
3237
}

src/main/java/de/codebarista/gallop/xrechnung/model/SellerOrBuyer.java

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,58 @@ public class SellerOrBuyer {
1010
* The official/legal name under which the seller/buyer can be found.
1111
*/
1212
private String name;
13+
1314
/**
1415
* Seller/Buyer trading name (BT-28/BT-45)
1516
* <p>
1617
* Optional name under which the seller/buyer is known if different from the official/legal name
1718
*/
1819
private String tradingName;
1920

21+
/**
22+
* Seller/Buyer legal registration identifier (BT-30/BT-47)
23+
* <p>
24+
* An identifier issued by an official registration authority that identifies the seller/buyer
25+
* as a legal entity or legal person.
26+
*/
27+
private String legalRegistrationIdentifier;
28+
29+
/**
30+
* Seller/Buyer legal registration identifier scheme for (BT-30/BT-47)
31+
* <p>
32+
* A code from <a href="https://www.xrepository.de/details/urn:xoev-de:kosit:codeliste:icd_5">ISO/IEC 17 6523</a>
33+
* that describes the schema/type of the legal registration identifier.
34+
* <p>
35+
* No schema is set for BT-30 if this is null or empty.
36+
*/
37+
private String legalRegistrationIdentifierScheme;
38+
2039
/**
2140
* Seller/Buyer VAT identifier (BT-31/BT-48)
2241
*/
2342
private String vatId;
2443

44+
/**
45+
* Seller tax registration identifier (BT-32)
46+
* <p>
47+
* A local tax identification of the seller (determined by their address)
48+
* or a reference to their registered tax status.
49+
* (If applicable, the indication "reverse charge" or the VAT exemption of
50+
* the invoice issuer should be entered here.)
51+
* <p>
52+
* Usually the Tax-ID.
53+
* <p>
54+
* Only necessary if VAT identifier (BT-31) is not present.
55+
*/
56+
private String sellerTaxRegistrationIdentifier;
57+
58+
/**
59+
* Seller additional legal information (BT-33)
60+
* <p>
61+
* Additional legal information that is relevant for the seller (such as share capital).
62+
*/
63+
private String sellerAdditionalLegalInfo;
64+
2565
/**
2666
* Seller/Buyer electronic address (BT-34/BT-49)
2767
*/
@@ -89,6 +129,38 @@ public SellerOrBuyer vatId(String vatId) {
89129
return this;
90130
}
91131

132+
/**
133+
* Sets the {@link #sellerTaxRegistrationIdentifier}.
134+
*/
135+
public SellerOrBuyer sellerTaxRegistrationIdentifier(String taxId) {
136+
this.sellerTaxRegistrationIdentifier = taxId;
137+
return this;
138+
}
139+
140+
/**
141+
* Sets the {@link #legalRegistrationIdentifier}.
142+
*/
143+
public SellerOrBuyer legalRegistrationIdentifier(String legalRegistrationIdentifier) {
144+
this.legalRegistrationIdentifier = legalRegistrationIdentifier;
145+
return this;
146+
}
147+
148+
/**
149+
* Sets the {@link #legalRegistrationIdentifierScheme}.
150+
*/
151+
public SellerOrBuyer legalRegistrationIdentifierScheme(String legalRegistrationIdentifierScheme) {
152+
this.legalRegistrationIdentifierScheme = legalRegistrationIdentifierScheme;
153+
return this;
154+
}
155+
156+
/**
157+
* Sets the {@link #sellerAdditionalLegalInfo}.
158+
*/
159+
public SellerOrBuyer sellerAdditionalLegalInfo(String info) {
160+
this.sellerAdditionalLegalInfo = info;
161+
return this;
162+
}
163+
92164
/**
93165
* Sets the {@link #electronicAddress}.
94166
*/
@@ -142,6 +214,34 @@ public String getVatId() {
142214
return vatId;
143215
}
144216

217+
/**
218+
* Gets the {@link #sellerTaxRegistrationIdentifier}
219+
*/
220+
public String getSellerTaxRegistrationIdentifier() {
221+
return sellerTaxRegistrationIdentifier;
222+
}
223+
224+
/**
225+
* Gets the {@link #legalRegistrationIdentifier}
226+
*/
227+
public String getLegalRegistrationIdentifier() {
228+
return legalRegistrationIdentifier;
229+
}
230+
231+
/**
232+
* Gets the {@link #legalRegistrationIdentifierScheme}
233+
*/
234+
public String getLegalRegistrationIdentifierScheme() {
235+
return legalRegistrationIdentifierScheme;
236+
}
237+
238+
/**
239+
* Gets the {@link #sellerAdditionalLegalInfo}
240+
*/
241+
public String getSellerAdditionalLegalInfo() {
242+
return sellerAdditionalLegalInfo;
243+
}
244+
145245
/**
146246
* Gets the {@link #electronicAddress}.
147247
*/

src/test/java/de/codebarista/gallop/xrechnung/BuildInvoiceTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ public void buildInvoice() {
116116
.taxBasisTotalAmount(new BigDecimal("529.48")) // Tax basis total
117117
.taxTotalAmount(new BigDecimal("100.60")) // Total VAT amount
118118
.grandTotalAmount(new BigDecimal("630.08")) // Invoice total with VAT
119-
.duePayableAmount(new BigDecimal("630.08")) // Amount due for payment
119+
.paidAmount(new BigDecimal("100.00")) // Already paid amount
120+
.duePayableAmount(new BigDecimal("530.08")) // Amount due for payment
120121

121122
// Sales order reference
122123
.salesOrderReference("SO-98765");

0 commit comments

Comments
 (0)