import ch.codeblock.qrinvoice.model.QrInvoice;
import ch.codeblock.qrinvoice.model.builder.QrInvoiceBuilder;
import ch.codeblock.qrinvoice.model.validation.ValidationException;
import ch.codeblock.qrinvoice.model.validation.ValidationResult;
import ch.codeblock.qrinvoice.model.billinformation.swicos1v12.SwicoS1v12;
import ch.codeblock.qrinvoice.model.billinformation.swicos1v12.builder.PaymentConditionBuilder;
import ch.codeblock.qrinvoice.model.billinformation.swicos1v12.builder.SwicoS1v12Builder;
import ch.codeblock.qrinvoice.model.billinformation.swicos1v12.builder.VatDetailsBuilder;
// ...
try {
final SwicoS1v12 s1 = SwicoS1v12Builder
.create()
.invoiceReference("10201409") // Tag 10 - any string
.invoiceDate(LocalDate.of(19, 5, 12)) // Tag 11 - 12.05.2019
.customerReference("1400.000-53") // Tag 20 - any string
.uidNumber("106017086") // Tag 30 - UID-Nr. without pre- and suffix or delimiteres - CHE-106.017.086 MWST
.vatDateStart(LocalDate.of(2018,5,8)) // Tag 31 - 08.05.2018
.vatDetails(
// Tag 32 - 7.7% VAT
VatDetailsBuilder.create().taxPercentage(7.7).build()
)
.paymentConditions(
// Tag 40 - 2% cash discount when payed within 10 days (2% skonto), afterwards 0% and amount payable within 30 days
PaymentConditionBuilder.create().cashDiscountPercentage(2).eligablePaymentPeriodDays(10).build(),
PaymentConditionBuilder.create().cashDiscountPercentage(0).eligablePaymentPeriodDays(30).build()
)
.build();
// contains: "//S1/10/10201409/11/190512/20/1400.000-53/30/106017086/31/180508/32/7.7/40/2:10;0:30"
final String swicoBillInformation = s1.toBillInformationString();
final QrInvoice qrInvoice = QrInvoiceBuilder
.create()
// ..
.additionalInformation(a -> a
.billInformation(swicoBillInformation)
)
.build();
} catch (ValidationException validationException) {
final ValidationResult validationResult = validationException.getValidationResult();
// handle exception...
}