Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V0.2 billing 3.0.10 #3

Merged
merged 2 commits into from
Jun 24, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ public static Invoice norwegianExample(){
, accountingCustomerParty
, taxTotal
, legalMonetaryTotal
, invoiceLine1
).withDueDate("2013-07-20")
.withInvoiceTypeCode(380)
.withNote("Ordered in our booth at the convention.")
Expand Down Expand Up @@ -258,7 +257,8 @@ public static Invoice norwegianExample(){
, new Amount("100", "NOK")
, new TaxCategory("S", new TaxScheme("VAT")).withPercent("25")
).withAllowanceChargeReasonCode("95").withAllowanceChargeReason("Promotion discount")
).withInvoiceLine(invoiceLine2)
).withInvoiceLine(invoiceLine1)
.withInvoiceLine(invoiceLine2)
.withInvoiceLine(invoiceLine3)
.withInvoiceLine(invoiceLine4)
.withInvoiceLine(invoiceLine5)
Expand Down Expand Up @@ -349,8 +349,8 @@ public static Invoice example1(){
, accountingCustomerParty
, taxTotal
, legalMonetaryTotal
, invoiceLine
).withBuyerReference("n/a")
.withInvoiceLine(invoiceLine)
.withDueDate("2020-11-30")
.withPaymentTerms(new PaymentTerms("10 dager"))
.withDelivery(delivery)
Expand Down
21 changes: 6 additions & 15 deletions domain/src/main/java/peppol/bis/invoice3/domain/CreditNote.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@
import java.util.ArrayList;
import java.util.List;

import static java.lang.String.format;
import static peppol.bis.invoice3.domain.Namespaces.CBC_NS;

public class CreditNote extends BillingCommon<CreditNote> implements XmlRootElement, XmlElement {

private static final int UNCL1001_Commercial_invoice = 380;
public static final String CREDIT_NOTE_NAMESPACE = "urn:oasis:names:specification:ubl:schema:xsd:CreditNote-2";

private String profileID;
private String invoiceTypeCode;
private String note;
private String taxCurrencyCode;
Expand All @@ -44,9 +42,8 @@ public class CreditNote extends BillingCommon<CreditNote> implements XmlRootElem
private OriginatorDocumentReference originatorDocumentReference;
private ContractDocumentReference contractDocumentReference;
private final List<XmlElement> additionalDocumentReferences = new ArrayList<>();
private ProjectReference projectReference;
private AccountingSupplierParty accountingSupplierParty;
private AccountingCustomerParty accountingCustomerParty;
private final AccountingSupplierParty accountingSupplierParty;
private final AccountingCustomerParty accountingCustomerParty;
private PayeeParty payeeParty;
private TaxRepresentativeParty taxRepresentativeParty;
private Delivery delivery;
Expand All @@ -58,20 +55,19 @@ public class CreditNote extends BillingCommon<CreditNote> implements XmlRootElem
private final LegalMonetaryTotal legalMonetaryTotal;
private final List<XmlElement> creditNoteLines = new ArrayList<>();

public CreditNote(String id, String issueDate, String documentCurrencyCode, AccountingSupplierParty accountingSupplierParty, AccountingCustomerParty accountingCustomerParty, TaxTotal taxTotal, LegalMonetaryTotal legalMonetaryTotal, CreditNoteLine creditNoteLine) {
public CreditNote(String id, String issueDate, String documentCurrencyCode, AccountingSupplierParty accountingSupplierParty, AccountingCustomerParty accountingCustomerParty, TaxTotal taxTotal, LegalMonetaryTotal legalMonetaryTotal) {
super(id, issueDate);
this.accountingSupplierParty = accountingSupplierParty;
this.accountingCustomerParty = accountingCustomerParty;
this.legalMonetaryTotal = legalMonetaryTotal;
this.withInvoiceTypeCode(UNCL1001_Commercial_invoice);
this.documentCurrencyCode = documentCurrencyCode;
this.taxTotals.add(taxTotal);
this.creditNoteLines.add(creditNoteLine);
}

public CreditNote withProcessNumber(int processNumber) {
this.profileID = "urn:fdc:peppol.eu:2017:poacc:billing:NN:1.0".replace("NN", format("%02d", processNumber));
return this;
public CreditNote(String id, String issueDate, String documentCurrencyCode, AccountingSupplierParty accountingSupplierParty, AccountingCustomerParty accountingCustomerParty, TaxTotal taxTotal, LegalMonetaryTotal legalMonetaryTotal, List<CreditNoteLine> creditNoteLines) {
this(id, issueDate, documentCurrencyCode, accountingSupplierParty, accountingCustomerParty, taxTotal, legalMonetaryTotal);
this.creditNoteLines.addAll(creditNoteLines);
}

public CreditNote withInvoiceTypeCode(int invoiceTypeCode) {
Expand Down Expand Up @@ -144,11 +140,6 @@ public CreditNote withAdditionalDocumentReferences(AdditionalDocumentReference a
return this;
}

public CreditNote withProjectReference(ProjectReference projectReference) {
this.projectReference = projectReference;
return this;
}

public CreditNote withTaxRepresentativeParty(TaxRepresentativeParty taxRepresentativeParty) {
this.taxRepresentativeParty = taxRepresentativeParty;
return this;
Expand Down
14 changes: 8 additions & 6 deletions domain/src/main/java/peppol/bis/invoice3/domain/Invoice.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.util.ArrayList;
import java.util.List;

import static java.lang.String.format;
import static peppol.bis.invoice3.domain.Namespaces.CBC_NS;

public class Invoice extends BillingCommon<Invoice>{
Expand All @@ -46,8 +45,8 @@ public class Invoice extends BillingCommon<Invoice>{
private ContractDocumentReference contractDocumentReference;
private final List<XmlElement> additionalDocumentReferences = new ArrayList<>();
private ProjectReference projectReference;
private AccountingSupplierParty accountingSupplierParty;
private AccountingCustomerParty accountingCustomerParty;
private final AccountingSupplierParty accountingSupplierParty;
private final AccountingCustomerParty accountingCustomerParty;
private PayeeParty payeeParty;
private TaxRepresentativeParty taxRepresentativeParty;
private Delivery delivery;
Expand All @@ -58,17 +57,19 @@ public class Invoice extends BillingCommon<Invoice>{
private final LegalMonetaryTotal legalMonetaryTotal;
private final List<XmlElement> invoiceLines = new ArrayList<>();

public Invoice(String id, String issueDate, String documentCurrencyCode, AccountingSupplierParty accountingSupplierParty, AccountingCustomerParty accountingCustomerParty, TaxTotal taxTotal, LegalMonetaryTotal legalMonetaryTotal, InvoiceLine invoiceLine) {
public Invoice(String id, String issueDate, String documentCurrencyCode, AccountingSupplierParty accountingSupplierParty, AccountingCustomerParty accountingCustomerParty, TaxTotal taxTotal, LegalMonetaryTotal legalMonetaryTotal) {
super(id, issueDate);
this.accountingSupplierParty = accountingSupplierParty;
this.accountingCustomerParty = accountingCustomerParty;
this.legalMonetaryTotal = legalMonetaryTotal;
this.withInvoiceTypeCode(UNCL1001_Commercial_invoice);
this.documentCurrencyCode = documentCurrencyCode;
this.taxTotals.add(taxTotal);
this.invoiceLines.add(invoiceLine);
}

public Invoice(String id, String issueDate, String documentCurrencyCode, AccountingSupplierParty accountingSupplierParty, AccountingCustomerParty accountingCustomerParty, TaxTotal taxTotal, LegalMonetaryTotal legalMonetaryTotal, List<InvoiceLine> invoiceLines) {
this(id, issueDate, documentCurrencyCode, accountingSupplierParty, accountingCustomerParty, taxTotal, legalMonetaryTotal);
this.invoiceLines.addAll(invoiceLines);
}

public Invoice withInvoiceTypeCode(int invoiceTypeCode) {
this.invoiceTypeCode = String.valueOf(invoiceTypeCode);
Expand Down Expand Up @@ -218,6 +219,7 @@ public Element node() {
optional(this.contractDocumentReference, elm);
list(this.additionalDocumentReferences, elm);
optional(this.projectReference, elm);
optional(this.projectReference, elm);
required(this.accountingSupplierParty, elm);
required(this.accountingCustomerParty, elm);
optional(this.payeeParty, elm);
Expand Down
3 changes: 1 addition & 2 deletions domain/src/test/java/peppol/bis/invoice3/InvoiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ void setUp() {
))
, taxTotal
, legalMonetaryTotal
, invoiceLine
);
).withInvoiceLine(invoiceLine);
}

@Test
Expand Down