From 16e58bd343a028e65724cd766aaea0c96b8a01aa Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 8 Oct 2025 10:14:01 +0000 Subject: [PATCH 01/43] feat(api): api update --- .stats.yml | 4 +- .../api/models/documents/DocumentCreate.kt | 792 +++++++++++++++++- .../api/models/documents/DocumentResponse.kt | 792 +++++++++++++++++- .../documents/DocumentCreateParamsTest.kt | 9 + .../models/documents/DocumentCreateTest.kt | 9 + .../models/documents/DocumentResponseTest.kt | 9 + .../inbox/PaginatedDocumentResponseTest.kt | 9 + .../ValidateValidateJsonParamsTest.kt | 9 + .../api/services/ErrorHandlingTest.kt | 51 ++ .../api/services/ServiceParamsTest.kt | 3 + .../async/DocumentServiceAsyncTest.kt | 3 + .../async/ValidateServiceAsyncTest.kt | 3 + .../services/blocking/DocumentServiceTest.kt | 3 + .../services/blocking/ValidateServiceTest.kt | 3 + 14 files changed, 1695 insertions(+), 4 deletions(-) diff --git a/.stats.yml b/.stats.yml index 5507ef0..a8a19e1 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 24 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-6bf85ca7bc7eac16815d912ab0720537e72e39e6234b030c9c3644b3df327788.yml -openapi_spec_hash: f9ac6f267c1fde475250d7893cf966c7 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-1108f2708fdafd879e0ff7b2826977c764458d1f17420711a9cee28f80e2567f.yml +openapi_spec_hash: 70dbf05e6e7f68a238c7b79cdf9e8e6b config_hash: d627f345d2cab6590eeea9820301272e diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt index 0c51e23..2c32fa4 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt @@ -4,6 +4,7 @@ package com.e_invoice.api.models.documents import com.e_invoice.api.core.BaseDeserializer import com.e_invoice.api.core.BaseSerializer +import com.e_invoice.api.core.Enum import com.e_invoice.api.core.ExcludeMissing import com.e_invoice.api.core.JsonField import com.e_invoice.api.core.JsonMissing @@ -67,9 +68,12 @@ private constructor( private val shippingAddressRecipient: JsonField, private val state: JsonField, private val subtotal: JsonField, + private val taxCode: JsonField, private val taxDetails: JsonField>, private val totalDiscount: JsonField, private val totalTax: JsonField, + private val vatex: JsonField, + private val vatexNote: JsonField, private val vendorAddress: JsonField, private val vendorAddressRecipient: JsonField, private val vendorEmail: JsonField, @@ -167,6 +171,7 @@ private constructor( shippingAddressRecipient: JsonField = JsonMissing.of(), @JsonProperty("state") @ExcludeMissing state: JsonField = JsonMissing.of(), @JsonProperty("subtotal") @ExcludeMissing subtotal: JsonField = JsonMissing.of(), + @JsonProperty("tax_code") @ExcludeMissing taxCode: JsonField = JsonMissing.of(), @JsonProperty("tax_details") @ExcludeMissing taxDetails: JsonField> = JsonMissing.of(), @@ -174,6 +179,8 @@ private constructor( @ExcludeMissing totalDiscount: JsonField = JsonMissing.of(), @JsonProperty("total_tax") @ExcludeMissing totalTax: JsonField = JsonMissing.of(), + @JsonProperty("vatex") @ExcludeMissing vatex: JsonField = JsonMissing.of(), + @JsonProperty("vatex_note") @ExcludeMissing vatexNote: JsonField = JsonMissing.of(), @JsonProperty("vendor_address") @ExcludeMissing vendorAddress: JsonField = JsonMissing.of(), @@ -223,9 +230,12 @@ private constructor( shippingAddressRecipient, state, subtotal, + taxCode, taxDetails, totalDiscount, totalTax, + vatex, + vatexNote, vendorAddress, vendorAddressRecipient, vendorEmail, @@ -442,6 +452,14 @@ private constructor( */ fun subtotal(): Optional = subtotal.getOptional("subtotal") + /** + * Tax category code of the invoice + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun taxCode(): Optional = taxCode.getOptional("tax_code") + /** * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -460,6 +478,24 @@ private constructor( */ fun totalTax(): Optional = totalTax.getOptional("total_tax") + /** + * VATEX code list for VAT exemption reasons + * + * Agency: CEF Identifier: vatex + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun vatex(): Optional = vatex.getOptional("vatex") + + /** + * VAT exemption note of the invoice + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun vatexNote(): Optional = vatexNote.getOptional("vatex_note") + /** * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -778,6 +814,13 @@ private constructor( */ @JsonProperty("subtotal") @ExcludeMissing fun _subtotal(): JsonField = subtotal + /** + * Returns the raw JSON value of [taxCode]. + * + * Unlike [taxCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax_code") @ExcludeMissing fun _taxCode(): JsonField = taxCode + /** * Returns the raw JSON value of [taxDetails]. * @@ -803,6 +846,20 @@ private constructor( */ @JsonProperty("total_tax") @ExcludeMissing fun _totalTax(): JsonField = totalTax + /** + * Returns the raw JSON value of [vatex]. + * + * Unlike [vatex], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("vatex") @ExcludeMissing fun _vatex(): JsonField = vatex + + /** + * Returns the raw JSON value of [vatexNote]. + * + * Unlike [vatexNote], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("vatex_note") @ExcludeMissing fun _vatexNote(): JsonField = vatexNote + /** * Returns the raw JSON value of [vendorAddress]. * @@ -901,9 +958,12 @@ private constructor( private var shippingAddressRecipient: JsonField = JsonMissing.of() private var state: JsonField = JsonMissing.of() private var subtotal: JsonField = JsonMissing.of() + private var taxCode: JsonField = JsonMissing.of() private var taxDetails: JsonField>? = null private var totalDiscount: JsonField = JsonMissing.of() private var totalTax: JsonField = JsonMissing.of() + private var vatex: JsonField = JsonMissing.of() + private var vatexNote: JsonField = JsonMissing.of() private var vendorAddress: JsonField = JsonMissing.of() private var vendorAddressRecipient: JsonField = JsonMissing.of() private var vendorEmail: JsonField = JsonMissing.of() @@ -946,9 +1006,12 @@ private constructor( shippingAddressRecipient = documentCreate.shippingAddressRecipient state = documentCreate.state subtotal = documentCreate.subtotal + taxCode = documentCreate.taxCode taxDetails = documentCreate.taxDetails.map { it.toMutableList() } totalDiscount = documentCreate.totalDiscount totalTax = documentCreate.totalTax + vatex = documentCreate.vatex + vatexNote = documentCreate.vatexNote vendorAddress = documentCreate.vendorAddress vendorAddressRecipient = documentCreate.vendorAddressRecipient vendorEmail = documentCreate.vendorEmail @@ -1575,6 +1638,17 @@ private constructor( /** Alias for calling [subtotal] with `Subtotal.ofString(string)`. */ fun subtotal(string: String) = subtotal(Subtotal.ofString(string)) + /** Tax category code of the invoice */ + fun taxCode(taxCode: TaxCode) = taxCode(JsonField.of(taxCode)) + + /** + * Sets [Builder.taxCode] to an arbitrary JSON value. + * + * You should usually call [Builder.taxCode] with a well-typed [TaxCode] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } + fun taxDetails(taxDetails: List?) = taxDetails(JsonField.ofNullable(taxDetails)) /** Alias for calling [Builder.taxDetails] with `taxDetails.orElse(null)`. */ @@ -1647,6 +1721,39 @@ private constructor( /** Alias for calling [totalTax] with `TotalTax.ofString(string)`. */ fun totalTax(string: String) = totalTax(TotalTax.ofString(string)) + /** + * VATEX code list for VAT exemption reasons + * + * Agency: CEF Identifier: vatex + */ + fun vatex(vatex: Vatex?) = vatex(JsonField.ofNullable(vatex)) + + /** Alias for calling [Builder.vatex] with `vatex.orElse(null)`. */ + fun vatex(vatex: Optional) = vatex(vatex.getOrNull()) + + /** + * Sets [Builder.vatex] to an arbitrary JSON value. + * + * You should usually call [Builder.vatex] with a well-typed [Vatex] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun vatex(vatex: JsonField) = apply { this.vatex = vatex } + + /** VAT exemption note of the invoice */ + fun vatexNote(vatexNote: String?) = vatexNote(JsonField.ofNullable(vatexNote)) + + /** Alias for calling [Builder.vatexNote] with `vatexNote.orElse(null)`. */ + fun vatexNote(vatexNote: Optional) = vatexNote(vatexNote.getOrNull()) + + /** + * Sets [Builder.vatexNote] to an arbitrary JSON value. + * + * You should usually call [Builder.vatexNote] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun vatexNote(vatexNote: JsonField) = apply { this.vatexNote = vatexNote } + fun vendorAddress(vendorAddress: String?) = vendorAddress(JsonField.ofNullable(vendorAddress)) @@ -1787,9 +1894,12 @@ private constructor( shippingAddressRecipient, state, subtotal, + taxCode, (taxDetails ?: JsonMissing.of()).map { it.toImmutable() }, totalDiscount, totalTax, + vatex, + vatexNote, vendorAddress, vendorAddressRecipient, vendorEmail, @@ -1839,9 +1949,12 @@ private constructor( shippingAddressRecipient() state().ifPresent { it.validate() } subtotal().ifPresent { it.validate() } + taxCode().ifPresent { it.validate() } taxDetails().ifPresent { it.forEach { it.validate() } } totalDiscount().ifPresent { it.validate() } totalTax().ifPresent { it.validate() } + vatex().ifPresent { it.validate() } + vatexNote() vendorAddress() vendorAddressRecipient() vendorEmail() @@ -1898,9 +2011,12 @@ private constructor( (if (shippingAddressRecipient.asKnown().isPresent) 1 else 0) + (state.asKnown().getOrNull()?.validity() ?: 0) + (subtotal.asKnown().getOrNull()?.validity() ?: 0) + + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + (taxDetails.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (totalDiscount.asKnown().getOrNull()?.validity() ?: 0) + (totalTax.asKnown().getOrNull()?.validity() ?: 0) + + (vatex.asKnown().getOrNull()?.validity() ?: 0) + + (if (vatexNote.asKnown().isPresent) 1 else 0) + (if (vendorAddress.asKnown().isPresent) 1 else 0) + (if (vendorAddressRecipient.asKnown().isPresent) 1 else 0) + (if (vendorEmail.asKnown().isPresent) 1 else 0) + @@ -3765,6 +3881,182 @@ private constructor( } } + /** Tax category code of the invoice */ + class TaxCode @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val AE = of("AE") + + @JvmField val E = of("E") + + @JvmField val S = of("S") + + @JvmField val Z = of("Z") + + @JvmField val G = of("G") + + @JvmField val O = of("O") + + @JvmField val K = of("K") + + @JvmField val L = of("L") + + @JvmField val M = of("M") + + @JvmField val B = of("B") + + @JvmStatic fun of(value: String) = TaxCode(JsonField.of(value)) + } + + /** An enum containing [TaxCode]'s known values. */ + enum class Known { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + } + + /** + * An enum containing [TaxCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TaxCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + /** An enum member indicating that [TaxCode] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AE -> Value.AE + E -> Value.E + S -> Value.S + Z -> Value.Z + G -> Value.G + O -> Value.O + K -> Value.K + L -> Value.L + M -> Value.M + B -> Value.B + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + AE -> Known.AE + E -> Known.E + S -> Known.S + Z -> Known.Z + G -> Known.G + O -> Known.O + K -> Known.K + L -> Known.L + M -> Known.M + B -> Known.B + else -> throw EInvoiceInvalidDataException("Unknown TaxCode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TaxCode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TaxCode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + class TaxDetail @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -4456,6 +4748,498 @@ private constructor( } } + /** + * VATEX code list for VAT exemption reasons + * + * Agency: CEF Identifier: vatex + */ + class Vatex @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val VATEX_EU_79_C = of("VATEX-EU-79-C") + + @JvmField val VATEX_EU_132 = of("VATEX-EU-132") + + @JvmField val VATEX_EU_132_1_A = of("VATEX-EU-132-1A") + + @JvmField val VATEX_EU_132_1_B = of("VATEX-EU-132-1B") + + @JvmField val VATEX_EU_132_1_C = of("VATEX-EU-132-1C") + + @JvmField val VATEX_EU_132_1_D = of("VATEX-EU-132-1D") + + @JvmField val VATEX_EU_132_1_E = of("VATEX-EU-132-1E") + + @JvmField val VATEX_EU_132_1_F = of("VATEX-EU-132-1F") + + @JvmField val VATEX_EU_132_1_G = of("VATEX-EU-132-1G") + + @JvmField val VATEX_EU_132_1_H = of("VATEX-EU-132-1H") + + @JvmField val VATEX_EU_132_1_I = of("VATEX-EU-132-1I") + + @JvmField val VATEX_EU_132_1_J = of("VATEX-EU-132-1J") + + @JvmField val VATEX_EU_132_1_K = of("VATEX-EU-132-1K") + + @JvmField val VATEX_EU_132_1_L = of("VATEX-EU-132-1L") + + @JvmField val VATEX_EU_132_1_M = of("VATEX-EU-132-1M") + + @JvmField val VATEX_EU_132_1_N = of("VATEX-EU-132-1N") + + @JvmField val VATEX_EU_132_1_O = of("VATEX-EU-132-1O") + + @JvmField val VATEX_EU_132_1_P = of("VATEX-EU-132-1P") + + @JvmField val VATEX_EU_132_1_Q = of("VATEX-EU-132-1Q") + + @JvmField val VATEX_EU_143 = of("VATEX-EU-143") + + @JvmField val VATEX_EU_143_1_A = of("VATEX-EU-143-1A") + + @JvmField val VATEX_EU_143_1_B = of("VATEX-EU-143-1B") + + @JvmField val VATEX_EU_143_1_C = of("VATEX-EU-143-1C") + + @JvmField val VATEX_EU_143_1_D = of("VATEX-EU-143-1D") + + @JvmField val VATEX_EU_143_1_E = of("VATEX-EU-143-1E") + + @JvmField val VATEX_EU_143_1_F = of("VATEX-EU-143-1F") + + @JvmField val VATEX_EU_143_1_FA = of("VATEX-EU-143-1FA") + + @JvmField val VATEX_EU_143_1_G = of("VATEX-EU-143-1G") + + @JvmField val VATEX_EU_143_1_H = of("VATEX-EU-143-1H") + + @JvmField val VATEX_EU_143_1_I = of("VATEX-EU-143-1I") + + @JvmField val VATEX_EU_143_1_J = of("VATEX-EU-143-1J") + + @JvmField val VATEX_EU_143_1_K = of("VATEX-EU-143-1K") + + @JvmField val VATEX_EU_143_1_L = of("VATEX-EU-143-1L") + + @JvmField val VATEX_EU_144 = of("VATEX-EU-144") + + @JvmField val VATEX_EU_146_1_E = of("VATEX-EU-146-1E") + + @JvmField val VATEX_EU_148 = of("VATEX-EU-148") + + @JvmField val VATEX_EU_148_A = of("VATEX-EU-148-A") + + @JvmField val VATEX_EU_148_B = of("VATEX-EU-148-B") + + @JvmField val VATEX_EU_148_C = of("VATEX-EU-148-C") + + @JvmField val VATEX_EU_148_D = of("VATEX-EU-148-D") + + @JvmField val VATEX_EU_148_E = of("VATEX-EU-148-E") + + @JvmField val VATEX_EU_148_F = of("VATEX-EU-148-F") + + @JvmField val VATEX_EU_148_G = of("VATEX-EU-148-G") + + @JvmField val VATEX_EU_151 = of("VATEX-EU-151") + + @JvmField val VATEX_EU_151_1_A = of("VATEX-EU-151-1A") + + @JvmField val VATEX_EU_151_1_AA = of("VATEX-EU-151-1AA") + + @JvmField val VATEX_EU_151_1_B = of("VATEX-EU-151-1B") + + @JvmField val VATEX_EU_151_1_C = of("VATEX-EU-151-1C") + + @JvmField val VATEX_EU_151_1_D = of("VATEX-EU-151-1D") + + @JvmField val VATEX_EU_151_1_E = of("VATEX-EU-151-1E") + + @JvmField val VATEX_EU_159 = of("VATEX-EU-159") + + @JvmField val VATEX_EU_309 = of("VATEX-EU-309") + + @JvmField val VATEX_EU_AE = of("VATEX-EU-AE") + + @JvmField val VATEX_EU_D = of("VATEX-EU-D") + + @JvmField val VATEX_EU_F = of("VATEX-EU-F") + + @JvmField val VATEX_EU_G = of("VATEX-EU-G") + + @JvmField val VATEX_EU_I = of("VATEX-EU-I") + + @JvmField val VATEX_EU_IC = of("VATEX-EU-IC") + + @JvmField val VATEX_EU_O = of("VATEX-EU-O") + + @JvmField val VATEX_EU_J = of("VATEX-EU-J") + + @JvmField val VATEX_FR_FRANCHISE = of("VATEX-FR-FRANCHISE") + + @JvmField val VATEX_FR_CNWVAT = of("VATEX-FR-CNWVAT") + + @JvmStatic fun of(value: String) = Vatex(JsonField.of(value)) + } + + /** An enum containing [Vatex]'s known values. */ + enum class Known { + VATEX_EU_79_C, + VATEX_EU_132, + VATEX_EU_132_1_A, + VATEX_EU_132_1_B, + VATEX_EU_132_1_C, + VATEX_EU_132_1_D, + VATEX_EU_132_1_E, + VATEX_EU_132_1_F, + VATEX_EU_132_1_G, + VATEX_EU_132_1_H, + VATEX_EU_132_1_I, + VATEX_EU_132_1_J, + VATEX_EU_132_1_K, + VATEX_EU_132_1_L, + VATEX_EU_132_1_M, + VATEX_EU_132_1_N, + VATEX_EU_132_1_O, + VATEX_EU_132_1_P, + VATEX_EU_132_1_Q, + VATEX_EU_143, + VATEX_EU_143_1_A, + VATEX_EU_143_1_B, + VATEX_EU_143_1_C, + VATEX_EU_143_1_D, + VATEX_EU_143_1_E, + VATEX_EU_143_1_F, + VATEX_EU_143_1_FA, + VATEX_EU_143_1_G, + VATEX_EU_143_1_H, + VATEX_EU_143_1_I, + VATEX_EU_143_1_J, + VATEX_EU_143_1_K, + VATEX_EU_143_1_L, + VATEX_EU_144, + VATEX_EU_146_1_E, + VATEX_EU_148, + VATEX_EU_148_A, + VATEX_EU_148_B, + VATEX_EU_148_C, + VATEX_EU_148_D, + VATEX_EU_148_E, + VATEX_EU_148_F, + VATEX_EU_148_G, + VATEX_EU_151, + VATEX_EU_151_1_A, + VATEX_EU_151_1_AA, + VATEX_EU_151_1_B, + VATEX_EU_151_1_C, + VATEX_EU_151_1_D, + VATEX_EU_151_1_E, + VATEX_EU_159, + VATEX_EU_309, + VATEX_EU_AE, + VATEX_EU_D, + VATEX_EU_F, + VATEX_EU_G, + VATEX_EU_I, + VATEX_EU_IC, + VATEX_EU_O, + VATEX_EU_J, + VATEX_FR_FRANCHISE, + VATEX_FR_CNWVAT, + } + + /** + * An enum containing [Vatex]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Vatex] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + VATEX_EU_79_C, + VATEX_EU_132, + VATEX_EU_132_1_A, + VATEX_EU_132_1_B, + VATEX_EU_132_1_C, + VATEX_EU_132_1_D, + VATEX_EU_132_1_E, + VATEX_EU_132_1_F, + VATEX_EU_132_1_G, + VATEX_EU_132_1_H, + VATEX_EU_132_1_I, + VATEX_EU_132_1_J, + VATEX_EU_132_1_K, + VATEX_EU_132_1_L, + VATEX_EU_132_1_M, + VATEX_EU_132_1_N, + VATEX_EU_132_1_O, + VATEX_EU_132_1_P, + VATEX_EU_132_1_Q, + VATEX_EU_143, + VATEX_EU_143_1_A, + VATEX_EU_143_1_B, + VATEX_EU_143_1_C, + VATEX_EU_143_1_D, + VATEX_EU_143_1_E, + VATEX_EU_143_1_F, + VATEX_EU_143_1_FA, + VATEX_EU_143_1_G, + VATEX_EU_143_1_H, + VATEX_EU_143_1_I, + VATEX_EU_143_1_J, + VATEX_EU_143_1_K, + VATEX_EU_143_1_L, + VATEX_EU_144, + VATEX_EU_146_1_E, + VATEX_EU_148, + VATEX_EU_148_A, + VATEX_EU_148_B, + VATEX_EU_148_C, + VATEX_EU_148_D, + VATEX_EU_148_E, + VATEX_EU_148_F, + VATEX_EU_148_G, + VATEX_EU_151, + VATEX_EU_151_1_A, + VATEX_EU_151_1_AA, + VATEX_EU_151_1_B, + VATEX_EU_151_1_C, + VATEX_EU_151_1_D, + VATEX_EU_151_1_E, + VATEX_EU_159, + VATEX_EU_309, + VATEX_EU_AE, + VATEX_EU_D, + VATEX_EU_F, + VATEX_EU_G, + VATEX_EU_I, + VATEX_EU_IC, + VATEX_EU_O, + VATEX_EU_J, + VATEX_FR_FRANCHISE, + VATEX_FR_CNWVAT, + /** An enum member indicating that [Vatex] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + VATEX_EU_79_C -> Value.VATEX_EU_79_C + VATEX_EU_132 -> Value.VATEX_EU_132 + VATEX_EU_132_1_A -> Value.VATEX_EU_132_1_A + VATEX_EU_132_1_B -> Value.VATEX_EU_132_1_B + VATEX_EU_132_1_C -> Value.VATEX_EU_132_1_C + VATEX_EU_132_1_D -> Value.VATEX_EU_132_1_D + VATEX_EU_132_1_E -> Value.VATEX_EU_132_1_E + VATEX_EU_132_1_F -> Value.VATEX_EU_132_1_F + VATEX_EU_132_1_G -> Value.VATEX_EU_132_1_G + VATEX_EU_132_1_H -> Value.VATEX_EU_132_1_H + VATEX_EU_132_1_I -> Value.VATEX_EU_132_1_I + VATEX_EU_132_1_J -> Value.VATEX_EU_132_1_J + VATEX_EU_132_1_K -> Value.VATEX_EU_132_1_K + VATEX_EU_132_1_L -> Value.VATEX_EU_132_1_L + VATEX_EU_132_1_M -> Value.VATEX_EU_132_1_M + VATEX_EU_132_1_N -> Value.VATEX_EU_132_1_N + VATEX_EU_132_1_O -> Value.VATEX_EU_132_1_O + VATEX_EU_132_1_P -> Value.VATEX_EU_132_1_P + VATEX_EU_132_1_Q -> Value.VATEX_EU_132_1_Q + VATEX_EU_143 -> Value.VATEX_EU_143 + VATEX_EU_143_1_A -> Value.VATEX_EU_143_1_A + VATEX_EU_143_1_B -> Value.VATEX_EU_143_1_B + VATEX_EU_143_1_C -> Value.VATEX_EU_143_1_C + VATEX_EU_143_1_D -> Value.VATEX_EU_143_1_D + VATEX_EU_143_1_E -> Value.VATEX_EU_143_1_E + VATEX_EU_143_1_F -> Value.VATEX_EU_143_1_F + VATEX_EU_143_1_FA -> Value.VATEX_EU_143_1_FA + VATEX_EU_143_1_G -> Value.VATEX_EU_143_1_G + VATEX_EU_143_1_H -> Value.VATEX_EU_143_1_H + VATEX_EU_143_1_I -> Value.VATEX_EU_143_1_I + VATEX_EU_143_1_J -> Value.VATEX_EU_143_1_J + VATEX_EU_143_1_K -> Value.VATEX_EU_143_1_K + VATEX_EU_143_1_L -> Value.VATEX_EU_143_1_L + VATEX_EU_144 -> Value.VATEX_EU_144 + VATEX_EU_146_1_E -> Value.VATEX_EU_146_1_E + VATEX_EU_148 -> Value.VATEX_EU_148 + VATEX_EU_148_A -> Value.VATEX_EU_148_A + VATEX_EU_148_B -> Value.VATEX_EU_148_B + VATEX_EU_148_C -> Value.VATEX_EU_148_C + VATEX_EU_148_D -> Value.VATEX_EU_148_D + VATEX_EU_148_E -> Value.VATEX_EU_148_E + VATEX_EU_148_F -> Value.VATEX_EU_148_F + VATEX_EU_148_G -> Value.VATEX_EU_148_G + VATEX_EU_151 -> Value.VATEX_EU_151 + VATEX_EU_151_1_A -> Value.VATEX_EU_151_1_A + VATEX_EU_151_1_AA -> Value.VATEX_EU_151_1_AA + VATEX_EU_151_1_B -> Value.VATEX_EU_151_1_B + VATEX_EU_151_1_C -> Value.VATEX_EU_151_1_C + VATEX_EU_151_1_D -> Value.VATEX_EU_151_1_D + VATEX_EU_151_1_E -> Value.VATEX_EU_151_1_E + VATEX_EU_159 -> Value.VATEX_EU_159 + VATEX_EU_309 -> Value.VATEX_EU_309 + VATEX_EU_AE -> Value.VATEX_EU_AE + VATEX_EU_D -> Value.VATEX_EU_D + VATEX_EU_F -> Value.VATEX_EU_F + VATEX_EU_G -> Value.VATEX_EU_G + VATEX_EU_I -> Value.VATEX_EU_I + VATEX_EU_IC -> Value.VATEX_EU_IC + VATEX_EU_O -> Value.VATEX_EU_O + VATEX_EU_J -> Value.VATEX_EU_J + VATEX_FR_FRANCHISE -> Value.VATEX_FR_FRANCHISE + VATEX_FR_CNWVAT -> Value.VATEX_FR_CNWVAT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + VATEX_EU_79_C -> Known.VATEX_EU_79_C + VATEX_EU_132 -> Known.VATEX_EU_132 + VATEX_EU_132_1_A -> Known.VATEX_EU_132_1_A + VATEX_EU_132_1_B -> Known.VATEX_EU_132_1_B + VATEX_EU_132_1_C -> Known.VATEX_EU_132_1_C + VATEX_EU_132_1_D -> Known.VATEX_EU_132_1_D + VATEX_EU_132_1_E -> Known.VATEX_EU_132_1_E + VATEX_EU_132_1_F -> Known.VATEX_EU_132_1_F + VATEX_EU_132_1_G -> Known.VATEX_EU_132_1_G + VATEX_EU_132_1_H -> Known.VATEX_EU_132_1_H + VATEX_EU_132_1_I -> Known.VATEX_EU_132_1_I + VATEX_EU_132_1_J -> Known.VATEX_EU_132_1_J + VATEX_EU_132_1_K -> Known.VATEX_EU_132_1_K + VATEX_EU_132_1_L -> Known.VATEX_EU_132_1_L + VATEX_EU_132_1_M -> Known.VATEX_EU_132_1_M + VATEX_EU_132_1_N -> Known.VATEX_EU_132_1_N + VATEX_EU_132_1_O -> Known.VATEX_EU_132_1_O + VATEX_EU_132_1_P -> Known.VATEX_EU_132_1_P + VATEX_EU_132_1_Q -> Known.VATEX_EU_132_1_Q + VATEX_EU_143 -> Known.VATEX_EU_143 + VATEX_EU_143_1_A -> Known.VATEX_EU_143_1_A + VATEX_EU_143_1_B -> Known.VATEX_EU_143_1_B + VATEX_EU_143_1_C -> Known.VATEX_EU_143_1_C + VATEX_EU_143_1_D -> Known.VATEX_EU_143_1_D + VATEX_EU_143_1_E -> Known.VATEX_EU_143_1_E + VATEX_EU_143_1_F -> Known.VATEX_EU_143_1_F + VATEX_EU_143_1_FA -> Known.VATEX_EU_143_1_FA + VATEX_EU_143_1_G -> Known.VATEX_EU_143_1_G + VATEX_EU_143_1_H -> Known.VATEX_EU_143_1_H + VATEX_EU_143_1_I -> Known.VATEX_EU_143_1_I + VATEX_EU_143_1_J -> Known.VATEX_EU_143_1_J + VATEX_EU_143_1_K -> Known.VATEX_EU_143_1_K + VATEX_EU_143_1_L -> Known.VATEX_EU_143_1_L + VATEX_EU_144 -> Known.VATEX_EU_144 + VATEX_EU_146_1_E -> Known.VATEX_EU_146_1_E + VATEX_EU_148 -> Known.VATEX_EU_148 + VATEX_EU_148_A -> Known.VATEX_EU_148_A + VATEX_EU_148_B -> Known.VATEX_EU_148_B + VATEX_EU_148_C -> Known.VATEX_EU_148_C + VATEX_EU_148_D -> Known.VATEX_EU_148_D + VATEX_EU_148_E -> Known.VATEX_EU_148_E + VATEX_EU_148_F -> Known.VATEX_EU_148_F + VATEX_EU_148_G -> Known.VATEX_EU_148_G + VATEX_EU_151 -> Known.VATEX_EU_151 + VATEX_EU_151_1_A -> Known.VATEX_EU_151_1_A + VATEX_EU_151_1_AA -> Known.VATEX_EU_151_1_AA + VATEX_EU_151_1_B -> Known.VATEX_EU_151_1_B + VATEX_EU_151_1_C -> Known.VATEX_EU_151_1_C + VATEX_EU_151_1_D -> Known.VATEX_EU_151_1_D + VATEX_EU_151_1_E -> Known.VATEX_EU_151_1_E + VATEX_EU_159 -> Known.VATEX_EU_159 + VATEX_EU_309 -> Known.VATEX_EU_309 + VATEX_EU_AE -> Known.VATEX_EU_AE + VATEX_EU_D -> Known.VATEX_EU_D + VATEX_EU_F -> Known.VATEX_EU_F + VATEX_EU_G -> Known.VATEX_EU_G + VATEX_EU_I -> Known.VATEX_EU_I + VATEX_EU_IC -> Known.VATEX_EU_IC + VATEX_EU_O -> Known.VATEX_EU_O + VATEX_EU_J -> Known.VATEX_EU_J + VATEX_FR_FRANCHISE -> Known.VATEX_FR_FRANCHISE + VATEX_FR_CNWVAT -> Known.VATEX_FR_CNWVAT + else -> throw EInvoiceInvalidDataException("Unknown Vatex: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Vatex = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Vatex && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4495,9 +5279,12 @@ private constructor( shippingAddressRecipient == other.shippingAddressRecipient && state == other.state && subtotal == other.subtotal && + taxCode == other.taxCode && taxDetails == other.taxDetails && totalDiscount == other.totalDiscount && totalTax == other.totalTax && + vatex == other.vatex && + vatexNote == other.vatexNote && vendorAddress == other.vendorAddress && vendorAddressRecipient == other.vendorAddressRecipient && vendorEmail == other.vendorEmail && @@ -4541,9 +5328,12 @@ private constructor( shippingAddressRecipient, state, subtotal, + taxCode, taxDetails, totalDiscount, totalTax, + vatex, + vatexNote, vendorAddress, vendorAddressRecipient, vendorEmail, @@ -4556,5 +5346,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "DocumentCreate{amountDue=$amountDue, attachments=$attachments, billingAddress=$billingAddress, billingAddressRecipient=$billingAddressRecipient, currency=$currency, customerAddress=$customerAddress, customerAddressRecipient=$customerAddressRecipient, customerEmail=$customerEmail, customerId=$customerId, customerName=$customerName, customerTaxId=$customerTaxId, direction=$direction, documentType=$documentType, dueDate=$dueDate, invoiceDate=$invoiceDate, invoiceId=$invoiceId, invoiceTotal=$invoiceTotal, items=$items, note=$note, paymentDetails=$paymentDetails, paymentTerm=$paymentTerm, previousUnpaidBalance=$previousUnpaidBalance, purchaseOrder=$purchaseOrder, remittanceAddress=$remittanceAddress, remittanceAddressRecipient=$remittanceAddressRecipient, serviceAddress=$serviceAddress, serviceAddressRecipient=$serviceAddressRecipient, serviceEndDate=$serviceEndDate, serviceStartDate=$serviceStartDate, shippingAddress=$shippingAddress, shippingAddressRecipient=$shippingAddressRecipient, state=$state, subtotal=$subtotal, taxDetails=$taxDetails, totalDiscount=$totalDiscount, totalTax=$totalTax, vendorAddress=$vendorAddress, vendorAddressRecipient=$vendorAddressRecipient, vendorEmail=$vendorEmail, vendorName=$vendorName, vendorTaxId=$vendorTaxId, additionalProperties=$additionalProperties}" + "DocumentCreate{amountDue=$amountDue, attachments=$attachments, billingAddress=$billingAddress, billingAddressRecipient=$billingAddressRecipient, currency=$currency, customerAddress=$customerAddress, customerAddressRecipient=$customerAddressRecipient, customerEmail=$customerEmail, customerId=$customerId, customerName=$customerName, customerTaxId=$customerTaxId, direction=$direction, documentType=$documentType, dueDate=$dueDate, invoiceDate=$invoiceDate, invoiceId=$invoiceId, invoiceTotal=$invoiceTotal, items=$items, note=$note, paymentDetails=$paymentDetails, paymentTerm=$paymentTerm, previousUnpaidBalance=$previousUnpaidBalance, purchaseOrder=$purchaseOrder, remittanceAddress=$remittanceAddress, remittanceAddressRecipient=$remittanceAddressRecipient, serviceAddress=$serviceAddress, serviceAddressRecipient=$serviceAddressRecipient, serviceEndDate=$serviceEndDate, serviceStartDate=$serviceStartDate, shippingAddress=$shippingAddress, shippingAddressRecipient=$shippingAddressRecipient, state=$state, subtotal=$subtotal, taxCode=$taxCode, taxDetails=$taxDetails, totalDiscount=$totalDiscount, totalTax=$totalTax, vatex=$vatex, vatexNote=$vatexNote, vendorAddress=$vendorAddress, vendorAddressRecipient=$vendorAddressRecipient, vendorEmail=$vendorEmail, vendorName=$vendorName, vendorTaxId=$vendorTaxId, additionalProperties=$additionalProperties}" } diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt index f266b64..b62efe0 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt @@ -2,6 +2,7 @@ package com.e_invoice.api.models.documents +import com.e_invoice.api.core.Enum import com.e_invoice.api.core.ExcludeMissing import com.e_invoice.api.core.JsonField import com.e_invoice.api.core.JsonMissing @@ -59,9 +60,12 @@ private constructor( private val shippingAddressRecipient: JsonField, private val state: JsonField, private val subtotal: JsonField, + private val taxCode: JsonField, private val taxDetails: JsonField>, private val totalDiscount: JsonField, private val totalTax: JsonField, + private val vatex: JsonField, + private val vatexNote: JsonField, private val vendorAddress: JsonField, private val vendorAddressRecipient: JsonField, private val vendorEmail: JsonField, @@ -158,6 +162,7 @@ private constructor( shippingAddressRecipient: JsonField = JsonMissing.of(), @JsonProperty("state") @ExcludeMissing state: JsonField = JsonMissing.of(), @JsonProperty("subtotal") @ExcludeMissing subtotal: JsonField = JsonMissing.of(), + @JsonProperty("tax_code") @ExcludeMissing taxCode: JsonField = JsonMissing.of(), @JsonProperty("tax_details") @ExcludeMissing taxDetails: JsonField> = JsonMissing.of(), @@ -165,6 +170,8 @@ private constructor( @ExcludeMissing totalDiscount: JsonField = JsonMissing.of(), @JsonProperty("total_tax") @ExcludeMissing totalTax: JsonField = JsonMissing.of(), + @JsonProperty("vatex") @ExcludeMissing vatex: JsonField = JsonMissing.of(), + @JsonProperty("vatex_note") @ExcludeMissing vatexNote: JsonField = JsonMissing.of(), @JsonProperty("vendor_address") @ExcludeMissing vendorAddress: JsonField = JsonMissing.of(), @@ -215,9 +222,12 @@ private constructor( shippingAddressRecipient, state, subtotal, + taxCode, taxDetails, totalDiscount, totalTax, + vatex, + vatexNote, vendorAddress, vendorAddressRecipient, vendorEmail, @@ -439,6 +449,14 @@ private constructor( */ fun subtotal(): Optional = subtotal.getOptional("subtotal") + /** + * Tax category code of the invoice + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun taxCode(): Optional = taxCode.getOptional("tax_code") + /** * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -457,6 +475,24 @@ private constructor( */ fun totalTax(): Optional = totalTax.getOptional("total_tax") + /** + * VATEX code list for VAT exemption reasons + * + * Agency: CEF Identifier: vatex + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun vatex(): Optional = vatex.getOptional("vatex") + + /** + * VAT exemption note of the invoice + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun vatexNote(): Optional = vatexNote.getOptional("vatex_note") + /** * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -782,6 +818,13 @@ private constructor( */ @JsonProperty("subtotal") @ExcludeMissing fun _subtotal(): JsonField = subtotal + /** + * Returns the raw JSON value of [taxCode]. + * + * Unlike [taxCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax_code") @ExcludeMissing fun _taxCode(): JsonField = taxCode + /** * Returns the raw JSON value of [taxDetails]. * @@ -807,6 +850,20 @@ private constructor( */ @JsonProperty("total_tax") @ExcludeMissing fun _totalTax(): JsonField = totalTax + /** + * Returns the raw JSON value of [vatex]. + * + * Unlike [vatex], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("vatex") @ExcludeMissing fun _vatex(): JsonField = vatex + + /** + * Returns the raw JSON value of [vatexNote]. + * + * Unlike [vatexNote], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("vatex_note") @ExcludeMissing fun _vatexNote(): JsonField = vatexNote + /** * Returns the raw JSON value of [vendorAddress]. * @@ -913,9 +970,12 @@ private constructor( private var shippingAddressRecipient: JsonField = JsonMissing.of() private var state: JsonField = JsonMissing.of() private var subtotal: JsonField = JsonMissing.of() + private var taxCode: JsonField = JsonMissing.of() private var taxDetails: JsonField>? = null private var totalDiscount: JsonField = JsonMissing.of() private var totalTax: JsonField = JsonMissing.of() + private var vatex: JsonField = JsonMissing.of() + private var vatexNote: JsonField = JsonMissing.of() private var vendorAddress: JsonField = JsonMissing.of() private var vendorAddressRecipient: JsonField = JsonMissing.of() private var vendorEmail: JsonField = JsonMissing.of() @@ -959,9 +1019,12 @@ private constructor( shippingAddressRecipient = documentResponse.shippingAddressRecipient state = documentResponse.state subtotal = documentResponse.subtotal + taxCode = documentResponse.taxCode taxDetails = documentResponse.taxDetails.map { it.toMutableList() } totalDiscount = documentResponse.totalDiscount totalTax = documentResponse.totalTax + vatex = documentResponse.vatex + vatexNote = documentResponse.vatexNote vendorAddress = documentResponse.vendorAddress vendorAddressRecipient = documentResponse.vendorAddressRecipient vendorEmail = documentResponse.vendorEmail @@ -1554,6 +1617,17 @@ private constructor( */ fun subtotal(subtotal: JsonField) = apply { this.subtotal = subtotal } + /** Tax category code of the invoice */ + fun taxCode(taxCode: TaxCode) = taxCode(JsonField.of(taxCode)) + + /** + * Sets [Builder.taxCode] to an arbitrary JSON value. + * + * You should usually call [Builder.taxCode] with a well-typed [TaxCode] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } + fun taxDetails(taxDetails: List) = taxDetails(JsonField.of(taxDetails)) /** @@ -1610,6 +1684,39 @@ private constructor( */ fun totalTax(totalTax: JsonField) = apply { this.totalTax = totalTax } + /** + * VATEX code list for VAT exemption reasons + * + * Agency: CEF Identifier: vatex + */ + fun vatex(vatex: Vatex?) = vatex(JsonField.ofNullable(vatex)) + + /** Alias for calling [Builder.vatex] with `vatex.orElse(null)`. */ + fun vatex(vatex: Optional) = vatex(vatex.getOrNull()) + + /** + * Sets [Builder.vatex] to an arbitrary JSON value. + * + * You should usually call [Builder.vatex] with a well-typed [Vatex] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun vatex(vatex: JsonField) = apply { this.vatex = vatex } + + /** VAT exemption note of the invoice */ + fun vatexNote(vatexNote: String?) = vatexNote(JsonField.ofNullable(vatexNote)) + + /** Alias for calling [Builder.vatexNote] with `vatexNote.orElse(null)`. */ + fun vatexNote(vatexNote: Optional) = vatexNote(vatexNote.getOrNull()) + + /** + * Sets [Builder.vatexNote] to an arbitrary JSON value. + * + * You should usually call [Builder.vatexNote] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun vatexNote(vatexNote: JsonField) = apply { this.vatexNote = vatexNote } + fun vendorAddress(vendorAddress: String?) = vendorAddress(JsonField.ofNullable(vendorAddress)) @@ -1758,9 +1865,12 @@ private constructor( shippingAddressRecipient, state, subtotal, + taxCode, (taxDetails ?: JsonMissing.of()).map { it.toImmutable() }, totalDiscount, totalTax, + vatex, + vatexNote, vendorAddress, vendorAddressRecipient, vendorEmail, @@ -1811,9 +1921,12 @@ private constructor( shippingAddressRecipient() state().ifPresent { it.validate() } subtotal() + taxCode().ifPresent { it.validate() } taxDetails().ifPresent { it.forEach { it.validate() } } totalDiscount() totalTax() + vatex().ifPresent { it.validate() } + vatexNote() vendorAddress() vendorAddressRecipient() vendorEmail() @@ -1871,9 +1984,12 @@ private constructor( (if (shippingAddressRecipient.asKnown().isPresent) 1 else 0) + (state.asKnown().getOrNull()?.validity() ?: 0) + (if (subtotal.asKnown().isPresent) 1 else 0) + + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + (taxDetails.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (totalDiscount.asKnown().isPresent) 1 else 0) + (if (totalTax.asKnown().isPresent) 1 else 0) + + (vatex.asKnown().getOrNull()?.validity() ?: 0) + + (if (vatexNote.asKnown().isPresent) 1 else 0) + (if (vendorAddress.asKnown().isPresent) 1 else 0) + (if (vendorAddressRecipient.asKnown().isPresent) 1 else 0) + (if (vendorEmail.asKnown().isPresent) 1 else 0) + @@ -2629,6 +2745,182 @@ private constructor( "PaymentDetail{bankAccountNumber=$bankAccountNumber, iban=$iban, paymentReference=$paymentReference, swift=$swift, additionalProperties=$additionalProperties}" } + /** Tax category code of the invoice */ + class TaxCode @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val AE = of("AE") + + @JvmField val E = of("E") + + @JvmField val S = of("S") + + @JvmField val Z = of("Z") + + @JvmField val G = of("G") + + @JvmField val O = of("O") + + @JvmField val K = of("K") + + @JvmField val L = of("L") + + @JvmField val M = of("M") + + @JvmField val B = of("B") + + @JvmStatic fun of(value: String) = TaxCode(JsonField.of(value)) + } + + /** An enum containing [TaxCode]'s known values. */ + enum class Known { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + } + + /** + * An enum containing [TaxCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TaxCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + /** An enum member indicating that [TaxCode] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AE -> Value.AE + E -> Value.E + S -> Value.S + Z -> Value.Z + G -> Value.G + O -> Value.O + K -> Value.K + L -> Value.L + M -> Value.M + B -> Value.B + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + AE -> Known.AE + E -> Known.E + S -> Known.S + Z -> Known.Z + G -> Known.G + O -> Known.O + K -> Known.K + L -> Known.L + M -> Known.M + B -> Known.B + else -> throw EInvoiceInvalidDataException("Unknown TaxCode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TaxCode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TaxCode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + class TaxDetail @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -2805,6 +3097,498 @@ private constructor( "TaxDetail{amount=$amount, rate=$rate, additionalProperties=$additionalProperties}" } + /** + * VATEX code list for VAT exemption reasons + * + * Agency: CEF Identifier: vatex + */ + class Vatex @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val VATEX_EU_79_C = of("VATEX-EU-79-C") + + @JvmField val VATEX_EU_132 = of("VATEX-EU-132") + + @JvmField val VATEX_EU_132_1_A = of("VATEX-EU-132-1A") + + @JvmField val VATEX_EU_132_1_B = of("VATEX-EU-132-1B") + + @JvmField val VATEX_EU_132_1_C = of("VATEX-EU-132-1C") + + @JvmField val VATEX_EU_132_1_D = of("VATEX-EU-132-1D") + + @JvmField val VATEX_EU_132_1_E = of("VATEX-EU-132-1E") + + @JvmField val VATEX_EU_132_1_F = of("VATEX-EU-132-1F") + + @JvmField val VATEX_EU_132_1_G = of("VATEX-EU-132-1G") + + @JvmField val VATEX_EU_132_1_H = of("VATEX-EU-132-1H") + + @JvmField val VATEX_EU_132_1_I = of("VATEX-EU-132-1I") + + @JvmField val VATEX_EU_132_1_J = of("VATEX-EU-132-1J") + + @JvmField val VATEX_EU_132_1_K = of("VATEX-EU-132-1K") + + @JvmField val VATEX_EU_132_1_L = of("VATEX-EU-132-1L") + + @JvmField val VATEX_EU_132_1_M = of("VATEX-EU-132-1M") + + @JvmField val VATEX_EU_132_1_N = of("VATEX-EU-132-1N") + + @JvmField val VATEX_EU_132_1_O = of("VATEX-EU-132-1O") + + @JvmField val VATEX_EU_132_1_P = of("VATEX-EU-132-1P") + + @JvmField val VATEX_EU_132_1_Q = of("VATEX-EU-132-1Q") + + @JvmField val VATEX_EU_143 = of("VATEX-EU-143") + + @JvmField val VATEX_EU_143_1_A = of("VATEX-EU-143-1A") + + @JvmField val VATEX_EU_143_1_B = of("VATEX-EU-143-1B") + + @JvmField val VATEX_EU_143_1_C = of("VATEX-EU-143-1C") + + @JvmField val VATEX_EU_143_1_D = of("VATEX-EU-143-1D") + + @JvmField val VATEX_EU_143_1_E = of("VATEX-EU-143-1E") + + @JvmField val VATEX_EU_143_1_F = of("VATEX-EU-143-1F") + + @JvmField val VATEX_EU_143_1_FA = of("VATEX-EU-143-1FA") + + @JvmField val VATEX_EU_143_1_G = of("VATEX-EU-143-1G") + + @JvmField val VATEX_EU_143_1_H = of("VATEX-EU-143-1H") + + @JvmField val VATEX_EU_143_1_I = of("VATEX-EU-143-1I") + + @JvmField val VATEX_EU_143_1_J = of("VATEX-EU-143-1J") + + @JvmField val VATEX_EU_143_1_K = of("VATEX-EU-143-1K") + + @JvmField val VATEX_EU_143_1_L = of("VATEX-EU-143-1L") + + @JvmField val VATEX_EU_144 = of("VATEX-EU-144") + + @JvmField val VATEX_EU_146_1_E = of("VATEX-EU-146-1E") + + @JvmField val VATEX_EU_148 = of("VATEX-EU-148") + + @JvmField val VATEX_EU_148_A = of("VATEX-EU-148-A") + + @JvmField val VATEX_EU_148_B = of("VATEX-EU-148-B") + + @JvmField val VATEX_EU_148_C = of("VATEX-EU-148-C") + + @JvmField val VATEX_EU_148_D = of("VATEX-EU-148-D") + + @JvmField val VATEX_EU_148_E = of("VATEX-EU-148-E") + + @JvmField val VATEX_EU_148_F = of("VATEX-EU-148-F") + + @JvmField val VATEX_EU_148_G = of("VATEX-EU-148-G") + + @JvmField val VATEX_EU_151 = of("VATEX-EU-151") + + @JvmField val VATEX_EU_151_1_A = of("VATEX-EU-151-1A") + + @JvmField val VATEX_EU_151_1_AA = of("VATEX-EU-151-1AA") + + @JvmField val VATEX_EU_151_1_B = of("VATEX-EU-151-1B") + + @JvmField val VATEX_EU_151_1_C = of("VATEX-EU-151-1C") + + @JvmField val VATEX_EU_151_1_D = of("VATEX-EU-151-1D") + + @JvmField val VATEX_EU_151_1_E = of("VATEX-EU-151-1E") + + @JvmField val VATEX_EU_159 = of("VATEX-EU-159") + + @JvmField val VATEX_EU_309 = of("VATEX-EU-309") + + @JvmField val VATEX_EU_AE = of("VATEX-EU-AE") + + @JvmField val VATEX_EU_D = of("VATEX-EU-D") + + @JvmField val VATEX_EU_F = of("VATEX-EU-F") + + @JvmField val VATEX_EU_G = of("VATEX-EU-G") + + @JvmField val VATEX_EU_I = of("VATEX-EU-I") + + @JvmField val VATEX_EU_IC = of("VATEX-EU-IC") + + @JvmField val VATEX_EU_O = of("VATEX-EU-O") + + @JvmField val VATEX_EU_J = of("VATEX-EU-J") + + @JvmField val VATEX_FR_FRANCHISE = of("VATEX-FR-FRANCHISE") + + @JvmField val VATEX_FR_CNWVAT = of("VATEX-FR-CNWVAT") + + @JvmStatic fun of(value: String) = Vatex(JsonField.of(value)) + } + + /** An enum containing [Vatex]'s known values. */ + enum class Known { + VATEX_EU_79_C, + VATEX_EU_132, + VATEX_EU_132_1_A, + VATEX_EU_132_1_B, + VATEX_EU_132_1_C, + VATEX_EU_132_1_D, + VATEX_EU_132_1_E, + VATEX_EU_132_1_F, + VATEX_EU_132_1_G, + VATEX_EU_132_1_H, + VATEX_EU_132_1_I, + VATEX_EU_132_1_J, + VATEX_EU_132_1_K, + VATEX_EU_132_1_L, + VATEX_EU_132_1_M, + VATEX_EU_132_1_N, + VATEX_EU_132_1_O, + VATEX_EU_132_1_P, + VATEX_EU_132_1_Q, + VATEX_EU_143, + VATEX_EU_143_1_A, + VATEX_EU_143_1_B, + VATEX_EU_143_1_C, + VATEX_EU_143_1_D, + VATEX_EU_143_1_E, + VATEX_EU_143_1_F, + VATEX_EU_143_1_FA, + VATEX_EU_143_1_G, + VATEX_EU_143_1_H, + VATEX_EU_143_1_I, + VATEX_EU_143_1_J, + VATEX_EU_143_1_K, + VATEX_EU_143_1_L, + VATEX_EU_144, + VATEX_EU_146_1_E, + VATEX_EU_148, + VATEX_EU_148_A, + VATEX_EU_148_B, + VATEX_EU_148_C, + VATEX_EU_148_D, + VATEX_EU_148_E, + VATEX_EU_148_F, + VATEX_EU_148_G, + VATEX_EU_151, + VATEX_EU_151_1_A, + VATEX_EU_151_1_AA, + VATEX_EU_151_1_B, + VATEX_EU_151_1_C, + VATEX_EU_151_1_D, + VATEX_EU_151_1_E, + VATEX_EU_159, + VATEX_EU_309, + VATEX_EU_AE, + VATEX_EU_D, + VATEX_EU_F, + VATEX_EU_G, + VATEX_EU_I, + VATEX_EU_IC, + VATEX_EU_O, + VATEX_EU_J, + VATEX_FR_FRANCHISE, + VATEX_FR_CNWVAT, + } + + /** + * An enum containing [Vatex]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Vatex] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + VATEX_EU_79_C, + VATEX_EU_132, + VATEX_EU_132_1_A, + VATEX_EU_132_1_B, + VATEX_EU_132_1_C, + VATEX_EU_132_1_D, + VATEX_EU_132_1_E, + VATEX_EU_132_1_F, + VATEX_EU_132_1_G, + VATEX_EU_132_1_H, + VATEX_EU_132_1_I, + VATEX_EU_132_1_J, + VATEX_EU_132_1_K, + VATEX_EU_132_1_L, + VATEX_EU_132_1_M, + VATEX_EU_132_1_N, + VATEX_EU_132_1_O, + VATEX_EU_132_1_P, + VATEX_EU_132_1_Q, + VATEX_EU_143, + VATEX_EU_143_1_A, + VATEX_EU_143_1_B, + VATEX_EU_143_1_C, + VATEX_EU_143_1_D, + VATEX_EU_143_1_E, + VATEX_EU_143_1_F, + VATEX_EU_143_1_FA, + VATEX_EU_143_1_G, + VATEX_EU_143_1_H, + VATEX_EU_143_1_I, + VATEX_EU_143_1_J, + VATEX_EU_143_1_K, + VATEX_EU_143_1_L, + VATEX_EU_144, + VATEX_EU_146_1_E, + VATEX_EU_148, + VATEX_EU_148_A, + VATEX_EU_148_B, + VATEX_EU_148_C, + VATEX_EU_148_D, + VATEX_EU_148_E, + VATEX_EU_148_F, + VATEX_EU_148_G, + VATEX_EU_151, + VATEX_EU_151_1_A, + VATEX_EU_151_1_AA, + VATEX_EU_151_1_B, + VATEX_EU_151_1_C, + VATEX_EU_151_1_D, + VATEX_EU_151_1_E, + VATEX_EU_159, + VATEX_EU_309, + VATEX_EU_AE, + VATEX_EU_D, + VATEX_EU_F, + VATEX_EU_G, + VATEX_EU_I, + VATEX_EU_IC, + VATEX_EU_O, + VATEX_EU_J, + VATEX_FR_FRANCHISE, + VATEX_FR_CNWVAT, + /** An enum member indicating that [Vatex] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + VATEX_EU_79_C -> Value.VATEX_EU_79_C + VATEX_EU_132 -> Value.VATEX_EU_132 + VATEX_EU_132_1_A -> Value.VATEX_EU_132_1_A + VATEX_EU_132_1_B -> Value.VATEX_EU_132_1_B + VATEX_EU_132_1_C -> Value.VATEX_EU_132_1_C + VATEX_EU_132_1_D -> Value.VATEX_EU_132_1_D + VATEX_EU_132_1_E -> Value.VATEX_EU_132_1_E + VATEX_EU_132_1_F -> Value.VATEX_EU_132_1_F + VATEX_EU_132_1_G -> Value.VATEX_EU_132_1_G + VATEX_EU_132_1_H -> Value.VATEX_EU_132_1_H + VATEX_EU_132_1_I -> Value.VATEX_EU_132_1_I + VATEX_EU_132_1_J -> Value.VATEX_EU_132_1_J + VATEX_EU_132_1_K -> Value.VATEX_EU_132_1_K + VATEX_EU_132_1_L -> Value.VATEX_EU_132_1_L + VATEX_EU_132_1_M -> Value.VATEX_EU_132_1_M + VATEX_EU_132_1_N -> Value.VATEX_EU_132_1_N + VATEX_EU_132_1_O -> Value.VATEX_EU_132_1_O + VATEX_EU_132_1_P -> Value.VATEX_EU_132_1_P + VATEX_EU_132_1_Q -> Value.VATEX_EU_132_1_Q + VATEX_EU_143 -> Value.VATEX_EU_143 + VATEX_EU_143_1_A -> Value.VATEX_EU_143_1_A + VATEX_EU_143_1_B -> Value.VATEX_EU_143_1_B + VATEX_EU_143_1_C -> Value.VATEX_EU_143_1_C + VATEX_EU_143_1_D -> Value.VATEX_EU_143_1_D + VATEX_EU_143_1_E -> Value.VATEX_EU_143_1_E + VATEX_EU_143_1_F -> Value.VATEX_EU_143_1_F + VATEX_EU_143_1_FA -> Value.VATEX_EU_143_1_FA + VATEX_EU_143_1_G -> Value.VATEX_EU_143_1_G + VATEX_EU_143_1_H -> Value.VATEX_EU_143_1_H + VATEX_EU_143_1_I -> Value.VATEX_EU_143_1_I + VATEX_EU_143_1_J -> Value.VATEX_EU_143_1_J + VATEX_EU_143_1_K -> Value.VATEX_EU_143_1_K + VATEX_EU_143_1_L -> Value.VATEX_EU_143_1_L + VATEX_EU_144 -> Value.VATEX_EU_144 + VATEX_EU_146_1_E -> Value.VATEX_EU_146_1_E + VATEX_EU_148 -> Value.VATEX_EU_148 + VATEX_EU_148_A -> Value.VATEX_EU_148_A + VATEX_EU_148_B -> Value.VATEX_EU_148_B + VATEX_EU_148_C -> Value.VATEX_EU_148_C + VATEX_EU_148_D -> Value.VATEX_EU_148_D + VATEX_EU_148_E -> Value.VATEX_EU_148_E + VATEX_EU_148_F -> Value.VATEX_EU_148_F + VATEX_EU_148_G -> Value.VATEX_EU_148_G + VATEX_EU_151 -> Value.VATEX_EU_151 + VATEX_EU_151_1_A -> Value.VATEX_EU_151_1_A + VATEX_EU_151_1_AA -> Value.VATEX_EU_151_1_AA + VATEX_EU_151_1_B -> Value.VATEX_EU_151_1_B + VATEX_EU_151_1_C -> Value.VATEX_EU_151_1_C + VATEX_EU_151_1_D -> Value.VATEX_EU_151_1_D + VATEX_EU_151_1_E -> Value.VATEX_EU_151_1_E + VATEX_EU_159 -> Value.VATEX_EU_159 + VATEX_EU_309 -> Value.VATEX_EU_309 + VATEX_EU_AE -> Value.VATEX_EU_AE + VATEX_EU_D -> Value.VATEX_EU_D + VATEX_EU_F -> Value.VATEX_EU_F + VATEX_EU_G -> Value.VATEX_EU_G + VATEX_EU_I -> Value.VATEX_EU_I + VATEX_EU_IC -> Value.VATEX_EU_IC + VATEX_EU_O -> Value.VATEX_EU_O + VATEX_EU_J -> Value.VATEX_EU_J + VATEX_FR_FRANCHISE -> Value.VATEX_FR_FRANCHISE + VATEX_FR_CNWVAT -> Value.VATEX_FR_CNWVAT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + VATEX_EU_79_C -> Known.VATEX_EU_79_C + VATEX_EU_132 -> Known.VATEX_EU_132 + VATEX_EU_132_1_A -> Known.VATEX_EU_132_1_A + VATEX_EU_132_1_B -> Known.VATEX_EU_132_1_B + VATEX_EU_132_1_C -> Known.VATEX_EU_132_1_C + VATEX_EU_132_1_D -> Known.VATEX_EU_132_1_D + VATEX_EU_132_1_E -> Known.VATEX_EU_132_1_E + VATEX_EU_132_1_F -> Known.VATEX_EU_132_1_F + VATEX_EU_132_1_G -> Known.VATEX_EU_132_1_G + VATEX_EU_132_1_H -> Known.VATEX_EU_132_1_H + VATEX_EU_132_1_I -> Known.VATEX_EU_132_1_I + VATEX_EU_132_1_J -> Known.VATEX_EU_132_1_J + VATEX_EU_132_1_K -> Known.VATEX_EU_132_1_K + VATEX_EU_132_1_L -> Known.VATEX_EU_132_1_L + VATEX_EU_132_1_M -> Known.VATEX_EU_132_1_M + VATEX_EU_132_1_N -> Known.VATEX_EU_132_1_N + VATEX_EU_132_1_O -> Known.VATEX_EU_132_1_O + VATEX_EU_132_1_P -> Known.VATEX_EU_132_1_P + VATEX_EU_132_1_Q -> Known.VATEX_EU_132_1_Q + VATEX_EU_143 -> Known.VATEX_EU_143 + VATEX_EU_143_1_A -> Known.VATEX_EU_143_1_A + VATEX_EU_143_1_B -> Known.VATEX_EU_143_1_B + VATEX_EU_143_1_C -> Known.VATEX_EU_143_1_C + VATEX_EU_143_1_D -> Known.VATEX_EU_143_1_D + VATEX_EU_143_1_E -> Known.VATEX_EU_143_1_E + VATEX_EU_143_1_F -> Known.VATEX_EU_143_1_F + VATEX_EU_143_1_FA -> Known.VATEX_EU_143_1_FA + VATEX_EU_143_1_G -> Known.VATEX_EU_143_1_G + VATEX_EU_143_1_H -> Known.VATEX_EU_143_1_H + VATEX_EU_143_1_I -> Known.VATEX_EU_143_1_I + VATEX_EU_143_1_J -> Known.VATEX_EU_143_1_J + VATEX_EU_143_1_K -> Known.VATEX_EU_143_1_K + VATEX_EU_143_1_L -> Known.VATEX_EU_143_1_L + VATEX_EU_144 -> Known.VATEX_EU_144 + VATEX_EU_146_1_E -> Known.VATEX_EU_146_1_E + VATEX_EU_148 -> Known.VATEX_EU_148 + VATEX_EU_148_A -> Known.VATEX_EU_148_A + VATEX_EU_148_B -> Known.VATEX_EU_148_B + VATEX_EU_148_C -> Known.VATEX_EU_148_C + VATEX_EU_148_D -> Known.VATEX_EU_148_D + VATEX_EU_148_E -> Known.VATEX_EU_148_E + VATEX_EU_148_F -> Known.VATEX_EU_148_F + VATEX_EU_148_G -> Known.VATEX_EU_148_G + VATEX_EU_151 -> Known.VATEX_EU_151 + VATEX_EU_151_1_A -> Known.VATEX_EU_151_1_A + VATEX_EU_151_1_AA -> Known.VATEX_EU_151_1_AA + VATEX_EU_151_1_B -> Known.VATEX_EU_151_1_B + VATEX_EU_151_1_C -> Known.VATEX_EU_151_1_C + VATEX_EU_151_1_D -> Known.VATEX_EU_151_1_D + VATEX_EU_151_1_E -> Known.VATEX_EU_151_1_E + VATEX_EU_159 -> Known.VATEX_EU_159 + VATEX_EU_309 -> Known.VATEX_EU_309 + VATEX_EU_AE -> Known.VATEX_EU_AE + VATEX_EU_D -> Known.VATEX_EU_D + VATEX_EU_F -> Known.VATEX_EU_F + VATEX_EU_G -> Known.VATEX_EU_G + VATEX_EU_I -> Known.VATEX_EU_I + VATEX_EU_IC -> Known.VATEX_EU_IC + VATEX_EU_O -> Known.VATEX_EU_O + VATEX_EU_J -> Known.VATEX_EU_J + VATEX_FR_FRANCHISE -> Known.VATEX_FR_FRANCHISE + VATEX_FR_CNWVAT -> Known.VATEX_FR_CNWVAT + else -> throw EInvoiceInvalidDataException("Unknown Vatex: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Vatex = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Vatex && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2845,9 +3629,12 @@ private constructor( shippingAddressRecipient == other.shippingAddressRecipient && state == other.state && subtotal == other.subtotal && + taxCode == other.taxCode && taxDetails == other.taxDetails && totalDiscount == other.totalDiscount && totalTax == other.totalTax && + vatex == other.vatex && + vatexNote == other.vatexNote && vendorAddress == other.vendorAddress && vendorAddressRecipient == other.vendorAddressRecipient && vendorEmail == other.vendorEmail && @@ -2892,9 +3679,12 @@ private constructor( shippingAddressRecipient, state, subtotal, + taxCode, taxDetails, totalDiscount, totalTax, + vatex, + vatexNote, vendorAddress, vendorAddressRecipient, vendorEmail, @@ -2907,5 +3697,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "DocumentResponse{id=$id, amountDue=$amountDue, attachments=$attachments, billingAddress=$billingAddress, billingAddressRecipient=$billingAddressRecipient, currency=$currency, customerAddress=$customerAddress, customerAddressRecipient=$customerAddressRecipient, customerEmail=$customerEmail, customerId=$customerId, customerName=$customerName, customerTaxId=$customerTaxId, direction=$direction, documentType=$documentType, dueDate=$dueDate, invoiceDate=$invoiceDate, invoiceId=$invoiceId, invoiceTotal=$invoiceTotal, items=$items, note=$note, paymentDetails=$paymentDetails, paymentTerm=$paymentTerm, previousUnpaidBalance=$previousUnpaidBalance, purchaseOrder=$purchaseOrder, remittanceAddress=$remittanceAddress, remittanceAddressRecipient=$remittanceAddressRecipient, serviceAddress=$serviceAddress, serviceAddressRecipient=$serviceAddressRecipient, serviceEndDate=$serviceEndDate, serviceStartDate=$serviceStartDate, shippingAddress=$shippingAddress, shippingAddressRecipient=$shippingAddressRecipient, state=$state, subtotal=$subtotal, taxDetails=$taxDetails, totalDiscount=$totalDiscount, totalTax=$totalTax, vendorAddress=$vendorAddress, vendorAddressRecipient=$vendorAddressRecipient, vendorEmail=$vendorEmail, vendorName=$vendorName, vendorTaxId=$vendorTaxId, additionalProperties=$additionalProperties}" + "DocumentResponse{id=$id, amountDue=$amountDue, attachments=$attachments, billingAddress=$billingAddress, billingAddressRecipient=$billingAddressRecipient, currency=$currency, customerAddress=$customerAddress, customerAddressRecipient=$customerAddressRecipient, customerEmail=$customerEmail, customerId=$customerId, customerName=$customerName, customerTaxId=$customerTaxId, direction=$direction, documentType=$documentType, dueDate=$dueDate, invoiceDate=$invoiceDate, invoiceId=$invoiceId, invoiceTotal=$invoiceTotal, items=$items, note=$note, paymentDetails=$paymentDetails, paymentTerm=$paymentTerm, previousUnpaidBalance=$previousUnpaidBalance, purchaseOrder=$purchaseOrder, remittanceAddress=$remittanceAddress, remittanceAddressRecipient=$remittanceAddressRecipient, serviceAddress=$serviceAddress, serviceAddressRecipient=$serviceAddressRecipient, serviceEndDate=$serviceEndDate, serviceStartDate=$serviceStartDate, shippingAddress=$shippingAddress, shippingAddressRecipient=$shippingAddressRecipient, state=$state, subtotal=$subtotal, taxCode=$taxCode, taxDetails=$taxDetails, totalDiscount=$totalDiscount, totalTax=$totalTax, vatex=$vatex, vatexNote=$vatexNote, vendorAddress=$vendorAddress, vendorAddressRecipient=$vendorAddressRecipient, vendorEmail=$vendorEmail, vendorName=$vendorName, vendorTaxId=$vendorTaxId, additionalProperties=$additionalProperties}" } diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateParamsTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateParamsTest.kt index 8378674..bc9823b 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateParamsTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateParamsTest.kt @@ -73,11 +73,14 @@ internal class DocumentCreateParamsTest { .shippingAddressRecipient("shipping_address_recipient") .state(DocumentState.DRAFT) .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) .addTaxDetail( DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() ) .totalDiscount(0.0) .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") .vendorEmail("vendor_email") @@ -153,11 +156,14 @@ internal class DocumentCreateParamsTest { .shippingAddressRecipient("shipping_address_recipient") .state(DocumentState.DRAFT) .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) .addTaxDetail( DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() ) .totalDiscount(0.0) .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") .vendorEmail("vendor_email") @@ -231,11 +237,14 @@ internal class DocumentCreateParamsTest { .shippingAddressRecipient("shipping_address_recipient") .state(DocumentState.DRAFT) .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) .addTaxDetail( DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() ) .totalDiscount(0.0) .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") .vendorEmail("vendor_email") diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateTest.kt index fff0f2b..3634e79 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateTest.kt @@ -75,9 +75,12 @@ internal class DocumentCreateTest { .shippingAddressRecipient("shipping_address_recipient") .state(DocumentState.DRAFT) .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) .addTaxDetail(DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build()) .totalDiscount(0.0) .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") .vendorEmail("vendor_email") @@ -150,11 +153,14 @@ internal class DocumentCreateTest { assertThat(documentCreate.shippingAddressRecipient()).contains("shipping_address_recipient") assertThat(documentCreate.state()).contains(DocumentState.DRAFT) assertThat(documentCreate.subtotal()).contains(DocumentCreate.Subtotal.ofNumber(0.0)) + assertThat(documentCreate.taxCode()).contains(DocumentCreate.TaxCode.AE) assertThat(documentCreate.taxDetails().getOrNull()) .containsExactly(DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build()) assertThat(documentCreate.totalDiscount()) .contains(DocumentCreate.TotalDiscount.ofNumber(0.0)) assertThat(documentCreate.totalTax()).contains(DocumentCreate.TotalTax.ofNumber(0.0)) + assertThat(documentCreate.vatex()).contains(DocumentCreate.Vatex.VATEX_EU_79_C) + assertThat(documentCreate.vatexNote()).contains("vatex_note") assertThat(documentCreate.vendorAddress()).contains("vendor_address") assertThat(documentCreate.vendorAddressRecipient()).contains("vendor_address_recipient") assertThat(documentCreate.vendorEmail()).contains("vendor_email") @@ -226,9 +232,12 @@ internal class DocumentCreateTest { .shippingAddressRecipient("shipping_address_recipient") .state(DocumentState.DRAFT) .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) .addTaxDetail(DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build()) .totalDiscount(0.0) .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") .vendorEmail("vendor_email") diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentResponseTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentResponseTest.kt index 3fcf1ab..868ed71 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentResponseTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentResponseTest.kt @@ -78,11 +78,14 @@ internal class DocumentResponseTest { .shippingAddressRecipient("shipping_address_recipient") .state(DocumentState.DRAFT) .subtotal("subtotal") + .taxCode(DocumentResponse.TaxCode.AE) .addTaxDetail( DocumentResponse.TaxDetail.builder().amount("amount").rate("rate").build() ) .totalDiscount("total_discount") .totalTax("total_tax") + .vatex(DocumentResponse.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") .vendorEmail("vendor_email") @@ -157,12 +160,15 @@ internal class DocumentResponseTest { .contains("shipping_address_recipient") assertThat(documentResponse.state()).contains(DocumentState.DRAFT) assertThat(documentResponse.subtotal()).contains("subtotal") + assertThat(documentResponse.taxCode()).contains(DocumentResponse.TaxCode.AE) assertThat(documentResponse.taxDetails().getOrNull()) .containsExactly( DocumentResponse.TaxDetail.builder().amount("amount").rate("rate").build() ) assertThat(documentResponse.totalDiscount()).contains("total_discount") assertThat(documentResponse.totalTax()).contains("total_tax") + assertThat(documentResponse.vatex()).contains(DocumentResponse.Vatex.VATEX_EU_79_C) + assertThat(documentResponse.vatexNote()).contains("vatex_note") assertThat(documentResponse.vendorAddress()).contains("vendor_address") assertThat(documentResponse.vendorAddressRecipient()).contains("vendor_address_recipient") assertThat(documentResponse.vendorEmail()).contains("vendor_email") @@ -236,11 +242,14 @@ internal class DocumentResponseTest { .shippingAddressRecipient("shipping_address_recipient") .state(DocumentState.DRAFT) .subtotal("subtotal") + .taxCode(DocumentResponse.TaxCode.AE) .addTaxDetail( DocumentResponse.TaxDetail.builder().amount("amount").rate("rate").build() ) .totalDiscount("total_discount") .totalTax("total_tax") + .vatex(DocumentResponse.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") .vendorEmail("vendor_email") diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt index f7d2eee..464c599 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt @@ -83,6 +83,7 @@ internal class PaginatedDocumentResponseTest { .shippingAddressRecipient("shipping_address_recipient") .state(DocumentState.DRAFT) .subtotal("subtotal") + .taxCode(DocumentResponse.TaxCode.AE) .addTaxDetail( DocumentResponse.TaxDetail.builder() .amount("amount") @@ -91,6 +92,8 @@ internal class PaginatedDocumentResponseTest { ) .totalDiscount("total_discount") .totalTax("total_tax") + .vatex(DocumentResponse.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") .vendorEmail("vendor_email") @@ -168,11 +171,14 @@ internal class PaginatedDocumentResponseTest { .shippingAddressRecipient("shipping_address_recipient") .state(DocumentState.DRAFT) .subtotal("subtotal") + .taxCode(DocumentResponse.TaxCode.AE) .addTaxDetail( DocumentResponse.TaxDetail.builder().amount("amount").rate("rate").build() ) .totalDiscount("total_discount") .totalTax("total_tax") + .vatex(DocumentResponse.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") .vendorEmail("vendor_email") @@ -254,6 +260,7 @@ internal class PaginatedDocumentResponseTest { .shippingAddressRecipient("shipping_address_recipient") .state(DocumentState.DRAFT) .subtotal("subtotal") + .taxCode(DocumentResponse.TaxCode.AE) .addTaxDetail( DocumentResponse.TaxDetail.builder() .amount("amount") @@ -262,6 +269,8 @@ internal class PaginatedDocumentResponseTest { ) .totalDiscount("total_discount") .totalTax("total_tax") + .vatex(DocumentResponse.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") .vendorEmail("vendor_email") diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/validate/ValidateValidateJsonParamsTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/validate/ValidateValidateJsonParamsTest.kt index a468954..b5e1f9f 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/validate/ValidateValidateJsonParamsTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/validate/ValidateValidateJsonParamsTest.kt @@ -80,11 +80,14 @@ internal class ValidateValidateJsonParamsTest { .shippingAddressRecipient("shipping_address_recipient") .state(DocumentState.DRAFT) .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) .addTaxDetail( DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() ) .totalDiscount(0.0) .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") .vendorEmail("vendor_email") @@ -160,11 +163,14 @@ internal class ValidateValidateJsonParamsTest { .shippingAddressRecipient("shipping_address_recipient") .state(DocumentState.DRAFT) .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) .addTaxDetail( DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() ) .totalDiscount(0.0) .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") .vendorEmail("vendor_email") @@ -238,11 +244,14 @@ internal class ValidateValidateJsonParamsTest { .shippingAddressRecipient("shipping_address_recipient") .state(DocumentState.DRAFT) .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) .addTaxDetail( DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() ) .totalDiscount(0.0) .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") .vendorEmail("vendor_email") diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ErrorHandlingTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ErrorHandlingTest.kt index 238a059..f0358f1 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ErrorHandlingTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ErrorHandlingTest.kt @@ -139,11 +139,14 @@ internal class ErrorHandlingTest { .shippingAddressRecipient("shipping_address_recipient") .state(DocumentState.DRAFT) .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) .addTaxDetail( DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() ) .totalDiscount(0.0) .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") .vendorEmail("vendor_email") @@ -231,11 +234,14 @@ internal class ErrorHandlingTest { .shippingAddressRecipient("shipping_address_recipient") .state(DocumentState.DRAFT) .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) .addTaxDetail( DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() ) .totalDiscount(0.0) .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") .vendorEmail("vendor_email") @@ -323,11 +329,14 @@ internal class ErrorHandlingTest { .shippingAddressRecipient("shipping_address_recipient") .state(DocumentState.DRAFT) .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) .addTaxDetail( DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() ) .totalDiscount(0.0) .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") .vendorEmail("vendor_email") @@ -415,11 +424,14 @@ internal class ErrorHandlingTest { .shippingAddressRecipient("shipping_address_recipient") .state(DocumentState.DRAFT) .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) .addTaxDetail( DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() ) .totalDiscount(0.0) .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") .vendorEmail("vendor_email") @@ -507,11 +519,14 @@ internal class ErrorHandlingTest { .shippingAddressRecipient("shipping_address_recipient") .state(DocumentState.DRAFT) .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) .addTaxDetail( DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() ) .totalDiscount(0.0) .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") .vendorEmail("vendor_email") @@ -599,11 +614,14 @@ internal class ErrorHandlingTest { .shippingAddressRecipient("shipping_address_recipient") .state(DocumentState.DRAFT) .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) .addTaxDetail( DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() ) .totalDiscount(0.0) .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") .vendorEmail("vendor_email") @@ -691,11 +709,14 @@ internal class ErrorHandlingTest { .shippingAddressRecipient("shipping_address_recipient") .state(DocumentState.DRAFT) .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) .addTaxDetail( DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() ) .totalDiscount(0.0) .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") .vendorEmail("vendor_email") @@ -783,11 +804,14 @@ internal class ErrorHandlingTest { .shippingAddressRecipient("shipping_address_recipient") .state(DocumentState.DRAFT) .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) .addTaxDetail( DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() ) .totalDiscount(0.0) .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") .vendorEmail("vendor_email") @@ -875,11 +899,14 @@ internal class ErrorHandlingTest { .shippingAddressRecipient("shipping_address_recipient") .state(DocumentState.DRAFT) .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) .addTaxDetail( DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() ) .totalDiscount(0.0) .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") .vendorEmail("vendor_email") @@ -967,11 +994,14 @@ internal class ErrorHandlingTest { .shippingAddressRecipient("shipping_address_recipient") .state(DocumentState.DRAFT) .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) .addTaxDetail( DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() ) .totalDiscount(0.0) .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") .vendorEmail("vendor_email") @@ -1059,11 +1089,14 @@ internal class ErrorHandlingTest { .shippingAddressRecipient("shipping_address_recipient") .state(DocumentState.DRAFT) .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) .addTaxDetail( DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() ) .totalDiscount(0.0) .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") .vendorEmail("vendor_email") @@ -1151,11 +1184,14 @@ internal class ErrorHandlingTest { .shippingAddressRecipient("shipping_address_recipient") .state(DocumentState.DRAFT) .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) .addTaxDetail( DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() ) .totalDiscount(0.0) .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") .vendorEmail("vendor_email") @@ -1243,11 +1279,14 @@ internal class ErrorHandlingTest { .shippingAddressRecipient("shipping_address_recipient") .state(DocumentState.DRAFT) .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) .addTaxDetail( DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() ) .totalDiscount(0.0) .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") .vendorEmail("vendor_email") @@ -1335,11 +1374,14 @@ internal class ErrorHandlingTest { .shippingAddressRecipient("shipping_address_recipient") .state(DocumentState.DRAFT) .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) .addTaxDetail( DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() ) .totalDiscount(0.0) .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") .vendorEmail("vendor_email") @@ -1427,11 +1469,14 @@ internal class ErrorHandlingTest { .shippingAddressRecipient("shipping_address_recipient") .state(DocumentState.DRAFT) .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) .addTaxDetail( DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() ) .totalDiscount(0.0) .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") .vendorEmail("vendor_email") @@ -1519,11 +1564,14 @@ internal class ErrorHandlingTest { .shippingAddressRecipient("shipping_address_recipient") .state(DocumentState.DRAFT) .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) .addTaxDetail( DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() ) .totalDiscount(0.0) .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") .vendorEmail("vendor_email") @@ -1609,11 +1657,14 @@ internal class ErrorHandlingTest { .shippingAddressRecipient("shipping_address_recipient") .state(DocumentState.DRAFT) .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) .addTaxDetail( DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() ) .totalDiscount(0.0) .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") .vendorEmail("vendor_email") diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ServiceParamsTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ServiceParamsTest.kt index eb5ef34..e8b1cd5 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ServiceParamsTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ServiceParamsTest.kt @@ -109,9 +109,12 @@ internal class ServiceParamsTest { .shippingAddressRecipient("shipping_address_recipient") .state(DocumentState.DRAFT) .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) .addTaxDetail(DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build()) .totalDiscount(0.0) .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") .vendorEmail("vendor_email") diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncTest.kt index 4edc2f0..d80b572 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncTest.kt @@ -93,11 +93,14 @@ internal class DocumentServiceAsyncTest { .shippingAddressRecipient("shipping_address_recipient") .state(DocumentState.DRAFT) .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) .addTaxDetail( DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() ) .totalDiscount(0.0) .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") .vendorEmail("vendor_email") diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/ValidateServiceAsyncTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/ValidateServiceAsyncTest.kt index 4ad06da..3cd4c41 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/ValidateServiceAsyncTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/ValidateServiceAsyncTest.kt @@ -94,11 +94,14 @@ internal class ValidateServiceAsyncTest { .shippingAddressRecipient("shipping_address_recipient") .state(DocumentState.DRAFT) .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) .addTaxDetail( DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() ) .totalDiscount(0.0) .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") .vendorEmail("vendor_email") diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/DocumentServiceTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/DocumentServiceTest.kt index 8d4aecf..bd40335 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/DocumentServiceTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/DocumentServiceTest.kt @@ -93,11 +93,14 @@ internal class DocumentServiceTest { .shippingAddressRecipient("shipping_address_recipient") .state(DocumentState.DRAFT) .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) .addTaxDetail( DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() ) .totalDiscount(0.0) .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") .vendorEmail("vendor_email") diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/ValidateServiceTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/ValidateServiceTest.kt index aa7a03c..6942489 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/ValidateServiceTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/ValidateServiceTest.kt @@ -94,11 +94,14 @@ internal class ValidateServiceTest { .shippingAddressRecipient("shipping_address_recipient") .state(DocumentState.DRAFT) .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) .addTaxDetail( DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() ) .totalDiscount(0.0) .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") .vendorEmail("vendor_email") From 7c8d5d6baaf53b8fa24983e413280c44ef6783bb Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 8 Oct 2025 19:23:48 +0000 Subject: [PATCH 02/43] feat(api): api update --- .stats.yml | 4 +- .../api/models/documents/DocumentCreate.kt | 6492 +++++++++++++++-- .../api/models/documents/DocumentResponse.kt | 3223 +++++++- .../documents/DocumentCreateParamsTest.kt | 132 + .../models/documents/DocumentCreateTest.kt | 134 + .../models/documents/DocumentResponseTest.kt | 134 + .../inbox/PaginatedDocumentResponseTest.kt | 132 + .../ValidateValidateJsonParamsTest.kt | 132 + .../api/services/ErrorHandlingTest.kt | 748 ++ .../api/services/ServiceParamsTest.kt | 44 + .../async/DocumentServiceAsyncTest.kt | 44 + .../async/ValidateServiceAsyncTest.kt | 44 + .../services/blocking/DocumentServiceTest.kt | 44 + .../services/blocking/ValidateServiceTest.kt | 44 + 14 files changed, 10399 insertions(+), 952 deletions(-) diff --git a/.stats.yml b/.stats.yml index a8a19e1..9c43dc7 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 24 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-1108f2708fdafd879e0ff7b2826977c764458d1f17420711a9cee28f80e2567f.yml -openapi_spec_hash: 70dbf05e6e7f68a238c7b79cdf9e8e6b +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-8edeb779b7c54508db755723beba2b378c3bf6566b460c25ccbae3341f00d675.yml +openapi_spec_hash: 4090ba8c97e2ceb86ce1c7ff994601af config_hash: d627f345d2cab6590eeea9820301272e diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt index 2c32fa4..1011c48 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt @@ -35,10 +35,12 @@ import kotlin.jvm.optionals.getOrNull class DocumentCreate @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val allowances: JsonField>, private val amountDue: JsonField, private val attachments: JsonField>, private val billingAddress: JsonField, private val billingAddressRecipient: JsonField, + private val charges: JsonField>, private val currency: JsonField, private val customerAddress: JsonField, private val customerAddressRecipient: JsonField, @@ -84,6 +86,9 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("allowances") + @ExcludeMissing + allowances: JsonField> = JsonMissing.of(), @JsonProperty("amount_due") @ExcludeMissing amountDue: JsonField = JsonMissing.of(), @@ -96,6 +101,9 @@ private constructor( @JsonProperty("billing_address_recipient") @ExcludeMissing billingAddressRecipient: JsonField = JsonMissing.of(), + @JsonProperty("charges") + @ExcludeMissing + charges: JsonField> = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @@ -197,10 +205,12 @@ private constructor( @ExcludeMissing vendorTaxId: JsonField = JsonMissing.of(), ) : this( + allowances, amountDue, attachments, billingAddress, billingAddressRecipient, + charges, currency, customerAddress, customerAddressRecipient, @@ -248,6 +258,14 @@ private constructor( * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ + fun allowances(): Optional> = allowances.getOptional("allowances") + + /** + * The amount due of the invoice. Must be positive and rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun amountDue(): Optional = amountDue.getOptional("amount_due") /** @@ -270,6 +288,12 @@ private constructor( fun billingAddressRecipient(): Optional = billingAddressRecipient.getOptional("billing_address_recipient") + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun charges(): Optional> = charges.getOptional("charges") + /** * Currency of the invoice * @@ -346,12 +370,17 @@ private constructor( fun invoiceId(): Optional = invoiceId.getOptional("invoice_id") /** + * The total amount of the invoice (so invoice_total = subtotal + total_tax + total_discount). + * Must be positive and rounded to maximum 2 decimals + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun invoiceTotal(): Optional = invoiceTotal.getOptional("invoice_total") /** + * At least one line item is required + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -377,6 +406,9 @@ private constructor( fun paymentTerm(): Optional = paymentTerm.getOptional("payment_term") /** + * The previous unpaid balance of the invoice, if any. Must be positive and rounded to maximum 2 + * decimals + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -447,6 +479,10 @@ private constructor( fun state(): Optional = state.getOptional("state") /** + * The taxable base of the invoice. Should be the sum of all line items - allowances (for + * example commercial discounts) + charges with impact on VAT. Must be positive and rounded to + * maximum 2 decimals + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -467,12 +503,17 @@ private constructor( fun taxDetails(): Optional> = taxDetails.getOptional("tax_details") /** + * The total financial discount of the invoice (so discounts not subject to VAT). Must be + * positive and rounded to maximum 2 decimals + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun totalDiscount(): Optional = totalDiscount.getOptional("total_discount") /** + * The total tax of the invoice. Must be positive and rounded to maximum 2 decimals + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -527,6 +568,15 @@ private constructor( */ fun vendorTaxId(): Optional = vendorTaxId.getOptional("vendor_tax_id") + /** + * Returns the raw JSON value of [allowances]. + * + * Unlike [allowances], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("allowances") + @ExcludeMissing + fun _allowances(): JsonField> = allowances + /** * Returns the raw JSON value of [amountDue]. * @@ -562,6 +612,13 @@ private constructor( @ExcludeMissing fun _billingAddressRecipient(): JsonField = billingAddressRecipient + /** + * Returns the raw JSON value of [charges]. + * + * Unlike [charges], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("charges") @ExcludeMissing fun _charges(): JsonField> = charges + /** * Returns the raw JSON value of [currency]. * @@ -925,10 +982,12 @@ private constructor( /** A builder for [DocumentCreate]. */ class Builder internal constructor() { + private var allowances: JsonField>? = null private var amountDue: JsonField = JsonMissing.of() private var attachments: JsonField>? = null private var billingAddress: JsonField = JsonMissing.of() private var billingAddressRecipient: JsonField = JsonMissing.of() + private var charges: JsonField>? = null private var currency: JsonField = JsonMissing.of() private var customerAddress: JsonField = JsonMissing.of() private var customerAddressRecipient: JsonField = JsonMissing.of() @@ -973,10 +1032,12 @@ private constructor( @JvmSynthetic internal fun from(documentCreate: DocumentCreate) = apply { + allowances = documentCreate.allowances.map { it.toMutableList() } amountDue = documentCreate.amountDue attachments = documentCreate.attachments.map { it.toMutableList() } billingAddress = documentCreate.billingAddress billingAddressRecipient = documentCreate.billingAddressRecipient + charges = documentCreate.charges.map { it.toMutableList() } currency = documentCreate.currency customerAddress = documentCreate.customerAddress customerAddressRecipient = documentCreate.customerAddressRecipient @@ -1020,6 +1081,35 @@ private constructor( additionalProperties = documentCreate.additionalProperties.toMutableMap() } + fun allowances(allowances: List?) = allowances(JsonField.ofNullable(allowances)) + + /** Alias for calling [Builder.allowances] with `allowances.orElse(null)`. */ + fun allowances(allowances: Optional>) = allowances(allowances.getOrNull()) + + /** + * Sets [Builder.allowances] to an arbitrary JSON value. + * + * You should usually call [Builder.allowances] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun allowances(allowances: JsonField>) = apply { + this.allowances = allowances.map { it.toMutableList() } + } + + /** + * Adds a single [Allowance] to [allowances]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowance(allowance: Allowance) = apply { + allowances = + (allowances ?: JsonField.of(mutableListOf())).also { + checkKnown("allowances", it).add(allowance) + } + } + + /** The amount due of the invoice. Must be positive and rounded to maximum 2 decimals */ fun amountDue(amountDue: AmountDue?) = amountDue(JsonField.ofNullable(amountDue)) /** Alias for calling [Builder.amountDue] with `amountDue.orElse(null)`. */ @@ -1109,6 +1199,34 @@ private constructor( this.billingAddressRecipient = billingAddressRecipient } + fun charges(charges: List?) = charges(JsonField.ofNullable(charges)) + + /** Alias for calling [Builder.charges] with `charges.orElse(null)`. */ + fun charges(charges: Optional>) = charges(charges.getOrNull()) + + /** + * Sets [Builder.charges] to an arbitrary JSON value. + * + * You should usually call [Builder.charges] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun charges(charges: JsonField>) = apply { + this.charges = charges.map { it.toMutableList() } + } + + /** + * Adds a single [Charge] to [charges]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCharge(charge: Charge) = apply { + charges = + (charges ?: JsonField.of(mutableListOf())).also { + checkKnown("charges", it).add(charge) + } + } + /** Currency of the invoice */ fun currency(currency: CurrencyCode) = currency(JsonField.of(currency)) @@ -1296,6 +1414,10 @@ private constructor( */ fun invoiceId(invoiceId: JsonField) = apply { this.invoiceId = invoiceId } + /** + * The total amount of the invoice (so invoice_total = subtotal + total_tax + + * total_discount). Must be positive and rounded to maximum 2 decimals + */ fun invoiceTotal(invoiceTotal: InvoiceTotal?) = invoiceTotal(JsonField.ofNullable(invoiceTotal)) @@ -1320,10 +1442,8 @@ private constructor( /** Alias for calling [invoiceTotal] with `InvoiceTotal.ofString(string)`. */ fun invoiceTotal(string: String) = invoiceTotal(InvoiceTotal.ofString(string)) - fun items(items: List?) = items(JsonField.ofNullable(items)) - - /** Alias for calling [Builder.items] with `items.orElse(null)`. */ - fun items(items: Optional>) = items(items.getOrNull()) + /** At least one line item is required */ + fun items(items: List) = items(JsonField.of(items)) /** * Sets [Builder.items] to an arbitrary JSON value. @@ -1403,6 +1523,10 @@ private constructor( */ fun paymentTerm(paymentTerm: JsonField) = apply { this.paymentTerm = paymentTerm } + /** + * The previous unpaid balance of the invoice, if any. Must be positive and rounded to + * maximum 2 decimals + */ fun previousUnpaidBalance(previousUnpaidBalance: PreviousUnpaidBalance?) = previousUnpaidBalance(JsonField.ofNullable(previousUnpaidBalance)) @@ -1618,6 +1742,11 @@ private constructor( */ fun state(state: JsonField) = apply { this.state = state } + /** + * The taxable base of the invoice. Should be the sum of all line items - allowances (for + * example commercial discounts) + charges with impact on VAT. Must be positive and rounded + * to maximum 2 decimals + */ fun subtotal(subtotal: Subtotal?) = subtotal(JsonField.ofNullable(subtotal)) /** Alias for calling [Builder.subtotal] with `subtotal.orElse(null)`. */ @@ -1677,6 +1806,10 @@ private constructor( } } + /** + * The total financial discount of the invoice (so discounts not subject to VAT). Must be + * positive and rounded to maximum 2 decimals + */ fun totalDiscount(totalDiscount: TotalDiscount?) = totalDiscount(JsonField.ofNullable(totalDiscount)) @@ -1701,6 +1834,7 @@ private constructor( /** Alias for calling [totalDiscount] with `TotalDiscount.ofString(string)`. */ fun totalDiscount(string: String) = totalDiscount(TotalDiscount.ofString(string)) + /** The total tax of the invoice. Must be positive and rounded to maximum 2 decimals */ fun totalTax(totalTax: TotalTax?) = totalTax(JsonField.ofNullable(totalTax)) /** Alias for calling [Builder.totalTax] with `totalTax.orElse(null)`. */ @@ -1861,10 +1995,12 @@ private constructor( */ fun build(): DocumentCreate = DocumentCreate( + (allowances ?: JsonMissing.of()).map { it.toImmutable() }, amountDue, (attachments ?: JsonMissing.of()).map { it.toImmutable() }, billingAddress, billingAddressRecipient, + (charges ?: JsonMissing.of()).map { it.toImmutable() }, currency, customerAddress, customerAddressRecipient, @@ -1916,10 +2052,12 @@ private constructor( return@apply } + allowances().ifPresent { it.forEach { it.validate() } } amountDue().ifPresent { it.validate() } attachments().ifPresent { it.forEach { it.validate() } } billingAddress() billingAddressRecipient() + charges().ifPresent { it.forEach { it.validate() } } currency().ifPresent { it.validate() } customerAddress() customerAddressRecipient() @@ -1978,10 +2116,12 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (amountDue.asKnown().getOrNull()?.validity() ?: 0) + + (allowances.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (amountDue.asKnown().getOrNull()?.validity() ?: 0) + (attachments.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (billingAddress.asKnown().isPresent) 1 else 0) + (if (billingAddressRecipient.asKnown().isPresent) 1 else 0) + + (charges.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (currency.asKnown().getOrNull()?.validity() ?: 0) + (if (customerAddress.asKnown().isPresent) 1 else 0) + (if (customerAddressRecipient.asKnown().isPresent) 1 else 0) + @@ -2023,219 +2163,401 @@ private constructor( (if (vendorName.asKnown().isPresent) 1 else 0) + (if (vendorTaxId.asKnown().isPresent) 1 else 0) - @JsonDeserialize(using = AmountDue.Deserializer::class) - @JsonSerialize(using = AmountDue.Serializer::class) - class AmountDue + /** An allowance is a discount for example for early payment, volume discount, etc. */ + class Allowance + @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val number: Double? = null, - private val string: String? = null, - private val _json: JsonValue? = null, + private val amount: JsonField, + private val baseAmount: JsonField, + private val multiplierFactor: JsonField, + private val reason: JsonField, + private val reasonCode: JsonField, + private val taxCode: JsonField, + private val taxRate: JsonField, + private val additionalProperties: MutableMap, ) { - fun number(): Optional = Optional.ofNullable(number) - - fun string(): Optional = Optional.ofNullable(string) - - fun isNumber(): Boolean = number != null + @JsonCreator + private constructor( + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("base_amount") + @ExcludeMissing + baseAmount: JsonField = JsonMissing.of(), + @JsonProperty("multiplier_factor") + @ExcludeMissing + multiplierFactor: JsonField = JsonMissing.of(), + @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), + @JsonProperty("reason_code") + @ExcludeMissing + reasonCode: JsonField = JsonMissing.of(), + @JsonProperty("tax_code") + @ExcludeMissing + taxCode: JsonField = JsonMissing.of(), + @JsonProperty("tax_rate") @ExcludeMissing taxRate: JsonField = JsonMissing.of(), + ) : this( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + mutableMapOf(), + ) - fun isString(): Boolean = string != null + /** + * The allowance amount, without VAT. Must be rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") - fun asNumber(): Double = number.getOrThrow("number") + /** + * The base amount that may be used, in conjunction with the allowance percentage, to + * calculate the allowance amount. Must be rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun baseAmount(): Optional = baseAmount.getOptional("base_amount") - fun asString(): String = string.getOrThrow("string") + /** + * The percentage that may be used, in conjunction with the allowance base amount, to + * calculate the allowance amount. To state 20%, use value 20 + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun multiplierFactor(): Optional = + multiplierFactor.getOptional("multiplier_factor") - fun _json(): Optional = Optional.ofNullable(_json) + /** + * The reason for the allowance + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun reason(): Optional = reason.getOptional("reason") - fun accept(visitor: Visitor): T = - when { - number != null -> visitor.visitNumber(number) - string != null -> visitor.visitString(string) - else -> visitor.unknown(_json) - } + /** + * The code for the allowance reason + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun reasonCode(): Optional = reasonCode.getOptional("reason_code") - private var validated: Boolean = false + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun taxCode(): Optional = taxCode.getOptional("tax_code") - fun validate(): AmountDue = apply { - if (validated) { - return@apply - } + /** + * The VAT rate, represented as percentage that applies to the allowance + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun taxRate(): Optional = taxRate.getOptional("tax_rate") - accept( - object : Visitor { - override fun visitNumber(number: Double) {} + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - override fun visitString(string: String) {} - } - ) - validated = true - } + /** + * Returns the raw JSON value of [baseAmount]. + * + * Unlike [baseAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("base_amount") + @ExcludeMissing + fun _baseAmount(): JsonField = baseAmount - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false - } + /** + * Returns the raw JSON value of [multiplierFactor]. + * + * Unlike [multiplierFactor], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("multiplier_factor") + @ExcludeMissing + fun _multiplierFactor(): JsonField = multiplierFactor /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns the raw JSON value of [reason]. * - * Used for best match union deserialization. + * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type. */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitNumber(number: Double) = 1 + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - override fun visitString(string: String) = 1 + /** + * Returns the raw JSON value of [reasonCode]. + * + * Unlike [reasonCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reason_code") + @ExcludeMissing + fun _reasonCode(): JsonField = reasonCode - override fun unknown(json: JsonValue?) = 0 - } - ) + /** + * Returns the raw JSON value of [taxCode]. + * + * Unlike [taxCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax_code") @ExcludeMissing fun _taxCode(): JsonField = taxCode - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns the raw JSON value of [taxRate]. + * + * Unlike [taxRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate - return other is AmountDue && number == other.number && string == other.string + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - override fun hashCode(): Int = Objects.hash(number, string) + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - override fun toString(): String = - when { - number != null -> "AmountDue{number=$number}" - string != null -> "AmountDue{string=$string}" - _json != null -> "AmountDue{_unknown=$_json}" - else -> throw IllegalStateException("Invalid AmountDue") - } + fun toBuilder() = Builder().from(this) companion object { - @JvmStatic fun ofNumber(number: Double) = AmountDue(number = number) - - @JvmStatic fun ofString(string: String) = AmountDue(string = string) + /** Returns a mutable builder for constructing an instance of [Allowance]. */ + @JvmStatic fun builder() = Builder() } - /** - * An interface that defines how to map each variant of [AmountDue] to a value of type [T]. - */ - interface Visitor { + /** A builder for [Allowance]. */ + class Builder internal constructor() { - fun visitNumber(number: Double): T + private var amount: JsonField = JsonMissing.of() + private var baseAmount: JsonField = JsonMissing.of() + private var multiplierFactor: JsonField = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var reasonCode: JsonField = JsonMissing.of() + private var taxCode: JsonField = JsonMissing.of() + private var taxRate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - fun visitString(string: String): T + @JvmSynthetic + internal fun from(allowance: Allowance) = apply { + amount = allowance.amount + baseAmount = allowance.baseAmount + multiplierFactor = allowance.multiplierFactor + reason = allowance.reason + reasonCode = allowance.reasonCode + taxCode = allowance.taxCode + taxRate = allowance.taxRate + additionalProperties = allowance.additionalProperties.toMutableMap() + } + + /** The allowance amount, without VAT. Must be rounded to maximum 2 decimals */ + fun amount(amount: Amount?) = amount(JsonField.ofNullable(amount)) + + /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ + fun amount(amount: Optional) = amount(amount.getOrNull()) /** - * Maps an unknown variant of [AmountDue] to a value of type [T]. - * - * An instance of [AmountDue] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. + * Sets [Builder.amount] to an arbitrary JSON value. * - * @throws EInvoiceInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw EInvoiceInvalidDataException("Unknown AmountDue: $json") - } - } + * You should usually call [Builder.amount] with a well-typed [Amount] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } - internal class Deserializer : BaseDeserializer(AmountDue::class) { + /** Alias for calling [amount] with `Amount.ofNumber(number)`. */ + fun amount(number: Double) = amount(Amount.ofNumber(number)) - override fun ObjectCodec.deserialize(node: JsonNode): AmountDue { - val json = JsonValue.fromJsonNode(node) + /** Alias for calling [amount] with `Amount.ofString(string)`. */ + fun amount(string: String) = amount(Amount.ofString(string)) - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - AmountDue(number = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - AmountDue(string = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). - 0 -> AmountDue(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the first - // completely valid match, or simply the first match if none are completely - // valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } + /** + * The base amount that may be used, in conjunction with the allowance percentage, to + * calculate the allowance amount. Must be rounded to maximum 2 decimals + */ + fun baseAmount(baseAmount: BaseAmount?) = baseAmount(JsonField.ofNullable(baseAmount)) + + /** Alias for calling [Builder.baseAmount] with `baseAmount.orElse(null)`. */ + fun baseAmount(baseAmount: Optional) = baseAmount(baseAmount.getOrNull()) + + /** + * Sets [Builder.baseAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.baseAmount] with a well-typed [BaseAmount] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun baseAmount(baseAmount: JsonField) = apply { + this.baseAmount = baseAmount } - } - internal class Serializer : BaseSerializer(AmountDue::class) { + /** Alias for calling [baseAmount] with `BaseAmount.ofNumber(number)`. */ + fun baseAmount(number: Double) = baseAmount(BaseAmount.ofNumber(number)) - override fun serialize( - value: AmountDue, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.number != null -> generator.writeObject(value.number) - value.string != null -> generator.writeObject(value.string) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid AmountDue") - } + /** Alias for calling [baseAmount] with `BaseAmount.ofString(string)`. */ + fun baseAmount(string: String) = baseAmount(BaseAmount.ofString(string)) + + /** + * The percentage that may be used, in conjunction with the allowance base amount, to + * calculate the allowance amount. To state 20%, use value 20 + */ + fun multiplierFactor(multiplierFactor: MultiplierFactor?) = + multiplierFactor(JsonField.ofNullable(multiplierFactor)) + + /** + * Alias for calling [Builder.multiplierFactor] with `multiplierFactor.orElse(null)`. + */ + fun multiplierFactor(multiplierFactor: Optional) = + multiplierFactor(multiplierFactor.getOrNull()) + + /** + * Sets [Builder.multiplierFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.multiplierFactor] with a well-typed + * [MultiplierFactor] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun multiplierFactor(multiplierFactor: JsonField) = apply { + this.multiplierFactor = multiplierFactor } - } - } - @JsonDeserialize(using = InvoiceTotal.Deserializer::class) - @JsonSerialize(using = InvoiceTotal.Serializer::class) - class InvoiceTotal - private constructor( - private val number: Double? = null, - private val string: String? = null, - private val _json: JsonValue? = null, - ) { + /** Alias for calling [multiplierFactor] with `MultiplierFactor.ofNumber(number)`. */ + fun multiplierFactor(number: Double) = + multiplierFactor(MultiplierFactor.ofNumber(number)) - fun number(): Optional = Optional.ofNullable(number) + /** Alias for calling [multiplierFactor] with `MultiplierFactor.ofString(string)`. */ + fun multiplierFactor(string: String) = + multiplierFactor(MultiplierFactor.ofString(string)) - fun string(): Optional = Optional.ofNullable(string) + /** The reason for the allowance */ + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - fun isNumber(): Boolean = number != null + /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ + fun reason(reason: Optional) = reason(reason.getOrNull()) - fun isString(): Boolean = string != null + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } - fun asNumber(): Double = number.getOrThrow("number") + /** The code for the allowance reason */ + fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) - fun asString(): String = string.getOrThrow("string") + /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ + fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) - fun _json(): Optional = Optional.ofNullable(_json) + /** + * Sets [Builder.reasonCode] to an arbitrary JSON value. + * + * You should usually call [Builder.reasonCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode } - fun accept(visitor: Visitor): T = - when { - number != null -> visitor.visitNumber(number) - string != null -> visitor.visitString(string) - else -> visitor.unknown(_json) + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + */ + fun taxCode(taxCode: TaxCode?) = taxCode(JsonField.ofNullable(taxCode)) + + /** Alias for calling [Builder.taxCode] with `taxCode.orElse(null)`. */ + fun taxCode(taxCode: Optional) = taxCode(taxCode.getOrNull()) + + /** + * Sets [Builder.taxCode] to an arbitrary JSON value. + * + * You should usually call [Builder.taxCode] with a well-typed [TaxCode] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } + + /** The VAT rate, represented as percentage that applies to the allowance */ + fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) + + /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ + fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) + + /** + * Sets [Builder.taxRate] to an arbitrary JSON value. + * + * You should usually call [Builder.taxRate] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [Allowance]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Allowance = + Allowance( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + additionalProperties.toMutableMap(), + ) + } + private var validated: Boolean = false - fun validate(): InvoiceTotal = apply { + fun validate(): Allowance = apply { if (validated) { return@apply } - accept( - object : Visitor { - override fun visitNumber(number: Double) {} - - override fun visitString(string: String) {} - } - ) + amount().ifPresent { it.validate() } + baseAmount().ifPresent { it.validate() } + multiplierFactor().ifPresent { it.validate() } + reason() + reasonCode() + taxCode().ifPresent { it.validate() } + taxRate() validated = true } @@ -2255,741 +2577,5405 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - accept( - object : Visitor { - override fun visitNumber(number: Double) = 1 + (amount.asKnown().getOrNull()?.validity() ?: 0) + + (baseAmount.asKnown().getOrNull()?.validity() ?: 0) + + (multiplierFactor.asKnown().getOrNull()?.validity() ?: 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (if (reasonCode.asKnown().isPresent) 1 else 0) + + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + + (if (taxRate.asKnown().isPresent) 1 else 0) + + /** The allowance amount, without VAT. Must be rounded to maximum 2 decimals */ + @JsonDeserialize(using = Amount.Deserializer::class) + @JsonSerialize(using = Amount.Serializer::class) + class Amount + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { - override fun visitString(string: String) = 1 + fun number(): Optional = Optional.ofNullable(number) - override fun unknown(json: JsonValue?) = 0 - } - ) + fun string(): Optional = Optional.ofNullable(string) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun isNumber(): Boolean = number != null - return other is InvoiceTotal && number == other.number && string == other.string - } + fun isString(): Boolean = string != null - override fun hashCode(): Int = Objects.hash(number, string) + fun asNumber(): Double = number.getOrThrow("number") - override fun toString(): String = - when { - number != null -> "InvoiceTotal{number=$number}" - string != null -> "InvoiceTotal{string=$string}" - _json != null -> "InvoiceTotal{_unknown=$_json}" - else -> throw IllegalStateException("Invalid InvoiceTotal") - } + fun asString(): String = string.getOrThrow("string") - companion object { + fun _json(): Optional = Optional.ofNullable(_json) - @JvmStatic fun ofNumber(number: Double) = InvoiceTotal(number = number) + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } - @JvmStatic fun ofString(string: String) = InvoiceTotal(string = string) - } + private var validated: Boolean = false - /** - * An interface that defines how to map each variant of [InvoiceTotal] to a value of type - * [T]. - */ - interface Visitor { + fun validate(): Amount = apply { + if (validated) { + return@apply + } - fun visitNumber(number: Double): T + accept( + object : Visitor { + override fun visitNumber(number: Double) {} - fun visitString(string: String): T + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } /** - * Maps an unknown variant of [InvoiceTotal] to a value of type [T]. - * - * An instance of [InvoiceTotal] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the SDK - * is unaware of. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws EInvoiceInvalidDataException in the default implementation. + * Used for best match union deserialization. */ - fun unknown(json: JsonValue?): T { - throw EInvoiceInvalidDataException("Unknown InvoiceTotal: $json") - } - } - - internal class Deserializer : BaseDeserializer(InvoiceTotal::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): InvoiceTotal { - val json = JsonValue.fromJsonNode(node) + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - InvoiceTotal(number = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - InvoiceTotal(string = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). - 0 -> InvoiceTotal(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the first - // completely valid match, or simply the first match if none are completely - // valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Amount && number == other.number && string == other.string } - } - internal class Serializer : BaseSerializer(InvoiceTotal::class) { + override fun hashCode(): Int = Objects.hash(number, string) - override fun serialize( - value: InvoiceTotal, - generator: JsonGenerator, - provider: SerializerProvider, - ) { + override fun toString(): String = when { - value.number != null -> generator.writeObject(value.number) - value.string != null -> generator.writeObject(value.string) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid InvoiceTotal") + number != null -> "Amount{number=$number}" + string != null -> "Amount{string=$string}" + _json != null -> "Amount{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Amount") } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Amount(number = number) + + @JvmStatic fun ofString(string: String) = Amount(string = string) } - } - } - class Item - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val amount: JsonField, - private val date: JsonField, - private val description: JsonField, - private val productCode: JsonField, - private val quantity: JsonField, - private val tax: JsonField, - private val taxRate: JsonField, - private val unit: JsonField, - private val unitPrice: JsonField, - private val additionalProperties: MutableMap, - ) { + /** + * An interface that defines how to map each variant of [Amount] to a value of type [T]. + */ + interface Visitor { - @JsonCreator - private constructor( - @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("date") @ExcludeMissing date: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("product_code") - @ExcludeMissing - productCode: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - quantity: JsonField = JsonMissing.of(), - @JsonProperty("tax") @ExcludeMissing tax: JsonField = JsonMissing.of(), - @JsonProperty("tax_rate") @ExcludeMissing taxRate: JsonField = JsonMissing.of(), - @JsonProperty("unit") - @ExcludeMissing - unit: JsonField = JsonMissing.of(), - @JsonProperty("unit_price") - @ExcludeMissing - unitPrice: JsonField = JsonMissing.of(), - ) : this( - amount, - date, - description, - productCode, - quantity, - tax, - taxRate, - unit, - unitPrice, - mutableMapOf(), - ) + fun visitNumber(number: Double): T - /** - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") + fun visitString(string: String): T - /** - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun date(): Optional = date.getOptional("date") + /** + * Maps an unknown variant of [Amount] to a value of type [T]. + * + * An instance of [Amount] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws EInvoiceInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw EInvoiceInvalidDataException("Unknown Amount: $json") + } + } - /** - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun description(): Optional = description.getOptional("description") + internal class Deserializer : BaseDeserializer(Amount::class) { - /** - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun productCode(): Optional = productCode.getOptional("product_code") + override fun ObjectCodec.deserialize(node: JsonNode): Amount { + val json = JsonValue.fromJsonNode(node) - /** - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun quantity(): Optional = quantity.getOptional("quantity") + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Amount(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Amount(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> Amount(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } - /** - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun tax(): Optional = tax.getOptional("tax") + internal class Serializer : BaseSerializer(Amount::class) { - /** - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun taxRate(): Optional = taxRate.getOptional("tax_rate") + override fun serialize( + value: Amount, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Amount") + } + } + } + } /** - * Unit of Measure Codes from UNECERec20 used in Peppol BIS Billing 3.0. - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). + * The base amount that may be used, in conjunction with the allowance percentage, to + * calculate the allowance amount. Must be rounded to maximum 2 decimals */ - fun unit(): Optional = unit.getOptional("unit") + @JsonDeserialize(using = BaseAmount.Deserializer::class) + @JsonSerialize(using = BaseAmount.Serializer::class) + class BaseAmount + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { - /** - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun unitPrice(): Optional = unitPrice.getOptional("unit_price") + fun number(): Optional = Optional.ofNullable(number) - /** - * Returns the raw JSON value of [amount]. - * - * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + fun string(): Optional = Optional.ofNullable(string) - /** - * Returns the raw JSON value of [date]. - * - * Unlike [date], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("date") @ExcludeMissing fun _date(): JsonField = date + fun isNumber(): Boolean = number != null - /** - * Returns the raw JSON value of [description]. - * - * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description + fun isString(): Boolean = string != null - /** - * Returns the raw JSON value of [productCode]. - * - * Unlike [productCode], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("product_code") - @ExcludeMissing - fun _productCode(): JsonField = productCode + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): BaseAmount = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BaseAmount && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "BaseAmount{number=$number}" + string != null -> "BaseAmount{string=$string}" + _json != null -> "BaseAmount{_unknown=$_json}" + else -> throw IllegalStateException("Invalid BaseAmount") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = BaseAmount(number = number) + + @JvmStatic fun ofString(string: String) = BaseAmount(string = string) + } + + /** + * An interface that defines how to map each variant of [BaseAmount] to a value of type + * [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [BaseAmount] to a value of type [T]. + * + * An instance of [BaseAmount] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws EInvoiceInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw EInvoiceInvalidDataException("Unknown BaseAmount: $json") + } + } + + internal class Deserializer : BaseDeserializer(BaseAmount::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): BaseAmount { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + BaseAmount(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + BaseAmount(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> BaseAmount(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(BaseAmount::class) { + + override fun serialize( + value: BaseAmount, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid BaseAmount") + } + } + } + } + + /** + * The percentage that may be used, in conjunction with the allowance base amount, to + * calculate the allowance amount. To state 20%, use value 20 + */ + @JsonDeserialize(using = MultiplierFactor.Deserializer::class) + @JsonSerialize(using = MultiplierFactor.Serializer::class) + class MultiplierFactor + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): MultiplierFactor = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MultiplierFactor && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "MultiplierFactor{number=$number}" + string != null -> "MultiplierFactor{string=$string}" + _json != null -> "MultiplierFactor{_unknown=$_json}" + else -> throw IllegalStateException("Invalid MultiplierFactor") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = MultiplierFactor(number = number) + + @JvmStatic fun ofString(string: String) = MultiplierFactor(string = string) + } + + /** + * An interface that defines how to map each variant of [MultiplierFactor] to a value of + * type [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [MultiplierFactor] to a value of type [T]. + * + * An instance of [MultiplierFactor] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. + * + * @throws EInvoiceInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw EInvoiceInvalidDataException("Unknown MultiplierFactor: $json") + } + } + + internal class Deserializer : + BaseDeserializer(MultiplierFactor::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): MultiplierFactor { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + MultiplierFactor(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + MultiplierFactor(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> MultiplierFactor(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(MultiplierFactor::class) { + + override fun serialize( + value: MultiplierFactor, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid MultiplierFactor") + } + } + } + } + + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + */ + class TaxCode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val AE = of("AE") + + @JvmField val E = of("E") + + @JvmField val S = of("S") + + @JvmField val Z = of("Z") + + @JvmField val G = of("G") + + @JvmField val O = of("O") + + @JvmField val K = of("K") + + @JvmField val L = of("L") + + @JvmField val M = of("M") + + @JvmField val B = of("B") + + @JvmStatic fun of(value: String) = TaxCode(JsonField.of(value)) + } + + /** An enum containing [TaxCode]'s known values. */ + enum class Known { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + } + + /** + * An enum containing [TaxCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TaxCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + /** + * An enum member indicating that [TaxCode] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AE -> Value.AE + E -> Value.E + S -> Value.S + Z -> Value.Z + G -> Value.G + O -> Value.O + K -> Value.K + L -> Value.L + M -> Value.M + B -> Value.B + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + AE -> Known.AE + E -> Known.E + S -> Known.S + Z -> Known.Z + G -> Known.G + O -> Known.O + K -> Known.K + L -> Known.L + M -> Known.M + B -> Known.B + else -> throw EInvoiceInvalidDataException("Unknown TaxCode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TaxCode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TaxCode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Allowance && + amount == other.amount && + baseAmount == other.baseAmount && + multiplierFactor == other.multiplierFactor && + reason == other.reason && + reasonCode == other.reasonCode && + taxCode == other.taxCode && + taxRate == other.taxRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Allowance{amount=$amount, baseAmount=$baseAmount, multiplierFactor=$multiplierFactor, reason=$reason, reasonCode=$reasonCode, taxCode=$taxCode, taxRate=$taxRate, additionalProperties=$additionalProperties}" + } + + /** The amount due of the invoice. Must be positive and rounded to maximum 2 decimals */ + @JsonDeserialize(using = AmountDue.Deserializer::class) + @JsonSerialize(using = AmountDue.Serializer::class) + class AmountDue + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): AmountDue = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AmountDue && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "AmountDue{number=$number}" + string != null -> "AmountDue{string=$string}" + _json != null -> "AmountDue{_unknown=$_json}" + else -> throw IllegalStateException("Invalid AmountDue") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = AmountDue(number = number) + + @JvmStatic fun ofString(string: String) = AmountDue(string = string) + } + + /** + * An interface that defines how to map each variant of [AmountDue] to a value of type [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [AmountDue] to a value of type [T]. + * + * An instance of [AmountDue] can contain an unknown variant if it was deserialized from + * data that doesn't match any known variant. For example, if the SDK is on an older + * version than the API, then the API may respond with new variants that the SDK is + * unaware of. + * + * @throws EInvoiceInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw EInvoiceInvalidDataException("Unknown AmountDue: $json") + } + } + + internal class Deserializer : BaseDeserializer(AmountDue::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): AmountDue { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + AmountDue(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + AmountDue(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> AmountDue(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(AmountDue::class) { + + override fun serialize( + value: AmountDue, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AmountDue") + } + } + } + } + + /** A charge is an additional fee for example for late payment, late delivery, etc. */ + class Charge + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val baseAmount: JsonField, + private val multiplierFactor: JsonField, + private val reason: JsonField, + private val reasonCode: JsonField, + private val taxCode: JsonField, + private val taxRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("base_amount") + @ExcludeMissing + baseAmount: JsonField = JsonMissing.of(), + @JsonProperty("multiplier_factor") + @ExcludeMissing + multiplierFactor: JsonField = JsonMissing.of(), + @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), + @JsonProperty("reason_code") + @ExcludeMissing + reasonCode: JsonField = JsonMissing.of(), + @JsonProperty("tax_code") + @ExcludeMissing + taxCode: JsonField = JsonMissing.of(), + @JsonProperty("tax_rate") @ExcludeMissing taxRate: JsonField = JsonMissing.of(), + ) : this( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + mutableMapOf(), + ) + + /** + * The charge amount, without VAT. Must be rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * The base amount that may be used, in conjunction with the charge percentage, to calculate + * the charge amount. Must be rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun baseAmount(): Optional = baseAmount.getOptional("base_amount") + + /** + * The percentage that may be used, in conjunction with the charge base amount, to calculate + * the charge amount. To state 20%, use value 20 + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun multiplierFactor(): Optional = + multiplierFactor.getOptional("multiplier_factor") + + /** + * The reason for the charge + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun reason(): Optional = reason.getOptional("reason") + + /** + * The code for the charge reason + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun reasonCode(): Optional = reasonCode.getOptional("reason_code") + + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun taxCode(): Optional = taxCode.getOptional("tax_code") + + /** + * The VAT rate, represented as percentage that applies to the charge + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun taxRate(): Optional = taxRate.getOptional("tax_rate") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [baseAmount]. + * + * Unlike [baseAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("base_amount") + @ExcludeMissing + fun _baseAmount(): JsonField = baseAmount + + /** + * Returns the raw JSON value of [multiplierFactor]. + * + * Unlike [multiplierFactor], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("multiplier_factor") + @ExcludeMissing + fun _multiplierFactor(): JsonField = multiplierFactor + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + /** + * Returns the raw JSON value of [reasonCode]. + * + * Unlike [reasonCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reason_code") + @ExcludeMissing + fun _reasonCode(): JsonField = reasonCode + + /** + * Returns the raw JSON value of [taxCode]. + * + * Unlike [taxCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax_code") @ExcludeMissing fun _taxCode(): JsonField = taxCode + + /** + * Returns the raw JSON value of [taxRate]. + * + * Unlike [taxRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Charge]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Charge]. */ + class Builder internal constructor() { + + private var amount: JsonField = JsonMissing.of() + private var baseAmount: JsonField = JsonMissing.of() + private var multiplierFactor: JsonField = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var reasonCode: JsonField = JsonMissing.of() + private var taxCode: JsonField = JsonMissing.of() + private var taxRate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(charge: Charge) = apply { + amount = charge.amount + baseAmount = charge.baseAmount + multiplierFactor = charge.multiplierFactor + reason = charge.reason + reasonCode = charge.reasonCode + taxCode = charge.taxCode + taxRate = charge.taxRate + additionalProperties = charge.additionalProperties.toMutableMap() + } + + /** The charge amount, without VAT. Must be rounded to maximum 2 decimals */ + fun amount(amount: Amount?) = amount(JsonField.ofNullable(amount)) + + /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ + fun amount(amount: Optional) = amount(amount.getOrNull()) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Amount] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** Alias for calling [amount] with `Amount.ofNumber(number)`. */ + fun amount(number: Double) = amount(Amount.ofNumber(number)) + + /** Alias for calling [amount] with `Amount.ofString(string)`. */ + fun amount(string: String) = amount(Amount.ofString(string)) + + /** + * The base amount that may be used, in conjunction with the charge percentage, to + * calculate the charge amount. Must be rounded to maximum 2 decimals + */ + fun baseAmount(baseAmount: BaseAmount?) = baseAmount(JsonField.ofNullable(baseAmount)) + + /** Alias for calling [Builder.baseAmount] with `baseAmount.orElse(null)`. */ + fun baseAmount(baseAmount: Optional) = baseAmount(baseAmount.getOrNull()) + + /** + * Sets [Builder.baseAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.baseAmount] with a well-typed [BaseAmount] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun baseAmount(baseAmount: JsonField) = apply { + this.baseAmount = baseAmount + } + + /** Alias for calling [baseAmount] with `BaseAmount.ofNumber(number)`. */ + fun baseAmount(number: Double) = baseAmount(BaseAmount.ofNumber(number)) + + /** Alias for calling [baseAmount] with `BaseAmount.ofString(string)`. */ + fun baseAmount(string: String) = baseAmount(BaseAmount.ofString(string)) + + /** + * The percentage that may be used, in conjunction with the charge base amount, to + * calculate the charge amount. To state 20%, use value 20 + */ + fun multiplierFactor(multiplierFactor: MultiplierFactor?) = + multiplierFactor(JsonField.ofNullable(multiplierFactor)) + + /** + * Alias for calling [Builder.multiplierFactor] with `multiplierFactor.orElse(null)`. + */ + fun multiplierFactor(multiplierFactor: Optional) = + multiplierFactor(multiplierFactor.getOrNull()) + + /** + * Sets [Builder.multiplierFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.multiplierFactor] with a well-typed + * [MultiplierFactor] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun multiplierFactor(multiplierFactor: JsonField) = apply { + this.multiplierFactor = multiplierFactor + } + + /** Alias for calling [multiplierFactor] with `MultiplierFactor.ofNumber(number)`. */ + fun multiplierFactor(number: Double) = + multiplierFactor(MultiplierFactor.ofNumber(number)) + + /** Alias for calling [multiplierFactor] with `MultiplierFactor.ofString(string)`. */ + fun multiplierFactor(string: String) = + multiplierFactor(MultiplierFactor.ofString(string)) + + /** The reason for the charge */ + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ + fun reason(reason: Optional) = reason(reason.getOrNull()) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + /** The code for the charge reason */ + fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) + + /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ + fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) + + /** + * Sets [Builder.reasonCode] to an arbitrary JSON value. + * + * You should usually call [Builder.reasonCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode } + + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + */ + fun taxCode(taxCode: TaxCode?) = taxCode(JsonField.ofNullable(taxCode)) + + /** Alias for calling [Builder.taxCode] with `taxCode.orElse(null)`. */ + fun taxCode(taxCode: Optional) = taxCode(taxCode.getOrNull()) + + /** + * Sets [Builder.taxCode] to an arbitrary JSON value. + * + * You should usually call [Builder.taxCode] with a well-typed [TaxCode] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } + + /** The VAT rate, represented as percentage that applies to the charge */ + fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) + + /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ + fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) + + /** + * Sets [Builder.taxRate] to an arbitrary JSON value. + * + * You should usually call [Builder.taxRate] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Charge]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Charge = + Charge( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Charge = apply { + if (validated) { + return@apply + } + + amount().ifPresent { it.validate() } + baseAmount().ifPresent { it.validate() } + multiplierFactor().ifPresent { it.validate() } + reason() + reasonCode() + taxCode().ifPresent { it.validate() } + taxRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (amount.asKnown().getOrNull()?.validity() ?: 0) + + (baseAmount.asKnown().getOrNull()?.validity() ?: 0) + + (multiplierFactor.asKnown().getOrNull()?.validity() ?: 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (if (reasonCode.asKnown().isPresent) 1 else 0) + + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + + (if (taxRate.asKnown().isPresent) 1 else 0) + + /** The charge amount, without VAT. Must be rounded to maximum 2 decimals */ + @JsonDeserialize(using = Amount.Deserializer::class) + @JsonSerialize(using = Amount.Serializer::class) + class Amount + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Amount = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Amount && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "Amount{number=$number}" + string != null -> "Amount{string=$string}" + _json != null -> "Amount{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Amount") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Amount(number = number) + + @JvmStatic fun ofString(string: String) = Amount(string = string) + } + + /** + * An interface that defines how to map each variant of [Amount] to a value of type [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Amount] to a value of type [T]. + * + * An instance of [Amount] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws EInvoiceInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw EInvoiceInvalidDataException("Unknown Amount: $json") + } + } + + internal class Deserializer : BaseDeserializer(Amount::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Amount { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Amount(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Amount(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> Amount(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Amount::class) { + + override fun serialize( + value: Amount, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Amount") + } + } + } + } + + /** + * The base amount that may be used, in conjunction with the charge percentage, to calculate + * the charge amount. Must be rounded to maximum 2 decimals + */ + @JsonDeserialize(using = BaseAmount.Deserializer::class) + @JsonSerialize(using = BaseAmount.Serializer::class) + class BaseAmount + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): BaseAmount = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BaseAmount && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "BaseAmount{number=$number}" + string != null -> "BaseAmount{string=$string}" + _json != null -> "BaseAmount{_unknown=$_json}" + else -> throw IllegalStateException("Invalid BaseAmount") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = BaseAmount(number = number) + + @JvmStatic fun ofString(string: String) = BaseAmount(string = string) + } + + /** + * An interface that defines how to map each variant of [BaseAmount] to a value of type + * [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [BaseAmount] to a value of type [T]. + * + * An instance of [BaseAmount] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws EInvoiceInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw EInvoiceInvalidDataException("Unknown BaseAmount: $json") + } + } + + internal class Deserializer : BaseDeserializer(BaseAmount::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): BaseAmount { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + BaseAmount(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + BaseAmount(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> BaseAmount(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(BaseAmount::class) { + + override fun serialize( + value: BaseAmount, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid BaseAmount") + } + } + } + } + + /** + * The percentage that may be used, in conjunction with the charge base amount, to calculate + * the charge amount. To state 20%, use value 20 + */ + @JsonDeserialize(using = MultiplierFactor.Deserializer::class) + @JsonSerialize(using = MultiplierFactor.Serializer::class) + class MultiplierFactor + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): MultiplierFactor = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MultiplierFactor && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "MultiplierFactor{number=$number}" + string != null -> "MultiplierFactor{string=$string}" + _json != null -> "MultiplierFactor{_unknown=$_json}" + else -> throw IllegalStateException("Invalid MultiplierFactor") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = MultiplierFactor(number = number) + + @JvmStatic fun ofString(string: String) = MultiplierFactor(string = string) + } + + /** + * An interface that defines how to map each variant of [MultiplierFactor] to a value of + * type [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [MultiplierFactor] to a value of type [T]. + * + * An instance of [MultiplierFactor] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. + * + * @throws EInvoiceInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw EInvoiceInvalidDataException("Unknown MultiplierFactor: $json") + } + } + + internal class Deserializer : + BaseDeserializer(MultiplierFactor::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): MultiplierFactor { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + MultiplierFactor(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + MultiplierFactor(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> MultiplierFactor(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(MultiplierFactor::class) { + + override fun serialize( + value: MultiplierFactor, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid MultiplierFactor") + } + } + } + } + + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + */ + class TaxCode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val AE = of("AE") + + @JvmField val E = of("E") + + @JvmField val S = of("S") + + @JvmField val Z = of("Z") + + @JvmField val G = of("G") + + @JvmField val O = of("O") + + @JvmField val K = of("K") + + @JvmField val L = of("L") + + @JvmField val M = of("M") + + @JvmField val B = of("B") + + @JvmStatic fun of(value: String) = TaxCode(JsonField.of(value)) + } + + /** An enum containing [TaxCode]'s known values. */ + enum class Known { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + } + + /** + * An enum containing [TaxCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TaxCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + /** + * An enum member indicating that [TaxCode] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AE -> Value.AE + E -> Value.E + S -> Value.S + Z -> Value.Z + G -> Value.G + O -> Value.O + K -> Value.K + L -> Value.L + M -> Value.M + B -> Value.B + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + AE -> Known.AE + E -> Known.E + S -> Known.S + Z -> Known.Z + G -> Known.G + O -> Known.O + K -> Known.K + L -> Known.L + M -> Known.M + B -> Known.B + else -> throw EInvoiceInvalidDataException("Unknown TaxCode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TaxCode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TaxCode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Charge && + amount == other.amount && + baseAmount == other.baseAmount && + multiplierFactor == other.multiplierFactor && + reason == other.reason && + reasonCode == other.reasonCode && + taxCode == other.taxCode && + taxRate == other.taxRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Charge{amount=$amount, baseAmount=$baseAmount, multiplierFactor=$multiplierFactor, reason=$reason, reasonCode=$reasonCode, taxCode=$taxCode, taxRate=$taxRate, additionalProperties=$additionalProperties}" + } + + /** + * The total amount of the invoice (so invoice_total = subtotal + total_tax + total_discount). + * Must be positive and rounded to maximum 2 decimals + */ + @JsonDeserialize(using = InvoiceTotal.Deserializer::class) + @JsonSerialize(using = InvoiceTotal.Serializer::class) + class InvoiceTotal + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): InvoiceTotal = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InvoiceTotal && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "InvoiceTotal{number=$number}" + string != null -> "InvoiceTotal{string=$string}" + _json != null -> "InvoiceTotal{_unknown=$_json}" + else -> throw IllegalStateException("Invalid InvoiceTotal") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = InvoiceTotal(number = number) + + @JvmStatic fun ofString(string: String) = InvoiceTotal(string = string) + } + + /** + * An interface that defines how to map each variant of [InvoiceTotal] to a value of type + * [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [InvoiceTotal] to a value of type [T]. + * + * An instance of [InvoiceTotal] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws EInvoiceInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw EInvoiceInvalidDataException("Unknown InvoiceTotal: $json") + } + } + + internal class Deserializer : BaseDeserializer(InvoiceTotal::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): InvoiceTotal { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + InvoiceTotal(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + InvoiceTotal(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> InvoiceTotal(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(InvoiceTotal::class) { + + override fun serialize( + value: InvoiceTotal, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid InvoiceTotal") + } + } + } + } + + class Item + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allowances: JsonField>, + private val amount: JsonField, + private val charges: JsonField>, + private val date: JsonField, + private val description: JsonField, + private val productCode: JsonField, + private val quantity: JsonField, + private val tax: JsonField, + private val taxRate: JsonField, + private val unit: JsonField, + private val unitPrice: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allowances") + @ExcludeMissing + allowances: JsonField> = JsonMissing.of(), + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("charges") + @ExcludeMissing + charges: JsonField> = JsonMissing.of(), + @JsonProperty("date") @ExcludeMissing date: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("product_code") + @ExcludeMissing + productCode: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + @JsonProperty("tax") @ExcludeMissing tax: JsonField = JsonMissing.of(), + @JsonProperty("tax_rate") @ExcludeMissing taxRate: JsonField = JsonMissing.of(), + @JsonProperty("unit") + @ExcludeMissing + unit: JsonField = JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + ) : this( + allowances, + amount, + charges, + date, + description, + productCode, + quantity, + tax, + taxRate, + unit, + unitPrice, + mutableMapOf(), + ) + + /** + * The allowances of the line item. + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun allowances(): Optional> = allowances.getOptional("allowances") + + /** + * The total amount of the line item, exclusive of VAT, after subtracting line level + * allowances and adding line level charges. Must be rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * The charges of the line item. + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun charges(): Optional> = charges.getOptional("charges") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun date(): Optional = date.getOptional("date") + + /** + * The description of the line item. + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * The product code of the line item. + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun productCode(): Optional = productCode.getOptional("product_code") + + /** + * The quantity of items (goods or services) that is the subject of the line item. Must be + * rounded to maximum 4 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun quantity(): Optional = quantity.getOptional("quantity") + + /** + * The total VAT amount for the line item. Must be rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tax(): Optional = tax.getOptional("tax") + + /** + * The VAT rate of the line item expressed as percentage with 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun taxRate(): Optional = taxRate.getOptional("tax_rate") + + /** + * Unit of Measure Codes from UNECERec20 used in Peppol BIS Billing 3.0. + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun unit(): Optional = unit.getOptional("unit") + + /** + * The unit price of the line item. Must be rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun unitPrice(): Optional = unitPrice.getOptional("unit_price") + + /** + * Returns the raw JSON value of [allowances]. + * + * Unlike [allowances], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("allowances") + @ExcludeMissing + fun _allowances(): JsonField> = allowances + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [charges]. + * + * Unlike [charges], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("charges") @ExcludeMissing fun _charges(): JsonField> = charges + + /** + * Returns the raw JSON value of [date]. + * + * Unlike [date], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("date") @ExcludeMissing fun _date(): JsonField = date + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [productCode]. + * + * Unlike [productCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("product_code") + @ExcludeMissing + fun _productCode(): JsonField = productCode + + /** + * Returns the raw JSON value of [quantity]. + * + * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity + + /** + * Returns the raw JSON value of [tax]. + * + * Unlike [tax], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax") @ExcludeMissing fun _tax(): JsonField = tax + + /** + * Returns the raw JSON value of [taxRate]. + * + * Unlike [taxRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate + + /** + * Returns the raw JSON value of [unit]. + * + * Unlike [unit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit + + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("unit_price") + @ExcludeMissing + fun _unitPrice(): JsonField = unitPrice + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Item]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Item]. */ + class Builder internal constructor() { + + private var allowances: JsonField>? = null + private var amount: JsonField = JsonMissing.of() + private var charges: JsonField>? = null + private var date: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var productCode: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var tax: JsonField = JsonMissing.of() + private var taxRate: JsonField = JsonMissing.of() + private var unit: JsonField = JsonMissing.of() + private var unitPrice: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(item: Item) = apply { + allowances = item.allowances.map { it.toMutableList() } + amount = item.amount + charges = item.charges.map { it.toMutableList() } + date = item.date + description = item.description + productCode = item.productCode + quantity = item.quantity + tax = item.tax + taxRate = item.taxRate + unit = item.unit + unitPrice = item.unitPrice + additionalProperties = item.additionalProperties.toMutableMap() + } + + /** The allowances of the line item. */ + fun allowances(allowances: List?) = + allowances(JsonField.ofNullable(allowances)) + + /** Alias for calling [Builder.allowances] with `allowances.orElse(null)`. */ + fun allowances(allowances: Optional>) = + allowances(allowances.getOrNull()) + + /** + * Sets [Builder.allowances] to an arbitrary JSON value. + * + * You should usually call [Builder.allowances] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun allowances(allowances: JsonField>) = apply { + this.allowances = allowances.map { it.toMutableList() } + } + + /** + * Adds a single [Allowance] to [allowances]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowance(allowance: Allowance) = apply { + allowances = + (allowances ?: JsonField.of(mutableListOf())).also { + checkKnown("allowances", it).add(allowance) + } + } + + /** + * The total amount of the line item, exclusive of VAT, after subtracting line level + * allowances and adding line level charges. Must be rounded to maximum 2 decimals + */ + fun amount(amount: Amount?) = amount(JsonField.ofNullable(amount)) + + /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ + fun amount(amount: Optional) = amount(amount.getOrNull()) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Amount] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** Alias for calling [amount] with `Amount.ofNumber(number)`. */ + fun amount(number: Double) = amount(Amount.ofNumber(number)) + + /** Alias for calling [amount] with `Amount.ofString(string)`. */ + fun amount(string: String) = amount(Amount.ofString(string)) + + /** The charges of the line item. */ + fun charges(charges: List?) = charges(JsonField.ofNullable(charges)) + + /** Alias for calling [Builder.charges] with `charges.orElse(null)`. */ + fun charges(charges: Optional>) = charges(charges.getOrNull()) + + /** + * Sets [Builder.charges] to an arbitrary JSON value. + * + * You should usually call [Builder.charges] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun charges(charges: JsonField>) = apply { + this.charges = charges.map { it.toMutableList() } + } + + /** + * Adds a single [Charge] to [charges]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCharge(charge: Charge) = apply { + charges = + (charges ?: JsonField.of(mutableListOf())).also { + checkKnown("charges", it).add(charge) + } + } + + fun date(date: Void?) = date(JsonField.ofNullable(date)) + + /** Alias for calling [Builder.date] with `date.orElse(null)`. */ + fun date(date: Optional) = date(date.getOrNull()) + + /** + * Sets [Builder.date] to an arbitrary JSON value. + * + * You should usually call [Builder.date] with a well-typed [Void] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun date(date: JsonField) = apply { this.date = date } + + /** The description of the line item. */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** The product code of the line item. */ + fun productCode(productCode: String?) = productCode(JsonField.ofNullable(productCode)) + + /** Alias for calling [Builder.productCode] with `productCode.orElse(null)`. */ + fun productCode(productCode: Optional) = productCode(productCode.getOrNull()) + + /** + * Sets [Builder.productCode] to an arbitrary JSON value. + * + * You should usually call [Builder.productCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun productCode(productCode: JsonField) = apply { + this.productCode = productCode + } + + /** + * The quantity of items (goods or services) that is the subject of the line item. Must + * be rounded to maximum 4 decimals + */ + fun quantity(quantity: Quantity?) = quantity(JsonField.ofNullable(quantity)) + + /** Alias for calling [Builder.quantity] with `quantity.orElse(null)`. */ + fun quantity(quantity: Optional) = quantity(quantity.getOrNull()) + + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Quantity] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + /** Alias for calling [quantity] with `Quantity.ofNumber(number)`. */ + fun quantity(number: Double) = quantity(Quantity.ofNumber(number)) + + /** Alias for calling [quantity] with `Quantity.ofString(string)`. */ + fun quantity(string: String) = quantity(Quantity.ofString(string)) + + /** The total VAT amount for the line item. Must be rounded to maximum 2 decimals */ + fun tax(tax: Tax?) = tax(JsonField.ofNullable(tax)) + + /** Alias for calling [Builder.tax] with `tax.orElse(null)`. */ + fun tax(tax: Optional) = tax(tax.getOrNull()) + + /** + * Sets [Builder.tax] to an arbitrary JSON value. + * + * You should usually call [Builder.tax] with a well-typed [Tax] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tax(tax: JsonField) = apply { this.tax = tax } + + /** Alias for calling [tax] with `Tax.ofNumber(number)`. */ + fun tax(number: Double) = tax(Tax.ofNumber(number)) + + /** Alias for calling [tax] with `Tax.ofString(string)`. */ + fun tax(string: String) = tax(Tax.ofString(string)) + + /** The VAT rate of the line item expressed as percentage with 2 decimals */ + fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) + + /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ + fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) + + /** + * Sets [Builder.taxRate] to an arbitrary JSON value. + * + * You should usually call [Builder.taxRate] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } + + /** Unit of Measure Codes from UNECERec20 used in Peppol BIS Billing 3.0. */ + fun unit(unit: UnitOfMeasureCode?) = unit(JsonField.ofNullable(unit)) + + /** Alias for calling [Builder.unit] with `unit.orElse(null)`. */ + fun unit(unit: Optional) = unit(unit.getOrNull()) + + /** + * Sets [Builder.unit] to an arbitrary JSON value. + * + * You should usually call [Builder.unit] with a well-typed [UnitOfMeasureCode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun unit(unit: JsonField) = apply { this.unit = unit } + + /** The unit price of the line item. Must be rounded to maximum 2 decimals */ + fun unitPrice(unitPrice: UnitPrice?) = unitPrice(JsonField.ofNullable(unitPrice)) + + /** Alias for calling [Builder.unitPrice] with `unitPrice.orElse(null)`. */ + fun unitPrice(unitPrice: Optional) = unitPrice(unitPrice.getOrNull()) + + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed [UnitPrice] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } + + /** Alias for calling [unitPrice] with `UnitPrice.ofNumber(number)`. */ + fun unitPrice(number: Double) = unitPrice(UnitPrice.ofNumber(number)) + + /** Alias for calling [unitPrice] with `UnitPrice.ofString(string)`. */ + fun unitPrice(string: String) = unitPrice(UnitPrice.ofString(string)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Item]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Item = + Item( + (allowances ?: JsonMissing.of()).map { it.toImmutable() }, + amount, + (charges ?: JsonMissing.of()).map { it.toImmutable() }, + date, + description, + productCode, + quantity, + tax, + taxRate, + unit, + unitPrice, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Item = apply { + if (validated) { + return@apply + } + + allowances().ifPresent { it.forEach { it.validate() } } + amount().ifPresent { it.validate() } + charges().ifPresent { it.forEach { it.validate() } } + date() + description() + productCode() + quantity().ifPresent { it.validate() } + tax().ifPresent { it.validate() } + taxRate() + unit().ifPresent { it.validate() } + unitPrice().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (allowances.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (amount.asKnown().getOrNull()?.validity() ?: 0) + + (charges.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (date.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (productCode.asKnown().isPresent) 1 else 0) + + (quantity.asKnown().getOrNull()?.validity() ?: 0) + + (tax.asKnown().getOrNull()?.validity() ?: 0) + + (if (taxRate.asKnown().isPresent) 1 else 0) + + (unit.asKnown().getOrNull()?.validity() ?: 0) + + (unitPrice.asKnown().getOrNull()?.validity() ?: 0) + + /** An allowance is a discount for example for early payment, volume discount, etc. */ + class Allowance + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val baseAmount: JsonField, + private val multiplierFactor: JsonField, + private val reason: JsonField, + private val reasonCode: JsonField, + private val taxCode: JsonField, + private val taxRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("base_amount") + @ExcludeMissing + baseAmount: JsonField = JsonMissing.of(), + @JsonProperty("multiplier_factor") + @ExcludeMissing + multiplierFactor: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + @JsonProperty("reason_code") + @ExcludeMissing + reasonCode: JsonField = JsonMissing.of(), + @JsonProperty("tax_code") + @ExcludeMissing + taxCode: JsonField = JsonMissing.of(), + @JsonProperty("tax_rate") + @ExcludeMissing + taxRate: JsonField = JsonMissing.of(), + ) : this( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + mutableMapOf(), + ) + + /** + * The allowance amount, without VAT. Must be rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * The base amount that may be used, in conjunction with the allowance percentage, to + * calculate the allowance amount. Must be rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun baseAmount(): Optional = baseAmount.getOptional("base_amount") + + /** + * The percentage that may be used, in conjunction with the allowance base amount, to + * calculate the allowance amount. To state 20%, use value 20 + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun multiplierFactor(): Optional = + multiplierFactor.getOptional("multiplier_factor") + + /** + * The reason for the allowance + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun reason(): Optional = reason.getOptional("reason") + + /** + * The code for the allowance reason + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun reasonCode(): Optional = reasonCode.getOptional("reason_code") + + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun taxCode(): Optional = taxCode.getOptional("tax_code") + + /** + * The VAT rate, represented as percentage that applies to the allowance + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun taxRate(): Optional = taxRate.getOptional("tax_rate") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [baseAmount]. + * + * Unlike [baseAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("base_amount") + @ExcludeMissing + fun _baseAmount(): JsonField = baseAmount + + /** + * Returns the raw JSON value of [multiplierFactor]. + * + * Unlike [multiplierFactor], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("multiplier_factor") + @ExcludeMissing + fun _multiplierFactor(): JsonField = multiplierFactor + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + /** + * Returns the raw JSON value of [reasonCode]. + * + * Unlike [reasonCode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reason_code") + @ExcludeMissing + fun _reasonCode(): JsonField = reasonCode + + /** + * Returns the raw JSON value of [taxCode]. + * + * Unlike [taxCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax_code") @ExcludeMissing fun _taxCode(): JsonField = taxCode + + /** + * Returns the raw JSON value of [taxRate]. + * + * Unlike [taxRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Allowance]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Allowance]. */ + class Builder internal constructor() { + + private var amount: JsonField = JsonMissing.of() + private var baseAmount: JsonField = JsonMissing.of() + private var multiplierFactor: JsonField = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var reasonCode: JsonField = JsonMissing.of() + private var taxCode: JsonField = JsonMissing.of() + private var taxRate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(allowance: Allowance) = apply { + amount = allowance.amount + baseAmount = allowance.baseAmount + multiplierFactor = allowance.multiplierFactor + reason = allowance.reason + reasonCode = allowance.reasonCode + taxCode = allowance.taxCode + taxRate = allowance.taxRate + additionalProperties = allowance.additionalProperties.toMutableMap() + } + + /** The allowance amount, without VAT. Must be rounded to maximum 2 decimals */ + fun amount(amount: Amount?) = amount(JsonField.ofNullable(amount)) + + /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ + fun amount(amount: Optional) = amount(amount.getOrNull()) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Amount] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** Alias for calling [amount] with `Amount.ofNumber(number)`. */ + fun amount(number: Double) = amount(Amount.ofNumber(number)) + + /** Alias for calling [amount] with `Amount.ofString(string)`. */ + fun amount(string: String) = amount(Amount.ofString(string)) + + /** + * The base amount that may be used, in conjunction with the allowance percentage, + * to calculate the allowance amount. Must be rounded to maximum 2 decimals + */ + fun baseAmount(baseAmount: BaseAmount?) = + baseAmount(JsonField.ofNullable(baseAmount)) + + /** Alias for calling [Builder.baseAmount] with `baseAmount.orElse(null)`. */ + fun baseAmount(baseAmount: Optional) = + baseAmount(baseAmount.getOrNull()) + + /** + * Sets [Builder.baseAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.baseAmount] with a well-typed [BaseAmount] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun baseAmount(baseAmount: JsonField) = apply { + this.baseAmount = baseAmount + } + + /** Alias for calling [baseAmount] with `BaseAmount.ofNumber(number)`. */ + fun baseAmount(number: Double) = baseAmount(BaseAmount.ofNumber(number)) + + /** Alias for calling [baseAmount] with `BaseAmount.ofString(string)`. */ + fun baseAmount(string: String) = baseAmount(BaseAmount.ofString(string)) + + /** + * The percentage that may be used, in conjunction with the allowance base amount, + * to calculate the allowance amount. To state 20%, use value 20 + */ + fun multiplierFactor(multiplierFactor: MultiplierFactor?) = + multiplierFactor(JsonField.ofNullable(multiplierFactor)) + + /** + * Alias for calling [Builder.multiplierFactor] with + * `multiplierFactor.orElse(null)`. + */ + fun multiplierFactor(multiplierFactor: Optional) = + multiplierFactor(multiplierFactor.getOrNull()) + + /** + * Sets [Builder.multiplierFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.multiplierFactor] with a well-typed + * [MultiplierFactor] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun multiplierFactor(multiplierFactor: JsonField) = apply { + this.multiplierFactor = multiplierFactor + } + + /** + * Alias for calling [multiplierFactor] with `MultiplierFactor.ofNumber(number)`. + */ + fun multiplierFactor(number: Double) = + multiplierFactor(MultiplierFactor.ofNumber(number)) + + /** + * Alias for calling [multiplierFactor] with `MultiplierFactor.ofString(string)`. + */ + fun multiplierFactor(string: String) = + multiplierFactor(MultiplierFactor.ofString(string)) + + /** The reason for the allowance */ + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ + fun reason(reason: Optional) = reason(reason.getOrNull()) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + /** The code for the allowance reason */ + fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) + + /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ + fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) + + /** + * Sets [Builder.reasonCode] to an arbitrary JSON value. + * + * You should usually call [Builder.reasonCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun reasonCode(reasonCode: JsonField) = apply { + this.reasonCode = reasonCode + } + + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + */ + fun taxCode(taxCode: TaxCode?) = taxCode(JsonField.ofNullable(taxCode)) + + /** Alias for calling [Builder.taxCode] with `taxCode.orElse(null)`. */ + fun taxCode(taxCode: Optional) = taxCode(taxCode.getOrNull()) + + /** + * Sets [Builder.taxCode] to an arbitrary JSON value. + * + * You should usually call [Builder.taxCode] with a well-typed [TaxCode] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } + + /** The VAT rate, represented as percentage that applies to the allowance */ + fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) + + /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ + fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) + + /** + * Sets [Builder.taxRate] to an arbitrary JSON value. + * + * You should usually call [Builder.taxRate] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Allowance]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Allowance = + Allowance( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Allowance = apply { + if (validated) { + return@apply + } + + amount().ifPresent { it.validate() } + baseAmount().ifPresent { it.validate() } + multiplierFactor().ifPresent { it.validate() } + reason() + reasonCode() + taxCode().ifPresent { it.validate() } + taxRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (amount.asKnown().getOrNull()?.validity() ?: 0) + + (baseAmount.asKnown().getOrNull()?.validity() ?: 0) + + (multiplierFactor.asKnown().getOrNull()?.validity() ?: 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (if (reasonCode.asKnown().isPresent) 1 else 0) + + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + + (if (taxRate.asKnown().isPresent) 1 else 0) + + /** The allowance amount, without VAT. Must be rounded to maximum 2 decimals */ + @JsonDeserialize(using = Amount.Deserializer::class) + @JsonSerialize(using = Amount.Serializer::class) + class Amount + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Amount = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Amount && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "Amount{number=$number}" + string != null -> "Amount{string=$string}" + _json != null -> "Amount{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Amount") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Amount(number = number) + + @JvmStatic fun ofString(string: String) = Amount(string = string) + } + + /** + * An interface that defines how to map each variant of [Amount] to a value of type + * [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Amount] to a value of type [T]. + * + * An instance of [Amount] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on + * an older version than the API, then the API may respond with new variants + * that the SDK is unaware of. + * + * @throws EInvoiceInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw EInvoiceInvalidDataException("Unknown Amount: $json") + } + } + + internal class Deserializer : BaseDeserializer(Amount::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Amount { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Amount(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Amount(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // object). + 0 -> Amount(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Amount::class) { + + override fun serialize( + value: Amount, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Amount") + } + } + } + } + + /** + * The base amount that may be used, in conjunction with the allowance percentage, to + * calculate the allowance amount. Must be rounded to maximum 2 decimals + */ + @JsonDeserialize(using = BaseAmount.Deserializer::class) + @JsonSerialize(using = BaseAmount.Serializer::class) + class BaseAmount + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): BaseAmount = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BaseAmount && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "BaseAmount{number=$number}" + string != null -> "BaseAmount{string=$string}" + _json != null -> "BaseAmount{_unknown=$_json}" + else -> throw IllegalStateException("Invalid BaseAmount") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = BaseAmount(number = number) + + @JvmStatic fun ofString(string: String) = BaseAmount(string = string) + } + + /** + * An interface that defines how to map each variant of [BaseAmount] to a value of + * type [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [BaseAmount] to a value of type [T]. + * + * An instance of [BaseAmount] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws EInvoiceInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw EInvoiceInvalidDataException("Unknown BaseAmount: $json") + } + } + + internal class Deserializer : BaseDeserializer(BaseAmount::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): BaseAmount { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + BaseAmount(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + BaseAmount(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // object). + 0 -> BaseAmount(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(BaseAmount::class) { + + override fun serialize( + value: BaseAmount, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid BaseAmount") + } + } + } + } + + /** + * The percentage that may be used, in conjunction with the allowance base amount, to + * calculate the allowance amount. To state 20%, use value 20 + */ + @JsonDeserialize(using = MultiplierFactor.Deserializer::class) + @JsonSerialize(using = MultiplierFactor.Serializer::class) + class MultiplierFactor + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): MultiplierFactor = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MultiplierFactor && + number == other.number && + string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "MultiplierFactor{number=$number}" + string != null -> "MultiplierFactor{string=$string}" + _json != null -> "MultiplierFactor{_unknown=$_json}" + else -> throw IllegalStateException("Invalid MultiplierFactor") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = MultiplierFactor(number = number) + + @JvmStatic fun ofString(string: String) = MultiplierFactor(string = string) + } + + /** + * An interface that defines how to map each variant of [MultiplierFactor] to a + * value of type [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [MultiplierFactor] to a value of type [T]. + * + * An instance of [MultiplierFactor] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws EInvoiceInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw EInvoiceInvalidDataException("Unknown MultiplierFactor: $json") + } + } + + internal class Deserializer : + BaseDeserializer(MultiplierFactor::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): MultiplierFactor { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + MultiplierFactor(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + MultiplierFactor(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // object). + 0 -> MultiplierFactor(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer(MultiplierFactor::class) { + + override fun serialize( + value: MultiplierFactor, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid MultiplierFactor") + } + } + } + } + + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + */ + class TaxCode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val AE = of("AE") + + @JvmField val E = of("E") + + @JvmField val S = of("S") + + @JvmField val Z = of("Z") + + @JvmField val G = of("G") + + @JvmField val O = of("O") + + @JvmField val K = of("K") + + @JvmField val L = of("L") + + @JvmField val M = of("M") + + @JvmField val B = of("B") + + @JvmStatic fun of(value: String) = TaxCode(JsonField.of(value)) + } + + /** An enum containing [TaxCode]'s known values. */ + enum class Known { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + } + + /** + * An enum containing [TaxCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TaxCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + /** + * An enum member indicating that [TaxCode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AE -> Value.AE + E -> Value.E + S -> Value.S + Z -> Value.Z + G -> Value.G + O -> Value.O + K -> Value.K + L -> Value.L + M -> Value.M + B -> Value.B + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + AE -> Known.AE + E -> Known.E + S -> Known.S + Z -> Known.Z + G -> Known.G + O -> Known.O + K -> Known.K + L -> Known.L + M -> Known.M + B -> Known.B + else -> throw EInvoiceInvalidDataException("Unknown TaxCode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TaxCode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TaxCode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Allowance && + amount == other.amount && + baseAmount == other.baseAmount && + multiplierFactor == other.multiplierFactor && + reason == other.reason && + reasonCode == other.reasonCode && + taxCode == other.taxCode && + taxRate == other.taxRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Allowance{amount=$amount, baseAmount=$baseAmount, multiplierFactor=$multiplierFactor, reason=$reason, reasonCode=$reasonCode, taxCode=$taxCode, taxRate=$taxRate, additionalProperties=$additionalProperties}" + } + + /** + * The total amount of the line item, exclusive of VAT, after subtracting line level + * allowances and adding line level charges. Must be rounded to maximum 2 decimals + */ + @JsonDeserialize(using = Amount.Deserializer::class) + @JsonSerialize(using = Amount.Serializer::class) + class Amount + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Amount = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Amount && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "Amount{number=$number}" + string != null -> "Amount{string=$string}" + _json != null -> "Amount{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Amount") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Amount(number = number) + + @JvmStatic fun ofString(string: String) = Amount(string = string) + } + + /** + * An interface that defines how to map each variant of [Amount] to a value of type [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Amount] to a value of type [T]. + * + * An instance of [Amount] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws EInvoiceInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw EInvoiceInvalidDataException("Unknown Amount: $json") + } + } + + internal class Deserializer : BaseDeserializer(Amount::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Amount { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Amount(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Amount(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> Amount(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Amount::class) { + + override fun serialize( + value: Amount, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Amount") + } + } + } + } + + /** A charge is an additional fee for example for late payment, late delivery, etc. */ + class Charge + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val baseAmount: JsonField, + private val multiplierFactor: JsonField, + private val reason: JsonField, + private val reasonCode: JsonField, + private val taxCode: JsonField, + private val taxRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("base_amount") + @ExcludeMissing + baseAmount: JsonField = JsonMissing.of(), + @JsonProperty("multiplier_factor") + @ExcludeMissing + multiplierFactor: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + @JsonProperty("reason_code") + @ExcludeMissing + reasonCode: JsonField = JsonMissing.of(), + @JsonProperty("tax_code") + @ExcludeMissing + taxCode: JsonField = JsonMissing.of(), + @JsonProperty("tax_rate") + @ExcludeMissing + taxRate: JsonField = JsonMissing.of(), + ) : this( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + mutableMapOf(), + ) + + /** + * The charge amount, without VAT. Must be rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * The base amount that may be used, in conjunction with the charge percentage, to + * calculate the charge amount. Must be rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun baseAmount(): Optional = baseAmount.getOptional("base_amount") + + /** + * The percentage that may be used, in conjunction with the charge base amount, to + * calculate the charge amount. To state 20%, use value 20 + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun multiplierFactor(): Optional = + multiplierFactor.getOptional("multiplier_factor") + + /** + * The reason for the charge + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun reason(): Optional = reason.getOptional("reason") + + /** + * The code for the charge reason + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun reasonCode(): Optional = reasonCode.getOptional("reason_code") + + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun taxCode(): Optional = taxCode.getOptional("tax_code") + + /** + * The VAT rate, represented as percentage that applies to the charge + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun taxRate(): Optional = taxRate.getOptional("tax_rate") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [baseAmount]. + * + * Unlike [baseAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("base_amount") + @ExcludeMissing + fun _baseAmount(): JsonField = baseAmount + + /** + * Returns the raw JSON value of [multiplierFactor]. + * + * Unlike [multiplierFactor], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("multiplier_factor") + @ExcludeMissing + fun _multiplierFactor(): JsonField = multiplierFactor + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + /** + * Returns the raw JSON value of [reasonCode]. + * + * Unlike [reasonCode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reason_code") + @ExcludeMissing + fun _reasonCode(): JsonField = reasonCode + + /** + * Returns the raw JSON value of [taxCode]. + * + * Unlike [taxCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax_code") @ExcludeMissing fun _taxCode(): JsonField = taxCode + + /** + * Returns the raw JSON value of [taxRate]. + * + * Unlike [taxRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Charge]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Charge]. */ + class Builder internal constructor() { + + private var amount: JsonField = JsonMissing.of() + private var baseAmount: JsonField = JsonMissing.of() + private var multiplierFactor: JsonField = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var reasonCode: JsonField = JsonMissing.of() + private var taxCode: JsonField = JsonMissing.of() + private var taxRate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(charge: Charge) = apply { + amount = charge.amount + baseAmount = charge.baseAmount + multiplierFactor = charge.multiplierFactor + reason = charge.reason + reasonCode = charge.reasonCode + taxCode = charge.taxCode + taxRate = charge.taxRate + additionalProperties = charge.additionalProperties.toMutableMap() + } + + /** The charge amount, without VAT. Must be rounded to maximum 2 decimals */ + fun amount(amount: Amount?) = amount(JsonField.ofNullable(amount)) + + /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ + fun amount(amount: Optional) = amount(amount.getOrNull()) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Amount] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** Alias for calling [amount] with `Amount.ofNumber(number)`. */ + fun amount(number: Double) = amount(Amount.ofNumber(number)) + + /** Alias for calling [amount] with `Amount.ofString(string)`. */ + fun amount(string: String) = amount(Amount.ofString(string)) + + /** + * The base amount that may be used, in conjunction with the charge percentage, to + * calculate the charge amount. Must be rounded to maximum 2 decimals + */ + fun baseAmount(baseAmount: BaseAmount?) = + baseAmount(JsonField.ofNullable(baseAmount)) + + /** Alias for calling [Builder.baseAmount] with `baseAmount.orElse(null)`. */ + fun baseAmount(baseAmount: Optional) = + baseAmount(baseAmount.getOrNull()) + + /** + * Sets [Builder.baseAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.baseAmount] with a well-typed [BaseAmount] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun baseAmount(baseAmount: JsonField) = apply { + this.baseAmount = baseAmount + } + + /** Alias for calling [baseAmount] with `BaseAmount.ofNumber(number)`. */ + fun baseAmount(number: Double) = baseAmount(BaseAmount.ofNumber(number)) + + /** Alias for calling [baseAmount] with `BaseAmount.ofString(string)`. */ + fun baseAmount(string: String) = baseAmount(BaseAmount.ofString(string)) + + /** + * The percentage that may be used, in conjunction with the charge base amount, to + * calculate the charge amount. To state 20%, use value 20 + */ + fun multiplierFactor(multiplierFactor: MultiplierFactor?) = + multiplierFactor(JsonField.ofNullable(multiplierFactor)) + + /** + * Alias for calling [Builder.multiplierFactor] with + * `multiplierFactor.orElse(null)`. + */ + fun multiplierFactor(multiplierFactor: Optional) = + multiplierFactor(multiplierFactor.getOrNull()) + + /** + * Sets [Builder.multiplierFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.multiplierFactor] with a well-typed + * [MultiplierFactor] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun multiplierFactor(multiplierFactor: JsonField) = apply { + this.multiplierFactor = multiplierFactor + } + + /** + * Alias for calling [multiplierFactor] with `MultiplierFactor.ofNumber(number)`. + */ + fun multiplierFactor(number: Double) = + multiplierFactor(MultiplierFactor.ofNumber(number)) + + /** + * Alias for calling [multiplierFactor] with `MultiplierFactor.ofString(string)`. + */ + fun multiplierFactor(string: String) = + multiplierFactor(MultiplierFactor.ofString(string)) + + /** The reason for the charge */ + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ + fun reason(reason: Optional) = reason(reason.getOrNull()) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + /** The code for the charge reason */ + fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) + + /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ + fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) + + /** + * Sets [Builder.reasonCode] to an arbitrary JSON value. + * + * You should usually call [Builder.reasonCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun reasonCode(reasonCode: JsonField) = apply { + this.reasonCode = reasonCode + } + + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + */ + fun taxCode(taxCode: TaxCode?) = taxCode(JsonField.ofNullable(taxCode)) + + /** Alias for calling [Builder.taxCode] with `taxCode.orElse(null)`. */ + fun taxCode(taxCode: Optional) = taxCode(taxCode.getOrNull()) + + /** + * Sets [Builder.taxCode] to an arbitrary JSON value. + * + * You should usually call [Builder.taxCode] with a well-typed [TaxCode] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } + + /** The VAT rate, represented as percentage that applies to the charge */ + fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) + + /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ + fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) + + /** + * Sets [Builder.taxRate] to an arbitrary JSON value. + * + * You should usually call [Builder.taxRate] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Charge]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Charge = + Charge( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Charge = apply { + if (validated) { + return@apply + } + + amount().ifPresent { it.validate() } + baseAmount().ifPresent { it.validate() } + multiplierFactor().ifPresent { it.validate() } + reason() + reasonCode() + taxCode().ifPresent { it.validate() } + taxRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } - /** - * Returns the raw JSON value of [quantity]. - * - * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (amount.asKnown().getOrNull()?.validity() ?: 0) + + (baseAmount.asKnown().getOrNull()?.validity() ?: 0) + + (multiplierFactor.asKnown().getOrNull()?.validity() ?: 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (if (reasonCode.asKnown().isPresent) 1 else 0) + + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + + (if (taxRate.asKnown().isPresent) 1 else 0) + + /** The charge amount, without VAT. Must be rounded to maximum 2 decimals */ + @JsonDeserialize(using = Amount.Deserializer::class) + @JsonSerialize(using = Amount.Serializer::class) + class Amount + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { - /** - * Returns the raw JSON value of [tax]. - * - * Unlike [tax], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tax") @ExcludeMissing fun _tax(): JsonField = tax + fun number(): Optional = Optional.ofNullable(number) - /** - * Returns the raw JSON value of [taxRate]. - * - * Unlike [taxRate], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate + fun string(): Optional = Optional.ofNullable(string) - /** - * Returns the raw JSON value of [unit]. - * - * Unlike [unit], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit + fun isNumber(): Boolean = number != null - /** - * Returns the raw JSON value of [unitPrice]. - * - * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("unit_price") - @ExcludeMissing - fun _unitPrice(): JsonField = unitPrice + fun isString(): Boolean = string != null - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun asNumber(): Double = number.getOrThrow("number") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun asString(): String = string.getOrThrow("string") - fun toBuilder() = Builder().from(this) + fun _json(): Optional = Optional.ofNullable(_json) - companion object { + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } - /** Returns a mutable builder for constructing an instance of [Item]. */ - @JvmStatic fun builder() = Builder() - } + private var validated: Boolean = false - /** A builder for [Item]. */ - class Builder internal constructor() { + fun validate(): Amount = apply { + if (validated) { + return@apply + } - private var amount: JsonField = JsonMissing.of() - private var date: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var productCode: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var tax: JsonField = JsonMissing.of() - private var taxRate: JsonField = JsonMissing.of() - private var unit: JsonField = JsonMissing.of() - private var unitPrice: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + accept( + object : Visitor { + override fun visitNumber(number: Double) {} - @JvmSynthetic - internal fun from(item: Item) = apply { - amount = item.amount - date = item.date - description = item.description - productCode = item.productCode - quantity = item.quantity - tax = item.tax - taxRate = item.taxRate - unit = item.unit - unitPrice = item.unitPrice - additionalProperties = item.additionalProperties.toMutableMap() - } + override fun visitString(string: String) {} + } + ) + validated = true + } - fun amount(amount: Amount?) = amount(JsonField.ofNullable(amount)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } - /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ - fun amount(amount: Optional) = amount(amount.getOrNull()) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 - /** - * Sets [Builder.amount] to an arbitrary JSON value. - * - * You should usually call [Builder.amount] with a well-typed [Amount] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } + override fun visitString(string: String) = 1 - /** Alias for calling [amount] with `Amount.ofNumber(number)`. */ - fun amount(number: Double) = amount(Amount.ofNumber(number)) + override fun unknown(json: JsonValue?) = 0 + } + ) - /** Alias for calling [amount] with `Amount.ofString(string)`. */ - fun amount(string: String) = amount(Amount.ofString(string)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun date(date: Void?) = date(JsonField.ofNullable(date)) + return other is Amount && number == other.number && string == other.string + } - /** Alias for calling [Builder.date] with `date.orElse(null)`. */ - fun date(date: Optional) = date(date.getOrNull()) + override fun hashCode(): Int = Objects.hash(number, string) - /** - * Sets [Builder.date] to an arbitrary JSON value. - * - * You should usually call [Builder.date] with a well-typed [Void] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun date(date: JsonField) = apply { this.date = date } + override fun toString(): String = + when { + number != null -> "Amount{number=$number}" + string != null -> "Amount{string=$string}" + _json != null -> "Amount{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Amount") + } - fun description(description: String?) = description(JsonField.ofNullable(description)) + companion object { - /** Alias for calling [Builder.description] with `description.orElse(null)`. */ - fun description(description: Optional) = description(description.getOrNull()) + @JvmStatic fun ofNumber(number: Double) = Amount(number = number) - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun description(description: JsonField) = apply { - this.description = description - } + @JvmStatic fun ofString(string: String) = Amount(string = string) + } - fun productCode(productCode: String?) = productCode(JsonField.ofNullable(productCode)) + /** + * An interface that defines how to map each variant of [Amount] to a value of type + * [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Amount] to a value of type [T]. + * + * An instance of [Amount] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on + * an older version than the API, then the API may respond with new variants + * that the SDK is unaware of. + * + * @throws EInvoiceInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw EInvoiceInvalidDataException("Unknown Amount: $json") + } + } - /** Alias for calling [Builder.productCode] with `productCode.orElse(null)`. */ - fun productCode(productCode: Optional) = productCode(productCode.getOrNull()) + internal class Deserializer : BaseDeserializer(Amount::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Amount { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Amount(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Amount(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // object). + 0 -> Amount(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Amount::class) { + + override fun serialize( + value: Amount, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Amount") + } + } + } + } /** - * Sets [Builder.productCode] to an arbitrary JSON value. - * - * You should usually call [Builder.productCode] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * The base amount that may be used, in conjunction with the charge percentage, to + * calculate the charge amount. Must be rounded to maximum 2 decimals */ - fun productCode(productCode: JsonField) = apply { - this.productCode = productCode - } + @JsonDeserialize(using = BaseAmount.Deserializer::class) + @JsonSerialize(using = BaseAmount.Serializer::class) + class BaseAmount + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { - fun quantity(quantity: Quantity?) = quantity(JsonField.ofNullable(quantity)) + fun number(): Optional = Optional.ofNullable(number) - /** Alias for calling [Builder.quantity] with `quantity.orElse(null)`. */ - fun quantity(quantity: Optional) = quantity(quantity.getOrNull()) + fun string(): Optional = Optional.ofNullable(string) - /** - * Sets [Builder.quantity] to an arbitrary JSON value. - * - * You should usually call [Builder.quantity] with a well-typed [Quantity] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + fun isNumber(): Boolean = number != null - /** Alias for calling [quantity] with `Quantity.ofNumber(number)`. */ - fun quantity(number: Double) = quantity(Quantity.ofNumber(number)) + fun isString(): Boolean = string != null - /** Alias for calling [quantity] with `Quantity.ofString(string)`. */ - fun quantity(string: String) = quantity(Quantity.ofString(string)) + fun asNumber(): Double = number.getOrThrow("number") - fun tax(tax: Tax?) = tax(JsonField.ofNullable(tax)) + fun asString(): String = string.getOrThrow("string") - /** Alias for calling [Builder.tax] with `tax.orElse(null)`. */ - fun tax(tax: Optional) = tax(tax.getOrNull()) + fun _json(): Optional = Optional.ofNullable(_json) - /** - * Sets [Builder.tax] to an arbitrary JSON value. - * - * You should usually call [Builder.tax] with a well-typed [Tax] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun tax(tax: JsonField) = apply { this.tax = tax } + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } - /** Alias for calling [tax] with `Tax.ofNumber(number)`. */ - fun tax(number: Double) = tax(Tax.ofNumber(number)) + private var validated: Boolean = false - /** Alias for calling [tax] with `Tax.ofString(string)`. */ - fun tax(string: String) = tax(Tax.ofString(string)) + fun validate(): BaseAmount = apply { + if (validated) { + return@apply + } - fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) + accept( + object : Visitor { + override fun visitNumber(number: Double) {} - /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ - fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) + override fun visitString(string: String) {} + } + ) + validated = true + } - /** - * Sets [Builder.taxRate] to an arbitrary JSON value. - * - * You should usually call [Builder.taxRate] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } - /** Unit of Measure Codes from UNECERec20 used in Peppol BIS Billing 3.0. */ - fun unit(unit: UnitOfMeasureCode?) = unit(JsonField.ofNullable(unit)) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 - /** Alias for calling [Builder.unit] with `unit.orElse(null)`. */ - fun unit(unit: Optional) = unit(unit.getOrNull()) + override fun visitString(string: String) = 1 - /** - * Sets [Builder.unit] to an arbitrary JSON value. - * - * You should usually call [Builder.unit] with a well-typed [UnitOfMeasureCode] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun unit(unit: JsonField) = apply { this.unit = unit } + override fun unknown(json: JsonValue?) = 0 + } + ) - fun unitPrice(unitPrice: UnitPrice?) = unitPrice(JsonField.ofNullable(unitPrice)) + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** Alias for calling [Builder.unitPrice] with `unitPrice.orElse(null)`. */ - fun unitPrice(unitPrice: Optional) = unitPrice(unitPrice.getOrNull()) + return other is BaseAmount && number == other.number && string == other.string + } - /** - * Sets [Builder.unitPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.unitPrice] with a well-typed [UnitPrice] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } + override fun hashCode(): Int = Objects.hash(number, string) - /** Alias for calling [unitPrice] with `UnitPrice.ofNumber(number)`. */ - fun unitPrice(number: Double) = unitPrice(UnitPrice.ofNumber(number)) + override fun toString(): String = + when { + number != null -> "BaseAmount{number=$number}" + string != null -> "BaseAmount{string=$string}" + _json != null -> "BaseAmount{_unknown=$_json}" + else -> throw IllegalStateException("Invalid BaseAmount") + } - /** Alias for calling [unitPrice] with `UnitPrice.ofString(string)`. */ - fun unitPrice(string: String) = unitPrice(UnitPrice.ofString(string)) + companion object { - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JvmStatic fun ofNumber(number: Double) = BaseAmount(number = number) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JvmStatic fun ofString(string: String) = BaseAmount(string = string) + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + /** + * An interface that defines how to map each variant of [BaseAmount] to a value of + * type [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [BaseAmount] to a value of type [T]. + * + * An instance of [BaseAmount] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws EInvoiceInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw EInvoiceInvalidDataException("Unknown BaseAmount: $json") + } + } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + internal class Deserializer : BaseDeserializer(BaseAmount::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): BaseAmount { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + BaseAmount(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + BaseAmount(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // object). + 0 -> BaseAmount(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + internal class Serializer : BaseSerializer(BaseAmount::class) { + + override fun serialize( + value: BaseAmount, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid BaseAmount") + } + } + } } /** - * Returns an immutable instance of [Item]. - * - * Further updates to this [Builder] will not mutate the returned instance. + * The percentage that may be used, in conjunction with the charge base amount, to + * calculate the charge amount. To state 20%, use value 20 */ - fun build(): Item = - Item( - amount, - date, - description, - productCode, - quantity, - tax, - taxRate, - unit, - unitPrice, - additionalProperties.toMutableMap(), - ) - } + @JsonDeserialize(using = MultiplierFactor.Deserializer::class) + @JsonSerialize(using = MultiplierFactor.Serializer::class) + class MultiplierFactor + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { - private var validated: Boolean = false + fun number(): Optional = Optional.ofNullable(number) - fun validate(): Item = apply { - if (validated) { - return@apply - } + fun string(): Optional = Optional.ofNullable(string) - amount().ifPresent { it.validate() } - date() - description() - productCode() - quantity().ifPresent { it.validate() } - tax().ifPresent { it.validate() } - taxRate() - unit().ifPresent { it.validate() } - unitPrice().ifPresent { it.validate() } - validated = true - } + fun isNumber(): Boolean = number != null - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false - } + fun isString(): Boolean = string != null - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (amount.asKnown().getOrNull()?.validity() ?: 0) + - (if (date.asKnown().isPresent) 1 else 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (if (productCode.asKnown().isPresent) 1 else 0) + - (quantity.asKnown().getOrNull()?.validity() ?: 0) + - (tax.asKnown().getOrNull()?.validity() ?: 0) + - (if (taxRate.asKnown().isPresent) 1 else 0) + - (unit.asKnown().getOrNull()?.validity() ?: 0) + - (unitPrice.asKnown().getOrNull()?.validity() ?: 0) + fun asNumber(): Double = number.getOrThrow("number") - @JsonDeserialize(using = Amount.Deserializer::class) - @JsonSerialize(using = Amount.Serializer::class) - class Amount - private constructor( - private val number: Double? = null, - private val string: String? = null, - private val _json: JsonValue? = null, - ) { + fun asString(): String = string.getOrThrow("string") - fun number(): Optional = Optional.ofNullable(number) + fun _json(): Optional = Optional.ofNullable(_json) - fun string(): Optional = Optional.ofNullable(string) + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } - fun isNumber(): Boolean = number != null + private var validated: Boolean = false - fun isString(): Boolean = string != null + fun validate(): MultiplierFactor = apply { + if (validated) { + return@apply + } - fun asNumber(): Double = number.getOrThrow("number") + accept( + object : Visitor { + override fun visitNumber(number: Double) {} - fun asString(): String = string.getOrThrow("string") + override fun visitString(string: String) {} + } + ) + validated = true + } - fun _json(): Optional = Optional.ofNullable(_json) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } - fun accept(visitor: Visitor): T = - when { - number != null -> visitor.visitNumber(number) - string != null -> visitor.visitString(string) - else -> visitor.unknown(_json) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MultiplierFactor && + number == other.number && + string == other.string } - private var validated: Boolean = false + override fun hashCode(): Int = Objects.hash(number, string) - fun validate(): Amount = apply { - if (validated) { - return@apply + override fun toString(): String = + when { + number != null -> "MultiplierFactor{number=$number}" + string != null -> "MultiplierFactor{string=$string}" + _json != null -> "MultiplierFactor{_unknown=$_json}" + else -> throw IllegalStateException("Invalid MultiplierFactor") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = MultiplierFactor(number = number) + + @JvmStatic fun ofString(string: String) = MultiplierFactor(string = string) } - accept( - object : Visitor { - override fun visitNumber(number: Double) {} + /** + * An interface that defines how to map each variant of [MultiplierFactor] to a + * value of type [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [MultiplierFactor] to a value of type [T]. + * + * An instance of [MultiplierFactor] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws EInvoiceInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw EInvoiceInvalidDataException("Unknown MultiplierFactor: $json") + } + } - override fun visitString(string: String) {} + internal class Deserializer : + BaseDeserializer(MultiplierFactor::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): MultiplierFactor { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + MultiplierFactor(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + MultiplierFactor(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // object). + 0 -> MultiplierFactor(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } } - ) - validated = true - } + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false + internal class Serializer : + BaseSerializer(MultiplierFactor::class) { + + override fun serialize( + value: MultiplierFactor, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid MultiplierFactor") + } + } } + } /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Duty or tax or fee category codes (Subset of UNCL5305) * - * Used for best match union deserialization. + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitNumber(number: Double) = 1 + class TaxCode @JsonCreator private constructor(private val value: JsonField) : + Enum { - override fun visitString(string: String) = 1 + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - override fun unknown(json: JsonValue?) = 0 - } - ) + companion object { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JvmField val AE = of("AE") - return other is Amount && number == other.number && string == other.string - } + @JvmField val E = of("E") - override fun hashCode(): Int = Objects.hash(number, string) + @JvmField val S = of("S") - override fun toString(): String = - when { - number != null -> "Amount{number=$number}" - string != null -> "Amount{string=$string}" - _json != null -> "Amount{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Amount") - } + @JvmField val Z = of("Z") - companion object { + @JvmField val G = of("G") - @JvmStatic fun ofNumber(number: Double) = Amount(number = number) + @JvmField val O = of("O") - @JvmStatic fun ofString(string: String) = Amount(string = string) - } + @JvmField val K = of("K") - /** - * An interface that defines how to map each variant of [Amount] to a value of type [T]. - */ - interface Visitor { + @JvmField val L = of("L") - fun visitNumber(number: Double): T + @JvmField val M = of("M") - fun visitString(string: String): T + @JvmField val B = of("B") + + @JvmStatic fun of(value: String) = TaxCode(JsonField.of(value)) + } + + /** An enum containing [TaxCode]'s known values. */ + enum class Known { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + } /** - * Maps an unknown variant of [Amount] to a value of type [T]. - * - * An instance of [Amount] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. + * An enum containing [TaxCode]'s known values, as well as an [_UNKNOWN] member. * - * @throws EInvoiceInvalidDataException in the default implementation. + * An instance of [TaxCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - fun unknown(json: JsonValue?): T { - throw EInvoiceInvalidDataException("Unknown Amount: $json") + enum class Value { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + /** + * An enum member indicating that [TaxCode] was instantiated with an unknown + * value. + */ + _UNKNOWN, } - } - internal class Deserializer : BaseDeserializer(Amount::class) { + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AE -> Value.AE + E -> Value.E + S -> Value.S + Z -> Value.Z + G -> Value.G + O -> Value.O + K -> Value.K + L -> Value.L + M -> Value.M + B -> Value.B + else -> Value._UNKNOWN + } - override fun ObjectCodec.deserialize(node: JsonNode): Amount { - val json = JsonValue.fromJsonNode(node) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + AE -> Known.AE + E -> Known.E + S -> Known.S + Z -> Known.Z + G -> Known.G + O -> Known.O + K -> Known.K + L -> Known.L + M -> Known.M + B -> Known.B + else -> throw EInvoiceInvalidDataException("Unknown TaxCode: $value") + } - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Amount(number = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Amount(string = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from object). - 0 -> Amount(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the - // first completely valid match, or simply the first match if none are - // completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TaxCode = apply { + if (validated) { + return@apply } + + known() + validated = true } - } - internal class Serializer : BaseSerializer(Amount::class) { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } - override fun serialize( - value: Amount, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.number != null -> generator.writeObject(value.number) - value.string != null -> generator.writeObject(value.string) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Amount") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is TaxCode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is Charge && + amount == other.amount && + baseAmount == other.baseAmount && + multiplierFactor == other.multiplierFactor && + reason == other.reason && + reasonCode == other.reasonCode && + taxCode == other.taxCode && + taxRate == other.taxRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Charge{amount=$amount, baseAmount=$baseAmount, multiplierFactor=$multiplierFactor, reason=$reason, reasonCode=$reasonCode, taxCode=$taxCode, taxRate=$taxRate, additionalProperties=$additionalProperties}" } + /** + * The quantity of items (goods or services) that is the subject of the line item. Must be + * rounded to maximum 4 decimals + */ @JsonDeserialize(using = Quantity.Deserializer::class) @JsonSerialize(using = Quantity.Serializer::class) class Quantity @@ -3160,6 +8146,7 @@ private constructor( } } + /** The total VAT amount for the line item. Must be rounded to maximum 2 decimals */ @JsonDeserialize(using = Tax.Deserializer::class) @JsonSerialize(using = Tax.Serializer::class) class Tax @@ -3329,6 +8316,7 @@ private constructor( } } + /** The unit price of the line item. Must be rounded to maximum 2 decimals */ @JsonDeserialize(using = UnitPrice.Deserializer::class) @JsonSerialize(using = UnitPrice.Serializer::class) class UnitPrice @@ -3505,7 +8493,9 @@ private constructor( } return other is Item && + allowances == other.allowances && amount == other.amount && + charges == other.charges && date == other.date && description == other.description && productCode == other.productCode && @@ -3519,7 +8509,9 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( + allowances, amount, + charges, date, description, productCode, @@ -3535,9 +8527,13 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Item{amount=$amount, date=$date, description=$description, productCode=$productCode, quantity=$quantity, tax=$tax, taxRate=$taxRate, unit=$unit, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" + "Item{allowances=$allowances, amount=$amount, charges=$charges, date=$date, description=$description, productCode=$productCode, quantity=$quantity, tax=$tax, taxRate=$taxRate, unit=$unit, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" } + /** + * The previous unpaid balance of the invoice, if any. Must be positive and rounded to maximum 2 + * decimals + */ @JsonDeserialize(using = PreviousUnpaidBalance.Deserializer::class) @JsonSerialize(using = PreviousUnpaidBalance.Serializer::class) class PreviousUnpaidBalance @@ -3712,6 +8708,11 @@ private constructor( } } + /** + * The taxable base of the invoice. Should be the sum of all line items - allowances (for + * example commercial discounts) + charges with impact on VAT. Must be positive and rounded to + * maximum 2 decimals + */ @JsonDeserialize(using = Subtotal.Deserializer::class) @JsonSerialize(using = Subtotal.Serializer::class) class Subtotal @@ -4409,6 +9410,10 @@ private constructor( "TaxDetail{amount=$amount, rate=$rate, additionalProperties=$additionalProperties}" } + /** + * The total financial discount of the invoice (so discounts not subject to VAT). Must be + * positive and rounded to maximum 2 decimals + */ @JsonDeserialize(using = TotalDiscount.Deserializer::class) @JsonSerialize(using = TotalDiscount.Serializer::class) class TotalDiscount @@ -4579,6 +9584,7 @@ private constructor( } } + /** The total tax of the invoice. Must be positive and rounded to maximum 2 decimals */ @JsonDeserialize(using = TotalTax.Deserializer::class) @JsonSerialize(using = TotalTax.Serializer::class) class TotalTax @@ -5246,10 +10252,12 @@ private constructor( } return other is DocumentCreate && + allowances == other.allowances && amountDue == other.amountDue && attachments == other.attachments && billingAddress == other.billingAddress && billingAddressRecipient == other.billingAddressRecipient && + charges == other.charges && currency == other.currency && customerAddress == other.customerAddress && customerAddressRecipient == other.customerAddressRecipient && @@ -5295,10 +10303,12 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( + allowances, amountDue, attachments, billingAddress, billingAddressRecipient, + charges, currency, customerAddress, customerAddressRecipient, @@ -5346,5 +10356,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "DocumentCreate{amountDue=$amountDue, attachments=$attachments, billingAddress=$billingAddress, billingAddressRecipient=$billingAddressRecipient, currency=$currency, customerAddress=$customerAddress, customerAddressRecipient=$customerAddressRecipient, customerEmail=$customerEmail, customerId=$customerId, customerName=$customerName, customerTaxId=$customerTaxId, direction=$direction, documentType=$documentType, dueDate=$dueDate, invoiceDate=$invoiceDate, invoiceId=$invoiceId, invoiceTotal=$invoiceTotal, items=$items, note=$note, paymentDetails=$paymentDetails, paymentTerm=$paymentTerm, previousUnpaidBalance=$previousUnpaidBalance, purchaseOrder=$purchaseOrder, remittanceAddress=$remittanceAddress, remittanceAddressRecipient=$remittanceAddressRecipient, serviceAddress=$serviceAddress, serviceAddressRecipient=$serviceAddressRecipient, serviceEndDate=$serviceEndDate, serviceStartDate=$serviceStartDate, shippingAddress=$shippingAddress, shippingAddressRecipient=$shippingAddressRecipient, state=$state, subtotal=$subtotal, taxCode=$taxCode, taxDetails=$taxDetails, totalDiscount=$totalDiscount, totalTax=$totalTax, vatex=$vatex, vatexNote=$vatexNote, vendorAddress=$vendorAddress, vendorAddressRecipient=$vendorAddressRecipient, vendorEmail=$vendorEmail, vendorName=$vendorName, vendorTaxId=$vendorTaxId, additionalProperties=$additionalProperties}" + "DocumentCreate{allowances=$allowances, amountDue=$amountDue, attachments=$attachments, billingAddress=$billingAddress, billingAddressRecipient=$billingAddressRecipient, charges=$charges, currency=$currency, customerAddress=$customerAddress, customerAddressRecipient=$customerAddressRecipient, customerEmail=$customerEmail, customerId=$customerId, customerName=$customerName, customerTaxId=$customerTaxId, direction=$direction, documentType=$documentType, dueDate=$dueDate, invoiceDate=$invoiceDate, invoiceId=$invoiceId, invoiceTotal=$invoiceTotal, items=$items, note=$note, paymentDetails=$paymentDetails, paymentTerm=$paymentTerm, previousUnpaidBalance=$previousUnpaidBalance, purchaseOrder=$purchaseOrder, remittanceAddress=$remittanceAddress, remittanceAddressRecipient=$remittanceAddressRecipient, serviceAddress=$serviceAddress, serviceAddressRecipient=$serviceAddressRecipient, serviceEndDate=$serviceEndDate, serviceStartDate=$serviceStartDate, shippingAddress=$shippingAddress, shippingAddressRecipient=$shippingAddressRecipient, state=$state, subtotal=$subtotal, taxCode=$taxCode, taxDetails=$taxDetails, totalDiscount=$totalDiscount, totalTax=$totalTax, vatex=$vatex, vatexNote=$vatexNote, vendorAddress=$vendorAddress, vendorAddressRecipient=$vendorAddressRecipient, vendorEmail=$vendorEmail, vendorName=$vendorName, vendorTaxId=$vendorTaxId, additionalProperties=$additionalProperties}" } diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt index b62efe0..8628ddc 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt @@ -27,10 +27,12 @@ class DocumentResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, + private val allowances: JsonField>, private val amountDue: JsonField, private val attachments: JsonField>, private val billingAddress: JsonField, private val billingAddressRecipient: JsonField, + private val charges: JsonField>, private val currency: JsonField, private val customerAddress: JsonField, private val customerAddressRecipient: JsonField, @@ -77,6 +79,9 @@ private constructor( @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("allowances") + @ExcludeMissing + allowances: JsonField> = JsonMissing.of(), @JsonProperty("amount_due") @ExcludeMissing amountDue: JsonField = JsonMissing.of(), @JsonProperty("attachments") @ExcludeMissing @@ -87,6 +92,9 @@ private constructor( @JsonProperty("billing_address_recipient") @ExcludeMissing billingAddressRecipient: JsonField = JsonMissing.of(), + @JsonProperty("charges") + @ExcludeMissing + charges: JsonField> = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @@ -189,10 +197,12 @@ private constructor( vendorTaxId: JsonField = JsonMissing.of(), ) : this( id, + allowances, amountDue, attachments, billingAddress, billingAddressRecipient, + charges, currency, customerAddress, customerAddressRecipient, @@ -246,6 +256,14 @@ private constructor( * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ + fun allowances(): Optional> = allowances.getOptional("allowances") + + /** + * The amount due of the invoice. Must be positive and rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ fun amountDue(): Optional = amountDue.getOptional("amount_due") /** @@ -267,6 +285,12 @@ private constructor( fun billingAddressRecipient(): Optional = billingAddressRecipient.getOptional("billing_address_recipient") + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun charges(): Optional> = charges.getOptional("charges") + /** * Currency of the invoice * @@ -343,6 +367,9 @@ private constructor( fun invoiceId(): Optional = invoiceId.getOptional("invoice_id") /** + * The total amount of the invoice (so invoice_total = subtotal + total_tax + total_discount). + * Must be positive and rounded to maximum 2 decimals + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -374,6 +401,9 @@ private constructor( fun paymentTerm(): Optional = paymentTerm.getOptional("payment_term") /** + * The previous unpaid balance of the invoice, if any. Must be positive and rounded to maximum 2 + * decimals + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -444,6 +474,10 @@ private constructor( fun state(): Optional = state.getOptional("state") /** + * The taxable base of the invoice. Should be the sum of all line items - allowances (for + * example commercial discounts) + charges with impact on VAT. Must be positive and rounded to + * maximum 2 decimals + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -464,12 +498,17 @@ private constructor( fun taxDetails(): Optional> = taxDetails.getOptional("tax_details") /** + * The total financial discount of the invoice (so discounts not subject to VAT). Must be + * positive and rounded to maximum 2 decimals + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun totalDiscount(): Optional = totalDiscount.getOptional("total_discount") /** + * The total tax of the invoice. Must be positive and rounded to maximum 2 decimals + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -531,6 +570,15 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + /** + * Returns the raw JSON value of [allowances]. + * + * Unlike [allowances], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("allowances") + @ExcludeMissing + fun _allowances(): JsonField> = allowances + /** * Returns the raw JSON value of [amountDue]. * @@ -566,6 +614,13 @@ private constructor( @ExcludeMissing fun _billingAddressRecipient(): JsonField = billingAddressRecipient + /** + * Returns the raw JSON value of [charges]. + * + * Unlike [charges], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("charges") @ExcludeMissing fun _charges(): JsonField> = charges + /** * Returns the raw JSON value of [currency]. * @@ -937,10 +992,12 @@ private constructor( class Builder internal constructor() { private var id: JsonField? = null + private var allowances: JsonField>? = null private var amountDue: JsonField = JsonMissing.of() private var attachments: JsonField>? = null private var billingAddress: JsonField = JsonMissing.of() private var billingAddressRecipient: JsonField = JsonMissing.of() + private var charges: JsonField>? = null private var currency: JsonField = JsonMissing.of() private var customerAddress: JsonField = JsonMissing.of() private var customerAddressRecipient: JsonField = JsonMissing.of() @@ -986,10 +1043,12 @@ private constructor( @JvmSynthetic internal fun from(documentResponse: DocumentResponse) = apply { id = documentResponse.id + allowances = documentResponse.allowances.map { it.toMutableList() } amountDue = documentResponse.amountDue attachments = documentResponse.attachments.map { it.toMutableList() } billingAddress = documentResponse.billingAddress billingAddressRecipient = documentResponse.billingAddressRecipient + charges = documentResponse.charges.map { it.toMutableList() } currency = documentResponse.currency customerAddress = documentResponse.customerAddress customerAddressRecipient = documentResponse.customerAddressRecipient @@ -1043,6 +1102,35 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } + fun allowances(allowances: List?) = allowances(JsonField.ofNullable(allowances)) + + /** Alias for calling [Builder.allowances] with `allowances.orElse(null)`. */ + fun allowances(allowances: Optional>) = allowances(allowances.getOrNull()) + + /** + * Sets [Builder.allowances] to an arbitrary JSON value. + * + * You should usually call [Builder.allowances] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun allowances(allowances: JsonField>) = apply { + this.allowances = allowances.map { it.toMutableList() } + } + + /** + * Adds a single [Allowance] to [allowances]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowance(allowance: Allowance) = apply { + allowances = + (allowances ?: JsonField.of(mutableListOf())).also { + checkKnown("allowances", it).add(allowance) + } + } + + /** The amount due of the invoice. Must be positive and rounded to maximum 2 decimals */ fun amountDue(amountDue: String?) = amountDue(JsonField.ofNullable(amountDue)) /** Alias for calling [Builder.amountDue] with `amountDue.orElse(null)`. */ @@ -1057,8 +1145,12 @@ private constructor( */ fun amountDue(amountDue: JsonField) = apply { this.amountDue = amountDue } - fun attachments(attachments: List) = - attachments(JsonField.of(attachments)) + fun attachments(attachments: List?) = + attachments(JsonField.ofNullable(attachments)) + + /** Alias for calling [Builder.attachments] with `attachments.orElse(null)`. */ + fun attachments(attachments: Optional>) = + attachments(attachments.getOrNull()) /** * Sets [Builder.attachments] to an arbitrary JSON value. @@ -1122,6 +1214,34 @@ private constructor( this.billingAddressRecipient = billingAddressRecipient } + fun charges(charges: List?) = charges(JsonField.ofNullable(charges)) + + /** Alias for calling [Builder.charges] with `charges.orElse(null)`. */ + fun charges(charges: Optional>) = charges(charges.getOrNull()) + + /** + * Sets [Builder.charges] to an arbitrary JSON value. + * + * You should usually call [Builder.charges] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun charges(charges: JsonField>) = apply { + this.charges = charges.map { it.toMutableList() } + } + + /** + * Adds a single [Charge] to [charges]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCharge(charge: Charge) = apply { + charges = + (charges ?: JsonField.of(mutableListOf())).also { + checkKnown("charges", it).add(charge) + } + } + /** Currency of the invoice */ fun currency(currency: CurrencyCode) = currency(JsonField.of(currency)) @@ -1309,6 +1429,10 @@ private constructor( */ fun invoiceId(invoiceId: JsonField) = apply { this.invoiceId = invoiceId } + /** + * The total amount of the invoice (so invoice_total = subtotal + total_tax + + * total_discount). Must be positive and rounded to maximum 2 decimals + */ fun invoiceTotal(invoiceTotal: String?) = invoiceTotal(JsonField.ofNullable(invoiceTotal)) /** Alias for calling [Builder.invoiceTotal] with `invoiceTotal.orElse(null)`. */ @@ -1325,7 +1449,10 @@ private constructor( this.invoiceTotal = invoiceTotal } - fun items(items: List) = items(JsonField.of(items)) + fun items(items: List?) = items(JsonField.ofNullable(items)) + + /** Alias for calling [Builder.items] with `items.orElse(null)`. */ + fun items(items: Optional>) = items(items.getOrNull()) /** * Sets [Builder.items] to an arbitrary JSON value. @@ -1361,8 +1488,12 @@ private constructor( */ fun note(note: JsonField) = apply { this.note = note } - fun paymentDetails(paymentDetails: List) = - paymentDetails(JsonField.of(paymentDetails)) + fun paymentDetails(paymentDetails: List?) = + paymentDetails(JsonField.ofNullable(paymentDetails)) + + /** Alias for calling [Builder.paymentDetails] with `paymentDetails.orElse(null)`. */ + fun paymentDetails(paymentDetails: Optional>) = + paymentDetails(paymentDetails.getOrNull()) /** * Sets [Builder.paymentDetails] to an arbitrary JSON value. @@ -1401,6 +1532,10 @@ private constructor( */ fun paymentTerm(paymentTerm: JsonField) = apply { this.paymentTerm = paymentTerm } + /** + * The previous unpaid balance of the invoice, if any. Must be positive and rounded to + * maximum 2 decimals + */ fun previousUnpaidBalance(previousUnpaidBalance: String?) = previousUnpaidBalance(JsonField.ofNullable(previousUnpaidBalance)) @@ -1604,6 +1739,11 @@ private constructor( */ fun state(state: JsonField) = apply { this.state = state } + /** + * The taxable base of the invoice. Should be the sum of all line items - allowances (for + * example commercial discounts) + charges with impact on VAT. Must be positive and rounded + * to maximum 2 decimals + */ fun subtotal(subtotal: String?) = subtotal(JsonField.ofNullable(subtotal)) /** Alias for calling [Builder.subtotal] with `subtotal.orElse(null)`. */ @@ -1628,7 +1768,10 @@ private constructor( */ fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } - fun taxDetails(taxDetails: List) = taxDetails(JsonField.of(taxDetails)) + fun taxDetails(taxDetails: List?) = taxDetails(JsonField.ofNullable(taxDetails)) + + /** Alias for calling [Builder.taxDetails] with `taxDetails.orElse(null)`. */ + fun taxDetails(taxDetails: Optional>) = taxDetails(taxDetails.getOrNull()) /** * Sets [Builder.taxDetails] to an arbitrary JSON value. @@ -1653,6 +1796,10 @@ private constructor( } } + /** + * The total financial discount of the invoice (so discounts not subject to VAT). Must be + * positive and rounded to maximum 2 decimals + */ fun totalDiscount(totalDiscount: String?) = totalDiscount(JsonField.ofNullable(totalDiscount)) @@ -1671,6 +1818,7 @@ private constructor( this.totalDiscount = totalDiscount } + /** The total tax of the invoice. Must be positive and rounded to maximum 2 decimals */ fun totalTax(totalTax: String?) = totalTax(JsonField.ofNullable(totalTax)) /** Alias for calling [Builder.totalTax] with `totalTax.orElse(null)`. */ @@ -1832,10 +1980,12 @@ private constructor( fun build(): DocumentResponse = DocumentResponse( checkRequired("id", id), + (allowances ?: JsonMissing.of()).map { it.toImmutable() }, amountDue, (attachments ?: JsonMissing.of()).map { it.toImmutable() }, billingAddress, billingAddressRecipient, + (charges ?: JsonMissing.of()).map { it.toImmutable() }, currency, customerAddress, customerAddressRecipient, @@ -1888,10 +2038,12 @@ private constructor( } id() + allowances().ifPresent { it.forEach { it.validate() } } amountDue() attachments().ifPresent { it.forEach { it.validate() } } billingAddress() billingAddressRecipient() + charges().ifPresent { it.forEach { it.validate() } } currency().ifPresent { it.validate() } customerAddress() customerAddressRecipient() @@ -1951,10 +2103,12 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + + (allowances.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (amountDue.asKnown().isPresent) 1 else 0) + (attachments.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (billingAddress.asKnown().isPresent) 1 else 0) + (if (billingAddressRecipient.asKnown().isPresent) 1 else 0) + + (charges.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (currency.asKnown().getOrNull()?.validity() ?: 0) + (if (customerAddress.asKnown().isPresent) 1 else 0) + (if (customerAddressRecipient.asKnown().isPresent) 1 else 0) + @@ -1996,110 +2150,106 @@ private constructor( (if (vendorName.asKnown().isPresent) 1 else 0) + (if (vendorTaxId.asKnown().isPresent) 1 else 0) - class Item + class Allowance @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, - private val date: JsonField, - private val description: JsonField, - private val productCode: JsonField, - private val quantity: JsonField, - private val tax: JsonField, + private val baseAmount: JsonField, + private val multiplierFactor: JsonField, + private val reason: JsonField, + private val reasonCode: JsonField, + private val taxCode: JsonField, private val taxRate: JsonField, - private val unit: JsonField, - private val unitPrice: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("date") @ExcludeMissing date: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("product_code") + @JsonProperty("base_amount") @ExcludeMissing - productCode: JsonField = JsonMissing.of(), - @JsonProperty("quantity") + baseAmount: JsonField = JsonMissing.of(), + @JsonProperty("multiplier_factor") @ExcludeMissing - quantity: JsonField = JsonMissing.of(), - @JsonProperty("tax") @ExcludeMissing tax: JsonField = JsonMissing.of(), - @JsonProperty("tax_rate") @ExcludeMissing taxRate: JsonField = JsonMissing.of(), - @JsonProperty("unit") + multiplierFactor: JsonField = JsonMissing.of(), + @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), + @JsonProperty("reason_code") @ExcludeMissing - unit: JsonField = JsonMissing.of(), - @JsonProperty("unit_price") + reasonCode: JsonField = JsonMissing.of(), + @JsonProperty("tax_code") @ExcludeMissing - unitPrice: JsonField = JsonMissing.of(), + taxCode: JsonField = JsonMissing.of(), + @JsonProperty("tax_rate") @ExcludeMissing taxRate: JsonField = JsonMissing.of(), ) : this( amount, - date, - description, - productCode, - quantity, - tax, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, taxRate, - unit, - unitPrice, mutableMapOf(), ) /** + * The allowance amount, without VAT. Must be rounded to maximum 2 decimals + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ fun amount(): Optional = amount.getOptional("amount") /** + * The base amount that may be used, in conjunction with the allowance percentage, to + * calculate the allowance amount. Must be rounded to maximum 2 decimals + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun date(): Optional = date.getOptional("date") - - /** - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun description(): Optional = description.getOptional("description") - - /** - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun productCode(): Optional = productCode.getOptional("product_code") + fun baseAmount(): Optional = baseAmount.getOptional("base_amount") /** + * The percentage that may be used, in conjunction with the allowance base amount, to + * calculate the allowance amount. To state 20%, use value 20 + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun quantity(): Optional = quantity.getOptional("quantity") + fun multiplierFactor(): Optional = multiplierFactor.getOptional("multiplier_factor") /** + * The reason for the allowance + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun tax(): Optional = tax.getOptional("tax") + fun reason(): Optional = reason.getOptional("reason") /** + * The code for the allowance reason + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun taxRate(): Optional = taxRate.getOptional("tax_rate") + fun reasonCode(): Optional = reasonCode.getOptional("reason_code") /** - * Unit of Measure Codes from UNECERec20 used in Peppol BIS Billing 3.0. + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun unit(): Optional = unit.getOptional("unit") + fun taxCode(): Optional = taxCode.getOptional("tax_code") /** + * The VAT rate, represented as percentage that applies to the allowance + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun unitPrice(): Optional = unitPrice.getOptional("unit_price") + fun taxRate(): Optional = taxRate.getOptional("tax_rate") /** * Returns the raw JSON value of [amount]. @@ -2109,43 +2259,46 @@ private constructor( @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** - * Returns the raw JSON value of [date]. + * Returns the raw JSON value of [baseAmount]. * - * Unlike [date], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [baseAmount], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("date") @ExcludeMissing fun _date(): JsonField = date + @JsonProperty("base_amount") + @ExcludeMissing + fun _baseAmount(): JsonField = baseAmount /** - * Returns the raw JSON value of [description]. + * Returns the raw JSON value of [multiplierFactor]. * - * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [multiplierFactor], this method doesn't throw if the JSON field has an unexpected + * type. */ - @JsonProperty("description") + @JsonProperty("multiplier_factor") @ExcludeMissing - fun _description(): JsonField = description + fun _multiplierFactor(): JsonField = multiplierFactor /** - * Returns the raw JSON value of [productCode]. + * Returns the raw JSON value of [reason]. * - * Unlike [productCode], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("product_code") - @ExcludeMissing - fun _productCode(): JsonField = productCode + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason /** - * Returns the raw JSON value of [quantity]. + * Returns the raw JSON value of [reasonCode]. * - * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [reasonCode], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity + @JsonProperty("reason_code") + @ExcludeMissing + fun _reasonCode(): JsonField = reasonCode /** - * Returns the raw JSON value of [tax]. + * Returns the raw JSON value of [taxCode]. * - * Unlike [tax], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [taxCode], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("tax") @ExcludeMissing fun _tax(): JsonField = tax + @JsonProperty("tax_code") @ExcludeMissing fun _taxCode(): JsonField = taxCode /** * Returns the raw JSON value of [taxRate]. @@ -2154,20 +2307,6 @@ private constructor( */ @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate - /** - * Returns the raw JSON value of [unit]. - * - * Unlike [unit], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit - - /** - * Returns the raw JSON value of [unitPrice]. - * - * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("unit_price") @ExcludeMissing fun _unitPrice(): JsonField = unitPrice - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -2182,38 +2321,35 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Item]. */ + /** Returns a mutable builder for constructing an instance of [Allowance]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [Item]. */ + /** A builder for [Allowance]. */ class Builder internal constructor() { private var amount: JsonField = JsonMissing.of() - private var date: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var productCode: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var tax: JsonField = JsonMissing.of() + private var baseAmount: JsonField = JsonMissing.of() + private var multiplierFactor: JsonField = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var reasonCode: JsonField = JsonMissing.of() + private var taxCode: JsonField = JsonMissing.of() private var taxRate: JsonField = JsonMissing.of() - private var unit: JsonField = JsonMissing.of() - private var unitPrice: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(item: Item) = apply { - amount = item.amount - date = item.date - description = item.description - productCode = item.productCode - quantity = item.quantity - tax = item.tax - taxRate = item.taxRate - unit = item.unit - unitPrice = item.unitPrice - additionalProperties = item.additionalProperties.toMutableMap() + internal fun from(allowance: Allowance) = apply { + amount = allowance.amount + baseAmount = allowance.baseAmount + multiplierFactor = allowance.multiplierFactor + reason = allowance.reason + reasonCode = allowance.reasonCode + taxCode = allowance.taxCode + taxRate = allowance.taxRate + additionalProperties = allowance.additionalProperties.toMutableMap() } + /** The allowance amount, without VAT. Must be rounded to maximum 2 decimals */ fun amount(amount: String?) = amount(JsonField.ofNullable(amount)) /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ @@ -2228,80 +2364,98 @@ private constructor( */ fun amount(amount: JsonField) = apply { this.amount = amount } - fun date(date: Void?) = date(JsonField.ofNullable(date)) + /** + * The base amount that may be used, in conjunction with the allowance percentage, to + * calculate the allowance amount. Must be rounded to maximum 2 decimals + */ + fun baseAmount(baseAmount: String?) = baseAmount(JsonField.ofNullable(baseAmount)) - /** Alias for calling [Builder.date] with `date.orElse(null)`. */ - fun date(date: Optional) = date(date.getOrNull()) + /** Alias for calling [Builder.baseAmount] with `baseAmount.orElse(null)`. */ + fun baseAmount(baseAmount: Optional) = baseAmount(baseAmount.getOrNull()) /** - * Sets [Builder.date] to an arbitrary JSON value. + * Sets [Builder.baseAmount] to an arbitrary JSON value. * - * You should usually call [Builder.date] with a well-typed [Void] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. + * You should usually call [Builder.baseAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun date(date: JsonField) = apply { this.date = date } + fun baseAmount(baseAmount: JsonField) = apply { this.baseAmount = baseAmount } - fun description(description: String?) = description(JsonField.ofNullable(description)) + /** + * The percentage that may be used, in conjunction with the allowance base amount, to + * calculate the allowance amount. To state 20%, use value 20 + */ + fun multiplierFactor(multiplierFactor: String?) = + multiplierFactor(JsonField.ofNullable(multiplierFactor)) - /** Alias for calling [Builder.description] with `description.orElse(null)`. */ - fun description(description: Optional) = description(description.getOrNull()) + /** + * Alias for calling [Builder.multiplierFactor] with `multiplierFactor.orElse(null)`. + */ + fun multiplierFactor(multiplierFactor: Optional) = + multiplierFactor(multiplierFactor.getOrNull()) /** - * Sets [Builder.description] to an arbitrary JSON value. + * Sets [Builder.multiplierFactor] to an arbitrary JSON value. * - * You should usually call [Builder.description] with a well-typed [String] value + * You should usually call [Builder.multiplierFactor] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun description(description: JsonField) = apply { - this.description = description + fun multiplierFactor(multiplierFactor: JsonField) = apply { + this.multiplierFactor = multiplierFactor } - fun productCode(productCode: String?) = productCode(JsonField.ofNullable(productCode)) + /** The reason for the allowance */ + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - /** Alias for calling [Builder.productCode] with `productCode.orElse(null)`. */ - fun productCode(productCode: Optional) = productCode(productCode.getOrNull()) + /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ + fun reason(reason: Optional) = reason(reason.getOrNull()) /** - * Sets [Builder.productCode] to an arbitrary JSON value. + * Sets [Builder.reason] to an arbitrary JSON value. * - * You should usually call [Builder.productCode] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet + * You should usually call [Builder.reason] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun productCode(productCode: JsonField) = apply { - this.productCode = productCode - } + fun reason(reason: JsonField) = apply { this.reason = reason } - fun quantity(quantity: String?) = quantity(JsonField.ofNullable(quantity)) + /** The code for the allowance reason */ + fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) - /** Alias for calling [Builder.quantity] with `quantity.orElse(null)`. */ - fun quantity(quantity: Optional) = quantity(quantity.getOrNull()) + /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ + fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) /** - * Sets [Builder.quantity] to an arbitrary JSON value. + * Sets [Builder.reasonCode] to an arbitrary JSON value. * - * You should usually call [Builder.quantity] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet + * You should usually call [Builder.reasonCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode } - fun tax(tax: String?) = tax(JsonField.ofNullable(tax)) + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + */ + fun taxCode(taxCode: TaxCode?) = taxCode(JsonField.ofNullable(taxCode)) - /** Alias for calling [Builder.tax] with `tax.orElse(null)`. */ - fun tax(tax: Optional) = tax(tax.getOrNull()) + /** Alias for calling [Builder.taxCode] with `taxCode.orElse(null)`. */ + fun taxCode(taxCode: Optional) = taxCode(taxCode.getOrNull()) /** - * Sets [Builder.tax] to an arbitrary JSON value. + * Sets [Builder.taxCode] to an arbitrary JSON value. * - * You should usually call [Builder.tax] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. + * You should usually call [Builder.taxCode] with a well-typed [TaxCode] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun tax(tax: JsonField) = apply { this.tax = tax } + fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } + /** The VAT rate, represented as percentage that applies to the allowance */ fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ @@ -2316,43 +2470,14 @@ private constructor( */ fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } - /** Unit of Measure Codes from UNECERec20 used in Peppol BIS Billing 3.0. */ - fun unit(unit: UnitOfMeasureCode?) = unit(JsonField.ofNullable(unit)) + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - /** Alias for calling [Builder.unit] with `unit.orElse(null)`. */ - fun unit(unit: Optional) = unit(unit.getOrNull()) - - /** - * Sets [Builder.unit] to an arbitrary JSON value. - * - * You should usually call [Builder.unit] with a well-typed [UnitOfMeasureCode] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun unit(unit: JsonField) = apply { this.unit = unit } - - fun unitPrice(unitPrice: String?) = unitPrice(JsonField.ofNullable(unitPrice)) - - /** Alias for calling [Builder.unitPrice] with `unitPrice.orElse(null)`. */ - fun unitPrice(unitPrice: Optional) = unitPrice(unitPrice.getOrNull()) - - /** - * Sets [Builder.unitPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.unitPrice] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } fun putAllAdditionalProperties(additionalProperties: Map) = apply { this.additionalProperties.putAll(additionalProperties) @@ -2365,41 +2490,37 @@ private constructor( } /** - * Returns an immutable instance of [Item]. + * Returns an immutable instance of [Allowance]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): Item = - Item( + fun build(): Allowance = + Allowance( amount, - date, - description, - productCode, - quantity, - tax, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, taxRate, - unit, - unitPrice, additionalProperties.toMutableMap(), ) } private var validated: Boolean = false - fun validate(): Item = apply { + fun validate(): Allowance = apply { if (validated) { return@apply } amount() - date() - description() - productCode() - quantity() - tax() + baseAmount() + multiplierFactor() + reason() + reasonCode() + taxCode().ifPresent { it.validate() } taxRate() - unit().ifPresent { it.validate() } - unitPrice() validated = true } @@ -2420,14 +2541,2690 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (amount.asKnown().isPresent) 1 else 0) + - (if (date.asKnown().isPresent) 1 else 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (if (productCode.asKnown().isPresent) 1 else 0) + - (if (quantity.asKnown().isPresent) 1 else 0) + - (if (tax.asKnown().isPresent) 1 else 0) + - (if (taxRate.asKnown().isPresent) 1 else 0) + - (unit.asKnown().getOrNull()?.validity() ?: 0) + - (if (unitPrice.asKnown().isPresent) 1 else 0) + (if (baseAmount.asKnown().isPresent) 1 else 0) + + (if (multiplierFactor.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (if (reasonCode.asKnown().isPresent) 1 else 0) + + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + + (if (taxRate.asKnown().isPresent) 1 else 0) + + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + */ + class TaxCode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val AE = of("AE") + + @JvmField val E = of("E") + + @JvmField val S = of("S") + + @JvmField val Z = of("Z") + + @JvmField val G = of("G") + + @JvmField val O = of("O") + + @JvmField val K = of("K") + + @JvmField val L = of("L") + + @JvmField val M = of("M") + + @JvmField val B = of("B") + + @JvmStatic fun of(value: String) = TaxCode(JsonField.of(value)) + } + + /** An enum containing [TaxCode]'s known values. */ + enum class Known { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + } + + /** + * An enum containing [TaxCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TaxCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + /** + * An enum member indicating that [TaxCode] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AE -> Value.AE + E -> Value.E + S -> Value.S + Z -> Value.Z + G -> Value.G + O -> Value.O + K -> Value.K + L -> Value.L + M -> Value.M + B -> Value.B + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + AE -> Known.AE + E -> Known.E + S -> Known.S + Z -> Known.Z + G -> Known.G + O -> Known.O + K -> Known.K + L -> Known.L + M -> Known.M + B -> Known.B + else -> throw EInvoiceInvalidDataException("Unknown TaxCode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TaxCode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TaxCode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Allowance && + amount == other.amount && + baseAmount == other.baseAmount && + multiplierFactor == other.multiplierFactor && + reason == other.reason && + reasonCode == other.reasonCode && + taxCode == other.taxCode && + taxRate == other.taxRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Allowance{amount=$amount, baseAmount=$baseAmount, multiplierFactor=$multiplierFactor, reason=$reason, reasonCode=$reasonCode, taxCode=$taxCode, taxRate=$taxRate, additionalProperties=$additionalProperties}" + } + + class Charge + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val baseAmount: JsonField, + private val multiplierFactor: JsonField, + private val reason: JsonField, + private val reasonCode: JsonField, + private val taxCode: JsonField, + private val taxRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("base_amount") + @ExcludeMissing + baseAmount: JsonField = JsonMissing.of(), + @JsonProperty("multiplier_factor") + @ExcludeMissing + multiplierFactor: JsonField = JsonMissing.of(), + @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), + @JsonProperty("reason_code") + @ExcludeMissing + reasonCode: JsonField = JsonMissing.of(), + @JsonProperty("tax_code") + @ExcludeMissing + taxCode: JsonField = JsonMissing.of(), + @JsonProperty("tax_rate") @ExcludeMissing taxRate: JsonField = JsonMissing.of(), + ) : this( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + mutableMapOf(), + ) + + /** + * The charge amount, without VAT. Must be rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * The base amount that may be used, in conjunction with the charge percentage, to calculate + * the charge amount. Must be rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun baseAmount(): Optional = baseAmount.getOptional("base_amount") + + /** + * The percentage that may be used, in conjunction with the charge base amount, to calculate + * the charge amount. To state 20%, use value 20 + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun multiplierFactor(): Optional = multiplierFactor.getOptional("multiplier_factor") + + /** + * The reason for the charge + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun reason(): Optional = reason.getOptional("reason") + + /** + * The code for the charge reason + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun reasonCode(): Optional = reasonCode.getOptional("reason_code") + + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun taxCode(): Optional = taxCode.getOptional("tax_code") + + /** + * The VAT rate, represented as percentage that applies to the charge + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun taxRate(): Optional = taxRate.getOptional("tax_rate") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [baseAmount]. + * + * Unlike [baseAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("base_amount") + @ExcludeMissing + fun _baseAmount(): JsonField = baseAmount + + /** + * Returns the raw JSON value of [multiplierFactor]. + * + * Unlike [multiplierFactor], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("multiplier_factor") + @ExcludeMissing + fun _multiplierFactor(): JsonField = multiplierFactor + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + /** + * Returns the raw JSON value of [reasonCode]. + * + * Unlike [reasonCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reason_code") + @ExcludeMissing + fun _reasonCode(): JsonField = reasonCode + + /** + * Returns the raw JSON value of [taxCode]. + * + * Unlike [taxCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax_code") @ExcludeMissing fun _taxCode(): JsonField = taxCode + + /** + * Returns the raw JSON value of [taxRate]. + * + * Unlike [taxRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Charge]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Charge]. */ + class Builder internal constructor() { + + private var amount: JsonField = JsonMissing.of() + private var baseAmount: JsonField = JsonMissing.of() + private var multiplierFactor: JsonField = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var reasonCode: JsonField = JsonMissing.of() + private var taxCode: JsonField = JsonMissing.of() + private var taxRate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(charge: Charge) = apply { + amount = charge.amount + baseAmount = charge.baseAmount + multiplierFactor = charge.multiplierFactor + reason = charge.reason + reasonCode = charge.reasonCode + taxCode = charge.taxCode + taxRate = charge.taxRate + additionalProperties = charge.additionalProperties.toMutableMap() + } + + /** The charge amount, without VAT. Must be rounded to maximum 2 decimals */ + fun amount(amount: String?) = amount(JsonField.ofNullable(amount)) + + /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ + fun amount(amount: Optional) = amount(amount.getOrNull()) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** + * The base amount that may be used, in conjunction with the charge percentage, to + * calculate the charge amount. Must be rounded to maximum 2 decimals + */ + fun baseAmount(baseAmount: String?) = baseAmount(JsonField.ofNullable(baseAmount)) + + /** Alias for calling [Builder.baseAmount] with `baseAmount.orElse(null)`. */ + fun baseAmount(baseAmount: Optional) = baseAmount(baseAmount.getOrNull()) + + /** + * Sets [Builder.baseAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.baseAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun baseAmount(baseAmount: JsonField) = apply { this.baseAmount = baseAmount } + + /** + * The percentage that may be used, in conjunction with the charge base amount, to + * calculate the charge amount. To state 20%, use value 20 + */ + fun multiplierFactor(multiplierFactor: String?) = + multiplierFactor(JsonField.ofNullable(multiplierFactor)) + + /** + * Alias for calling [Builder.multiplierFactor] with `multiplierFactor.orElse(null)`. + */ + fun multiplierFactor(multiplierFactor: Optional) = + multiplierFactor(multiplierFactor.getOrNull()) + + /** + * Sets [Builder.multiplierFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.multiplierFactor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun multiplierFactor(multiplierFactor: JsonField) = apply { + this.multiplierFactor = multiplierFactor + } + + /** The reason for the charge */ + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ + fun reason(reason: Optional) = reason(reason.getOrNull()) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + /** The code for the charge reason */ + fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) + + /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ + fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) + + /** + * Sets [Builder.reasonCode] to an arbitrary JSON value. + * + * You should usually call [Builder.reasonCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode } + + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + */ + fun taxCode(taxCode: TaxCode?) = taxCode(JsonField.ofNullable(taxCode)) + + /** Alias for calling [Builder.taxCode] with `taxCode.orElse(null)`. */ + fun taxCode(taxCode: Optional) = taxCode(taxCode.getOrNull()) + + /** + * Sets [Builder.taxCode] to an arbitrary JSON value. + * + * You should usually call [Builder.taxCode] with a well-typed [TaxCode] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } + + /** The VAT rate, represented as percentage that applies to the charge */ + fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) + + /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ + fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) + + /** + * Sets [Builder.taxRate] to an arbitrary JSON value. + * + * You should usually call [Builder.taxRate] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Charge]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Charge = + Charge( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Charge = apply { + if (validated) { + return@apply + } + + amount() + baseAmount() + multiplierFactor() + reason() + reasonCode() + taxCode().ifPresent { it.validate() } + taxRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (baseAmount.asKnown().isPresent) 1 else 0) + + (if (multiplierFactor.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (if (reasonCode.asKnown().isPresent) 1 else 0) + + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + + (if (taxRate.asKnown().isPresent) 1 else 0) + + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + */ + class TaxCode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val AE = of("AE") + + @JvmField val E = of("E") + + @JvmField val S = of("S") + + @JvmField val Z = of("Z") + + @JvmField val G = of("G") + + @JvmField val O = of("O") + + @JvmField val K = of("K") + + @JvmField val L = of("L") + + @JvmField val M = of("M") + + @JvmField val B = of("B") + + @JvmStatic fun of(value: String) = TaxCode(JsonField.of(value)) + } + + /** An enum containing [TaxCode]'s known values. */ + enum class Known { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + } + + /** + * An enum containing [TaxCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TaxCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + /** + * An enum member indicating that [TaxCode] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AE -> Value.AE + E -> Value.E + S -> Value.S + Z -> Value.Z + G -> Value.G + O -> Value.O + K -> Value.K + L -> Value.L + M -> Value.M + B -> Value.B + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + AE -> Known.AE + E -> Known.E + S -> Known.S + Z -> Known.Z + G -> Known.G + O -> Known.O + K -> Known.K + L -> Known.L + M -> Known.M + B -> Known.B + else -> throw EInvoiceInvalidDataException("Unknown TaxCode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TaxCode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TaxCode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Charge && + amount == other.amount && + baseAmount == other.baseAmount && + multiplierFactor == other.multiplierFactor && + reason == other.reason && + reasonCode == other.reasonCode && + taxCode == other.taxCode && + taxRate == other.taxRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Charge{amount=$amount, baseAmount=$baseAmount, multiplierFactor=$multiplierFactor, reason=$reason, reasonCode=$reasonCode, taxCode=$taxCode, taxRate=$taxRate, additionalProperties=$additionalProperties}" + } + + class Item + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allowances: JsonField>, + private val amount: JsonField, + private val charges: JsonField>, + private val date: JsonField, + private val description: JsonField, + private val productCode: JsonField, + private val quantity: JsonField, + private val tax: JsonField, + private val taxRate: JsonField, + private val unit: JsonField, + private val unitPrice: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allowances") + @ExcludeMissing + allowances: JsonField> = JsonMissing.of(), + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("charges") + @ExcludeMissing + charges: JsonField> = JsonMissing.of(), + @JsonProperty("date") @ExcludeMissing date: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("product_code") + @ExcludeMissing + productCode: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + @JsonProperty("tax") @ExcludeMissing tax: JsonField = JsonMissing.of(), + @JsonProperty("tax_rate") @ExcludeMissing taxRate: JsonField = JsonMissing.of(), + @JsonProperty("unit") + @ExcludeMissing + unit: JsonField = JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + ) : this( + allowances, + amount, + charges, + date, + description, + productCode, + quantity, + tax, + taxRate, + unit, + unitPrice, + mutableMapOf(), + ) + + /** + * The allowances of the line item. + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun allowances(): Optional> = allowances.getOptional("allowances") + + /** + * The total amount of the line item, exclusive of VAT, after subtracting line level + * allowances and adding line level charges. Must be rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * The charges of the line item. + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun charges(): Optional> = charges.getOptional("charges") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun date(): Optional = date.getOptional("date") + + /** + * The description of the line item. + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * The product code of the line item. + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun productCode(): Optional = productCode.getOptional("product_code") + + /** + * The quantity of items (goods or services) that is the subject of the line item. Must be + * rounded to maximum 4 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun quantity(): Optional = quantity.getOptional("quantity") + + /** + * The total VAT amount for the line item. Must be rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tax(): Optional = tax.getOptional("tax") + + /** + * The VAT rate of the line item expressed as percentage with 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun taxRate(): Optional = taxRate.getOptional("tax_rate") + + /** + * Unit of Measure Codes from UNECERec20 used in Peppol BIS Billing 3.0. + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun unit(): Optional = unit.getOptional("unit") + + /** + * The unit price of the line item. Must be rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun unitPrice(): Optional = unitPrice.getOptional("unit_price") + + /** + * Returns the raw JSON value of [allowances]. + * + * Unlike [allowances], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("allowances") + @ExcludeMissing + fun _allowances(): JsonField> = allowances + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [charges]. + * + * Unlike [charges], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("charges") @ExcludeMissing fun _charges(): JsonField> = charges + + /** + * Returns the raw JSON value of [date]. + * + * Unlike [date], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("date") @ExcludeMissing fun _date(): JsonField = date + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [productCode]. + * + * Unlike [productCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("product_code") + @ExcludeMissing + fun _productCode(): JsonField = productCode + + /** + * Returns the raw JSON value of [quantity]. + * + * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity + + /** + * Returns the raw JSON value of [tax]. + * + * Unlike [tax], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax") @ExcludeMissing fun _tax(): JsonField = tax + + /** + * Returns the raw JSON value of [taxRate]. + * + * Unlike [taxRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate + + /** + * Returns the raw JSON value of [unit]. + * + * Unlike [unit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit + + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("unit_price") @ExcludeMissing fun _unitPrice(): JsonField = unitPrice + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Item]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Item]. */ + class Builder internal constructor() { + + private var allowances: JsonField>? = null + private var amount: JsonField = JsonMissing.of() + private var charges: JsonField>? = null + private var date: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var productCode: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var tax: JsonField = JsonMissing.of() + private var taxRate: JsonField = JsonMissing.of() + private var unit: JsonField = JsonMissing.of() + private var unitPrice: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(item: Item) = apply { + allowances = item.allowances.map { it.toMutableList() } + amount = item.amount + charges = item.charges.map { it.toMutableList() } + date = item.date + description = item.description + productCode = item.productCode + quantity = item.quantity + tax = item.tax + taxRate = item.taxRate + unit = item.unit + unitPrice = item.unitPrice + additionalProperties = item.additionalProperties.toMutableMap() + } + + /** The allowances of the line item. */ + fun allowances(allowances: List?) = + allowances(JsonField.ofNullable(allowances)) + + /** Alias for calling [Builder.allowances] with `allowances.orElse(null)`. */ + fun allowances(allowances: Optional>) = + allowances(allowances.getOrNull()) + + /** + * Sets [Builder.allowances] to an arbitrary JSON value. + * + * You should usually call [Builder.allowances] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun allowances(allowances: JsonField>) = apply { + this.allowances = allowances.map { it.toMutableList() } + } + + /** + * Adds a single [Allowance] to [allowances]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowance(allowance: Allowance) = apply { + allowances = + (allowances ?: JsonField.of(mutableListOf())).also { + checkKnown("allowances", it).add(allowance) + } + } + + /** + * The total amount of the line item, exclusive of VAT, after subtracting line level + * allowances and adding line level charges. Must be rounded to maximum 2 decimals + */ + fun amount(amount: String?) = amount(JsonField.ofNullable(amount)) + + /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ + fun amount(amount: Optional) = amount(amount.getOrNull()) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The charges of the line item. */ + fun charges(charges: List?) = charges(JsonField.ofNullable(charges)) + + /** Alias for calling [Builder.charges] with `charges.orElse(null)`. */ + fun charges(charges: Optional>) = charges(charges.getOrNull()) + + /** + * Sets [Builder.charges] to an arbitrary JSON value. + * + * You should usually call [Builder.charges] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun charges(charges: JsonField>) = apply { + this.charges = charges.map { it.toMutableList() } + } + + /** + * Adds a single [Charge] to [charges]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCharge(charge: Charge) = apply { + charges = + (charges ?: JsonField.of(mutableListOf())).also { + checkKnown("charges", it).add(charge) + } + } + + fun date(date: Void?) = date(JsonField.ofNullable(date)) + + /** Alias for calling [Builder.date] with `date.orElse(null)`. */ + fun date(date: Optional) = date(date.getOrNull()) + + /** + * Sets [Builder.date] to an arbitrary JSON value. + * + * You should usually call [Builder.date] with a well-typed [Void] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun date(date: JsonField) = apply { this.date = date } + + /** The description of the line item. */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** The product code of the line item. */ + fun productCode(productCode: String?) = productCode(JsonField.ofNullable(productCode)) + + /** Alias for calling [Builder.productCode] with `productCode.orElse(null)`. */ + fun productCode(productCode: Optional) = productCode(productCode.getOrNull()) + + /** + * Sets [Builder.productCode] to an arbitrary JSON value. + * + * You should usually call [Builder.productCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun productCode(productCode: JsonField) = apply { + this.productCode = productCode + } + + /** + * The quantity of items (goods or services) that is the subject of the line item. Must + * be rounded to maximum 4 decimals + */ + fun quantity(quantity: String?) = quantity(JsonField.ofNullable(quantity)) + + /** Alias for calling [Builder.quantity] with `quantity.orElse(null)`. */ + fun quantity(quantity: Optional) = quantity(quantity.getOrNull()) + + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + /** The total VAT amount for the line item. Must be rounded to maximum 2 decimals */ + fun tax(tax: String?) = tax(JsonField.ofNullable(tax)) + + /** Alias for calling [Builder.tax] with `tax.orElse(null)`. */ + fun tax(tax: Optional) = tax(tax.getOrNull()) + + /** + * Sets [Builder.tax] to an arbitrary JSON value. + * + * You should usually call [Builder.tax] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tax(tax: JsonField) = apply { this.tax = tax } + + /** The VAT rate of the line item expressed as percentage with 2 decimals */ + fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) + + /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ + fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) + + /** + * Sets [Builder.taxRate] to an arbitrary JSON value. + * + * You should usually call [Builder.taxRate] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } + + /** Unit of Measure Codes from UNECERec20 used in Peppol BIS Billing 3.0. */ + fun unit(unit: UnitOfMeasureCode?) = unit(JsonField.ofNullable(unit)) + + /** Alias for calling [Builder.unit] with `unit.orElse(null)`. */ + fun unit(unit: Optional) = unit(unit.getOrNull()) + + /** + * Sets [Builder.unit] to an arbitrary JSON value. + * + * You should usually call [Builder.unit] with a well-typed [UnitOfMeasureCode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun unit(unit: JsonField) = apply { this.unit = unit } + + /** The unit price of the line item. Must be rounded to maximum 2 decimals */ + fun unitPrice(unitPrice: String?) = unitPrice(JsonField.ofNullable(unitPrice)) + + /** Alias for calling [Builder.unitPrice] with `unitPrice.orElse(null)`. */ + fun unitPrice(unitPrice: Optional) = unitPrice(unitPrice.getOrNull()) + + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Item]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Item = + Item( + (allowances ?: JsonMissing.of()).map { it.toImmutable() }, + amount, + (charges ?: JsonMissing.of()).map { it.toImmutable() }, + date, + description, + productCode, + quantity, + tax, + taxRate, + unit, + unitPrice, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Item = apply { + if (validated) { + return@apply + } + + allowances().ifPresent { it.forEach { it.validate() } } + amount() + charges().ifPresent { it.forEach { it.validate() } } + date() + description() + productCode() + quantity() + tax() + taxRate() + unit().ifPresent { it.validate() } + unitPrice() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (allowances.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (charges.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (date.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (productCode.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (tax.asKnown().isPresent) 1 else 0) + + (if (taxRate.asKnown().isPresent) 1 else 0) + + (unit.asKnown().getOrNull()?.validity() ?: 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) + + /** An allowance is a discount for example for early payment, volume discount, etc. */ + class Allowance + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val baseAmount: JsonField, + private val multiplierFactor: JsonField, + private val reason: JsonField, + private val reasonCode: JsonField, + private val taxCode: JsonField, + private val taxRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("base_amount") + @ExcludeMissing + baseAmount: JsonField = JsonMissing.of(), + @JsonProperty("multiplier_factor") + @ExcludeMissing + multiplierFactor: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + @JsonProperty("reason_code") + @ExcludeMissing + reasonCode: JsonField = JsonMissing.of(), + @JsonProperty("tax_code") + @ExcludeMissing + taxCode: JsonField = JsonMissing.of(), + @JsonProperty("tax_rate") + @ExcludeMissing + taxRate: JsonField = JsonMissing.of(), + ) : this( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + mutableMapOf(), + ) + + /** + * The allowance amount, without VAT. Must be rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * The base amount that may be used, in conjunction with the allowance percentage, to + * calculate the allowance amount. Must be rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun baseAmount(): Optional = baseAmount.getOptional("base_amount") + + /** + * The percentage that may be used, in conjunction with the allowance base amount, to + * calculate the allowance amount. To state 20%, use value 20 + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun multiplierFactor(): Optional = + multiplierFactor.getOptional("multiplier_factor") + + /** + * The reason for the allowance + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun reason(): Optional = reason.getOptional("reason") + + /** + * The code for the allowance reason + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun reasonCode(): Optional = reasonCode.getOptional("reason_code") + + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun taxCode(): Optional = taxCode.getOptional("tax_code") + + /** + * The VAT rate, represented as percentage that applies to the allowance + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun taxRate(): Optional = taxRate.getOptional("tax_rate") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [baseAmount]. + * + * Unlike [baseAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("base_amount") + @ExcludeMissing + fun _baseAmount(): JsonField = baseAmount + + /** + * Returns the raw JSON value of [multiplierFactor]. + * + * Unlike [multiplierFactor], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("multiplier_factor") + @ExcludeMissing + fun _multiplierFactor(): JsonField = multiplierFactor + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + /** + * Returns the raw JSON value of [reasonCode]. + * + * Unlike [reasonCode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reason_code") + @ExcludeMissing + fun _reasonCode(): JsonField = reasonCode + + /** + * Returns the raw JSON value of [taxCode]. + * + * Unlike [taxCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax_code") @ExcludeMissing fun _taxCode(): JsonField = taxCode + + /** + * Returns the raw JSON value of [taxRate]. + * + * Unlike [taxRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Allowance]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Allowance]. */ + class Builder internal constructor() { + + private var amount: JsonField = JsonMissing.of() + private var baseAmount: JsonField = JsonMissing.of() + private var multiplierFactor: JsonField = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var reasonCode: JsonField = JsonMissing.of() + private var taxCode: JsonField = JsonMissing.of() + private var taxRate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(allowance: Allowance) = apply { + amount = allowance.amount + baseAmount = allowance.baseAmount + multiplierFactor = allowance.multiplierFactor + reason = allowance.reason + reasonCode = allowance.reasonCode + taxCode = allowance.taxCode + taxRate = allowance.taxRate + additionalProperties = allowance.additionalProperties.toMutableMap() + } + + /** The allowance amount, without VAT. Must be rounded to maximum 2 decimals */ + fun amount(amount: String?) = amount(JsonField.ofNullable(amount)) + + /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ + fun amount(amount: Optional) = amount(amount.getOrNull()) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** + * The base amount that may be used, in conjunction with the allowance percentage, + * to calculate the allowance amount. Must be rounded to maximum 2 decimals + */ + fun baseAmount(baseAmount: String?) = baseAmount(JsonField.ofNullable(baseAmount)) + + /** Alias for calling [Builder.baseAmount] with `baseAmount.orElse(null)`. */ + fun baseAmount(baseAmount: Optional) = baseAmount(baseAmount.getOrNull()) + + /** + * Sets [Builder.baseAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.baseAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun baseAmount(baseAmount: JsonField) = apply { + this.baseAmount = baseAmount + } + + /** + * The percentage that may be used, in conjunction with the allowance base amount, + * to calculate the allowance amount. To state 20%, use value 20 + */ + fun multiplierFactor(multiplierFactor: String?) = + multiplierFactor(JsonField.ofNullable(multiplierFactor)) + + /** + * Alias for calling [Builder.multiplierFactor] with + * `multiplierFactor.orElse(null)`. + */ + fun multiplierFactor(multiplierFactor: Optional) = + multiplierFactor(multiplierFactor.getOrNull()) + + /** + * Sets [Builder.multiplierFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.multiplierFactor] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun multiplierFactor(multiplierFactor: JsonField) = apply { + this.multiplierFactor = multiplierFactor + } + + /** The reason for the allowance */ + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ + fun reason(reason: Optional) = reason(reason.getOrNull()) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + /** The code for the allowance reason */ + fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) + + /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ + fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) + + /** + * Sets [Builder.reasonCode] to an arbitrary JSON value. + * + * You should usually call [Builder.reasonCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun reasonCode(reasonCode: JsonField) = apply { + this.reasonCode = reasonCode + } + + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + */ + fun taxCode(taxCode: TaxCode?) = taxCode(JsonField.ofNullable(taxCode)) + + /** Alias for calling [Builder.taxCode] with `taxCode.orElse(null)`. */ + fun taxCode(taxCode: Optional) = taxCode(taxCode.getOrNull()) + + /** + * Sets [Builder.taxCode] to an arbitrary JSON value. + * + * You should usually call [Builder.taxCode] with a well-typed [TaxCode] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } + + /** The VAT rate, represented as percentage that applies to the allowance */ + fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) + + /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ + fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) + + /** + * Sets [Builder.taxRate] to an arbitrary JSON value. + * + * You should usually call [Builder.taxRate] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Allowance]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Allowance = + Allowance( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Allowance = apply { + if (validated) { + return@apply + } + + amount() + baseAmount() + multiplierFactor() + reason() + reasonCode() + taxCode().ifPresent { it.validate() } + taxRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (baseAmount.asKnown().isPresent) 1 else 0) + + (if (multiplierFactor.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (if (reasonCode.asKnown().isPresent) 1 else 0) + + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + + (if (taxRate.asKnown().isPresent) 1 else 0) + + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + */ + class TaxCode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val AE = of("AE") + + @JvmField val E = of("E") + + @JvmField val S = of("S") + + @JvmField val Z = of("Z") + + @JvmField val G = of("G") + + @JvmField val O = of("O") + + @JvmField val K = of("K") + + @JvmField val L = of("L") + + @JvmField val M = of("M") + + @JvmField val B = of("B") + + @JvmStatic fun of(value: String) = TaxCode(JsonField.of(value)) + } + + /** An enum containing [TaxCode]'s known values. */ + enum class Known { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + } + + /** + * An enum containing [TaxCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TaxCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + /** + * An enum member indicating that [TaxCode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AE -> Value.AE + E -> Value.E + S -> Value.S + Z -> Value.Z + G -> Value.G + O -> Value.O + K -> Value.K + L -> Value.L + M -> Value.M + B -> Value.B + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + AE -> Known.AE + E -> Known.E + S -> Known.S + Z -> Known.Z + G -> Known.G + O -> Known.O + K -> Known.K + L -> Known.L + M -> Known.M + B -> Known.B + else -> throw EInvoiceInvalidDataException("Unknown TaxCode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TaxCode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TaxCode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Allowance && + amount == other.amount && + baseAmount == other.baseAmount && + multiplierFactor == other.multiplierFactor && + reason == other.reason && + reasonCode == other.reasonCode && + taxCode == other.taxCode && + taxRate == other.taxRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Allowance{amount=$amount, baseAmount=$baseAmount, multiplierFactor=$multiplierFactor, reason=$reason, reasonCode=$reasonCode, taxCode=$taxCode, taxRate=$taxRate, additionalProperties=$additionalProperties}" + } + + /** A charge is an additional fee for example for late payment, late delivery, etc. */ + class Charge + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val baseAmount: JsonField, + private val multiplierFactor: JsonField, + private val reason: JsonField, + private val reasonCode: JsonField, + private val taxCode: JsonField, + private val taxRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("base_amount") + @ExcludeMissing + baseAmount: JsonField = JsonMissing.of(), + @JsonProperty("multiplier_factor") + @ExcludeMissing + multiplierFactor: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + @JsonProperty("reason_code") + @ExcludeMissing + reasonCode: JsonField = JsonMissing.of(), + @JsonProperty("tax_code") + @ExcludeMissing + taxCode: JsonField = JsonMissing.of(), + @JsonProperty("tax_rate") + @ExcludeMissing + taxRate: JsonField = JsonMissing.of(), + ) : this( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + mutableMapOf(), + ) + + /** + * The charge amount, without VAT. Must be rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * The base amount that may be used, in conjunction with the charge percentage, to + * calculate the charge amount. Must be rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun baseAmount(): Optional = baseAmount.getOptional("base_amount") + + /** + * The percentage that may be used, in conjunction with the charge base amount, to + * calculate the charge amount. To state 20%, use value 20 + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun multiplierFactor(): Optional = + multiplierFactor.getOptional("multiplier_factor") + + /** + * The reason for the charge + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun reason(): Optional = reason.getOptional("reason") + + /** + * The code for the charge reason + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun reasonCode(): Optional = reasonCode.getOptional("reason_code") + + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun taxCode(): Optional = taxCode.getOptional("tax_code") + + /** + * The VAT rate, represented as percentage that applies to the charge + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun taxRate(): Optional = taxRate.getOptional("tax_rate") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [baseAmount]. + * + * Unlike [baseAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("base_amount") + @ExcludeMissing + fun _baseAmount(): JsonField = baseAmount + + /** + * Returns the raw JSON value of [multiplierFactor]. + * + * Unlike [multiplierFactor], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("multiplier_factor") + @ExcludeMissing + fun _multiplierFactor(): JsonField = multiplierFactor + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + /** + * Returns the raw JSON value of [reasonCode]. + * + * Unlike [reasonCode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reason_code") + @ExcludeMissing + fun _reasonCode(): JsonField = reasonCode + + /** + * Returns the raw JSON value of [taxCode]. + * + * Unlike [taxCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax_code") @ExcludeMissing fun _taxCode(): JsonField = taxCode + + /** + * Returns the raw JSON value of [taxRate]. + * + * Unlike [taxRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Charge]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Charge]. */ + class Builder internal constructor() { + + private var amount: JsonField = JsonMissing.of() + private var baseAmount: JsonField = JsonMissing.of() + private var multiplierFactor: JsonField = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var reasonCode: JsonField = JsonMissing.of() + private var taxCode: JsonField = JsonMissing.of() + private var taxRate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(charge: Charge) = apply { + amount = charge.amount + baseAmount = charge.baseAmount + multiplierFactor = charge.multiplierFactor + reason = charge.reason + reasonCode = charge.reasonCode + taxCode = charge.taxCode + taxRate = charge.taxRate + additionalProperties = charge.additionalProperties.toMutableMap() + } + + /** The charge amount, without VAT. Must be rounded to maximum 2 decimals */ + fun amount(amount: String?) = amount(JsonField.ofNullable(amount)) + + /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ + fun amount(amount: Optional) = amount(amount.getOrNull()) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** + * The base amount that may be used, in conjunction with the charge percentage, to + * calculate the charge amount. Must be rounded to maximum 2 decimals + */ + fun baseAmount(baseAmount: String?) = baseAmount(JsonField.ofNullable(baseAmount)) + + /** Alias for calling [Builder.baseAmount] with `baseAmount.orElse(null)`. */ + fun baseAmount(baseAmount: Optional) = baseAmount(baseAmount.getOrNull()) + + /** + * Sets [Builder.baseAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.baseAmount] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun baseAmount(baseAmount: JsonField) = apply { + this.baseAmount = baseAmount + } + + /** + * The percentage that may be used, in conjunction with the charge base amount, to + * calculate the charge amount. To state 20%, use value 20 + */ + fun multiplierFactor(multiplierFactor: String?) = + multiplierFactor(JsonField.ofNullable(multiplierFactor)) + + /** + * Alias for calling [Builder.multiplierFactor] with + * `multiplierFactor.orElse(null)`. + */ + fun multiplierFactor(multiplierFactor: Optional) = + multiplierFactor(multiplierFactor.getOrNull()) + + /** + * Sets [Builder.multiplierFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.multiplierFactor] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun multiplierFactor(multiplierFactor: JsonField) = apply { + this.multiplierFactor = multiplierFactor + } + + /** The reason for the charge */ + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ + fun reason(reason: Optional) = reason(reason.getOrNull()) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + /** The code for the charge reason */ + fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) + + /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ + fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) + + /** + * Sets [Builder.reasonCode] to an arbitrary JSON value. + * + * You should usually call [Builder.reasonCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun reasonCode(reasonCode: JsonField) = apply { + this.reasonCode = reasonCode + } + + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + */ + fun taxCode(taxCode: TaxCode?) = taxCode(JsonField.ofNullable(taxCode)) + + /** Alias for calling [Builder.taxCode] with `taxCode.orElse(null)`. */ + fun taxCode(taxCode: Optional) = taxCode(taxCode.getOrNull()) + + /** + * Sets [Builder.taxCode] to an arbitrary JSON value. + * + * You should usually call [Builder.taxCode] with a well-typed [TaxCode] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } + + /** The VAT rate, represented as percentage that applies to the charge */ + fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) + + /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ + fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) + + /** + * Sets [Builder.taxRate] to an arbitrary JSON value. + * + * You should usually call [Builder.taxRate] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Charge]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Charge = + Charge( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Charge = apply { + if (validated) { + return@apply + } + + amount() + baseAmount() + multiplierFactor() + reason() + reasonCode() + taxCode().ifPresent { it.validate() } + taxRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (baseAmount.asKnown().isPresent) 1 else 0) + + (if (multiplierFactor.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (if (reasonCode.asKnown().isPresent) 1 else 0) + + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + + (if (taxRate.asKnown().isPresent) 1 else 0) + + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + */ + class TaxCode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val AE = of("AE") + + @JvmField val E = of("E") + + @JvmField val S = of("S") + + @JvmField val Z = of("Z") + + @JvmField val G = of("G") + + @JvmField val O = of("O") + + @JvmField val K = of("K") + + @JvmField val L = of("L") + + @JvmField val M = of("M") + + @JvmField val B = of("B") + + @JvmStatic fun of(value: String) = TaxCode(JsonField.of(value)) + } + + /** An enum containing [TaxCode]'s known values. */ + enum class Known { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + } + + /** + * An enum containing [TaxCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TaxCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + /** + * An enum member indicating that [TaxCode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AE -> Value.AE + E -> Value.E + S -> Value.S + Z -> Value.Z + G -> Value.G + O -> Value.O + K -> Value.K + L -> Value.L + M -> Value.M + B -> Value.B + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + AE -> Known.AE + E -> Known.E + S -> Known.S + Z -> Known.Z + G -> Known.G + O -> Known.O + K -> Known.K + L -> Known.L + M -> Known.M + B -> Known.B + else -> throw EInvoiceInvalidDataException("Unknown TaxCode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TaxCode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TaxCode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Charge && + amount == other.amount && + baseAmount == other.baseAmount && + multiplierFactor == other.multiplierFactor && + reason == other.reason && + reasonCode == other.reasonCode && + taxCode == other.taxCode && + taxRate == other.taxRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Charge{amount=$amount, baseAmount=$baseAmount, multiplierFactor=$multiplierFactor, reason=$reason, reasonCode=$reasonCode, taxCode=$taxCode, taxRate=$taxRate, additionalProperties=$additionalProperties}" + } override fun equals(other: Any?): Boolean { if (this === other) { @@ -2435,7 +5232,9 @@ private constructor( } return other is Item && + allowances == other.allowances && amount == other.amount && + charges == other.charges && date == other.date && description == other.description && productCode == other.productCode && @@ -2449,7 +5248,9 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( + allowances, amount, + charges, date, description, productCode, @@ -2465,7 +5266,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Item{amount=$amount, date=$date, description=$description, productCode=$productCode, quantity=$quantity, tax=$tax, taxRate=$taxRate, unit=$unit, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" + "Item{allowances=$allowances, amount=$amount, charges=$charges, date=$date, description=$description, productCode=$productCode, quantity=$quantity, tax=$tax, taxRate=$taxRate, unit=$unit, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" } class PaymentDetail @@ -3596,10 +6397,12 @@ private constructor( return other is DocumentResponse && id == other.id && + allowances == other.allowances && amountDue == other.amountDue && attachments == other.attachments && billingAddress == other.billingAddress && billingAddressRecipient == other.billingAddressRecipient && + charges == other.charges && currency == other.currency && customerAddress == other.customerAddress && customerAddressRecipient == other.customerAddressRecipient && @@ -3646,10 +6449,12 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( id, + allowances, amountDue, attachments, billingAddress, billingAddressRecipient, + charges, currency, customerAddress, customerAddressRecipient, @@ -3697,5 +6502,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "DocumentResponse{id=$id, amountDue=$amountDue, attachments=$attachments, billingAddress=$billingAddress, billingAddressRecipient=$billingAddressRecipient, currency=$currency, customerAddress=$customerAddress, customerAddressRecipient=$customerAddressRecipient, customerEmail=$customerEmail, customerId=$customerId, customerName=$customerName, customerTaxId=$customerTaxId, direction=$direction, documentType=$documentType, dueDate=$dueDate, invoiceDate=$invoiceDate, invoiceId=$invoiceId, invoiceTotal=$invoiceTotal, items=$items, note=$note, paymentDetails=$paymentDetails, paymentTerm=$paymentTerm, previousUnpaidBalance=$previousUnpaidBalance, purchaseOrder=$purchaseOrder, remittanceAddress=$remittanceAddress, remittanceAddressRecipient=$remittanceAddressRecipient, serviceAddress=$serviceAddress, serviceAddressRecipient=$serviceAddressRecipient, serviceEndDate=$serviceEndDate, serviceStartDate=$serviceStartDate, shippingAddress=$shippingAddress, shippingAddressRecipient=$shippingAddressRecipient, state=$state, subtotal=$subtotal, taxCode=$taxCode, taxDetails=$taxDetails, totalDiscount=$totalDiscount, totalTax=$totalTax, vatex=$vatex, vatexNote=$vatexNote, vendorAddress=$vendorAddress, vendorAddressRecipient=$vendorAddressRecipient, vendorEmail=$vendorEmail, vendorName=$vendorName, vendorTaxId=$vendorTaxId, additionalProperties=$additionalProperties}" + "DocumentResponse{id=$id, allowances=$allowances, amountDue=$amountDue, attachments=$attachments, billingAddress=$billingAddress, billingAddressRecipient=$billingAddressRecipient, charges=$charges, currency=$currency, customerAddress=$customerAddress, customerAddressRecipient=$customerAddressRecipient, customerEmail=$customerEmail, customerId=$customerId, customerName=$customerName, customerTaxId=$customerTaxId, direction=$direction, documentType=$documentType, dueDate=$dueDate, invoiceDate=$invoiceDate, invoiceId=$invoiceId, invoiceTotal=$invoiceTotal, items=$items, note=$note, paymentDetails=$paymentDetails, paymentTerm=$paymentTerm, previousUnpaidBalance=$previousUnpaidBalance, purchaseOrder=$purchaseOrder, remittanceAddress=$remittanceAddress, remittanceAddressRecipient=$remittanceAddressRecipient, serviceAddress=$serviceAddress, serviceAddressRecipient=$serviceAddressRecipient, serviceEndDate=$serviceEndDate, serviceStartDate=$serviceStartDate, shippingAddress=$shippingAddress, shippingAddressRecipient=$shippingAddressRecipient, state=$state, subtotal=$subtotal, taxCode=$taxCode, taxDetails=$taxDetails, totalDiscount=$totalDiscount, totalTax=$totalTax, vatex=$vatex, vatexNote=$vatexNote, vendorAddress=$vendorAddress, vendorAddressRecipient=$vendorAddressRecipient, vendorEmail=$vendorEmail, vendorName=$vendorName, vendorTaxId=$vendorTaxId, additionalProperties=$additionalProperties}" } diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateParamsTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateParamsTest.kt index bc9823b..72eb3cb 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateParamsTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateParamsTest.kt @@ -14,6 +14,17 @@ internal class DocumentCreateParamsTest { DocumentCreateParams.builder() .documentCreate( DocumentCreate.builder() + .addAllowance( + DocumentCreate.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amountDue(0.0) .addAttachment( DocumentAttachmentCreate.builder() @@ -25,6 +36,17 @@ internal class DocumentCreateParamsTest { ) .billingAddress("billing_address") .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentCreate.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") @@ -40,7 +62,29 @@ internal class DocumentCreateParamsTest { .invoiceTotal(0.0) .addItem( DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") @@ -97,6 +141,17 @@ internal class DocumentCreateParamsTest { DocumentCreateParams.builder() .documentCreate( DocumentCreate.builder() + .addAllowance( + DocumentCreate.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amountDue(0.0) .addAttachment( DocumentAttachmentCreate.builder() @@ -108,6 +163,17 @@ internal class DocumentCreateParamsTest { ) .billingAddress("billing_address") .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentCreate.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") @@ -123,7 +189,29 @@ internal class DocumentCreateParamsTest { .invoiceTotal(0.0) .addItem( DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") @@ -178,6 +266,17 @@ internal class DocumentCreateParamsTest { assertThat(body) .isEqualTo( DocumentCreate.builder() + .addAllowance( + DocumentCreate.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amountDue(0.0) .addAttachment( DocumentAttachmentCreate.builder() @@ -189,6 +288,17 @@ internal class DocumentCreateParamsTest { ) .billingAddress("billing_address") .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentCreate.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") @@ -204,7 +314,29 @@ internal class DocumentCreateParamsTest { .invoiceTotal(0.0) .addItem( DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateTest.kt index 3634e79..2131d8c 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateTest.kt @@ -16,6 +16,17 @@ internal class DocumentCreateTest { fun create() { val documentCreate = DocumentCreate.builder() + .addAllowance( + DocumentCreate.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amountDue(0.0) .addAttachment( DocumentAttachmentCreate.builder() @@ -27,6 +38,17 @@ internal class DocumentCreateTest { ) .billingAddress("billing_address") .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentCreate.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") @@ -42,7 +64,29 @@ internal class DocumentCreateTest { .invoiceTotal(0.0) .addItem( DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") @@ -88,6 +132,18 @@ internal class DocumentCreateTest { .vendorTaxId("vendor_tax_id") .build() + assertThat(documentCreate.allowances().getOrNull()) + .containsExactly( + DocumentCreate.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) assertThat(documentCreate.amountDue()).contains(DocumentCreate.AmountDue.ofNumber(0.0)) assertThat(documentCreate.attachments().getOrNull()) .containsExactly( @@ -100,6 +156,18 @@ internal class DocumentCreateTest { ) assertThat(documentCreate.billingAddress()).contains("billing_address") assertThat(documentCreate.billingAddressRecipient()).contains("billing_address_recipient") + assertThat(documentCreate.charges().getOrNull()) + .containsExactly( + DocumentCreate.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) assertThat(documentCreate.currency()).contains(CurrencyCode.EUR) assertThat(documentCreate.customerAddress()).contains("customer_address") assertThat(documentCreate.customerAddressRecipient()).contains("customer_address_recipient") @@ -117,7 +185,29 @@ internal class DocumentCreateTest { assertThat(documentCreate.items().getOrNull()) .containsExactly( DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") @@ -173,6 +263,17 @@ internal class DocumentCreateTest { val jsonMapper = jsonMapper() val documentCreate = DocumentCreate.builder() + .addAllowance( + DocumentCreate.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amountDue(0.0) .addAttachment( DocumentAttachmentCreate.builder() @@ -184,6 +285,17 @@ internal class DocumentCreateTest { ) .billingAddress("billing_address") .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentCreate.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") @@ -199,7 +311,29 @@ internal class DocumentCreateTest { .invoiceTotal(0.0) .addItem( DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentResponseTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentResponseTest.kt index 868ed71..40c1b42 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentResponseTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentResponseTest.kt @@ -18,6 +18,17 @@ internal class DocumentResponseTest { val documentResponse = DocumentResponse.builder() .id("id") + .addAllowance( + DocumentResponse.Allowance.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentResponse.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amountDue("amount_due") .addAttachment( DocumentAttachment.builder() @@ -30,6 +41,17 @@ internal class DocumentResponseTest { ) .billingAddress("billing_address") .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentResponse.Charge.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentResponse.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") @@ -45,7 +67,29 @@ internal class DocumentResponseTest { .invoiceTotal("invoice_total") .addItem( DocumentResponse.Item.builder() + .addAllowance( + DocumentResponse.Item.Allowance.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentResponse.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount("amount") + .addCharge( + DocumentResponse.Item.Charge.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentResponse.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") @@ -94,6 +138,18 @@ internal class DocumentResponseTest { .build() assertThat(documentResponse.id()).isEqualTo("id") + assertThat(documentResponse.allowances().getOrNull()) + .containsExactly( + DocumentResponse.Allowance.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentResponse.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) assertThat(documentResponse.amountDue()).contains("amount_due") assertThat(documentResponse.attachments().getOrNull()) .containsExactly( @@ -107,6 +163,18 @@ internal class DocumentResponseTest { ) assertThat(documentResponse.billingAddress()).contains("billing_address") assertThat(documentResponse.billingAddressRecipient()).contains("billing_address_recipient") + assertThat(documentResponse.charges().getOrNull()) + .containsExactly( + DocumentResponse.Charge.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentResponse.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) assertThat(documentResponse.currency()).contains(CurrencyCode.EUR) assertThat(documentResponse.customerAddress()).contains("customer_address") assertThat(documentResponse.customerAddressRecipient()) @@ -124,7 +192,29 @@ internal class DocumentResponseTest { assertThat(documentResponse.items().getOrNull()) .containsExactly( DocumentResponse.Item.builder() + .addAllowance( + DocumentResponse.Item.Allowance.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentResponse.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount("amount") + .addCharge( + DocumentResponse.Item.Charge.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentResponse.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") @@ -182,6 +272,17 @@ internal class DocumentResponseTest { val documentResponse = DocumentResponse.builder() .id("id") + .addAllowance( + DocumentResponse.Allowance.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentResponse.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amountDue("amount_due") .addAttachment( DocumentAttachment.builder() @@ -194,6 +295,17 @@ internal class DocumentResponseTest { ) .billingAddress("billing_address") .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentResponse.Charge.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentResponse.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") @@ -209,7 +321,29 @@ internal class DocumentResponseTest { .invoiceTotal("invoice_total") .addItem( DocumentResponse.Item.builder() + .addAllowance( + DocumentResponse.Item.Allowance.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentResponse.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount("amount") + .addCharge( + DocumentResponse.Item.Charge.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentResponse.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt index 464c599..98ee424 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt @@ -23,6 +23,17 @@ internal class PaginatedDocumentResponseTest { .addItem( DocumentResponse.builder() .id("id") + .addAllowance( + DocumentResponse.Allowance.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentResponse.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amountDue("amount_due") .addAttachment( DocumentAttachment.builder() @@ -35,6 +46,17 @@ internal class PaginatedDocumentResponseTest { ) .billingAddress("billing_address") .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentResponse.Charge.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentResponse.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") @@ -50,7 +72,29 @@ internal class PaginatedDocumentResponseTest { .invoiceTotal("invoice_total") .addItem( DocumentResponse.Item.builder() + .addAllowance( + DocumentResponse.Item.Allowance.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentResponse.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount("amount") + .addCharge( + DocumentResponse.Item.Charge.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentResponse.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") @@ -111,6 +155,17 @@ internal class PaginatedDocumentResponseTest { .containsExactly( DocumentResponse.builder() .id("id") + .addAllowance( + DocumentResponse.Allowance.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentResponse.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amountDue("amount_due") .addAttachment( DocumentAttachment.builder() @@ -123,6 +178,17 @@ internal class PaginatedDocumentResponseTest { ) .billingAddress("billing_address") .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentResponse.Charge.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentResponse.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") @@ -138,7 +204,29 @@ internal class PaginatedDocumentResponseTest { .invoiceTotal("invoice_total") .addItem( DocumentResponse.Item.builder() + .addAllowance( + DocumentResponse.Item.Allowance.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentResponse.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount("amount") + .addCharge( + DocumentResponse.Item.Charge.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentResponse.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") @@ -200,6 +288,17 @@ internal class PaginatedDocumentResponseTest { .addItem( DocumentResponse.builder() .id("id") + .addAllowance( + DocumentResponse.Allowance.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentResponse.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amountDue("amount_due") .addAttachment( DocumentAttachment.builder() @@ -212,6 +311,17 @@ internal class PaginatedDocumentResponseTest { ) .billingAddress("billing_address") .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentResponse.Charge.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentResponse.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") @@ -227,7 +337,29 @@ internal class PaginatedDocumentResponseTest { .invoiceTotal("invoice_total") .addItem( DocumentResponse.Item.builder() + .addAllowance( + DocumentResponse.Item.Allowance.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentResponse.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount("amount") + .addCharge( + DocumentResponse.Item.Charge.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentResponse.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/validate/ValidateValidateJsonParamsTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/validate/ValidateValidateJsonParamsTest.kt index b5e1f9f..dfbad13 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/validate/ValidateValidateJsonParamsTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/validate/ValidateValidateJsonParamsTest.kt @@ -21,6 +21,17 @@ internal class ValidateValidateJsonParamsTest { ValidateValidateJsonParams.builder() .documentCreate( DocumentCreate.builder() + .addAllowance( + DocumentCreate.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amountDue(0.0) .addAttachment( DocumentAttachmentCreate.builder() @@ -32,6 +43,17 @@ internal class ValidateValidateJsonParamsTest { ) .billingAddress("billing_address") .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentCreate.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") @@ -47,7 +69,29 @@ internal class ValidateValidateJsonParamsTest { .invoiceTotal(0.0) .addItem( DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") @@ -104,6 +148,17 @@ internal class ValidateValidateJsonParamsTest { ValidateValidateJsonParams.builder() .documentCreate( DocumentCreate.builder() + .addAllowance( + DocumentCreate.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amountDue(0.0) .addAttachment( DocumentAttachmentCreate.builder() @@ -115,6 +170,17 @@ internal class ValidateValidateJsonParamsTest { ) .billingAddress("billing_address") .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentCreate.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") @@ -130,7 +196,29 @@ internal class ValidateValidateJsonParamsTest { .invoiceTotal(0.0) .addItem( DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") @@ -185,6 +273,17 @@ internal class ValidateValidateJsonParamsTest { assertThat(body) .isEqualTo( DocumentCreate.builder() + .addAllowance( + DocumentCreate.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amountDue(0.0) .addAttachment( DocumentAttachmentCreate.builder() @@ -196,6 +295,17 @@ internal class ValidateValidateJsonParamsTest { ) .billingAddress("billing_address") .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentCreate.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") @@ -211,7 +321,29 @@ internal class ValidateValidateJsonParamsTest { .invoiceTotal(0.0) .addItem( DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ErrorHandlingTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ErrorHandlingTest.kt index f0358f1..3864f1f 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ErrorHandlingTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ErrorHandlingTest.kt @@ -80,6 +80,17 @@ internal class ErrorHandlingTest { assertThrows { documentService.create( DocumentCreate.builder() + .addAllowance( + DocumentCreate.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amountDue(0.0) .addAttachment( DocumentAttachmentCreate.builder() @@ -91,6 +102,17 @@ internal class ErrorHandlingTest { ) .billingAddress("billing_address") .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentCreate.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") @@ -106,7 +128,29 @@ internal class ErrorHandlingTest { .invoiceTotal(0.0) .addItem( DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") @@ -175,6 +219,17 @@ internal class ErrorHandlingTest { assertThrows { documentService.create( DocumentCreate.builder() + .addAllowance( + DocumentCreate.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amountDue(0.0) .addAttachment( DocumentAttachmentCreate.builder() @@ -186,6 +241,17 @@ internal class ErrorHandlingTest { ) .billingAddress("billing_address") .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentCreate.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") @@ -201,7 +267,29 @@ internal class ErrorHandlingTest { .invoiceTotal(0.0) .addItem( DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") @@ -270,6 +358,17 @@ internal class ErrorHandlingTest { assertThrows { documentService.create( DocumentCreate.builder() + .addAllowance( + DocumentCreate.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amountDue(0.0) .addAttachment( DocumentAttachmentCreate.builder() @@ -281,6 +380,17 @@ internal class ErrorHandlingTest { ) .billingAddress("billing_address") .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentCreate.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") @@ -296,7 +406,29 @@ internal class ErrorHandlingTest { .invoiceTotal(0.0) .addItem( DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") @@ -365,6 +497,17 @@ internal class ErrorHandlingTest { assertThrows { documentService.create( DocumentCreate.builder() + .addAllowance( + DocumentCreate.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amountDue(0.0) .addAttachment( DocumentAttachmentCreate.builder() @@ -376,6 +519,17 @@ internal class ErrorHandlingTest { ) .billingAddress("billing_address") .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentCreate.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") @@ -391,7 +545,29 @@ internal class ErrorHandlingTest { .invoiceTotal(0.0) .addItem( DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") @@ -460,6 +636,17 @@ internal class ErrorHandlingTest { assertThrows { documentService.create( DocumentCreate.builder() + .addAllowance( + DocumentCreate.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amountDue(0.0) .addAttachment( DocumentAttachmentCreate.builder() @@ -471,6 +658,17 @@ internal class ErrorHandlingTest { ) .billingAddress("billing_address") .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentCreate.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") @@ -486,7 +684,29 @@ internal class ErrorHandlingTest { .invoiceTotal(0.0) .addItem( DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") @@ -555,6 +775,17 @@ internal class ErrorHandlingTest { assertThrows { documentService.create( DocumentCreate.builder() + .addAllowance( + DocumentCreate.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amountDue(0.0) .addAttachment( DocumentAttachmentCreate.builder() @@ -566,6 +797,17 @@ internal class ErrorHandlingTest { ) .billingAddress("billing_address") .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentCreate.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") @@ -581,7 +823,29 @@ internal class ErrorHandlingTest { .invoiceTotal(0.0) .addItem( DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") @@ -650,6 +914,17 @@ internal class ErrorHandlingTest { assertThrows { documentService.create( DocumentCreate.builder() + .addAllowance( + DocumentCreate.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amountDue(0.0) .addAttachment( DocumentAttachmentCreate.builder() @@ -661,6 +936,17 @@ internal class ErrorHandlingTest { ) .billingAddress("billing_address") .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentCreate.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") @@ -676,7 +962,29 @@ internal class ErrorHandlingTest { .invoiceTotal(0.0) .addItem( DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") @@ -745,6 +1053,17 @@ internal class ErrorHandlingTest { assertThrows { documentService.create( DocumentCreate.builder() + .addAllowance( + DocumentCreate.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amountDue(0.0) .addAttachment( DocumentAttachmentCreate.builder() @@ -756,6 +1075,17 @@ internal class ErrorHandlingTest { ) .billingAddress("billing_address") .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentCreate.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") @@ -771,7 +1101,29 @@ internal class ErrorHandlingTest { .invoiceTotal(0.0) .addItem( DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") @@ -840,6 +1192,17 @@ internal class ErrorHandlingTest { assertThrows { documentService.create( DocumentCreate.builder() + .addAllowance( + DocumentCreate.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amountDue(0.0) .addAttachment( DocumentAttachmentCreate.builder() @@ -851,6 +1214,17 @@ internal class ErrorHandlingTest { ) .billingAddress("billing_address") .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentCreate.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") @@ -866,7 +1240,29 @@ internal class ErrorHandlingTest { .invoiceTotal(0.0) .addItem( DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") @@ -935,6 +1331,17 @@ internal class ErrorHandlingTest { assertThrows { documentService.create( DocumentCreate.builder() + .addAllowance( + DocumentCreate.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amountDue(0.0) .addAttachment( DocumentAttachmentCreate.builder() @@ -946,6 +1353,17 @@ internal class ErrorHandlingTest { ) .billingAddress("billing_address") .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentCreate.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") @@ -961,7 +1379,29 @@ internal class ErrorHandlingTest { .invoiceTotal(0.0) .addItem( DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") @@ -1030,6 +1470,17 @@ internal class ErrorHandlingTest { assertThrows { documentService.create( DocumentCreate.builder() + .addAllowance( + DocumentCreate.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amountDue(0.0) .addAttachment( DocumentAttachmentCreate.builder() @@ -1041,6 +1492,17 @@ internal class ErrorHandlingTest { ) .billingAddress("billing_address") .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentCreate.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") @@ -1056,7 +1518,29 @@ internal class ErrorHandlingTest { .invoiceTotal(0.0) .addItem( DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") @@ -1125,6 +1609,17 @@ internal class ErrorHandlingTest { assertThrows { documentService.create( DocumentCreate.builder() + .addAllowance( + DocumentCreate.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amountDue(0.0) .addAttachment( DocumentAttachmentCreate.builder() @@ -1136,6 +1631,17 @@ internal class ErrorHandlingTest { ) .billingAddress("billing_address") .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentCreate.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") @@ -1151,7 +1657,29 @@ internal class ErrorHandlingTest { .invoiceTotal(0.0) .addItem( DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") @@ -1220,6 +1748,17 @@ internal class ErrorHandlingTest { assertThrows { documentService.create( DocumentCreate.builder() + .addAllowance( + DocumentCreate.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amountDue(0.0) .addAttachment( DocumentAttachmentCreate.builder() @@ -1231,6 +1770,17 @@ internal class ErrorHandlingTest { ) .billingAddress("billing_address") .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentCreate.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") @@ -1246,7 +1796,29 @@ internal class ErrorHandlingTest { .invoiceTotal(0.0) .addItem( DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") @@ -1315,6 +1887,17 @@ internal class ErrorHandlingTest { assertThrows { documentService.create( DocumentCreate.builder() + .addAllowance( + DocumentCreate.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amountDue(0.0) .addAttachment( DocumentAttachmentCreate.builder() @@ -1326,6 +1909,17 @@ internal class ErrorHandlingTest { ) .billingAddress("billing_address") .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentCreate.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") @@ -1341,7 +1935,29 @@ internal class ErrorHandlingTest { .invoiceTotal(0.0) .addItem( DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") @@ -1410,6 +2026,17 @@ internal class ErrorHandlingTest { assertThrows { documentService.create( DocumentCreate.builder() + .addAllowance( + DocumentCreate.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amountDue(0.0) .addAttachment( DocumentAttachmentCreate.builder() @@ -1421,6 +2048,17 @@ internal class ErrorHandlingTest { ) .billingAddress("billing_address") .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentCreate.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") @@ -1436,7 +2074,29 @@ internal class ErrorHandlingTest { .invoiceTotal(0.0) .addItem( DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") @@ -1505,6 +2165,17 @@ internal class ErrorHandlingTest { assertThrows { documentService.create( DocumentCreate.builder() + .addAllowance( + DocumentCreate.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amountDue(0.0) .addAttachment( DocumentAttachmentCreate.builder() @@ -1516,6 +2187,17 @@ internal class ErrorHandlingTest { ) .billingAddress("billing_address") .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentCreate.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") @@ -1531,7 +2213,29 @@ internal class ErrorHandlingTest { .invoiceTotal(0.0) .addItem( DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") @@ -1598,6 +2302,17 @@ internal class ErrorHandlingTest { assertThrows { documentService.create( DocumentCreate.builder() + .addAllowance( + DocumentCreate.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amountDue(0.0) .addAttachment( DocumentAttachmentCreate.builder() @@ -1609,6 +2324,17 @@ internal class ErrorHandlingTest { ) .billingAddress("billing_address") .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentCreate.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") @@ -1624,7 +2350,29 @@ internal class ErrorHandlingTest { .invoiceTotal(0.0) .addItem( DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ServiceParamsTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ServiceParamsTest.kt index e8b1cd5..961b110 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ServiceParamsTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ServiceParamsTest.kt @@ -50,6 +50,17 @@ internal class ServiceParamsTest { documentService.create( DocumentCreate.builder() + .addAllowance( + DocumentCreate.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amountDue(0.0) .addAttachment( DocumentAttachmentCreate.builder() @@ -61,6 +72,17 @@ internal class ServiceParamsTest { ) .billingAddress("billing_address") .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentCreate.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") @@ -76,7 +98,29 @@ internal class ServiceParamsTest { .invoiceTotal(0.0) .addItem( DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncTest.kt index d80b572..922dcf7 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncTest.kt @@ -34,6 +34,17 @@ internal class DocumentServiceAsyncTest { val documentResponseFuture = documentServiceAsync.create( DocumentCreate.builder() + .addAllowance( + DocumentCreate.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amountDue(0.0) .addAttachment( DocumentAttachmentCreate.builder() @@ -45,6 +56,17 @@ internal class DocumentServiceAsyncTest { ) .billingAddress("billing_address") .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentCreate.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") @@ -60,7 +82,29 @@ internal class DocumentServiceAsyncTest { .invoiceTotal(0.0) .addItem( DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/ValidateServiceAsyncTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/ValidateServiceAsyncTest.kt index 3cd4c41..921db18 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/ValidateServiceAsyncTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/ValidateServiceAsyncTest.kt @@ -35,6 +35,17 @@ internal class ValidateServiceAsyncTest { val ublDocumentValidationFuture = validateServiceAsync.validateJson( DocumentCreate.builder() + .addAllowance( + DocumentCreate.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amountDue(0.0) .addAttachment( DocumentAttachmentCreate.builder() @@ -46,6 +57,17 @@ internal class ValidateServiceAsyncTest { ) .billingAddress("billing_address") .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentCreate.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") @@ -61,7 +83,29 @@ internal class ValidateServiceAsyncTest { .invoiceTotal(0.0) .addItem( DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/DocumentServiceTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/DocumentServiceTest.kt index bd40335..28da298 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/DocumentServiceTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/DocumentServiceTest.kt @@ -34,6 +34,17 @@ internal class DocumentServiceTest { val documentResponse = documentService.create( DocumentCreate.builder() + .addAllowance( + DocumentCreate.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amountDue(0.0) .addAttachment( DocumentAttachmentCreate.builder() @@ -45,6 +56,17 @@ internal class DocumentServiceTest { ) .billingAddress("billing_address") .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentCreate.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") @@ -60,7 +82,29 @@ internal class DocumentServiceTest { .invoiceTotal(0.0) .addItem( DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/ValidateServiceTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/ValidateServiceTest.kt index 6942489..1ef161a 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/ValidateServiceTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/ValidateServiceTest.kt @@ -35,6 +35,17 @@ internal class ValidateServiceTest { val ublDocumentValidation = validateService.validateJson( DocumentCreate.builder() + .addAllowance( + DocumentCreate.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amountDue(0.0) .addAttachment( DocumentAttachmentCreate.builder() @@ -46,6 +57,17 @@ internal class ValidateServiceTest { ) .billingAddress("billing_address") .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentCreate.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") @@ -61,7 +83,29 @@ internal class ValidateServiceTest { .invoiceTotal(0.0) .addItem( DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode("reason_code") + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) .date(null) .description("description") .productCode("product_code") From 4f7dc90de5d979ea18f9650a25a4b747e28ce5af Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 8 Oct 2025 19:33:38 +0000 Subject: [PATCH 03/43] feat(api): manual updates --- .stats.yml | 4 +- README.md | 36 +- .../e_invoice/api/client/EInvoiceClient.kt | 5 + .../api/client/EInvoiceClientAsync.kt | 5 + .../api/client/EInvoiceClientAsyncImpl.kt | 12 + .../api/client/EInvoiceClientImpl.kt | 12 + .../api/models/documents/Allowance.kt | 619 +++ .../e_invoice/api/models/documents/Charge.kt | 619 +++ .../documents/DocumentCreateFromPdfParams.kt | 455 ++ .../DocumentCreateFromPdfResponse.kt | 3762 +++++++++++++++++ .../api/models/documents/DocumentResponse.kt | 1270 ------ .../documents/DocumentValidateParams.kt | 230 + .../documents/ubl/UblCreateFromUblParams.kt | 415 ++ .../api/models/me/MeRetrieveParams.kt | 170 + .../api/models/me/MeRetrieveResponse.kt | 1028 +++++ .../services/async/DocumentServiceAsync.kt | 115 + .../async/DocumentServiceAsyncImpl.kt | 84 + .../api/services/async/MeServiceAsync.kt | 80 + .../api/services/async/MeServiceAsyncImpl.kt | 84 + .../async/documents/UblServiceAsync.kt | 27 + .../async/documents/UblServiceAsyncImpl.kt | 41 + .../api/services/blocking/DocumentService.kt | 113 + .../services/blocking/DocumentServiceImpl.kt | 78 + .../api/services/blocking/MeService.kt | 79 + .../api/services/blocking/MeServiceImpl.kt | 79 + .../services/blocking/documents/UblService.kt | 27 + .../blocking/documents/UblServiceImpl.kt | 38 + .../api/models/documents/AllowanceTest.kt | 56 + .../api/models/documents/ChargeTest.kt | 53 + .../DocumentCreateFromPdfParamsTest.kt | 101 + .../DocumentCreateFromPdfResponseTest.kt | 420 ++ .../models/documents/DocumentResponseTest.kt | 24 +- .../documents/DocumentValidateParamsTest.kt | 23 + .../ubl/UblCreateFromUblParamsTest.kt | 38 + .../inbox/PaginatedDocumentResponseTest.kt | 26 +- .../api/models/me/MeRetrieveParamsTest.kt | 13 + .../api/models/me/MeRetrieveResponseTest.kt | 86 + .../async/DocumentServiceAsyncTest.kt | 40 + .../api/services/async/MeServiceAsyncTest.kt | 29 + .../async/documents/UblServiceAsyncTest.kt | 20 + .../services/blocking/DocumentServiceTest.kt | 38 + .../api/services/blocking/MeServiceTest.kt | 28 + .../blocking/documents/UblServiceTest.kt | 19 + .../api/proguard/ProGuardCompatibilityTest.kt | 28 +- 44 files changed, 9201 insertions(+), 1328 deletions(-) create mode 100644 e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Allowance.kt create mode 100644 e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Charge.kt create mode 100644 e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfParams.kt create mode 100644 e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponse.kt create mode 100644 e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentValidateParams.kt create mode 100644 e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/ubl/UblCreateFromUblParams.kt create mode 100644 e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/me/MeRetrieveParams.kt create mode 100644 e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/me/MeRetrieveResponse.kt create mode 100644 e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/MeServiceAsync.kt create mode 100644 e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/MeServiceAsyncImpl.kt create mode 100644 e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/MeService.kt create mode 100644 e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/MeServiceImpl.kt create mode 100644 e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/AllowanceTest.kt create mode 100644 e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/ChargeTest.kt create mode 100644 e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfParamsTest.kt create mode 100644 e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponseTest.kt create mode 100644 e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentValidateParamsTest.kt create mode 100644 e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/ubl/UblCreateFromUblParamsTest.kt create mode 100644 e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/me/MeRetrieveParamsTest.kt create mode 100644 e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/me/MeRetrieveResponseTest.kt create mode 100644 e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/MeServiceAsyncTest.kt create mode 100644 e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/MeServiceTest.kt diff --git a/.stats.yml b/.stats.yml index 9c43dc7..8760fae 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 24 +configured_endpoints: 28 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-8edeb779b7c54508db755723beba2b378c3bf6566b460c25ccbae3341f00d675.yml openapi_spec_hash: 4090ba8c97e2ceb86ce1c7ff994601af -config_hash: d627f345d2cab6590eeea9820301272e +config_hash: 852a0117abb3db077933876ad1185f41 diff --git a/README.md b/README.md index af73d52..e974c26 100644 --- a/README.md +++ b/README.md @@ -185,61 +185,57 @@ The SDK defines methods that accept files. To upload a file, pass a [`Path`](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html): ```java -import com.e_invoice.api.models.documents.attachments.AttachmentAddParams; -import com.e_invoice.api.models.documents.attachments.DocumentAttachment; +import com.e_invoice.api.models.documents.DocumentCreateFromPdfParams; +import com.e_invoice.api.models.documents.DocumentCreateFromPdfResponse; import java.nio.file.Paths; -AttachmentAddParams params = AttachmentAddParams.builder() - .documentId("document_id") +DocumentCreateFromPdfParams params = DocumentCreateFromPdfParams.builder() .file(Paths.get("/path/to/file")) .build(); -DocumentAttachment documentAttachment = client.documents().attachments().add(params); +DocumentCreateFromPdfResponse response = client.documents().createFromPdf(params); ``` Or an arbitrary [`InputStream`](https://docs.oracle.com/javase/8/docs/api/java/io/InputStream.html): ```java -import com.e_invoice.api.models.documents.attachments.AttachmentAddParams; -import com.e_invoice.api.models.documents.attachments.DocumentAttachment; +import com.e_invoice.api.models.documents.DocumentCreateFromPdfParams; +import com.e_invoice.api.models.documents.DocumentCreateFromPdfResponse; import java.net.URL; -AttachmentAddParams params = AttachmentAddParams.builder() - .documentId("document_id") +DocumentCreateFromPdfParams params = DocumentCreateFromPdfParams.builder() .file(new URL("https://example.com//path/to/file").openStream()) .build(); -DocumentAttachment documentAttachment = client.documents().attachments().add(params); +DocumentCreateFromPdfResponse response = client.documents().createFromPdf(params); ``` Or a `byte[]` array: ```java -import com.e_invoice.api.models.documents.attachments.AttachmentAddParams; -import com.e_invoice.api.models.documents.attachments.DocumentAttachment; +import com.e_invoice.api.models.documents.DocumentCreateFromPdfParams; +import com.e_invoice.api.models.documents.DocumentCreateFromPdfResponse; -AttachmentAddParams params = AttachmentAddParams.builder() - .documentId("document_id") +DocumentCreateFromPdfParams params = DocumentCreateFromPdfParams.builder() .file("content".getBytes()) .build(); -DocumentAttachment documentAttachment = client.documents().attachments().add(params); +DocumentCreateFromPdfResponse response = client.documents().createFromPdf(params); ``` Note that when passing a non-`Path` its filename is unknown so it will not be included in the request. To manually set a filename, pass a [`MultipartField`](e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/Values.kt): ```java import com.e_invoice.api.core.MultipartField; -import com.e_invoice.api.models.documents.attachments.AttachmentAddParams; -import com.e_invoice.api.models.documents.attachments.DocumentAttachment; +import com.e_invoice.api.models.documents.DocumentCreateFromPdfParams; +import com.e_invoice.api.models.documents.DocumentCreateFromPdfResponse; import java.io.InputStream; import java.net.URL; -AttachmentAddParams params = AttachmentAddParams.builder() - .documentId("document_id") +DocumentCreateFromPdfParams params = DocumentCreateFromPdfParams.builder() .file(MultipartField.builder() .value(new URL("https://example.com//path/to/file").openStream()) .filename("/path/to/file") .build()) .build(); -DocumentAttachment documentAttachment = client.documents().attachments().add(params); +DocumentCreateFromPdfResponse response = client.documents().createFromPdf(params); ``` ## Raw responses diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/client/EInvoiceClient.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/client/EInvoiceClient.kt index bdb63cf..a542ec7 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/client/EInvoiceClient.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/client/EInvoiceClient.kt @@ -6,6 +6,7 @@ import com.e_invoice.api.core.ClientOptions import com.e_invoice.api.services.blocking.DocumentService import com.e_invoice.api.services.blocking.InboxService import com.e_invoice.api.services.blocking.LookupService +import com.e_invoice.api.services.blocking.MeService import com.e_invoice.api.services.blocking.OutboxService import com.e_invoice.api.services.blocking.ValidateService import com.e_invoice.api.services.blocking.WebhookService @@ -57,6 +58,8 @@ interface EInvoiceClient { fun lookup(): LookupService + fun me(): MeService + fun webhooks(): WebhookService /** @@ -92,6 +95,8 @@ interface EInvoiceClient { fun lookup(): LookupService.WithRawResponse + fun me(): MeService.WithRawResponse + fun webhooks(): WebhookService.WithRawResponse } } diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/client/EInvoiceClientAsync.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/client/EInvoiceClientAsync.kt index 41b20ab..5fed5d0 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/client/EInvoiceClientAsync.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/client/EInvoiceClientAsync.kt @@ -6,6 +6,7 @@ import com.e_invoice.api.core.ClientOptions import com.e_invoice.api.services.async.DocumentServiceAsync import com.e_invoice.api.services.async.InboxServiceAsync import com.e_invoice.api.services.async.LookupServiceAsync +import com.e_invoice.api.services.async.MeServiceAsync import com.e_invoice.api.services.async.OutboxServiceAsync import com.e_invoice.api.services.async.ValidateServiceAsync import com.e_invoice.api.services.async.WebhookServiceAsync @@ -57,6 +58,8 @@ interface EInvoiceClientAsync { fun lookup(): LookupServiceAsync + fun me(): MeServiceAsync + fun webhooks(): WebhookServiceAsync /** @@ -96,6 +99,8 @@ interface EInvoiceClientAsync { fun lookup(): LookupServiceAsync.WithRawResponse + fun me(): MeServiceAsync.WithRawResponse + fun webhooks(): WebhookServiceAsync.WithRawResponse } } diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/client/EInvoiceClientAsyncImpl.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/client/EInvoiceClientAsyncImpl.kt index 68f8a26..4c1c28a 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/client/EInvoiceClientAsyncImpl.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/client/EInvoiceClientAsyncImpl.kt @@ -10,6 +10,8 @@ import com.e_invoice.api.services.async.InboxServiceAsync import com.e_invoice.api.services.async.InboxServiceAsyncImpl import com.e_invoice.api.services.async.LookupServiceAsync import com.e_invoice.api.services.async.LookupServiceAsyncImpl +import com.e_invoice.api.services.async.MeServiceAsync +import com.e_invoice.api.services.async.MeServiceAsyncImpl import com.e_invoice.api.services.async.OutboxServiceAsync import com.e_invoice.api.services.async.OutboxServiceAsyncImpl import com.e_invoice.api.services.async.ValidateServiceAsync @@ -55,6 +57,8 @@ class EInvoiceClientAsyncImpl(private val clientOptions: ClientOptions) : EInvoi LookupServiceAsyncImpl(clientOptionsWithUserAgent) } + private val me: MeServiceAsync by lazy { MeServiceAsyncImpl(clientOptionsWithUserAgent) } + private val webhooks: WebhookServiceAsync by lazy { WebhookServiceAsyncImpl(clientOptionsWithUserAgent) } @@ -76,6 +80,8 @@ class EInvoiceClientAsyncImpl(private val clientOptions: ClientOptions) : EInvoi override fun lookup(): LookupServiceAsync = lookup + override fun me(): MeServiceAsync = me + override fun webhooks(): WebhookServiceAsync = webhooks override fun close() = clientOptions.close() @@ -103,6 +109,10 @@ class EInvoiceClientAsyncImpl(private val clientOptions: ClientOptions) : EInvoi LookupServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val me: MeServiceAsync.WithRawResponse by lazy { + MeServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + private val webhooks: WebhookServiceAsync.WithRawResponse by lazy { WebhookServiceAsyncImpl.WithRawResponseImpl(clientOptions) } @@ -124,6 +134,8 @@ class EInvoiceClientAsyncImpl(private val clientOptions: ClientOptions) : EInvoi override fun lookup(): LookupServiceAsync.WithRawResponse = lookup + override fun me(): MeServiceAsync.WithRawResponse = me + override fun webhooks(): WebhookServiceAsync.WithRawResponse = webhooks } } diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/client/EInvoiceClientImpl.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/client/EInvoiceClientImpl.kt index ecf0dc0..ff71e20 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/client/EInvoiceClientImpl.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/client/EInvoiceClientImpl.kt @@ -10,6 +10,8 @@ import com.e_invoice.api.services.blocking.InboxService import com.e_invoice.api.services.blocking.InboxServiceImpl import com.e_invoice.api.services.blocking.LookupService import com.e_invoice.api.services.blocking.LookupServiceImpl +import com.e_invoice.api.services.blocking.MeService +import com.e_invoice.api.services.blocking.MeServiceImpl import com.e_invoice.api.services.blocking.OutboxService import com.e_invoice.api.services.blocking.OutboxServiceImpl import com.e_invoice.api.services.blocking.ValidateService @@ -49,6 +51,8 @@ class EInvoiceClientImpl(private val clientOptions: ClientOptions) : EInvoiceCli private val lookup: LookupService by lazy { LookupServiceImpl(clientOptionsWithUserAgent) } + private val me: MeService by lazy { MeServiceImpl(clientOptionsWithUserAgent) } + private val webhooks: WebhookService by lazy { WebhookServiceImpl(clientOptionsWithUserAgent) } override fun async(): EInvoiceClientAsync = async @@ -68,6 +72,8 @@ class EInvoiceClientImpl(private val clientOptions: ClientOptions) : EInvoiceCli override fun lookup(): LookupService = lookup + override fun me(): MeService = me + override fun webhooks(): WebhookService = webhooks override fun close() = clientOptions.close() @@ -95,6 +101,10 @@ class EInvoiceClientImpl(private val clientOptions: ClientOptions) : EInvoiceCli LookupServiceImpl.WithRawResponseImpl(clientOptions) } + private val me: MeService.WithRawResponse by lazy { + MeServiceImpl.WithRawResponseImpl(clientOptions) + } + private val webhooks: WebhookService.WithRawResponse by lazy { WebhookServiceImpl.WithRawResponseImpl(clientOptions) } @@ -116,6 +126,8 @@ class EInvoiceClientImpl(private val clientOptions: ClientOptions) : EInvoiceCli override fun lookup(): LookupService.WithRawResponse = lookup + override fun me(): MeService.WithRawResponse = me + override fun webhooks(): WebhookService.WithRawResponse = webhooks } } diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Allowance.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Allowance.kt new file mode 100644 index 0000000..75ac28d --- /dev/null +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Allowance.kt @@ -0,0 +1,619 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.e_invoice.api.models.documents + +import com.e_invoice.api.core.Enum +import com.e_invoice.api.core.ExcludeMissing +import com.e_invoice.api.core.JsonField +import com.e_invoice.api.core.JsonMissing +import com.e_invoice.api.core.JsonValue +import com.e_invoice.api.errors.EInvoiceInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** An allowance is a discount for example for early payment, volume discount, etc. */ +class Allowance +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val amount: JsonField, + private val baseAmount: JsonField, + private val multiplierFactor: JsonField, + private val reason: JsonField, + private val reasonCode: JsonField, + private val taxCode: JsonField, + private val taxRate: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("base_amount") + @ExcludeMissing + baseAmount: JsonField = JsonMissing.of(), + @JsonProperty("multiplier_factor") + @ExcludeMissing + multiplierFactor: JsonField = JsonMissing.of(), + @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), + @JsonProperty("reason_code") + @ExcludeMissing + reasonCode: JsonField = JsonMissing.of(), + @JsonProperty("tax_code") @ExcludeMissing taxCode: JsonField = JsonMissing.of(), + @JsonProperty("tax_rate") @ExcludeMissing taxRate: JsonField = JsonMissing.of(), + ) : this( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + mutableMapOf(), + ) + + /** + * The allowance amount, without VAT. Must be rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * The base amount that may be used, in conjunction with the allowance percentage, to calculate + * the allowance amount. Must be rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun baseAmount(): Optional = baseAmount.getOptional("base_amount") + + /** + * The percentage that may be used, in conjunction with the allowance base amount, to calculate + * the allowance amount. To state 20%, use value 20 + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun multiplierFactor(): Optional = multiplierFactor.getOptional("multiplier_factor") + + /** + * The reason for the allowance + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun reason(): Optional = reason.getOptional("reason") + + /** + * The code for the allowance reason + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun reasonCode(): Optional = reasonCode.getOptional("reason_code") + + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun taxCode(): Optional = taxCode.getOptional("tax_code") + + /** + * The VAT rate, represented as percentage that applies to the allowance + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun taxRate(): Optional = taxRate.getOptional("tax_rate") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [baseAmount]. + * + * Unlike [baseAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("base_amount") @ExcludeMissing fun _baseAmount(): JsonField = baseAmount + + /** + * Returns the raw JSON value of [multiplierFactor]. + * + * Unlike [multiplierFactor], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("multiplier_factor") + @ExcludeMissing + fun _multiplierFactor(): JsonField = multiplierFactor + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + /** + * Returns the raw JSON value of [reasonCode]. + * + * Unlike [reasonCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reason_code") @ExcludeMissing fun _reasonCode(): JsonField = reasonCode + + /** + * Returns the raw JSON value of [taxCode]. + * + * Unlike [taxCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax_code") @ExcludeMissing fun _taxCode(): JsonField = taxCode + + /** + * Returns the raw JSON value of [taxRate]. + * + * Unlike [taxRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Allowance]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Allowance]. */ + class Builder internal constructor() { + + private var amount: JsonField = JsonMissing.of() + private var baseAmount: JsonField = JsonMissing.of() + private var multiplierFactor: JsonField = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var reasonCode: JsonField = JsonMissing.of() + private var taxCode: JsonField = JsonMissing.of() + private var taxRate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(allowance: Allowance) = apply { + amount = allowance.amount + baseAmount = allowance.baseAmount + multiplierFactor = allowance.multiplierFactor + reason = allowance.reason + reasonCode = allowance.reasonCode + taxCode = allowance.taxCode + taxRate = allowance.taxRate + additionalProperties = allowance.additionalProperties.toMutableMap() + } + + /** The allowance amount, without VAT. Must be rounded to maximum 2 decimals */ + fun amount(amount: String?) = amount(JsonField.ofNullable(amount)) + + /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ + fun amount(amount: Optional) = amount(amount.getOrNull()) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** + * The base amount that may be used, in conjunction with the allowance percentage, to + * calculate the allowance amount. Must be rounded to maximum 2 decimals + */ + fun baseAmount(baseAmount: String?) = baseAmount(JsonField.ofNullable(baseAmount)) + + /** Alias for calling [Builder.baseAmount] with `baseAmount.orElse(null)`. */ + fun baseAmount(baseAmount: Optional) = baseAmount(baseAmount.getOrNull()) + + /** + * Sets [Builder.baseAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.baseAmount] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun baseAmount(baseAmount: JsonField) = apply { this.baseAmount = baseAmount } + + /** + * The percentage that may be used, in conjunction with the allowance base amount, to + * calculate the allowance amount. To state 20%, use value 20 + */ + fun multiplierFactor(multiplierFactor: String?) = + multiplierFactor(JsonField.ofNullable(multiplierFactor)) + + /** Alias for calling [Builder.multiplierFactor] with `multiplierFactor.orElse(null)`. */ + fun multiplierFactor(multiplierFactor: Optional) = + multiplierFactor(multiplierFactor.getOrNull()) + + /** + * Sets [Builder.multiplierFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.multiplierFactor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun multiplierFactor(multiplierFactor: JsonField) = apply { + this.multiplierFactor = multiplierFactor + } + + /** The reason for the allowance */ + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ + fun reason(reason: Optional) = reason(reason.getOrNull()) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + /** The code for the allowance reason */ + fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) + + /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ + fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) + + /** + * Sets [Builder.reasonCode] to an arbitrary JSON value. + * + * You should usually call [Builder.reasonCode] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode } + + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + */ + fun taxCode(taxCode: TaxCode?) = taxCode(JsonField.ofNullable(taxCode)) + + /** Alias for calling [Builder.taxCode] with `taxCode.orElse(null)`. */ + fun taxCode(taxCode: Optional) = taxCode(taxCode.getOrNull()) + + /** + * Sets [Builder.taxCode] to an arbitrary JSON value. + * + * You should usually call [Builder.taxCode] with a well-typed [TaxCode] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } + + /** The VAT rate, represented as percentage that applies to the allowance */ + fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) + + /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ + fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) + + /** + * Sets [Builder.taxRate] to an arbitrary JSON value. + * + * You should usually call [Builder.taxRate] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Allowance]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Allowance = + Allowance( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Allowance = apply { + if (validated) { + return@apply + } + + amount() + baseAmount() + multiplierFactor() + reason() + reasonCode() + taxCode().ifPresent { it.validate() } + taxRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (baseAmount.asKnown().isPresent) 1 else 0) + + (if (multiplierFactor.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (if (reasonCode.asKnown().isPresent) 1 else 0) + + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + + (if (taxRate.asKnown().isPresent) 1 else 0) + + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + */ + class TaxCode @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val AE = of("AE") + + @JvmField val E = of("E") + + @JvmField val S = of("S") + + @JvmField val Z = of("Z") + + @JvmField val G = of("G") + + @JvmField val O = of("O") + + @JvmField val K = of("K") + + @JvmField val L = of("L") + + @JvmField val M = of("M") + + @JvmField val B = of("B") + + @JvmStatic fun of(value: String) = TaxCode(JsonField.of(value)) + } + + /** An enum containing [TaxCode]'s known values. */ + enum class Known { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + } + + /** + * An enum containing [TaxCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TaxCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + /** An enum member indicating that [TaxCode] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AE -> Value.AE + E -> Value.E + S -> Value.S + Z -> Value.Z + G -> Value.G + O -> Value.O + K -> Value.K + L -> Value.L + M -> Value.M + B -> Value.B + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + AE -> Known.AE + E -> Known.E + S -> Known.S + Z -> Known.Z + G -> Known.G + O -> Known.O + K -> Known.K + L -> Known.L + M -> Known.M + B -> Known.B + else -> throw EInvoiceInvalidDataException("Unknown TaxCode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TaxCode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TaxCode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Allowance && + amount == other.amount && + baseAmount == other.baseAmount && + multiplierFactor == other.multiplierFactor && + reason == other.reason && + reasonCode == other.reasonCode && + taxCode == other.taxCode && + taxRate == other.taxRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Allowance{amount=$amount, baseAmount=$baseAmount, multiplierFactor=$multiplierFactor, reason=$reason, reasonCode=$reasonCode, taxCode=$taxCode, taxRate=$taxRate, additionalProperties=$additionalProperties}" +} diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Charge.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Charge.kt new file mode 100644 index 0000000..3654cc2 --- /dev/null +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Charge.kt @@ -0,0 +1,619 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.e_invoice.api.models.documents + +import com.e_invoice.api.core.Enum +import com.e_invoice.api.core.ExcludeMissing +import com.e_invoice.api.core.JsonField +import com.e_invoice.api.core.JsonMissing +import com.e_invoice.api.core.JsonValue +import com.e_invoice.api.errors.EInvoiceInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** A charge is an additional fee for example for late payment, late delivery, etc. */ +class Charge +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val amount: JsonField, + private val baseAmount: JsonField, + private val multiplierFactor: JsonField, + private val reason: JsonField, + private val reasonCode: JsonField, + private val taxCode: JsonField, + private val taxRate: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("base_amount") + @ExcludeMissing + baseAmount: JsonField = JsonMissing.of(), + @JsonProperty("multiplier_factor") + @ExcludeMissing + multiplierFactor: JsonField = JsonMissing.of(), + @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), + @JsonProperty("reason_code") + @ExcludeMissing + reasonCode: JsonField = JsonMissing.of(), + @JsonProperty("tax_code") @ExcludeMissing taxCode: JsonField = JsonMissing.of(), + @JsonProperty("tax_rate") @ExcludeMissing taxRate: JsonField = JsonMissing.of(), + ) : this( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + mutableMapOf(), + ) + + /** + * The charge amount, without VAT. Must be rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * The base amount that may be used, in conjunction with the charge percentage, to calculate the + * charge amount. Must be rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun baseAmount(): Optional = baseAmount.getOptional("base_amount") + + /** + * The percentage that may be used, in conjunction with the charge base amount, to calculate the + * charge amount. To state 20%, use value 20 + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun multiplierFactor(): Optional = multiplierFactor.getOptional("multiplier_factor") + + /** + * The reason for the charge + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun reason(): Optional = reason.getOptional("reason") + + /** + * The code for the charge reason + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun reasonCode(): Optional = reasonCode.getOptional("reason_code") + + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun taxCode(): Optional = taxCode.getOptional("tax_code") + + /** + * The VAT rate, represented as percentage that applies to the charge + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun taxRate(): Optional = taxRate.getOptional("tax_rate") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [baseAmount]. + * + * Unlike [baseAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("base_amount") @ExcludeMissing fun _baseAmount(): JsonField = baseAmount + + /** + * Returns the raw JSON value of [multiplierFactor]. + * + * Unlike [multiplierFactor], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("multiplier_factor") + @ExcludeMissing + fun _multiplierFactor(): JsonField = multiplierFactor + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + /** + * Returns the raw JSON value of [reasonCode]. + * + * Unlike [reasonCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reason_code") @ExcludeMissing fun _reasonCode(): JsonField = reasonCode + + /** + * Returns the raw JSON value of [taxCode]. + * + * Unlike [taxCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax_code") @ExcludeMissing fun _taxCode(): JsonField = taxCode + + /** + * Returns the raw JSON value of [taxRate]. + * + * Unlike [taxRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Charge]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Charge]. */ + class Builder internal constructor() { + + private var amount: JsonField = JsonMissing.of() + private var baseAmount: JsonField = JsonMissing.of() + private var multiplierFactor: JsonField = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var reasonCode: JsonField = JsonMissing.of() + private var taxCode: JsonField = JsonMissing.of() + private var taxRate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(charge: Charge) = apply { + amount = charge.amount + baseAmount = charge.baseAmount + multiplierFactor = charge.multiplierFactor + reason = charge.reason + reasonCode = charge.reasonCode + taxCode = charge.taxCode + taxRate = charge.taxRate + additionalProperties = charge.additionalProperties.toMutableMap() + } + + /** The charge amount, without VAT. Must be rounded to maximum 2 decimals */ + fun amount(amount: String?) = amount(JsonField.ofNullable(amount)) + + /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ + fun amount(amount: Optional) = amount(amount.getOrNull()) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** + * The base amount that may be used, in conjunction with the charge percentage, to calculate + * the charge amount. Must be rounded to maximum 2 decimals + */ + fun baseAmount(baseAmount: String?) = baseAmount(JsonField.ofNullable(baseAmount)) + + /** Alias for calling [Builder.baseAmount] with `baseAmount.orElse(null)`. */ + fun baseAmount(baseAmount: Optional) = baseAmount(baseAmount.getOrNull()) + + /** + * Sets [Builder.baseAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.baseAmount] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun baseAmount(baseAmount: JsonField) = apply { this.baseAmount = baseAmount } + + /** + * The percentage that may be used, in conjunction with the charge base amount, to calculate + * the charge amount. To state 20%, use value 20 + */ + fun multiplierFactor(multiplierFactor: String?) = + multiplierFactor(JsonField.ofNullable(multiplierFactor)) + + /** Alias for calling [Builder.multiplierFactor] with `multiplierFactor.orElse(null)`. */ + fun multiplierFactor(multiplierFactor: Optional) = + multiplierFactor(multiplierFactor.getOrNull()) + + /** + * Sets [Builder.multiplierFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.multiplierFactor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun multiplierFactor(multiplierFactor: JsonField) = apply { + this.multiplierFactor = multiplierFactor + } + + /** The reason for the charge */ + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ + fun reason(reason: Optional) = reason(reason.getOrNull()) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + /** The code for the charge reason */ + fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) + + /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ + fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) + + /** + * Sets [Builder.reasonCode] to an arbitrary JSON value. + * + * You should usually call [Builder.reasonCode] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode } + + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + */ + fun taxCode(taxCode: TaxCode?) = taxCode(JsonField.ofNullable(taxCode)) + + /** Alias for calling [Builder.taxCode] with `taxCode.orElse(null)`. */ + fun taxCode(taxCode: Optional) = taxCode(taxCode.getOrNull()) + + /** + * Sets [Builder.taxCode] to an arbitrary JSON value. + * + * You should usually call [Builder.taxCode] with a well-typed [TaxCode] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } + + /** The VAT rate, represented as percentage that applies to the charge */ + fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) + + /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ + fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) + + /** + * Sets [Builder.taxRate] to an arbitrary JSON value. + * + * You should usually call [Builder.taxRate] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Charge]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Charge = + Charge( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Charge = apply { + if (validated) { + return@apply + } + + amount() + baseAmount() + multiplierFactor() + reason() + reasonCode() + taxCode().ifPresent { it.validate() } + taxRate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (baseAmount.asKnown().isPresent) 1 else 0) + + (if (multiplierFactor.asKnown().isPresent) 1 else 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (if (reasonCode.asKnown().isPresent) 1 else 0) + + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + + (if (taxRate.asKnown().isPresent) 1 else 0) + + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + */ + class TaxCode @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val AE = of("AE") + + @JvmField val E = of("E") + + @JvmField val S = of("S") + + @JvmField val Z = of("Z") + + @JvmField val G = of("G") + + @JvmField val O = of("O") + + @JvmField val K = of("K") + + @JvmField val L = of("L") + + @JvmField val M = of("M") + + @JvmField val B = of("B") + + @JvmStatic fun of(value: String) = TaxCode(JsonField.of(value)) + } + + /** An enum containing [TaxCode]'s known values. */ + enum class Known { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + } + + /** + * An enum containing [TaxCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TaxCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + /** An enum member indicating that [TaxCode] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AE -> Value.AE + E -> Value.E + S -> Value.S + Z -> Value.Z + G -> Value.G + O -> Value.O + K -> Value.K + L -> Value.L + M -> Value.M + B -> Value.B + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + AE -> Known.AE + E -> Known.E + S -> Known.S + Z -> Known.Z + G -> Known.G + O -> Known.O + K -> Known.K + L -> Known.L + M -> Known.M + B -> Known.B + else -> throw EInvoiceInvalidDataException("Unknown TaxCode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TaxCode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TaxCode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Charge && + amount == other.amount && + baseAmount == other.baseAmount && + multiplierFactor == other.multiplierFactor && + reason == other.reason && + reasonCode == other.reasonCode && + taxCode == other.taxCode && + taxRate == other.taxRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Charge{amount=$amount, baseAmount=$baseAmount, multiplierFactor=$multiplierFactor, reason=$reason, reasonCode=$reasonCode, taxCode=$taxCode, taxRate=$taxRate, additionalProperties=$additionalProperties}" +} diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfParams.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfParams.kt new file mode 100644 index 0000000..f418bfd --- /dev/null +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfParams.kt @@ -0,0 +1,455 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.e_invoice.api.models.documents + +import com.e_invoice.api.core.ExcludeMissing +import com.e_invoice.api.core.JsonValue +import com.e_invoice.api.core.MultipartField +import com.e_invoice.api.core.Params +import com.e_invoice.api.core.checkRequired +import com.e_invoice.api.core.http.Headers +import com.e_invoice.api.core.http.QueryParams +import com.e_invoice.api.core.toImmutable +import com.e_invoice.api.errors.EInvoiceInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import java.io.InputStream +import java.nio.file.Path +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.io.path.inputStream +import kotlin.io.path.name +import kotlin.jvm.optionals.getOrNull + +/** + * Create a new invoice or credit note from a PDF file. If the 'ubl_document' field is set in the + * response, it indicates that sufficient details were extracted from the PDF to automatically + * generate a valid UBL document ready for sending. If 'ubl_document' is not set, human intervention + * may be required to ensure compliance. + */ +class DocumentCreateFromPdfParams +private constructor( + private val customerTaxId: String?, + private val vendorTaxId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun customerTaxId(): Optional = Optional.ofNullable(customerTaxId) + + fun vendorTaxId(): Optional = Optional.ofNullable(vendorTaxId) + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun file(): InputStream = body.file() + + /** + * Returns the raw multipart value of [file]. + * + * Unlike [file], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _file(): MultipartField = body._file() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [DocumentCreateFromPdfParams]. + * + * The following fields are required: + * ```java + * .file() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DocumentCreateFromPdfParams]. */ + class Builder internal constructor() { + + private var customerTaxId: String? = null + private var vendorTaxId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(documentCreateFromPdfParams: DocumentCreateFromPdfParams) = apply { + customerTaxId = documentCreateFromPdfParams.customerTaxId + vendorTaxId = documentCreateFromPdfParams.vendorTaxId + body = documentCreateFromPdfParams.body.toBuilder() + additionalHeaders = documentCreateFromPdfParams.additionalHeaders.toBuilder() + additionalQueryParams = documentCreateFromPdfParams.additionalQueryParams.toBuilder() + } + + fun customerTaxId(customerTaxId: String?) = apply { this.customerTaxId = customerTaxId } + + /** Alias for calling [Builder.customerTaxId] with `customerTaxId.orElse(null)`. */ + fun customerTaxId(customerTaxId: Optional) = + customerTaxId(customerTaxId.getOrNull()) + + fun vendorTaxId(vendorTaxId: String?) = apply { this.vendorTaxId = vendorTaxId } + + /** Alias for calling [Builder.vendorTaxId] with `vendorTaxId.orElse(null)`. */ + fun vendorTaxId(vendorTaxId: Optional) = vendorTaxId(vendorTaxId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [file] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun file(file: InputStream) = apply { body.file(file) } + + /** + * Sets [Builder.file] to an arbitrary multipart value. + * + * You should usually call [Builder.file] with a well-typed [InputStream] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun file(file: MultipartField) = apply { body.file(file) } + + fun file(file: ByteArray) = apply { body.file(file) } + + fun file(path: Path) = apply { body.file(path) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [DocumentCreateFromPdfParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .file() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DocumentCreateFromPdfParams = + DocumentCreateFromPdfParams( + customerTaxId, + vendorTaxId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Map> = + (mapOf("file" to _file()) + + _additionalBodyProperties().mapValues { (_, value) -> MultipartField.of(value) }) + .toImmutable() + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + customerTaxId?.let { put("customer_tax_id", it) } + vendorTaxId?.let { put("vendor_tax_id", it) } + putAll(additionalQueryParams) + } + .build() + + class Body + private constructor( + private val file: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun file(): InputStream = file.value.getRequired("file") + + /** + * Returns the raw multipart value of [file]. + * + * Unlike [file], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("file") @ExcludeMissing fun _file(): MultipartField = file + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .file() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var file: MultipartField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + file = body.file + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun file(file: InputStream) = file(MultipartField.of(file)) + + /** + * Sets [Builder.file] to an arbitrary multipart value. + * + * You should usually call [Builder.file] with a well-typed [InputStream] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun file(file: MultipartField) = apply { this.file = file } + + fun file(file: ByteArray) = file(file.inputStream()) + + fun file(path: Path) = + file( + MultipartField.builder() + .value(path.inputStream()) + .filename(path.name) + .build() + ) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .file() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body(checkRequired("file", file), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + file() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + file == other.file && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(file, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Body{file=$file, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DocumentCreateFromPdfParams && + customerTaxId == other.customerTaxId && + vendorTaxId == other.vendorTaxId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(customerTaxId, vendorTaxId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "DocumentCreateFromPdfParams{customerTaxId=$customerTaxId, vendorTaxId=$vendorTaxId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponse.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponse.kt new file mode 100644 index 0000000..5164b90 --- /dev/null +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponse.kt @@ -0,0 +1,3762 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.e_invoice.api.models.documents + +import com.e_invoice.api.core.Enum +import com.e_invoice.api.core.ExcludeMissing +import com.e_invoice.api.core.JsonField +import com.e_invoice.api.core.JsonMissing +import com.e_invoice.api.core.JsonValue +import com.e_invoice.api.core.checkKnown +import com.e_invoice.api.core.toImmutable +import com.e_invoice.api.errors.EInvoiceInvalidDataException +import com.e_invoice.api.models.inbox.DocumentState +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.time.LocalDate +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class DocumentCreateFromPdfResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val allowances: JsonField>, + private val amountDue: JsonField, + private val attachments: JsonField>, + private val billingAddress: JsonField, + private val billingAddressRecipient: JsonField, + private val charges: JsonField>, + private val currency: JsonField, + private val customerAddress: JsonField, + private val customerAddressRecipient: JsonField, + private val customerEmail: JsonField, + private val customerId: JsonField, + private val customerName: JsonField, + private val customerTaxId: JsonField, + private val direction: JsonField, + private val documentType: JsonField, + private val dueDate: JsonField, + private val invoiceDate: JsonField, + private val invoiceId: JsonField, + private val invoiceTotal: JsonField, + private val items: JsonField>, + private val note: JsonField, + private val paymentDetails: JsonField>, + private val paymentTerm: JsonField, + private val previousUnpaidBalance: JsonField, + private val purchaseOrder: JsonField, + private val remittanceAddress: JsonField, + private val remittanceAddressRecipient: JsonField, + private val serviceAddress: JsonField, + private val serviceAddressRecipient: JsonField, + private val serviceEndDate: JsonField, + private val serviceStartDate: JsonField, + private val shippingAddress: JsonField, + private val shippingAddressRecipient: JsonField, + private val state: JsonField, + private val subtotal: JsonField, + private val success: JsonField, + private val taxCode: JsonField, + private val taxDetails: JsonField>, + private val totalDiscount: JsonField, + private val totalTax: JsonField, + private val ublDocument: JsonField, + private val vatex: JsonField, + private val vatexNote: JsonField, + private val vendorAddress: JsonField, + private val vendorAddressRecipient: JsonField, + private val vendorEmail: JsonField, + private val vendorName: JsonField, + private val vendorTaxId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("allowances") + @ExcludeMissing + allowances: JsonField> = JsonMissing.of(), + @JsonProperty("amount_due") @ExcludeMissing amountDue: JsonField = JsonMissing.of(), + @JsonProperty("attachments") + @ExcludeMissing + attachments: JsonField> = JsonMissing.of(), + @JsonProperty("billing_address") + @ExcludeMissing + billingAddress: JsonField = JsonMissing.of(), + @JsonProperty("billing_address_recipient") + @ExcludeMissing + billingAddressRecipient: JsonField = JsonMissing.of(), + @JsonProperty("charges") + @ExcludeMissing + charges: JsonField> = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("customer_address") + @ExcludeMissing + customerAddress: JsonField = JsonMissing.of(), + @JsonProperty("customer_address_recipient") + @ExcludeMissing + customerAddressRecipient: JsonField = JsonMissing.of(), + @JsonProperty("customer_email") + @ExcludeMissing + customerEmail: JsonField = JsonMissing.of(), + @JsonProperty("customer_id") + @ExcludeMissing + customerId: JsonField = JsonMissing.of(), + @JsonProperty("customer_name") + @ExcludeMissing + customerName: JsonField = JsonMissing.of(), + @JsonProperty("customer_tax_id") + @ExcludeMissing + customerTaxId: JsonField = JsonMissing.of(), + @JsonProperty("direction") + @ExcludeMissing + direction: JsonField = JsonMissing.of(), + @JsonProperty("document_type") + @ExcludeMissing + documentType: JsonField = JsonMissing.of(), + @JsonProperty("due_date") @ExcludeMissing dueDate: JsonField = JsonMissing.of(), + @JsonProperty("invoice_date") + @ExcludeMissing + invoiceDate: JsonField = JsonMissing.of(), + @JsonProperty("invoice_id") @ExcludeMissing invoiceId: JsonField = JsonMissing.of(), + @JsonProperty("invoice_total") + @ExcludeMissing + invoiceTotal: JsonField = JsonMissing.of(), + @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of(), + @JsonProperty("note") @ExcludeMissing note: JsonField = JsonMissing.of(), + @JsonProperty("payment_details") + @ExcludeMissing + paymentDetails: JsonField> = JsonMissing.of(), + @JsonProperty("payment_term") + @ExcludeMissing + paymentTerm: JsonField = JsonMissing.of(), + @JsonProperty("previous_unpaid_balance") + @ExcludeMissing + previousUnpaidBalance: JsonField = JsonMissing.of(), + @JsonProperty("purchase_order") + @ExcludeMissing + purchaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("remittance_address") + @ExcludeMissing + remittanceAddress: JsonField = JsonMissing.of(), + @JsonProperty("remittance_address_recipient") + @ExcludeMissing + remittanceAddressRecipient: JsonField = JsonMissing.of(), + @JsonProperty("service_address") + @ExcludeMissing + serviceAddress: JsonField = JsonMissing.of(), + @JsonProperty("service_address_recipient") + @ExcludeMissing + serviceAddressRecipient: JsonField = JsonMissing.of(), + @JsonProperty("service_end_date") + @ExcludeMissing + serviceEndDate: JsonField = JsonMissing.of(), + @JsonProperty("service_start_date") + @ExcludeMissing + serviceStartDate: JsonField = JsonMissing.of(), + @JsonProperty("shipping_address") + @ExcludeMissing + shippingAddress: JsonField = JsonMissing.of(), + @JsonProperty("shipping_address_recipient") + @ExcludeMissing + shippingAddressRecipient: JsonField = JsonMissing.of(), + @JsonProperty("state") @ExcludeMissing state: JsonField = JsonMissing.of(), + @JsonProperty("subtotal") @ExcludeMissing subtotal: JsonField = JsonMissing.of(), + @JsonProperty("success") @ExcludeMissing success: JsonField = JsonMissing.of(), + @JsonProperty("tax_code") @ExcludeMissing taxCode: JsonField = JsonMissing.of(), + @JsonProperty("tax_details") + @ExcludeMissing + taxDetails: JsonField> = JsonMissing.of(), + @JsonProperty("total_discount") + @ExcludeMissing + totalDiscount: JsonField = JsonMissing.of(), + @JsonProperty("total_tax") @ExcludeMissing totalTax: JsonField = JsonMissing.of(), + @JsonProperty("ubl_document") + @ExcludeMissing + ublDocument: JsonField = JsonMissing.of(), + @JsonProperty("vatex") @ExcludeMissing vatex: JsonField = JsonMissing.of(), + @JsonProperty("vatex_note") @ExcludeMissing vatexNote: JsonField = JsonMissing.of(), + @JsonProperty("vendor_address") + @ExcludeMissing + vendorAddress: JsonField = JsonMissing.of(), + @JsonProperty("vendor_address_recipient") + @ExcludeMissing + vendorAddressRecipient: JsonField = JsonMissing.of(), + @JsonProperty("vendor_email") + @ExcludeMissing + vendorEmail: JsonField = JsonMissing.of(), + @JsonProperty("vendor_name") + @ExcludeMissing + vendorName: JsonField = JsonMissing.of(), + @JsonProperty("vendor_tax_id") + @ExcludeMissing + vendorTaxId: JsonField = JsonMissing.of(), + ) : this( + allowances, + amountDue, + attachments, + billingAddress, + billingAddressRecipient, + charges, + currency, + customerAddress, + customerAddressRecipient, + customerEmail, + customerId, + customerName, + customerTaxId, + direction, + documentType, + dueDate, + invoiceDate, + invoiceId, + invoiceTotal, + items, + note, + paymentDetails, + paymentTerm, + previousUnpaidBalance, + purchaseOrder, + remittanceAddress, + remittanceAddressRecipient, + serviceAddress, + serviceAddressRecipient, + serviceEndDate, + serviceStartDate, + shippingAddress, + shippingAddressRecipient, + state, + subtotal, + success, + taxCode, + taxDetails, + totalDiscount, + totalTax, + ublDocument, + vatex, + vatexNote, + vendorAddress, + vendorAddressRecipient, + vendorEmail, + vendorName, + vendorTaxId, + mutableMapOf(), + ) + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun allowances(): Optional> = allowances.getOptional("allowances") + + /** + * The amount due of the invoice. Must be positive and rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun amountDue(): Optional = amountDue.getOptional("amount_due") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun attachments(): Optional> = + attachments.getOptional("attachments") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billingAddress(): Optional = billingAddress.getOptional("billing_address") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun billingAddressRecipient(): Optional = + billingAddressRecipient.getOptional("billing_address_recipient") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun charges(): Optional> = charges.getOptional("charges") + + /** + * Currency of the invoice + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customerAddress(): Optional = customerAddress.getOptional("customer_address") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customerAddressRecipient(): Optional = + customerAddressRecipient.getOptional("customer_address_recipient") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customerEmail(): Optional = customerEmail.getOptional("customer_email") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customerId(): Optional = customerId.getOptional("customer_id") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customerName(): Optional = customerName.getOptional("customer_name") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customerTaxId(): Optional = customerTaxId.getOptional("customer_tax_id") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun direction(): Optional = direction.getOptional("direction") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun documentType(): Optional = documentType.getOptional("document_type") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dueDate(): Optional = dueDate.getOptional("due_date") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceDate(): Optional = invoiceDate.getOptional("invoice_date") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceId(): Optional = invoiceId.getOptional("invoice_id") + + /** + * The total amount of the invoice (so invoice_total = subtotal + total_tax + total_discount). + * Must be positive and rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun invoiceTotal(): Optional = invoiceTotal.getOptional("invoice_total") + + /** + * At least one line item is required + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun items(): Optional> = items.getOptional("items") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun note(): Optional = note.getOptional("note") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paymentDetails(): Optional> = + paymentDetails.getOptional("payment_details") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paymentTerm(): Optional = paymentTerm.getOptional("payment_term") + + /** + * The previous unpaid balance of the invoice, if any. Must be positive and rounded to maximum 2 + * decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun previousUnpaidBalance(): Optional = + previousUnpaidBalance.getOptional("previous_unpaid_balance") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun purchaseOrder(): Optional = purchaseOrder.getOptional("purchase_order") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun remittanceAddress(): Optional = remittanceAddress.getOptional("remittance_address") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun remittanceAddressRecipient(): Optional = + remittanceAddressRecipient.getOptional("remittance_address_recipient") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun serviceAddress(): Optional = serviceAddress.getOptional("service_address") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun serviceAddressRecipient(): Optional = + serviceAddressRecipient.getOptional("service_address_recipient") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun serviceEndDate(): Optional = serviceEndDate.getOptional("service_end_date") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun serviceStartDate(): Optional = serviceStartDate.getOptional("service_start_date") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun shippingAddress(): Optional = shippingAddress.getOptional("shipping_address") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun shippingAddressRecipient(): Optional = + shippingAddressRecipient.getOptional("shipping_address_recipient") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun state(): Optional = state.getOptional("state") + + /** + * The taxable base of the invoice. Should be the sum of all line items - allowances (for + * example commercial discounts) + charges with impact on VAT. Must be positive and rounded to + * maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun subtotal(): Optional = subtotal.getOptional("subtotal") + + /** + * Whether the PDF was successfully converted into a compliant e-invoice + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun success(): Optional = success.getOptional("success") + + /** + * Tax category code of the invoice + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun taxCode(): Optional = taxCode.getOptional("tax_code") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun taxDetails(): Optional> = taxDetails.getOptional("tax_details") + + /** + * The total financial discount of the invoice (so discounts not subject to VAT). Must be + * positive and rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun totalDiscount(): Optional = totalDiscount.getOptional("total_discount") + + /** + * The total tax of the invoice. Must be positive and rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun totalTax(): Optional = totalTax.getOptional("total_tax") + + /** + * The UBL document as an XML string + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ublDocument(): Optional = ublDocument.getOptional("ubl_document") + + /** + * VATEX code list for VAT exemption reasons + * + * Agency: CEF Identifier: vatex + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun vatex(): Optional = vatex.getOptional("vatex") + + /** + * VAT exemption note of the invoice + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun vatexNote(): Optional = vatexNote.getOptional("vatex_note") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun vendorAddress(): Optional = vendorAddress.getOptional("vendor_address") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun vendorAddressRecipient(): Optional = + vendorAddressRecipient.getOptional("vendor_address_recipient") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun vendorEmail(): Optional = vendorEmail.getOptional("vendor_email") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun vendorName(): Optional = vendorName.getOptional("vendor_name") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun vendorTaxId(): Optional = vendorTaxId.getOptional("vendor_tax_id") + + /** + * Returns the raw JSON value of [allowances]. + * + * Unlike [allowances], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("allowances") + @ExcludeMissing + fun _allowances(): JsonField> = allowances + + /** + * Returns the raw JSON value of [amountDue]. + * + * Unlike [amountDue], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount_due") @ExcludeMissing fun _amountDue(): JsonField = amountDue + + /** + * Returns the raw JSON value of [attachments]. + * + * Unlike [attachments], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("attachments") + @ExcludeMissing + fun _attachments(): JsonField> = attachments + + /** + * Returns the raw JSON value of [billingAddress]. + * + * Unlike [billingAddress], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("billing_address") + @ExcludeMissing + fun _billingAddress(): JsonField = billingAddress + + /** + * Returns the raw JSON value of [billingAddressRecipient]. + * + * Unlike [billingAddressRecipient], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("billing_address_recipient") + @ExcludeMissing + fun _billingAddressRecipient(): JsonField = billingAddressRecipient + + /** + * Returns the raw JSON value of [charges]. + * + * Unlike [charges], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("charges") @ExcludeMissing fun _charges(): JsonField> = charges + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [customerAddress]. + * + * Unlike [customerAddress], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("customer_address") + @ExcludeMissing + fun _customerAddress(): JsonField = customerAddress + + /** + * Returns the raw JSON value of [customerAddressRecipient]. + * + * Unlike [customerAddressRecipient], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("customer_address_recipient") + @ExcludeMissing + fun _customerAddressRecipient(): JsonField = customerAddressRecipient + + /** + * Returns the raw JSON value of [customerEmail]. + * + * Unlike [customerEmail], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("customer_email") + @ExcludeMissing + fun _customerEmail(): JsonField = customerEmail + + /** + * Returns the raw JSON value of [customerId]. + * + * Unlike [customerId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("customer_id") @ExcludeMissing fun _customerId(): JsonField = customerId + + /** + * Returns the raw JSON value of [customerName]. + * + * Unlike [customerName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("customer_name") + @ExcludeMissing + fun _customerName(): JsonField = customerName + + /** + * Returns the raw JSON value of [customerTaxId]. + * + * Unlike [customerTaxId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("customer_tax_id") + @ExcludeMissing + fun _customerTaxId(): JsonField = customerTaxId + + /** + * Returns the raw JSON value of [direction]. + * + * Unlike [direction], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("direction") + @ExcludeMissing + fun _direction(): JsonField = direction + + /** + * Returns the raw JSON value of [documentType]. + * + * Unlike [documentType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("document_type") + @ExcludeMissing + fun _documentType(): JsonField = documentType + + /** + * Returns the raw JSON value of [dueDate]. + * + * Unlike [dueDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("due_date") @ExcludeMissing fun _dueDate(): JsonField = dueDate + + /** + * Returns the raw JSON value of [invoiceDate]. + * + * Unlike [invoiceDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("invoice_date") + @ExcludeMissing + fun _invoiceDate(): JsonField = invoiceDate + + /** + * Returns the raw JSON value of [invoiceId]. + * + * Unlike [invoiceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("invoice_id") @ExcludeMissing fun _invoiceId(): JsonField = invoiceId + + /** + * Returns the raw JSON value of [invoiceTotal]. + * + * Unlike [invoiceTotal], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("invoice_total") + @ExcludeMissing + fun _invoiceTotal(): JsonField = invoiceTotal + + /** + * Returns the raw JSON value of [items]. + * + * Unlike [items], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("items") @ExcludeMissing fun _items(): JsonField> = items + + /** + * Returns the raw JSON value of [note]. + * + * Unlike [note], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("note") @ExcludeMissing fun _note(): JsonField = note + + /** + * Returns the raw JSON value of [paymentDetails]. + * + * Unlike [paymentDetails], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("payment_details") + @ExcludeMissing + fun _paymentDetails(): JsonField> = paymentDetails + + /** + * Returns the raw JSON value of [paymentTerm]. + * + * Unlike [paymentTerm], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("payment_term") + @ExcludeMissing + fun _paymentTerm(): JsonField = paymentTerm + + /** + * Returns the raw JSON value of [previousUnpaidBalance]. + * + * Unlike [previousUnpaidBalance], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("previous_unpaid_balance") + @ExcludeMissing + fun _previousUnpaidBalance(): JsonField = previousUnpaidBalance + + /** + * Returns the raw JSON value of [purchaseOrder]. + * + * Unlike [purchaseOrder], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("purchase_order") + @ExcludeMissing + fun _purchaseOrder(): JsonField = purchaseOrder + + /** + * Returns the raw JSON value of [remittanceAddress]. + * + * Unlike [remittanceAddress], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("remittance_address") + @ExcludeMissing + fun _remittanceAddress(): JsonField = remittanceAddress + + /** + * Returns the raw JSON value of [remittanceAddressRecipient]. + * + * Unlike [remittanceAddressRecipient], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("remittance_address_recipient") + @ExcludeMissing + fun _remittanceAddressRecipient(): JsonField = remittanceAddressRecipient + + /** + * Returns the raw JSON value of [serviceAddress]. + * + * Unlike [serviceAddress], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("service_address") + @ExcludeMissing + fun _serviceAddress(): JsonField = serviceAddress + + /** + * Returns the raw JSON value of [serviceAddressRecipient]. + * + * Unlike [serviceAddressRecipient], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("service_address_recipient") + @ExcludeMissing + fun _serviceAddressRecipient(): JsonField = serviceAddressRecipient + + /** + * Returns the raw JSON value of [serviceEndDate]. + * + * Unlike [serviceEndDate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("service_end_date") + @ExcludeMissing + fun _serviceEndDate(): JsonField = serviceEndDate + + /** + * Returns the raw JSON value of [serviceStartDate]. + * + * Unlike [serviceStartDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("service_start_date") + @ExcludeMissing + fun _serviceStartDate(): JsonField = serviceStartDate + + /** + * Returns the raw JSON value of [shippingAddress]. + * + * Unlike [shippingAddress], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("shipping_address") + @ExcludeMissing + fun _shippingAddress(): JsonField = shippingAddress + + /** + * Returns the raw JSON value of [shippingAddressRecipient]. + * + * Unlike [shippingAddressRecipient], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("shipping_address_recipient") + @ExcludeMissing + fun _shippingAddressRecipient(): JsonField = shippingAddressRecipient + + /** + * Returns the raw JSON value of [state]. + * + * Unlike [state], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state + + /** + * Returns the raw JSON value of [subtotal]. + * + * Unlike [subtotal], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("subtotal") @ExcludeMissing fun _subtotal(): JsonField = subtotal + + /** + * Returns the raw JSON value of [success]. + * + * Unlike [success], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("success") @ExcludeMissing fun _success(): JsonField = success + + /** + * Returns the raw JSON value of [taxCode]. + * + * Unlike [taxCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax_code") @ExcludeMissing fun _taxCode(): JsonField = taxCode + + /** + * Returns the raw JSON value of [taxDetails]. + * + * Unlike [taxDetails], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax_details") + @ExcludeMissing + fun _taxDetails(): JsonField> = taxDetails + + /** + * Returns the raw JSON value of [totalDiscount]. + * + * Unlike [totalDiscount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_discount") + @ExcludeMissing + fun _totalDiscount(): JsonField = totalDiscount + + /** + * Returns the raw JSON value of [totalTax]. + * + * Unlike [totalTax], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_tax") @ExcludeMissing fun _totalTax(): JsonField = totalTax + + /** + * Returns the raw JSON value of [ublDocument]. + * + * Unlike [ublDocument], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ubl_document") + @ExcludeMissing + fun _ublDocument(): JsonField = ublDocument + + /** + * Returns the raw JSON value of [vatex]. + * + * Unlike [vatex], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("vatex") @ExcludeMissing fun _vatex(): JsonField = vatex + + /** + * Returns the raw JSON value of [vatexNote]. + * + * Unlike [vatexNote], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("vatex_note") @ExcludeMissing fun _vatexNote(): JsonField = vatexNote + + /** + * Returns the raw JSON value of [vendorAddress]. + * + * Unlike [vendorAddress], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("vendor_address") + @ExcludeMissing + fun _vendorAddress(): JsonField = vendorAddress + + /** + * Returns the raw JSON value of [vendorAddressRecipient]. + * + * Unlike [vendorAddressRecipient], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("vendor_address_recipient") + @ExcludeMissing + fun _vendorAddressRecipient(): JsonField = vendorAddressRecipient + + /** + * Returns the raw JSON value of [vendorEmail]. + * + * Unlike [vendorEmail], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("vendor_email") + @ExcludeMissing + fun _vendorEmail(): JsonField = vendorEmail + + /** + * Returns the raw JSON value of [vendorName]. + * + * Unlike [vendorName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("vendor_name") @ExcludeMissing fun _vendorName(): JsonField = vendorName + + /** + * Returns the raw JSON value of [vendorTaxId]. + * + * Unlike [vendorTaxId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("vendor_tax_id") + @ExcludeMissing + fun _vendorTaxId(): JsonField = vendorTaxId + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [DocumentCreateFromPdfResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DocumentCreateFromPdfResponse]. */ + class Builder internal constructor() { + + private var allowances: JsonField>? = null + private var amountDue: JsonField = JsonMissing.of() + private var attachments: JsonField>? = null + private var billingAddress: JsonField = JsonMissing.of() + private var billingAddressRecipient: JsonField = JsonMissing.of() + private var charges: JsonField>? = null + private var currency: JsonField = JsonMissing.of() + private var customerAddress: JsonField = JsonMissing.of() + private var customerAddressRecipient: JsonField = JsonMissing.of() + private var customerEmail: JsonField = JsonMissing.of() + private var customerId: JsonField = JsonMissing.of() + private var customerName: JsonField = JsonMissing.of() + private var customerTaxId: JsonField = JsonMissing.of() + private var direction: JsonField = JsonMissing.of() + private var documentType: JsonField = JsonMissing.of() + private var dueDate: JsonField = JsonMissing.of() + private var invoiceDate: JsonField = JsonMissing.of() + private var invoiceId: JsonField = JsonMissing.of() + private var invoiceTotal: JsonField = JsonMissing.of() + private var items: JsonField>? = null + private var note: JsonField = JsonMissing.of() + private var paymentDetails: JsonField>? = null + private var paymentTerm: JsonField = JsonMissing.of() + private var previousUnpaidBalance: JsonField = JsonMissing.of() + private var purchaseOrder: JsonField = JsonMissing.of() + private var remittanceAddress: JsonField = JsonMissing.of() + private var remittanceAddressRecipient: JsonField = JsonMissing.of() + private var serviceAddress: JsonField = JsonMissing.of() + private var serviceAddressRecipient: JsonField = JsonMissing.of() + private var serviceEndDate: JsonField = JsonMissing.of() + private var serviceStartDate: JsonField = JsonMissing.of() + private var shippingAddress: JsonField = JsonMissing.of() + private var shippingAddressRecipient: JsonField = JsonMissing.of() + private var state: JsonField = JsonMissing.of() + private var subtotal: JsonField = JsonMissing.of() + private var success: JsonField = JsonMissing.of() + private var taxCode: JsonField = JsonMissing.of() + private var taxDetails: JsonField>? = null + private var totalDiscount: JsonField = JsonMissing.of() + private var totalTax: JsonField = JsonMissing.of() + private var ublDocument: JsonField = JsonMissing.of() + private var vatex: JsonField = JsonMissing.of() + private var vatexNote: JsonField = JsonMissing.of() + private var vendorAddress: JsonField = JsonMissing.of() + private var vendorAddressRecipient: JsonField = JsonMissing.of() + private var vendorEmail: JsonField = JsonMissing.of() + private var vendorName: JsonField = JsonMissing.of() + private var vendorTaxId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(documentCreateFromPdfResponse: DocumentCreateFromPdfResponse) = apply { + allowances = documentCreateFromPdfResponse.allowances.map { it.toMutableList() } + amountDue = documentCreateFromPdfResponse.amountDue + attachments = documentCreateFromPdfResponse.attachments.map { it.toMutableList() } + billingAddress = documentCreateFromPdfResponse.billingAddress + billingAddressRecipient = documentCreateFromPdfResponse.billingAddressRecipient + charges = documentCreateFromPdfResponse.charges.map { it.toMutableList() } + currency = documentCreateFromPdfResponse.currency + customerAddress = documentCreateFromPdfResponse.customerAddress + customerAddressRecipient = documentCreateFromPdfResponse.customerAddressRecipient + customerEmail = documentCreateFromPdfResponse.customerEmail + customerId = documentCreateFromPdfResponse.customerId + customerName = documentCreateFromPdfResponse.customerName + customerTaxId = documentCreateFromPdfResponse.customerTaxId + direction = documentCreateFromPdfResponse.direction + documentType = documentCreateFromPdfResponse.documentType + dueDate = documentCreateFromPdfResponse.dueDate + invoiceDate = documentCreateFromPdfResponse.invoiceDate + invoiceId = documentCreateFromPdfResponse.invoiceId + invoiceTotal = documentCreateFromPdfResponse.invoiceTotal + items = documentCreateFromPdfResponse.items.map { it.toMutableList() } + note = documentCreateFromPdfResponse.note + paymentDetails = documentCreateFromPdfResponse.paymentDetails.map { it.toMutableList() } + paymentTerm = documentCreateFromPdfResponse.paymentTerm + previousUnpaidBalance = documentCreateFromPdfResponse.previousUnpaidBalance + purchaseOrder = documentCreateFromPdfResponse.purchaseOrder + remittanceAddress = documentCreateFromPdfResponse.remittanceAddress + remittanceAddressRecipient = documentCreateFromPdfResponse.remittanceAddressRecipient + serviceAddress = documentCreateFromPdfResponse.serviceAddress + serviceAddressRecipient = documentCreateFromPdfResponse.serviceAddressRecipient + serviceEndDate = documentCreateFromPdfResponse.serviceEndDate + serviceStartDate = documentCreateFromPdfResponse.serviceStartDate + shippingAddress = documentCreateFromPdfResponse.shippingAddress + shippingAddressRecipient = documentCreateFromPdfResponse.shippingAddressRecipient + state = documentCreateFromPdfResponse.state + subtotal = documentCreateFromPdfResponse.subtotal + success = documentCreateFromPdfResponse.success + taxCode = documentCreateFromPdfResponse.taxCode + taxDetails = documentCreateFromPdfResponse.taxDetails.map { it.toMutableList() } + totalDiscount = documentCreateFromPdfResponse.totalDiscount + totalTax = documentCreateFromPdfResponse.totalTax + ublDocument = documentCreateFromPdfResponse.ublDocument + vatex = documentCreateFromPdfResponse.vatex + vatexNote = documentCreateFromPdfResponse.vatexNote + vendorAddress = documentCreateFromPdfResponse.vendorAddress + vendorAddressRecipient = documentCreateFromPdfResponse.vendorAddressRecipient + vendorEmail = documentCreateFromPdfResponse.vendorEmail + vendorName = documentCreateFromPdfResponse.vendorName + vendorTaxId = documentCreateFromPdfResponse.vendorTaxId + additionalProperties = documentCreateFromPdfResponse.additionalProperties.toMutableMap() + } + + fun allowances(allowances: List?) = allowances(JsonField.ofNullable(allowances)) + + /** Alias for calling [Builder.allowances] with `allowances.orElse(null)`. */ + fun allowances(allowances: Optional>) = allowances(allowances.getOrNull()) + + /** + * Sets [Builder.allowances] to an arbitrary JSON value. + * + * You should usually call [Builder.allowances] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun allowances(allowances: JsonField>) = apply { + this.allowances = allowances.map { it.toMutableList() } + } + + /** + * Adds a single [Allowance] to [allowances]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowance(allowance: Allowance) = apply { + allowances = + (allowances ?: JsonField.of(mutableListOf())).also { + checkKnown("allowances", it).add(allowance) + } + } + + /** The amount due of the invoice. Must be positive and rounded to maximum 2 decimals */ + fun amountDue(amountDue: String?) = amountDue(JsonField.ofNullable(amountDue)) + + /** Alias for calling [Builder.amountDue] with `amountDue.orElse(null)`. */ + fun amountDue(amountDue: Optional) = amountDue(amountDue.getOrNull()) + + /** + * Sets [Builder.amountDue] to an arbitrary JSON value. + * + * You should usually call [Builder.amountDue] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun amountDue(amountDue: JsonField) = apply { this.amountDue = amountDue } + + fun attachments(attachments: List?) = + attachments(JsonField.ofNullable(attachments)) + + /** Alias for calling [Builder.attachments] with `attachments.orElse(null)`. */ + fun attachments(attachments: Optional>) = + attachments(attachments.getOrNull()) + + /** + * Sets [Builder.attachments] to an arbitrary JSON value. + * + * You should usually call [Builder.attachments] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun attachments(attachments: JsonField>) = apply { + this.attachments = attachments.map { it.toMutableList() } + } + + /** + * Adds a single [DocumentAttachmentCreate] to [attachments]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAttachment(attachment: DocumentAttachmentCreate) = apply { + attachments = + (attachments ?: JsonField.of(mutableListOf())).also { + checkKnown("attachments", it).add(attachment) + } + } + + fun billingAddress(billingAddress: String?) = + billingAddress(JsonField.ofNullable(billingAddress)) + + /** Alias for calling [Builder.billingAddress] with `billingAddress.orElse(null)`. */ + fun billingAddress(billingAddress: Optional) = + billingAddress(billingAddress.getOrNull()) + + /** + * Sets [Builder.billingAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.billingAddress] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun billingAddress(billingAddress: JsonField) = apply { + this.billingAddress = billingAddress + } + + fun billingAddressRecipient(billingAddressRecipient: String?) = + billingAddressRecipient(JsonField.ofNullable(billingAddressRecipient)) + + /** + * Alias for calling [Builder.billingAddressRecipient] with + * `billingAddressRecipient.orElse(null)`. + */ + fun billingAddressRecipient(billingAddressRecipient: Optional) = + billingAddressRecipient(billingAddressRecipient.getOrNull()) + + /** + * Sets [Builder.billingAddressRecipient] to an arbitrary JSON value. + * + * You should usually call [Builder.billingAddressRecipient] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun billingAddressRecipient(billingAddressRecipient: JsonField) = apply { + this.billingAddressRecipient = billingAddressRecipient + } + + fun charges(charges: List?) = charges(JsonField.ofNullable(charges)) + + /** Alias for calling [Builder.charges] with `charges.orElse(null)`. */ + fun charges(charges: Optional>) = charges(charges.getOrNull()) + + /** + * Sets [Builder.charges] to an arbitrary JSON value. + * + * You should usually call [Builder.charges] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun charges(charges: JsonField>) = apply { + this.charges = charges.map { it.toMutableList() } + } + + /** + * Adds a single [Charge] to [charges]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCharge(charge: Charge) = apply { + charges = + (charges ?: JsonField.of(mutableListOf())).also { + checkKnown("charges", it).add(charge) + } + } + + /** Currency of the invoice */ + fun currency(currency: CurrencyCode) = currency(JsonField.of(currency)) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [CurrencyCode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun customerAddress(customerAddress: String?) = + customerAddress(JsonField.ofNullable(customerAddress)) + + /** Alias for calling [Builder.customerAddress] with `customerAddress.orElse(null)`. */ + fun customerAddress(customerAddress: Optional) = + customerAddress(customerAddress.getOrNull()) + + /** + * Sets [Builder.customerAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.customerAddress] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customerAddress(customerAddress: JsonField) = apply { + this.customerAddress = customerAddress + } + + fun customerAddressRecipient(customerAddressRecipient: String?) = + customerAddressRecipient(JsonField.ofNullable(customerAddressRecipient)) + + /** + * Alias for calling [Builder.customerAddressRecipient] with + * `customerAddressRecipient.orElse(null)`. + */ + fun customerAddressRecipient(customerAddressRecipient: Optional) = + customerAddressRecipient(customerAddressRecipient.getOrNull()) + + /** + * Sets [Builder.customerAddressRecipient] to an arbitrary JSON value. + * + * You should usually call [Builder.customerAddressRecipient] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun customerAddressRecipient(customerAddressRecipient: JsonField) = apply { + this.customerAddressRecipient = customerAddressRecipient + } + + fun customerEmail(customerEmail: String?) = + customerEmail(JsonField.ofNullable(customerEmail)) + + /** Alias for calling [Builder.customerEmail] with `customerEmail.orElse(null)`. */ + fun customerEmail(customerEmail: Optional) = + customerEmail(customerEmail.getOrNull()) + + /** + * Sets [Builder.customerEmail] to an arbitrary JSON value. + * + * You should usually call [Builder.customerEmail] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun customerEmail(customerEmail: JsonField) = apply { + this.customerEmail = customerEmail + } + + fun customerId(customerId: String?) = customerId(JsonField.ofNullable(customerId)) + + /** Alias for calling [Builder.customerId] with `customerId.orElse(null)`. */ + fun customerId(customerId: Optional) = customerId(customerId.getOrNull()) + + /** + * Sets [Builder.customerId] to an arbitrary JSON value. + * + * You should usually call [Builder.customerId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun customerId(customerId: JsonField) = apply { this.customerId = customerId } + + fun customerName(customerName: String?) = customerName(JsonField.ofNullable(customerName)) + + /** Alias for calling [Builder.customerName] with `customerName.orElse(null)`. */ + fun customerName(customerName: Optional) = customerName(customerName.getOrNull()) + + /** + * Sets [Builder.customerName] to an arbitrary JSON value. + * + * You should usually call [Builder.customerName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun customerName(customerName: JsonField) = apply { + this.customerName = customerName + } + + fun customerTaxId(customerTaxId: String?) = + customerTaxId(JsonField.ofNullable(customerTaxId)) + + /** Alias for calling [Builder.customerTaxId] with `customerTaxId.orElse(null)`. */ + fun customerTaxId(customerTaxId: Optional) = + customerTaxId(customerTaxId.getOrNull()) + + /** + * Sets [Builder.customerTaxId] to an arbitrary JSON value. + * + * You should usually call [Builder.customerTaxId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun customerTaxId(customerTaxId: JsonField) = apply { + this.customerTaxId = customerTaxId + } + + fun direction(direction: DocumentDirection) = direction(JsonField.of(direction)) + + /** + * Sets [Builder.direction] to an arbitrary JSON value. + * + * You should usually call [Builder.direction] with a well-typed [DocumentDirection] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun direction(direction: JsonField) = apply { + this.direction = direction + } + + fun documentType(documentType: DocumentType) = documentType(JsonField.of(documentType)) + + /** + * Sets [Builder.documentType] to an arbitrary JSON value. + * + * You should usually call [Builder.documentType] with a well-typed [DocumentType] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun documentType(documentType: JsonField) = apply { + this.documentType = documentType + } + + fun dueDate(dueDate: LocalDate?) = dueDate(JsonField.ofNullable(dueDate)) + + /** Alias for calling [Builder.dueDate] with `dueDate.orElse(null)`. */ + fun dueDate(dueDate: Optional) = dueDate(dueDate.getOrNull()) + + /** + * Sets [Builder.dueDate] to an arbitrary JSON value. + * + * You should usually call [Builder.dueDate] with a well-typed [LocalDate] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dueDate(dueDate: JsonField) = apply { this.dueDate = dueDate } + + fun invoiceDate(invoiceDate: LocalDate?) = invoiceDate(JsonField.ofNullable(invoiceDate)) + + /** Alias for calling [Builder.invoiceDate] with `invoiceDate.orElse(null)`. */ + fun invoiceDate(invoiceDate: Optional) = invoiceDate(invoiceDate.getOrNull()) + + /** + * Sets [Builder.invoiceDate] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun invoiceDate(invoiceDate: JsonField) = apply { + this.invoiceDate = invoiceDate + } + + fun invoiceId(invoiceId: String?) = invoiceId(JsonField.ofNullable(invoiceId)) + + /** Alias for calling [Builder.invoiceId] with `invoiceId.orElse(null)`. */ + fun invoiceId(invoiceId: Optional) = invoiceId(invoiceId.getOrNull()) + + /** + * Sets [Builder.invoiceId] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoiceId(invoiceId: JsonField) = apply { this.invoiceId = invoiceId } + + /** + * The total amount of the invoice (so invoice_total = subtotal + total_tax + + * total_discount). Must be positive and rounded to maximum 2 decimals + */ + fun invoiceTotal(invoiceTotal: String?) = invoiceTotal(JsonField.ofNullable(invoiceTotal)) + + /** Alias for calling [Builder.invoiceTotal] with `invoiceTotal.orElse(null)`. */ + fun invoiceTotal(invoiceTotal: Optional) = invoiceTotal(invoiceTotal.getOrNull()) + + /** + * Sets [Builder.invoiceTotal] to an arbitrary JSON value. + * + * You should usually call [Builder.invoiceTotal] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun invoiceTotal(invoiceTotal: JsonField) = apply { + this.invoiceTotal = invoiceTotal + } + + /** At least one line item is required */ + fun items(items: List) = items(JsonField.of(items)) + + /** + * Sets [Builder.items] to an arbitrary JSON value. + * + * You should usually call [Builder.items] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun items(items: JsonField>) = apply { + this.items = items.map { it.toMutableList() } + } + + /** + * Adds a single [Item] to [items]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addItem(item: Item) = apply { + items = + (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } + } + + fun note(note: String?) = note(JsonField.ofNullable(note)) + + /** Alias for calling [Builder.note] with `note.orElse(null)`. */ + fun note(note: Optional) = note(note.getOrNull()) + + /** + * Sets [Builder.note] to an arbitrary JSON value. + * + * You should usually call [Builder.note] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun note(note: JsonField) = apply { this.note = note } + + fun paymentDetails(paymentDetails: List?) = + paymentDetails(JsonField.ofNullable(paymentDetails)) + + /** Alias for calling [Builder.paymentDetails] with `paymentDetails.orElse(null)`. */ + fun paymentDetails(paymentDetails: Optional>) = + paymentDetails(paymentDetails.getOrNull()) + + /** + * Sets [Builder.paymentDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentDetails] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun paymentDetails(paymentDetails: JsonField>) = apply { + this.paymentDetails = paymentDetails.map { it.toMutableList() } + } + + /** + * Adds a single [PaymentDetailCreate] to [paymentDetails]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPaymentDetail(paymentDetail: PaymentDetailCreate) = apply { + paymentDetails = + (paymentDetails ?: JsonField.of(mutableListOf())).also { + checkKnown("paymentDetails", it).add(paymentDetail) + } + } + + fun paymentTerm(paymentTerm: String?) = paymentTerm(JsonField.ofNullable(paymentTerm)) + + /** Alias for calling [Builder.paymentTerm] with `paymentTerm.orElse(null)`. */ + fun paymentTerm(paymentTerm: Optional) = paymentTerm(paymentTerm.getOrNull()) + + /** + * Sets [Builder.paymentTerm] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentTerm] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun paymentTerm(paymentTerm: JsonField) = apply { this.paymentTerm = paymentTerm } + + /** + * The previous unpaid balance of the invoice, if any. Must be positive and rounded to + * maximum 2 decimals + */ + fun previousUnpaidBalance(previousUnpaidBalance: String?) = + previousUnpaidBalance(JsonField.ofNullable(previousUnpaidBalance)) + + /** + * Alias for calling [Builder.previousUnpaidBalance] with + * `previousUnpaidBalance.orElse(null)`. + */ + fun previousUnpaidBalance(previousUnpaidBalance: Optional) = + previousUnpaidBalance(previousUnpaidBalance.getOrNull()) + + /** + * Sets [Builder.previousUnpaidBalance] to an arbitrary JSON value. + * + * You should usually call [Builder.previousUnpaidBalance] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun previousUnpaidBalance(previousUnpaidBalance: JsonField) = apply { + this.previousUnpaidBalance = previousUnpaidBalance + } + + fun purchaseOrder(purchaseOrder: String?) = + purchaseOrder(JsonField.ofNullable(purchaseOrder)) + + /** Alias for calling [Builder.purchaseOrder] with `purchaseOrder.orElse(null)`. */ + fun purchaseOrder(purchaseOrder: Optional) = + purchaseOrder(purchaseOrder.getOrNull()) + + /** + * Sets [Builder.purchaseOrder] to an arbitrary JSON value. + * + * You should usually call [Builder.purchaseOrder] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun purchaseOrder(purchaseOrder: JsonField) = apply { + this.purchaseOrder = purchaseOrder + } + + fun remittanceAddress(remittanceAddress: String?) = + remittanceAddress(JsonField.ofNullable(remittanceAddress)) + + /** Alias for calling [Builder.remittanceAddress] with `remittanceAddress.orElse(null)`. */ + fun remittanceAddress(remittanceAddress: Optional) = + remittanceAddress(remittanceAddress.getOrNull()) + + /** + * Sets [Builder.remittanceAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.remittanceAddress] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun remittanceAddress(remittanceAddress: JsonField) = apply { + this.remittanceAddress = remittanceAddress + } + + fun remittanceAddressRecipient(remittanceAddressRecipient: String?) = + remittanceAddressRecipient(JsonField.ofNullable(remittanceAddressRecipient)) + + /** + * Alias for calling [Builder.remittanceAddressRecipient] with + * `remittanceAddressRecipient.orElse(null)`. + */ + fun remittanceAddressRecipient(remittanceAddressRecipient: Optional) = + remittanceAddressRecipient(remittanceAddressRecipient.getOrNull()) + + /** + * Sets [Builder.remittanceAddressRecipient] to an arbitrary JSON value. + * + * You should usually call [Builder.remittanceAddressRecipient] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun remittanceAddressRecipient(remittanceAddressRecipient: JsonField) = apply { + this.remittanceAddressRecipient = remittanceAddressRecipient + } + + fun serviceAddress(serviceAddress: String?) = + serviceAddress(JsonField.ofNullable(serviceAddress)) + + /** Alias for calling [Builder.serviceAddress] with `serviceAddress.orElse(null)`. */ + fun serviceAddress(serviceAddress: Optional) = + serviceAddress(serviceAddress.getOrNull()) + + /** + * Sets [Builder.serviceAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceAddress] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun serviceAddress(serviceAddress: JsonField) = apply { + this.serviceAddress = serviceAddress + } + + fun serviceAddressRecipient(serviceAddressRecipient: String?) = + serviceAddressRecipient(JsonField.ofNullable(serviceAddressRecipient)) + + /** + * Alias for calling [Builder.serviceAddressRecipient] with + * `serviceAddressRecipient.orElse(null)`. + */ + fun serviceAddressRecipient(serviceAddressRecipient: Optional) = + serviceAddressRecipient(serviceAddressRecipient.getOrNull()) + + /** + * Sets [Builder.serviceAddressRecipient] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceAddressRecipient] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun serviceAddressRecipient(serviceAddressRecipient: JsonField) = apply { + this.serviceAddressRecipient = serviceAddressRecipient + } + + fun serviceEndDate(serviceEndDate: LocalDate?) = + serviceEndDate(JsonField.ofNullable(serviceEndDate)) + + /** Alias for calling [Builder.serviceEndDate] with `serviceEndDate.orElse(null)`. */ + fun serviceEndDate(serviceEndDate: Optional) = + serviceEndDate(serviceEndDate.getOrNull()) + + /** + * Sets [Builder.serviceEndDate] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceEndDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun serviceEndDate(serviceEndDate: JsonField) = apply { + this.serviceEndDate = serviceEndDate + } + + fun serviceStartDate(serviceStartDate: LocalDate?) = + serviceStartDate(JsonField.ofNullable(serviceStartDate)) + + /** Alias for calling [Builder.serviceStartDate] with `serviceStartDate.orElse(null)`. */ + fun serviceStartDate(serviceStartDate: Optional) = + serviceStartDate(serviceStartDate.getOrNull()) + + /** + * Sets [Builder.serviceStartDate] to an arbitrary JSON value. + * + * You should usually call [Builder.serviceStartDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun serviceStartDate(serviceStartDate: JsonField) = apply { + this.serviceStartDate = serviceStartDate + } + + fun shippingAddress(shippingAddress: String?) = + shippingAddress(JsonField.ofNullable(shippingAddress)) + + /** Alias for calling [Builder.shippingAddress] with `shippingAddress.orElse(null)`. */ + fun shippingAddress(shippingAddress: Optional) = + shippingAddress(shippingAddress.getOrNull()) + + /** + * Sets [Builder.shippingAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.shippingAddress] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun shippingAddress(shippingAddress: JsonField) = apply { + this.shippingAddress = shippingAddress + } + + fun shippingAddressRecipient(shippingAddressRecipient: String?) = + shippingAddressRecipient(JsonField.ofNullable(shippingAddressRecipient)) + + /** + * Alias for calling [Builder.shippingAddressRecipient] with + * `shippingAddressRecipient.orElse(null)`. + */ + fun shippingAddressRecipient(shippingAddressRecipient: Optional) = + shippingAddressRecipient(shippingAddressRecipient.getOrNull()) + + /** + * Sets [Builder.shippingAddressRecipient] to an arbitrary JSON value. + * + * You should usually call [Builder.shippingAddressRecipient] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun shippingAddressRecipient(shippingAddressRecipient: JsonField) = apply { + this.shippingAddressRecipient = shippingAddressRecipient + } + + fun state(state: DocumentState) = state(JsonField.of(state)) + + /** + * Sets [Builder.state] to an arbitrary JSON value. + * + * You should usually call [Builder.state] with a well-typed [DocumentState] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun state(state: JsonField) = apply { this.state = state } + + /** + * The taxable base of the invoice. Should be the sum of all line items - allowances (for + * example commercial discounts) + charges with impact on VAT. Must be positive and rounded + * to maximum 2 decimals + */ + fun subtotal(subtotal: String?) = subtotal(JsonField.ofNullable(subtotal)) + + /** Alias for calling [Builder.subtotal] with `subtotal.orElse(null)`. */ + fun subtotal(subtotal: Optional) = subtotal(subtotal.getOrNull()) + + /** + * Sets [Builder.subtotal] to an arbitrary JSON value. + * + * You should usually call [Builder.subtotal] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun subtotal(subtotal: JsonField) = apply { this.subtotal = subtotal } + + /** Whether the PDF was successfully converted into a compliant e-invoice */ + fun success(success: Boolean) = success(JsonField.of(success)) + + /** + * Sets [Builder.success] to an arbitrary JSON value. + * + * You should usually call [Builder.success] with a well-typed [Boolean] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun success(success: JsonField) = apply { this.success = success } + + /** Tax category code of the invoice */ + fun taxCode(taxCode: TaxCode) = taxCode(JsonField.of(taxCode)) + + /** + * Sets [Builder.taxCode] to an arbitrary JSON value. + * + * You should usually call [Builder.taxCode] with a well-typed [TaxCode] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } + + fun taxDetails(taxDetails: List?) = taxDetails(JsonField.ofNullable(taxDetails)) + + /** Alias for calling [Builder.taxDetails] with `taxDetails.orElse(null)`. */ + fun taxDetails(taxDetails: Optional>) = taxDetails(taxDetails.getOrNull()) + + /** + * Sets [Builder.taxDetails] to an arbitrary JSON value. + * + * You should usually call [Builder.taxDetails] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun taxDetails(taxDetails: JsonField>) = apply { + this.taxDetails = taxDetails.map { it.toMutableList() } + } + + /** + * Adds a single [TaxDetail] to [taxDetails]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTaxDetail(taxDetail: TaxDetail) = apply { + taxDetails = + (taxDetails ?: JsonField.of(mutableListOf())).also { + checkKnown("taxDetails", it).add(taxDetail) + } + } + + /** + * The total financial discount of the invoice (so discounts not subject to VAT). Must be + * positive and rounded to maximum 2 decimals + */ + fun totalDiscount(totalDiscount: String?) = + totalDiscount(JsonField.ofNullable(totalDiscount)) + + /** Alias for calling [Builder.totalDiscount] with `totalDiscount.orElse(null)`. */ + fun totalDiscount(totalDiscount: Optional) = + totalDiscount(totalDiscount.getOrNull()) + + /** + * Sets [Builder.totalDiscount] to an arbitrary JSON value. + * + * You should usually call [Builder.totalDiscount] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun totalDiscount(totalDiscount: JsonField) = apply { + this.totalDiscount = totalDiscount + } + + /** The total tax of the invoice. Must be positive and rounded to maximum 2 decimals */ + fun totalTax(totalTax: String?) = totalTax(JsonField.ofNullable(totalTax)) + + /** Alias for calling [Builder.totalTax] with `totalTax.orElse(null)`. */ + fun totalTax(totalTax: Optional) = totalTax(totalTax.getOrNull()) + + /** + * Sets [Builder.totalTax] to an arbitrary JSON value. + * + * You should usually call [Builder.totalTax] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun totalTax(totalTax: JsonField) = apply { this.totalTax = totalTax } + + /** The UBL document as an XML string */ + fun ublDocument(ublDocument: String?) = ublDocument(JsonField.ofNullable(ublDocument)) + + /** Alias for calling [Builder.ublDocument] with `ublDocument.orElse(null)`. */ + fun ublDocument(ublDocument: Optional) = ublDocument(ublDocument.getOrNull()) + + /** + * Sets [Builder.ublDocument] to an arbitrary JSON value. + * + * You should usually call [Builder.ublDocument] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ublDocument(ublDocument: JsonField) = apply { this.ublDocument = ublDocument } + + /** + * VATEX code list for VAT exemption reasons + * + * Agency: CEF Identifier: vatex + */ + fun vatex(vatex: Vatex?) = vatex(JsonField.ofNullable(vatex)) + + /** Alias for calling [Builder.vatex] with `vatex.orElse(null)`. */ + fun vatex(vatex: Optional) = vatex(vatex.getOrNull()) + + /** + * Sets [Builder.vatex] to an arbitrary JSON value. + * + * You should usually call [Builder.vatex] with a well-typed [Vatex] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun vatex(vatex: JsonField) = apply { this.vatex = vatex } + + /** VAT exemption note of the invoice */ + fun vatexNote(vatexNote: String?) = vatexNote(JsonField.ofNullable(vatexNote)) + + /** Alias for calling [Builder.vatexNote] with `vatexNote.orElse(null)`. */ + fun vatexNote(vatexNote: Optional) = vatexNote(vatexNote.getOrNull()) + + /** + * Sets [Builder.vatexNote] to an arbitrary JSON value. + * + * You should usually call [Builder.vatexNote] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun vatexNote(vatexNote: JsonField) = apply { this.vatexNote = vatexNote } + + fun vendorAddress(vendorAddress: String?) = + vendorAddress(JsonField.ofNullable(vendorAddress)) + + /** Alias for calling [Builder.vendorAddress] with `vendorAddress.orElse(null)`. */ + fun vendorAddress(vendorAddress: Optional) = + vendorAddress(vendorAddress.getOrNull()) + + /** + * Sets [Builder.vendorAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.vendorAddress] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun vendorAddress(vendorAddress: JsonField) = apply { + this.vendorAddress = vendorAddress + } + + fun vendorAddressRecipient(vendorAddressRecipient: String?) = + vendorAddressRecipient(JsonField.ofNullable(vendorAddressRecipient)) + + /** + * Alias for calling [Builder.vendorAddressRecipient] with + * `vendorAddressRecipient.orElse(null)`. + */ + fun vendorAddressRecipient(vendorAddressRecipient: Optional) = + vendorAddressRecipient(vendorAddressRecipient.getOrNull()) + + /** + * Sets [Builder.vendorAddressRecipient] to an arbitrary JSON value. + * + * You should usually call [Builder.vendorAddressRecipient] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun vendorAddressRecipient(vendorAddressRecipient: JsonField) = apply { + this.vendorAddressRecipient = vendorAddressRecipient + } + + fun vendorEmail(vendorEmail: String?) = vendorEmail(JsonField.ofNullable(vendorEmail)) + + /** Alias for calling [Builder.vendorEmail] with `vendorEmail.orElse(null)`. */ + fun vendorEmail(vendorEmail: Optional) = vendorEmail(vendorEmail.getOrNull()) + + /** + * Sets [Builder.vendorEmail] to an arbitrary JSON value. + * + * You should usually call [Builder.vendorEmail] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun vendorEmail(vendorEmail: JsonField) = apply { this.vendorEmail = vendorEmail } + + fun vendorName(vendorName: String?) = vendorName(JsonField.ofNullable(vendorName)) + + /** Alias for calling [Builder.vendorName] with `vendorName.orElse(null)`. */ + fun vendorName(vendorName: Optional) = vendorName(vendorName.getOrNull()) + + /** + * Sets [Builder.vendorName] to an arbitrary JSON value. + * + * You should usually call [Builder.vendorName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun vendorName(vendorName: JsonField) = apply { this.vendorName = vendorName } + + fun vendorTaxId(vendorTaxId: String?) = vendorTaxId(JsonField.ofNullable(vendorTaxId)) + + /** Alias for calling [Builder.vendorTaxId] with `vendorTaxId.orElse(null)`. */ + fun vendorTaxId(vendorTaxId: Optional) = vendorTaxId(vendorTaxId.getOrNull()) + + /** + * Sets [Builder.vendorTaxId] to an arbitrary JSON value. + * + * You should usually call [Builder.vendorTaxId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun vendorTaxId(vendorTaxId: JsonField) = apply { this.vendorTaxId = vendorTaxId } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [DocumentCreateFromPdfResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DocumentCreateFromPdfResponse = + DocumentCreateFromPdfResponse( + (allowances ?: JsonMissing.of()).map { it.toImmutable() }, + amountDue, + (attachments ?: JsonMissing.of()).map { it.toImmutable() }, + billingAddress, + billingAddressRecipient, + (charges ?: JsonMissing.of()).map { it.toImmutable() }, + currency, + customerAddress, + customerAddressRecipient, + customerEmail, + customerId, + customerName, + customerTaxId, + direction, + documentType, + dueDate, + invoiceDate, + invoiceId, + invoiceTotal, + (items ?: JsonMissing.of()).map { it.toImmutable() }, + note, + (paymentDetails ?: JsonMissing.of()).map { it.toImmutable() }, + paymentTerm, + previousUnpaidBalance, + purchaseOrder, + remittanceAddress, + remittanceAddressRecipient, + serviceAddress, + serviceAddressRecipient, + serviceEndDate, + serviceStartDate, + shippingAddress, + shippingAddressRecipient, + state, + subtotal, + success, + taxCode, + (taxDetails ?: JsonMissing.of()).map { it.toImmutable() }, + totalDiscount, + totalTax, + ublDocument, + vatex, + vatexNote, + vendorAddress, + vendorAddressRecipient, + vendorEmail, + vendorName, + vendorTaxId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): DocumentCreateFromPdfResponse = apply { + if (validated) { + return@apply + } + + allowances().ifPresent { it.forEach { it.validate() } } + amountDue() + attachments().ifPresent { it.forEach { it.validate() } } + billingAddress() + billingAddressRecipient() + charges().ifPresent { it.forEach { it.validate() } } + currency().ifPresent { it.validate() } + customerAddress() + customerAddressRecipient() + customerEmail() + customerId() + customerName() + customerTaxId() + direction().ifPresent { it.validate() } + documentType().ifPresent { it.validate() } + dueDate() + invoiceDate() + invoiceId() + invoiceTotal() + items().ifPresent { it.forEach { it.validate() } } + note() + paymentDetails().ifPresent { it.forEach { it.validate() } } + paymentTerm() + previousUnpaidBalance() + purchaseOrder() + remittanceAddress() + remittanceAddressRecipient() + serviceAddress() + serviceAddressRecipient() + serviceEndDate() + serviceStartDate() + shippingAddress() + shippingAddressRecipient() + state().ifPresent { it.validate() } + subtotal() + success() + taxCode().ifPresent { it.validate() } + taxDetails().ifPresent { it.forEach { it.validate() } } + totalDiscount() + totalTax() + ublDocument() + vatex().ifPresent { it.validate() } + vatexNote() + vendorAddress() + vendorAddressRecipient() + vendorEmail() + vendorName() + vendorTaxId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (allowances.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (amountDue.asKnown().isPresent) 1 else 0) + + (attachments.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (billingAddress.asKnown().isPresent) 1 else 0) + + (if (billingAddressRecipient.asKnown().isPresent) 1 else 0) + + (charges.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (currency.asKnown().getOrNull()?.validity() ?: 0) + + (if (customerAddress.asKnown().isPresent) 1 else 0) + + (if (customerAddressRecipient.asKnown().isPresent) 1 else 0) + + (if (customerEmail.asKnown().isPresent) 1 else 0) + + (if (customerId.asKnown().isPresent) 1 else 0) + + (if (customerName.asKnown().isPresent) 1 else 0) + + (if (customerTaxId.asKnown().isPresent) 1 else 0) + + (direction.asKnown().getOrNull()?.validity() ?: 0) + + (documentType.asKnown().getOrNull()?.validity() ?: 0) + + (if (dueDate.asKnown().isPresent) 1 else 0) + + (if (invoiceDate.asKnown().isPresent) 1 else 0) + + (if (invoiceId.asKnown().isPresent) 1 else 0) + + (if (invoiceTotal.asKnown().isPresent) 1 else 0) + + (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (note.asKnown().isPresent) 1 else 0) + + (paymentDetails.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (paymentTerm.asKnown().isPresent) 1 else 0) + + (if (previousUnpaidBalance.asKnown().isPresent) 1 else 0) + + (if (purchaseOrder.asKnown().isPresent) 1 else 0) + + (if (remittanceAddress.asKnown().isPresent) 1 else 0) + + (if (remittanceAddressRecipient.asKnown().isPresent) 1 else 0) + + (if (serviceAddress.asKnown().isPresent) 1 else 0) + + (if (serviceAddressRecipient.asKnown().isPresent) 1 else 0) + + (if (serviceEndDate.asKnown().isPresent) 1 else 0) + + (if (serviceStartDate.asKnown().isPresent) 1 else 0) + + (if (shippingAddress.asKnown().isPresent) 1 else 0) + + (if (shippingAddressRecipient.asKnown().isPresent) 1 else 0) + + (state.asKnown().getOrNull()?.validity() ?: 0) + + (if (subtotal.asKnown().isPresent) 1 else 0) + + (if (success.asKnown().isPresent) 1 else 0) + + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + + (taxDetails.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (totalDiscount.asKnown().isPresent) 1 else 0) + + (if (totalTax.asKnown().isPresent) 1 else 0) + + (if (ublDocument.asKnown().isPresent) 1 else 0) + + (vatex.asKnown().getOrNull()?.validity() ?: 0) + + (if (vatexNote.asKnown().isPresent) 1 else 0) + + (if (vendorAddress.asKnown().isPresent) 1 else 0) + + (if (vendorAddressRecipient.asKnown().isPresent) 1 else 0) + + (if (vendorEmail.asKnown().isPresent) 1 else 0) + + (if (vendorName.asKnown().isPresent) 1 else 0) + + (if (vendorTaxId.asKnown().isPresent) 1 else 0) + + class Item + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allowances: JsonField>, + private val amount: JsonField, + private val charges: JsonField>, + private val date: JsonField, + private val description: JsonField, + private val productCode: JsonField, + private val quantity: JsonField, + private val tax: JsonField, + private val taxRate: JsonField, + private val unit: JsonField, + private val unitPrice: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allowances") + @ExcludeMissing + allowances: JsonField> = JsonMissing.of(), + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("charges") + @ExcludeMissing + charges: JsonField> = JsonMissing.of(), + @JsonProperty("date") @ExcludeMissing date: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("product_code") + @ExcludeMissing + productCode: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + @JsonProperty("tax") @ExcludeMissing tax: JsonField = JsonMissing.of(), + @JsonProperty("tax_rate") @ExcludeMissing taxRate: JsonField = JsonMissing.of(), + @JsonProperty("unit") + @ExcludeMissing + unit: JsonField = JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + ) : this( + allowances, + amount, + charges, + date, + description, + productCode, + quantity, + tax, + taxRate, + unit, + unitPrice, + mutableMapOf(), + ) + + /** + * The allowances of the line item. + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun allowances(): Optional> = allowances.getOptional("allowances") + + /** + * The total amount of the line item, exclusive of VAT, after subtracting line level + * allowances and adding line level charges. Must be rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * The charges of the line item. + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun charges(): Optional> = charges.getOptional("charges") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun date(): Optional = date.getOptional("date") + + /** + * The description of the line item. + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * The product code of the line item. + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun productCode(): Optional = productCode.getOptional("product_code") + + /** + * The quantity of items (goods or services) that is the subject of the line item. Must be + * rounded to maximum 4 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun quantity(): Optional = quantity.getOptional("quantity") + + /** + * The total VAT amount for the line item. Must be rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tax(): Optional = tax.getOptional("tax") + + /** + * The VAT rate of the line item expressed as percentage with 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun taxRate(): Optional = taxRate.getOptional("tax_rate") + + /** + * Unit of Measure Codes from UNECERec20 used in Peppol BIS Billing 3.0. + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun unit(): Optional = unit.getOptional("unit") + + /** + * The unit price of the line item. Must be rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun unitPrice(): Optional = unitPrice.getOptional("unit_price") + + /** + * Returns the raw JSON value of [allowances]. + * + * Unlike [allowances], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("allowances") + @ExcludeMissing + fun _allowances(): JsonField> = allowances + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [charges]. + * + * Unlike [charges], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("charges") @ExcludeMissing fun _charges(): JsonField> = charges + + /** + * Returns the raw JSON value of [date]. + * + * Unlike [date], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("date") @ExcludeMissing fun _date(): JsonField = date + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [productCode]. + * + * Unlike [productCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("product_code") + @ExcludeMissing + fun _productCode(): JsonField = productCode + + /** + * Returns the raw JSON value of [quantity]. + * + * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity + + /** + * Returns the raw JSON value of [tax]. + * + * Unlike [tax], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax") @ExcludeMissing fun _tax(): JsonField = tax + + /** + * Returns the raw JSON value of [taxRate]. + * + * Unlike [taxRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate + + /** + * Returns the raw JSON value of [unit]. + * + * Unlike [unit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit + + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("unit_price") @ExcludeMissing fun _unitPrice(): JsonField = unitPrice + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Item]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Item]. */ + class Builder internal constructor() { + + private var allowances: JsonField>? = null + private var amount: JsonField = JsonMissing.of() + private var charges: JsonField>? = null + private var date: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var productCode: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var tax: JsonField = JsonMissing.of() + private var taxRate: JsonField = JsonMissing.of() + private var unit: JsonField = JsonMissing.of() + private var unitPrice: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(item: Item) = apply { + allowances = item.allowances.map { it.toMutableList() } + amount = item.amount + charges = item.charges.map { it.toMutableList() } + date = item.date + description = item.description + productCode = item.productCode + quantity = item.quantity + tax = item.tax + taxRate = item.taxRate + unit = item.unit + unitPrice = item.unitPrice + additionalProperties = item.additionalProperties.toMutableMap() + } + + /** The allowances of the line item. */ + fun allowances(allowances: List?) = + allowances(JsonField.ofNullable(allowances)) + + /** Alias for calling [Builder.allowances] with `allowances.orElse(null)`. */ + fun allowances(allowances: Optional>) = + allowances(allowances.getOrNull()) + + /** + * Sets [Builder.allowances] to an arbitrary JSON value. + * + * You should usually call [Builder.allowances] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun allowances(allowances: JsonField>) = apply { + this.allowances = allowances.map { it.toMutableList() } + } + + /** + * Adds a single [Allowance] to [allowances]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowance(allowance: Allowance) = apply { + allowances = + (allowances ?: JsonField.of(mutableListOf())).also { + checkKnown("allowances", it).add(allowance) + } + } + + /** + * The total amount of the line item, exclusive of VAT, after subtracting line level + * allowances and adding line level charges. Must be rounded to maximum 2 decimals + */ + fun amount(amount: String?) = amount(JsonField.ofNullable(amount)) + + /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ + fun amount(amount: Optional) = amount(amount.getOrNull()) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The charges of the line item. */ + fun charges(charges: List?) = charges(JsonField.ofNullable(charges)) + + /** Alias for calling [Builder.charges] with `charges.orElse(null)`. */ + fun charges(charges: Optional>) = charges(charges.getOrNull()) + + /** + * Sets [Builder.charges] to an arbitrary JSON value. + * + * You should usually call [Builder.charges] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun charges(charges: JsonField>) = apply { + this.charges = charges.map { it.toMutableList() } + } + + /** + * Adds a single [Charge] to [charges]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCharge(charge: Charge) = apply { + charges = + (charges ?: JsonField.of(mutableListOf())).also { + checkKnown("charges", it).add(charge) + } + } + + fun date(date: Void?) = date(JsonField.ofNullable(date)) + + /** Alias for calling [Builder.date] with `date.orElse(null)`. */ + fun date(date: Optional) = date(date.getOrNull()) + + /** + * Sets [Builder.date] to an arbitrary JSON value. + * + * You should usually call [Builder.date] with a well-typed [Void] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun date(date: JsonField) = apply { this.date = date } + + /** The description of the line item. */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** The product code of the line item. */ + fun productCode(productCode: String?) = productCode(JsonField.ofNullable(productCode)) + + /** Alias for calling [Builder.productCode] with `productCode.orElse(null)`. */ + fun productCode(productCode: Optional) = productCode(productCode.getOrNull()) + + /** + * Sets [Builder.productCode] to an arbitrary JSON value. + * + * You should usually call [Builder.productCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun productCode(productCode: JsonField) = apply { + this.productCode = productCode + } + + /** + * The quantity of items (goods or services) that is the subject of the line item. Must + * be rounded to maximum 4 decimals + */ + fun quantity(quantity: String?) = quantity(JsonField.ofNullable(quantity)) + + /** Alias for calling [Builder.quantity] with `quantity.orElse(null)`. */ + fun quantity(quantity: Optional) = quantity(quantity.getOrNull()) + + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + /** The total VAT amount for the line item. Must be rounded to maximum 2 decimals */ + fun tax(tax: String?) = tax(JsonField.ofNullable(tax)) + + /** Alias for calling [Builder.tax] with `tax.orElse(null)`. */ + fun tax(tax: Optional) = tax(tax.getOrNull()) + + /** + * Sets [Builder.tax] to an arbitrary JSON value. + * + * You should usually call [Builder.tax] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tax(tax: JsonField) = apply { this.tax = tax } + + /** The VAT rate of the line item expressed as percentage with 2 decimals */ + fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) + + /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ + fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) + + /** + * Sets [Builder.taxRate] to an arbitrary JSON value. + * + * You should usually call [Builder.taxRate] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } + + /** Unit of Measure Codes from UNECERec20 used in Peppol BIS Billing 3.0. */ + fun unit(unit: UnitOfMeasureCode?) = unit(JsonField.ofNullable(unit)) + + /** Alias for calling [Builder.unit] with `unit.orElse(null)`. */ + fun unit(unit: Optional) = unit(unit.getOrNull()) + + /** + * Sets [Builder.unit] to an arbitrary JSON value. + * + * You should usually call [Builder.unit] with a well-typed [UnitOfMeasureCode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun unit(unit: JsonField) = apply { this.unit = unit } + + /** The unit price of the line item. Must be rounded to maximum 2 decimals */ + fun unitPrice(unitPrice: String?) = unitPrice(JsonField.ofNullable(unitPrice)) + + /** Alias for calling [Builder.unitPrice] with `unitPrice.orElse(null)`. */ + fun unitPrice(unitPrice: Optional) = unitPrice(unitPrice.getOrNull()) + + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Item]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Item = + Item( + (allowances ?: JsonMissing.of()).map { it.toImmutable() }, + amount, + (charges ?: JsonMissing.of()).map { it.toImmutable() }, + date, + description, + productCode, + quantity, + tax, + taxRate, + unit, + unitPrice, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Item = apply { + if (validated) { + return@apply + } + + allowances().ifPresent { it.forEach { it.validate() } } + amount() + charges().ifPresent { it.forEach { it.validate() } } + date() + description() + productCode() + quantity() + tax() + taxRate() + unit().ifPresent { it.validate() } + unitPrice() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (allowances.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (charges.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (date.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (productCode.asKnown().isPresent) 1 else 0) + + (if (quantity.asKnown().isPresent) 1 else 0) + + (if (tax.asKnown().isPresent) 1 else 0) + + (if (taxRate.asKnown().isPresent) 1 else 0) + + (unit.asKnown().getOrNull()?.validity() ?: 0) + + (if (unitPrice.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Item && + allowances == other.allowances && + amount == other.amount && + charges == other.charges && + date == other.date && + description == other.description && + productCode == other.productCode && + quantity == other.quantity && + tax == other.tax && + taxRate == other.taxRate && + unit == other.unit && + unitPrice == other.unitPrice && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + allowances, + amount, + charges, + date, + description, + productCode, + quantity, + tax, + taxRate, + unit, + unitPrice, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Item{allowances=$allowances, amount=$amount, charges=$charges, date=$date, description=$description, productCode=$productCode, quantity=$quantity, tax=$tax, taxRate=$taxRate, unit=$unit, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" + } + + /** Tax category code of the invoice */ + class TaxCode @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val AE = of("AE") + + @JvmField val E = of("E") + + @JvmField val S = of("S") + + @JvmField val Z = of("Z") + + @JvmField val G = of("G") + + @JvmField val O = of("O") + + @JvmField val K = of("K") + + @JvmField val L = of("L") + + @JvmField val M = of("M") + + @JvmField val B = of("B") + + @JvmStatic fun of(value: String) = TaxCode(JsonField.of(value)) + } + + /** An enum containing [TaxCode]'s known values. */ + enum class Known { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + } + + /** + * An enum containing [TaxCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TaxCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + /** An enum member indicating that [TaxCode] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AE -> Value.AE + E -> Value.E + S -> Value.S + Z -> Value.Z + G -> Value.G + O -> Value.O + K -> Value.K + L -> Value.L + M -> Value.M + B -> Value.B + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + AE -> Known.AE + E -> Known.E + S -> Known.S + Z -> Known.Z + G -> Known.G + O -> Known.O + K -> Known.K + L -> Known.L + M -> Known.M + B -> Known.B + else -> throw EInvoiceInvalidDataException("Unknown TaxCode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TaxCode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TaxCode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class TaxDetail + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val rate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("rate") @ExcludeMissing rate: JsonField = JsonMissing.of(), + ) : this(amount, rate, mutableMapOf()) + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun rate(): Optional = rate.getOptional("rate") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [rate]. + * + * Unlike [rate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rate") @ExcludeMissing fun _rate(): JsonField = rate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [TaxDetail]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TaxDetail]. */ + class Builder internal constructor() { + + private var amount: JsonField = JsonMissing.of() + private var rate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(taxDetail: TaxDetail) = apply { + amount = taxDetail.amount + rate = taxDetail.rate + additionalProperties = taxDetail.additionalProperties.toMutableMap() + } + + fun amount(amount: String?) = amount(JsonField.ofNullable(amount)) + + /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ + fun amount(amount: Optional) = amount(amount.getOrNull()) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + fun rate(rate: String?) = rate(JsonField.ofNullable(rate)) + + /** Alias for calling [Builder.rate] with `rate.orElse(null)`. */ + fun rate(rate: Optional) = rate(rate.getOrNull()) + + /** + * Sets [Builder.rate] to an arbitrary JSON value. + * + * You should usually call [Builder.rate] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun rate(rate: JsonField) = apply { this.rate = rate } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [TaxDetail]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TaxDetail = TaxDetail(amount, rate, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): TaxDetail = apply { + if (validated) { + return@apply + } + + amount() + rate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + (if (rate.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TaxDetail && + amount == other.amount && + rate == other.rate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(amount, rate, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TaxDetail{amount=$amount, rate=$rate, additionalProperties=$additionalProperties}" + } + + /** + * VATEX code list for VAT exemption reasons + * + * Agency: CEF Identifier: vatex + */ + class Vatex @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val VATEX_EU_79_C = of("VATEX-EU-79-C") + + @JvmField val VATEX_EU_132 = of("VATEX-EU-132") + + @JvmField val VATEX_EU_132_1_A = of("VATEX-EU-132-1A") + + @JvmField val VATEX_EU_132_1_B = of("VATEX-EU-132-1B") + + @JvmField val VATEX_EU_132_1_C = of("VATEX-EU-132-1C") + + @JvmField val VATEX_EU_132_1_D = of("VATEX-EU-132-1D") + + @JvmField val VATEX_EU_132_1_E = of("VATEX-EU-132-1E") + + @JvmField val VATEX_EU_132_1_F = of("VATEX-EU-132-1F") + + @JvmField val VATEX_EU_132_1_G = of("VATEX-EU-132-1G") + + @JvmField val VATEX_EU_132_1_H = of("VATEX-EU-132-1H") + + @JvmField val VATEX_EU_132_1_I = of("VATEX-EU-132-1I") + + @JvmField val VATEX_EU_132_1_J = of("VATEX-EU-132-1J") + + @JvmField val VATEX_EU_132_1_K = of("VATEX-EU-132-1K") + + @JvmField val VATEX_EU_132_1_L = of("VATEX-EU-132-1L") + + @JvmField val VATEX_EU_132_1_M = of("VATEX-EU-132-1M") + + @JvmField val VATEX_EU_132_1_N = of("VATEX-EU-132-1N") + + @JvmField val VATEX_EU_132_1_O = of("VATEX-EU-132-1O") + + @JvmField val VATEX_EU_132_1_P = of("VATEX-EU-132-1P") + + @JvmField val VATEX_EU_132_1_Q = of("VATEX-EU-132-1Q") + + @JvmField val VATEX_EU_143 = of("VATEX-EU-143") + + @JvmField val VATEX_EU_143_1_A = of("VATEX-EU-143-1A") + + @JvmField val VATEX_EU_143_1_B = of("VATEX-EU-143-1B") + + @JvmField val VATEX_EU_143_1_C = of("VATEX-EU-143-1C") + + @JvmField val VATEX_EU_143_1_D = of("VATEX-EU-143-1D") + + @JvmField val VATEX_EU_143_1_E = of("VATEX-EU-143-1E") + + @JvmField val VATEX_EU_143_1_F = of("VATEX-EU-143-1F") + + @JvmField val VATEX_EU_143_1_FA = of("VATEX-EU-143-1FA") + + @JvmField val VATEX_EU_143_1_G = of("VATEX-EU-143-1G") + + @JvmField val VATEX_EU_143_1_H = of("VATEX-EU-143-1H") + + @JvmField val VATEX_EU_143_1_I = of("VATEX-EU-143-1I") + + @JvmField val VATEX_EU_143_1_J = of("VATEX-EU-143-1J") + + @JvmField val VATEX_EU_143_1_K = of("VATEX-EU-143-1K") + + @JvmField val VATEX_EU_143_1_L = of("VATEX-EU-143-1L") + + @JvmField val VATEX_EU_144 = of("VATEX-EU-144") + + @JvmField val VATEX_EU_146_1_E = of("VATEX-EU-146-1E") + + @JvmField val VATEX_EU_148 = of("VATEX-EU-148") + + @JvmField val VATEX_EU_148_A = of("VATEX-EU-148-A") + + @JvmField val VATEX_EU_148_B = of("VATEX-EU-148-B") + + @JvmField val VATEX_EU_148_C = of("VATEX-EU-148-C") + + @JvmField val VATEX_EU_148_D = of("VATEX-EU-148-D") + + @JvmField val VATEX_EU_148_E = of("VATEX-EU-148-E") + + @JvmField val VATEX_EU_148_F = of("VATEX-EU-148-F") + + @JvmField val VATEX_EU_148_G = of("VATEX-EU-148-G") + + @JvmField val VATEX_EU_151 = of("VATEX-EU-151") + + @JvmField val VATEX_EU_151_1_A = of("VATEX-EU-151-1A") + + @JvmField val VATEX_EU_151_1_AA = of("VATEX-EU-151-1AA") + + @JvmField val VATEX_EU_151_1_B = of("VATEX-EU-151-1B") + + @JvmField val VATEX_EU_151_1_C = of("VATEX-EU-151-1C") + + @JvmField val VATEX_EU_151_1_D = of("VATEX-EU-151-1D") + + @JvmField val VATEX_EU_151_1_E = of("VATEX-EU-151-1E") + + @JvmField val VATEX_EU_159 = of("VATEX-EU-159") + + @JvmField val VATEX_EU_309 = of("VATEX-EU-309") + + @JvmField val VATEX_EU_AE = of("VATEX-EU-AE") + + @JvmField val VATEX_EU_D = of("VATEX-EU-D") + + @JvmField val VATEX_EU_F = of("VATEX-EU-F") + + @JvmField val VATEX_EU_G = of("VATEX-EU-G") + + @JvmField val VATEX_EU_I = of("VATEX-EU-I") + + @JvmField val VATEX_EU_IC = of("VATEX-EU-IC") + + @JvmField val VATEX_EU_O = of("VATEX-EU-O") + + @JvmField val VATEX_EU_J = of("VATEX-EU-J") + + @JvmField val VATEX_FR_FRANCHISE = of("VATEX-FR-FRANCHISE") + + @JvmField val VATEX_FR_CNWVAT = of("VATEX-FR-CNWVAT") + + @JvmStatic fun of(value: String) = Vatex(JsonField.of(value)) + } + + /** An enum containing [Vatex]'s known values. */ + enum class Known { + VATEX_EU_79_C, + VATEX_EU_132, + VATEX_EU_132_1_A, + VATEX_EU_132_1_B, + VATEX_EU_132_1_C, + VATEX_EU_132_1_D, + VATEX_EU_132_1_E, + VATEX_EU_132_1_F, + VATEX_EU_132_1_G, + VATEX_EU_132_1_H, + VATEX_EU_132_1_I, + VATEX_EU_132_1_J, + VATEX_EU_132_1_K, + VATEX_EU_132_1_L, + VATEX_EU_132_1_M, + VATEX_EU_132_1_N, + VATEX_EU_132_1_O, + VATEX_EU_132_1_P, + VATEX_EU_132_1_Q, + VATEX_EU_143, + VATEX_EU_143_1_A, + VATEX_EU_143_1_B, + VATEX_EU_143_1_C, + VATEX_EU_143_1_D, + VATEX_EU_143_1_E, + VATEX_EU_143_1_F, + VATEX_EU_143_1_FA, + VATEX_EU_143_1_G, + VATEX_EU_143_1_H, + VATEX_EU_143_1_I, + VATEX_EU_143_1_J, + VATEX_EU_143_1_K, + VATEX_EU_143_1_L, + VATEX_EU_144, + VATEX_EU_146_1_E, + VATEX_EU_148, + VATEX_EU_148_A, + VATEX_EU_148_B, + VATEX_EU_148_C, + VATEX_EU_148_D, + VATEX_EU_148_E, + VATEX_EU_148_F, + VATEX_EU_148_G, + VATEX_EU_151, + VATEX_EU_151_1_A, + VATEX_EU_151_1_AA, + VATEX_EU_151_1_B, + VATEX_EU_151_1_C, + VATEX_EU_151_1_D, + VATEX_EU_151_1_E, + VATEX_EU_159, + VATEX_EU_309, + VATEX_EU_AE, + VATEX_EU_D, + VATEX_EU_F, + VATEX_EU_G, + VATEX_EU_I, + VATEX_EU_IC, + VATEX_EU_O, + VATEX_EU_J, + VATEX_FR_FRANCHISE, + VATEX_FR_CNWVAT, + } + + /** + * An enum containing [Vatex]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Vatex] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + VATEX_EU_79_C, + VATEX_EU_132, + VATEX_EU_132_1_A, + VATEX_EU_132_1_B, + VATEX_EU_132_1_C, + VATEX_EU_132_1_D, + VATEX_EU_132_1_E, + VATEX_EU_132_1_F, + VATEX_EU_132_1_G, + VATEX_EU_132_1_H, + VATEX_EU_132_1_I, + VATEX_EU_132_1_J, + VATEX_EU_132_1_K, + VATEX_EU_132_1_L, + VATEX_EU_132_1_M, + VATEX_EU_132_1_N, + VATEX_EU_132_1_O, + VATEX_EU_132_1_P, + VATEX_EU_132_1_Q, + VATEX_EU_143, + VATEX_EU_143_1_A, + VATEX_EU_143_1_B, + VATEX_EU_143_1_C, + VATEX_EU_143_1_D, + VATEX_EU_143_1_E, + VATEX_EU_143_1_F, + VATEX_EU_143_1_FA, + VATEX_EU_143_1_G, + VATEX_EU_143_1_H, + VATEX_EU_143_1_I, + VATEX_EU_143_1_J, + VATEX_EU_143_1_K, + VATEX_EU_143_1_L, + VATEX_EU_144, + VATEX_EU_146_1_E, + VATEX_EU_148, + VATEX_EU_148_A, + VATEX_EU_148_B, + VATEX_EU_148_C, + VATEX_EU_148_D, + VATEX_EU_148_E, + VATEX_EU_148_F, + VATEX_EU_148_G, + VATEX_EU_151, + VATEX_EU_151_1_A, + VATEX_EU_151_1_AA, + VATEX_EU_151_1_B, + VATEX_EU_151_1_C, + VATEX_EU_151_1_D, + VATEX_EU_151_1_E, + VATEX_EU_159, + VATEX_EU_309, + VATEX_EU_AE, + VATEX_EU_D, + VATEX_EU_F, + VATEX_EU_G, + VATEX_EU_I, + VATEX_EU_IC, + VATEX_EU_O, + VATEX_EU_J, + VATEX_FR_FRANCHISE, + VATEX_FR_CNWVAT, + /** An enum member indicating that [Vatex] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + VATEX_EU_79_C -> Value.VATEX_EU_79_C + VATEX_EU_132 -> Value.VATEX_EU_132 + VATEX_EU_132_1_A -> Value.VATEX_EU_132_1_A + VATEX_EU_132_1_B -> Value.VATEX_EU_132_1_B + VATEX_EU_132_1_C -> Value.VATEX_EU_132_1_C + VATEX_EU_132_1_D -> Value.VATEX_EU_132_1_D + VATEX_EU_132_1_E -> Value.VATEX_EU_132_1_E + VATEX_EU_132_1_F -> Value.VATEX_EU_132_1_F + VATEX_EU_132_1_G -> Value.VATEX_EU_132_1_G + VATEX_EU_132_1_H -> Value.VATEX_EU_132_1_H + VATEX_EU_132_1_I -> Value.VATEX_EU_132_1_I + VATEX_EU_132_1_J -> Value.VATEX_EU_132_1_J + VATEX_EU_132_1_K -> Value.VATEX_EU_132_1_K + VATEX_EU_132_1_L -> Value.VATEX_EU_132_1_L + VATEX_EU_132_1_M -> Value.VATEX_EU_132_1_M + VATEX_EU_132_1_N -> Value.VATEX_EU_132_1_N + VATEX_EU_132_1_O -> Value.VATEX_EU_132_1_O + VATEX_EU_132_1_P -> Value.VATEX_EU_132_1_P + VATEX_EU_132_1_Q -> Value.VATEX_EU_132_1_Q + VATEX_EU_143 -> Value.VATEX_EU_143 + VATEX_EU_143_1_A -> Value.VATEX_EU_143_1_A + VATEX_EU_143_1_B -> Value.VATEX_EU_143_1_B + VATEX_EU_143_1_C -> Value.VATEX_EU_143_1_C + VATEX_EU_143_1_D -> Value.VATEX_EU_143_1_D + VATEX_EU_143_1_E -> Value.VATEX_EU_143_1_E + VATEX_EU_143_1_F -> Value.VATEX_EU_143_1_F + VATEX_EU_143_1_FA -> Value.VATEX_EU_143_1_FA + VATEX_EU_143_1_G -> Value.VATEX_EU_143_1_G + VATEX_EU_143_1_H -> Value.VATEX_EU_143_1_H + VATEX_EU_143_1_I -> Value.VATEX_EU_143_1_I + VATEX_EU_143_1_J -> Value.VATEX_EU_143_1_J + VATEX_EU_143_1_K -> Value.VATEX_EU_143_1_K + VATEX_EU_143_1_L -> Value.VATEX_EU_143_1_L + VATEX_EU_144 -> Value.VATEX_EU_144 + VATEX_EU_146_1_E -> Value.VATEX_EU_146_1_E + VATEX_EU_148 -> Value.VATEX_EU_148 + VATEX_EU_148_A -> Value.VATEX_EU_148_A + VATEX_EU_148_B -> Value.VATEX_EU_148_B + VATEX_EU_148_C -> Value.VATEX_EU_148_C + VATEX_EU_148_D -> Value.VATEX_EU_148_D + VATEX_EU_148_E -> Value.VATEX_EU_148_E + VATEX_EU_148_F -> Value.VATEX_EU_148_F + VATEX_EU_148_G -> Value.VATEX_EU_148_G + VATEX_EU_151 -> Value.VATEX_EU_151 + VATEX_EU_151_1_A -> Value.VATEX_EU_151_1_A + VATEX_EU_151_1_AA -> Value.VATEX_EU_151_1_AA + VATEX_EU_151_1_B -> Value.VATEX_EU_151_1_B + VATEX_EU_151_1_C -> Value.VATEX_EU_151_1_C + VATEX_EU_151_1_D -> Value.VATEX_EU_151_1_D + VATEX_EU_151_1_E -> Value.VATEX_EU_151_1_E + VATEX_EU_159 -> Value.VATEX_EU_159 + VATEX_EU_309 -> Value.VATEX_EU_309 + VATEX_EU_AE -> Value.VATEX_EU_AE + VATEX_EU_D -> Value.VATEX_EU_D + VATEX_EU_F -> Value.VATEX_EU_F + VATEX_EU_G -> Value.VATEX_EU_G + VATEX_EU_I -> Value.VATEX_EU_I + VATEX_EU_IC -> Value.VATEX_EU_IC + VATEX_EU_O -> Value.VATEX_EU_O + VATEX_EU_J -> Value.VATEX_EU_J + VATEX_FR_FRANCHISE -> Value.VATEX_FR_FRANCHISE + VATEX_FR_CNWVAT -> Value.VATEX_FR_CNWVAT + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + VATEX_EU_79_C -> Known.VATEX_EU_79_C + VATEX_EU_132 -> Known.VATEX_EU_132 + VATEX_EU_132_1_A -> Known.VATEX_EU_132_1_A + VATEX_EU_132_1_B -> Known.VATEX_EU_132_1_B + VATEX_EU_132_1_C -> Known.VATEX_EU_132_1_C + VATEX_EU_132_1_D -> Known.VATEX_EU_132_1_D + VATEX_EU_132_1_E -> Known.VATEX_EU_132_1_E + VATEX_EU_132_1_F -> Known.VATEX_EU_132_1_F + VATEX_EU_132_1_G -> Known.VATEX_EU_132_1_G + VATEX_EU_132_1_H -> Known.VATEX_EU_132_1_H + VATEX_EU_132_1_I -> Known.VATEX_EU_132_1_I + VATEX_EU_132_1_J -> Known.VATEX_EU_132_1_J + VATEX_EU_132_1_K -> Known.VATEX_EU_132_1_K + VATEX_EU_132_1_L -> Known.VATEX_EU_132_1_L + VATEX_EU_132_1_M -> Known.VATEX_EU_132_1_M + VATEX_EU_132_1_N -> Known.VATEX_EU_132_1_N + VATEX_EU_132_1_O -> Known.VATEX_EU_132_1_O + VATEX_EU_132_1_P -> Known.VATEX_EU_132_1_P + VATEX_EU_132_1_Q -> Known.VATEX_EU_132_1_Q + VATEX_EU_143 -> Known.VATEX_EU_143 + VATEX_EU_143_1_A -> Known.VATEX_EU_143_1_A + VATEX_EU_143_1_B -> Known.VATEX_EU_143_1_B + VATEX_EU_143_1_C -> Known.VATEX_EU_143_1_C + VATEX_EU_143_1_D -> Known.VATEX_EU_143_1_D + VATEX_EU_143_1_E -> Known.VATEX_EU_143_1_E + VATEX_EU_143_1_F -> Known.VATEX_EU_143_1_F + VATEX_EU_143_1_FA -> Known.VATEX_EU_143_1_FA + VATEX_EU_143_1_G -> Known.VATEX_EU_143_1_G + VATEX_EU_143_1_H -> Known.VATEX_EU_143_1_H + VATEX_EU_143_1_I -> Known.VATEX_EU_143_1_I + VATEX_EU_143_1_J -> Known.VATEX_EU_143_1_J + VATEX_EU_143_1_K -> Known.VATEX_EU_143_1_K + VATEX_EU_143_1_L -> Known.VATEX_EU_143_1_L + VATEX_EU_144 -> Known.VATEX_EU_144 + VATEX_EU_146_1_E -> Known.VATEX_EU_146_1_E + VATEX_EU_148 -> Known.VATEX_EU_148 + VATEX_EU_148_A -> Known.VATEX_EU_148_A + VATEX_EU_148_B -> Known.VATEX_EU_148_B + VATEX_EU_148_C -> Known.VATEX_EU_148_C + VATEX_EU_148_D -> Known.VATEX_EU_148_D + VATEX_EU_148_E -> Known.VATEX_EU_148_E + VATEX_EU_148_F -> Known.VATEX_EU_148_F + VATEX_EU_148_G -> Known.VATEX_EU_148_G + VATEX_EU_151 -> Known.VATEX_EU_151 + VATEX_EU_151_1_A -> Known.VATEX_EU_151_1_A + VATEX_EU_151_1_AA -> Known.VATEX_EU_151_1_AA + VATEX_EU_151_1_B -> Known.VATEX_EU_151_1_B + VATEX_EU_151_1_C -> Known.VATEX_EU_151_1_C + VATEX_EU_151_1_D -> Known.VATEX_EU_151_1_D + VATEX_EU_151_1_E -> Known.VATEX_EU_151_1_E + VATEX_EU_159 -> Known.VATEX_EU_159 + VATEX_EU_309 -> Known.VATEX_EU_309 + VATEX_EU_AE -> Known.VATEX_EU_AE + VATEX_EU_D -> Known.VATEX_EU_D + VATEX_EU_F -> Known.VATEX_EU_F + VATEX_EU_G -> Known.VATEX_EU_G + VATEX_EU_I -> Known.VATEX_EU_I + VATEX_EU_IC -> Known.VATEX_EU_IC + VATEX_EU_O -> Known.VATEX_EU_O + VATEX_EU_J -> Known.VATEX_EU_J + VATEX_FR_FRANCHISE -> Known.VATEX_FR_FRANCHISE + VATEX_FR_CNWVAT -> Known.VATEX_FR_CNWVAT + else -> throw EInvoiceInvalidDataException("Unknown Vatex: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Vatex = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Vatex && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DocumentCreateFromPdfResponse && + allowances == other.allowances && + amountDue == other.amountDue && + attachments == other.attachments && + billingAddress == other.billingAddress && + billingAddressRecipient == other.billingAddressRecipient && + charges == other.charges && + currency == other.currency && + customerAddress == other.customerAddress && + customerAddressRecipient == other.customerAddressRecipient && + customerEmail == other.customerEmail && + customerId == other.customerId && + customerName == other.customerName && + customerTaxId == other.customerTaxId && + direction == other.direction && + documentType == other.documentType && + dueDate == other.dueDate && + invoiceDate == other.invoiceDate && + invoiceId == other.invoiceId && + invoiceTotal == other.invoiceTotal && + items == other.items && + note == other.note && + paymentDetails == other.paymentDetails && + paymentTerm == other.paymentTerm && + previousUnpaidBalance == other.previousUnpaidBalance && + purchaseOrder == other.purchaseOrder && + remittanceAddress == other.remittanceAddress && + remittanceAddressRecipient == other.remittanceAddressRecipient && + serviceAddress == other.serviceAddress && + serviceAddressRecipient == other.serviceAddressRecipient && + serviceEndDate == other.serviceEndDate && + serviceStartDate == other.serviceStartDate && + shippingAddress == other.shippingAddress && + shippingAddressRecipient == other.shippingAddressRecipient && + state == other.state && + subtotal == other.subtotal && + success == other.success && + taxCode == other.taxCode && + taxDetails == other.taxDetails && + totalDiscount == other.totalDiscount && + totalTax == other.totalTax && + ublDocument == other.ublDocument && + vatex == other.vatex && + vatexNote == other.vatexNote && + vendorAddress == other.vendorAddress && + vendorAddressRecipient == other.vendorAddressRecipient && + vendorEmail == other.vendorEmail && + vendorName == other.vendorName && + vendorTaxId == other.vendorTaxId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + allowances, + amountDue, + attachments, + billingAddress, + billingAddressRecipient, + charges, + currency, + customerAddress, + customerAddressRecipient, + customerEmail, + customerId, + customerName, + customerTaxId, + direction, + documentType, + dueDate, + invoiceDate, + invoiceId, + invoiceTotal, + items, + note, + paymentDetails, + paymentTerm, + previousUnpaidBalance, + purchaseOrder, + remittanceAddress, + remittanceAddressRecipient, + serviceAddress, + serviceAddressRecipient, + serviceEndDate, + serviceStartDate, + shippingAddress, + shippingAddressRecipient, + state, + subtotal, + success, + taxCode, + taxDetails, + totalDiscount, + totalTax, + ublDocument, + vatex, + vatexNote, + vendorAddress, + vendorAddressRecipient, + vendorEmail, + vendorName, + vendorTaxId, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DocumentCreateFromPdfResponse{allowances=$allowances, amountDue=$amountDue, attachments=$attachments, billingAddress=$billingAddress, billingAddressRecipient=$billingAddressRecipient, charges=$charges, currency=$currency, customerAddress=$customerAddress, customerAddressRecipient=$customerAddressRecipient, customerEmail=$customerEmail, customerId=$customerId, customerName=$customerName, customerTaxId=$customerTaxId, direction=$direction, documentType=$documentType, dueDate=$dueDate, invoiceDate=$invoiceDate, invoiceId=$invoiceId, invoiceTotal=$invoiceTotal, items=$items, note=$note, paymentDetails=$paymentDetails, paymentTerm=$paymentTerm, previousUnpaidBalance=$previousUnpaidBalance, purchaseOrder=$purchaseOrder, remittanceAddress=$remittanceAddress, remittanceAddressRecipient=$remittanceAddressRecipient, serviceAddress=$serviceAddress, serviceAddressRecipient=$serviceAddressRecipient, serviceEndDate=$serviceEndDate, serviceStartDate=$serviceStartDate, shippingAddress=$shippingAddress, shippingAddressRecipient=$shippingAddressRecipient, state=$state, subtotal=$subtotal, success=$success, taxCode=$taxCode, taxDetails=$taxDetails, totalDiscount=$totalDiscount, totalTax=$totalTax, ublDocument=$ublDocument, vatex=$vatex, vatexNote=$vatexNote, vendorAddress=$vendorAddress, vendorAddressRecipient=$vendorAddressRecipient, vendorEmail=$vendorEmail, vendorName=$vendorName, vendorTaxId=$vendorTaxId, additionalProperties=$additionalProperties}" +} diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt index 8628ddc..9f0679b 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt @@ -3956,1276 +3956,6 @@ private constructor( (unit.asKnown().getOrNull()?.validity() ?: 0) + (if (unitPrice.asKnown().isPresent) 1 else 0) - /** An allowance is a discount for example for early payment, volume discount, etc. */ - class Allowance - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val amount: JsonField, - private val baseAmount: JsonField, - private val multiplierFactor: JsonField, - private val reason: JsonField, - private val reasonCode: JsonField, - private val taxCode: JsonField, - private val taxRate: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - amount: JsonField = JsonMissing.of(), - @JsonProperty("base_amount") - @ExcludeMissing - baseAmount: JsonField = JsonMissing.of(), - @JsonProperty("multiplier_factor") - @ExcludeMissing - multiplierFactor: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - reason: JsonField = JsonMissing.of(), - @JsonProperty("reason_code") - @ExcludeMissing - reasonCode: JsonField = JsonMissing.of(), - @JsonProperty("tax_code") - @ExcludeMissing - taxCode: JsonField = JsonMissing.of(), - @JsonProperty("tax_rate") - @ExcludeMissing - taxRate: JsonField = JsonMissing.of(), - ) : this( - amount, - baseAmount, - multiplierFactor, - reason, - reasonCode, - taxCode, - taxRate, - mutableMapOf(), - ) - - /** - * The allowance amount, without VAT. Must be rounded to maximum 2 decimals - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * The base amount that may be used, in conjunction with the allowance percentage, to - * calculate the allowance amount. Must be rounded to maximum 2 decimals - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun baseAmount(): Optional = baseAmount.getOptional("base_amount") - - /** - * The percentage that may be used, in conjunction with the allowance base amount, to - * calculate the allowance amount. To state 20%, use value 20 - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun multiplierFactor(): Optional = - multiplierFactor.getOptional("multiplier_factor") - - /** - * The reason for the allowance - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun reason(): Optional = reason.getOptional("reason") - - /** - * The code for the allowance reason - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun reasonCode(): Optional = reasonCode.getOptional("reason_code") - - /** - * Duty or tax or fee category codes (Subset of UNCL5305) - * - * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun taxCode(): Optional = taxCode.getOptional("tax_code") - - /** - * The VAT rate, represented as percentage that applies to the allowance - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun taxRate(): Optional = taxRate.getOptional("tax_rate") - - /** - * Returns the raw JSON value of [amount]. - * - * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** - * Returns the raw JSON value of [baseAmount]. - * - * Unlike [baseAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("base_amount") - @ExcludeMissing - fun _baseAmount(): JsonField = baseAmount - - /** - * Returns the raw JSON value of [multiplierFactor]. - * - * Unlike [multiplierFactor], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("multiplier_factor") - @ExcludeMissing - fun _multiplierFactor(): JsonField = multiplierFactor - - /** - * Returns the raw JSON value of [reason]. - * - * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - /** - * Returns the raw JSON value of [reasonCode]. - * - * Unlike [reasonCode], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("reason_code") - @ExcludeMissing - fun _reasonCode(): JsonField = reasonCode - - /** - * Returns the raw JSON value of [taxCode]. - * - * Unlike [taxCode], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tax_code") @ExcludeMissing fun _taxCode(): JsonField = taxCode - - /** - * Returns the raw JSON value of [taxRate]. - * - * Unlike [taxRate], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Allowance]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Allowance]. */ - class Builder internal constructor() { - - private var amount: JsonField = JsonMissing.of() - private var baseAmount: JsonField = JsonMissing.of() - private var multiplierFactor: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() - private var reasonCode: JsonField = JsonMissing.of() - private var taxCode: JsonField = JsonMissing.of() - private var taxRate: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(allowance: Allowance) = apply { - amount = allowance.amount - baseAmount = allowance.baseAmount - multiplierFactor = allowance.multiplierFactor - reason = allowance.reason - reasonCode = allowance.reasonCode - taxCode = allowance.taxCode - taxRate = allowance.taxRate - additionalProperties = allowance.additionalProperties.toMutableMap() - } - - /** The allowance amount, without VAT. Must be rounded to maximum 2 decimals */ - fun amount(amount: String?) = amount(JsonField.ofNullable(amount)) - - /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ - fun amount(amount: Optional) = amount(amount.getOrNull()) - - /** - * Sets [Builder.amount] to an arbitrary JSON value. - * - * You should usually call [Builder.amount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** - * The base amount that may be used, in conjunction with the allowance percentage, - * to calculate the allowance amount. Must be rounded to maximum 2 decimals - */ - fun baseAmount(baseAmount: String?) = baseAmount(JsonField.ofNullable(baseAmount)) - - /** Alias for calling [Builder.baseAmount] with `baseAmount.orElse(null)`. */ - fun baseAmount(baseAmount: Optional) = baseAmount(baseAmount.getOrNull()) - - /** - * Sets [Builder.baseAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.baseAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun baseAmount(baseAmount: JsonField) = apply { - this.baseAmount = baseAmount - } - - /** - * The percentage that may be used, in conjunction with the allowance base amount, - * to calculate the allowance amount. To state 20%, use value 20 - */ - fun multiplierFactor(multiplierFactor: String?) = - multiplierFactor(JsonField.ofNullable(multiplierFactor)) - - /** - * Alias for calling [Builder.multiplierFactor] with - * `multiplierFactor.orElse(null)`. - */ - fun multiplierFactor(multiplierFactor: Optional) = - multiplierFactor(multiplierFactor.getOrNull()) - - /** - * Sets [Builder.multiplierFactor] to an arbitrary JSON value. - * - * You should usually call [Builder.multiplierFactor] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun multiplierFactor(multiplierFactor: JsonField) = apply { - this.multiplierFactor = multiplierFactor - } - - /** The reason for the allowance */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ - fun reason(reason: Optional) = reason(reason.getOrNull()) - - /** - * Sets [Builder.reason] to an arbitrary JSON value. - * - * You should usually call [Builder.reason] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - /** The code for the allowance reason */ - fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) - - /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ - fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) - - /** - * Sets [Builder.reasonCode] to an arbitrary JSON value. - * - * You should usually call [Builder.reasonCode] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun reasonCode(reasonCode: JsonField) = apply { - this.reasonCode = reasonCode - } - - /** - * Duty or tax or fee category codes (Subset of UNCL5305) - * - * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL - */ - fun taxCode(taxCode: TaxCode?) = taxCode(JsonField.ofNullable(taxCode)) - - /** Alias for calling [Builder.taxCode] with `taxCode.orElse(null)`. */ - fun taxCode(taxCode: Optional) = taxCode(taxCode.getOrNull()) - - /** - * Sets [Builder.taxCode] to an arbitrary JSON value. - * - * You should usually call [Builder.taxCode] with a well-typed [TaxCode] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } - - /** The VAT rate, represented as percentage that applies to the allowance */ - fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) - - /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ - fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) - - /** - * Sets [Builder.taxRate] to an arbitrary JSON value. - * - * You should usually call [Builder.taxRate] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Allowance]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Allowance = - Allowance( - amount, - baseAmount, - multiplierFactor, - reason, - reasonCode, - taxCode, - taxRate, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Allowance = apply { - if (validated) { - return@apply - } - - amount() - baseAmount() - multiplierFactor() - reason() - reasonCode() - taxCode().ifPresent { it.validate() } - taxRate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (amount.asKnown().isPresent) 1 else 0) + - (if (baseAmount.asKnown().isPresent) 1 else 0) + - (if (multiplierFactor.asKnown().isPresent) 1 else 0) + - (if (reason.asKnown().isPresent) 1 else 0) + - (if (reasonCode.asKnown().isPresent) 1 else 0) + - (taxCode.asKnown().getOrNull()?.validity() ?: 0) + - (if (taxRate.asKnown().isPresent) 1 else 0) - - /** - * Duty or tax or fee category codes (Subset of UNCL5305) - * - * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL - */ - class TaxCode @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val AE = of("AE") - - @JvmField val E = of("E") - - @JvmField val S = of("S") - - @JvmField val Z = of("Z") - - @JvmField val G = of("G") - - @JvmField val O = of("O") - - @JvmField val K = of("K") - - @JvmField val L = of("L") - - @JvmField val M = of("M") - - @JvmField val B = of("B") - - @JvmStatic fun of(value: String) = TaxCode(JsonField.of(value)) - } - - /** An enum containing [TaxCode]'s known values. */ - enum class Known { - AE, - E, - S, - Z, - G, - O, - K, - L, - M, - B, - } - - /** - * An enum containing [TaxCode]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [TaxCode] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AE, - E, - S, - Z, - G, - O, - K, - L, - M, - B, - /** - * An enum member indicating that [TaxCode] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AE -> Value.AE - E -> Value.E - S -> Value.S - Z -> Value.Z - G -> Value.G - O -> Value.O - K -> Value.K - L -> Value.L - M -> Value.M - B -> Value.B - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws EInvoiceInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AE -> Known.AE - E -> Known.E - S -> Known.S - Z -> Known.Z - G -> Known.G - O -> Known.O - K -> Known.K - L -> Known.L - M -> Known.M - B -> Known.B - else -> throw EInvoiceInvalidDataException("Unknown TaxCode: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws EInvoiceInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - EInvoiceInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): TaxCode = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TaxCode && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Allowance && - amount == other.amount && - baseAmount == other.baseAmount && - multiplierFactor == other.multiplierFactor && - reason == other.reason && - reasonCode == other.reasonCode && - taxCode == other.taxCode && - taxRate == other.taxRate && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - amount, - baseAmount, - multiplierFactor, - reason, - reasonCode, - taxCode, - taxRate, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Allowance{amount=$amount, baseAmount=$baseAmount, multiplierFactor=$multiplierFactor, reason=$reason, reasonCode=$reasonCode, taxCode=$taxCode, taxRate=$taxRate, additionalProperties=$additionalProperties}" - } - - /** A charge is an additional fee for example for late payment, late delivery, etc. */ - class Charge - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val amount: JsonField, - private val baseAmount: JsonField, - private val multiplierFactor: JsonField, - private val reason: JsonField, - private val reasonCode: JsonField, - private val taxCode: JsonField, - private val taxRate: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - amount: JsonField = JsonMissing.of(), - @JsonProperty("base_amount") - @ExcludeMissing - baseAmount: JsonField = JsonMissing.of(), - @JsonProperty("multiplier_factor") - @ExcludeMissing - multiplierFactor: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - reason: JsonField = JsonMissing.of(), - @JsonProperty("reason_code") - @ExcludeMissing - reasonCode: JsonField = JsonMissing.of(), - @JsonProperty("tax_code") - @ExcludeMissing - taxCode: JsonField = JsonMissing.of(), - @JsonProperty("tax_rate") - @ExcludeMissing - taxRate: JsonField = JsonMissing.of(), - ) : this( - amount, - baseAmount, - multiplierFactor, - reason, - reasonCode, - taxCode, - taxRate, - mutableMapOf(), - ) - - /** - * The charge amount, without VAT. Must be rounded to maximum 2 decimals - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * The base amount that may be used, in conjunction with the charge percentage, to - * calculate the charge amount. Must be rounded to maximum 2 decimals - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun baseAmount(): Optional = baseAmount.getOptional("base_amount") - - /** - * The percentage that may be used, in conjunction with the charge base amount, to - * calculate the charge amount. To state 20%, use value 20 - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun multiplierFactor(): Optional = - multiplierFactor.getOptional("multiplier_factor") - - /** - * The reason for the charge - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun reason(): Optional = reason.getOptional("reason") - - /** - * The code for the charge reason - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun reasonCode(): Optional = reasonCode.getOptional("reason_code") - - /** - * Duty or tax or fee category codes (Subset of UNCL5305) - * - * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun taxCode(): Optional = taxCode.getOptional("tax_code") - - /** - * The VAT rate, represented as percentage that applies to the charge - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun taxRate(): Optional = taxRate.getOptional("tax_rate") - - /** - * Returns the raw JSON value of [amount]. - * - * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** - * Returns the raw JSON value of [baseAmount]. - * - * Unlike [baseAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("base_amount") - @ExcludeMissing - fun _baseAmount(): JsonField = baseAmount - - /** - * Returns the raw JSON value of [multiplierFactor]. - * - * Unlike [multiplierFactor], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("multiplier_factor") - @ExcludeMissing - fun _multiplierFactor(): JsonField = multiplierFactor - - /** - * Returns the raw JSON value of [reason]. - * - * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - /** - * Returns the raw JSON value of [reasonCode]. - * - * Unlike [reasonCode], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("reason_code") - @ExcludeMissing - fun _reasonCode(): JsonField = reasonCode - - /** - * Returns the raw JSON value of [taxCode]. - * - * Unlike [taxCode], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tax_code") @ExcludeMissing fun _taxCode(): JsonField = taxCode - - /** - * Returns the raw JSON value of [taxRate]. - * - * Unlike [taxRate], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Charge]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Charge]. */ - class Builder internal constructor() { - - private var amount: JsonField = JsonMissing.of() - private var baseAmount: JsonField = JsonMissing.of() - private var multiplierFactor: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() - private var reasonCode: JsonField = JsonMissing.of() - private var taxCode: JsonField = JsonMissing.of() - private var taxRate: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(charge: Charge) = apply { - amount = charge.amount - baseAmount = charge.baseAmount - multiplierFactor = charge.multiplierFactor - reason = charge.reason - reasonCode = charge.reasonCode - taxCode = charge.taxCode - taxRate = charge.taxRate - additionalProperties = charge.additionalProperties.toMutableMap() - } - - /** The charge amount, without VAT. Must be rounded to maximum 2 decimals */ - fun amount(amount: String?) = amount(JsonField.ofNullable(amount)) - - /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ - fun amount(amount: Optional) = amount(amount.getOrNull()) - - /** - * Sets [Builder.amount] to an arbitrary JSON value. - * - * You should usually call [Builder.amount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** - * The base amount that may be used, in conjunction with the charge percentage, to - * calculate the charge amount. Must be rounded to maximum 2 decimals - */ - fun baseAmount(baseAmount: String?) = baseAmount(JsonField.ofNullable(baseAmount)) - - /** Alias for calling [Builder.baseAmount] with `baseAmount.orElse(null)`. */ - fun baseAmount(baseAmount: Optional) = baseAmount(baseAmount.getOrNull()) - - /** - * Sets [Builder.baseAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.baseAmount] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun baseAmount(baseAmount: JsonField) = apply { - this.baseAmount = baseAmount - } - - /** - * The percentage that may be used, in conjunction with the charge base amount, to - * calculate the charge amount. To state 20%, use value 20 - */ - fun multiplierFactor(multiplierFactor: String?) = - multiplierFactor(JsonField.ofNullable(multiplierFactor)) - - /** - * Alias for calling [Builder.multiplierFactor] with - * `multiplierFactor.orElse(null)`. - */ - fun multiplierFactor(multiplierFactor: Optional) = - multiplierFactor(multiplierFactor.getOrNull()) - - /** - * Sets [Builder.multiplierFactor] to an arbitrary JSON value. - * - * You should usually call [Builder.multiplierFactor] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun multiplierFactor(multiplierFactor: JsonField) = apply { - this.multiplierFactor = multiplierFactor - } - - /** The reason for the charge */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ - fun reason(reason: Optional) = reason(reason.getOrNull()) - - /** - * Sets [Builder.reason] to an arbitrary JSON value. - * - * You should usually call [Builder.reason] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - /** The code for the charge reason */ - fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) - - /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ - fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) - - /** - * Sets [Builder.reasonCode] to an arbitrary JSON value. - * - * You should usually call [Builder.reasonCode] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun reasonCode(reasonCode: JsonField) = apply { - this.reasonCode = reasonCode - } - - /** - * Duty or tax or fee category codes (Subset of UNCL5305) - * - * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL - */ - fun taxCode(taxCode: TaxCode?) = taxCode(JsonField.ofNullable(taxCode)) - - /** Alias for calling [Builder.taxCode] with `taxCode.orElse(null)`. */ - fun taxCode(taxCode: Optional) = taxCode(taxCode.getOrNull()) - - /** - * Sets [Builder.taxCode] to an arbitrary JSON value. - * - * You should usually call [Builder.taxCode] with a well-typed [TaxCode] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } - - /** The VAT rate, represented as percentage that applies to the charge */ - fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) - - /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ - fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) - - /** - * Sets [Builder.taxRate] to an arbitrary JSON value. - * - * You should usually call [Builder.taxRate] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Charge]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Charge = - Charge( - amount, - baseAmount, - multiplierFactor, - reason, - reasonCode, - taxCode, - taxRate, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Charge = apply { - if (validated) { - return@apply - } - - amount() - baseAmount() - multiplierFactor() - reason() - reasonCode() - taxCode().ifPresent { it.validate() } - taxRate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (amount.asKnown().isPresent) 1 else 0) + - (if (baseAmount.asKnown().isPresent) 1 else 0) + - (if (multiplierFactor.asKnown().isPresent) 1 else 0) + - (if (reason.asKnown().isPresent) 1 else 0) + - (if (reasonCode.asKnown().isPresent) 1 else 0) + - (taxCode.asKnown().getOrNull()?.validity() ?: 0) + - (if (taxRate.asKnown().isPresent) 1 else 0) - - /** - * Duty or tax or fee category codes (Subset of UNCL5305) - * - * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL - */ - class TaxCode @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val AE = of("AE") - - @JvmField val E = of("E") - - @JvmField val S = of("S") - - @JvmField val Z = of("Z") - - @JvmField val G = of("G") - - @JvmField val O = of("O") - - @JvmField val K = of("K") - - @JvmField val L = of("L") - - @JvmField val M = of("M") - - @JvmField val B = of("B") - - @JvmStatic fun of(value: String) = TaxCode(JsonField.of(value)) - } - - /** An enum containing [TaxCode]'s known values. */ - enum class Known { - AE, - E, - S, - Z, - G, - O, - K, - L, - M, - B, - } - - /** - * An enum containing [TaxCode]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [TaxCode] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AE, - E, - S, - Z, - G, - O, - K, - L, - M, - B, - /** - * An enum member indicating that [TaxCode] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AE -> Value.AE - E -> Value.E - S -> Value.S - Z -> Value.Z - G -> Value.G - O -> Value.O - K -> Value.K - L -> Value.L - M -> Value.M - B -> Value.B - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws EInvoiceInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AE -> Known.AE - E -> Known.E - S -> Known.S - Z -> Known.Z - G -> Known.G - O -> Known.O - K -> Known.K - L -> Known.L - M -> Known.M - B -> Known.B - else -> throw EInvoiceInvalidDataException("Unknown TaxCode: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws EInvoiceInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - EInvoiceInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): TaxCode = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TaxCode && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Charge && - amount == other.amount && - baseAmount == other.baseAmount && - multiplierFactor == other.multiplierFactor && - reason == other.reason && - reasonCode == other.reasonCode && - taxCode == other.taxCode && - taxRate == other.taxRate && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - amount, - baseAmount, - multiplierFactor, - reason, - reasonCode, - taxCode, - taxRate, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Charge{amount=$amount, baseAmount=$baseAmount, multiplierFactor=$multiplierFactor, reason=$reason, reasonCode=$reasonCode, taxCode=$taxCode, taxRate=$taxRate, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentValidateParams.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentValidateParams.kt new file mode 100644 index 0000000..303db15 --- /dev/null +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentValidateParams.kt @@ -0,0 +1,230 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.e_invoice.api.models.documents + +import com.e_invoice.api.core.JsonValue +import com.e_invoice.api.core.Params +import com.e_invoice.api.core.http.Headers +import com.e_invoice.api.core.http.QueryParams +import com.e_invoice.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Validate a UBL document according to Peppol BIS Billing 3.0 */ +class DocumentValidateParams +private constructor( + private val documentId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun documentId(): Optional = Optional.ofNullable(documentId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): DocumentValidateParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [DocumentValidateParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DocumentValidateParams]. */ + class Builder internal constructor() { + + private var documentId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(documentValidateParams: DocumentValidateParams) = apply { + documentId = documentValidateParams.documentId + additionalHeaders = documentValidateParams.additionalHeaders.toBuilder() + additionalQueryParams = documentValidateParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + documentValidateParams.additionalBodyProperties.toMutableMap() + } + + fun documentId(documentId: String?) = apply { this.documentId = documentId } + + /** Alias for calling [Builder.documentId] with `documentId.orElse(null)`. */ + fun documentId(documentId: Optional) = documentId(documentId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [DocumentValidateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DocumentValidateParams = + DocumentValidateParams( + documentId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> documentId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DocumentValidateParams && + documentId == other.documentId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash(documentId, additionalHeaders, additionalQueryParams, additionalBodyProperties) + + override fun toString() = + "DocumentValidateParams{documentId=$documentId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/ubl/UblCreateFromUblParams.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/ubl/UblCreateFromUblParams.kt new file mode 100644 index 0000000..fc29fbe --- /dev/null +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/ubl/UblCreateFromUblParams.kt @@ -0,0 +1,415 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.e_invoice.api.models.documents.ubl + +import com.e_invoice.api.core.ExcludeMissing +import com.e_invoice.api.core.JsonValue +import com.e_invoice.api.core.MultipartField +import com.e_invoice.api.core.Params +import com.e_invoice.api.core.checkRequired +import com.e_invoice.api.core.http.Headers +import com.e_invoice.api.core.http.QueryParams +import com.e_invoice.api.core.toImmutable +import com.e_invoice.api.errors.EInvoiceInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonProperty +import java.io.InputStream +import java.nio.file.Path +import java.util.Collections +import java.util.Objects +import kotlin.io.path.inputStream +import kotlin.io.path.name + +/** Create a new invoice or credit note from a UBL file */ +class UblCreateFromUblParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun file(): InputStream = body.file() + + /** + * Returns the raw multipart value of [file]. + * + * Unlike [file], this method doesn't throw if the multipart field has an unexpected type. + */ + fun _file(): MultipartField = body._file() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [UblCreateFromUblParams]. + * + * The following fields are required: + * ```java + * .file() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UblCreateFromUblParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(ublCreateFromUblParams: UblCreateFromUblParams) = apply { + body = ublCreateFromUblParams.body.toBuilder() + additionalHeaders = ublCreateFromUblParams.additionalHeaders.toBuilder() + additionalQueryParams = ublCreateFromUblParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [file] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + fun file(file: InputStream) = apply { body.file(file) } + + /** + * Sets [Builder.file] to an arbitrary multipart value. + * + * You should usually call [Builder.file] with a well-typed [InputStream] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun file(file: MultipartField) = apply { body.file(file) } + + fun file(file: ByteArray) = apply { body.file(file) } + + fun file(path: Path) = apply { body.file(path) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [UblCreateFromUblParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .file() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UblCreateFromUblParams = + UblCreateFromUblParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Map> = + (mapOf("file" to _file()) + + _additionalBodyProperties().mapValues { (_, value) -> MultipartField.of(value) }) + .toImmutable() + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + private constructor( + private val file: MultipartField, + private val additionalProperties: MutableMap, + ) { + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun file(): InputStream = file.value.getRequired("file") + + /** + * Returns the raw multipart value of [file]. + * + * Unlike [file], this method doesn't throw if the multipart field has an unexpected type. + */ + @JsonProperty("file") @ExcludeMissing fun _file(): MultipartField = file + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .file() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var file: MultipartField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + file = body.file + additionalProperties = body.additionalProperties.toMutableMap() + } + + fun file(file: InputStream) = file(MultipartField.of(file)) + + /** + * Sets [Builder.file] to an arbitrary multipart value. + * + * You should usually call [Builder.file] with a well-typed [InputStream] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun file(file: MultipartField) = apply { this.file = file } + + fun file(file: ByteArray) = file(file.inputStream()) + + fun file(path: Path) = + file( + MultipartField.builder() + .value(path.inputStream()) + .filename(path.name) + .build() + ) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .file() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body(checkRequired("file", file), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + file() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + file == other.file && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(file, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Body{file=$file, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is UblCreateFromUblParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "UblCreateFromUblParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/me/MeRetrieveParams.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/me/MeRetrieveParams.kt new file mode 100644 index 0000000..fde28c1 --- /dev/null +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/me/MeRetrieveParams.kt @@ -0,0 +1,170 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.e_invoice.api.models.me + +import com.e_invoice.api.core.Params +import com.e_invoice.api.core.http.Headers +import com.e_invoice.api.core.http.QueryParams +import java.util.Objects + +/** Retrieve information about your account. */ +class MeRetrieveParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): MeRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [MeRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MeRetrieveParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(meRetrieveParams: MeRetrieveParams) = apply { + additionalHeaders = meRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = meRetrieveParams.additionalQueryParams.toBuilder() + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [MeRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): MeRetrieveParams = + MeRetrieveParams(additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MeRetrieveParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "MeRetrieveParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/me/MeRetrieveResponse.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/me/MeRetrieveResponse.kt new file mode 100644 index 0000000..c3709a5 --- /dev/null +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/me/MeRetrieveResponse.kt @@ -0,0 +1,1028 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.e_invoice.api.models.me + +import com.e_invoice.api.core.Enum +import com.e_invoice.api.core.ExcludeMissing +import com.e_invoice.api.core.JsonField +import com.e_invoice.api.core.JsonMissing +import com.e_invoice.api.core.JsonValue +import com.e_invoice.api.core.checkKnown +import com.e_invoice.api.core.checkRequired +import com.e_invoice.api.core.toImmutable +import com.e_invoice.api.errors.EInvoiceInvalidDataException +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class MeRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val creditBalance: JsonField, + private val name: JsonField, + private val plan: JsonField, + private val bccRecipientEmail: JsonField, + private val companyAddress: JsonField, + private val companyCity: JsonField, + private val companyCountry: JsonField, + private val companyEmail: JsonField, + private val companyName: JsonField, + private val companyNumber: JsonField, + private val companyZip: JsonField, + private val description: JsonField, + private val ibans: JsonField>, + private val peppolIds: JsonField>, + private val smpRegistration: JsonField, + private val smpRegistrationDate: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("credit_balance") + @ExcludeMissing + creditBalance: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("plan") @ExcludeMissing plan: JsonField = JsonMissing.of(), + @JsonProperty("bcc_recipient_email") + @ExcludeMissing + bccRecipientEmail: JsonField = JsonMissing.of(), + @JsonProperty("company_address") + @ExcludeMissing + companyAddress: JsonField = JsonMissing.of(), + @JsonProperty("company_city") + @ExcludeMissing + companyCity: JsonField = JsonMissing.of(), + @JsonProperty("company_country") + @ExcludeMissing + companyCountry: JsonField = JsonMissing.of(), + @JsonProperty("company_email") + @ExcludeMissing + companyEmail: JsonField = JsonMissing.of(), + @JsonProperty("company_name") + @ExcludeMissing + companyName: JsonField = JsonMissing.of(), + @JsonProperty("company_number") + @ExcludeMissing + companyNumber: JsonField = JsonMissing.of(), + @JsonProperty("company_zip") + @ExcludeMissing + companyZip: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("ibans") @ExcludeMissing ibans: JsonField> = JsonMissing.of(), + @JsonProperty("peppol_ids") + @ExcludeMissing + peppolIds: JsonField> = JsonMissing.of(), + @JsonProperty("smp_registration") + @ExcludeMissing + smpRegistration: JsonField = JsonMissing.of(), + @JsonProperty("smp_registration_date") + @ExcludeMissing + smpRegistrationDate: JsonField = JsonMissing.of(), + ) : this( + creditBalance, + name, + plan, + bccRecipientEmail, + companyAddress, + companyCity, + companyCountry, + companyEmail, + companyName, + companyNumber, + companyZip, + description, + ibans, + peppolIds, + smpRegistration, + smpRegistrationDate, + mutableMapOf(), + ) + + /** + * Credit balance of the tenant + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun creditBalance(): Long = creditBalance.getRequired("credit_balance") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * Plan of the tenant + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun plan(): Plan = plan.getRequired("plan") + + /** + * BCC recipient email to deliver documents + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun bccRecipientEmail(): Optional = bccRecipientEmail.getOptional("bcc_recipient_email") + + /** + * Address of the company + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun companyAddress(): Optional = companyAddress.getOptional("company_address") + + /** + * City of the company + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun companyCity(): Optional = companyCity.getOptional("company_city") + + /** + * Country of the company + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun companyCountry(): Optional = companyCountry.getOptional("company_country") + + /** + * Email of the company + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun companyEmail(): Optional = companyEmail.getOptional("company_email") + + /** + * Name of the company + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun companyName(): Optional = companyName.getOptional("company_name") + + /** + * Company number + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun companyNumber(): Optional = companyNumber.getOptional("company_number") + + /** + * Zip code of the company + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun companyZip(): Optional = companyZip.getOptional("company_zip") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * IBANs of the tenant + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun ibans(): Optional> = ibans.getOptional("ibans") + + /** + * Peppol IDs of the tenant + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun peppolIds(): Optional> = peppolIds.getOptional("peppol_ids") + + /** + * Whether the tenant is registered on our SMP + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun smpRegistration(): Optional = smpRegistration.getOptional("smp_registration") + + /** + * Date when the tenant was registered on SMP + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun smpRegistrationDate(): Optional = + smpRegistrationDate.getOptional("smp_registration_date") + + /** + * Returns the raw JSON value of [creditBalance]. + * + * Unlike [creditBalance], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("credit_balance") + @ExcludeMissing + fun _creditBalance(): JsonField = creditBalance + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [plan]. + * + * Unlike [plan], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan + + /** + * Returns the raw JSON value of [bccRecipientEmail]. + * + * Unlike [bccRecipientEmail], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("bcc_recipient_email") + @ExcludeMissing + fun _bccRecipientEmail(): JsonField = bccRecipientEmail + + /** + * Returns the raw JSON value of [companyAddress]. + * + * Unlike [companyAddress], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("company_address") + @ExcludeMissing + fun _companyAddress(): JsonField = companyAddress + + /** + * Returns the raw JSON value of [companyCity]. + * + * Unlike [companyCity], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("company_city") + @ExcludeMissing + fun _companyCity(): JsonField = companyCity + + /** + * Returns the raw JSON value of [companyCountry]. + * + * Unlike [companyCountry], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("company_country") + @ExcludeMissing + fun _companyCountry(): JsonField = companyCountry + + /** + * Returns the raw JSON value of [companyEmail]. + * + * Unlike [companyEmail], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("company_email") + @ExcludeMissing + fun _companyEmail(): JsonField = companyEmail + + /** + * Returns the raw JSON value of [companyName]. + * + * Unlike [companyName], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("company_name") + @ExcludeMissing + fun _companyName(): JsonField = companyName + + /** + * Returns the raw JSON value of [companyNumber]. + * + * Unlike [companyNumber], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("company_number") + @ExcludeMissing + fun _companyNumber(): JsonField = companyNumber + + /** + * Returns the raw JSON value of [companyZip]. + * + * Unlike [companyZip], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("company_zip") @ExcludeMissing fun _companyZip(): JsonField = companyZip + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [ibans]. + * + * Unlike [ibans], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("ibans") @ExcludeMissing fun _ibans(): JsonField> = ibans + + /** + * Returns the raw JSON value of [peppolIds]. + * + * Unlike [peppolIds], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("peppol_ids") + @ExcludeMissing + fun _peppolIds(): JsonField> = peppolIds + + /** + * Returns the raw JSON value of [smpRegistration]. + * + * Unlike [smpRegistration], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("smp_registration") + @ExcludeMissing + fun _smpRegistration(): JsonField = smpRegistration + + /** + * Returns the raw JSON value of [smpRegistrationDate]. + * + * Unlike [smpRegistrationDate], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("smp_registration_date") + @ExcludeMissing + fun _smpRegistrationDate(): JsonField = smpRegistrationDate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [MeRetrieveResponse]. + * + * The following fields are required: + * ```java + * .creditBalance() + * .name() + * .plan() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [MeRetrieveResponse]. */ + class Builder internal constructor() { + + private var creditBalance: JsonField? = null + private var name: JsonField? = null + private var plan: JsonField? = null + private var bccRecipientEmail: JsonField = JsonMissing.of() + private var companyAddress: JsonField = JsonMissing.of() + private var companyCity: JsonField = JsonMissing.of() + private var companyCountry: JsonField = JsonMissing.of() + private var companyEmail: JsonField = JsonMissing.of() + private var companyName: JsonField = JsonMissing.of() + private var companyNumber: JsonField = JsonMissing.of() + private var companyZip: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var ibans: JsonField>? = null + private var peppolIds: JsonField>? = null + private var smpRegistration: JsonField = JsonMissing.of() + private var smpRegistrationDate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(meRetrieveResponse: MeRetrieveResponse) = apply { + creditBalance = meRetrieveResponse.creditBalance + name = meRetrieveResponse.name + plan = meRetrieveResponse.plan + bccRecipientEmail = meRetrieveResponse.bccRecipientEmail + companyAddress = meRetrieveResponse.companyAddress + companyCity = meRetrieveResponse.companyCity + companyCountry = meRetrieveResponse.companyCountry + companyEmail = meRetrieveResponse.companyEmail + companyName = meRetrieveResponse.companyName + companyNumber = meRetrieveResponse.companyNumber + companyZip = meRetrieveResponse.companyZip + description = meRetrieveResponse.description + ibans = meRetrieveResponse.ibans.map { it.toMutableList() } + peppolIds = meRetrieveResponse.peppolIds.map { it.toMutableList() } + smpRegistration = meRetrieveResponse.smpRegistration + smpRegistrationDate = meRetrieveResponse.smpRegistrationDate + additionalProperties = meRetrieveResponse.additionalProperties.toMutableMap() + } + + /** Credit balance of the tenant */ + fun creditBalance(creditBalance: Long) = creditBalance(JsonField.of(creditBalance)) + + /** + * Sets [Builder.creditBalance] to an arbitrary JSON value. + * + * You should usually call [Builder.creditBalance] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun creditBalance(creditBalance: JsonField) = apply { + this.creditBalance = creditBalance + } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Plan of the tenant */ + fun plan(plan: Plan) = plan(JsonField.of(plan)) + + /** + * Sets [Builder.plan] to an arbitrary JSON value. + * + * You should usually call [Builder.plan] with a well-typed [Plan] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun plan(plan: JsonField) = apply { this.plan = plan } + + /** BCC recipient email to deliver documents */ + fun bccRecipientEmail(bccRecipientEmail: String?) = + bccRecipientEmail(JsonField.ofNullable(bccRecipientEmail)) + + /** Alias for calling [Builder.bccRecipientEmail] with `bccRecipientEmail.orElse(null)`. */ + fun bccRecipientEmail(bccRecipientEmail: Optional) = + bccRecipientEmail(bccRecipientEmail.getOrNull()) + + /** + * Sets [Builder.bccRecipientEmail] to an arbitrary JSON value. + * + * You should usually call [Builder.bccRecipientEmail] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun bccRecipientEmail(bccRecipientEmail: JsonField) = apply { + this.bccRecipientEmail = bccRecipientEmail + } + + /** Address of the company */ + fun companyAddress(companyAddress: String?) = + companyAddress(JsonField.ofNullable(companyAddress)) + + /** Alias for calling [Builder.companyAddress] with `companyAddress.orElse(null)`. */ + fun companyAddress(companyAddress: Optional) = + companyAddress(companyAddress.getOrNull()) + + /** + * Sets [Builder.companyAddress] to an arbitrary JSON value. + * + * You should usually call [Builder.companyAddress] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun companyAddress(companyAddress: JsonField) = apply { + this.companyAddress = companyAddress + } + + /** City of the company */ + fun companyCity(companyCity: String?) = companyCity(JsonField.ofNullable(companyCity)) + + /** Alias for calling [Builder.companyCity] with `companyCity.orElse(null)`. */ + fun companyCity(companyCity: Optional) = companyCity(companyCity.getOrNull()) + + /** + * Sets [Builder.companyCity] to an arbitrary JSON value. + * + * You should usually call [Builder.companyCity] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun companyCity(companyCity: JsonField) = apply { this.companyCity = companyCity } + + /** Country of the company */ + fun companyCountry(companyCountry: String?) = + companyCountry(JsonField.ofNullable(companyCountry)) + + /** Alias for calling [Builder.companyCountry] with `companyCountry.orElse(null)`. */ + fun companyCountry(companyCountry: Optional) = + companyCountry(companyCountry.getOrNull()) + + /** + * Sets [Builder.companyCountry] to an arbitrary JSON value. + * + * You should usually call [Builder.companyCountry] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun companyCountry(companyCountry: JsonField) = apply { + this.companyCountry = companyCountry + } + + /** Email of the company */ + fun companyEmail(companyEmail: String?) = companyEmail(JsonField.ofNullable(companyEmail)) + + /** Alias for calling [Builder.companyEmail] with `companyEmail.orElse(null)`. */ + fun companyEmail(companyEmail: Optional) = companyEmail(companyEmail.getOrNull()) + + /** + * Sets [Builder.companyEmail] to an arbitrary JSON value. + * + * You should usually call [Builder.companyEmail] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun companyEmail(companyEmail: JsonField) = apply { + this.companyEmail = companyEmail + } + + /** Name of the company */ + fun companyName(companyName: String?) = companyName(JsonField.ofNullable(companyName)) + + /** Alias for calling [Builder.companyName] with `companyName.orElse(null)`. */ + fun companyName(companyName: Optional) = companyName(companyName.getOrNull()) + + /** + * Sets [Builder.companyName] to an arbitrary JSON value. + * + * You should usually call [Builder.companyName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun companyName(companyName: JsonField) = apply { this.companyName = companyName } + + /** Company number */ + fun companyNumber(companyNumber: String?) = + companyNumber(JsonField.ofNullable(companyNumber)) + + /** Alias for calling [Builder.companyNumber] with `companyNumber.orElse(null)`. */ + fun companyNumber(companyNumber: Optional) = + companyNumber(companyNumber.getOrNull()) + + /** + * Sets [Builder.companyNumber] to an arbitrary JSON value. + * + * You should usually call [Builder.companyNumber] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun companyNumber(companyNumber: JsonField) = apply { + this.companyNumber = companyNumber + } + + /** Zip code of the company */ + fun companyZip(companyZip: String?) = companyZip(JsonField.ofNullable(companyZip)) + + /** Alias for calling [Builder.companyZip] with `companyZip.orElse(null)`. */ + fun companyZip(companyZip: Optional) = companyZip(companyZip.getOrNull()) + + /** + * Sets [Builder.companyZip] to an arbitrary JSON value. + * + * You should usually call [Builder.companyZip] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun companyZip(companyZip: JsonField) = apply { this.companyZip = companyZip } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun description(description: JsonField) = apply { this.description = description } + + /** IBANs of the tenant */ + fun ibans(ibans: List?) = ibans(JsonField.ofNullable(ibans)) + + /** Alias for calling [Builder.ibans] with `ibans.orElse(null)`. */ + fun ibans(ibans: Optional>) = ibans(ibans.getOrNull()) + + /** + * Sets [Builder.ibans] to an arbitrary JSON value. + * + * You should usually call [Builder.ibans] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun ibans(ibans: JsonField>) = apply { + this.ibans = ibans.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [ibans]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addIban(iban: String) = apply { + ibans = + (ibans ?: JsonField.of(mutableListOf())).also { checkKnown("ibans", it).add(iban) } + } + + /** Peppol IDs of the tenant */ + fun peppolIds(peppolIds: List?) = peppolIds(JsonField.ofNullable(peppolIds)) + + /** Alias for calling [Builder.peppolIds] with `peppolIds.orElse(null)`. */ + fun peppolIds(peppolIds: Optional>) = peppolIds(peppolIds.getOrNull()) + + /** + * Sets [Builder.peppolIds] to an arbitrary JSON value. + * + * You should usually call [Builder.peppolIds] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun peppolIds(peppolIds: JsonField>) = apply { + this.peppolIds = peppolIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [peppolIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPeppolId(peppolId: String) = apply { + peppolIds = + (peppolIds ?: JsonField.of(mutableListOf())).also { + checkKnown("peppolIds", it).add(peppolId) + } + } + + /** Whether the tenant is registered on our SMP */ + fun smpRegistration(smpRegistration: Boolean?) = + smpRegistration(JsonField.ofNullable(smpRegistration)) + + /** + * Alias for [Builder.smpRegistration]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun smpRegistration(smpRegistration: Boolean) = smpRegistration(smpRegistration as Boolean?) + + /** Alias for calling [Builder.smpRegistration] with `smpRegistration.orElse(null)`. */ + fun smpRegistration(smpRegistration: Optional) = + smpRegistration(smpRegistration.getOrNull()) + + /** + * Sets [Builder.smpRegistration] to an arbitrary JSON value. + * + * You should usually call [Builder.smpRegistration] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun smpRegistration(smpRegistration: JsonField) = apply { + this.smpRegistration = smpRegistration + } + + /** Date when the tenant was registered on SMP */ + fun smpRegistrationDate(smpRegistrationDate: OffsetDateTime?) = + smpRegistrationDate(JsonField.ofNullable(smpRegistrationDate)) + + /** + * Alias for calling [Builder.smpRegistrationDate] with `smpRegistrationDate.orElse(null)`. + */ + fun smpRegistrationDate(smpRegistrationDate: Optional) = + smpRegistrationDate(smpRegistrationDate.getOrNull()) + + /** + * Sets [Builder.smpRegistrationDate] to an arbitrary JSON value. + * + * You should usually call [Builder.smpRegistrationDate] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun smpRegistrationDate(smpRegistrationDate: JsonField) = apply { + this.smpRegistrationDate = smpRegistrationDate + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [MeRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .creditBalance() + * .name() + * .plan() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): MeRetrieveResponse = + MeRetrieveResponse( + checkRequired("creditBalance", creditBalance), + checkRequired("name", name), + checkRequired("plan", plan), + bccRecipientEmail, + companyAddress, + companyCity, + companyCountry, + companyEmail, + companyName, + companyNumber, + companyZip, + description, + (ibans ?: JsonMissing.of()).map { it.toImmutable() }, + (peppolIds ?: JsonMissing.of()).map { it.toImmutable() }, + smpRegistration, + smpRegistrationDate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): MeRetrieveResponse = apply { + if (validated) { + return@apply + } + + creditBalance() + name() + plan().validate() + bccRecipientEmail() + companyAddress() + companyCity() + companyCountry() + companyEmail() + companyName() + companyNumber() + companyZip() + description() + ibans() + peppolIds() + smpRegistration() + smpRegistrationDate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (creditBalance.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (plan.asKnown().getOrNull()?.validity() ?: 0) + + (if (bccRecipientEmail.asKnown().isPresent) 1 else 0) + + (if (companyAddress.asKnown().isPresent) 1 else 0) + + (if (companyCity.asKnown().isPresent) 1 else 0) + + (if (companyCountry.asKnown().isPresent) 1 else 0) + + (if (companyEmail.asKnown().isPresent) 1 else 0) + + (if (companyName.asKnown().isPresent) 1 else 0) + + (if (companyNumber.asKnown().isPresent) 1 else 0) + + (if (companyZip.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (ibans.asKnown().getOrNull()?.size ?: 0) + + (peppolIds.asKnown().getOrNull()?.size ?: 0) + + (if (smpRegistration.asKnown().isPresent) 1 else 0) + + (if (smpRegistrationDate.asKnown().isPresent) 1 else 0) + + /** Plan of the tenant */ + class Plan @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val STARTER = of("starter") + + @JvmField val PRO = of("pro") + + @JvmField val ENTERPRISE = of("enterprise") + + @JvmStatic fun of(value: String) = Plan(JsonField.of(value)) + } + + /** An enum containing [Plan]'s known values. */ + enum class Known { + STARTER, + PRO, + ENTERPRISE, + } + + /** + * An enum containing [Plan]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Plan] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + STARTER, + PRO, + ENTERPRISE, + /** An enum member indicating that [Plan] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + STARTER -> Value.STARTER + PRO -> Value.PRO + ENTERPRISE -> Value.ENTERPRISE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + STARTER -> Known.STARTER + PRO -> Known.PRO + ENTERPRISE -> Known.ENTERPRISE + else -> throw EInvoiceInvalidDataException("Unknown Plan: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Plan = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Plan && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MeRetrieveResponse && + creditBalance == other.creditBalance && + name == other.name && + plan == other.plan && + bccRecipientEmail == other.bccRecipientEmail && + companyAddress == other.companyAddress && + companyCity == other.companyCity && + companyCountry == other.companyCountry && + companyEmail == other.companyEmail && + companyName == other.companyName && + companyNumber == other.companyNumber && + companyZip == other.companyZip && + description == other.description && + ibans == other.ibans && + peppolIds == other.peppolIds && + smpRegistration == other.smpRegistration && + smpRegistrationDate == other.smpRegistrationDate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + creditBalance, + name, + plan, + bccRecipientEmail, + companyAddress, + companyCity, + companyCountry, + companyEmail, + companyName, + companyNumber, + companyZip, + description, + ibans, + peppolIds, + smpRegistration, + smpRegistrationDate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "MeRetrieveResponse{creditBalance=$creditBalance, name=$name, plan=$plan, bccRecipientEmail=$bccRecipientEmail, companyAddress=$companyAddress, companyCity=$companyCity, companyCountry=$companyCountry, companyEmail=$companyEmail, companyName=$companyName, companyNumber=$companyNumber, companyZip=$companyZip, description=$description, ibans=$ibans, peppolIds=$peppolIds, smpRegistration=$smpRegistration, smpRegistrationDate=$smpRegistrationDate, additionalProperties=$additionalProperties}" +} diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/DocumentServiceAsync.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/DocumentServiceAsync.kt index 088f18d..56b20a6 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/DocumentServiceAsync.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/DocumentServiceAsync.kt @@ -6,12 +6,16 @@ import com.e_invoice.api.core.ClientOptions import com.e_invoice.api.core.RequestOptions import com.e_invoice.api.core.http.HttpResponseFor import com.e_invoice.api.models.documents.DocumentCreate +import com.e_invoice.api.models.documents.DocumentCreateFromPdfParams +import com.e_invoice.api.models.documents.DocumentCreateFromPdfResponse import com.e_invoice.api.models.documents.DocumentCreateParams import com.e_invoice.api.models.documents.DocumentDeleteParams import com.e_invoice.api.models.documents.DocumentDeleteResponse import com.e_invoice.api.models.documents.DocumentResponse import com.e_invoice.api.models.documents.DocumentRetrieveParams import com.e_invoice.api.models.documents.DocumentSendParams +import com.e_invoice.api.models.documents.DocumentValidateParams +import com.e_invoice.api.models.validate.UblDocumentValidation import com.e_invoice.api.services.async.documents.AttachmentServiceAsync import com.e_invoice.api.services.async.documents.UblServiceAsync import java.util.concurrent.CompletableFuture @@ -129,6 +133,23 @@ interface DocumentServiceAsync { ): CompletableFuture = delete(documentId, DocumentDeleteParams.none(), requestOptions) + /** + * Create a new invoice or credit note from a PDF file. If the 'ubl_document' field is set in + * the response, it indicates that sufficient details were extracted from the PDF to + * automatically generate a valid UBL document ready for sending. If 'ubl_document' is not set, + * human intervention may be required to ensure compliance. + */ + fun createFromPdf( + params: DocumentCreateFromPdfParams + ): CompletableFuture = + createFromPdf(params, RequestOptions.none()) + + /** @see createFromPdf */ + fun createFromPdf( + params: DocumentCreateFromPdfParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + /** Send an invoice or credit note via Peppol */ fun send(documentId: String): CompletableFuture = send(documentId, DocumentSendParams.none()) @@ -164,6 +185,42 @@ interface DocumentServiceAsync { ): CompletableFuture = send(documentId, DocumentSendParams.none(), requestOptions) + /** Validate a UBL document according to Peppol BIS Billing 3.0 */ + fun validate(documentId: String): CompletableFuture = + validate(documentId, DocumentValidateParams.none()) + + /** @see validate */ + fun validate( + documentId: String, + params: DocumentValidateParams = DocumentValidateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + validate(params.toBuilder().documentId(documentId).build(), requestOptions) + + /** @see validate */ + fun validate( + documentId: String, + params: DocumentValidateParams = DocumentValidateParams.none(), + ): CompletableFuture = + validate(documentId, params, RequestOptions.none()) + + /** @see validate */ + fun validate( + params: DocumentValidateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see validate */ + fun validate(params: DocumentValidateParams): CompletableFuture = + validate(params, RequestOptions.none()) + + /** @see validate */ + fun validate( + documentId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + validate(documentId, DocumentValidateParams.none(), requestOptions) + /** * A view of [DocumentServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -295,6 +352,21 @@ interface DocumentServiceAsync { ): CompletableFuture> = delete(documentId, DocumentDeleteParams.none(), requestOptions) + /** + * Returns a raw HTTP response for `post /api/documents/pdf`, but is otherwise the same as + * [DocumentServiceAsync.createFromPdf]. + */ + fun createFromPdf( + params: DocumentCreateFromPdfParams + ): CompletableFuture> = + createFromPdf(params, RequestOptions.none()) + + /** @see createFromPdf */ + fun createFromPdf( + params: DocumentCreateFromPdfParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + /** * Returns a raw HTTP response for `post /api/documents/{document_id}/send`, but is * otherwise the same as [DocumentServiceAsync.send]. @@ -333,5 +405,48 @@ interface DocumentServiceAsync { requestOptions: RequestOptions, ): CompletableFuture> = send(documentId, DocumentSendParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/documents/{document_id}/validate`, but is + * otherwise the same as [DocumentServiceAsync.validate]. + */ + fun validate( + documentId: String + ): CompletableFuture> = + validate(documentId, DocumentValidateParams.none()) + + /** @see validate */ + fun validate( + documentId: String, + params: DocumentValidateParams = DocumentValidateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + validate(params.toBuilder().documentId(documentId).build(), requestOptions) + + /** @see validate */ + fun validate( + documentId: String, + params: DocumentValidateParams = DocumentValidateParams.none(), + ): CompletableFuture> = + validate(documentId, params, RequestOptions.none()) + + /** @see validate */ + fun validate( + params: DocumentValidateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see validate */ + fun validate( + params: DocumentValidateParams + ): CompletableFuture> = + validate(params, RequestOptions.none()) + + /** @see validate */ + fun validate( + documentId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + validate(documentId, DocumentValidateParams.none(), requestOptions) } } diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncImpl.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncImpl.kt index ec2198d..182c156 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncImpl.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncImpl.kt @@ -14,14 +14,19 @@ import com.e_invoice.api.core.http.HttpResponse import com.e_invoice.api.core.http.HttpResponse.Handler import com.e_invoice.api.core.http.HttpResponseFor import com.e_invoice.api.core.http.json +import com.e_invoice.api.core.http.multipartFormData import com.e_invoice.api.core.http.parseable import com.e_invoice.api.core.prepareAsync +import com.e_invoice.api.models.documents.DocumentCreateFromPdfParams +import com.e_invoice.api.models.documents.DocumentCreateFromPdfResponse import com.e_invoice.api.models.documents.DocumentCreateParams import com.e_invoice.api.models.documents.DocumentDeleteParams import com.e_invoice.api.models.documents.DocumentDeleteResponse import com.e_invoice.api.models.documents.DocumentResponse import com.e_invoice.api.models.documents.DocumentRetrieveParams import com.e_invoice.api.models.documents.DocumentSendParams +import com.e_invoice.api.models.documents.DocumentValidateParams +import com.e_invoice.api.models.validate.UblDocumentValidation import com.e_invoice.api.services.async.documents.AttachmentServiceAsync import com.e_invoice.api.services.async.documents.AttachmentServiceAsyncImpl import com.e_invoice.api.services.async.documents.UblServiceAsync @@ -73,6 +78,13 @@ class DocumentServiceAsyncImpl internal constructor(private val clientOptions: C // delete /api/documents/{document_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + override fun createFromPdf( + params: DocumentCreateFromPdfParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /api/documents/pdf + withRawResponse().createFromPdf(params, requestOptions).thenApply { it.parse() } + override fun send( params: DocumentSendParams, requestOptions: RequestOptions, @@ -80,6 +92,13 @@ class DocumentServiceAsyncImpl internal constructor(private val clientOptions: C // post /api/documents/{document_id}/send withRawResponse().send(params, requestOptions).thenApply { it.parse() } + override fun validate( + params: DocumentValidateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /api/documents/{document_id}/validate + withRawResponse().validate(params, requestOptions).thenApply { it.parse() } + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : DocumentServiceAsync.WithRawResponse { @@ -203,6 +222,37 @@ class DocumentServiceAsyncImpl internal constructor(private val clientOptions: C } } + private val createFromPdfHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun createFromPdf( + params: DocumentCreateFromPdfParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "documents", "pdf") + .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createFromPdfHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + private val sendHandler: Handler = jsonHandler(clientOptions.jsonMapper) @@ -236,5 +286,39 @@ class DocumentServiceAsyncImpl internal constructor(private val clientOptions: C } } } + + private val validateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun validate( + params: DocumentValidateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("documentId", params.documentId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "documents", params._pathParam(0), "validate") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { validateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } } } diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/MeServiceAsync.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/MeServiceAsync.kt new file mode 100644 index 0000000..eaf8aa3 --- /dev/null +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/MeServiceAsync.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.e_invoice.api.services.async + +import com.e_invoice.api.core.ClientOptions +import com.e_invoice.api.core.RequestOptions +import com.e_invoice.api.core.http.HttpResponseFor +import com.e_invoice.api.models.me.MeRetrieveParams +import com.e_invoice.api.models.me.MeRetrieveResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface MeServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): MeServiceAsync + + /** Retrieve information about your account. */ + fun retrieve(): CompletableFuture = retrieve(MeRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + params: MeRetrieveParams = MeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve( + params: MeRetrieveParams = MeRetrieveParams.none() + ): CompletableFuture = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(requestOptions: RequestOptions): CompletableFuture = + retrieve(MeRetrieveParams.none(), requestOptions) + + /** A view of [MeServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): MeServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/me/`, but is otherwise the same as + * [MeServiceAsync.retrieve]. + */ + fun retrieve(): CompletableFuture> = + retrieve(MeRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + params: MeRetrieveParams = MeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve( + params: MeRetrieveParams = MeRetrieveParams.none() + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + requestOptions: RequestOptions + ): CompletableFuture> = + retrieve(MeRetrieveParams.none(), requestOptions) + } +} diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/MeServiceAsyncImpl.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/MeServiceAsyncImpl.kt new file mode 100644 index 0000000..47db487 --- /dev/null +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/MeServiceAsyncImpl.kt @@ -0,0 +1,84 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.e_invoice.api.services.async + +import com.e_invoice.api.core.ClientOptions +import com.e_invoice.api.core.RequestOptions +import com.e_invoice.api.core.handlers.errorBodyHandler +import com.e_invoice.api.core.handlers.errorHandler +import com.e_invoice.api.core.handlers.jsonHandler +import com.e_invoice.api.core.http.HttpMethod +import com.e_invoice.api.core.http.HttpRequest +import com.e_invoice.api.core.http.HttpResponse +import com.e_invoice.api.core.http.HttpResponse.Handler +import com.e_invoice.api.core.http.HttpResponseFor +import com.e_invoice.api.core.http.parseable +import com.e_invoice.api.core.prepareAsync +import com.e_invoice.api.models.me.MeRetrieveParams +import com.e_invoice.api.models.me.MeRetrieveResponse +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class MeServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + MeServiceAsync { + + private val withRawResponse: MeServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): MeServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): MeServiceAsync = + MeServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: MeRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/me/ + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + MeServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): MeServiceAsync.WithRawResponse = + MeServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: MeRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "me", "") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/documents/UblServiceAsync.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/documents/UblServiceAsync.kt index a965f55..c1f5776 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/documents/UblServiceAsync.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/documents/UblServiceAsync.kt @@ -5,6 +5,8 @@ package com.e_invoice.api.services.async.documents import com.e_invoice.api.core.ClientOptions import com.e_invoice.api.core.RequestOptions import com.e_invoice.api.core.http.HttpResponseFor +import com.e_invoice.api.models.documents.DocumentResponse +import com.e_invoice.api.models.documents.ubl.UblCreateFromUblParams import com.e_invoice.api.models.documents.ubl.UblGetParams import com.e_invoice.api.models.documents.ubl.UblGetResponse import java.util.concurrent.CompletableFuture @@ -24,6 +26,16 @@ interface UblServiceAsync { */ fun withOptions(modifier: Consumer): UblServiceAsync + /** Create a new invoice or credit note from a UBL file */ + fun createFromUbl(params: UblCreateFromUblParams): CompletableFuture = + createFromUbl(params, RequestOptions.none()) + + /** @see createFromUbl */ + fun createFromUbl( + params: UblCreateFromUblParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + /** Get the UBL for an invoice or credit note */ fun get(documentId: String): CompletableFuture = get(documentId, UblGetParams.none()) @@ -66,6 +78,21 @@ interface UblServiceAsync { */ fun withOptions(modifier: Consumer): UblServiceAsync.WithRawResponse + /** + * Returns a raw HTTP response for `post /api/documents/ubl`, but is otherwise the same as + * [UblServiceAsync.createFromUbl]. + */ + fun createFromUbl( + params: UblCreateFromUblParams + ): CompletableFuture> = + createFromUbl(params, RequestOptions.none()) + + /** @see createFromUbl */ + fun createFromUbl( + params: UblCreateFromUblParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + /** * Returns a raw HTTP response for `get /api/documents/{document_id}/ubl`, but is otherwise * the same as [UblServiceAsync.get]. diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/documents/UblServiceAsyncImpl.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/documents/UblServiceAsyncImpl.kt index 75d1d1b..155f769 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/documents/UblServiceAsyncImpl.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/documents/UblServiceAsyncImpl.kt @@ -13,8 +13,11 @@ import com.e_invoice.api.core.http.HttpRequest import com.e_invoice.api.core.http.HttpResponse import com.e_invoice.api.core.http.HttpResponse.Handler import com.e_invoice.api.core.http.HttpResponseFor +import com.e_invoice.api.core.http.multipartFormData import com.e_invoice.api.core.http.parseable import com.e_invoice.api.core.prepareAsync +import com.e_invoice.api.models.documents.DocumentResponse +import com.e_invoice.api.models.documents.ubl.UblCreateFromUblParams import com.e_invoice.api.models.documents.ubl.UblGetParams import com.e_invoice.api.models.documents.ubl.UblGetResponse import java.util.concurrent.CompletableFuture @@ -33,6 +36,13 @@ class UblServiceAsyncImpl internal constructor(private val clientOptions: Client override fun withOptions(modifier: Consumer): UblServiceAsync = UblServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun createFromUbl( + params: UblCreateFromUblParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /api/documents/ubl + withRawResponse().createFromUbl(params, requestOptions).thenApply { it.parse() } + override fun get( params: UblGetParams, requestOptions: RequestOptions, @@ -53,6 +63,37 @@ class UblServiceAsyncImpl internal constructor(private val clientOptions: Client clientOptions.toBuilder().apply(modifier::accept).build() ) + private val createFromUblHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun createFromUbl( + params: UblCreateFromUblParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "documents", "ubl") + .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createFromUblHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + private val getHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/DocumentService.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/DocumentService.kt index b6bb7b9..80373f8 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/DocumentService.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/DocumentService.kt @@ -6,12 +6,16 @@ import com.e_invoice.api.core.ClientOptions import com.e_invoice.api.core.RequestOptions import com.e_invoice.api.core.http.HttpResponseFor import com.e_invoice.api.models.documents.DocumentCreate +import com.e_invoice.api.models.documents.DocumentCreateFromPdfParams +import com.e_invoice.api.models.documents.DocumentCreateFromPdfResponse import com.e_invoice.api.models.documents.DocumentCreateParams import com.e_invoice.api.models.documents.DocumentDeleteParams import com.e_invoice.api.models.documents.DocumentDeleteResponse import com.e_invoice.api.models.documents.DocumentResponse import com.e_invoice.api.models.documents.DocumentRetrieveParams import com.e_invoice.api.models.documents.DocumentSendParams +import com.e_invoice.api.models.documents.DocumentValidateParams +import com.e_invoice.api.models.validate.UblDocumentValidation import com.e_invoice.api.services.blocking.documents.AttachmentService import com.e_invoice.api.services.blocking.documents.UblService import com.google.errorprone.annotations.MustBeClosed @@ -123,6 +127,21 @@ interface DocumentService { fun delete(documentId: String, requestOptions: RequestOptions): DocumentDeleteResponse = delete(documentId, DocumentDeleteParams.none(), requestOptions) + /** + * Create a new invoice or credit note from a PDF file. If the 'ubl_document' field is set in + * the response, it indicates that sufficient details were extracted from the PDF to + * automatically generate a valid UBL document ready for sending. If 'ubl_document' is not set, + * human intervention may be required to ensure compliance. + */ + fun createFromPdf(params: DocumentCreateFromPdfParams): DocumentCreateFromPdfResponse = + createFromPdf(params, RequestOptions.none()) + + /** @see createFromPdf */ + fun createFromPdf( + params: DocumentCreateFromPdfParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): DocumentCreateFromPdfResponse + /** Send an invoice or credit note via Peppol */ fun send(documentId: String): DocumentResponse = send(documentId, DocumentSendParams.none()) @@ -152,6 +171,38 @@ interface DocumentService { fun send(documentId: String, requestOptions: RequestOptions): DocumentResponse = send(documentId, DocumentSendParams.none(), requestOptions) + /** Validate a UBL document according to Peppol BIS Billing 3.0 */ + fun validate(documentId: String): UblDocumentValidation = + validate(documentId, DocumentValidateParams.none()) + + /** @see validate */ + fun validate( + documentId: String, + params: DocumentValidateParams = DocumentValidateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): UblDocumentValidation = + validate(params.toBuilder().documentId(documentId).build(), requestOptions) + + /** @see validate */ + fun validate( + documentId: String, + params: DocumentValidateParams = DocumentValidateParams.none(), + ): UblDocumentValidation = validate(documentId, params, RequestOptions.none()) + + /** @see validate */ + fun validate( + params: DocumentValidateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): UblDocumentValidation + + /** @see validate */ + fun validate(params: DocumentValidateParams): UblDocumentValidation = + validate(params, RequestOptions.none()) + + /** @see validate */ + fun validate(documentId: String, requestOptions: RequestOptions): UblDocumentValidation = + validate(documentId, DocumentValidateParams.none(), requestOptions) + /** A view of [DocumentService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -286,6 +337,23 @@ interface DocumentService { ): HttpResponseFor = delete(documentId, DocumentDeleteParams.none(), requestOptions) + /** + * Returns a raw HTTP response for `post /api/documents/pdf`, but is otherwise the same as + * [DocumentService.createFromPdf]. + */ + @MustBeClosed + fun createFromPdf( + params: DocumentCreateFromPdfParams + ): HttpResponseFor = + createFromPdf(params, RequestOptions.none()) + + /** @see createFromPdf */ + @MustBeClosed + fun createFromPdf( + params: DocumentCreateFromPdfParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + /** * Returns a raw HTTP response for `post /api/documents/{document_id}/send`, but is * otherwise the same as [DocumentService.send]. @@ -329,5 +397,50 @@ interface DocumentService { requestOptions: RequestOptions, ): HttpResponseFor = send(documentId, DocumentSendParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/documents/{document_id}/validate`, but is + * otherwise the same as [DocumentService.validate]. + */ + @MustBeClosed + fun validate(documentId: String): HttpResponseFor = + validate(documentId, DocumentValidateParams.none()) + + /** @see validate */ + @MustBeClosed + fun validate( + documentId: String, + params: DocumentValidateParams = DocumentValidateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + validate(params.toBuilder().documentId(documentId).build(), requestOptions) + + /** @see validate */ + @MustBeClosed + fun validate( + documentId: String, + params: DocumentValidateParams = DocumentValidateParams.none(), + ): HttpResponseFor = + validate(documentId, params, RequestOptions.none()) + + /** @see validate */ + @MustBeClosed + fun validate( + params: DocumentValidateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see validate */ + @MustBeClosed + fun validate(params: DocumentValidateParams): HttpResponseFor = + validate(params, RequestOptions.none()) + + /** @see validate */ + @MustBeClosed + fun validate( + documentId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + validate(documentId, DocumentValidateParams.none(), requestOptions) } } diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/DocumentServiceImpl.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/DocumentServiceImpl.kt index 4b32b73..fc6ec56 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/DocumentServiceImpl.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/DocumentServiceImpl.kt @@ -14,14 +14,19 @@ import com.e_invoice.api.core.http.HttpResponse import com.e_invoice.api.core.http.HttpResponse.Handler import com.e_invoice.api.core.http.HttpResponseFor import com.e_invoice.api.core.http.json +import com.e_invoice.api.core.http.multipartFormData import com.e_invoice.api.core.http.parseable import com.e_invoice.api.core.prepare +import com.e_invoice.api.models.documents.DocumentCreateFromPdfParams +import com.e_invoice.api.models.documents.DocumentCreateFromPdfResponse import com.e_invoice.api.models.documents.DocumentCreateParams import com.e_invoice.api.models.documents.DocumentDeleteParams import com.e_invoice.api.models.documents.DocumentDeleteResponse import com.e_invoice.api.models.documents.DocumentResponse import com.e_invoice.api.models.documents.DocumentRetrieveParams import com.e_invoice.api.models.documents.DocumentSendParams +import com.e_invoice.api.models.documents.DocumentValidateParams +import com.e_invoice.api.models.validate.UblDocumentValidation import com.e_invoice.api.services.blocking.documents.AttachmentService import com.e_invoice.api.services.blocking.documents.AttachmentServiceImpl import com.e_invoice.api.services.blocking.documents.UblService @@ -70,6 +75,13 @@ class DocumentServiceImpl internal constructor(private val clientOptions: Client // delete /api/documents/{document_id} withRawResponse().delete(params, requestOptions).parse() + override fun createFromPdf( + params: DocumentCreateFromPdfParams, + requestOptions: RequestOptions, + ): DocumentCreateFromPdfResponse = + // post /api/documents/pdf + withRawResponse().createFromPdf(params, requestOptions).parse() + override fun send( params: DocumentSendParams, requestOptions: RequestOptions, @@ -77,6 +89,13 @@ class DocumentServiceImpl internal constructor(private val clientOptions: Client // post /api/documents/{document_id}/send withRawResponse().send(params, requestOptions).parse() + override fun validate( + params: DocumentValidateParams, + requestOptions: RequestOptions, + ): UblDocumentValidation = + // post /api/documents/{document_id}/validate + withRawResponse().validate(params, requestOptions).parse() + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : DocumentService.WithRawResponse { @@ -191,6 +210,34 @@ class DocumentServiceImpl internal constructor(private val clientOptions: Client } } + private val createFromPdfHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun createFromPdf( + params: DocumentCreateFromPdfParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "documents", "pdf") + .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createFromPdfHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + private val sendHandler: Handler = jsonHandler(clientOptions.jsonMapper) @@ -221,5 +268,36 @@ class DocumentServiceImpl internal constructor(private val clientOptions: Client } } } + + private val validateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun validate( + params: DocumentValidateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("documentId", params.documentId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "documents", params._pathParam(0), "validate") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { validateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } } diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/MeService.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/MeService.kt new file mode 100644 index 0000000..f6de205 --- /dev/null +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/MeService.kt @@ -0,0 +1,79 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.e_invoice.api.services.blocking + +import com.e_invoice.api.core.ClientOptions +import com.e_invoice.api.core.RequestOptions +import com.e_invoice.api.core.http.HttpResponseFor +import com.e_invoice.api.models.me.MeRetrieveParams +import com.e_invoice.api.models.me.MeRetrieveResponse +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface MeService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): MeService + + /** Retrieve information about your account. */ + fun retrieve(): MeRetrieveResponse = retrieve(MeRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + params: MeRetrieveParams = MeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): MeRetrieveResponse + + /** @see retrieve */ + fun retrieve(params: MeRetrieveParams = MeRetrieveParams.none()): MeRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(requestOptions: RequestOptions): MeRetrieveResponse = + retrieve(MeRetrieveParams.none(), requestOptions) + + /** A view of [MeService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): MeService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/me/`, but is otherwise the same as + * [MeService.retrieve]. + */ + @MustBeClosed + fun retrieve(): HttpResponseFor = retrieve(MeRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: MeRetrieveParams = MeRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: MeRetrieveParams = MeRetrieveParams.none() + ): HttpResponseFor = retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve(requestOptions: RequestOptions): HttpResponseFor = + retrieve(MeRetrieveParams.none(), requestOptions) + } +} diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/MeServiceImpl.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/MeServiceImpl.kt new file mode 100644 index 0000000..715fcbd --- /dev/null +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/MeServiceImpl.kt @@ -0,0 +1,79 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.e_invoice.api.services.blocking + +import com.e_invoice.api.core.ClientOptions +import com.e_invoice.api.core.RequestOptions +import com.e_invoice.api.core.handlers.errorBodyHandler +import com.e_invoice.api.core.handlers.errorHandler +import com.e_invoice.api.core.handlers.jsonHandler +import com.e_invoice.api.core.http.HttpMethod +import com.e_invoice.api.core.http.HttpRequest +import com.e_invoice.api.core.http.HttpResponse +import com.e_invoice.api.core.http.HttpResponse.Handler +import com.e_invoice.api.core.http.HttpResponseFor +import com.e_invoice.api.core.http.parseable +import com.e_invoice.api.core.prepare +import com.e_invoice.api.models.me.MeRetrieveParams +import com.e_invoice.api.models.me.MeRetrieveResponse +import java.util.function.Consumer + +class MeServiceImpl internal constructor(private val clientOptions: ClientOptions) : MeService { + + private val withRawResponse: MeService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): MeService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): MeService = + MeServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun retrieve( + params: MeRetrieveParams, + requestOptions: RequestOptions, + ): MeRetrieveResponse = + // get /api/me/ + withRawResponse().retrieve(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + MeService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): MeService.WithRawResponse = + MeServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: MeRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "me", "") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/documents/UblService.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/documents/UblService.kt index b9d4d30..cab4bcd 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/documents/UblService.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/documents/UblService.kt @@ -5,6 +5,8 @@ package com.e_invoice.api.services.blocking.documents import com.e_invoice.api.core.ClientOptions import com.e_invoice.api.core.RequestOptions import com.e_invoice.api.core.http.HttpResponseFor +import com.e_invoice.api.models.documents.DocumentResponse +import com.e_invoice.api.models.documents.ubl.UblCreateFromUblParams import com.e_invoice.api.models.documents.ubl.UblGetParams import com.e_invoice.api.models.documents.ubl.UblGetResponse import com.google.errorprone.annotations.MustBeClosed @@ -24,6 +26,16 @@ interface UblService { */ fun withOptions(modifier: Consumer): UblService + /** Create a new invoice or credit note from a UBL file */ + fun createFromUbl(params: UblCreateFromUblParams): DocumentResponse = + createFromUbl(params, RequestOptions.none()) + + /** @see createFromUbl */ + fun createFromUbl( + params: UblCreateFromUblParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): DocumentResponse + /** Get the UBL for an invoice or credit note */ fun get(documentId: String): UblGetResponse = get(documentId, UblGetParams.none()) @@ -61,6 +73,21 @@ interface UblService { */ fun withOptions(modifier: Consumer): UblService.WithRawResponse + /** + * Returns a raw HTTP response for `post /api/documents/ubl`, but is otherwise the same as + * [UblService.createFromUbl]. + */ + @MustBeClosed + fun createFromUbl(params: UblCreateFromUblParams): HttpResponseFor = + createFromUbl(params, RequestOptions.none()) + + /** @see createFromUbl */ + @MustBeClosed + fun createFromUbl( + params: UblCreateFromUblParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + /** * Returns a raw HTTP response for `get /api/documents/{document_id}/ubl`, but is otherwise * the same as [UblService.get]. diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/documents/UblServiceImpl.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/documents/UblServiceImpl.kt index 746287a..a35c082 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/documents/UblServiceImpl.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/documents/UblServiceImpl.kt @@ -13,8 +13,11 @@ import com.e_invoice.api.core.http.HttpRequest import com.e_invoice.api.core.http.HttpResponse import com.e_invoice.api.core.http.HttpResponse.Handler import com.e_invoice.api.core.http.HttpResponseFor +import com.e_invoice.api.core.http.multipartFormData import com.e_invoice.api.core.http.parseable import com.e_invoice.api.core.prepare +import com.e_invoice.api.models.documents.DocumentResponse +import com.e_invoice.api.models.documents.ubl.UblCreateFromUblParams import com.e_invoice.api.models.documents.ubl.UblGetParams import com.e_invoice.api.models.documents.ubl.UblGetResponse import java.util.function.Consumer @@ -31,6 +34,13 @@ class UblServiceImpl internal constructor(private val clientOptions: ClientOptio override fun withOptions(modifier: Consumer): UblService = UblServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun createFromUbl( + params: UblCreateFromUblParams, + requestOptions: RequestOptions, + ): DocumentResponse = + // post /api/documents/ubl + withRawResponse().createFromUbl(params, requestOptions).parse() + override fun get(params: UblGetParams, requestOptions: RequestOptions): UblGetResponse = // get /api/documents/{document_id}/ubl withRawResponse().get(params, requestOptions).parse() @@ -48,6 +58,34 @@ class UblServiceImpl internal constructor(private val clientOptions: ClientOptio clientOptions.toBuilder().apply(modifier::accept).build() ) + private val createFromUblHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun createFromUbl( + params: UblCreateFromUblParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "documents", "ubl") + .body(multipartFormData(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createFromUblHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + private val getHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/AllowanceTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/AllowanceTest.kt new file mode 100644 index 0000000..5f6c011 --- /dev/null +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/AllowanceTest.kt @@ -0,0 +1,56 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.e_invoice.api.models.documents + +import com.e_invoice.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class AllowanceTest { + + @Test + fun create() { + val allowance = + Allowance.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + + assertThat(allowance.amount()).contains("amount") + assertThat(allowance.baseAmount()).contains("base_amount") + assertThat(allowance.multiplierFactor()).contains("multiplier_factor") + assertThat(allowance.reason()).contains("reason") + assertThat(allowance.reasonCode()).contains("reason_code") + assertThat(allowance.taxCode()).contains(Allowance.TaxCode.AE) + assertThat(allowance.taxRate()).contains("tax_rate") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val allowance = + Allowance.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + + val roundtrippedAllowance = + jsonMapper.readValue( + jsonMapper.writeValueAsString(allowance), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAllowance).isEqualTo(allowance) + } +} diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/ChargeTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/ChargeTest.kt new file mode 100644 index 0000000..8a868cb --- /dev/null +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/ChargeTest.kt @@ -0,0 +1,53 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.e_invoice.api.models.documents + +import com.e_invoice.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ChargeTest { + + @Test + fun create() { + val charge = + Charge.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + + assertThat(charge.amount()).contains("amount") + assertThat(charge.baseAmount()).contains("base_amount") + assertThat(charge.multiplierFactor()).contains("multiplier_factor") + assertThat(charge.reason()).contains("reason") + assertThat(charge.reasonCode()).contains("reason_code") + assertThat(charge.taxCode()).contains(Charge.TaxCode.AE) + assertThat(charge.taxRate()).contains("tax_rate") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val charge = + Charge.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + + val roundtrippedCharge = + jsonMapper.readValue(jsonMapper.writeValueAsString(charge), jacksonTypeRef()) + + assertThat(roundtrippedCharge).isEqualTo(charge) + } +} diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfParamsTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfParamsTest.kt new file mode 100644 index 0000000..e644893 --- /dev/null +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfParamsTest.kt @@ -0,0 +1,101 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.e_invoice.api.models.documents + +import com.e_invoice.api.core.MultipartField +import com.e_invoice.api.core.http.QueryParams +import java.io.InputStream +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DocumentCreateFromPdfParamsTest { + + @Test + fun create() { + DocumentCreateFromPdfParams.builder() + .customerTaxId("customer_tax_id") + .vendorTaxId("vendor_tax_id") + .file("some content".byteInputStream()) + .build() + } + + @Test + fun queryParams() { + val params = + DocumentCreateFromPdfParams.builder() + .customerTaxId("customer_tax_id") + .vendorTaxId("vendor_tax_id") + .file("some content".byteInputStream()) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("customer_tax_id", "customer_tax_id") + .put("vendor_tax_id", "vendor_tax_id") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + DocumentCreateFromPdfParams.builder().file("some content".byteInputStream()).build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } + + @Test + fun body() { + val params = + DocumentCreateFromPdfParams.builder() + .customerTaxId("customer_tax_id") + .vendorTaxId("vendor_tax_id") + .file("some content".byteInputStream()) + .build() + + val body = params._body() + + assertThat(body.filterValues { !it.value.isNull() }) + .usingRecursiveComparison() + // TODO(AssertJ): Replace this and the `mapValues` below with: + // https://github.com/assertj/assertj/issues/3165 + .withEqualsForType( + { a, b -> a.readBytes() contentEquals b.readBytes() }, + InputStream::class.java, + ) + .isEqualTo( + mapOf("file" to MultipartField.of("some content".byteInputStream())).mapValues { + (_, field) -> + field.map { (it as? ByteArray)?.inputStream() ?: it } + } + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + DocumentCreateFromPdfParams.builder().file("some content".byteInputStream()).build() + + val body = params._body() + + assertThat(body.filterValues { !it.value.isNull() }) + .usingRecursiveComparison() + // TODO(AssertJ): Replace this and the `mapValues` below with: + // https://github.com/assertj/assertj/issues/3165 + .withEqualsForType( + { a, b -> a.readBytes() contentEquals b.readBytes() }, + InputStream::class.java, + ) + .isEqualTo( + mapOf("file" to MultipartField.of("some content".byteInputStream())).mapValues { + (_, field) -> + field.map { (it as? ByteArray)?.inputStream() ?: it } + } + ) + } +} diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponseTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponseTest.kt new file mode 100644 index 0000000..47aa52d --- /dev/null +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponseTest.kt @@ -0,0 +1,420 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.e_invoice.api.models.documents + +import com.e_invoice.api.core.jsonMapper +import com.e_invoice.api.models.inbox.DocumentState +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.LocalDate +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DocumentCreateFromPdfResponseTest { + + @Test + fun create() { + val documentCreateFromPdfResponse = + DocumentCreateFromPdfResponse.builder() + .addAllowance( + Allowance.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) + .amountDue("amount_due") + .addAttachment( + DocumentAttachmentCreate.builder() + .fileName("file_name") + .fileData("file_data") + .fileSize(0L) + .fileType("file_type") + .build() + ) + .billingAddress("billing_address") + .billingAddressRecipient("billing_address_recipient") + .addCharge( + Charge.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) + .currency(CurrencyCode.EUR) + .customerAddress("customer_address") + .customerAddressRecipient("customer_address_recipient") + .customerEmail("customer_email") + .customerId("customer_id") + .customerName("customer_name") + .customerTaxId("customer_tax_id") + .direction(DocumentDirection.INBOUND) + .documentType(DocumentType.INVOICE) + .dueDate(LocalDate.parse("2019-12-27")) + .invoiceDate(LocalDate.parse("2019-12-27")) + .invoiceId("invoice_id") + .invoiceTotal("invoice_total") + .addItem( + DocumentCreateFromPdfResponse.Item.builder() + .addAllowance( + Allowance.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) + .amount("amount") + .addCharge( + Charge.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) + .date(null) + .description("description") + .productCode("product_code") + .quantity("quantity") + .tax("tax") + .taxRate("tax_rate") + .unit(UnitOfMeasureCode._10) + .unitPrice("unit_price") + .build() + ) + .note("note") + .addPaymentDetail( + PaymentDetailCreate.builder() + .bankAccountNumber("bank_account_number") + .iban("iban") + .paymentReference("payment_reference") + .swift("swift") + .build() + ) + .paymentTerm("payment_term") + .previousUnpaidBalance("previous_unpaid_balance") + .purchaseOrder("purchase_order") + .remittanceAddress("remittance_address") + .remittanceAddressRecipient("remittance_address_recipient") + .serviceAddress("service_address") + .serviceAddressRecipient("service_address_recipient") + .serviceEndDate(LocalDate.parse("2019-12-27")) + .serviceStartDate(LocalDate.parse("2019-12-27")) + .shippingAddress("shipping_address") + .shippingAddressRecipient("shipping_address_recipient") + .state(DocumentState.DRAFT) + .subtotal("subtotal") + .success(true) + .taxCode(DocumentCreateFromPdfResponse.TaxCode.AE) + .addTaxDetail( + DocumentCreateFromPdfResponse.TaxDetail.builder() + .amount("amount") + .rate("rate") + .build() + ) + .totalDiscount("total_discount") + .totalTax("total_tax") + .ublDocument("ubl_document") + .vatex(DocumentCreateFromPdfResponse.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") + .vendorAddress("vendor_address") + .vendorAddressRecipient("vendor_address_recipient") + .vendorEmail("vendor_email") + .vendorName("vendor_name") + .vendorTaxId("vendor_tax_id") + .build() + + assertThat(documentCreateFromPdfResponse.allowances().getOrNull()) + .containsExactly( + Allowance.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) + assertThat(documentCreateFromPdfResponse.amountDue()).contains("amount_due") + assertThat(documentCreateFromPdfResponse.attachments().getOrNull()) + .containsExactly( + DocumentAttachmentCreate.builder() + .fileName("file_name") + .fileData("file_data") + .fileSize(0L) + .fileType("file_type") + .build() + ) + assertThat(documentCreateFromPdfResponse.billingAddress()).contains("billing_address") + assertThat(documentCreateFromPdfResponse.billingAddressRecipient()) + .contains("billing_address_recipient") + assertThat(documentCreateFromPdfResponse.charges().getOrNull()) + .containsExactly( + Charge.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) + assertThat(documentCreateFromPdfResponse.currency()).contains(CurrencyCode.EUR) + assertThat(documentCreateFromPdfResponse.customerAddress()).contains("customer_address") + assertThat(documentCreateFromPdfResponse.customerAddressRecipient()) + .contains("customer_address_recipient") + assertThat(documentCreateFromPdfResponse.customerEmail()).contains("customer_email") + assertThat(documentCreateFromPdfResponse.customerId()).contains("customer_id") + assertThat(documentCreateFromPdfResponse.customerName()).contains("customer_name") + assertThat(documentCreateFromPdfResponse.customerTaxId()).contains("customer_tax_id") + assertThat(documentCreateFromPdfResponse.direction()).contains(DocumentDirection.INBOUND) + assertThat(documentCreateFromPdfResponse.documentType()).contains(DocumentType.INVOICE) + assertThat(documentCreateFromPdfResponse.dueDate()).contains(LocalDate.parse("2019-12-27")) + assertThat(documentCreateFromPdfResponse.invoiceDate()) + .contains(LocalDate.parse("2019-12-27")) + assertThat(documentCreateFromPdfResponse.invoiceId()).contains("invoice_id") + assertThat(documentCreateFromPdfResponse.invoiceTotal()).contains("invoice_total") + assertThat(documentCreateFromPdfResponse.items().getOrNull()) + .containsExactly( + DocumentCreateFromPdfResponse.Item.builder() + .addAllowance( + Allowance.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) + .amount("amount") + .addCharge( + Charge.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) + .date(null) + .description("description") + .productCode("product_code") + .quantity("quantity") + .tax("tax") + .taxRate("tax_rate") + .unit(UnitOfMeasureCode._10) + .unitPrice("unit_price") + .build() + ) + assertThat(documentCreateFromPdfResponse.note()).contains("note") + assertThat(documentCreateFromPdfResponse.paymentDetails().getOrNull()) + .containsExactly( + PaymentDetailCreate.builder() + .bankAccountNumber("bank_account_number") + .iban("iban") + .paymentReference("payment_reference") + .swift("swift") + .build() + ) + assertThat(documentCreateFromPdfResponse.paymentTerm()).contains("payment_term") + assertThat(documentCreateFromPdfResponse.previousUnpaidBalance()) + .contains("previous_unpaid_balance") + assertThat(documentCreateFromPdfResponse.purchaseOrder()).contains("purchase_order") + assertThat(documentCreateFromPdfResponse.remittanceAddress()).contains("remittance_address") + assertThat(documentCreateFromPdfResponse.remittanceAddressRecipient()) + .contains("remittance_address_recipient") + assertThat(documentCreateFromPdfResponse.serviceAddress()).contains("service_address") + assertThat(documentCreateFromPdfResponse.serviceAddressRecipient()) + .contains("service_address_recipient") + assertThat(documentCreateFromPdfResponse.serviceEndDate()) + .contains(LocalDate.parse("2019-12-27")) + assertThat(documentCreateFromPdfResponse.serviceStartDate()) + .contains(LocalDate.parse("2019-12-27")) + assertThat(documentCreateFromPdfResponse.shippingAddress()).contains("shipping_address") + assertThat(documentCreateFromPdfResponse.shippingAddressRecipient()) + .contains("shipping_address_recipient") + assertThat(documentCreateFromPdfResponse.state()).contains(DocumentState.DRAFT) + assertThat(documentCreateFromPdfResponse.subtotal()).contains("subtotal") + assertThat(documentCreateFromPdfResponse.success()).contains(true) + assertThat(documentCreateFromPdfResponse.taxCode()) + .contains(DocumentCreateFromPdfResponse.TaxCode.AE) + assertThat(documentCreateFromPdfResponse.taxDetails().getOrNull()) + .containsExactly( + DocumentCreateFromPdfResponse.TaxDetail.builder() + .amount("amount") + .rate("rate") + .build() + ) + assertThat(documentCreateFromPdfResponse.totalDiscount()).contains("total_discount") + assertThat(documentCreateFromPdfResponse.totalTax()).contains("total_tax") + assertThat(documentCreateFromPdfResponse.ublDocument()).contains("ubl_document") + assertThat(documentCreateFromPdfResponse.vatex()) + .contains(DocumentCreateFromPdfResponse.Vatex.VATEX_EU_79_C) + assertThat(documentCreateFromPdfResponse.vatexNote()).contains("vatex_note") + assertThat(documentCreateFromPdfResponse.vendorAddress()).contains("vendor_address") + assertThat(documentCreateFromPdfResponse.vendorAddressRecipient()) + .contains("vendor_address_recipient") + assertThat(documentCreateFromPdfResponse.vendorEmail()).contains("vendor_email") + assertThat(documentCreateFromPdfResponse.vendorName()).contains("vendor_name") + assertThat(documentCreateFromPdfResponse.vendorTaxId()).contains("vendor_tax_id") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val documentCreateFromPdfResponse = + DocumentCreateFromPdfResponse.builder() + .addAllowance( + Allowance.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) + .amountDue("amount_due") + .addAttachment( + DocumentAttachmentCreate.builder() + .fileName("file_name") + .fileData("file_data") + .fileSize(0L) + .fileType("file_type") + .build() + ) + .billingAddress("billing_address") + .billingAddressRecipient("billing_address_recipient") + .addCharge( + Charge.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) + .currency(CurrencyCode.EUR) + .customerAddress("customer_address") + .customerAddressRecipient("customer_address_recipient") + .customerEmail("customer_email") + .customerId("customer_id") + .customerName("customer_name") + .customerTaxId("customer_tax_id") + .direction(DocumentDirection.INBOUND) + .documentType(DocumentType.INVOICE) + .dueDate(LocalDate.parse("2019-12-27")) + .invoiceDate(LocalDate.parse("2019-12-27")) + .invoiceId("invoice_id") + .invoiceTotal("invoice_total") + .addItem( + DocumentCreateFromPdfResponse.Item.builder() + .addAllowance( + Allowance.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(Allowance.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) + .amount("amount") + .addCharge( + Charge.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(Charge.TaxCode.AE) + .taxRate("tax_rate") + .build() + ) + .date(null) + .description("description") + .productCode("product_code") + .quantity("quantity") + .tax("tax") + .taxRate("tax_rate") + .unit(UnitOfMeasureCode._10) + .unitPrice("unit_price") + .build() + ) + .note("note") + .addPaymentDetail( + PaymentDetailCreate.builder() + .bankAccountNumber("bank_account_number") + .iban("iban") + .paymentReference("payment_reference") + .swift("swift") + .build() + ) + .paymentTerm("payment_term") + .previousUnpaidBalance("previous_unpaid_balance") + .purchaseOrder("purchase_order") + .remittanceAddress("remittance_address") + .remittanceAddressRecipient("remittance_address_recipient") + .serviceAddress("service_address") + .serviceAddressRecipient("service_address_recipient") + .serviceEndDate(LocalDate.parse("2019-12-27")) + .serviceStartDate(LocalDate.parse("2019-12-27")) + .shippingAddress("shipping_address") + .shippingAddressRecipient("shipping_address_recipient") + .state(DocumentState.DRAFT) + .subtotal("subtotal") + .success(true) + .taxCode(DocumentCreateFromPdfResponse.TaxCode.AE) + .addTaxDetail( + DocumentCreateFromPdfResponse.TaxDetail.builder() + .amount("amount") + .rate("rate") + .build() + ) + .totalDiscount("total_discount") + .totalTax("total_tax") + .ublDocument("ubl_document") + .vatex(DocumentCreateFromPdfResponse.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") + .vendorAddress("vendor_address") + .vendorAddressRecipient("vendor_address_recipient") + .vendorEmail("vendor_email") + .vendorName("vendor_name") + .vendorTaxId("vendor_tax_id") + .build() + + val roundtrippedDocumentCreateFromPdfResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(documentCreateFromPdfResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedDocumentCreateFromPdfResponse) + .isEqualTo(documentCreateFromPdfResponse) + } +} diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentResponseTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentResponseTest.kt index 40c1b42..7568d34 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentResponseTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentResponseTest.kt @@ -68,25 +68,25 @@ internal class DocumentResponseTest { .addItem( DocumentResponse.Item.builder() .addAllowance( - DocumentResponse.Item.Allowance.builder() + Allowance.builder() .amount("amount") .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") .reasonCode("reason_code") - .taxCode(DocumentResponse.Item.Allowance.TaxCode.AE) + .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() ) .amount("amount") .addCharge( - DocumentResponse.Item.Charge.builder() + Charge.builder() .amount("amount") .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") .reasonCode("reason_code") - .taxCode(DocumentResponse.Item.Charge.TaxCode.AE) + .taxCode(Charge.TaxCode.AE) .taxRate("tax_rate") .build() ) @@ -193,25 +193,25 @@ internal class DocumentResponseTest { .containsExactly( DocumentResponse.Item.builder() .addAllowance( - DocumentResponse.Item.Allowance.builder() + Allowance.builder() .amount("amount") .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") .reasonCode("reason_code") - .taxCode(DocumentResponse.Item.Allowance.TaxCode.AE) + .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() ) .amount("amount") .addCharge( - DocumentResponse.Item.Charge.builder() + Charge.builder() .amount("amount") .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") .reasonCode("reason_code") - .taxCode(DocumentResponse.Item.Charge.TaxCode.AE) + .taxCode(Charge.TaxCode.AE) .taxRate("tax_rate") .build() ) @@ -322,25 +322,25 @@ internal class DocumentResponseTest { .addItem( DocumentResponse.Item.builder() .addAllowance( - DocumentResponse.Item.Allowance.builder() + Allowance.builder() .amount("amount") .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") .reasonCode("reason_code") - .taxCode(DocumentResponse.Item.Allowance.TaxCode.AE) + .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() ) .amount("amount") .addCharge( - DocumentResponse.Item.Charge.builder() + Charge.builder() .amount("amount") .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") .reasonCode("reason_code") - .taxCode(DocumentResponse.Item.Charge.TaxCode.AE) + .taxCode(Charge.TaxCode.AE) .taxRate("tax_rate") .build() ) diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentValidateParamsTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentValidateParamsTest.kt new file mode 100644 index 0000000..e012ebc --- /dev/null +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentValidateParamsTest.kt @@ -0,0 +1,23 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.e_invoice.api.models.documents + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DocumentValidateParamsTest { + + @Test + fun create() { + DocumentValidateParams.builder().documentId("document_id").build() + } + + @Test + fun pathParams() { + val params = DocumentValidateParams.builder().documentId("document_id").build() + + assertThat(params._pathParam(0)).isEqualTo("document_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/ubl/UblCreateFromUblParamsTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/ubl/UblCreateFromUblParamsTest.kt new file mode 100644 index 0000000..a2fa17b --- /dev/null +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/ubl/UblCreateFromUblParamsTest.kt @@ -0,0 +1,38 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.e_invoice.api.models.documents.ubl + +import com.e_invoice.api.core.MultipartField +import java.io.InputStream +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class UblCreateFromUblParamsTest { + + @Test + fun create() { + UblCreateFromUblParams.builder().file("some content".byteInputStream()).build() + } + + @Test + fun body() { + val params = UblCreateFromUblParams.builder().file("some content".byteInputStream()).build() + + val body = params._body() + + assertThat(body.filterValues { !it.value.isNull() }) + .usingRecursiveComparison() + // TODO(AssertJ): Replace this and the `mapValues` below with: + // https://github.com/assertj/assertj/issues/3165 + .withEqualsForType( + { a, b -> a.readBytes() contentEquals b.readBytes() }, + InputStream::class.java, + ) + .isEqualTo( + mapOf("file" to MultipartField.of("some content".byteInputStream())).mapValues { + (_, field) -> + field.map { (it as? ByteArray)?.inputStream() ?: it } + } + ) + } +} diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt index 98ee424..92e57e4 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt @@ -3,6 +3,8 @@ package com.e_invoice.api.models.inbox import com.e_invoice.api.core.jsonMapper +import com.e_invoice.api.models.documents.Allowance +import com.e_invoice.api.models.documents.Charge import com.e_invoice.api.models.documents.CurrencyCode import com.e_invoice.api.models.documents.DocumentDirection import com.e_invoice.api.models.documents.DocumentResponse @@ -73,25 +75,25 @@ internal class PaginatedDocumentResponseTest { .addItem( DocumentResponse.Item.builder() .addAllowance( - DocumentResponse.Item.Allowance.builder() + Allowance.builder() .amount("amount") .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") .reasonCode("reason_code") - .taxCode(DocumentResponse.Item.Allowance.TaxCode.AE) + .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() ) .amount("amount") .addCharge( - DocumentResponse.Item.Charge.builder() + Charge.builder() .amount("amount") .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") .reasonCode("reason_code") - .taxCode(DocumentResponse.Item.Charge.TaxCode.AE) + .taxCode(Charge.TaxCode.AE) .taxRate("tax_rate") .build() ) @@ -205,25 +207,25 @@ internal class PaginatedDocumentResponseTest { .addItem( DocumentResponse.Item.builder() .addAllowance( - DocumentResponse.Item.Allowance.builder() + Allowance.builder() .amount("amount") .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") .reasonCode("reason_code") - .taxCode(DocumentResponse.Item.Allowance.TaxCode.AE) + .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() ) .amount("amount") .addCharge( - DocumentResponse.Item.Charge.builder() + Charge.builder() .amount("amount") .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") .reasonCode("reason_code") - .taxCode(DocumentResponse.Item.Charge.TaxCode.AE) + .taxCode(Charge.TaxCode.AE) .taxRate("tax_rate") .build() ) @@ -338,25 +340,25 @@ internal class PaginatedDocumentResponseTest { .addItem( DocumentResponse.Item.builder() .addAllowance( - DocumentResponse.Item.Allowance.builder() + Allowance.builder() .amount("amount") .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") .reasonCode("reason_code") - .taxCode(DocumentResponse.Item.Allowance.TaxCode.AE) + .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() ) .amount("amount") .addCharge( - DocumentResponse.Item.Charge.builder() + Charge.builder() .amount("amount") .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") .reasonCode("reason_code") - .taxCode(DocumentResponse.Item.Charge.TaxCode.AE) + .taxCode(Charge.TaxCode.AE) .taxRate("tax_rate") .build() ) diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/me/MeRetrieveParamsTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/me/MeRetrieveParamsTest.kt new file mode 100644 index 0000000..c7522d1 --- /dev/null +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/me/MeRetrieveParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.e_invoice.api.models.me + +import org.junit.jupiter.api.Test + +internal class MeRetrieveParamsTest { + + @Test + fun create() { + MeRetrieveParams.builder().build() + } +} diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/me/MeRetrieveResponseTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/me/MeRetrieveResponseTest.kt new file mode 100644 index 0000000..2a16e6a --- /dev/null +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/me/MeRetrieveResponseTest.kt @@ -0,0 +1,86 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.e_invoice.api.models.me + +import com.e_invoice.api.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class MeRetrieveResponseTest { + + @Test + fun create() { + val meRetrieveResponse = + MeRetrieveResponse.builder() + .creditBalance(0L) + .name("name") + .plan(MeRetrieveResponse.Plan.STARTER) + .bccRecipientEmail("bcc_recipient_email") + .companyAddress("company_address") + .companyCity("company_city") + .companyCountry("company_country") + .companyEmail("company_email") + .companyName("company_name") + .companyNumber("company_number") + .companyZip("company_zip") + .description("description") + .addIban("string") + .addPeppolId("string") + .smpRegistration(true) + .smpRegistrationDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(meRetrieveResponse.creditBalance()).isEqualTo(0L) + assertThat(meRetrieveResponse.name()).isEqualTo("name") + assertThat(meRetrieveResponse.plan()).isEqualTo(MeRetrieveResponse.Plan.STARTER) + assertThat(meRetrieveResponse.bccRecipientEmail()).contains("bcc_recipient_email") + assertThat(meRetrieveResponse.companyAddress()).contains("company_address") + assertThat(meRetrieveResponse.companyCity()).contains("company_city") + assertThat(meRetrieveResponse.companyCountry()).contains("company_country") + assertThat(meRetrieveResponse.companyEmail()).contains("company_email") + assertThat(meRetrieveResponse.companyName()).contains("company_name") + assertThat(meRetrieveResponse.companyNumber()).contains("company_number") + assertThat(meRetrieveResponse.companyZip()).contains("company_zip") + assertThat(meRetrieveResponse.description()).contains("description") + assertThat(meRetrieveResponse.ibans().getOrNull()).containsExactly("string") + assertThat(meRetrieveResponse.peppolIds().getOrNull()).containsExactly("string") + assertThat(meRetrieveResponse.smpRegistration()).contains(true) + assertThat(meRetrieveResponse.smpRegistrationDate()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val meRetrieveResponse = + MeRetrieveResponse.builder() + .creditBalance(0L) + .name("name") + .plan(MeRetrieveResponse.Plan.STARTER) + .bccRecipientEmail("bcc_recipient_email") + .companyAddress("company_address") + .companyCity("company_city") + .companyCountry("company_country") + .companyEmail("company_email") + .companyName("company_name") + .companyNumber("company_number") + .companyZip("company_zip") + .description("description") + .addIban("string") + .addPeppolId("string") + .smpRegistration(true) + .smpRegistrationDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedMeRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(meRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedMeRetrieveResponse).isEqualTo(meRetrieveResponse) + } +} diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncTest.kt index 922dcf7..22a131e 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncTest.kt @@ -7,6 +7,7 @@ import com.e_invoice.api.client.okhttp.EInvoiceOkHttpClientAsync import com.e_invoice.api.models.documents.CurrencyCode import com.e_invoice.api.models.documents.DocumentAttachmentCreate import com.e_invoice.api.models.documents.DocumentCreate +import com.e_invoice.api.models.documents.DocumentCreateFromPdfParams import com.e_invoice.api.models.documents.DocumentDirection import com.e_invoice.api.models.documents.DocumentSendParams import com.e_invoice.api.models.documents.DocumentType @@ -189,6 +190,29 @@ internal class DocumentServiceAsyncTest { document.validate() } + @Disabled("Prism tests are disabled") + @Test + fun createFromPdf() { + val client = + EInvoiceOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val documentServiceAsync = client.documents() + + val responseFuture = + documentServiceAsync.createFromPdf( + DocumentCreateFromPdfParams.builder() + .customerTaxId("customer_tax_id") + .vendorTaxId("vendor_tax_id") + .file("some content".byteInputStream()) + .build() + ) + + val response = responseFuture.get() + response.validate() + } + @Disabled("Prism tests are disabled") @Test fun send() { @@ -214,4 +238,20 @@ internal class DocumentServiceAsyncTest { val documentResponse = documentResponseFuture.get() documentResponse.validate() } + + @Disabled("Prism tests are disabled") + @Test + fun validate() { + val client = + EInvoiceOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val documentServiceAsync = client.documents() + + val ublDocumentValidationFuture = documentServiceAsync.validate("document_id") + + val ublDocumentValidation = ublDocumentValidationFuture.get() + ublDocumentValidation.validate() + } } diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/MeServiceAsyncTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/MeServiceAsyncTest.kt new file mode 100644 index 0000000..afeb131 --- /dev/null +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/MeServiceAsyncTest.kt @@ -0,0 +1,29 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.e_invoice.api.services.async + +import com.e_invoice.api.TestServerExtension +import com.e_invoice.api.client.okhttp.EInvoiceOkHttpClientAsync +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class MeServiceAsyncTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + EInvoiceOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val meServiceAsync = client.me() + + val meFuture = meServiceAsync.retrieve() + + val me = meFuture.get() + me.validate() + } +} diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/documents/UblServiceAsyncTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/documents/UblServiceAsyncTest.kt index 230f1e7..57b55f9 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/documents/UblServiceAsyncTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/documents/UblServiceAsyncTest.kt @@ -4,6 +4,7 @@ package com.e_invoice.api.services.async.documents import com.e_invoice.api.TestServerExtension import com.e_invoice.api.client.okhttp.EInvoiceOkHttpClientAsync +import com.e_invoice.api.models.documents.ubl.UblCreateFromUblParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -11,6 +12,25 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class UblServiceAsyncTest { + @Disabled("Prism tests are disabled") + @Test + fun createFromUbl() { + val client = + EInvoiceOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val ublServiceAsync = client.documents().ubl() + + val documentResponseFuture = + ublServiceAsync.createFromUbl( + UblCreateFromUblParams.builder().file("some content".byteInputStream()).build() + ) + + val documentResponse = documentResponseFuture.get() + documentResponse.validate() + } + @Disabled("Prism tests are disabled") @Test fun get() { diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/DocumentServiceTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/DocumentServiceTest.kt index 28da298..a872082 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/DocumentServiceTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/DocumentServiceTest.kt @@ -7,6 +7,7 @@ import com.e_invoice.api.client.okhttp.EInvoiceOkHttpClient import com.e_invoice.api.models.documents.CurrencyCode import com.e_invoice.api.models.documents.DocumentAttachmentCreate import com.e_invoice.api.models.documents.DocumentCreate +import com.e_invoice.api.models.documents.DocumentCreateFromPdfParams import com.e_invoice.api.models.documents.DocumentDirection import com.e_invoice.api.models.documents.DocumentSendParams import com.e_invoice.api.models.documents.DocumentType @@ -186,6 +187,28 @@ internal class DocumentServiceTest { document.validate() } + @Disabled("Prism tests are disabled") + @Test + fun createFromPdf() { + val client = + EInvoiceOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val documentService = client.documents() + + val response = + documentService.createFromPdf( + DocumentCreateFromPdfParams.builder() + .customerTaxId("customer_tax_id") + .vendorTaxId("vendor_tax_id") + .file("some content".byteInputStream()) + .build() + ) + + response.validate() + } + @Disabled("Prism tests are disabled") @Test fun send() { @@ -210,4 +233,19 @@ internal class DocumentServiceTest { documentResponse.validate() } + + @Disabled("Prism tests are disabled") + @Test + fun validate() { + val client = + EInvoiceOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val documentService = client.documents() + + val ublDocumentValidation = documentService.validate("document_id") + + ublDocumentValidation.validate() + } } diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/MeServiceTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/MeServiceTest.kt new file mode 100644 index 0000000..a41faee --- /dev/null +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/MeServiceTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.e_invoice.api.services.blocking + +import com.e_invoice.api.TestServerExtension +import com.e_invoice.api.client.okhttp.EInvoiceOkHttpClient +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class MeServiceTest { + + @Disabled("Prism tests are disabled") + @Test + fun retrieve() { + val client = + EInvoiceOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val meService = client.me() + + val me = meService.retrieve() + + me.validate() + } +} diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/documents/UblServiceTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/documents/UblServiceTest.kt index e07b788..935995b 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/documents/UblServiceTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/documents/UblServiceTest.kt @@ -4,6 +4,7 @@ package com.e_invoice.api.services.blocking.documents import com.e_invoice.api.TestServerExtension import com.e_invoice.api.client.okhttp.EInvoiceOkHttpClient +import com.e_invoice.api.models.documents.ubl.UblCreateFromUblParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -11,6 +12,24 @@ import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class UblServiceTest { + @Disabled("Prism tests are disabled") + @Test + fun createFromUbl() { + val client = + EInvoiceOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val ublService = client.documents().ubl() + + val documentResponse = + ublService.createFromUbl( + UblCreateFromUblParams.builder().file("some content".byteInputStream()).build() + ) + + documentResponse.validate() + } + @Disabled("Prism tests are disabled") @Test fun get() { diff --git a/e-invoice-java-proguard-test/src/test/kotlin/com/e_invoice/api/proguard/ProGuardCompatibilityTest.kt b/e-invoice-java-proguard-test/src/test/kotlin/com/e_invoice/api/proguard/ProGuardCompatibilityTest.kt index f97f978..e6113ec 100644 --- a/e-invoice-java-proguard-test/src/test/kotlin/com/e_invoice/api/proguard/ProGuardCompatibilityTest.kt +++ b/e-invoice-java-proguard-test/src/test/kotlin/com/e_invoice/api/proguard/ProGuardCompatibilityTest.kt @@ -4,8 +4,8 @@ package com.e_invoice.api.proguard import com.e_invoice.api.client.okhttp.EInvoiceOkHttpClient import com.e_invoice.api.core.jsonMapper +import com.e_invoice.api.models.documents.Allowance import com.e_invoice.api.models.documents.CurrencyCode -import com.e_invoice.api.models.documents.DocumentAttachmentCreate import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import kotlin.reflect.full.memberFunctions import kotlin.reflect.jvm.javaMethod @@ -53,27 +53,31 @@ internal class ProGuardCompatibilityTest { assertThat(client.outbox()).isNotNull() assertThat(client.validate()).isNotNull() assertThat(client.lookup()).isNotNull() + assertThat(client.me()).isNotNull() assertThat(client.webhooks()).isNotNull() } @Test - fun documentAttachmentCreateRoundtrip() { + fun allowanceRoundtrip() { val jsonMapper = jsonMapper() - val documentAttachmentCreate = - DocumentAttachmentCreate.builder() - .fileName("file_name") - .fileData("file_data") - .fileSize(0L) - .fileType("file_type") + val allowance = + Allowance.builder() + .amount("amount") + .baseAmount("base_amount") + .multiplierFactor("multiplier_factor") + .reason("reason") + .reasonCode("reason_code") + .taxCode(Allowance.TaxCode.AE) + .taxRate("tax_rate") .build() - val roundtrippedDocumentAttachmentCreate = + val roundtrippedAllowance = jsonMapper.readValue( - jsonMapper.writeValueAsString(documentAttachmentCreate), - jacksonTypeRef(), + jsonMapper.writeValueAsString(allowance), + jacksonTypeRef(), ) - assertThat(roundtrippedDocumentAttachmentCreate).isEqualTo(documentAttachmentCreate) + assertThat(roundtrippedAllowance).isEqualTo(allowance) } @Test From 5b447b4473189cf6675d79480758e989808dab38 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 9 Oct 2025 09:14:00 +0000 Subject: [PATCH 04/43] feat(api): api update --- .stats.yml | 4 ++-- .../api/models/documents/UnitOfMeasureCode.kt | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.stats.yml b/.stats.yml index 8760fae..c02d4db 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-8edeb779b7c54508db755723beba2b378c3bf6566b460c25ccbae3341f00d675.yml -openapi_spec_hash: 4090ba8c97e2ceb86ce1c7ff994601af +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-1a682c6e176e8001373897a1aeee5f053e69cb49d8c75e0cb9b59caa2b09290f.yml +openapi_spec_hash: 77b0ad472aa8dee92d0785a7ee45e269 config_hash: 852a0117abb3db077933876ad1185f41 diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/UnitOfMeasureCode.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/UnitOfMeasureCode.kt index e58cd7d..2214a3c 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/UnitOfMeasureCode.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/UnitOfMeasureCode.kt @@ -792,8 +792,6 @@ class UnitOfMeasureCode @JsonCreator private constructor(private val value: Json @JvmField val C61 = of("C61") - @JvmField val C62 = of("C62") - @JvmField val C63 = of("C63") @JvmField val C64 = of("C64") @@ -2082,6 +2080,8 @@ class UnitOfMeasureCode @JsonCreator private constructor(private val value: Json @JvmField val NAR = of("NAR") + @JvmField val C62 = of("C62") + @JvmField val LTR = of("LTR") @JvmStatic fun of(value: String) = UnitOfMeasureCode(JsonField.of(value)) @@ -2474,7 +2474,6 @@ class UnitOfMeasureCode @JsonCreator private constructor(private val value: Json C59, C60, C61, - C62, C63, C64, C65, @@ -3119,6 +3118,7 @@ class UnitOfMeasureCode @JsonCreator private constructor(private val value: Json XZZ, ZZ, NAR, + C62, LTR, } @@ -3517,7 +3517,6 @@ class UnitOfMeasureCode @JsonCreator private constructor(private val value: Json C59, C60, C61, - C62, C63, C64, C65, @@ -4162,6 +4161,7 @@ class UnitOfMeasureCode @JsonCreator private constructor(private val value: Json XZZ, ZZ, NAR, + C62, LTR, /** * An enum member indicating that [UnitOfMeasureCode] was instantiated with an unknown @@ -4564,7 +4564,6 @@ class UnitOfMeasureCode @JsonCreator private constructor(private val value: Json C59 -> Value.C59 C60 -> Value.C60 C61 -> Value.C61 - C62 -> Value.C62 C63 -> Value.C63 C64 -> Value.C64 C65 -> Value.C65 @@ -5209,6 +5208,7 @@ class UnitOfMeasureCode @JsonCreator private constructor(private val value: Json XZZ -> Value.XZZ ZZ -> Value.ZZ NAR -> Value.NAR + C62 -> Value.C62 LTR -> Value.LTR else -> Value._UNKNOWN } @@ -5608,7 +5608,6 @@ class UnitOfMeasureCode @JsonCreator private constructor(private val value: Json C59 -> Known.C59 C60 -> Known.C60 C61 -> Known.C61 - C62 -> Known.C62 C63 -> Known.C63 C64 -> Known.C64 C65 -> Known.C65 @@ -6253,6 +6252,7 @@ class UnitOfMeasureCode @JsonCreator private constructor(private val value: Json XZZ -> Known.XZZ ZZ -> Known.ZZ NAR -> Known.NAR + C62 -> Known.C62 LTR -> Known.LTR else -> throw EInvoiceInvalidDataException("Unknown UnitOfMeasureCode: $value") } From 8d536ca1926c0bcb30f4583adcb68aa82494fe95 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 9 Oct 2025 13:14:00 +0000 Subject: [PATCH 05/43] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index c02d4db..ee793fc 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-1a682c6e176e8001373897a1aeee5f053e69cb49d8c75e0cb9b59caa2b09290f.yml -openapi_spec_hash: 77b0ad472aa8dee92d0785a7ee45e269 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-97871d8011b01785a17b52d21dd1453198e4b1f7a19f4ac7f5e5060802c84a99.yml +openapi_spec_hash: 8bb1fbea9952047205e9b8d77608fe39 config_hash: 852a0117abb3db077933876ad1185f41 From 88a2388ce1f68f3ad01ac7ae30aa6fd25c1daa15 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 6 Nov 2025 08:14:05 +0000 Subject: [PATCH 06/43] feat(api): api update --- .stats.yml | 4 ++-- .../api/models/documents/DocumentCreate.kt | 15 +++++++++------ .../documents/DocumentCreateFromPdfResponse.kt | 10 ++++++---- .../api/models/documents/DocumentResponse.kt | 10 ++++++---- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/.stats.yml b/.stats.yml index ee793fc..1e2de2d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-97871d8011b01785a17b52d21dd1453198e4b1f7a19f4ac7f5e5060802c84a99.yml -openapi_spec_hash: 8bb1fbea9952047205e9b8d77608fe39 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-1cefc48406ed0f3fa4907a76caa079f57f9c45e8b4d53377327b39dac02f0230.yml +openapi_spec_hash: d61f0e5d98be81938f74581ba859c1c7 config_hash: 852a0117abb3db077933876ad1185f41 diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt index 1011c48..c4b6d5b 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt @@ -503,8 +503,9 @@ private constructor( fun taxDetails(): Optional> = taxDetails.getOptional("tax_details") /** - * The total financial discount of the invoice (so discounts not subject to VAT). Must be - * positive and rounded to maximum 2 decimals + * The net financial discount/charge of the invoice (non-VAT charges minus non-VAT allowances). + * Can be positive (net charge), negative (net discount), or zero. Must be rounded to maximum 2 + * decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1807,8 +1808,9 @@ private constructor( } /** - * The total financial discount of the invoice (so discounts not subject to VAT). Must be - * positive and rounded to maximum 2 decimals + * The net financial discount/charge of the invoice (non-VAT charges minus non-VAT + * allowances). Can be positive (net charge), negative (net discount), or zero. Must be + * rounded to maximum 2 decimals */ fun totalDiscount(totalDiscount: TotalDiscount?) = totalDiscount(JsonField.ofNullable(totalDiscount)) @@ -9411,8 +9413,9 @@ private constructor( } /** - * The total financial discount of the invoice (so discounts not subject to VAT). Must be - * positive and rounded to maximum 2 decimals + * The net financial discount/charge of the invoice (non-VAT charges minus non-VAT allowances). + * Can be positive (net charge), negative (net discount), or zero. Must be rounded to maximum 2 + * decimals */ @JsonDeserialize(using = TotalDiscount.Deserializer::class) @JsonSerialize(using = TotalDiscount.Serializer::class) diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponse.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponse.kt index 5164b90..ea0328c 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponse.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponse.kt @@ -506,8 +506,9 @@ private constructor( fun taxDetails(): Optional> = taxDetails.getOptional("tax_details") /** - * The total financial discount of the invoice (so discounts not subject to VAT). Must be - * positive and rounded to maximum 2 decimals + * The net financial discount/charge of the invoice (non-VAT charges minus non-VAT allowances). + * Can be positive (net charge), negative (net discount), or zero. Must be rounded to maximum 2 + * decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1819,8 +1820,9 @@ private constructor( } /** - * The total financial discount of the invoice (so discounts not subject to VAT). Must be - * positive and rounded to maximum 2 decimals + * The net financial discount/charge of the invoice (non-VAT charges minus non-VAT + * allowances). Can be positive (net charge), negative (net discount), or zero. Must be + * rounded to maximum 2 decimals */ fun totalDiscount(totalDiscount: String?) = totalDiscount(JsonField.ofNullable(totalDiscount)) diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt index 9f0679b..881bca3 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt @@ -498,8 +498,9 @@ private constructor( fun taxDetails(): Optional> = taxDetails.getOptional("tax_details") /** - * The total financial discount of the invoice (so discounts not subject to VAT). Must be - * positive and rounded to maximum 2 decimals + * The net financial discount/charge of the invoice (non-VAT charges minus non-VAT allowances). + * Can be positive (net charge), negative (net discount), or zero. Must be rounded to maximum 2 + * decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1797,8 +1798,9 @@ private constructor( } /** - * The total financial discount of the invoice (so discounts not subject to VAT). Must be - * positive and rounded to maximum 2 decimals + * The net financial discount/charge of the invoice (non-VAT charges minus non-VAT + * allowances). Can be positive (net charge), negative (net discount), or zero. Must be + * rounded to maximum 2 decimals */ fun totalDiscount(totalDiscount: String?) = totalDiscount(JsonField.ofNullable(totalDiscount)) From 50eb173e52614313f0474c525571300d31f47003 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sun, 9 Nov 2025 15:14:09 +0000 Subject: [PATCH 07/43] feat(api): api update --- .stats.yml | 4 +- .../api/models/documents/DocumentCreate.kt | 257 +++++++++++++++-- .../DocumentCreateFromPdfResponse.kt | 244 ++++++++++++++-- .../api/models/documents/DocumentResponse.kt | 260 ++++++++++++++++-- .../models/documents/PaymentDetailCreate.kt | 16 ++ .../api/models/me/MeRetrieveResponse.kt | 67 ++++- .../DocumentCreateFromPdfResponseTest.kt | 18 +- .../documents/DocumentCreateParamsTest.kt | 18 +- .../models/documents/DocumentCreateTest.kt | 18 +- .../models/documents/DocumentResponseTest.kt | 18 +- .../inbox/PaginatedDocumentResponseTest.kt | 18 +- .../api/models/me/MeRetrieveResponseTest.kt | 45 +-- .../ValidateValidateJsonParamsTest.kt | 18 +- .../api/services/ErrorHandlingTest.kt | 102 ++++--- .../api/services/ServiceParamsTest.kt | 6 +- .../async/DocumentServiceAsyncTest.kt | 6 +- .../async/ValidateServiceAsyncTest.kt | 6 +- .../services/blocking/DocumentServiceTest.kt | 6 +- .../services/blocking/ValidateServiceTest.kt | 6 +- 19 files changed, 963 insertions(+), 170 deletions(-) diff --git a/.stats.yml b/.stats.yml index 1e2de2d..12f0e7f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-1cefc48406ed0f3fa4907a76caa079f57f9c45e8b4d53377327b39dac02f0230.yml -openapi_spec_hash: d61f0e5d98be81938f74581ba859c1c7 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-009e20418b5b4a984fbc1a6c74d2148f2ebb823568699babb83ec8a4f2aea1f7.yml +openapi_spec_hash: 8a63ae95d8d7e7beaaf306f1bb2b1cd3 config_hash: 852a0117abb3db077933876ad1185f41 diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt index c4b6d5b..5828329 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt @@ -44,6 +44,7 @@ private constructor( private val currency: JsonField, private val customerAddress: JsonField, private val customerAddressRecipient: JsonField, + private val customerCompanyId: JsonField, private val customerEmail: JsonField, private val customerId: JsonField, private val customerName: JsonField, @@ -78,6 +79,7 @@ private constructor( private val vatexNote: JsonField, private val vendorAddress: JsonField, private val vendorAddressRecipient: JsonField, + private val vendorCompanyId: JsonField, private val vendorEmail: JsonField, private val vendorName: JsonField, private val vendorTaxId: JsonField, @@ -113,6 +115,9 @@ private constructor( @JsonProperty("customer_address_recipient") @ExcludeMissing customerAddressRecipient: JsonField = JsonMissing.of(), + @JsonProperty("customer_company_id") + @ExcludeMissing + customerCompanyId: JsonField = JsonMissing.of(), @JsonProperty("customer_email") @ExcludeMissing customerEmail: JsonField = JsonMissing.of(), @@ -195,6 +200,9 @@ private constructor( @JsonProperty("vendor_address_recipient") @ExcludeMissing vendorAddressRecipient: JsonField = JsonMissing.of(), + @JsonProperty("vendor_company_id") + @ExcludeMissing + vendorCompanyId: JsonField = JsonMissing.of(), @JsonProperty("vendor_email") @ExcludeMissing vendorEmail: JsonField = JsonMissing.of(), @@ -214,6 +222,7 @@ private constructor( currency, customerAddress, customerAddressRecipient, + customerCompanyId, customerEmail, customerId, customerName, @@ -248,6 +257,7 @@ private constructor( vatexNote, vendorAddress, vendorAddressRecipient, + vendorCompanyId, vendorEmail, vendorName, vendorTaxId, @@ -261,7 +271,7 @@ private constructor( fun allowances(): Optional> = allowances.getOptional("allowances") /** - * The amount due of the invoice. Must be positive and rounded to maximum 2 decimals + * The amount due for payment. Must be positive and rounded to maximum 2 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -276,12 +286,16 @@ private constructor( attachments.getOptional("attachments") /** + * The billing address (if different from customer address) + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun billingAddress(): Optional = billingAddress.getOptional("billing_address") /** + * The recipient name at the billing address + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -295,7 +309,7 @@ private constructor( fun charges(): Optional> = charges.getOptional("charges") /** - * Currency of the invoice + * Currency of the invoice (ISO 4217 currency code) * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -303,12 +317,16 @@ private constructor( fun currency(): Optional = currency.getOptional("currency") /** + * The address of the customer/buyer + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun customerAddress(): Optional = customerAddress.getOptional("customer_address") /** + * The recipient name at the customer address + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -316,62 +334,89 @@ private constructor( customerAddressRecipient.getOptional("customer_address_recipient") /** + * Customer company ID. For Belgium this is the CBE number or their EUID (European Unique + * Identifier) number. In the Netherlands this is the KVK number. + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customerCompanyId(): Optional = customerCompanyId.getOptional("customer_company_id") + + /** + * The email address of the customer + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun customerEmail(): Optional = customerEmail.getOptional("customer_email") /** + * The unique identifier for the customer in your system + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun customerId(): Optional = customerId.getOptional("customer_id") /** + * The company name of the customer/buyer + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun customerName(): Optional = customerName.getOptional("customer_name") /** + * Customer tax ID. For Belgium this is the VAT number. Must include the country prefix + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun customerTaxId(): Optional = customerTaxId.getOptional("customer_tax_id") /** + * The direction of the document: INBOUND (purchases) or OUTBOUND (sales) + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun direction(): Optional = direction.getOptional("direction") /** + * The type of document: INVOICE, CREDIT_NOTE, or DEBIT_NOTE + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun documentType(): Optional = documentType.getOptional("document_type") /** + * The date when payment is due + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun dueDate(): Optional = dueDate.getOptional("due_date") /** + * The date when the invoice was issued + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun invoiceDate(): Optional = invoiceDate.getOptional("invoice_date") /** + * The unique invoice identifier/number + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun invoiceId(): Optional = invoiceId.getOptional("invoice_id") /** - * The total amount of the invoice (so invoice_total = subtotal + total_tax + total_discount). - * Must be positive and rounded to maximum 2 decimals + * The total amount of the invoice including tax (invoice_total = subtotal + total_tax + + * total_discount). Must be positive and rounded to maximum 2 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -387,6 +432,8 @@ private constructor( fun items(): Optional> = items.getOptional("items") /** + * Additional notes or comments for the invoice + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -400,14 +447,16 @@ private constructor( paymentDetails.getOptional("payment_details") /** + * The payment terms (e.g., 'Net 30', 'Due on receipt', '2/10 Net 30') + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun paymentTerm(): Optional = paymentTerm.getOptional("payment_term") /** - * The previous unpaid balance of the invoice, if any. Must be positive and rounded to maximum 2 - * decimals + * The previous unpaid balance from prior invoices, if any. Must be positive and rounded to + * maximum 2 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -416,18 +465,24 @@ private constructor( previousUnpaidBalance.getOptional("previous_unpaid_balance") /** + * The purchase order reference number + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun purchaseOrder(): Optional = purchaseOrder.getOptional("purchase_order") /** + * The address where payment should be sent or remitted to + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun remittanceAddress(): Optional = remittanceAddress.getOptional("remittance_address") /** + * The recipient name at the remittance address + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -435,12 +490,16 @@ private constructor( remittanceAddressRecipient.getOptional("remittance_address_recipient") /** + * The address where services were performed or goods were delivered + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun serviceAddress(): Optional = serviceAddress.getOptional("service_address") /** + * The recipient name at the service address + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -448,24 +507,32 @@ private constructor( serviceAddressRecipient.getOptional("service_address_recipient") /** + * The end date of the service period or delivery period + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun serviceEndDate(): Optional = serviceEndDate.getOptional("service_end_date") /** + * The start date of the service period or delivery period + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun serviceStartDate(): Optional = serviceStartDate.getOptional("service_start_date") /** + * The shipping/delivery address + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun shippingAddress(): Optional = shippingAddress.getOptional("shipping_address") /** + * The recipient name at the shipping address + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -473,6 +540,8 @@ private constructor( shippingAddressRecipient.getOptional("shipping_address_recipient") /** + * The current state of the document: DRAFT, TRANSIT, FAILED, SENT, or RECEIVED + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -489,7 +558,7 @@ private constructor( fun subtotal(): Optional = subtotal.getOptional("subtotal") /** - * Tax category code of the invoice + * Tax category code of the invoice (e.g., S for standard rate, Z for zero rate, E for exempt) * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -513,7 +582,7 @@ private constructor( fun totalDiscount(): Optional = totalDiscount.getOptional("total_discount") /** - * The total tax of the invoice. Must be positive and rounded to maximum 2 decimals + * The total tax amount of the invoice. Must be positive and rounded to maximum 2 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -531,7 +600,7 @@ private constructor( fun vatex(): Optional = vatex.getOptional("vatex") /** - * VAT exemption note of the invoice + * Textual explanation for VAT exemption * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -539,12 +608,16 @@ private constructor( fun vatexNote(): Optional = vatexNote.getOptional("vatex_note") /** + * The address of the vendor/seller + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun vendorAddress(): Optional = vendorAddress.getOptional("vendor_address") /** + * The recipient name at the vendor address + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -552,18 +625,33 @@ private constructor( vendorAddressRecipient.getOptional("vendor_address_recipient") /** + * Vendor company ID. For Belgium this is the CBE number or their EUID (European Unique + * Identifier) number. In the Netherlands this is the KVK number. + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun vendorCompanyId(): Optional = vendorCompanyId.getOptional("vendor_company_id") + + /** + * The email address of the vendor + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun vendorEmail(): Optional = vendorEmail.getOptional("vendor_email") /** + * The name of the vendor/seller/supplier + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun vendorName(): Optional = vendorName.getOptional("vendor_name") /** + * Vendor tax ID. For Belgium this is the VAT number. Must include the country prefix + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -646,6 +734,16 @@ private constructor( @ExcludeMissing fun _customerAddressRecipient(): JsonField = customerAddressRecipient + /** + * Returns the raw JSON value of [customerCompanyId]. + * + * Unlike [customerCompanyId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("customer_company_id") + @ExcludeMissing + fun _customerCompanyId(): JsonField = customerCompanyId + /** * Returns the raw JSON value of [customerEmail]. * @@ -937,6 +1035,15 @@ private constructor( @ExcludeMissing fun _vendorAddressRecipient(): JsonField = vendorAddressRecipient + /** + * Returns the raw JSON value of [vendorCompanyId]. + * + * Unlike [vendorCompanyId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("vendor_company_id") + @ExcludeMissing + fun _vendorCompanyId(): JsonField = vendorCompanyId + /** * Returns the raw JSON value of [vendorEmail]. * @@ -992,6 +1099,7 @@ private constructor( private var currency: JsonField = JsonMissing.of() private var customerAddress: JsonField = JsonMissing.of() private var customerAddressRecipient: JsonField = JsonMissing.of() + private var customerCompanyId: JsonField = JsonMissing.of() private var customerEmail: JsonField = JsonMissing.of() private var customerId: JsonField = JsonMissing.of() private var customerName: JsonField = JsonMissing.of() @@ -1026,6 +1134,7 @@ private constructor( private var vatexNote: JsonField = JsonMissing.of() private var vendorAddress: JsonField = JsonMissing.of() private var vendorAddressRecipient: JsonField = JsonMissing.of() + private var vendorCompanyId: JsonField = JsonMissing.of() private var vendorEmail: JsonField = JsonMissing.of() private var vendorName: JsonField = JsonMissing.of() private var vendorTaxId: JsonField = JsonMissing.of() @@ -1042,6 +1151,7 @@ private constructor( currency = documentCreate.currency customerAddress = documentCreate.customerAddress customerAddressRecipient = documentCreate.customerAddressRecipient + customerCompanyId = documentCreate.customerCompanyId customerEmail = documentCreate.customerEmail customerId = documentCreate.customerId customerName = documentCreate.customerName @@ -1076,6 +1186,7 @@ private constructor( vatexNote = documentCreate.vatexNote vendorAddress = documentCreate.vendorAddress vendorAddressRecipient = documentCreate.vendorAddressRecipient + vendorCompanyId = documentCreate.vendorCompanyId vendorEmail = documentCreate.vendorEmail vendorName = documentCreate.vendorName vendorTaxId = documentCreate.vendorTaxId @@ -1110,7 +1221,7 @@ private constructor( } } - /** The amount due of the invoice. Must be positive and rounded to maximum 2 decimals */ + /** The amount due for payment. Must be positive and rounded to maximum 2 decimals */ fun amountDue(amountDue: AmountDue?) = amountDue(JsonField.ofNullable(amountDue)) /** Alias for calling [Builder.amountDue] with `amountDue.orElse(null)`. */ @@ -1161,6 +1272,7 @@ private constructor( } } + /** The billing address (if different from customer address) */ fun billingAddress(billingAddress: String?) = billingAddress(JsonField.ofNullable(billingAddress)) @@ -1179,6 +1291,7 @@ private constructor( this.billingAddress = billingAddress } + /** The recipient name at the billing address */ fun billingAddressRecipient(billingAddressRecipient: String?) = billingAddressRecipient(JsonField.ofNullable(billingAddressRecipient)) @@ -1228,7 +1341,7 @@ private constructor( } } - /** Currency of the invoice */ + /** Currency of the invoice (ISO 4217 currency code) */ fun currency(currency: CurrencyCode) = currency(JsonField.of(currency)) /** @@ -1240,6 +1353,7 @@ private constructor( */ fun currency(currency: JsonField) = apply { this.currency = currency } + /** The address of the customer/buyer */ fun customerAddress(customerAddress: String?) = customerAddress(JsonField.ofNullable(customerAddress)) @@ -1258,6 +1372,7 @@ private constructor( this.customerAddress = customerAddress } + /** The recipient name at the customer address */ fun customerAddressRecipient(customerAddressRecipient: String?) = customerAddressRecipient(JsonField.ofNullable(customerAddressRecipient)) @@ -1279,6 +1394,29 @@ private constructor( this.customerAddressRecipient = customerAddressRecipient } + /** + * Customer company ID. For Belgium this is the CBE number or their EUID (European Unique + * Identifier) number. In the Netherlands this is the KVK number. + */ + fun customerCompanyId(customerCompanyId: String?) = + customerCompanyId(JsonField.ofNullable(customerCompanyId)) + + /** Alias for calling [Builder.customerCompanyId] with `customerCompanyId.orElse(null)`. */ + fun customerCompanyId(customerCompanyId: Optional) = + customerCompanyId(customerCompanyId.getOrNull()) + + /** + * Sets [Builder.customerCompanyId] to an arbitrary JSON value. + * + * You should usually call [Builder.customerCompanyId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customerCompanyId(customerCompanyId: JsonField) = apply { + this.customerCompanyId = customerCompanyId + } + + /** The email address of the customer */ fun customerEmail(customerEmail: String?) = customerEmail(JsonField.ofNullable(customerEmail)) @@ -1297,6 +1435,7 @@ private constructor( this.customerEmail = customerEmail } + /** The unique identifier for the customer in your system */ fun customerId(customerId: String?) = customerId(JsonField.ofNullable(customerId)) /** Alias for calling [Builder.customerId] with `customerId.orElse(null)`. */ @@ -1311,6 +1450,7 @@ private constructor( */ fun customerId(customerId: JsonField) = apply { this.customerId = customerId } + /** The company name of the customer/buyer */ fun customerName(customerName: String?) = customerName(JsonField.ofNullable(customerName)) /** Alias for calling [Builder.customerName] with `customerName.orElse(null)`. */ @@ -1327,6 +1467,7 @@ private constructor( this.customerName = customerName } + /** Customer tax ID. For Belgium this is the VAT number. Must include the country prefix */ fun customerTaxId(customerTaxId: String?) = customerTaxId(JsonField.ofNullable(customerTaxId)) @@ -1345,6 +1486,7 @@ private constructor( this.customerTaxId = customerTaxId } + /** The direction of the document: INBOUND (purchases) or OUTBOUND (sales) */ fun direction(direction: DocumentDirection) = direction(JsonField.of(direction)) /** @@ -1358,6 +1500,7 @@ private constructor( this.direction = direction } + /** The type of document: INVOICE, CREDIT_NOTE, or DEBIT_NOTE */ fun documentType(documentType: DocumentType) = documentType(JsonField.of(documentType)) /** @@ -1371,6 +1514,7 @@ private constructor( this.documentType = documentType } + /** The date when payment is due */ fun dueDate(dueDate: LocalDate?) = dueDate(JsonField.ofNullable(dueDate)) /** Alias for calling [Builder.dueDate] with `dueDate.orElse(null)`. */ @@ -1385,6 +1529,7 @@ private constructor( */ fun dueDate(dueDate: JsonField) = apply { this.dueDate = dueDate } + /** The date when the invoice was issued */ fun invoiceDate(invoiceDate: LocalDate?) = invoiceDate(JsonField.ofNullable(invoiceDate)) /** Alias for calling [Builder.invoiceDate] with `invoiceDate.orElse(null)`. */ @@ -1401,6 +1546,7 @@ private constructor( this.invoiceDate = invoiceDate } + /** The unique invoice identifier/number */ fun invoiceId(invoiceId: String?) = invoiceId(JsonField.ofNullable(invoiceId)) /** Alias for calling [Builder.invoiceId] with `invoiceId.orElse(null)`. */ @@ -1416,7 +1562,7 @@ private constructor( fun invoiceId(invoiceId: JsonField) = apply { this.invoiceId = invoiceId } /** - * The total amount of the invoice (so invoice_total = subtotal + total_tax + + * The total amount of the invoice including tax (invoice_total = subtotal + total_tax + * total_discount). Must be positive and rounded to maximum 2 decimals */ fun invoiceTotal(invoiceTotal: InvoiceTotal?) = @@ -1467,6 +1613,7 @@ private constructor( (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } } + /** Additional notes or comments for the invoice */ fun note(note: String?) = note(JsonField.ofNullable(note)) /** Alias for calling [Builder.note] with `note.orElse(null)`. */ @@ -1510,6 +1657,7 @@ private constructor( } } + /** The payment terms (e.g., 'Net 30', 'Due on receipt', '2/10 Net 30') */ fun paymentTerm(paymentTerm: String?) = paymentTerm(JsonField.ofNullable(paymentTerm)) /** Alias for calling [Builder.paymentTerm] with `paymentTerm.orElse(null)`. */ @@ -1525,7 +1673,7 @@ private constructor( fun paymentTerm(paymentTerm: JsonField) = apply { this.paymentTerm = paymentTerm } /** - * The previous unpaid balance of the invoice, if any. Must be positive and rounded to + * The previous unpaid balance from prior invoices, if any. Must be positive and rounded to * maximum 2 decimals */ fun previousUnpaidBalance(previousUnpaidBalance: PreviousUnpaidBalance?) = @@ -1561,6 +1709,7 @@ private constructor( fun previousUnpaidBalance(string: String) = previousUnpaidBalance(PreviousUnpaidBalance.ofString(string)) + /** The purchase order reference number */ fun purchaseOrder(purchaseOrder: String?) = purchaseOrder(JsonField.ofNullable(purchaseOrder)) @@ -1579,6 +1728,7 @@ private constructor( this.purchaseOrder = purchaseOrder } + /** The address where payment should be sent or remitted to */ fun remittanceAddress(remittanceAddress: String?) = remittanceAddress(JsonField.ofNullable(remittanceAddress)) @@ -1597,6 +1747,7 @@ private constructor( this.remittanceAddress = remittanceAddress } + /** The recipient name at the remittance address */ fun remittanceAddressRecipient(remittanceAddressRecipient: String?) = remittanceAddressRecipient(JsonField.ofNullable(remittanceAddressRecipient)) @@ -1618,6 +1769,7 @@ private constructor( this.remittanceAddressRecipient = remittanceAddressRecipient } + /** The address where services were performed or goods were delivered */ fun serviceAddress(serviceAddress: String?) = serviceAddress(JsonField.ofNullable(serviceAddress)) @@ -1636,6 +1788,7 @@ private constructor( this.serviceAddress = serviceAddress } + /** The recipient name at the service address */ fun serviceAddressRecipient(serviceAddressRecipient: String?) = serviceAddressRecipient(JsonField.ofNullable(serviceAddressRecipient)) @@ -1657,6 +1810,7 @@ private constructor( this.serviceAddressRecipient = serviceAddressRecipient } + /** The end date of the service period or delivery period */ fun serviceEndDate(serviceEndDate: LocalDate?) = serviceEndDate(JsonField.ofNullable(serviceEndDate)) @@ -1675,6 +1829,7 @@ private constructor( this.serviceEndDate = serviceEndDate } + /** The start date of the service period or delivery period */ fun serviceStartDate(serviceStartDate: LocalDate?) = serviceStartDate(JsonField.ofNullable(serviceStartDate)) @@ -1693,6 +1848,7 @@ private constructor( this.serviceStartDate = serviceStartDate } + /** The shipping/delivery address */ fun shippingAddress(shippingAddress: String?) = shippingAddress(JsonField.ofNullable(shippingAddress)) @@ -1711,6 +1867,7 @@ private constructor( this.shippingAddress = shippingAddress } + /** The recipient name at the shipping address */ fun shippingAddressRecipient(shippingAddressRecipient: String?) = shippingAddressRecipient(JsonField.ofNullable(shippingAddressRecipient)) @@ -1732,6 +1889,7 @@ private constructor( this.shippingAddressRecipient = shippingAddressRecipient } + /** The current state of the document: DRAFT, TRANSIT, FAILED, SENT, or RECEIVED */ fun state(state: DocumentState) = state(JsonField.of(state)) /** @@ -1768,7 +1926,10 @@ private constructor( /** Alias for calling [subtotal] with `Subtotal.ofString(string)`. */ fun subtotal(string: String) = subtotal(Subtotal.ofString(string)) - /** Tax category code of the invoice */ + /** + * Tax category code of the invoice (e.g., S for standard rate, Z for zero rate, E for + * exempt) + */ fun taxCode(taxCode: TaxCode) = taxCode(JsonField.of(taxCode)) /** @@ -1836,7 +1997,9 @@ private constructor( /** Alias for calling [totalDiscount] with `TotalDiscount.ofString(string)`. */ fun totalDiscount(string: String) = totalDiscount(TotalDiscount.ofString(string)) - /** The total tax of the invoice. Must be positive and rounded to maximum 2 decimals */ + /** + * The total tax amount of the invoice. Must be positive and rounded to maximum 2 decimals + */ fun totalTax(totalTax: TotalTax?) = totalTax(JsonField.ofNullable(totalTax)) /** Alias for calling [Builder.totalTax] with `totalTax.orElse(null)`. */ @@ -1875,7 +2038,7 @@ private constructor( */ fun vatex(vatex: JsonField) = apply { this.vatex = vatex } - /** VAT exemption note of the invoice */ + /** Textual explanation for VAT exemption */ fun vatexNote(vatexNote: String?) = vatexNote(JsonField.ofNullable(vatexNote)) /** Alias for calling [Builder.vatexNote] with `vatexNote.orElse(null)`. */ @@ -1890,6 +2053,7 @@ private constructor( */ fun vatexNote(vatexNote: JsonField) = apply { this.vatexNote = vatexNote } + /** The address of the vendor/seller */ fun vendorAddress(vendorAddress: String?) = vendorAddress(JsonField.ofNullable(vendorAddress)) @@ -1908,6 +2072,7 @@ private constructor( this.vendorAddress = vendorAddress } + /** The recipient name at the vendor address */ fun vendorAddressRecipient(vendorAddressRecipient: String?) = vendorAddressRecipient(JsonField.ofNullable(vendorAddressRecipient)) @@ -1929,6 +2094,29 @@ private constructor( this.vendorAddressRecipient = vendorAddressRecipient } + /** + * Vendor company ID. For Belgium this is the CBE number or their EUID (European Unique + * Identifier) number. In the Netherlands this is the KVK number. + */ + fun vendorCompanyId(vendorCompanyId: String?) = + vendorCompanyId(JsonField.ofNullable(vendorCompanyId)) + + /** Alias for calling [Builder.vendorCompanyId] with `vendorCompanyId.orElse(null)`. */ + fun vendorCompanyId(vendorCompanyId: Optional) = + vendorCompanyId(vendorCompanyId.getOrNull()) + + /** + * Sets [Builder.vendorCompanyId] to an arbitrary JSON value. + * + * You should usually call [Builder.vendorCompanyId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun vendorCompanyId(vendorCompanyId: JsonField) = apply { + this.vendorCompanyId = vendorCompanyId + } + + /** The email address of the vendor */ fun vendorEmail(vendorEmail: String?) = vendorEmail(JsonField.ofNullable(vendorEmail)) /** Alias for calling [Builder.vendorEmail] with `vendorEmail.orElse(null)`. */ @@ -1943,6 +2131,7 @@ private constructor( */ fun vendorEmail(vendorEmail: JsonField) = apply { this.vendorEmail = vendorEmail } + /** The name of the vendor/seller/supplier */ fun vendorName(vendorName: String?) = vendorName(JsonField.ofNullable(vendorName)) /** Alias for calling [Builder.vendorName] with `vendorName.orElse(null)`. */ @@ -1957,6 +2146,7 @@ private constructor( */ fun vendorName(vendorName: JsonField) = apply { this.vendorName = vendorName } + /** Vendor tax ID. For Belgium this is the VAT number. Must include the country prefix */ fun vendorTaxId(vendorTaxId: String?) = vendorTaxId(JsonField.ofNullable(vendorTaxId)) /** Alias for calling [Builder.vendorTaxId] with `vendorTaxId.orElse(null)`. */ @@ -2006,6 +2196,7 @@ private constructor( currency, customerAddress, customerAddressRecipient, + customerCompanyId, customerEmail, customerId, customerName, @@ -2040,6 +2231,7 @@ private constructor( vatexNote, vendorAddress, vendorAddressRecipient, + vendorCompanyId, vendorEmail, vendorName, vendorTaxId, @@ -2063,6 +2255,7 @@ private constructor( currency().ifPresent { it.validate() } customerAddress() customerAddressRecipient() + customerCompanyId() customerEmail() customerId() customerName() @@ -2097,6 +2290,7 @@ private constructor( vatexNote() vendorAddress() vendorAddressRecipient() + vendorCompanyId() vendorEmail() vendorName() vendorTaxId() @@ -2127,6 +2321,7 @@ private constructor( (currency.asKnown().getOrNull()?.validity() ?: 0) + (if (customerAddress.asKnown().isPresent) 1 else 0) + (if (customerAddressRecipient.asKnown().isPresent) 1 else 0) + + (if (customerCompanyId.asKnown().isPresent) 1 else 0) + (if (customerEmail.asKnown().isPresent) 1 else 0) + (if (customerId.asKnown().isPresent) 1 else 0) + (if (customerName.asKnown().isPresent) 1 else 0) + @@ -2161,6 +2356,7 @@ private constructor( (if (vatexNote.asKnown().isPresent) 1 else 0) + (if (vendorAddress.asKnown().isPresent) 1 else 0) + (if (vendorAddressRecipient.asKnown().isPresent) 1 else 0) + + (if (vendorCompanyId.asKnown().isPresent) 1 else 0) + (if (vendorEmail.asKnown().isPresent) 1 else 0) + (if (vendorName.asKnown().isPresent) 1 else 0) + (if (vendorTaxId.asKnown().isPresent) 1 else 0) @@ -3324,7 +3520,7 @@ private constructor( "Allowance{amount=$amount, baseAmount=$baseAmount, multiplierFactor=$multiplierFactor, reason=$reason, reasonCode=$reasonCode, taxCode=$taxCode, taxRate=$taxRate, additionalProperties=$additionalProperties}" } - /** The amount due of the invoice. Must be positive and rounded to maximum 2 decimals */ + /** The amount due for payment. Must be positive and rounded to maximum 2 decimals */ @JsonDeserialize(using = AmountDue.Deserializer::class) @JsonSerialize(using = AmountDue.Serializer::class) class AmountDue @@ -4654,8 +4850,8 @@ private constructor( } /** - * The total amount of the invoice (so invoice_total = subtotal + total_tax + total_discount). - * Must be positive and rounded to maximum 2 decimals + * The total amount of the invoice including tax (invoice_total = subtotal + total_tax + + * total_discount). Must be positive and rounded to maximum 2 decimals */ @JsonDeserialize(using = InvoiceTotal.Deserializer::class) @JsonSerialize(using = InvoiceTotal.Serializer::class) @@ -8533,8 +8729,8 @@ private constructor( } /** - * The previous unpaid balance of the invoice, if any. Must be positive and rounded to maximum 2 - * decimals + * The previous unpaid balance from prior invoices, if any. Must be positive and rounded to + * maximum 2 decimals */ @JsonDeserialize(using = PreviousUnpaidBalance.Deserializer::class) @JsonSerialize(using = PreviousUnpaidBalance.Serializer::class) @@ -8884,7 +9080,9 @@ private constructor( } } - /** Tax category code of the invoice */ + /** + * Tax category code of the invoice (e.g., S for standard rate, Z for zero rate, E for exempt) + */ class TaxCode @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -9075,12 +9273,16 @@ private constructor( ) : this(amount, rate, mutableMapOf()) /** + * The tax amount for this tax category. Must be rounded to maximum 2 decimals + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ fun amount(): Optional = amount.getOptional("amount") /** + * The tax rate as a percentage (e.g., '21.00', '6.00', '0.00') + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ @@ -9132,6 +9334,7 @@ private constructor( additionalProperties = taxDetail.additionalProperties.toMutableMap() } + /** The tax amount for this tax category. Must be rounded to maximum 2 decimals */ fun amount(amount: Amount?) = amount(JsonField.ofNullable(amount)) /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ @@ -9152,6 +9355,7 @@ private constructor( /** Alias for calling [amount] with `Amount.ofString(string)`. */ fun amount(string: String) = amount(Amount.ofString(string)) + /** The tax rate as a percentage (e.g., '21.00', '6.00', '0.00') */ fun rate(rate: String?) = rate(JsonField.ofNullable(rate)) /** Alias for calling [Builder.rate] with `rate.orElse(null)`. */ @@ -9224,6 +9428,7 @@ private constructor( (amount.asKnown().getOrNull()?.validity() ?: 0) + (if (rate.asKnown().isPresent) 1 else 0) + /** The tax amount for this tax category. Must be rounded to maximum 2 decimals */ @JsonDeserialize(using = Amount.Deserializer::class) @JsonSerialize(using = Amount.Serializer::class) class Amount @@ -9587,7 +9792,7 @@ private constructor( } } - /** The total tax of the invoice. Must be positive and rounded to maximum 2 decimals */ + /** The total tax amount of the invoice. Must be positive and rounded to maximum 2 decimals */ @JsonDeserialize(using = TotalTax.Deserializer::class) @JsonSerialize(using = TotalTax.Serializer::class) class TotalTax @@ -10264,6 +10469,7 @@ private constructor( currency == other.currency && customerAddress == other.customerAddress && customerAddressRecipient == other.customerAddressRecipient && + customerCompanyId == other.customerCompanyId && customerEmail == other.customerEmail && customerId == other.customerId && customerName == other.customerName && @@ -10298,6 +10504,7 @@ private constructor( vatexNote == other.vatexNote && vendorAddress == other.vendorAddress && vendorAddressRecipient == other.vendorAddressRecipient && + vendorCompanyId == other.vendorCompanyId && vendorEmail == other.vendorEmail && vendorName == other.vendorName && vendorTaxId == other.vendorTaxId && @@ -10315,6 +10522,7 @@ private constructor( currency, customerAddress, customerAddressRecipient, + customerCompanyId, customerEmail, customerId, customerName, @@ -10349,6 +10557,7 @@ private constructor( vatexNote, vendorAddress, vendorAddressRecipient, + vendorCompanyId, vendorEmail, vendorName, vendorTaxId, @@ -10359,5 +10568,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "DocumentCreate{allowances=$allowances, amountDue=$amountDue, attachments=$attachments, billingAddress=$billingAddress, billingAddressRecipient=$billingAddressRecipient, charges=$charges, currency=$currency, customerAddress=$customerAddress, customerAddressRecipient=$customerAddressRecipient, customerEmail=$customerEmail, customerId=$customerId, customerName=$customerName, customerTaxId=$customerTaxId, direction=$direction, documentType=$documentType, dueDate=$dueDate, invoiceDate=$invoiceDate, invoiceId=$invoiceId, invoiceTotal=$invoiceTotal, items=$items, note=$note, paymentDetails=$paymentDetails, paymentTerm=$paymentTerm, previousUnpaidBalance=$previousUnpaidBalance, purchaseOrder=$purchaseOrder, remittanceAddress=$remittanceAddress, remittanceAddressRecipient=$remittanceAddressRecipient, serviceAddress=$serviceAddress, serviceAddressRecipient=$serviceAddressRecipient, serviceEndDate=$serviceEndDate, serviceStartDate=$serviceStartDate, shippingAddress=$shippingAddress, shippingAddressRecipient=$shippingAddressRecipient, state=$state, subtotal=$subtotal, taxCode=$taxCode, taxDetails=$taxDetails, totalDiscount=$totalDiscount, totalTax=$totalTax, vatex=$vatex, vatexNote=$vatexNote, vendorAddress=$vendorAddress, vendorAddressRecipient=$vendorAddressRecipient, vendorEmail=$vendorEmail, vendorName=$vendorName, vendorTaxId=$vendorTaxId, additionalProperties=$additionalProperties}" + "DocumentCreate{allowances=$allowances, amountDue=$amountDue, attachments=$attachments, billingAddress=$billingAddress, billingAddressRecipient=$billingAddressRecipient, charges=$charges, currency=$currency, customerAddress=$customerAddress, customerAddressRecipient=$customerAddressRecipient, customerCompanyId=$customerCompanyId, customerEmail=$customerEmail, customerId=$customerId, customerName=$customerName, customerTaxId=$customerTaxId, direction=$direction, documentType=$documentType, dueDate=$dueDate, invoiceDate=$invoiceDate, invoiceId=$invoiceId, invoiceTotal=$invoiceTotal, items=$items, note=$note, paymentDetails=$paymentDetails, paymentTerm=$paymentTerm, previousUnpaidBalance=$previousUnpaidBalance, purchaseOrder=$purchaseOrder, remittanceAddress=$remittanceAddress, remittanceAddressRecipient=$remittanceAddressRecipient, serviceAddress=$serviceAddress, serviceAddressRecipient=$serviceAddressRecipient, serviceEndDate=$serviceEndDate, serviceStartDate=$serviceStartDate, shippingAddress=$shippingAddress, shippingAddressRecipient=$shippingAddressRecipient, state=$state, subtotal=$subtotal, taxCode=$taxCode, taxDetails=$taxDetails, totalDiscount=$totalDiscount, totalTax=$totalTax, vatex=$vatex, vatexNote=$vatexNote, vendorAddress=$vendorAddress, vendorAddressRecipient=$vendorAddressRecipient, vendorCompanyId=$vendorCompanyId, vendorEmail=$vendorEmail, vendorName=$vendorName, vendorTaxId=$vendorTaxId, additionalProperties=$additionalProperties}" } diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponse.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponse.kt index ea0328c..f517073 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponse.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponse.kt @@ -33,6 +33,7 @@ private constructor( private val currency: JsonField, private val customerAddress: JsonField, private val customerAddressRecipient: JsonField, + private val customerCompanyId: JsonField, private val customerEmail: JsonField, private val customerId: JsonField, private val customerName: JsonField, @@ -69,6 +70,7 @@ private constructor( private val vatexNote: JsonField, private val vendorAddress: JsonField, private val vendorAddressRecipient: JsonField, + private val vendorCompanyId: JsonField, private val vendorEmail: JsonField, private val vendorName: JsonField, private val vendorTaxId: JsonField, @@ -102,6 +104,9 @@ private constructor( @JsonProperty("customer_address_recipient") @ExcludeMissing customerAddressRecipient: JsonField = JsonMissing.of(), + @JsonProperty("customer_company_id") + @ExcludeMissing + customerCompanyId: JsonField = JsonMissing.of(), @JsonProperty("customer_email") @ExcludeMissing customerEmail: JsonField = JsonMissing.of(), @@ -188,6 +193,9 @@ private constructor( @JsonProperty("vendor_address_recipient") @ExcludeMissing vendorAddressRecipient: JsonField = JsonMissing.of(), + @JsonProperty("vendor_company_id") + @ExcludeMissing + vendorCompanyId: JsonField = JsonMissing.of(), @JsonProperty("vendor_email") @ExcludeMissing vendorEmail: JsonField = JsonMissing.of(), @@ -207,6 +215,7 @@ private constructor( currency, customerAddress, customerAddressRecipient, + customerCompanyId, customerEmail, customerId, customerName, @@ -243,6 +252,7 @@ private constructor( vatexNote, vendorAddress, vendorAddressRecipient, + vendorCompanyId, vendorEmail, vendorName, vendorTaxId, @@ -256,7 +266,7 @@ private constructor( fun allowances(): Optional> = allowances.getOptional("allowances") /** - * The amount due of the invoice. Must be positive and rounded to maximum 2 decimals + * The amount due for payment. Must be positive and rounded to maximum 2 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -271,12 +281,16 @@ private constructor( attachments.getOptional("attachments") /** + * The billing address (if different from customer address) + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun billingAddress(): Optional = billingAddress.getOptional("billing_address") /** + * The recipient name at the billing address + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -290,7 +304,7 @@ private constructor( fun charges(): Optional> = charges.getOptional("charges") /** - * Currency of the invoice + * Currency of the invoice (ISO 4217 currency code) * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -298,12 +312,16 @@ private constructor( fun currency(): Optional = currency.getOptional("currency") /** + * The address of the customer/buyer + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun customerAddress(): Optional = customerAddress.getOptional("customer_address") /** + * The recipient name at the customer address + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -311,62 +329,89 @@ private constructor( customerAddressRecipient.getOptional("customer_address_recipient") /** + * Customer company ID. For Belgium this is the CBE number or their EUID (European Unique + * Identifier) number. In the Netherlands this is the KVK number. + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customerCompanyId(): Optional = customerCompanyId.getOptional("customer_company_id") + + /** + * The email address of the customer + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun customerEmail(): Optional = customerEmail.getOptional("customer_email") /** + * The unique identifier for the customer in your system + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun customerId(): Optional = customerId.getOptional("customer_id") /** + * The company name of the customer/buyer + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun customerName(): Optional = customerName.getOptional("customer_name") /** + * Customer tax ID. For Belgium this is the VAT number. Must include the country prefix + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun customerTaxId(): Optional = customerTaxId.getOptional("customer_tax_id") /** + * The direction of the document: INBOUND (purchases) or OUTBOUND (sales) + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun direction(): Optional = direction.getOptional("direction") /** + * The type of document: INVOICE, CREDIT_NOTE, or DEBIT_NOTE + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun documentType(): Optional = documentType.getOptional("document_type") /** + * The date when payment is due + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun dueDate(): Optional = dueDate.getOptional("due_date") /** + * The date when the invoice was issued + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun invoiceDate(): Optional = invoiceDate.getOptional("invoice_date") /** + * The unique invoice identifier/number + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun invoiceId(): Optional = invoiceId.getOptional("invoice_id") /** - * The total amount of the invoice (so invoice_total = subtotal + total_tax + total_discount). - * Must be positive and rounded to maximum 2 decimals + * The total amount of the invoice including tax (invoice_total = subtotal + total_tax + + * total_discount). Must be positive and rounded to maximum 2 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -382,6 +427,8 @@ private constructor( fun items(): Optional> = items.getOptional("items") /** + * Additional notes or comments for the invoice + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -395,14 +442,16 @@ private constructor( paymentDetails.getOptional("payment_details") /** + * The payment terms (e.g., 'Net 30', 'Due on receipt', '2/10 Net 30') + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun paymentTerm(): Optional = paymentTerm.getOptional("payment_term") /** - * The previous unpaid balance of the invoice, if any. Must be positive and rounded to maximum 2 - * decimals + * The previous unpaid balance from prior invoices, if any. Must be positive and rounded to + * maximum 2 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -411,18 +460,24 @@ private constructor( previousUnpaidBalance.getOptional("previous_unpaid_balance") /** + * The purchase order reference number + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun purchaseOrder(): Optional = purchaseOrder.getOptional("purchase_order") /** + * The address where payment should be sent or remitted to + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun remittanceAddress(): Optional = remittanceAddress.getOptional("remittance_address") /** + * The recipient name at the remittance address + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -430,12 +485,16 @@ private constructor( remittanceAddressRecipient.getOptional("remittance_address_recipient") /** + * The address where services were performed or goods were delivered + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun serviceAddress(): Optional = serviceAddress.getOptional("service_address") /** + * The recipient name at the service address + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -443,24 +502,32 @@ private constructor( serviceAddressRecipient.getOptional("service_address_recipient") /** + * The end date of the service period or delivery period + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun serviceEndDate(): Optional = serviceEndDate.getOptional("service_end_date") /** + * The start date of the service period or delivery period + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun serviceStartDate(): Optional = serviceStartDate.getOptional("service_start_date") /** + * The shipping/delivery address + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun shippingAddress(): Optional = shippingAddress.getOptional("shipping_address") /** + * The recipient name at the shipping address + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -468,6 +535,8 @@ private constructor( shippingAddressRecipient.getOptional("shipping_address_recipient") /** + * The current state of the document: DRAFT, TRANSIT, FAILED, SENT, or RECEIVED + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -492,7 +561,7 @@ private constructor( fun success(): Optional = success.getOptional("success") /** - * Tax category code of the invoice + * Tax category code of the invoice (e.g., S for standard rate, Z for zero rate, E for exempt) * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -516,7 +585,7 @@ private constructor( fun totalDiscount(): Optional = totalDiscount.getOptional("total_discount") /** - * The total tax of the invoice. Must be positive and rounded to maximum 2 decimals + * The total tax amount of the invoice. Must be positive and rounded to maximum 2 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -542,7 +611,7 @@ private constructor( fun vatex(): Optional = vatex.getOptional("vatex") /** - * VAT exemption note of the invoice + * Textual explanation for VAT exemption * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -550,12 +619,16 @@ private constructor( fun vatexNote(): Optional = vatexNote.getOptional("vatex_note") /** + * The address of the vendor/seller + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun vendorAddress(): Optional = vendorAddress.getOptional("vendor_address") /** + * The recipient name at the vendor address + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -563,18 +636,33 @@ private constructor( vendorAddressRecipient.getOptional("vendor_address_recipient") /** + * Vendor company ID. For Belgium this is the CBE number or their EUID (European Unique + * Identifier) number. In the Netherlands this is the KVK number. + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun vendorCompanyId(): Optional = vendorCompanyId.getOptional("vendor_company_id") + + /** + * The email address of the vendor + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun vendorEmail(): Optional = vendorEmail.getOptional("vendor_email") /** + * The name of the vendor/seller/supplier + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun vendorName(): Optional = vendorName.getOptional("vendor_name") /** + * Vendor tax ID. For Belgium this is the VAT number. Must include the country prefix + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -657,6 +745,16 @@ private constructor( @ExcludeMissing fun _customerAddressRecipient(): JsonField = customerAddressRecipient + /** + * Returns the raw JSON value of [customerCompanyId]. + * + * Unlike [customerCompanyId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("customer_company_id") + @ExcludeMissing + fun _customerCompanyId(): JsonField = customerCompanyId + /** * Returns the raw JSON value of [customerEmail]. * @@ -964,6 +1062,15 @@ private constructor( @ExcludeMissing fun _vendorAddressRecipient(): JsonField = vendorAddressRecipient + /** + * Returns the raw JSON value of [vendorCompanyId]. + * + * Unlike [vendorCompanyId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("vendor_company_id") + @ExcludeMissing + fun _vendorCompanyId(): JsonField = vendorCompanyId + /** * Returns the raw JSON value of [vendorEmail]. * @@ -1022,6 +1129,7 @@ private constructor( private var currency: JsonField = JsonMissing.of() private var customerAddress: JsonField = JsonMissing.of() private var customerAddressRecipient: JsonField = JsonMissing.of() + private var customerCompanyId: JsonField = JsonMissing.of() private var customerEmail: JsonField = JsonMissing.of() private var customerId: JsonField = JsonMissing.of() private var customerName: JsonField = JsonMissing.of() @@ -1058,6 +1166,7 @@ private constructor( private var vatexNote: JsonField = JsonMissing.of() private var vendorAddress: JsonField = JsonMissing.of() private var vendorAddressRecipient: JsonField = JsonMissing.of() + private var vendorCompanyId: JsonField = JsonMissing.of() private var vendorEmail: JsonField = JsonMissing.of() private var vendorName: JsonField = JsonMissing.of() private var vendorTaxId: JsonField = JsonMissing.of() @@ -1074,6 +1183,7 @@ private constructor( currency = documentCreateFromPdfResponse.currency customerAddress = documentCreateFromPdfResponse.customerAddress customerAddressRecipient = documentCreateFromPdfResponse.customerAddressRecipient + customerCompanyId = documentCreateFromPdfResponse.customerCompanyId customerEmail = documentCreateFromPdfResponse.customerEmail customerId = documentCreateFromPdfResponse.customerId customerName = documentCreateFromPdfResponse.customerName @@ -1110,6 +1220,7 @@ private constructor( vatexNote = documentCreateFromPdfResponse.vatexNote vendorAddress = documentCreateFromPdfResponse.vendorAddress vendorAddressRecipient = documentCreateFromPdfResponse.vendorAddressRecipient + vendorCompanyId = documentCreateFromPdfResponse.vendorCompanyId vendorEmail = documentCreateFromPdfResponse.vendorEmail vendorName = documentCreateFromPdfResponse.vendorName vendorTaxId = documentCreateFromPdfResponse.vendorTaxId @@ -1144,7 +1255,7 @@ private constructor( } } - /** The amount due of the invoice. Must be positive and rounded to maximum 2 decimals */ + /** The amount due for payment. Must be positive and rounded to maximum 2 decimals */ fun amountDue(amountDue: String?) = amountDue(JsonField.ofNullable(amountDue)) /** Alias for calling [Builder.amountDue] with `amountDue.orElse(null)`. */ @@ -1189,6 +1300,7 @@ private constructor( } } + /** The billing address (if different from customer address) */ fun billingAddress(billingAddress: String?) = billingAddress(JsonField.ofNullable(billingAddress)) @@ -1207,6 +1319,7 @@ private constructor( this.billingAddress = billingAddress } + /** The recipient name at the billing address */ fun billingAddressRecipient(billingAddressRecipient: String?) = billingAddressRecipient(JsonField.ofNullable(billingAddressRecipient)) @@ -1256,7 +1369,7 @@ private constructor( } } - /** Currency of the invoice */ + /** Currency of the invoice (ISO 4217 currency code) */ fun currency(currency: CurrencyCode) = currency(JsonField.of(currency)) /** @@ -1268,6 +1381,7 @@ private constructor( */ fun currency(currency: JsonField) = apply { this.currency = currency } + /** The address of the customer/buyer */ fun customerAddress(customerAddress: String?) = customerAddress(JsonField.ofNullable(customerAddress)) @@ -1286,6 +1400,7 @@ private constructor( this.customerAddress = customerAddress } + /** The recipient name at the customer address */ fun customerAddressRecipient(customerAddressRecipient: String?) = customerAddressRecipient(JsonField.ofNullable(customerAddressRecipient)) @@ -1307,6 +1422,29 @@ private constructor( this.customerAddressRecipient = customerAddressRecipient } + /** + * Customer company ID. For Belgium this is the CBE number or their EUID (European Unique + * Identifier) number. In the Netherlands this is the KVK number. + */ + fun customerCompanyId(customerCompanyId: String?) = + customerCompanyId(JsonField.ofNullable(customerCompanyId)) + + /** Alias for calling [Builder.customerCompanyId] with `customerCompanyId.orElse(null)`. */ + fun customerCompanyId(customerCompanyId: Optional) = + customerCompanyId(customerCompanyId.getOrNull()) + + /** + * Sets [Builder.customerCompanyId] to an arbitrary JSON value. + * + * You should usually call [Builder.customerCompanyId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customerCompanyId(customerCompanyId: JsonField) = apply { + this.customerCompanyId = customerCompanyId + } + + /** The email address of the customer */ fun customerEmail(customerEmail: String?) = customerEmail(JsonField.ofNullable(customerEmail)) @@ -1325,6 +1463,7 @@ private constructor( this.customerEmail = customerEmail } + /** The unique identifier for the customer in your system */ fun customerId(customerId: String?) = customerId(JsonField.ofNullable(customerId)) /** Alias for calling [Builder.customerId] with `customerId.orElse(null)`. */ @@ -1339,6 +1478,7 @@ private constructor( */ fun customerId(customerId: JsonField) = apply { this.customerId = customerId } + /** The company name of the customer/buyer */ fun customerName(customerName: String?) = customerName(JsonField.ofNullable(customerName)) /** Alias for calling [Builder.customerName] with `customerName.orElse(null)`. */ @@ -1355,6 +1495,7 @@ private constructor( this.customerName = customerName } + /** Customer tax ID. For Belgium this is the VAT number. Must include the country prefix */ fun customerTaxId(customerTaxId: String?) = customerTaxId(JsonField.ofNullable(customerTaxId)) @@ -1373,6 +1514,7 @@ private constructor( this.customerTaxId = customerTaxId } + /** The direction of the document: INBOUND (purchases) or OUTBOUND (sales) */ fun direction(direction: DocumentDirection) = direction(JsonField.of(direction)) /** @@ -1386,6 +1528,7 @@ private constructor( this.direction = direction } + /** The type of document: INVOICE, CREDIT_NOTE, or DEBIT_NOTE */ fun documentType(documentType: DocumentType) = documentType(JsonField.of(documentType)) /** @@ -1399,6 +1542,7 @@ private constructor( this.documentType = documentType } + /** The date when payment is due */ fun dueDate(dueDate: LocalDate?) = dueDate(JsonField.ofNullable(dueDate)) /** Alias for calling [Builder.dueDate] with `dueDate.orElse(null)`. */ @@ -1413,6 +1557,7 @@ private constructor( */ fun dueDate(dueDate: JsonField) = apply { this.dueDate = dueDate } + /** The date when the invoice was issued */ fun invoiceDate(invoiceDate: LocalDate?) = invoiceDate(JsonField.ofNullable(invoiceDate)) /** Alias for calling [Builder.invoiceDate] with `invoiceDate.orElse(null)`. */ @@ -1429,6 +1574,7 @@ private constructor( this.invoiceDate = invoiceDate } + /** The unique invoice identifier/number */ fun invoiceId(invoiceId: String?) = invoiceId(JsonField.ofNullable(invoiceId)) /** Alias for calling [Builder.invoiceId] with `invoiceId.orElse(null)`. */ @@ -1444,7 +1590,7 @@ private constructor( fun invoiceId(invoiceId: JsonField) = apply { this.invoiceId = invoiceId } /** - * The total amount of the invoice (so invoice_total = subtotal + total_tax + + * The total amount of the invoice including tax (invoice_total = subtotal + total_tax + * total_discount). Must be positive and rounded to maximum 2 decimals */ fun invoiceTotal(invoiceTotal: String?) = invoiceTotal(JsonField.ofNullable(invoiceTotal)) @@ -1487,6 +1633,7 @@ private constructor( (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } } + /** Additional notes or comments for the invoice */ fun note(note: String?) = note(JsonField.ofNullable(note)) /** Alias for calling [Builder.note] with `note.orElse(null)`. */ @@ -1530,6 +1677,7 @@ private constructor( } } + /** The payment terms (e.g., 'Net 30', 'Due on receipt', '2/10 Net 30') */ fun paymentTerm(paymentTerm: String?) = paymentTerm(JsonField.ofNullable(paymentTerm)) /** Alias for calling [Builder.paymentTerm] with `paymentTerm.orElse(null)`. */ @@ -1545,7 +1693,7 @@ private constructor( fun paymentTerm(paymentTerm: JsonField) = apply { this.paymentTerm = paymentTerm } /** - * The previous unpaid balance of the invoice, if any. Must be positive and rounded to + * The previous unpaid balance from prior invoices, if any. Must be positive and rounded to * maximum 2 decimals */ fun previousUnpaidBalance(previousUnpaidBalance: String?) = @@ -1569,6 +1717,7 @@ private constructor( this.previousUnpaidBalance = previousUnpaidBalance } + /** The purchase order reference number */ fun purchaseOrder(purchaseOrder: String?) = purchaseOrder(JsonField.ofNullable(purchaseOrder)) @@ -1587,6 +1736,7 @@ private constructor( this.purchaseOrder = purchaseOrder } + /** The address where payment should be sent or remitted to */ fun remittanceAddress(remittanceAddress: String?) = remittanceAddress(JsonField.ofNullable(remittanceAddress)) @@ -1605,6 +1755,7 @@ private constructor( this.remittanceAddress = remittanceAddress } + /** The recipient name at the remittance address */ fun remittanceAddressRecipient(remittanceAddressRecipient: String?) = remittanceAddressRecipient(JsonField.ofNullable(remittanceAddressRecipient)) @@ -1626,6 +1777,7 @@ private constructor( this.remittanceAddressRecipient = remittanceAddressRecipient } + /** The address where services were performed or goods were delivered */ fun serviceAddress(serviceAddress: String?) = serviceAddress(JsonField.ofNullable(serviceAddress)) @@ -1644,6 +1796,7 @@ private constructor( this.serviceAddress = serviceAddress } + /** The recipient name at the service address */ fun serviceAddressRecipient(serviceAddressRecipient: String?) = serviceAddressRecipient(JsonField.ofNullable(serviceAddressRecipient)) @@ -1665,6 +1818,7 @@ private constructor( this.serviceAddressRecipient = serviceAddressRecipient } + /** The end date of the service period or delivery period */ fun serviceEndDate(serviceEndDate: LocalDate?) = serviceEndDate(JsonField.ofNullable(serviceEndDate)) @@ -1683,6 +1837,7 @@ private constructor( this.serviceEndDate = serviceEndDate } + /** The start date of the service period or delivery period */ fun serviceStartDate(serviceStartDate: LocalDate?) = serviceStartDate(JsonField.ofNullable(serviceStartDate)) @@ -1701,6 +1856,7 @@ private constructor( this.serviceStartDate = serviceStartDate } + /** The shipping/delivery address */ fun shippingAddress(shippingAddress: String?) = shippingAddress(JsonField.ofNullable(shippingAddress)) @@ -1719,6 +1875,7 @@ private constructor( this.shippingAddress = shippingAddress } + /** The recipient name at the shipping address */ fun shippingAddressRecipient(shippingAddressRecipient: String?) = shippingAddressRecipient(JsonField.ofNullable(shippingAddressRecipient)) @@ -1740,6 +1897,7 @@ private constructor( this.shippingAddressRecipient = shippingAddressRecipient } + /** The current state of the document: DRAFT, TRANSIT, FAILED, SENT, or RECEIVED */ fun state(state: DocumentState) = state(JsonField.of(state)) /** @@ -1780,7 +1938,10 @@ private constructor( */ fun success(success: JsonField) = apply { this.success = success } - /** Tax category code of the invoice */ + /** + * Tax category code of the invoice (e.g., S for standard rate, Z for zero rate, E for + * exempt) + */ fun taxCode(taxCode: TaxCode) = taxCode(JsonField.of(taxCode)) /** @@ -1842,7 +2003,9 @@ private constructor( this.totalDiscount = totalDiscount } - /** The total tax of the invoice. Must be positive and rounded to maximum 2 decimals */ + /** + * The total tax amount of the invoice. Must be positive and rounded to maximum 2 decimals + */ fun totalTax(totalTax: String?) = totalTax(JsonField.ofNullable(totalTax)) /** Alias for calling [Builder.totalTax] with `totalTax.orElse(null)`. */ @@ -1889,7 +2052,7 @@ private constructor( */ fun vatex(vatex: JsonField) = apply { this.vatex = vatex } - /** VAT exemption note of the invoice */ + /** Textual explanation for VAT exemption */ fun vatexNote(vatexNote: String?) = vatexNote(JsonField.ofNullable(vatexNote)) /** Alias for calling [Builder.vatexNote] with `vatexNote.orElse(null)`. */ @@ -1904,6 +2067,7 @@ private constructor( */ fun vatexNote(vatexNote: JsonField) = apply { this.vatexNote = vatexNote } + /** The address of the vendor/seller */ fun vendorAddress(vendorAddress: String?) = vendorAddress(JsonField.ofNullable(vendorAddress)) @@ -1922,6 +2086,7 @@ private constructor( this.vendorAddress = vendorAddress } + /** The recipient name at the vendor address */ fun vendorAddressRecipient(vendorAddressRecipient: String?) = vendorAddressRecipient(JsonField.ofNullable(vendorAddressRecipient)) @@ -1943,6 +2108,29 @@ private constructor( this.vendorAddressRecipient = vendorAddressRecipient } + /** + * Vendor company ID. For Belgium this is the CBE number or their EUID (European Unique + * Identifier) number. In the Netherlands this is the KVK number. + */ + fun vendorCompanyId(vendorCompanyId: String?) = + vendorCompanyId(JsonField.ofNullable(vendorCompanyId)) + + /** Alias for calling [Builder.vendorCompanyId] with `vendorCompanyId.orElse(null)`. */ + fun vendorCompanyId(vendorCompanyId: Optional) = + vendorCompanyId(vendorCompanyId.getOrNull()) + + /** + * Sets [Builder.vendorCompanyId] to an arbitrary JSON value. + * + * You should usually call [Builder.vendorCompanyId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun vendorCompanyId(vendorCompanyId: JsonField) = apply { + this.vendorCompanyId = vendorCompanyId + } + + /** The email address of the vendor */ fun vendorEmail(vendorEmail: String?) = vendorEmail(JsonField.ofNullable(vendorEmail)) /** Alias for calling [Builder.vendorEmail] with `vendorEmail.orElse(null)`. */ @@ -1957,6 +2145,7 @@ private constructor( */ fun vendorEmail(vendorEmail: JsonField) = apply { this.vendorEmail = vendorEmail } + /** The name of the vendor/seller/supplier */ fun vendorName(vendorName: String?) = vendorName(JsonField.ofNullable(vendorName)) /** Alias for calling [Builder.vendorName] with `vendorName.orElse(null)`. */ @@ -1971,6 +2160,7 @@ private constructor( */ fun vendorName(vendorName: JsonField) = apply { this.vendorName = vendorName } + /** Vendor tax ID. For Belgium this is the VAT number. Must include the country prefix */ fun vendorTaxId(vendorTaxId: String?) = vendorTaxId(JsonField.ofNullable(vendorTaxId)) /** Alias for calling [Builder.vendorTaxId] with `vendorTaxId.orElse(null)`. */ @@ -2020,6 +2210,7 @@ private constructor( currency, customerAddress, customerAddressRecipient, + customerCompanyId, customerEmail, customerId, customerName, @@ -2056,6 +2247,7 @@ private constructor( vatexNote, vendorAddress, vendorAddressRecipient, + vendorCompanyId, vendorEmail, vendorName, vendorTaxId, @@ -2079,6 +2271,7 @@ private constructor( currency().ifPresent { it.validate() } customerAddress() customerAddressRecipient() + customerCompanyId() customerEmail() customerId() customerName() @@ -2115,6 +2308,7 @@ private constructor( vatexNote() vendorAddress() vendorAddressRecipient() + vendorCompanyId() vendorEmail() vendorName() vendorTaxId() @@ -2145,6 +2339,7 @@ private constructor( (currency.asKnown().getOrNull()?.validity() ?: 0) + (if (customerAddress.asKnown().isPresent) 1 else 0) + (if (customerAddressRecipient.asKnown().isPresent) 1 else 0) + + (if (customerCompanyId.asKnown().isPresent) 1 else 0) + (if (customerEmail.asKnown().isPresent) 1 else 0) + (if (customerId.asKnown().isPresent) 1 else 0) + (if (customerName.asKnown().isPresent) 1 else 0) + @@ -2181,6 +2376,7 @@ private constructor( (if (vatexNote.asKnown().isPresent) 1 else 0) + (if (vendorAddress.asKnown().isPresent) 1 else 0) + (if (vendorAddressRecipient.asKnown().isPresent) 1 else 0) + + (if (vendorCompanyId.asKnown().isPresent) 1 else 0) + (if (vendorEmail.asKnown().isPresent) 1 else 0) + (if (vendorName.asKnown().isPresent) 1 else 0) + (if (vendorTaxId.asKnown().isPresent) 1 else 0) @@ -2802,7 +2998,9 @@ private constructor( "Item{allowances=$allowances, amount=$amount, charges=$charges, date=$date, description=$description, productCode=$productCode, quantity=$quantity, tax=$tax, taxRate=$taxRate, unit=$unit, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" } - /** Tax category code of the invoice */ + /** + * Tax category code of the invoice (e.g., S for standard rate, Z for zero rate, E for exempt) + */ class TaxCode @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -2993,12 +3191,16 @@ private constructor( ) : this(amount, rate, mutableMapOf()) /** + * The tax amount for this tax category. Must be rounded to maximum 2 decimals + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ fun amount(): Optional = amount.getOptional("amount") /** + * The tax rate as a percentage (e.g., '21.00', '6.00', '0.00') + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ @@ -3050,6 +3252,7 @@ private constructor( additionalProperties = taxDetail.additionalProperties.toMutableMap() } + /** The tax amount for this tax category. Must be rounded to maximum 2 decimals */ fun amount(amount: String?) = amount(JsonField.ofNullable(amount)) /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ @@ -3064,6 +3267,7 @@ private constructor( */ fun amount(amount: JsonField) = apply { this.amount = amount } + /** The tax rate as a percentage (e.g., '21.00', '6.00', '0.00') */ fun rate(rate: String?) = rate(JsonField.ofNullable(rate)) /** Alias for calling [Builder.rate] with `rate.orElse(null)`. */ @@ -3661,6 +3865,7 @@ private constructor( currency == other.currency && customerAddress == other.customerAddress && customerAddressRecipient == other.customerAddressRecipient && + customerCompanyId == other.customerCompanyId && customerEmail == other.customerEmail && customerId == other.customerId && customerName == other.customerName && @@ -3697,6 +3902,7 @@ private constructor( vatexNote == other.vatexNote && vendorAddress == other.vendorAddress && vendorAddressRecipient == other.vendorAddressRecipient && + vendorCompanyId == other.vendorCompanyId && vendorEmail == other.vendorEmail && vendorName == other.vendorName && vendorTaxId == other.vendorTaxId && @@ -3714,6 +3920,7 @@ private constructor( currency, customerAddress, customerAddressRecipient, + customerCompanyId, customerEmail, customerId, customerName, @@ -3750,6 +3957,7 @@ private constructor( vatexNote, vendorAddress, vendorAddressRecipient, + vendorCompanyId, vendorEmail, vendorName, vendorTaxId, @@ -3760,5 +3968,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "DocumentCreateFromPdfResponse{allowances=$allowances, amountDue=$amountDue, attachments=$attachments, billingAddress=$billingAddress, billingAddressRecipient=$billingAddressRecipient, charges=$charges, currency=$currency, customerAddress=$customerAddress, customerAddressRecipient=$customerAddressRecipient, customerEmail=$customerEmail, customerId=$customerId, customerName=$customerName, customerTaxId=$customerTaxId, direction=$direction, documentType=$documentType, dueDate=$dueDate, invoiceDate=$invoiceDate, invoiceId=$invoiceId, invoiceTotal=$invoiceTotal, items=$items, note=$note, paymentDetails=$paymentDetails, paymentTerm=$paymentTerm, previousUnpaidBalance=$previousUnpaidBalance, purchaseOrder=$purchaseOrder, remittanceAddress=$remittanceAddress, remittanceAddressRecipient=$remittanceAddressRecipient, serviceAddress=$serviceAddress, serviceAddressRecipient=$serviceAddressRecipient, serviceEndDate=$serviceEndDate, serviceStartDate=$serviceStartDate, shippingAddress=$shippingAddress, shippingAddressRecipient=$shippingAddressRecipient, state=$state, subtotal=$subtotal, success=$success, taxCode=$taxCode, taxDetails=$taxDetails, totalDiscount=$totalDiscount, totalTax=$totalTax, ublDocument=$ublDocument, vatex=$vatex, vatexNote=$vatexNote, vendorAddress=$vendorAddress, vendorAddressRecipient=$vendorAddressRecipient, vendorEmail=$vendorEmail, vendorName=$vendorName, vendorTaxId=$vendorTaxId, additionalProperties=$additionalProperties}" + "DocumentCreateFromPdfResponse{allowances=$allowances, amountDue=$amountDue, attachments=$attachments, billingAddress=$billingAddress, billingAddressRecipient=$billingAddressRecipient, charges=$charges, currency=$currency, customerAddress=$customerAddress, customerAddressRecipient=$customerAddressRecipient, customerCompanyId=$customerCompanyId, customerEmail=$customerEmail, customerId=$customerId, customerName=$customerName, customerTaxId=$customerTaxId, direction=$direction, documentType=$documentType, dueDate=$dueDate, invoiceDate=$invoiceDate, invoiceId=$invoiceId, invoiceTotal=$invoiceTotal, items=$items, note=$note, paymentDetails=$paymentDetails, paymentTerm=$paymentTerm, previousUnpaidBalance=$previousUnpaidBalance, purchaseOrder=$purchaseOrder, remittanceAddress=$remittanceAddress, remittanceAddressRecipient=$remittanceAddressRecipient, serviceAddress=$serviceAddress, serviceAddressRecipient=$serviceAddressRecipient, serviceEndDate=$serviceEndDate, serviceStartDate=$serviceStartDate, shippingAddress=$shippingAddress, shippingAddressRecipient=$shippingAddressRecipient, state=$state, subtotal=$subtotal, success=$success, taxCode=$taxCode, taxDetails=$taxDetails, totalDiscount=$totalDiscount, totalTax=$totalTax, ublDocument=$ublDocument, vatex=$vatex, vatexNote=$vatexNote, vendorAddress=$vendorAddress, vendorAddressRecipient=$vendorAddressRecipient, vendorCompanyId=$vendorCompanyId, vendorEmail=$vendorEmail, vendorName=$vendorName, vendorTaxId=$vendorTaxId, additionalProperties=$additionalProperties}" } diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt index 881bca3..066f3b6 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt @@ -36,6 +36,7 @@ private constructor( private val currency: JsonField, private val customerAddress: JsonField, private val customerAddressRecipient: JsonField, + private val customerCompanyId: JsonField, private val customerEmail: JsonField, private val customerId: JsonField, private val customerName: JsonField, @@ -70,6 +71,7 @@ private constructor( private val vatexNote: JsonField, private val vendorAddress: JsonField, private val vendorAddressRecipient: JsonField, + private val vendorCompanyId: JsonField, private val vendorEmail: JsonField, private val vendorName: JsonField, private val vendorTaxId: JsonField, @@ -104,6 +106,9 @@ private constructor( @JsonProperty("customer_address_recipient") @ExcludeMissing customerAddressRecipient: JsonField = JsonMissing.of(), + @JsonProperty("customer_company_id") + @ExcludeMissing + customerCompanyId: JsonField = JsonMissing.of(), @JsonProperty("customer_email") @ExcludeMissing customerEmail: JsonField = JsonMissing.of(), @@ -186,6 +191,9 @@ private constructor( @JsonProperty("vendor_address_recipient") @ExcludeMissing vendorAddressRecipient: JsonField = JsonMissing.of(), + @JsonProperty("vendor_company_id") + @ExcludeMissing + vendorCompanyId: JsonField = JsonMissing.of(), @JsonProperty("vendor_email") @ExcludeMissing vendorEmail: JsonField = JsonMissing.of(), @@ -206,6 +214,7 @@ private constructor( currency, customerAddress, customerAddressRecipient, + customerCompanyId, customerEmail, customerId, customerName, @@ -240,6 +249,7 @@ private constructor( vatexNote, vendorAddress, vendorAddressRecipient, + vendorCompanyId, vendorEmail, vendorName, vendorTaxId, @@ -259,7 +269,7 @@ private constructor( fun allowances(): Optional> = allowances.getOptional("allowances") /** - * The amount due of the invoice. Must be positive and rounded to maximum 2 decimals + * The amount due for payment. Must be positive and rounded to maximum 2 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -273,12 +283,16 @@ private constructor( fun attachments(): Optional> = attachments.getOptional("attachments") /** + * The billing address (if different from customer address) + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun billingAddress(): Optional = billingAddress.getOptional("billing_address") /** + * The recipient name at the billing address + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -292,7 +306,7 @@ private constructor( fun charges(): Optional> = charges.getOptional("charges") /** - * Currency of the invoice + * Currency of the invoice (ISO 4217 currency code) * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -300,12 +314,16 @@ private constructor( fun currency(): Optional = currency.getOptional("currency") /** + * The address of the customer/buyer + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun customerAddress(): Optional = customerAddress.getOptional("customer_address") /** + * The recipient name at the customer address + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -313,62 +331,89 @@ private constructor( customerAddressRecipient.getOptional("customer_address_recipient") /** + * Customer company ID. For Belgium this is the CBE number or their EUID (European Unique + * Identifier) number. In the Netherlands this is the KVK number. + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun customerCompanyId(): Optional = customerCompanyId.getOptional("customer_company_id") + + /** + * The email address of the customer + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun customerEmail(): Optional = customerEmail.getOptional("customer_email") /** + * The unique identifier for the customer in your system + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun customerId(): Optional = customerId.getOptional("customer_id") /** + * The company name of the customer/buyer + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun customerName(): Optional = customerName.getOptional("customer_name") /** + * Customer tax ID. For Belgium this is the VAT number. Must include the country prefix + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun customerTaxId(): Optional = customerTaxId.getOptional("customer_tax_id") /** + * The direction of the document: INBOUND (purchases) or OUTBOUND (sales) + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun direction(): Optional = direction.getOptional("direction") /** + * The type of document: INVOICE, CREDIT_NOTE, or DEBIT_NOTE + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun documentType(): Optional = documentType.getOptional("document_type") /** + * The date when payment is due + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun dueDate(): Optional = dueDate.getOptional("due_date") /** + * The date when the invoice was issued + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun invoiceDate(): Optional = invoiceDate.getOptional("invoice_date") /** + * The unique invoice identifier/number + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun invoiceId(): Optional = invoiceId.getOptional("invoice_id") /** - * The total amount of the invoice (so invoice_total = subtotal + total_tax + total_discount). - * Must be positive and rounded to maximum 2 decimals + * The total amount of the invoice including tax (invoice_total = subtotal + total_tax + + * total_discount). Must be positive and rounded to maximum 2 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -382,6 +427,8 @@ private constructor( fun items(): Optional> = items.getOptional("items") /** + * Additional notes or comments for the invoice + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -395,14 +442,16 @@ private constructor( paymentDetails.getOptional("payment_details") /** + * The payment terms (e.g., 'Net 30', 'Due on receipt', '2/10 Net 30') + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun paymentTerm(): Optional = paymentTerm.getOptional("payment_term") /** - * The previous unpaid balance of the invoice, if any. Must be positive and rounded to maximum 2 - * decimals + * The previous unpaid balance from prior invoices, if any. Must be positive and rounded to + * maximum 2 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -411,18 +460,24 @@ private constructor( previousUnpaidBalance.getOptional("previous_unpaid_balance") /** + * The purchase order reference number + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun purchaseOrder(): Optional = purchaseOrder.getOptional("purchase_order") /** + * The address where payment should be sent or remitted to + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun remittanceAddress(): Optional = remittanceAddress.getOptional("remittance_address") /** + * The recipient name at the remittance address + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -430,12 +485,16 @@ private constructor( remittanceAddressRecipient.getOptional("remittance_address_recipient") /** + * The address where services were performed or goods were delivered + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun serviceAddress(): Optional = serviceAddress.getOptional("service_address") /** + * The recipient name at the service address + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -443,24 +502,32 @@ private constructor( serviceAddressRecipient.getOptional("service_address_recipient") /** + * The end date of the service period or delivery period + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun serviceEndDate(): Optional = serviceEndDate.getOptional("service_end_date") /** + * The start date of the service period or delivery period + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun serviceStartDate(): Optional = serviceStartDate.getOptional("service_start_date") /** + * The shipping/delivery address + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun shippingAddress(): Optional = shippingAddress.getOptional("shipping_address") /** + * The recipient name at the shipping address + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -468,6 +535,8 @@ private constructor( shippingAddressRecipient.getOptional("shipping_address_recipient") /** + * The current state of the document: DRAFT, TRANSIT, FAILED, SENT, or RECEIVED + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -484,7 +553,7 @@ private constructor( fun subtotal(): Optional = subtotal.getOptional("subtotal") /** - * Tax category code of the invoice + * Tax category code of the invoice (e.g., S for standard rate, Z for zero rate, E for exempt) * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -508,7 +577,7 @@ private constructor( fun totalDiscount(): Optional = totalDiscount.getOptional("total_discount") /** - * The total tax of the invoice. Must be positive and rounded to maximum 2 decimals + * The total tax amount of the invoice. Must be positive and rounded to maximum 2 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -526,7 +595,7 @@ private constructor( fun vatex(): Optional = vatex.getOptional("vatex") /** - * VAT exemption note of the invoice + * Textual explanation for VAT exemption * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -534,12 +603,16 @@ private constructor( fun vatexNote(): Optional = vatexNote.getOptional("vatex_note") /** + * The address of the vendor/seller + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun vendorAddress(): Optional = vendorAddress.getOptional("vendor_address") /** + * The recipient name at the vendor address + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -547,18 +620,33 @@ private constructor( vendorAddressRecipient.getOptional("vendor_address_recipient") /** + * Vendor company ID. For Belgium this is the CBE number or their EUID (European Unique + * Identifier) number. In the Netherlands this is the KVK number. + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun vendorCompanyId(): Optional = vendorCompanyId.getOptional("vendor_company_id") + + /** + * The email address of the vendor + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun vendorEmail(): Optional = vendorEmail.getOptional("vendor_email") /** + * The name of the vendor/seller/supplier + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun vendorName(): Optional = vendorName.getOptional("vendor_name") /** + * Vendor tax ID. For Belgium this is the VAT number. Must include the country prefix + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -648,6 +736,16 @@ private constructor( @ExcludeMissing fun _customerAddressRecipient(): JsonField = customerAddressRecipient + /** + * Returns the raw JSON value of [customerCompanyId]. + * + * Unlike [customerCompanyId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("customer_company_id") + @ExcludeMissing + fun _customerCompanyId(): JsonField = customerCompanyId + /** * Returns the raw JSON value of [customerEmail]. * @@ -939,6 +1037,15 @@ private constructor( @ExcludeMissing fun _vendorAddressRecipient(): JsonField = vendorAddressRecipient + /** + * Returns the raw JSON value of [vendorCompanyId]. + * + * Unlike [vendorCompanyId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("vendor_company_id") + @ExcludeMissing + fun _vendorCompanyId(): JsonField = vendorCompanyId + /** * Returns the raw JSON value of [vendorEmail]. * @@ -1002,6 +1109,7 @@ private constructor( private var currency: JsonField = JsonMissing.of() private var customerAddress: JsonField = JsonMissing.of() private var customerAddressRecipient: JsonField = JsonMissing.of() + private var customerCompanyId: JsonField = JsonMissing.of() private var customerEmail: JsonField = JsonMissing.of() private var customerId: JsonField = JsonMissing.of() private var customerName: JsonField = JsonMissing.of() @@ -1036,6 +1144,7 @@ private constructor( private var vatexNote: JsonField = JsonMissing.of() private var vendorAddress: JsonField = JsonMissing.of() private var vendorAddressRecipient: JsonField = JsonMissing.of() + private var vendorCompanyId: JsonField = JsonMissing.of() private var vendorEmail: JsonField = JsonMissing.of() private var vendorName: JsonField = JsonMissing.of() private var vendorTaxId: JsonField = JsonMissing.of() @@ -1053,6 +1162,7 @@ private constructor( currency = documentResponse.currency customerAddress = documentResponse.customerAddress customerAddressRecipient = documentResponse.customerAddressRecipient + customerCompanyId = documentResponse.customerCompanyId customerEmail = documentResponse.customerEmail customerId = documentResponse.customerId customerName = documentResponse.customerName @@ -1087,6 +1197,7 @@ private constructor( vatexNote = documentResponse.vatexNote vendorAddress = documentResponse.vendorAddress vendorAddressRecipient = documentResponse.vendorAddressRecipient + vendorCompanyId = documentResponse.vendorCompanyId vendorEmail = documentResponse.vendorEmail vendorName = documentResponse.vendorName vendorTaxId = documentResponse.vendorTaxId @@ -1131,7 +1242,7 @@ private constructor( } } - /** The amount due of the invoice. Must be positive and rounded to maximum 2 decimals */ + /** The amount due for payment. Must be positive and rounded to maximum 2 decimals */ fun amountDue(amountDue: String?) = amountDue(JsonField.ofNullable(amountDue)) /** Alias for calling [Builder.amountDue] with `amountDue.orElse(null)`. */ @@ -1176,6 +1287,7 @@ private constructor( } } + /** The billing address (if different from customer address) */ fun billingAddress(billingAddress: String?) = billingAddress(JsonField.ofNullable(billingAddress)) @@ -1194,6 +1306,7 @@ private constructor( this.billingAddress = billingAddress } + /** The recipient name at the billing address */ fun billingAddressRecipient(billingAddressRecipient: String?) = billingAddressRecipient(JsonField.ofNullable(billingAddressRecipient)) @@ -1243,7 +1356,7 @@ private constructor( } } - /** Currency of the invoice */ + /** Currency of the invoice (ISO 4217 currency code) */ fun currency(currency: CurrencyCode) = currency(JsonField.of(currency)) /** @@ -1255,6 +1368,7 @@ private constructor( */ fun currency(currency: JsonField) = apply { this.currency = currency } + /** The address of the customer/buyer */ fun customerAddress(customerAddress: String?) = customerAddress(JsonField.ofNullable(customerAddress)) @@ -1273,6 +1387,7 @@ private constructor( this.customerAddress = customerAddress } + /** The recipient name at the customer address */ fun customerAddressRecipient(customerAddressRecipient: String?) = customerAddressRecipient(JsonField.ofNullable(customerAddressRecipient)) @@ -1294,6 +1409,29 @@ private constructor( this.customerAddressRecipient = customerAddressRecipient } + /** + * Customer company ID. For Belgium this is the CBE number or their EUID (European Unique + * Identifier) number. In the Netherlands this is the KVK number. + */ + fun customerCompanyId(customerCompanyId: String?) = + customerCompanyId(JsonField.ofNullable(customerCompanyId)) + + /** Alias for calling [Builder.customerCompanyId] with `customerCompanyId.orElse(null)`. */ + fun customerCompanyId(customerCompanyId: Optional) = + customerCompanyId(customerCompanyId.getOrNull()) + + /** + * Sets [Builder.customerCompanyId] to an arbitrary JSON value. + * + * You should usually call [Builder.customerCompanyId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun customerCompanyId(customerCompanyId: JsonField) = apply { + this.customerCompanyId = customerCompanyId + } + + /** The email address of the customer */ fun customerEmail(customerEmail: String?) = customerEmail(JsonField.ofNullable(customerEmail)) @@ -1312,6 +1450,7 @@ private constructor( this.customerEmail = customerEmail } + /** The unique identifier for the customer in your system */ fun customerId(customerId: String?) = customerId(JsonField.ofNullable(customerId)) /** Alias for calling [Builder.customerId] with `customerId.orElse(null)`. */ @@ -1326,6 +1465,7 @@ private constructor( */ fun customerId(customerId: JsonField) = apply { this.customerId = customerId } + /** The company name of the customer/buyer */ fun customerName(customerName: String?) = customerName(JsonField.ofNullable(customerName)) /** Alias for calling [Builder.customerName] with `customerName.orElse(null)`. */ @@ -1342,6 +1482,7 @@ private constructor( this.customerName = customerName } + /** Customer tax ID. For Belgium this is the VAT number. Must include the country prefix */ fun customerTaxId(customerTaxId: String?) = customerTaxId(JsonField.ofNullable(customerTaxId)) @@ -1360,6 +1501,7 @@ private constructor( this.customerTaxId = customerTaxId } + /** The direction of the document: INBOUND (purchases) or OUTBOUND (sales) */ fun direction(direction: DocumentDirection) = direction(JsonField.of(direction)) /** @@ -1373,6 +1515,7 @@ private constructor( this.direction = direction } + /** The type of document: INVOICE, CREDIT_NOTE, or DEBIT_NOTE */ fun documentType(documentType: DocumentType) = documentType(JsonField.of(documentType)) /** @@ -1386,6 +1529,7 @@ private constructor( this.documentType = documentType } + /** The date when payment is due */ fun dueDate(dueDate: LocalDate?) = dueDate(JsonField.ofNullable(dueDate)) /** Alias for calling [Builder.dueDate] with `dueDate.orElse(null)`. */ @@ -1400,6 +1544,7 @@ private constructor( */ fun dueDate(dueDate: JsonField) = apply { this.dueDate = dueDate } + /** The date when the invoice was issued */ fun invoiceDate(invoiceDate: LocalDate?) = invoiceDate(JsonField.ofNullable(invoiceDate)) /** Alias for calling [Builder.invoiceDate] with `invoiceDate.orElse(null)`. */ @@ -1416,6 +1561,7 @@ private constructor( this.invoiceDate = invoiceDate } + /** The unique invoice identifier/number */ fun invoiceId(invoiceId: String?) = invoiceId(JsonField.ofNullable(invoiceId)) /** Alias for calling [Builder.invoiceId] with `invoiceId.orElse(null)`. */ @@ -1431,7 +1577,7 @@ private constructor( fun invoiceId(invoiceId: JsonField) = apply { this.invoiceId = invoiceId } /** - * The total amount of the invoice (so invoice_total = subtotal + total_tax + + * The total amount of the invoice including tax (invoice_total = subtotal + total_tax + * total_discount). Must be positive and rounded to maximum 2 decimals */ fun invoiceTotal(invoiceTotal: String?) = invoiceTotal(JsonField.ofNullable(invoiceTotal)) @@ -1476,6 +1622,7 @@ private constructor( (items ?: JsonField.of(mutableListOf())).also { checkKnown("items", it).add(item) } } + /** Additional notes or comments for the invoice */ fun note(note: String?) = note(JsonField.ofNullable(note)) /** Alias for calling [Builder.note] with `note.orElse(null)`. */ @@ -1519,6 +1666,7 @@ private constructor( } } + /** The payment terms (e.g., 'Net 30', 'Due on receipt', '2/10 Net 30') */ fun paymentTerm(paymentTerm: String?) = paymentTerm(JsonField.ofNullable(paymentTerm)) /** Alias for calling [Builder.paymentTerm] with `paymentTerm.orElse(null)`. */ @@ -1534,7 +1682,7 @@ private constructor( fun paymentTerm(paymentTerm: JsonField) = apply { this.paymentTerm = paymentTerm } /** - * The previous unpaid balance of the invoice, if any. Must be positive and rounded to + * The previous unpaid balance from prior invoices, if any. Must be positive and rounded to * maximum 2 decimals */ fun previousUnpaidBalance(previousUnpaidBalance: String?) = @@ -1558,6 +1706,7 @@ private constructor( this.previousUnpaidBalance = previousUnpaidBalance } + /** The purchase order reference number */ fun purchaseOrder(purchaseOrder: String?) = purchaseOrder(JsonField.ofNullable(purchaseOrder)) @@ -1576,6 +1725,7 @@ private constructor( this.purchaseOrder = purchaseOrder } + /** The address where payment should be sent or remitted to */ fun remittanceAddress(remittanceAddress: String?) = remittanceAddress(JsonField.ofNullable(remittanceAddress)) @@ -1594,6 +1744,7 @@ private constructor( this.remittanceAddress = remittanceAddress } + /** The recipient name at the remittance address */ fun remittanceAddressRecipient(remittanceAddressRecipient: String?) = remittanceAddressRecipient(JsonField.ofNullable(remittanceAddressRecipient)) @@ -1615,6 +1766,7 @@ private constructor( this.remittanceAddressRecipient = remittanceAddressRecipient } + /** The address where services were performed or goods were delivered */ fun serviceAddress(serviceAddress: String?) = serviceAddress(JsonField.ofNullable(serviceAddress)) @@ -1633,6 +1785,7 @@ private constructor( this.serviceAddress = serviceAddress } + /** The recipient name at the service address */ fun serviceAddressRecipient(serviceAddressRecipient: String?) = serviceAddressRecipient(JsonField.ofNullable(serviceAddressRecipient)) @@ -1654,6 +1807,7 @@ private constructor( this.serviceAddressRecipient = serviceAddressRecipient } + /** The end date of the service period or delivery period */ fun serviceEndDate(serviceEndDate: LocalDate?) = serviceEndDate(JsonField.ofNullable(serviceEndDate)) @@ -1672,6 +1826,7 @@ private constructor( this.serviceEndDate = serviceEndDate } + /** The start date of the service period or delivery period */ fun serviceStartDate(serviceStartDate: LocalDate?) = serviceStartDate(JsonField.ofNullable(serviceStartDate)) @@ -1690,6 +1845,7 @@ private constructor( this.serviceStartDate = serviceStartDate } + /** The shipping/delivery address */ fun shippingAddress(shippingAddress: String?) = shippingAddress(JsonField.ofNullable(shippingAddress)) @@ -1708,6 +1864,7 @@ private constructor( this.shippingAddress = shippingAddress } + /** The recipient name at the shipping address */ fun shippingAddressRecipient(shippingAddressRecipient: String?) = shippingAddressRecipient(JsonField.ofNullable(shippingAddressRecipient)) @@ -1729,6 +1886,7 @@ private constructor( this.shippingAddressRecipient = shippingAddressRecipient } + /** The current state of the document: DRAFT, TRANSIT, FAILED, SENT, or RECEIVED */ fun state(state: DocumentState) = state(JsonField.of(state)) /** @@ -1758,7 +1916,10 @@ private constructor( */ fun subtotal(subtotal: JsonField) = apply { this.subtotal = subtotal } - /** Tax category code of the invoice */ + /** + * Tax category code of the invoice (e.g., S for standard rate, Z for zero rate, E for + * exempt) + */ fun taxCode(taxCode: TaxCode) = taxCode(JsonField.of(taxCode)) /** @@ -1820,7 +1981,9 @@ private constructor( this.totalDiscount = totalDiscount } - /** The total tax of the invoice. Must be positive and rounded to maximum 2 decimals */ + /** + * The total tax amount of the invoice. Must be positive and rounded to maximum 2 decimals + */ fun totalTax(totalTax: String?) = totalTax(JsonField.ofNullable(totalTax)) /** Alias for calling [Builder.totalTax] with `totalTax.orElse(null)`. */ @@ -1852,7 +2015,7 @@ private constructor( */ fun vatex(vatex: JsonField) = apply { this.vatex = vatex } - /** VAT exemption note of the invoice */ + /** Textual explanation for VAT exemption */ fun vatexNote(vatexNote: String?) = vatexNote(JsonField.ofNullable(vatexNote)) /** Alias for calling [Builder.vatexNote] with `vatexNote.orElse(null)`. */ @@ -1867,6 +2030,7 @@ private constructor( */ fun vatexNote(vatexNote: JsonField) = apply { this.vatexNote = vatexNote } + /** The address of the vendor/seller */ fun vendorAddress(vendorAddress: String?) = vendorAddress(JsonField.ofNullable(vendorAddress)) @@ -1885,6 +2049,7 @@ private constructor( this.vendorAddress = vendorAddress } + /** The recipient name at the vendor address */ fun vendorAddressRecipient(vendorAddressRecipient: String?) = vendorAddressRecipient(JsonField.ofNullable(vendorAddressRecipient)) @@ -1906,6 +2071,29 @@ private constructor( this.vendorAddressRecipient = vendorAddressRecipient } + /** + * Vendor company ID. For Belgium this is the CBE number or their EUID (European Unique + * Identifier) number. In the Netherlands this is the KVK number. + */ + fun vendorCompanyId(vendorCompanyId: String?) = + vendorCompanyId(JsonField.ofNullable(vendorCompanyId)) + + /** Alias for calling [Builder.vendorCompanyId] with `vendorCompanyId.orElse(null)`. */ + fun vendorCompanyId(vendorCompanyId: Optional) = + vendorCompanyId(vendorCompanyId.getOrNull()) + + /** + * Sets [Builder.vendorCompanyId] to an arbitrary JSON value. + * + * You should usually call [Builder.vendorCompanyId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun vendorCompanyId(vendorCompanyId: JsonField) = apply { + this.vendorCompanyId = vendorCompanyId + } + + /** The email address of the vendor */ fun vendorEmail(vendorEmail: String?) = vendorEmail(JsonField.ofNullable(vendorEmail)) /** Alias for calling [Builder.vendorEmail] with `vendorEmail.orElse(null)`. */ @@ -1920,6 +2108,7 @@ private constructor( */ fun vendorEmail(vendorEmail: JsonField) = apply { this.vendorEmail = vendorEmail } + /** The name of the vendor/seller/supplier */ fun vendorName(vendorName: String?) = vendorName(JsonField.ofNullable(vendorName)) /** Alias for calling [Builder.vendorName] with `vendorName.orElse(null)`. */ @@ -1934,6 +2123,7 @@ private constructor( */ fun vendorName(vendorName: JsonField) = apply { this.vendorName = vendorName } + /** Vendor tax ID. For Belgium this is the VAT number. Must include the country prefix */ fun vendorTaxId(vendorTaxId: String?) = vendorTaxId(JsonField.ofNullable(vendorTaxId)) /** Alias for calling [Builder.vendorTaxId] with `vendorTaxId.orElse(null)`. */ @@ -1991,6 +2181,7 @@ private constructor( currency, customerAddress, customerAddressRecipient, + customerCompanyId, customerEmail, customerId, customerName, @@ -2025,6 +2216,7 @@ private constructor( vatexNote, vendorAddress, vendorAddressRecipient, + vendorCompanyId, vendorEmail, vendorName, vendorTaxId, @@ -2049,6 +2241,7 @@ private constructor( currency().ifPresent { it.validate() } customerAddress() customerAddressRecipient() + customerCompanyId() customerEmail() customerId() customerName() @@ -2083,6 +2276,7 @@ private constructor( vatexNote() vendorAddress() vendorAddressRecipient() + vendorCompanyId() vendorEmail() vendorName() vendorTaxId() @@ -2114,6 +2308,7 @@ private constructor( (currency.asKnown().getOrNull()?.validity() ?: 0) + (if (customerAddress.asKnown().isPresent) 1 else 0) + (if (customerAddressRecipient.asKnown().isPresent) 1 else 0) + + (if (customerCompanyId.asKnown().isPresent) 1 else 0) + (if (customerEmail.asKnown().isPresent) 1 else 0) + (if (customerId.asKnown().isPresent) 1 else 0) + (if (customerName.asKnown().isPresent) 1 else 0) + @@ -2148,6 +2343,7 @@ private constructor( (if (vatexNote.asKnown().isPresent) 1 else 0) + (if (vendorAddress.asKnown().isPresent) 1 else 0) + (if (vendorAddressRecipient.asKnown().isPresent) 1 else 0) + + (if (vendorCompanyId.asKnown().isPresent) 1 else 0) + (if (vendorEmail.asKnown().isPresent) 1 else 0) + (if (vendorName.asKnown().isPresent) 1 else 0) + (if (vendorTaxId.asKnown().isPresent) 1 else 0) @@ -4024,6 +4220,8 @@ private constructor( ) : this(bankAccountNumber, iban, paymentReference, swift, mutableMapOf()) /** + * Bank account number (for non-IBAN accounts) + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ @@ -4031,18 +4229,25 @@ private constructor( bankAccountNumber.getOptional("bank_account_number") /** + * International Bank Account Number for payment transfers + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ fun iban(): Optional = iban.getOptional("iban") /** + * Structured payment reference or communication (e.g., structured communication for Belgian + * bank transfers) + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ fun paymentReference(): Optional = paymentReference.getOptional("payment_reference") /** + * SWIFT/BIC code of the bank + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ @@ -4118,6 +4323,7 @@ private constructor( additionalProperties = paymentDetail.additionalProperties.toMutableMap() } + /** Bank account number (for non-IBAN accounts) */ fun bankAccountNumber(bankAccountNumber: String?) = bankAccountNumber(JsonField.ofNullable(bankAccountNumber)) @@ -4138,6 +4344,7 @@ private constructor( this.bankAccountNumber = bankAccountNumber } + /** International Bank Account Number for payment transfers */ fun iban(iban: String?) = iban(JsonField.ofNullable(iban)) /** Alias for calling [Builder.iban] with `iban.orElse(null)`. */ @@ -4152,6 +4359,10 @@ private constructor( */ fun iban(iban: JsonField) = apply { this.iban = iban } + /** + * Structured payment reference or communication (e.g., structured communication for + * Belgian bank transfers) + */ fun paymentReference(paymentReference: String?) = paymentReference(JsonField.ofNullable(paymentReference)) @@ -4172,6 +4383,7 @@ private constructor( this.paymentReference = paymentReference } + /** SWIFT/BIC code of the bank */ fun swift(swift: String?) = swift(JsonField.ofNullable(swift)) /** Alias for calling [Builder.swift] with `swift.orElse(null)`. */ @@ -4278,7 +4490,9 @@ private constructor( "PaymentDetail{bankAccountNumber=$bankAccountNumber, iban=$iban, paymentReference=$paymentReference, swift=$swift, additionalProperties=$additionalProperties}" } - /** Tax category code of the invoice */ + /** + * Tax category code of the invoice (e.g., S for standard rate, Z for zero rate, E for exempt) + */ class TaxCode @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -4469,12 +4683,16 @@ private constructor( ) : this(amount, rate, mutableMapOf()) /** + * The tax amount for this tax category. Must be rounded to maximum 2 decimals + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ fun amount(): Optional = amount.getOptional("amount") /** + * The tax rate as a percentage (e.g., '21.00', '6.00', '0.00') + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ @@ -4526,6 +4744,7 @@ private constructor( additionalProperties = taxDetail.additionalProperties.toMutableMap() } + /** The tax amount for this tax category. Must be rounded to maximum 2 decimals */ fun amount(amount: String?) = amount(JsonField.ofNullable(amount)) /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ @@ -4540,6 +4759,7 @@ private constructor( */ fun amount(amount: JsonField) = apply { this.amount = amount } + /** The tax rate as a percentage (e.g., '21.00', '6.00', '0.00') */ fun rate(rate: String?) = rate(JsonField.ofNullable(rate)) /** Alias for calling [Builder.rate] with `rate.orElse(null)`. */ @@ -5138,6 +5358,7 @@ private constructor( currency == other.currency && customerAddress == other.customerAddress && customerAddressRecipient == other.customerAddressRecipient && + customerCompanyId == other.customerCompanyId && customerEmail == other.customerEmail && customerId == other.customerId && customerName == other.customerName && @@ -5172,6 +5393,7 @@ private constructor( vatexNote == other.vatexNote && vendorAddress == other.vendorAddress && vendorAddressRecipient == other.vendorAddressRecipient && + vendorCompanyId == other.vendorCompanyId && vendorEmail == other.vendorEmail && vendorName == other.vendorName && vendorTaxId == other.vendorTaxId && @@ -5190,6 +5412,7 @@ private constructor( currency, customerAddress, customerAddressRecipient, + customerCompanyId, customerEmail, customerId, customerName, @@ -5224,6 +5447,7 @@ private constructor( vatexNote, vendorAddress, vendorAddressRecipient, + vendorCompanyId, vendorEmail, vendorName, vendorTaxId, @@ -5234,5 +5458,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "DocumentResponse{id=$id, allowances=$allowances, amountDue=$amountDue, attachments=$attachments, billingAddress=$billingAddress, billingAddressRecipient=$billingAddressRecipient, charges=$charges, currency=$currency, customerAddress=$customerAddress, customerAddressRecipient=$customerAddressRecipient, customerEmail=$customerEmail, customerId=$customerId, customerName=$customerName, customerTaxId=$customerTaxId, direction=$direction, documentType=$documentType, dueDate=$dueDate, invoiceDate=$invoiceDate, invoiceId=$invoiceId, invoiceTotal=$invoiceTotal, items=$items, note=$note, paymentDetails=$paymentDetails, paymentTerm=$paymentTerm, previousUnpaidBalance=$previousUnpaidBalance, purchaseOrder=$purchaseOrder, remittanceAddress=$remittanceAddress, remittanceAddressRecipient=$remittanceAddressRecipient, serviceAddress=$serviceAddress, serviceAddressRecipient=$serviceAddressRecipient, serviceEndDate=$serviceEndDate, serviceStartDate=$serviceStartDate, shippingAddress=$shippingAddress, shippingAddressRecipient=$shippingAddressRecipient, state=$state, subtotal=$subtotal, taxCode=$taxCode, taxDetails=$taxDetails, totalDiscount=$totalDiscount, totalTax=$totalTax, vatex=$vatex, vatexNote=$vatexNote, vendorAddress=$vendorAddress, vendorAddressRecipient=$vendorAddressRecipient, vendorEmail=$vendorEmail, vendorName=$vendorName, vendorTaxId=$vendorTaxId, additionalProperties=$additionalProperties}" + "DocumentResponse{id=$id, allowances=$allowances, amountDue=$amountDue, attachments=$attachments, billingAddress=$billingAddress, billingAddressRecipient=$billingAddressRecipient, charges=$charges, currency=$currency, customerAddress=$customerAddress, customerAddressRecipient=$customerAddressRecipient, customerCompanyId=$customerCompanyId, customerEmail=$customerEmail, customerId=$customerId, customerName=$customerName, customerTaxId=$customerTaxId, direction=$direction, documentType=$documentType, dueDate=$dueDate, invoiceDate=$invoiceDate, invoiceId=$invoiceId, invoiceTotal=$invoiceTotal, items=$items, note=$note, paymentDetails=$paymentDetails, paymentTerm=$paymentTerm, previousUnpaidBalance=$previousUnpaidBalance, purchaseOrder=$purchaseOrder, remittanceAddress=$remittanceAddress, remittanceAddressRecipient=$remittanceAddressRecipient, serviceAddress=$serviceAddress, serviceAddressRecipient=$serviceAddressRecipient, serviceEndDate=$serviceEndDate, serviceStartDate=$serviceStartDate, shippingAddress=$shippingAddress, shippingAddressRecipient=$shippingAddressRecipient, state=$state, subtotal=$subtotal, taxCode=$taxCode, taxDetails=$taxDetails, totalDiscount=$totalDiscount, totalTax=$totalTax, vatex=$vatex, vatexNote=$vatexNote, vendorAddress=$vendorAddress, vendorAddressRecipient=$vendorAddressRecipient, vendorCompanyId=$vendorCompanyId, vendorEmail=$vendorEmail, vendorName=$vendorName, vendorTaxId=$vendorTaxId, additionalProperties=$additionalProperties}" } diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/PaymentDetailCreate.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/PaymentDetailCreate.kt index 87d6adb..d22e20f 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/PaymentDetailCreate.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/PaymentDetailCreate.kt @@ -39,24 +39,33 @@ private constructor( ) : this(bankAccountNumber, iban, paymentReference, swift, mutableMapOf()) /** + * Bank account number (for non-IBAN accounts) + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun bankAccountNumber(): Optional = bankAccountNumber.getOptional("bank_account_number") /** + * International Bank Account Number for payment transfers + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun iban(): Optional = iban.getOptional("iban") /** + * Structured payment reference or communication (e.g., structured communication for Belgian + * bank transfers) + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun paymentReference(): Optional = paymentReference.getOptional("payment_reference") /** + * SWIFT/BIC code of the bank + * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -132,6 +141,7 @@ private constructor( additionalProperties = paymentDetailCreate.additionalProperties.toMutableMap() } + /** Bank account number (for non-IBAN accounts) */ fun bankAccountNumber(bankAccountNumber: String?) = bankAccountNumber(JsonField.ofNullable(bankAccountNumber)) @@ -150,6 +160,7 @@ private constructor( this.bankAccountNumber = bankAccountNumber } + /** International Bank Account Number for payment transfers */ fun iban(iban: String?) = iban(JsonField.ofNullable(iban)) /** Alias for calling [Builder.iban] with `iban.orElse(null)`. */ @@ -163,6 +174,10 @@ private constructor( */ fun iban(iban: JsonField) = apply { this.iban = iban } + /** + * Structured payment reference or communication (e.g., structured communication for Belgian + * bank transfers) + */ fun paymentReference(paymentReference: String?) = paymentReference(JsonField.ofNullable(paymentReference)) @@ -181,6 +196,7 @@ private constructor( this.paymentReference = paymentReference } + /** SWIFT/BIC code of the bank */ fun swift(swift: String?) = swift(JsonField.ofNullable(swift)) /** Alias for calling [Builder.swift] with `swift.orElse(null)`. */ diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/me/MeRetrieveResponse.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/me/MeRetrieveResponse.kt index c3709a5..68c57a4 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/me/MeRetrieveResponse.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/me/MeRetrieveResponse.kt @@ -34,6 +34,7 @@ private constructor( private val companyEmail: JsonField, private val companyName: JsonField, private val companyNumber: JsonField, + private val companyTaxId: JsonField, private val companyZip: JsonField, private val description: JsonField, private val ibans: JsonField>, @@ -71,6 +72,9 @@ private constructor( @JsonProperty("company_number") @ExcludeMissing companyNumber: JsonField = JsonMissing.of(), + @JsonProperty("company_tax_id") + @ExcludeMissing + companyTaxId: JsonField = JsonMissing.of(), @JsonProperty("company_zip") @ExcludeMissing companyZip: JsonField = JsonMissing.of(), @@ -98,6 +102,7 @@ private constructor( companyEmail, companyName, companyNumber, + companyTaxId, companyZip, description, ibans, @@ -138,7 +143,7 @@ private constructor( fun bccRecipientEmail(): Optional = bccRecipientEmail.getOptional("bcc_recipient_email") /** - * Address of the company + * Address of the company. Must be in the form of `Street Name Street Number` * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -170,7 +175,7 @@ private constructor( fun companyEmail(): Optional = companyEmail.getOptional("company_email") /** - * Name of the company + * Name of the company. Must include the company type. For example: `BV`, `NV`, `CVBA`, `VOF` * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -178,13 +183,22 @@ private constructor( fun companyName(): Optional = companyName.getOptional("company_name") /** - * Company number + * Company number. For Belgium this is the CBE number or their EUID (European Unique Identifier) + * number * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun companyNumber(): Optional = companyNumber.getOptional("company_number") + /** + * Company tax ID. For Belgium this is the VAT number. Must include the country prefix + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun companyTaxId(): Optional = companyTaxId.getOptional("company_tax_id") + /** * Zip code of the company * @@ -319,6 +333,15 @@ private constructor( @ExcludeMissing fun _companyNumber(): JsonField = companyNumber + /** + * Returns the raw JSON value of [companyTaxId]. + * + * Unlike [companyTaxId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("company_tax_id") + @ExcludeMissing + fun _companyTaxId(): JsonField = companyTaxId + /** * Returns the raw JSON value of [companyZip]. * @@ -408,6 +431,7 @@ private constructor( private var companyEmail: JsonField = JsonMissing.of() private var companyName: JsonField = JsonMissing.of() private var companyNumber: JsonField = JsonMissing.of() + private var companyTaxId: JsonField = JsonMissing.of() private var companyZip: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() private var ibans: JsonField>? = null @@ -428,6 +452,7 @@ private constructor( companyEmail = meRetrieveResponse.companyEmail companyName = meRetrieveResponse.companyName companyNumber = meRetrieveResponse.companyNumber + companyTaxId = meRetrieveResponse.companyTaxId companyZip = meRetrieveResponse.companyZip description = meRetrieveResponse.description ibans = meRetrieveResponse.ibans.map { it.toMutableList() } @@ -491,7 +516,7 @@ private constructor( this.bccRecipientEmail = bccRecipientEmail } - /** Address of the company */ + /** Address of the company. Must be in the form of `Street Name Street Number` */ fun companyAddress(companyAddress: String?) = companyAddress(JsonField.ofNullable(companyAddress)) @@ -561,7 +586,10 @@ private constructor( this.companyEmail = companyEmail } - /** Name of the company */ + /** + * Name of the company. Must include the company type. For example: `BV`, `NV`, `CVBA`, + * `VOF` + */ fun companyName(companyName: String?) = companyName(JsonField.ofNullable(companyName)) /** Alias for calling [Builder.companyName] with `companyName.orElse(null)`. */ @@ -576,7 +604,10 @@ private constructor( */ fun companyName(companyName: JsonField) = apply { this.companyName = companyName } - /** Company number */ + /** + * Company number. For Belgium this is the CBE number or their EUID (European Unique + * Identifier) number + */ fun companyNumber(companyNumber: String?) = companyNumber(JsonField.ofNullable(companyNumber)) @@ -595,6 +626,23 @@ private constructor( this.companyNumber = companyNumber } + /** Company tax ID. For Belgium this is the VAT number. Must include the country prefix */ + fun companyTaxId(companyTaxId: String?) = companyTaxId(JsonField.ofNullable(companyTaxId)) + + /** Alias for calling [Builder.companyTaxId] with `companyTaxId.orElse(null)`. */ + fun companyTaxId(companyTaxId: Optional) = companyTaxId(companyTaxId.getOrNull()) + + /** + * Sets [Builder.companyTaxId] to an arbitrary JSON value. + * + * You should usually call [Builder.companyTaxId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun companyTaxId(companyTaxId: JsonField) = apply { + this.companyTaxId = companyTaxId + } + /** Zip code of the company */ fun companyZip(companyZip: String?) = companyZip(JsonField.ofNullable(companyZip)) @@ -772,6 +820,7 @@ private constructor( companyEmail, companyName, companyNumber, + companyTaxId, companyZip, description, (ibans ?: JsonMissing.of()).map { it.toImmutable() }, @@ -799,6 +848,7 @@ private constructor( companyEmail() companyName() companyNumber() + companyTaxId() companyZip() description() ibans() @@ -833,6 +883,7 @@ private constructor( (if (companyEmail.asKnown().isPresent) 1 else 0) + (if (companyName.asKnown().isPresent) 1 else 0) + (if (companyNumber.asKnown().isPresent) 1 else 0) + + (if (companyTaxId.asKnown().isPresent) 1 else 0) + (if (companyZip.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + (ibans.asKnown().getOrNull()?.size ?: 0) + @@ -990,6 +1041,7 @@ private constructor( companyEmail == other.companyEmail && companyName == other.companyName && companyNumber == other.companyNumber && + companyTaxId == other.companyTaxId && companyZip == other.companyZip && description == other.description && ibans == other.ibans && @@ -1011,6 +1063,7 @@ private constructor( companyEmail, companyName, companyNumber, + companyTaxId, companyZip, description, ibans, @@ -1024,5 +1077,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MeRetrieveResponse{creditBalance=$creditBalance, name=$name, plan=$plan, bccRecipientEmail=$bccRecipientEmail, companyAddress=$companyAddress, companyCity=$companyCity, companyCountry=$companyCountry, companyEmail=$companyEmail, companyName=$companyName, companyNumber=$companyNumber, companyZip=$companyZip, description=$description, ibans=$ibans, peppolIds=$peppolIds, smpRegistration=$smpRegistration, smpRegistrationDate=$smpRegistrationDate, additionalProperties=$additionalProperties}" + "MeRetrieveResponse{creditBalance=$creditBalance, name=$name, plan=$plan, bccRecipientEmail=$bccRecipientEmail, companyAddress=$companyAddress, companyCity=$companyCity, companyCountry=$companyCountry, companyEmail=$companyEmail, companyName=$companyName, companyNumber=$companyNumber, companyTaxId=$companyTaxId, companyZip=$companyZip, description=$description, ibans=$ibans, peppolIds=$peppolIds, smpRegistration=$smpRegistration, smpRegistrationDate=$smpRegistrationDate, additionalProperties=$additionalProperties}" } diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponseTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponseTest.kt index 47aa52d..7c7d640 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponseTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponseTest.kt @@ -52,10 +52,11 @@ internal class DocumentCreateFromPdfResponseTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -134,9 +135,10 @@ internal class DocumentCreateFromPdfResponseTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() assertThat(documentCreateFromPdfResponse.allowances().getOrNull()) @@ -180,10 +182,11 @@ internal class DocumentCreateFromPdfResponseTest { assertThat(documentCreateFromPdfResponse.customerAddress()).contains("customer_address") assertThat(documentCreateFromPdfResponse.customerAddressRecipient()) .contains("customer_address_recipient") + assertThat(documentCreateFromPdfResponse.customerCompanyId()).contains("1018265814") assertThat(documentCreateFromPdfResponse.customerEmail()).contains("customer_email") assertThat(documentCreateFromPdfResponse.customerId()).contains("customer_id") assertThat(documentCreateFromPdfResponse.customerName()).contains("customer_name") - assertThat(documentCreateFromPdfResponse.customerTaxId()).contains("customer_tax_id") + assertThat(documentCreateFromPdfResponse.customerTaxId()).contains("BE1018265814") assertThat(documentCreateFromPdfResponse.direction()).contains(DocumentDirection.INBOUND) assertThat(documentCreateFromPdfResponse.documentType()).contains(DocumentType.INVOICE) assertThat(documentCreateFromPdfResponse.dueDate()).contains(LocalDate.parse("2019-12-27")) @@ -275,9 +278,10 @@ internal class DocumentCreateFromPdfResponseTest { assertThat(documentCreateFromPdfResponse.vendorAddress()).contains("vendor_address") assertThat(documentCreateFromPdfResponse.vendorAddressRecipient()) .contains("vendor_address_recipient") + assertThat(documentCreateFromPdfResponse.vendorCompanyId()).contains("1018265814") assertThat(documentCreateFromPdfResponse.vendorEmail()).contains("vendor_email") assertThat(documentCreateFromPdfResponse.vendorName()).contains("vendor_name") - assertThat(documentCreateFromPdfResponse.vendorTaxId()).contains("vendor_tax_id") + assertThat(documentCreateFromPdfResponse.vendorTaxId()).contains("BE1018265814") } @Test @@ -321,10 +325,11 @@ internal class DocumentCreateFromPdfResponseTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -403,9 +408,10 @@ internal class DocumentCreateFromPdfResponseTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() val roundtrippedDocumentCreateFromPdfResponse = diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateParamsTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateParamsTest.kt index 72eb3cb..6aec828 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateParamsTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateParamsTest.kt @@ -50,10 +50,11 @@ internal class DocumentCreateParamsTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -127,9 +128,10 @@ internal class DocumentCreateParamsTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() ) .build() @@ -177,10 +179,11 @@ internal class DocumentCreateParamsTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -254,9 +257,10 @@ internal class DocumentCreateParamsTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() ) .build() @@ -302,10 +306,11 @@ internal class DocumentCreateParamsTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -379,9 +384,10 @@ internal class DocumentCreateParamsTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() ) } diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateTest.kt index 2131d8c..655056f 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateTest.kt @@ -52,10 +52,11 @@ internal class DocumentCreateTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -127,9 +128,10 @@ internal class DocumentCreateTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() assertThat(documentCreate.allowances().getOrNull()) @@ -171,10 +173,11 @@ internal class DocumentCreateTest { assertThat(documentCreate.currency()).contains(CurrencyCode.EUR) assertThat(documentCreate.customerAddress()).contains("customer_address") assertThat(documentCreate.customerAddressRecipient()).contains("customer_address_recipient") + assertThat(documentCreate.customerCompanyId()).contains("1018265814") assertThat(documentCreate.customerEmail()).contains("customer_email") assertThat(documentCreate.customerId()).contains("customer_id") assertThat(documentCreate.customerName()).contains("customer_name") - assertThat(documentCreate.customerTaxId()).contains("customer_tax_id") + assertThat(documentCreate.customerTaxId()).contains("BE1018265814") assertThat(documentCreate.direction()).contains(DocumentDirection.INBOUND) assertThat(documentCreate.documentType()).contains(DocumentType.INVOICE) assertThat(documentCreate.dueDate()).contains(LocalDate.parse("2019-12-27")) @@ -253,9 +256,10 @@ internal class DocumentCreateTest { assertThat(documentCreate.vatexNote()).contains("vatex_note") assertThat(documentCreate.vendorAddress()).contains("vendor_address") assertThat(documentCreate.vendorAddressRecipient()).contains("vendor_address_recipient") + assertThat(documentCreate.vendorCompanyId()).contains("1018265814") assertThat(documentCreate.vendorEmail()).contains("vendor_email") assertThat(documentCreate.vendorName()).contains("vendor_name") - assertThat(documentCreate.vendorTaxId()).contains("vendor_tax_id") + assertThat(documentCreate.vendorTaxId()).contains("BE1018265814") } @Test @@ -299,10 +303,11 @@ internal class DocumentCreateTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -374,9 +379,10 @@ internal class DocumentCreateTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() val roundtrippedDocumentCreate = diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentResponseTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentResponseTest.kt index 7568d34..a404ab7 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentResponseTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentResponseTest.kt @@ -55,10 +55,11 @@ internal class DocumentResponseTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -132,9 +133,10 @@ internal class DocumentResponseTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() assertThat(documentResponse.id()).isEqualTo("id") @@ -179,10 +181,11 @@ internal class DocumentResponseTest { assertThat(documentResponse.customerAddress()).contains("customer_address") assertThat(documentResponse.customerAddressRecipient()) .contains("customer_address_recipient") + assertThat(documentResponse.customerCompanyId()).contains("1018265814") assertThat(documentResponse.customerEmail()).contains("customer_email") assertThat(documentResponse.customerId()).contains("customer_id") assertThat(documentResponse.customerName()).contains("customer_name") - assertThat(documentResponse.customerTaxId()).contains("customer_tax_id") + assertThat(documentResponse.customerTaxId()).contains("BE1018265814") assertThat(documentResponse.direction()).contains(DocumentDirection.INBOUND) assertThat(documentResponse.documentType()).contains(DocumentType.INVOICE) assertThat(documentResponse.dueDate()).contains(LocalDate.parse("2019-12-27")) @@ -261,9 +264,10 @@ internal class DocumentResponseTest { assertThat(documentResponse.vatexNote()).contains("vatex_note") assertThat(documentResponse.vendorAddress()).contains("vendor_address") assertThat(documentResponse.vendorAddressRecipient()).contains("vendor_address_recipient") + assertThat(documentResponse.vendorCompanyId()).contains("1018265814") assertThat(documentResponse.vendorEmail()).contains("vendor_email") assertThat(documentResponse.vendorName()).contains("vendor_name") - assertThat(documentResponse.vendorTaxId()).contains("vendor_tax_id") + assertThat(documentResponse.vendorTaxId()).contains("BE1018265814") } @Test @@ -309,10 +313,11 @@ internal class DocumentResponseTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -386,9 +391,10 @@ internal class DocumentResponseTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() val roundtrippedDocumentResponse = diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt index 92e57e4..987a7ec 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt @@ -62,10 +62,11 @@ internal class PaginatedDocumentResponseTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -142,9 +143,10 @@ internal class PaginatedDocumentResponseTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() ) .page(0L) @@ -194,10 +196,11 @@ internal class PaginatedDocumentResponseTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -271,9 +274,10 @@ internal class PaginatedDocumentResponseTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() ) assertThat(paginatedDocumentResponse.page()).isEqualTo(0L) @@ -327,10 +331,11 @@ internal class PaginatedDocumentResponseTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -407,9 +412,10 @@ internal class PaginatedDocumentResponseTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() ) .page(0L) diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/me/MeRetrieveResponseTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/me/MeRetrieveResponseTest.kt index 2a16e6a..28da861 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/me/MeRetrieveResponseTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/me/MeRetrieveResponseTest.kt @@ -19,13 +19,14 @@ internal class MeRetrieveResponseTest { .name("name") .plan(MeRetrieveResponse.Plan.STARTER) .bccRecipientEmail("bcc_recipient_email") - .companyAddress("company_address") - .companyCity("company_city") - .companyCountry("company_country") - .companyEmail("company_email") - .companyName("company_name") - .companyNumber("company_number") - .companyZip("company_zip") + .companyAddress("Brusselsesteenweg 119/A") + .companyCity("Zemst") + .companyCountry("Belgium") + .companyEmail("info@e-invoice.be") + .companyName("E-INVOICE BV") + .companyNumber("1018265814") + .companyTaxId("BE1018265814") + .companyZip("1980") .description("description") .addIban("string") .addPeppolId("string") @@ -37,13 +38,14 @@ internal class MeRetrieveResponseTest { assertThat(meRetrieveResponse.name()).isEqualTo("name") assertThat(meRetrieveResponse.plan()).isEqualTo(MeRetrieveResponse.Plan.STARTER) assertThat(meRetrieveResponse.bccRecipientEmail()).contains("bcc_recipient_email") - assertThat(meRetrieveResponse.companyAddress()).contains("company_address") - assertThat(meRetrieveResponse.companyCity()).contains("company_city") - assertThat(meRetrieveResponse.companyCountry()).contains("company_country") - assertThat(meRetrieveResponse.companyEmail()).contains("company_email") - assertThat(meRetrieveResponse.companyName()).contains("company_name") - assertThat(meRetrieveResponse.companyNumber()).contains("company_number") - assertThat(meRetrieveResponse.companyZip()).contains("company_zip") + assertThat(meRetrieveResponse.companyAddress()).contains("Brusselsesteenweg 119/A") + assertThat(meRetrieveResponse.companyCity()).contains("Zemst") + assertThat(meRetrieveResponse.companyCountry()).contains("Belgium") + assertThat(meRetrieveResponse.companyEmail()).contains("info@e-invoice.be") + assertThat(meRetrieveResponse.companyName()).contains("E-INVOICE BV") + assertThat(meRetrieveResponse.companyNumber()).contains("1018265814") + assertThat(meRetrieveResponse.companyTaxId()).contains("BE1018265814") + assertThat(meRetrieveResponse.companyZip()).contains("1980") assertThat(meRetrieveResponse.description()).contains("description") assertThat(meRetrieveResponse.ibans().getOrNull()).containsExactly("string") assertThat(meRetrieveResponse.peppolIds().getOrNull()).containsExactly("string") @@ -61,13 +63,14 @@ internal class MeRetrieveResponseTest { .name("name") .plan(MeRetrieveResponse.Plan.STARTER) .bccRecipientEmail("bcc_recipient_email") - .companyAddress("company_address") - .companyCity("company_city") - .companyCountry("company_country") - .companyEmail("company_email") - .companyName("company_name") - .companyNumber("company_number") - .companyZip("company_zip") + .companyAddress("Brusselsesteenweg 119/A") + .companyCity("Zemst") + .companyCountry("Belgium") + .companyEmail("info@e-invoice.be") + .companyName("E-INVOICE BV") + .companyNumber("1018265814") + .companyTaxId("BE1018265814") + .companyZip("1980") .description("description") .addIban("string") .addPeppolId("string") diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/validate/ValidateValidateJsonParamsTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/validate/ValidateValidateJsonParamsTest.kt index dfbad13..44d2c71 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/validate/ValidateValidateJsonParamsTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/validate/ValidateValidateJsonParamsTest.kt @@ -57,10 +57,11 @@ internal class ValidateValidateJsonParamsTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -134,9 +135,10 @@ internal class ValidateValidateJsonParamsTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() ) .build() @@ -184,10 +186,11 @@ internal class ValidateValidateJsonParamsTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -261,9 +264,10 @@ internal class ValidateValidateJsonParamsTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() ) .build() @@ -309,10 +313,11 @@ internal class ValidateValidateJsonParamsTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -386,9 +391,10 @@ internal class ValidateValidateJsonParamsTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() ) } diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ErrorHandlingTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ErrorHandlingTest.kt index 3864f1f..44a8ed8 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ErrorHandlingTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ErrorHandlingTest.kt @@ -116,10 +116,11 @@ internal class ErrorHandlingTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -193,9 +194,10 @@ internal class ErrorHandlingTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() ) } @@ -255,10 +257,11 @@ internal class ErrorHandlingTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -332,9 +335,10 @@ internal class ErrorHandlingTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() ) } @@ -394,10 +398,11 @@ internal class ErrorHandlingTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -471,9 +476,10 @@ internal class ErrorHandlingTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() ) } @@ -533,10 +539,11 @@ internal class ErrorHandlingTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -610,9 +617,10 @@ internal class ErrorHandlingTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() ) } @@ -672,10 +680,11 @@ internal class ErrorHandlingTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -749,9 +758,10 @@ internal class ErrorHandlingTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() ) } @@ -811,10 +821,11 @@ internal class ErrorHandlingTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -888,9 +899,10 @@ internal class ErrorHandlingTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() ) } @@ -950,10 +962,11 @@ internal class ErrorHandlingTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -1027,9 +1040,10 @@ internal class ErrorHandlingTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() ) } @@ -1089,10 +1103,11 @@ internal class ErrorHandlingTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -1166,9 +1181,10 @@ internal class ErrorHandlingTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() ) } @@ -1228,10 +1244,11 @@ internal class ErrorHandlingTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -1305,9 +1322,10 @@ internal class ErrorHandlingTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() ) } @@ -1367,10 +1385,11 @@ internal class ErrorHandlingTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -1444,9 +1463,10 @@ internal class ErrorHandlingTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() ) } @@ -1506,10 +1526,11 @@ internal class ErrorHandlingTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -1583,9 +1604,10 @@ internal class ErrorHandlingTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() ) } @@ -1645,10 +1667,11 @@ internal class ErrorHandlingTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -1722,9 +1745,10 @@ internal class ErrorHandlingTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() ) } @@ -1784,10 +1808,11 @@ internal class ErrorHandlingTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -1861,9 +1886,10 @@ internal class ErrorHandlingTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() ) } @@ -1923,10 +1949,11 @@ internal class ErrorHandlingTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -2000,9 +2027,10 @@ internal class ErrorHandlingTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() ) } @@ -2062,10 +2090,11 @@ internal class ErrorHandlingTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -2139,9 +2168,10 @@ internal class ErrorHandlingTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() ) } @@ -2201,10 +2231,11 @@ internal class ErrorHandlingTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -2278,9 +2309,10 @@ internal class ErrorHandlingTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() ) } @@ -2338,10 +2370,11 @@ internal class ErrorHandlingTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -2415,9 +2448,10 @@ internal class ErrorHandlingTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() ) } diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ServiceParamsTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ServiceParamsTest.kt index 961b110..44e13bd 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ServiceParamsTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ServiceParamsTest.kt @@ -86,10 +86,11 @@ internal class ServiceParamsTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -161,9 +162,10 @@ internal class ServiceParamsTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() ) diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncTest.kt index 22a131e..c75bf1d 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncTest.kt @@ -71,10 +71,11 @@ internal class DocumentServiceAsyncTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -148,9 +149,10 @@ internal class DocumentServiceAsyncTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() ) diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/ValidateServiceAsyncTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/ValidateServiceAsyncTest.kt index 921db18..827c4e0 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/ValidateServiceAsyncTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/ValidateServiceAsyncTest.kt @@ -71,10 +71,11 @@ internal class ValidateServiceAsyncTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -148,9 +149,10 @@ internal class ValidateServiceAsyncTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() ) diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/DocumentServiceTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/DocumentServiceTest.kt index a872082..c34988c 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/DocumentServiceTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/DocumentServiceTest.kt @@ -71,10 +71,11 @@ internal class DocumentServiceTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -148,9 +149,10 @@ internal class DocumentServiceTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() ) diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/ValidateServiceTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/ValidateServiceTest.kt index 1ef161a..936c28c 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/ValidateServiceTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/ValidateServiceTest.kt @@ -71,10 +71,11 @@ internal class ValidateServiceTest { .currency(CurrencyCode.EUR) .customerAddress("customer_address") .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") .customerEmail("customer_email") .customerId("customer_id") .customerName("customer_name") - .customerTaxId("customer_tax_id") + .customerTaxId("BE1018265814") .direction(DocumentDirection.INBOUND) .documentType(DocumentType.INVOICE) .dueDate(LocalDate.parse("2019-12-27")) @@ -148,9 +149,10 @@ internal class ValidateServiceTest { .vatexNote("vatex_note") .vendorAddress("vendor_address") .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") .vendorEmail("vendor_email") .vendorName("vendor_name") - .vendorTaxId("vendor_tax_id") + .vendorTaxId("BE1018265814") .build() ) From 57c75d98fc1b53bdc1d1544476c6a31cec525601 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Nov 2025 03:14:12 +0000 Subject: [PATCH 08/43] fix(client): multi-value header serialization --- .../kotlin/com/e_invoice/api/client/okhttp/OkHttpClient.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/OkHttpClient.kt b/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/OkHttpClient.kt index f3c8245..6836d72 100644 --- a/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/OkHttpClient.kt +++ b/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/OkHttpClient.kt @@ -109,19 +109,19 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpC val builder = Request.Builder().url(toUrl()).method(method.name, body) headers.names().forEach { name -> - headers.values(name).forEach { builder.header(name, it) } + headers.values(name).forEach { builder.addHeader(name, it) } } if ( !headers.names().contains("X-Stainless-Read-Timeout") && client.readTimeoutMillis != 0 ) { - builder.header( + builder.addHeader( "X-Stainless-Read-Timeout", Duration.ofMillis(client.readTimeoutMillis.toLong()).seconds.toString(), ) } if (!headers.names().contains("X-Stainless-Timeout") && client.callTimeoutMillis != 0) { - builder.header( + builder.addHeader( "X-Stainless-Timeout", Duration.ofMillis(client.callTimeoutMillis.toLong()).seconds.toString(), ) From 02308b86f70414c3008b61e1776f17f1fa8d38f0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Nov 2025 09:14:10 +0000 Subject: [PATCH 09/43] feat(api): api update --- .stats.yml | 4 +- .../api/models/documents/Allowance.kt | 298 +- .../e_invoice/api/models/documents/Charge.kt | 1218 ++- .../api/models/documents/DocumentCreate.kt | 8207 ++++++++++++----- .../DocumentCreateFromPdfResponse.kt | 76 +- .../api/models/documents/DocumentResponse.kt | 1589 +++- .../api/models/documents/AllowanceTest.kt | 6 +- .../api/models/documents/ChargeTest.kt | 12 +- .../DocumentCreateFromPdfResponseTest.kt | 45 +- .../documents/DocumentCreateParamsTest.kt | 57 +- .../models/documents/DocumentCreateTest.kt | 57 +- .../models/documents/DocumentResponseTest.kt | 45 +- .../inbox/PaginatedDocumentResponseTest.kt | 45 +- .../ValidateValidateJsonParamsTest.kt | 57 +- .../api/services/ErrorHandlingTest.kt | 323 +- .../api/services/ServiceParamsTest.kt | 19 +- .../async/DocumentServiceAsyncTest.kt | 19 +- .../async/ValidateServiceAsyncTest.kt | 19 +- .../services/blocking/DocumentServiceTest.kt | 19 +- .../services/blocking/ValidateServiceTest.kt | 19 +- .../api/proguard/ProGuardCompatibilityTest.kt | 2 +- 21 files changed, 9561 insertions(+), 2575 deletions(-) diff --git a/.stats.yml b/.stats.yml index 12f0e7f..e83c012 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-009e20418b5b4a984fbc1a6c74d2148f2ebb823568699babb83ec8a4f2aea1f7.yml -openapi_spec_hash: 8a63ae95d8d7e7beaaf306f1bb2b1cd3 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-59acba77a8b016bab32cdc817ebca4ffda9d446803c3f28d662d85666d49d0ad.yml +openapi_spec_hash: aac8accb851703f53ab7e17a5fb23a48 config_hash: 852a0117abb3db077933876ad1185f41 diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Allowance.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Allowance.kt index 75ac28d..0351698 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Allowance.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Allowance.kt @@ -25,7 +25,7 @@ private constructor( private val baseAmount: JsonField, private val multiplierFactor: JsonField, private val reason: JsonField, - private val reasonCode: JsonField, + private val reasonCode: JsonField, private val taxCode: JsonField, private val taxRate: JsonField, private val additionalProperties: MutableMap, @@ -43,7 +43,7 @@ private constructor( @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), @JsonProperty("reason_code") @ExcludeMissing - reasonCode: JsonField = JsonMissing.of(), + reasonCode: JsonField = JsonMissing.of(), @JsonProperty("tax_code") @ExcludeMissing taxCode: JsonField = JsonMissing.of(), @JsonProperty("tax_rate") @ExcludeMissing taxRate: JsonField = JsonMissing.of(), ) : this( @@ -76,7 +76,7 @@ private constructor( /** * The percentage that may be used, in conjunction with the allowance base amount, to calculate - * the allowance amount. To state 20%, use value 20 + * the allowance amount. To state 20%, use value 20. Must be rounded to maximum 2 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -92,17 +92,15 @@ private constructor( fun reason(): Optional = reason.getOptional("reason") /** - * The code for the allowance reason + * Allowance reason codes for invoice discounts and charges * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun reasonCode(): Optional = reasonCode.getOptional("reason_code") + fun reasonCode(): Optional = reasonCode.getOptional("reason_code") /** - * Duty or tax or fee category codes (Subset of UNCL5305) - * - * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + * The VAT category code that applies to the allowance * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -110,7 +108,8 @@ private constructor( fun taxCode(): Optional = taxCode.getOptional("tax_code") /** - * The VAT rate, represented as percentage that applies to the allowance + * The VAT rate, represented as percentage that applies to the allowance. Must be rounded to + * maximum 2 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -153,7 +152,9 @@ private constructor( * * Unlike [reasonCode], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("reason_code") @ExcludeMissing fun _reasonCode(): JsonField = reasonCode + @JsonProperty("reason_code") + @ExcludeMissing + fun _reasonCode(): JsonField = reasonCode /** * Returns the raw JSON value of [taxCode]. @@ -194,7 +195,7 @@ private constructor( private var baseAmount: JsonField = JsonMissing.of() private var multiplierFactor: JsonField = JsonMissing.of() private var reason: JsonField = JsonMissing.of() - private var reasonCode: JsonField = JsonMissing.of() + private var reasonCode: JsonField = JsonMissing.of() private var taxCode: JsonField = JsonMissing.of() private var taxRate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -245,7 +246,8 @@ private constructor( /** * The percentage that may be used, in conjunction with the allowance base amount, to - * calculate the allowance amount. To state 20%, use value 20 + * calculate the allowance amount. To state 20%, use value 20. Must be rounded to maximum 2 + * decimals */ fun multiplierFactor(multiplierFactor: String?) = multiplierFactor(JsonField.ofNullable(multiplierFactor)) @@ -279,30 +281,23 @@ private constructor( */ fun reason(reason: JsonField) = apply { this.reason = reason } - /** The code for the allowance reason */ - fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) + /** Allowance reason codes for invoice discounts and charges */ + fun reasonCode(reasonCode: ReasonCode?) = reasonCode(JsonField.ofNullable(reasonCode)) /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ - fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) + fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) /** * Sets [Builder.reasonCode] to an arbitrary JSON value. * - * You should usually call [Builder.reasonCode] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode } - - /** - * Duty or tax or fee category codes (Subset of UNCL5305) - * - * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + * You should usually call [Builder.reasonCode] with a well-typed [ReasonCode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun taxCode(taxCode: TaxCode?) = taxCode(JsonField.ofNullable(taxCode)) + fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode } - /** Alias for calling [Builder.taxCode] with `taxCode.orElse(null)`. */ - fun taxCode(taxCode: Optional) = taxCode(taxCode.getOrNull()) + /** The VAT category code that applies to the allowance */ + fun taxCode(taxCode: TaxCode) = taxCode(JsonField.of(taxCode)) /** * Sets [Builder.taxCode] to an arbitrary JSON value. @@ -312,7 +307,10 @@ private constructor( */ fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } - /** The VAT rate, represented as percentage that applies to the allowance */ + /** + * The VAT rate, represented as percentage that applies to the allowance. Must be rounded to + * maximum 2 decimals + */ fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ @@ -374,7 +372,7 @@ private constructor( baseAmount() multiplierFactor() reason() - reasonCode() + reasonCode().ifPresent { it.validate() } taxCode().ifPresent { it.validate() } taxRate() validated = true @@ -399,15 +397,243 @@ private constructor( (if (baseAmount.asKnown().isPresent) 1 else 0) + (if (multiplierFactor.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) + - (if (reasonCode.asKnown().isPresent) 1 else 0) + + (reasonCode.asKnown().getOrNull()?.validity() ?: 0) + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + (if (taxRate.asKnown().isPresent) 1 else 0) - /** - * Duty or tax or fee category codes (Subset of UNCL5305) - * - * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL - */ + /** Allowance reason codes for invoice discounts and charges */ + class ReasonCode @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val _41 = of("41") + + @JvmField val _42 = of("42") + + @JvmField val _60 = of("60") + + @JvmField val _62 = of("62") + + @JvmField val _63 = of("63") + + @JvmField val _64 = of("64") + + @JvmField val _65 = of("65") + + @JvmField val _66 = of("66") + + @JvmField val _67 = of("67") + + @JvmField val _68 = of("68") + + @JvmField val _70 = of("70") + + @JvmField val _71 = of("71") + + @JvmField val _88 = of("88") + + @JvmField val _95 = of("95") + + @JvmField val _100 = of("100") + + @JvmField val _102 = of("102") + + @JvmField val _103 = of("103") + + @JvmField val _104 = of("104") + + @JvmField val _105 = of("105") + + @JvmStatic fun of(value: String) = ReasonCode(JsonField.of(value)) + } + + /** An enum containing [ReasonCode]'s known values. */ + enum class Known { + _41, + _42, + _60, + _62, + _63, + _64, + _65, + _66, + _67, + _68, + _70, + _71, + _88, + _95, + _100, + _102, + _103, + _104, + _105, + } + + /** + * An enum containing [ReasonCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ReasonCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + _41, + _42, + _60, + _62, + _63, + _64, + _65, + _66, + _67, + _68, + _70, + _71, + _88, + _95, + _100, + _102, + _103, + _104, + _105, + /** + * An enum member indicating that [ReasonCode] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + _41 -> Value._41 + _42 -> Value._42 + _60 -> Value._60 + _62 -> Value._62 + _63 -> Value._63 + _64 -> Value._64 + _65 -> Value._65 + _66 -> Value._66 + _67 -> Value._67 + _68 -> Value._68 + _70 -> Value._70 + _71 -> Value._71 + _88 -> Value._88 + _95 -> Value._95 + _100 -> Value._100 + _102 -> Value._102 + _103 -> Value._103 + _104 -> Value._104 + _105 -> Value._105 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + _41 -> Known._41 + _42 -> Known._42 + _60 -> Known._60 + _62 -> Known._62 + _63 -> Known._63 + _64 -> Known._64 + _65 -> Known._65 + _66 -> Known._66 + _67 -> Known._67 + _68 -> Known._68 + _70 -> Known._70 + _71 -> Known._71 + _88 -> Known._88 + _95 -> Known._95 + _100 -> Known._100 + _102 -> Known._102 + _103 -> Known._103 + _104 -> Known._104 + _105 -> Known._105 + else -> throw EInvoiceInvalidDataException("Unknown ReasonCode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReasonCode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReasonCode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The VAT category code that applies to the allowance */ class TaxCode @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Charge.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Charge.kt index 3654cc2..45e1ce7 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Charge.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Charge.kt @@ -25,7 +25,7 @@ private constructor( private val baseAmount: JsonField, private val multiplierFactor: JsonField, private val reason: JsonField, - private val reasonCode: JsonField, + private val reasonCode: JsonField, private val taxCode: JsonField, private val taxRate: JsonField, private val additionalProperties: MutableMap, @@ -43,7 +43,7 @@ private constructor( @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), @JsonProperty("reason_code") @ExcludeMissing - reasonCode: JsonField = JsonMissing.of(), + reasonCode: JsonField = JsonMissing.of(), @JsonProperty("tax_code") @ExcludeMissing taxCode: JsonField = JsonMissing.of(), @JsonProperty("tax_rate") @ExcludeMissing taxRate: JsonField = JsonMissing.of(), ) : this( @@ -92,12 +92,12 @@ private constructor( fun reason(): Optional = reason.getOptional("reason") /** - * The code for the charge reason + * Charge reason codes for invoice charges and fees * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun reasonCode(): Optional = reasonCode.getOptional("reason_code") + fun reasonCode(): Optional = reasonCode.getOptional("reason_code") /** * Duty or tax or fee category codes (Subset of UNCL5305) @@ -153,7 +153,9 @@ private constructor( * * Unlike [reasonCode], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("reason_code") @ExcludeMissing fun _reasonCode(): JsonField = reasonCode + @JsonProperty("reason_code") + @ExcludeMissing + fun _reasonCode(): JsonField = reasonCode /** * Returns the raw JSON value of [taxCode]. @@ -194,7 +196,7 @@ private constructor( private var baseAmount: JsonField = JsonMissing.of() private var multiplierFactor: JsonField = JsonMissing.of() private var reason: JsonField = JsonMissing.of() - private var reasonCode: JsonField = JsonMissing.of() + private var reasonCode: JsonField = JsonMissing.of() private var taxCode: JsonField = JsonMissing.of() private var taxRate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -279,20 +281,20 @@ private constructor( */ fun reason(reason: JsonField) = apply { this.reason = reason } - /** The code for the charge reason */ - fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) + /** Charge reason codes for invoice charges and fees */ + fun reasonCode(reasonCode: ReasonCode?) = reasonCode(JsonField.ofNullable(reasonCode)) /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ - fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) + fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) /** * Sets [Builder.reasonCode] to an arbitrary JSON value. * - * You should usually call [Builder.reasonCode] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. + * You should usually call [Builder.reasonCode] with a well-typed [ReasonCode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode } + fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode } /** * Duty or tax or fee category codes (Subset of UNCL5305) @@ -374,7 +376,7 @@ private constructor( baseAmount() multiplierFactor() reason() - reasonCode() + reasonCode().ifPresent { it.validate() } taxCode().ifPresent { it.validate() } taxRate() validated = true @@ -399,10 +401,1196 @@ private constructor( (if (baseAmount.asKnown().isPresent) 1 else 0) + (if (multiplierFactor.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) + - (if (reasonCode.asKnown().isPresent) 1 else 0) + + (reasonCode.asKnown().getOrNull()?.validity() ?: 0) + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + (if (taxRate.asKnown().isPresent) 1 else 0) + /** Charge reason codes for invoice charges and fees */ + class ReasonCode @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val AA = of("AA") + + @JvmField val AAA = of("AAA") + + @JvmField val AAC = of("AAC") + + @JvmField val AAD = of("AAD") + + @JvmField val AAE = of("AAE") + + @JvmField val AAF = of("AAF") + + @JvmField val AAH = of("AAH") + + @JvmField val AAI = of("AAI") + + @JvmField val AAS = of("AAS") + + @JvmField val AAT = of("AAT") + + @JvmField val AAV = of("AAV") + + @JvmField val AAY = of("AAY") + + @JvmField val AAZ = of("AAZ") + + @JvmField val ABA = of("ABA") + + @JvmField val ABB = of("ABB") + + @JvmField val ABC = of("ABC") + + @JvmField val ABD = of("ABD") + + @JvmField val ABF = of("ABF") + + @JvmField val ABK = of("ABK") + + @JvmField val ABL = of("ABL") + + @JvmField val ABN = of("ABN") + + @JvmField val ABR = of("ABR") + + @JvmField val ABS = of("ABS") + + @JvmField val ABT = of("ABT") + + @JvmField val ABU = of("ABU") + + @JvmField val ACF = of("ACF") + + @JvmField val ACG = of("ACG") + + @JvmField val ACH = of("ACH") + + @JvmField val ACI = of("ACI") + + @JvmField val ACJ = of("ACJ") + + @JvmField val ACK = of("ACK") + + @JvmField val ACL = of("ACL") + + @JvmField val ACM = of("ACM") + + @JvmField val ACS = of("ACS") + + @JvmField val ADC = of("ADC") + + @JvmField val ADE = of("ADE") + + @JvmField val ADJ = of("ADJ") + + @JvmField val ADK = of("ADK") + + @JvmField val ADL = of("ADL") + + @JvmField val ADM = of("ADM") + + @JvmField val ADN = of("ADN") + + @JvmField val ADO = of("ADO") + + @JvmField val ADP = of("ADP") + + @JvmField val ADQ = of("ADQ") + + @JvmField val ADR = of("ADR") + + @JvmField val ADT = of("ADT") + + @JvmField val ADW = of("ADW") + + @JvmField val ADY = of("ADY") + + @JvmField val ADZ = of("ADZ") + + @JvmField val AEA = of("AEA") + + @JvmField val AEB = of("AEB") + + @JvmField val AEC = of("AEC") + + @JvmField val AED = of("AED") + + @JvmField val AEF = of("AEF") + + @JvmField val AEH = of("AEH") + + @JvmField val AEI = of("AEI") + + @JvmField val AEJ = of("AEJ") + + @JvmField val AEK = of("AEK") + + @JvmField val AEL = of("AEL") + + @JvmField val AEM = of("AEM") + + @JvmField val AEN = of("AEN") + + @JvmField val AEO = of("AEO") + + @JvmField val AEP = of("AEP") + + @JvmField val AES = of("AES") + + @JvmField val AET = of("AET") + + @JvmField val AEU = of("AEU") + + @JvmField val AEV = of("AEV") + + @JvmField val AEW = of("AEW") + + @JvmField val AEX = of("AEX") + + @JvmField val AEY = of("AEY") + + @JvmField val AEZ = of("AEZ") + + @JvmField val AJ = of("AJ") + + @JvmField val AU = of("AU") + + @JvmField val CA = of("CA") + + @JvmField val CAB = of("CAB") + + @JvmField val CAD = of("CAD") + + @JvmField val CAE = of("CAE") + + @JvmField val CAF = of("CAF") + + @JvmField val CAI = of("CAI") + + @JvmField val CAJ = of("CAJ") + + @JvmField val CAK = of("CAK") + + @JvmField val CAL = of("CAL") + + @JvmField val CAM = of("CAM") + + @JvmField val CAN = of("CAN") + + @JvmField val CAO = of("CAO") + + @JvmField val CAP = of("CAP") + + @JvmField val CAQ = of("CAQ") + + @JvmField val CAR = of("CAR") + + @JvmField val CAS = of("CAS") + + @JvmField val CAT = of("CAT") + + @JvmField val CAU = of("CAU") + + @JvmField val CAV = of("CAV") + + @JvmField val CAW = of("CAW") + + @JvmField val CAX = of("CAX") + + @JvmField val CAY = of("CAY") + + @JvmField val CAZ = of("CAZ") + + @JvmField val CD = of("CD") + + @JvmField val CG = of("CG") + + @JvmField val CS = of("CS") + + @JvmField val CT = of("CT") + + @JvmField val DAB = of("DAB") + + @JvmField val DAC = of("DAC") + + @JvmField val DAD = of("DAD") + + @JvmField val DAF = of("DAF") + + @JvmField val DAG = of("DAG") + + @JvmField val DAH = of("DAH") + + @JvmField val DAI = of("DAI") + + @JvmField val DAJ = of("DAJ") + + @JvmField val DAK = of("DAK") + + @JvmField val DAL = of("DAL") + + @JvmField val DAM = of("DAM") + + @JvmField val DAN = of("DAN") + + @JvmField val DAO = of("DAO") + + @JvmField val DAP = of("DAP") + + @JvmField val DAQ = of("DAQ") + + @JvmField val DL = of("DL") + + @JvmField val EG = of("EG") + + @JvmField val EP = of("EP") + + @JvmField val ER = of("ER") + + @JvmField val FAA = of("FAA") + + @JvmField val FAB = of("FAB") + + @JvmField val FAC = of("FAC") + + @JvmField val FC = of("FC") + + @JvmField val FH = of("FH") + + @JvmField val FI = of("FI") + + @JvmField val GAA = of("GAA") + + @JvmField val HAA = of("HAA") + + @JvmField val HD = of("HD") + + @JvmField val HH = of("HH") + + @JvmField val IAA = of("IAA") + + @JvmField val IAB = of("IAB") + + @JvmField val ID = of("ID") + + @JvmField val IF = of("IF") + + @JvmField val IR = of("IR") + + @JvmField val IS = of("IS") + + @JvmField val KO = of("KO") + + @JvmField val L1 = of("L1") + + @JvmField val LA = of("LA") + + @JvmField val LAA = of("LAA") + + @JvmField val LAB = of("LAB") + + @JvmField val LF = of("LF") + + @JvmField val MAE = of("MAE") + + @JvmField val MI = of("MI") + + @JvmField val ML = of("ML") + + @JvmField val NAA = of("NAA") + + @JvmField val OA = of("OA") + + @JvmField val PA = of("PA") + + @JvmField val PAA = of("PAA") + + @JvmField val PC = of("PC") + + @JvmField val PL = of("PL") + + @JvmField val PRV = of("PRV") + + @JvmField val RAB = of("RAB") + + @JvmField val RAC = of("RAC") + + @JvmField val RAD = of("RAD") + + @JvmField val RAF = of("RAF") + + @JvmField val RE = of("RE") + + @JvmField val RF = of("RF") + + @JvmField val RH = of("RH") + + @JvmField val RV = of("RV") + + @JvmField val SA = of("SA") + + @JvmField val SAA = of("SAA") + + @JvmField val SAD = of("SAD") + + @JvmField val SAE = of("SAE") + + @JvmField val SAI = of("SAI") + + @JvmField val SG = of("SG") + + @JvmField val SH = of("SH") + + @JvmField val SM = of("SM") + + @JvmField val SU = of("SU") + + @JvmField val TAB = of("TAB") + + @JvmField val TAC = of("TAC") + + @JvmField val TT = of("TT") + + @JvmField val TV = of("TV") + + @JvmField val V1 = of("V1") + + @JvmField val V2 = of("V2") + + @JvmField val WH = of("WH") + + @JvmField val XAA = of("XAA") + + @JvmField val YY = of("YY") + + @JvmField val ZZZ = of("ZZZ") + + @JvmStatic fun of(value: String) = ReasonCode(JsonField.of(value)) + } + + /** An enum containing [ReasonCode]'s known values. */ + enum class Known { + AA, + AAA, + AAC, + AAD, + AAE, + AAF, + AAH, + AAI, + AAS, + AAT, + AAV, + AAY, + AAZ, + ABA, + ABB, + ABC, + ABD, + ABF, + ABK, + ABL, + ABN, + ABR, + ABS, + ABT, + ABU, + ACF, + ACG, + ACH, + ACI, + ACJ, + ACK, + ACL, + ACM, + ACS, + ADC, + ADE, + ADJ, + ADK, + ADL, + ADM, + ADN, + ADO, + ADP, + ADQ, + ADR, + ADT, + ADW, + ADY, + ADZ, + AEA, + AEB, + AEC, + AED, + AEF, + AEH, + AEI, + AEJ, + AEK, + AEL, + AEM, + AEN, + AEO, + AEP, + AES, + AET, + AEU, + AEV, + AEW, + AEX, + AEY, + AEZ, + AJ, + AU, + CA, + CAB, + CAD, + CAE, + CAF, + CAI, + CAJ, + CAK, + CAL, + CAM, + CAN, + CAO, + CAP, + CAQ, + CAR, + CAS, + CAT, + CAU, + CAV, + CAW, + CAX, + CAY, + CAZ, + CD, + CG, + CS, + CT, + DAB, + DAC, + DAD, + DAF, + DAG, + DAH, + DAI, + DAJ, + DAK, + DAL, + DAM, + DAN, + DAO, + DAP, + DAQ, + DL, + EG, + EP, + ER, + FAA, + FAB, + FAC, + FC, + FH, + FI, + GAA, + HAA, + HD, + HH, + IAA, + IAB, + ID, + IF, + IR, + IS, + KO, + L1, + LA, + LAA, + LAB, + LF, + MAE, + MI, + ML, + NAA, + OA, + PA, + PAA, + PC, + PL, + PRV, + RAB, + RAC, + RAD, + RAF, + RE, + RF, + RH, + RV, + SA, + SAA, + SAD, + SAE, + SAI, + SG, + SH, + SM, + SU, + TAB, + TAC, + TT, + TV, + V1, + V2, + WH, + XAA, + YY, + ZZZ, + } + + /** + * An enum containing [ReasonCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ReasonCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AA, + AAA, + AAC, + AAD, + AAE, + AAF, + AAH, + AAI, + AAS, + AAT, + AAV, + AAY, + AAZ, + ABA, + ABB, + ABC, + ABD, + ABF, + ABK, + ABL, + ABN, + ABR, + ABS, + ABT, + ABU, + ACF, + ACG, + ACH, + ACI, + ACJ, + ACK, + ACL, + ACM, + ACS, + ADC, + ADE, + ADJ, + ADK, + ADL, + ADM, + ADN, + ADO, + ADP, + ADQ, + ADR, + ADT, + ADW, + ADY, + ADZ, + AEA, + AEB, + AEC, + AED, + AEF, + AEH, + AEI, + AEJ, + AEK, + AEL, + AEM, + AEN, + AEO, + AEP, + AES, + AET, + AEU, + AEV, + AEW, + AEX, + AEY, + AEZ, + AJ, + AU, + CA, + CAB, + CAD, + CAE, + CAF, + CAI, + CAJ, + CAK, + CAL, + CAM, + CAN, + CAO, + CAP, + CAQ, + CAR, + CAS, + CAT, + CAU, + CAV, + CAW, + CAX, + CAY, + CAZ, + CD, + CG, + CS, + CT, + DAB, + DAC, + DAD, + DAF, + DAG, + DAH, + DAI, + DAJ, + DAK, + DAL, + DAM, + DAN, + DAO, + DAP, + DAQ, + DL, + EG, + EP, + ER, + FAA, + FAB, + FAC, + FC, + FH, + FI, + GAA, + HAA, + HD, + HH, + IAA, + IAB, + ID, + IF, + IR, + IS, + KO, + L1, + LA, + LAA, + LAB, + LF, + MAE, + MI, + ML, + NAA, + OA, + PA, + PAA, + PC, + PL, + PRV, + RAB, + RAC, + RAD, + RAF, + RE, + RF, + RH, + RV, + SA, + SAA, + SAD, + SAE, + SAI, + SG, + SH, + SM, + SU, + TAB, + TAC, + TT, + TV, + V1, + V2, + WH, + XAA, + YY, + ZZZ, + /** + * An enum member indicating that [ReasonCode] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AA -> Value.AA + AAA -> Value.AAA + AAC -> Value.AAC + AAD -> Value.AAD + AAE -> Value.AAE + AAF -> Value.AAF + AAH -> Value.AAH + AAI -> Value.AAI + AAS -> Value.AAS + AAT -> Value.AAT + AAV -> Value.AAV + AAY -> Value.AAY + AAZ -> Value.AAZ + ABA -> Value.ABA + ABB -> Value.ABB + ABC -> Value.ABC + ABD -> Value.ABD + ABF -> Value.ABF + ABK -> Value.ABK + ABL -> Value.ABL + ABN -> Value.ABN + ABR -> Value.ABR + ABS -> Value.ABS + ABT -> Value.ABT + ABU -> Value.ABU + ACF -> Value.ACF + ACG -> Value.ACG + ACH -> Value.ACH + ACI -> Value.ACI + ACJ -> Value.ACJ + ACK -> Value.ACK + ACL -> Value.ACL + ACM -> Value.ACM + ACS -> Value.ACS + ADC -> Value.ADC + ADE -> Value.ADE + ADJ -> Value.ADJ + ADK -> Value.ADK + ADL -> Value.ADL + ADM -> Value.ADM + ADN -> Value.ADN + ADO -> Value.ADO + ADP -> Value.ADP + ADQ -> Value.ADQ + ADR -> Value.ADR + ADT -> Value.ADT + ADW -> Value.ADW + ADY -> Value.ADY + ADZ -> Value.ADZ + AEA -> Value.AEA + AEB -> Value.AEB + AEC -> Value.AEC + AED -> Value.AED + AEF -> Value.AEF + AEH -> Value.AEH + AEI -> Value.AEI + AEJ -> Value.AEJ + AEK -> Value.AEK + AEL -> Value.AEL + AEM -> Value.AEM + AEN -> Value.AEN + AEO -> Value.AEO + AEP -> Value.AEP + AES -> Value.AES + AET -> Value.AET + AEU -> Value.AEU + AEV -> Value.AEV + AEW -> Value.AEW + AEX -> Value.AEX + AEY -> Value.AEY + AEZ -> Value.AEZ + AJ -> Value.AJ + AU -> Value.AU + CA -> Value.CA + CAB -> Value.CAB + CAD -> Value.CAD + CAE -> Value.CAE + CAF -> Value.CAF + CAI -> Value.CAI + CAJ -> Value.CAJ + CAK -> Value.CAK + CAL -> Value.CAL + CAM -> Value.CAM + CAN -> Value.CAN + CAO -> Value.CAO + CAP -> Value.CAP + CAQ -> Value.CAQ + CAR -> Value.CAR + CAS -> Value.CAS + CAT -> Value.CAT + CAU -> Value.CAU + CAV -> Value.CAV + CAW -> Value.CAW + CAX -> Value.CAX + CAY -> Value.CAY + CAZ -> Value.CAZ + CD -> Value.CD + CG -> Value.CG + CS -> Value.CS + CT -> Value.CT + DAB -> Value.DAB + DAC -> Value.DAC + DAD -> Value.DAD + DAF -> Value.DAF + DAG -> Value.DAG + DAH -> Value.DAH + DAI -> Value.DAI + DAJ -> Value.DAJ + DAK -> Value.DAK + DAL -> Value.DAL + DAM -> Value.DAM + DAN -> Value.DAN + DAO -> Value.DAO + DAP -> Value.DAP + DAQ -> Value.DAQ + DL -> Value.DL + EG -> Value.EG + EP -> Value.EP + ER -> Value.ER + FAA -> Value.FAA + FAB -> Value.FAB + FAC -> Value.FAC + FC -> Value.FC + FH -> Value.FH + FI -> Value.FI + GAA -> Value.GAA + HAA -> Value.HAA + HD -> Value.HD + HH -> Value.HH + IAA -> Value.IAA + IAB -> Value.IAB + ID -> Value.ID + IF -> Value.IF + IR -> Value.IR + IS -> Value.IS + KO -> Value.KO + L1 -> Value.L1 + LA -> Value.LA + LAA -> Value.LAA + LAB -> Value.LAB + LF -> Value.LF + MAE -> Value.MAE + MI -> Value.MI + ML -> Value.ML + NAA -> Value.NAA + OA -> Value.OA + PA -> Value.PA + PAA -> Value.PAA + PC -> Value.PC + PL -> Value.PL + PRV -> Value.PRV + RAB -> Value.RAB + RAC -> Value.RAC + RAD -> Value.RAD + RAF -> Value.RAF + RE -> Value.RE + RF -> Value.RF + RH -> Value.RH + RV -> Value.RV + SA -> Value.SA + SAA -> Value.SAA + SAD -> Value.SAD + SAE -> Value.SAE + SAI -> Value.SAI + SG -> Value.SG + SH -> Value.SH + SM -> Value.SM + SU -> Value.SU + TAB -> Value.TAB + TAC -> Value.TAC + TT -> Value.TT + TV -> Value.TV + V1 -> Value.V1 + V2 -> Value.V2 + WH -> Value.WH + XAA -> Value.XAA + YY -> Value.YY + ZZZ -> Value.ZZZ + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + AA -> Known.AA + AAA -> Known.AAA + AAC -> Known.AAC + AAD -> Known.AAD + AAE -> Known.AAE + AAF -> Known.AAF + AAH -> Known.AAH + AAI -> Known.AAI + AAS -> Known.AAS + AAT -> Known.AAT + AAV -> Known.AAV + AAY -> Known.AAY + AAZ -> Known.AAZ + ABA -> Known.ABA + ABB -> Known.ABB + ABC -> Known.ABC + ABD -> Known.ABD + ABF -> Known.ABF + ABK -> Known.ABK + ABL -> Known.ABL + ABN -> Known.ABN + ABR -> Known.ABR + ABS -> Known.ABS + ABT -> Known.ABT + ABU -> Known.ABU + ACF -> Known.ACF + ACG -> Known.ACG + ACH -> Known.ACH + ACI -> Known.ACI + ACJ -> Known.ACJ + ACK -> Known.ACK + ACL -> Known.ACL + ACM -> Known.ACM + ACS -> Known.ACS + ADC -> Known.ADC + ADE -> Known.ADE + ADJ -> Known.ADJ + ADK -> Known.ADK + ADL -> Known.ADL + ADM -> Known.ADM + ADN -> Known.ADN + ADO -> Known.ADO + ADP -> Known.ADP + ADQ -> Known.ADQ + ADR -> Known.ADR + ADT -> Known.ADT + ADW -> Known.ADW + ADY -> Known.ADY + ADZ -> Known.ADZ + AEA -> Known.AEA + AEB -> Known.AEB + AEC -> Known.AEC + AED -> Known.AED + AEF -> Known.AEF + AEH -> Known.AEH + AEI -> Known.AEI + AEJ -> Known.AEJ + AEK -> Known.AEK + AEL -> Known.AEL + AEM -> Known.AEM + AEN -> Known.AEN + AEO -> Known.AEO + AEP -> Known.AEP + AES -> Known.AES + AET -> Known.AET + AEU -> Known.AEU + AEV -> Known.AEV + AEW -> Known.AEW + AEX -> Known.AEX + AEY -> Known.AEY + AEZ -> Known.AEZ + AJ -> Known.AJ + AU -> Known.AU + CA -> Known.CA + CAB -> Known.CAB + CAD -> Known.CAD + CAE -> Known.CAE + CAF -> Known.CAF + CAI -> Known.CAI + CAJ -> Known.CAJ + CAK -> Known.CAK + CAL -> Known.CAL + CAM -> Known.CAM + CAN -> Known.CAN + CAO -> Known.CAO + CAP -> Known.CAP + CAQ -> Known.CAQ + CAR -> Known.CAR + CAS -> Known.CAS + CAT -> Known.CAT + CAU -> Known.CAU + CAV -> Known.CAV + CAW -> Known.CAW + CAX -> Known.CAX + CAY -> Known.CAY + CAZ -> Known.CAZ + CD -> Known.CD + CG -> Known.CG + CS -> Known.CS + CT -> Known.CT + DAB -> Known.DAB + DAC -> Known.DAC + DAD -> Known.DAD + DAF -> Known.DAF + DAG -> Known.DAG + DAH -> Known.DAH + DAI -> Known.DAI + DAJ -> Known.DAJ + DAK -> Known.DAK + DAL -> Known.DAL + DAM -> Known.DAM + DAN -> Known.DAN + DAO -> Known.DAO + DAP -> Known.DAP + DAQ -> Known.DAQ + DL -> Known.DL + EG -> Known.EG + EP -> Known.EP + ER -> Known.ER + FAA -> Known.FAA + FAB -> Known.FAB + FAC -> Known.FAC + FC -> Known.FC + FH -> Known.FH + FI -> Known.FI + GAA -> Known.GAA + HAA -> Known.HAA + HD -> Known.HD + HH -> Known.HH + IAA -> Known.IAA + IAB -> Known.IAB + ID -> Known.ID + IF -> Known.IF + IR -> Known.IR + IS -> Known.IS + KO -> Known.KO + L1 -> Known.L1 + LA -> Known.LA + LAA -> Known.LAA + LAB -> Known.LAB + LF -> Known.LF + MAE -> Known.MAE + MI -> Known.MI + ML -> Known.ML + NAA -> Known.NAA + OA -> Known.OA + PA -> Known.PA + PAA -> Known.PAA + PC -> Known.PC + PL -> Known.PL + PRV -> Known.PRV + RAB -> Known.RAB + RAC -> Known.RAC + RAD -> Known.RAD + RAF -> Known.RAF + RE -> Known.RE + RF -> Known.RF + RH -> Known.RH + RV -> Known.RV + SA -> Known.SA + SAA -> Known.SAA + SAD -> Known.SAD + SAE -> Known.SAE + SAI -> Known.SAI + SG -> Known.SG + SH -> Known.SH + SM -> Known.SM + SU -> Known.SU + TAB -> Known.TAB + TAC -> Known.TAC + TT -> Known.TT + TV -> Known.TV + V1 -> Known.V1 + V2 -> Known.V2 + WH -> Known.WH + XAA -> Known.XAA + YY -> Known.YY + ZZZ -> Known.ZZZ + else -> throw EInvoiceInvalidDataException("Unknown ReasonCode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReasonCode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReasonCode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + /** * Duty or tax or fee category codes (Subset of UNCL5305) * diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt index 5828329..af5a6d3 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt @@ -2369,9 +2369,9 @@ private constructor( private val baseAmount: JsonField, private val multiplierFactor: JsonField, private val reason: JsonField, - private val reasonCode: JsonField, + private val reasonCode: JsonField, private val taxCode: JsonField, - private val taxRate: JsonField, + private val taxRate: JsonField, private val additionalProperties: MutableMap, ) { @@ -2387,11 +2387,11 @@ private constructor( @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), @JsonProperty("reason_code") @ExcludeMissing - reasonCode: JsonField = JsonMissing.of(), + reasonCode: JsonField = JsonMissing.of(), @JsonProperty("tax_code") @ExcludeMissing taxCode: JsonField = JsonMissing.of(), - @JsonProperty("tax_rate") @ExcludeMissing taxRate: JsonField = JsonMissing.of(), + @JsonProperty("tax_rate") @ExcludeMissing taxRate: JsonField = JsonMissing.of(), ) : this( amount, baseAmount, @@ -2422,7 +2422,8 @@ private constructor( /** * The percentage that may be used, in conjunction with the allowance base amount, to - * calculate the allowance amount. To state 20%, use value 20 + * calculate the allowance amount. To state 20%, use value 20. Must be rounded to maximum 2 + * decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -2439,17 +2440,15 @@ private constructor( fun reason(): Optional = reason.getOptional("reason") /** - * The code for the allowance reason + * Allowance reason codes for invoice discounts and charges * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun reasonCode(): Optional = reasonCode.getOptional("reason_code") + fun reasonCode(): Optional = reasonCode.getOptional("reason_code") /** - * Duty or tax or fee category codes (Subset of UNCL5305) - * - * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + * The VAT category code that applies to the allowance * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -2457,12 +2456,13 @@ private constructor( fun taxCode(): Optional = taxCode.getOptional("tax_code") /** - * The VAT rate, represented as percentage that applies to the allowance + * The VAT rate, represented as percentage that applies to the allowance. Must be rounded to + * maximum 2 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun taxRate(): Optional = taxRate.getOptional("tax_rate") + fun taxRate(): Optional = taxRate.getOptional("tax_rate") /** * Returns the raw JSON value of [amount]. @@ -2504,7 +2504,7 @@ private constructor( */ @JsonProperty("reason_code") @ExcludeMissing - fun _reasonCode(): JsonField = reasonCode + fun _reasonCode(): JsonField = reasonCode /** * Returns the raw JSON value of [taxCode]. @@ -2518,7 +2518,7 @@ private constructor( * * Unlike [taxRate], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate + @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -2545,9 +2545,9 @@ private constructor( private var baseAmount: JsonField = JsonMissing.of() private var multiplierFactor: JsonField = JsonMissing.of() private var reason: JsonField = JsonMissing.of() - private var reasonCode: JsonField = JsonMissing.of() + private var reasonCode: JsonField = JsonMissing.of() private var taxCode: JsonField = JsonMissing.of() - private var taxRate: JsonField = JsonMissing.of() + private var taxRate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2611,7 +2611,8 @@ private constructor( /** * The percentage that may be used, in conjunction with the allowance base amount, to - * calculate the allowance amount. To state 20%, use value 20 + * calculate the allowance amount. To state 20%, use value 20. Must be rounded to + * maximum 2 decimals */ fun multiplierFactor(multiplierFactor: MultiplierFactor?) = multiplierFactor(JsonField.ofNullable(multiplierFactor)) @@ -2656,30 +2657,25 @@ private constructor( */ fun reason(reason: JsonField) = apply { this.reason = reason } - /** The code for the allowance reason */ - fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) + /** Allowance reason codes for invoice discounts and charges */ + fun reasonCode(reasonCode: ReasonCode?) = reasonCode(JsonField.ofNullable(reasonCode)) /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ - fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) + fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) /** * Sets [Builder.reasonCode] to an arbitrary JSON value. * - * You should usually call [Builder.reasonCode] with a well-typed [String] value + * You should usually call [Builder.reasonCode] with a well-typed [ReasonCode] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode } - - /** - * Duty or tax or fee category codes (Subset of UNCL5305) - * - * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL - */ - fun taxCode(taxCode: TaxCode?) = taxCode(JsonField.ofNullable(taxCode)) + fun reasonCode(reasonCode: JsonField) = apply { + this.reasonCode = reasonCode + } - /** Alias for calling [Builder.taxCode] with `taxCode.orElse(null)`. */ - fun taxCode(taxCode: Optional) = taxCode(taxCode.getOrNull()) + /** The VAT category code that applies to the allowance */ + fun taxCode(taxCode: TaxCode) = taxCode(JsonField.of(taxCode)) /** * Sets [Builder.taxCode] to an arbitrary JSON value. @@ -2690,20 +2686,29 @@ private constructor( */ fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } - /** The VAT rate, represented as percentage that applies to the allowance */ - fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) + /** + * The VAT rate, represented as percentage that applies to the allowance. Must be + * rounded to maximum 2 decimals + */ + fun taxRate(taxRate: TaxRate?) = taxRate(JsonField.ofNullable(taxRate)) /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ - fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) + fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) /** * Sets [Builder.taxRate] to an arbitrary JSON value. * - * You should usually call [Builder.taxRate] with a well-typed [String] value instead. + * You should usually call [Builder.taxRate] with a well-typed [TaxRate] value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } + fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } + + /** Alias for calling [taxRate] with `TaxRate.ofNumber(number)`. */ + fun taxRate(number: Double) = taxRate(TaxRate.ofNumber(number)) + + /** Alias for calling [taxRate] with `TaxRate.ofString(string)`. */ + fun taxRate(string: String) = taxRate(TaxRate.ofString(string)) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2753,9 +2758,9 @@ private constructor( baseAmount().ifPresent { it.validate() } multiplierFactor().ifPresent { it.validate() } reason() - reasonCode() + reasonCode().ifPresent { it.validate() } taxCode().ifPresent { it.validate() } - taxRate() + taxRate().ifPresent { it.validate() } validated = true } @@ -2779,9 +2784,9 @@ private constructor( (baseAmount.asKnown().getOrNull()?.validity() ?: 0) + (multiplierFactor.asKnown().getOrNull()?.validity() ?: 0) + (if (reason.asKnown().isPresent) 1 else 0) + - (if (reasonCode.asKnown().isPresent) 1 else 0) + + (reasonCode.asKnown().getOrNull()?.validity() ?: 0) + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + - (if (taxRate.asKnown().isPresent) 1 else 0) + (taxRate.asKnown().getOrNull()?.validity() ?: 0) /** The allowance amount, without VAT. Must be rounded to maximum 2 decimals */ @JsonDeserialize(using = Amount.Deserializer::class) @@ -3129,7 +3134,8 @@ private constructor( /** * The percentage that may be used, in conjunction with the allowance base amount, to - * calculate the allowance amount. To state 20%, use value 20 + * calculate the allowance amount. To state 20%, use value 20. Must be rounded to maximum 2 + * decimals */ @JsonDeserialize(using = MultiplierFactor.Deserializer::class) @JsonSerialize(using = MultiplierFactor.Serializer::class) @@ -3302,11 +3308,241 @@ private constructor( } } - /** - * Duty or tax or fee category codes (Subset of UNCL5305) - * - * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL - */ + /** Allowance reason codes for invoice discounts and charges */ + class ReasonCode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val _41 = of("41") + + @JvmField val _42 = of("42") + + @JvmField val _60 = of("60") + + @JvmField val _62 = of("62") + + @JvmField val _63 = of("63") + + @JvmField val _64 = of("64") + + @JvmField val _65 = of("65") + + @JvmField val _66 = of("66") + + @JvmField val _67 = of("67") + + @JvmField val _68 = of("68") + + @JvmField val _70 = of("70") + + @JvmField val _71 = of("71") + + @JvmField val _88 = of("88") + + @JvmField val _95 = of("95") + + @JvmField val _100 = of("100") + + @JvmField val _102 = of("102") + + @JvmField val _103 = of("103") + + @JvmField val _104 = of("104") + + @JvmField val _105 = of("105") + + @JvmStatic fun of(value: String) = ReasonCode(JsonField.of(value)) + } + + /** An enum containing [ReasonCode]'s known values. */ + enum class Known { + _41, + _42, + _60, + _62, + _63, + _64, + _65, + _66, + _67, + _68, + _70, + _71, + _88, + _95, + _100, + _102, + _103, + _104, + _105, + } + + /** + * An enum containing [ReasonCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ReasonCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + _41, + _42, + _60, + _62, + _63, + _64, + _65, + _66, + _67, + _68, + _70, + _71, + _88, + _95, + _100, + _102, + _103, + _104, + _105, + /** + * An enum member indicating that [ReasonCode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + _41 -> Value._41 + _42 -> Value._42 + _60 -> Value._60 + _62 -> Value._62 + _63 -> Value._63 + _64 -> Value._64 + _65 -> Value._65 + _66 -> Value._66 + _67 -> Value._67 + _68 -> Value._68 + _70 -> Value._70 + _71 -> Value._71 + _88 -> Value._88 + _95 -> Value._95 + _100 -> Value._100 + _102 -> Value._102 + _103 -> Value._103 + _104 -> Value._104 + _105 -> Value._105 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + _41 -> Known._41 + _42 -> Known._42 + _60 -> Known._60 + _62 -> Known._62 + _63 -> Known._63 + _64 -> Known._64 + _65 -> Known._65 + _66 -> Known._66 + _67 -> Known._67 + _68 -> Known._68 + _70 -> Known._70 + _71 -> Known._71 + _88 -> Known._88 + _95 -> Known._95 + _100 -> Known._100 + _102 -> Known._102 + _103 -> Known._103 + _104 -> Known._104 + _105 -> Known._105 + else -> throw EInvoiceInvalidDataException("Unknown ReasonCode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReasonCode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReasonCode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The VAT category code that applies to the allowance */ class TaxCode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3485,88 +3721,262 @@ private constructor( override fun toString() = value.toString() } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Allowance && - amount == other.amount && - baseAmount == other.baseAmount && - multiplierFactor == other.multiplierFactor && - reason == other.reason && - reasonCode == other.reasonCode && - taxCode == other.taxCode && - taxRate == other.taxRate && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - amount, - baseAmount, - multiplierFactor, - reason, - reasonCode, - taxCode, - taxRate, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode + /** + * The VAT rate, represented as percentage that applies to the allowance. Must be rounded to + * maximum 2 decimals + */ + @JsonDeserialize(using = TaxRate.Deserializer::class) + @JsonSerialize(using = TaxRate.Serializer::class) + class TaxRate + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { - override fun toString() = - "Allowance{amount=$amount, baseAmount=$baseAmount, multiplierFactor=$multiplierFactor, reason=$reason, reasonCode=$reasonCode, taxCode=$taxCode, taxRate=$taxRate, additionalProperties=$additionalProperties}" - } + fun number(): Optional = Optional.ofNullable(number) - /** The amount due for payment. Must be positive and rounded to maximum 2 decimals */ - @JsonDeserialize(using = AmountDue.Deserializer::class) - @JsonSerialize(using = AmountDue.Serializer::class) - class AmountDue - private constructor( - private val number: Double? = null, - private val string: String? = null, - private val _json: JsonValue? = null, - ) { + fun string(): Optional = Optional.ofNullable(string) - fun number(): Optional = Optional.ofNullable(number) + fun isNumber(): Boolean = number != null - fun string(): Optional = Optional.ofNullable(string) + fun isString(): Boolean = string != null - fun isNumber(): Boolean = number != null + fun asNumber(): Double = number.getOrThrow("number") - fun isString(): Boolean = string != null + fun asString(): String = string.getOrThrow("string") - fun asNumber(): Double = number.getOrThrow("number") + fun _json(): Optional = Optional.ofNullable(_json) - fun asString(): String = string.getOrThrow("string") + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } - fun _json(): Optional = Optional.ofNullable(_json) + private var validated: Boolean = false - fun accept(visitor: Visitor): T = - when { - number != null -> visitor.visitNumber(number) - string != null -> visitor.visitString(string) - else -> visitor.unknown(_json) - } + fun validate(): TaxRate = apply { + if (validated) { + return@apply + } - private var validated: Boolean = false + accept( + object : Visitor { + override fun visitNumber(number: Double) {} - fun validate(): AmountDue = apply { - if (validated) { - return@apply + override fun visitString(string: String) {} + } + ) + validated = true } - accept( - object : Visitor { - override fun visitNumber(number: Double) {} - - override fun visitString(string: String) {} + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false } - ) - validated = true - } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TaxRate && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "TaxRate{number=$number}" + string != null -> "TaxRate{string=$string}" + _json != null -> "TaxRate{_unknown=$_json}" + else -> throw IllegalStateException("Invalid TaxRate") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = TaxRate(number = number) + + @JvmStatic fun ofString(string: String) = TaxRate(string = string) + } + + /** + * An interface that defines how to map each variant of [TaxRate] to a value of type + * [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [TaxRate] to a value of type [T]. + * + * An instance of [TaxRate] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws EInvoiceInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw EInvoiceInvalidDataException("Unknown TaxRate: $json") + } + } + + internal class Deserializer : BaseDeserializer(TaxRate::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): TaxRate { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + TaxRate(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + TaxRate(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> TaxRate(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(TaxRate::class) { + + override fun serialize( + value: TaxRate, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid TaxRate") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Allowance && + amount == other.amount && + baseAmount == other.baseAmount && + multiplierFactor == other.multiplierFactor && + reason == other.reason && + reasonCode == other.reasonCode && + taxCode == other.taxCode && + taxRate == other.taxRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Allowance{amount=$amount, baseAmount=$baseAmount, multiplierFactor=$multiplierFactor, reason=$reason, reasonCode=$reasonCode, taxCode=$taxCode, taxRate=$taxRate, additionalProperties=$additionalProperties}" + } + + /** The amount due for payment. Must be positive and rounded to maximum 2 decimals */ + @JsonDeserialize(using = AmountDue.Deserializer::class) + @JsonSerialize(using = AmountDue.Serializer::class) + class AmountDue + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): AmountDue = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } fun isValid(): Boolean = try { @@ -3698,9 +4108,9 @@ private constructor( private val baseAmount: JsonField, private val multiplierFactor: JsonField, private val reason: JsonField, - private val reasonCode: JsonField, + private val reasonCode: JsonField, private val taxCode: JsonField, - private val taxRate: JsonField, + private val taxRate: JsonField, private val additionalProperties: MutableMap, ) { @@ -3716,11 +4126,11 @@ private constructor( @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), @JsonProperty("reason_code") @ExcludeMissing - reasonCode: JsonField = JsonMissing.of(), + reasonCode: JsonField = JsonMissing.of(), @JsonProperty("tax_code") @ExcludeMissing taxCode: JsonField = JsonMissing.of(), - @JsonProperty("tax_rate") @ExcludeMissing taxRate: JsonField = JsonMissing.of(), + @JsonProperty("tax_rate") @ExcludeMissing taxRate: JsonField = JsonMissing.of(), ) : this( amount, baseAmount, @@ -3768,12 +4178,12 @@ private constructor( fun reason(): Optional = reason.getOptional("reason") /** - * The code for the charge reason + * Charge reason codes for invoice charges and fees * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun reasonCode(): Optional = reasonCode.getOptional("reason_code") + fun reasonCode(): Optional = reasonCode.getOptional("reason_code") /** * Duty or tax or fee category codes (Subset of UNCL5305) @@ -3791,7 +4201,7 @@ private constructor( * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun taxRate(): Optional = taxRate.getOptional("tax_rate") + fun taxRate(): Optional = taxRate.getOptional("tax_rate") /** * Returns the raw JSON value of [amount]. @@ -3833,7 +4243,7 @@ private constructor( */ @JsonProperty("reason_code") @ExcludeMissing - fun _reasonCode(): JsonField = reasonCode + fun _reasonCode(): JsonField = reasonCode /** * Returns the raw JSON value of [taxCode]. @@ -3847,7 +4257,7 @@ private constructor( * * Unlike [taxRate], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate + @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -3874,9 +4284,9 @@ private constructor( private var baseAmount: JsonField = JsonMissing.of() private var multiplierFactor: JsonField = JsonMissing.of() private var reason: JsonField = JsonMissing.of() - private var reasonCode: JsonField = JsonMissing.of() + private var reasonCode: JsonField = JsonMissing.of() private var taxCode: JsonField = JsonMissing.of() - private var taxRate: JsonField = JsonMissing.of() + private var taxRate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3985,20 +4395,22 @@ private constructor( */ fun reason(reason: JsonField) = apply { this.reason = reason } - /** The code for the charge reason */ - fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) + /** Charge reason codes for invoice charges and fees */ + fun reasonCode(reasonCode: ReasonCode?) = reasonCode(JsonField.ofNullable(reasonCode)) /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ - fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) + fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) /** * Sets [Builder.reasonCode] to an arbitrary JSON value. * - * You should usually call [Builder.reasonCode] with a well-typed [String] value + * You should usually call [Builder.reasonCode] with a well-typed [ReasonCode] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode } + fun reasonCode(reasonCode: JsonField) = apply { + this.reasonCode = reasonCode + } /** * Duty or tax or fee category codes (Subset of UNCL5305) @@ -4020,19 +4432,25 @@ private constructor( fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } /** The VAT rate, represented as percentage that applies to the charge */ - fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) + fun taxRate(taxRate: TaxRate?) = taxRate(JsonField.ofNullable(taxRate)) /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ - fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) + fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) /** * Sets [Builder.taxRate] to an arbitrary JSON value. * - * You should usually call [Builder.taxRate] with a well-typed [String] value instead. + * You should usually call [Builder.taxRate] with a well-typed [TaxRate] value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } + fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } + + /** Alias for calling [taxRate] with `TaxRate.ofNumber(number)`. */ + fun taxRate(number: Double) = taxRate(TaxRate.ofNumber(number)) + + /** Alias for calling [taxRate] with `TaxRate.ofString(string)`. */ + fun taxRate(string: String) = taxRate(TaxRate.ofString(string)) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -4082,9 +4500,9 @@ private constructor( baseAmount().ifPresent { it.validate() } multiplierFactor().ifPresent { it.validate() } reason() - reasonCode() + reasonCode().ifPresent { it.validate() } taxCode().ifPresent { it.validate() } - taxRate() + taxRate().ifPresent { it.validate() } validated = true } @@ -4108,9 +4526,9 @@ private constructor( (baseAmount.asKnown().getOrNull()?.validity() ?: 0) + (multiplierFactor.asKnown().getOrNull()?.validity() ?: 0) + (if (reason.asKnown().isPresent) 1 else 0) + - (if (reasonCode.asKnown().isPresent) 1 else 0) + + (reasonCode.asKnown().getOrNull()?.validity() ?: 0) + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + - (if (taxRate.asKnown().isPresent) 1 else 0) + (taxRate.asKnown().getOrNull()?.validity() ?: 0) /** The charge amount, without VAT. Must be rounded to maximum 2 decimals */ @JsonDeserialize(using = Amount.Deserializer::class) @@ -4631,12 +5049,8 @@ private constructor( } } - /** - * Duty or tax or fee category codes (Subset of UNCL5305) - * - * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL - */ - class TaxCode @JsonCreator private constructor(private val value: JsonField) : + /** Charge reason codes for invoice charges and fees */ + class ReasonCode @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -4651,88 +5065,929 @@ private constructor( companion object { - @JvmField val AE = of("AE") + @JvmField val AA = of("AA") - @JvmField val E = of("E") + @JvmField val AAA = of("AAA") - @JvmField val S = of("S") + @JvmField val AAC = of("AAC") - @JvmField val Z = of("Z") + @JvmField val AAD = of("AAD") - @JvmField val G = of("G") + @JvmField val AAE = of("AAE") - @JvmField val O = of("O") + @JvmField val AAF = of("AAF") - @JvmField val K = of("K") + @JvmField val AAH = of("AAH") - @JvmField val L = of("L") + @JvmField val AAI = of("AAI") - @JvmField val M = of("M") + @JvmField val AAS = of("AAS") - @JvmField val B = of("B") + @JvmField val AAT = of("AAT") - @JvmStatic fun of(value: String) = TaxCode(JsonField.of(value)) - } + @JvmField val AAV = of("AAV") - /** An enum containing [TaxCode]'s known values. */ - enum class Known { - AE, - E, - S, - Z, - G, - O, - K, - L, - M, - B, - } + @JvmField val AAY = of("AAY") - /** - * An enum containing [TaxCode]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [TaxCode] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AE, - E, - S, - Z, - G, - O, - K, - L, - M, - B, - /** - * An enum member indicating that [TaxCode] was instantiated with an unknown value. - */ - _UNKNOWN, - } + @JvmField val AAZ = of("AAZ") - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AE -> Value.AE - E -> Value.E - S -> Value.S - Z -> Value.Z - G -> Value.G - O -> Value.O - K -> Value.K - L -> Value.L - M -> Value.M - B -> Value.B + @JvmField val ABA = of("ABA") + + @JvmField val ABB = of("ABB") + + @JvmField val ABC = of("ABC") + + @JvmField val ABD = of("ABD") + + @JvmField val ABF = of("ABF") + + @JvmField val ABK = of("ABK") + + @JvmField val ABL = of("ABL") + + @JvmField val ABN = of("ABN") + + @JvmField val ABR = of("ABR") + + @JvmField val ABS = of("ABS") + + @JvmField val ABT = of("ABT") + + @JvmField val ABU = of("ABU") + + @JvmField val ACF = of("ACF") + + @JvmField val ACG = of("ACG") + + @JvmField val ACH = of("ACH") + + @JvmField val ACI = of("ACI") + + @JvmField val ACJ = of("ACJ") + + @JvmField val ACK = of("ACK") + + @JvmField val ACL = of("ACL") + + @JvmField val ACM = of("ACM") + + @JvmField val ACS = of("ACS") + + @JvmField val ADC = of("ADC") + + @JvmField val ADE = of("ADE") + + @JvmField val ADJ = of("ADJ") + + @JvmField val ADK = of("ADK") + + @JvmField val ADL = of("ADL") + + @JvmField val ADM = of("ADM") + + @JvmField val ADN = of("ADN") + + @JvmField val ADO = of("ADO") + + @JvmField val ADP = of("ADP") + + @JvmField val ADQ = of("ADQ") + + @JvmField val ADR = of("ADR") + + @JvmField val ADT = of("ADT") + + @JvmField val ADW = of("ADW") + + @JvmField val ADY = of("ADY") + + @JvmField val ADZ = of("ADZ") + + @JvmField val AEA = of("AEA") + + @JvmField val AEB = of("AEB") + + @JvmField val AEC = of("AEC") + + @JvmField val AED = of("AED") + + @JvmField val AEF = of("AEF") + + @JvmField val AEH = of("AEH") + + @JvmField val AEI = of("AEI") + + @JvmField val AEJ = of("AEJ") + + @JvmField val AEK = of("AEK") + + @JvmField val AEL = of("AEL") + + @JvmField val AEM = of("AEM") + + @JvmField val AEN = of("AEN") + + @JvmField val AEO = of("AEO") + + @JvmField val AEP = of("AEP") + + @JvmField val AES = of("AES") + + @JvmField val AET = of("AET") + + @JvmField val AEU = of("AEU") + + @JvmField val AEV = of("AEV") + + @JvmField val AEW = of("AEW") + + @JvmField val AEX = of("AEX") + + @JvmField val AEY = of("AEY") + + @JvmField val AEZ = of("AEZ") + + @JvmField val AJ = of("AJ") + + @JvmField val AU = of("AU") + + @JvmField val CA = of("CA") + + @JvmField val CAB = of("CAB") + + @JvmField val CAD = of("CAD") + + @JvmField val CAE = of("CAE") + + @JvmField val CAF = of("CAF") + + @JvmField val CAI = of("CAI") + + @JvmField val CAJ = of("CAJ") + + @JvmField val CAK = of("CAK") + + @JvmField val CAL = of("CAL") + + @JvmField val CAM = of("CAM") + + @JvmField val CAN = of("CAN") + + @JvmField val CAO = of("CAO") + + @JvmField val CAP = of("CAP") + + @JvmField val CAQ = of("CAQ") + + @JvmField val CAR = of("CAR") + + @JvmField val CAS = of("CAS") + + @JvmField val CAT = of("CAT") + + @JvmField val CAU = of("CAU") + + @JvmField val CAV = of("CAV") + + @JvmField val CAW = of("CAW") + + @JvmField val CAX = of("CAX") + + @JvmField val CAY = of("CAY") + + @JvmField val CAZ = of("CAZ") + + @JvmField val CD = of("CD") + + @JvmField val CG = of("CG") + + @JvmField val CS = of("CS") + + @JvmField val CT = of("CT") + + @JvmField val DAB = of("DAB") + + @JvmField val DAC = of("DAC") + + @JvmField val DAD = of("DAD") + + @JvmField val DAF = of("DAF") + + @JvmField val DAG = of("DAG") + + @JvmField val DAH = of("DAH") + + @JvmField val DAI = of("DAI") + + @JvmField val DAJ = of("DAJ") + + @JvmField val DAK = of("DAK") + + @JvmField val DAL = of("DAL") + + @JvmField val DAM = of("DAM") + + @JvmField val DAN = of("DAN") + + @JvmField val DAO = of("DAO") + + @JvmField val DAP = of("DAP") + + @JvmField val DAQ = of("DAQ") + + @JvmField val DL = of("DL") + + @JvmField val EG = of("EG") + + @JvmField val EP = of("EP") + + @JvmField val ER = of("ER") + + @JvmField val FAA = of("FAA") + + @JvmField val FAB = of("FAB") + + @JvmField val FAC = of("FAC") + + @JvmField val FC = of("FC") + + @JvmField val FH = of("FH") + + @JvmField val FI = of("FI") + + @JvmField val GAA = of("GAA") + + @JvmField val HAA = of("HAA") + + @JvmField val HD = of("HD") + + @JvmField val HH = of("HH") + + @JvmField val IAA = of("IAA") + + @JvmField val IAB = of("IAB") + + @JvmField val ID = of("ID") + + @JvmField val IF = of("IF") + + @JvmField val IR = of("IR") + + @JvmField val IS = of("IS") + + @JvmField val KO = of("KO") + + @JvmField val L1 = of("L1") + + @JvmField val LA = of("LA") + + @JvmField val LAA = of("LAA") + + @JvmField val LAB = of("LAB") + + @JvmField val LF = of("LF") + + @JvmField val MAE = of("MAE") + + @JvmField val MI = of("MI") + + @JvmField val ML = of("ML") + + @JvmField val NAA = of("NAA") + + @JvmField val OA = of("OA") + + @JvmField val PA = of("PA") + + @JvmField val PAA = of("PAA") + + @JvmField val PC = of("PC") + + @JvmField val PL = of("PL") + + @JvmField val PRV = of("PRV") + + @JvmField val RAB = of("RAB") + + @JvmField val RAC = of("RAC") + + @JvmField val RAD = of("RAD") + + @JvmField val RAF = of("RAF") + + @JvmField val RE = of("RE") + + @JvmField val RF = of("RF") + + @JvmField val RH = of("RH") + + @JvmField val RV = of("RV") + + @JvmField val SA = of("SA") + + @JvmField val SAA = of("SAA") + + @JvmField val SAD = of("SAD") + + @JvmField val SAE = of("SAE") + + @JvmField val SAI = of("SAI") + + @JvmField val SG = of("SG") + + @JvmField val SH = of("SH") + + @JvmField val SM = of("SM") + + @JvmField val SU = of("SU") + + @JvmField val TAB = of("TAB") + + @JvmField val TAC = of("TAC") + + @JvmField val TT = of("TT") + + @JvmField val TV = of("TV") + + @JvmField val V1 = of("V1") + + @JvmField val V2 = of("V2") + + @JvmField val WH = of("WH") + + @JvmField val XAA = of("XAA") + + @JvmField val YY = of("YY") + + @JvmField val ZZZ = of("ZZZ") + + @JvmStatic fun of(value: String) = ReasonCode(JsonField.of(value)) + } + + /** An enum containing [ReasonCode]'s known values. */ + enum class Known { + AA, + AAA, + AAC, + AAD, + AAE, + AAF, + AAH, + AAI, + AAS, + AAT, + AAV, + AAY, + AAZ, + ABA, + ABB, + ABC, + ABD, + ABF, + ABK, + ABL, + ABN, + ABR, + ABS, + ABT, + ABU, + ACF, + ACG, + ACH, + ACI, + ACJ, + ACK, + ACL, + ACM, + ACS, + ADC, + ADE, + ADJ, + ADK, + ADL, + ADM, + ADN, + ADO, + ADP, + ADQ, + ADR, + ADT, + ADW, + ADY, + ADZ, + AEA, + AEB, + AEC, + AED, + AEF, + AEH, + AEI, + AEJ, + AEK, + AEL, + AEM, + AEN, + AEO, + AEP, + AES, + AET, + AEU, + AEV, + AEW, + AEX, + AEY, + AEZ, + AJ, + AU, + CA, + CAB, + CAD, + CAE, + CAF, + CAI, + CAJ, + CAK, + CAL, + CAM, + CAN, + CAO, + CAP, + CAQ, + CAR, + CAS, + CAT, + CAU, + CAV, + CAW, + CAX, + CAY, + CAZ, + CD, + CG, + CS, + CT, + DAB, + DAC, + DAD, + DAF, + DAG, + DAH, + DAI, + DAJ, + DAK, + DAL, + DAM, + DAN, + DAO, + DAP, + DAQ, + DL, + EG, + EP, + ER, + FAA, + FAB, + FAC, + FC, + FH, + FI, + GAA, + HAA, + HD, + HH, + IAA, + IAB, + ID, + IF, + IR, + IS, + KO, + L1, + LA, + LAA, + LAB, + LF, + MAE, + MI, + ML, + NAA, + OA, + PA, + PAA, + PC, + PL, + PRV, + RAB, + RAC, + RAD, + RAF, + RE, + RF, + RH, + RV, + SA, + SAA, + SAD, + SAE, + SAI, + SG, + SH, + SM, + SU, + TAB, + TAC, + TT, + TV, + V1, + V2, + WH, + XAA, + YY, + ZZZ, + } + + /** + * An enum containing [ReasonCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ReasonCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AA, + AAA, + AAC, + AAD, + AAE, + AAF, + AAH, + AAI, + AAS, + AAT, + AAV, + AAY, + AAZ, + ABA, + ABB, + ABC, + ABD, + ABF, + ABK, + ABL, + ABN, + ABR, + ABS, + ABT, + ABU, + ACF, + ACG, + ACH, + ACI, + ACJ, + ACK, + ACL, + ACM, + ACS, + ADC, + ADE, + ADJ, + ADK, + ADL, + ADM, + ADN, + ADO, + ADP, + ADQ, + ADR, + ADT, + ADW, + ADY, + ADZ, + AEA, + AEB, + AEC, + AED, + AEF, + AEH, + AEI, + AEJ, + AEK, + AEL, + AEM, + AEN, + AEO, + AEP, + AES, + AET, + AEU, + AEV, + AEW, + AEX, + AEY, + AEZ, + AJ, + AU, + CA, + CAB, + CAD, + CAE, + CAF, + CAI, + CAJ, + CAK, + CAL, + CAM, + CAN, + CAO, + CAP, + CAQ, + CAR, + CAS, + CAT, + CAU, + CAV, + CAW, + CAX, + CAY, + CAZ, + CD, + CG, + CS, + CT, + DAB, + DAC, + DAD, + DAF, + DAG, + DAH, + DAI, + DAJ, + DAK, + DAL, + DAM, + DAN, + DAO, + DAP, + DAQ, + DL, + EG, + EP, + ER, + FAA, + FAB, + FAC, + FC, + FH, + FI, + GAA, + HAA, + HD, + HH, + IAA, + IAB, + ID, + IF, + IR, + IS, + KO, + L1, + LA, + LAA, + LAB, + LF, + MAE, + MI, + ML, + NAA, + OA, + PA, + PAA, + PC, + PL, + PRV, + RAB, + RAC, + RAD, + RAF, + RE, + RF, + RH, + RV, + SA, + SAA, + SAD, + SAE, + SAI, + SG, + SH, + SM, + SU, + TAB, + TAC, + TT, + TV, + V1, + V2, + WH, + XAA, + YY, + ZZZ, + /** + * An enum member indicating that [ReasonCode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AA -> Value.AA + AAA -> Value.AAA + AAC -> Value.AAC + AAD -> Value.AAD + AAE -> Value.AAE + AAF -> Value.AAF + AAH -> Value.AAH + AAI -> Value.AAI + AAS -> Value.AAS + AAT -> Value.AAT + AAV -> Value.AAV + AAY -> Value.AAY + AAZ -> Value.AAZ + ABA -> Value.ABA + ABB -> Value.ABB + ABC -> Value.ABC + ABD -> Value.ABD + ABF -> Value.ABF + ABK -> Value.ABK + ABL -> Value.ABL + ABN -> Value.ABN + ABR -> Value.ABR + ABS -> Value.ABS + ABT -> Value.ABT + ABU -> Value.ABU + ACF -> Value.ACF + ACG -> Value.ACG + ACH -> Value.ACH + ACI -> Value.ACI + ACJ -> Value.ACJ + ACK -> Value.ACK + ACL -> Value.ACL + ACM -> Value.ACM + ACS -> Value.ACS + ADC -> Value.ADC + ADE -> Value.ADE + ADJ -> Value.ADJ + ADK -> Value.ADK + ADL -> Value.ADL + ADM -> Value.ADM + ADN -> Value.ADN + ADO -> Value.ADO + ADP -> Value.ADP + ADQ -> Value.ADQ + ADR -> Value.ADR + ADT -> Value.ADT + ADW -> Value.ADW + ADY -> Value.ADY + ADZ -> Value.ADZ + AEA -> Value.AEA + AEB -> Value.AEB + AEC -> Value.AEC + AED -> Value.AED + AEF -> Value.AEF + AEH -> Value.AEH + AEI -> Value.AEI + AEJ -> Value.AEJ + AEK -> Value.AEK + AEL -> Value.AEL + AEM -> Value.AEM + AEN -> Value.AEN + AEO -> Value.AEO + AEP -> Value.AEP + AES -> Value.AES + AET -> Value.AET + AEU -> Value.AEU + AEV -> Value.AEV + AEW -> Value.AEW + AEX -> Value.AEX + AEY -> Value.AEY + AEZ -> Value.AEZ + AJ -> Value.AJ + AU -> Value.AU + CA -> Value.CA + CAB -> Value.CAB + CAD -> Value.CAD + CAE -> Value.CAE + CAF -> Value.CAF + CAI -> Value.CAI + CAJ -> Value.CAJ + CAK -> Value.CAK + CAL -> Value.CAL + CAM -> Value.CAM + CAN -> Value.CAN + CAO -> Value.CAO + CAP -> Value.CAP + CAQ -> Value.CAQ + CAR -> Value.CAR + CAS -> Value.CAS + CAT -> Value.CAT + CAU -> Value.CAU + CAV -> Value.CAV + CAW -> Value.CAW + CAX -> Value.CAX + CAY -> Value.CAY + CAZ -> Value.CAZ + CD -> Value.CD + CG -> Value.CG + CS -> Value.CS + CT -> Value.CT + DAB -> Value.DAB + DAC -> Value.DAC + DAD -> Value.DAD + DAF -> Value.DAF + DAG -> Value.DAG + DAH -> Value.DAH + DAI -> Value.DAI + DAJ -> Value.DAJ + DAK -> Value.DAK + DAL -> Value.DAL + DAM -> Value.DAM + DAN -> Value.DAN + DAO -> Value.DAO + DAP -> Value.DAP + DAQ -> Value.DAQ + DL -> Value.DL + EG -> Value.EG + EP -> Value.EP + ER -> Value.ER + FAA -> Value.FAA + FAB -> Value.FAB + FAC -> Value.FAC + FC -> Value.FC + FH -> Value.FH + FI -> Value.FI + GAA -> Value.GAA + HAA -> Value.HAA + HD -> Value.HD + HH -> Value.HH + IAA -> Value.IAA + IAB -> Value.IAB + ID -> Value.ID + IF -> Value.IF + IR -> Value.IR + IS -> Value.IS + KO -> Value.KO + L1 -> Value.L1 + LA -> Value.LA + LAA -> Value.LAA + LAB -> Value.LAB + LF -> Value.LF + MAE -> Value.MAE + MI -> Value.MI + ML -> Value.ML + NAA -> Value.NAA + OA -> Value.OA + PA -> Value.PA + PAA -> Value.PAA + PC -> Value.PC + PL -> Value.PL + PRV -> Value.PRV + RAB -> Value.RAB + RAC -> Value.RAC + RAD -> Value.RAD + RAF -> Value.RAF + RE -> Value.RE + RF -> Value.RF + RH -> Value.RH + RV -> Value.RV + SA -> Value.SA + SAA -> Value.SAA + SAD -> Value.SAD + SAE -> Value.SAE + SAI -> Value.SAI + SG -> Value.SG + SH -> Value.SH + SM -> Value.SM + SU -> Value.SU + TAB -> Value.TAB + TAC -> Value.TAC + TT -> Value.TT + TV -> Value.TV + V1 -> Value.V1 + V2 -> Value.V2 + WH -> Value.WH + XAA -> Value.XAA + YY -> Value.YY + ZZZ -> Value.ZZZ else -> Value._UNKNOWN } @@ -4747,17 +6002,185 @@ private constructor( */ fun known(): Known = when (this) { - AE -> Known.AE - E -> Known.E - S -> Known.S - Z -> Known.Z - G -> Known.G - O -> Known.O - K -> Known.K - L -> Known.L - M -> Known.M - B -> Known.B - else -> throw EInvoiceInvalidDataException("Unknown TaxCode: $value") + AA -> Known.AA + AAA -> Known.AAA + AAC -> Known.AAC + AAD -> Known.AAD + AAE -> Known.AAE + AAF -> Known.AAF + AAH -> Known.AAH + AAI -> Known.AAI + AAS -> Known.AAS + AAT -> Known.AAT + AAV -> Known.AAV + AAY -> Known.AAY + AAZ -> Known.AAZ + ABA -> Known.ABA + ABB -> Known.ABB + ABC -> Known.ABC + ABD -> Known.ABD + ABF -> Known.ABF + ABK -> Known.ABK + ABL -> Known.ABL + ABN -> Known.ABN + ABR -> Known.ABR + ABS -> Known.ABS + ABT -> Known.ABT + ABU -> Known.ABU + ACF -> Known.ACF + ACG -> Known.ACG + ACH -> Known.ACH + ACI -> Known.ACI + ACJ -> Known.ACJ + ACK -> Known.ACK + ACL -> Known.ACL + ACM -> Known.ACM + ACS -> Known.ACS + ADC -> Known.ADC + ADE -> Known.ADE + ADJ -> Known.ADJ + ADK -> Known.ADK + ADL -> Known.ADL + ADM -> Known.ADM + ADN -> Known.ADN + ADO -> Known.ADO + ADP -> Known.ADP + ADQ -> Known.ADQ + ADR -> Known.ADR + ADT -> Known.ADT + ADW -> Known.ADW + ADY -> Known.ADY + ADZ -> Known.ADZ + AEA -> Known.AEA + AEB -> Known.AEB + AEC -> Known.AEC + AED -> Known.AED + AEF -> Known.AEF + AEH -> Known.AEH + AEI -> Known.AEI + AEJ -> Known.AEJ + AEK -> Known.AEK + AEL -> Known.AEL + AEM -> Known.AEM + AEN -> Known.AEN + AEO -> Known.AEO + AEP -> Known.AEP + AES -> Known.AES + AET -> Known.AET + AEU -> Known.AEU + AEV -> Known.AEV + AEW -> Known.AEW + AEX -> Known.AEX + AEY -> Known.AEY + AEZ -> Known.AEZ + AJ -> Known.AJ + AU -> Known.AU + CA -> Known.CA + CAB -> Known.CAB + CAD -> Known.CAD + CAE -> Known.CAE + CAF -> Known.CAF + CAI -> Known.CAI + CAJ -> Known.CAJ + CAK -> Known.CAK + CAL -> Known.CAL + CAM -> Known.CAM + CAN -> Known.CAN + CAO -> Known.CAO + CAP -> Known.CAP + CAQ -> Known.CAQ + CAR -> Known.CAR + CAS -> Known.CAS + CAT -> Known.CAT + CAU -> Known.CAU + CAV -> Known.CAV + CAW -> Known.CAW + CAX -> Known.CAX + CAY -> Known.CAY + CAZ -> Known.CAZ + CD -> Known.CD + CG -> Known.CG + CS -> Known.CS + CT -> Known.CT + DAB -> Known.DAB + DAC -> Known.DAC + DAD -> Known.DAD + DAF -> Known.DAF + DAG -> Known.DAG + DAH -> Known.DAH + DAI -> Known.DAI + DAJ -> Known.DAJ + DAK -> Known.DAK + DAL -> Known.DAL + DAM -> Known.DAM + DAN -> Known.DAN + DAO -> Known.DAO + DAP -> Known.DAP + DAQ -> Known.DAQ + DL -> Known.DL + EG -> Known.EG + EP -> Known.EP + ER -> Known.ER + FAA -> Known.FAA + FAB -> Known.FAB + FAC -> Known.FAC + FC -> Known.FC + FH -> Known.FH + FI -> Known.FI + GAA -> Known.GAA + HAA -> Known.HAA + HD -> Known.HD + HH -> Known.HH + IAA -> Known.IAA + IAB -> Known.IAB + ID -> Known.ID + IF -> Known.IF + IR -> Known.IR + IS -> Known.IS + KO -> Known.KO + L1 -> Known.L1 + LA -> Known.LA + LAA -> Known.LAA + LAB -> Known.LAB + LF -> Known.LF + MAE -> Known.MAE + MI -> Known.MI + ML -> Known.ML + NAA -> Known.NAA + OA -> Known.OA + PA -> Known.PA + PAA -> Known.PAA + PC -> Known.PC + PL -> Known.PL + PRV -> Known.PRV + RAB -> Known.RAB + RAC -> Known.RAC + RAD -> Known.RAD + RAF -> Known.RAF + RE -> Known.RE + RF -> Known.RF + RH -> Known.RH + RV -> Known.RV + SA -> Known.SA + SAA -> Known.SAA + SAD -> Known.SAD + SAE -> Known.SAE + SAI -> Known.SAI + SG -> Known.SG + SH -> Known.SH + SM -> Known.SM + SU -> Known.SU + TAB -> Known.TAB + TAC -> Known.TAC + TT -> Known.TT + TV -> Known.TV + V1 -> Known.V1 + V2 -> Known.V2 + WH -> Known.WH + XAA -> Known.XAA + YY -> Known.YY + ZZZ -> Known.ZZZ + else -> throw EInvoiceInvalidDataException("Unknown ReasonCode: $value") } /** @@ -4776,7 +6199,7 @@ private constructor( private var validated: Boolean = false - fun validate(): TaxCode = apply { + fun validate(): ReasonCode = apply { if (validated) { return@apply } @@ -4806,7 +6229,7 @@ private constructor( return true } - return other is TaxCode && value == other.value + return other is ReasonCode && value == other.value } override fun hashCode() = value.hashCode() @@ -4814,826 +6237,3029 @@ private constructor( override fun toString() = value.toString() } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + */ + class TaxCode @JsonCreator private constructor(private val value: JsonField) : + Enum { - return other is Charge && - amount == other.amount && - baseAmount == other.baseAmount && - multiplierFactor == other.multiplierFactor && - reason == other.reason && - reasonCode == other.reasonCode && - taxCode == other.taxCode && - taxRate == other.taxRate && - additionalProperties == other.additionalProperties - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - private val hashCode: Int by lazy { - Objects.hash( - amount, - baseAmount, - multiplierFactor, - reason, - reasonCode, - taxCode, - taxRate, - additionalProperties, - ) - } + companion object { - override fun hashCode(): Int = hashCode + @JvmField val AE = of("AE") - override fun toString() = - "Charge{amount=$amount, baseAmount=$baseAmount, multiplierFactor=$multiplierFactor, reason=$reason, reasonCode=$reasonCode, taxCode=$taxCode, taxRate=$taxRate, additionalProperties=$additionalProperties}" - } + @JvmField val E = of("E") - /** - * The total amount of the invoice including tax (invoice_total = subtotal + total_tax + - * total_discount). Must be positive and rounded to maximum 2 decimals - */ - @JsonDeserialize(using = InvoiceTotal.Deserializer::class) - @JsonSerialize(using = InvoiceTotal.Serializer::class) - class InvoiceTotal - private constructor( - private val number: Double? = null, - private val string: String? = null, - private val _json: JsonValue? = null, - ) { + @JvmField val S = of("S") - fun number(): Optional = Optional.ofNullable(number) + @JvmField val Z = of("Z") - fun string(): Optional = Optional.ofNullable(string) + @JvmField val G = of("G") - fun isNumber(): Boolean = number != null + @JvmField val O = of("O") - fun isString(): Boolean = string != null + @JvmField val K = of("K") - fun asNumber(): Double = number.getOrThrow("number") + @JvmField val L = of("L") - fun asString(): String = string.getOrThrow("string") + @JvmField val M = of("M") - fun _json(): Optional = Optional.ofNullable(_json) + @JvmField val B = of("B") - fun accept(visitor: Visitor): T = - when { - number != null -> visitor.visitNumber(number) - string != null -> visitor.visitString(string) - else -> visitor.unknown(_json) + @JvmStatic fun of(value: String) = TaxCode(JsonField.of(value)) } - private var validated: Boolean = false + /** An enum containing [TaxCode]'s known values. */ + enum class Known { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + } - fun validate(): InvoiceTotal = apply { - if (validated) { - return@apply + /** + * An enum containing [TaxCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TaxCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + /** + * An enum member indicating that [TaxCode] was instantiated with an unknown value. + */ + _UNKNOWN, } - accept( - object : Visitor { - override fun visitNumber(number: Double) {} + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AE -> Value.AE + E -> Value.E + S -> Value.S + Z -> Value.Z + G -> Value.G + O -> Value.O + K -> Value.K + L -> Value.L + M -> Value.M + B -> Value.B + else -> Value._UNKNOWN + } - override fun visitString(string: String) {} + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + AE -> Known.AE + E -> Known.E + S -> Known.S + Z -> Known.Z + G -> Known.G + O -> Known.O + K -> Known.K + L -> Known.L + M -> Known.M + B -> Known.B + else -> throw EInvoiceInvalidDataException("Unknown TaxCode: $value") } - ) - validated = true - } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TaxCode = apply { + if (validated) { + return@apply + } + + known() + validated = true } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitNumber(number: Double) = 1 + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } - override fun visitString(string: String) = 1 + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - override fun unknown(json: JsonValue?) = 0 + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + return other is TaxCode && value == other.value } - return other is InvoiceTotal && number == other.number && string == other.string + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - override fun hashCode(): Int = Objects.hash(number, string) + /** The VAT rate, represented as percentage that applies to the charge */ + @JsonDeserialize(using = TaxRate.Deserializer::class) + @JsonSerialize(using = TaxRate.Serializer::class) + class TaxRate + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { - override fun toString(): String = - when { - number != null -> "InvoiceTotal{number=$number}" - string != null -> "InvoiceTotal{string=$string}" - _json != null -> "InvoiceTotal{_unknown=$_json}" - else -> throw IllegalStateException("Invalid InvoiceTotal") - } + fun number(): Optional = Optional.ofNullable(number) - companion object { + fun string(): Optional = Optional.ofNullable(string) - @JvmStatic fun ofNumber(number: Double) = InvoiceTotal(number = number) + fun isNumber(): Boolean = number != null - @JvmStatic fun ofString(string: String) = InvoiceTotal(string = string) - } + fun isString(): Boolean = string != null - /** - * An interface that defines how to map each variant of [InvoiceTotal] to a value of type - * [T]. - */ - interface Visitor { + fun asNumber(): Double = number.getOrThrow("number") - fun visitNumber(number: Double): T + fun asString(): String = string.getOrThrow("string") - fun visitString(string: String): T + fun _json(): Optional = Optional.ofNullable(_json) - /** - * Maps an unknown variant of [InvoiceTotal] to a value of type [T]. - * - * An instance of [InvoiceTotal] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the SDK - * is unaware of. - * - * @throws EInvoiceInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw EInvoiceInvalidDataException("Unknown InvoiceTotal: $json") - } - } + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } - internal class Deserializer : BaseDeserializer(InvoiceTotal::class) { + private var validated: Boolean = false - override fun ObjectCodec.deserialize(node: JsonNode): InvoiceTotal { - val json = JsonValue.fromJsonNode(node) + fun validate(): TaxRate = apply { + if (validated) { + return@apply + } - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - InvoiceTotal(number = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - InvoiceTotal(string = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). - 0 -> InvoiceTotal(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the first - // completely valid match, or simply the first match if none are completely - // valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(InvoiceTotal::class) { + accept( + object : Visitor { + override fun visitNumber(number: Double) {} - override fun serialize( - value: InvoiceTotal, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.number != null -> generator.writeObject(value.number) - value.string != null -> generator.writeObject(value.string) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid InvoiceTotal") - } + override fun visitString(string: String) {} + } + ) + validated = true } - } - } - - class Item - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val allowances: JsonField>, - private val amount: JsonField, - private val charges: JsonField>, - private val date: JsonField, - private val description: JsonField, - private val productCode: JsonField, - private val quantity: JsonField, - private val tax: JsonField, - private val taxRate: JsonField, - private val unit: JsonField, - private val unitPrice: JsonField, - private val additionalProperties: MutableMap, - ) { - @JsonCreator - private constructor( - @JsonProperty("allowances") - @ExcludeMissing - allowances: JsonField> = JsonMissing.of(), - @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("charges") - @ExcludeMissing - charges: JsonField> = JsonMissing.of(), - @JsonProperty("date") @ExcludeMissing date: JsonField = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("product_code") - @ExcludeMissing - productCode: JsonField = JsonMissing.of(), - @JsonProperty("quantity") - @ExcludeMissing - quantity: JsonField = JsonMissing.of(), - @JsonProperty("tax") @ExcludeMissing tax: JsonField = JsonMissing.of(), - @JsonProperty("tax_rate") @ExcludeMissing taxRate: JsonField = JsonMissing.of(), - @JsonProperty("unit") - @ExcludeMissing - unit: JsonField = JsonMissing.of(), - @JsonProperty("unit_price") - @ExcludeMissing - unitPrice: JsonField = JsonMissing.of(), - ) : this( - allowances, - amount, - charges, - date, - description, - productCode, - quantity, - tax, - taxRate, - unit, - unitPrice, - mutableMapOf(), - ) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } - /** - * The allowances of the line item. - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun allowances(): Optional> = allowances.getOptional("allowances") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 - /** - * The total amount of the line item, exclusive of VAT, after subtracting line level - * allowances and adding line level charges. Must be rounded to maximum 2 decimals - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") + override fun visitString(string: String) = 1 - /** - * The charges of the line item. - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun charges(): Optional> = charges.getOptional("charges") + override fun unknown(json: JsonValue?) = 0 + } + ) - /** - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun date(): Optional = date.getOptional("date") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * The description of the line item. - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun description(): Optional = description.getOptional("description") + return other is TaxRate && number == other.number && string == other.string + } - /** - * The product code of the line item. - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun productCode(): Optional = productCode.getOptional("product_code") + override fun hashCode(): Int = Objects.hash(number, string) - /** - * The quantity of items (goods or services) that is the subject of the line item. Must be - * rounded to maximum 4 decimals - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun quantity(): Optional = quantity.getOptional("quantity") + override fun toString(): String = + when { + number != null -> "TaxRate{number=$number}" + string != null -> "TaxRate{string=$string}" + _json != null -> "TaxRate{_unknown=$_json}" + else -> throw IllegalStateException("Invalid TaxRate") + } - /** - * The total VAT amount for the line item. Must be rounded to maximum 2 decimals - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun tax(): Optional = tax.getOptional("tax") + companion object { - /** - * The VAT rate of the line item expressed as percentage with 2 decimals - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun taxRate(): Optional = taxRate.getOptional("tax_rate") + @JvmStatic fun ofNumber(number: Double) = TaxRate(number = number) - /** - * Unit of Measure Codes from UNECERec20 used in Peppol BIS Billing 3.0. - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun unit(): Optional = unit.getOptional("unit") + @JvmStatic fun ofString(string: String) = TaxRate(string = string) + } - /** - * The unit price of the line item. Must be rounded to maximum 2 decimals - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun unitPrice(): Optional = unitPrice.getOptional("unit_price") + /** + * An interface that defines how to map each variant of [TaxRate] to a value of type + * [T]. + */ + interface Visitor { - /** - * Returns the raw JSON value of [allowances]. - * - * Unlike [allowances], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("allowances") - @ExcludeMissing - fun _allowances(): JsonField> = allowances + fun visitNumber(number: Double): T - /** - * Returns the raw JSON value of [amount]. - * - * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + fun visitString(string: String): T - /** - * Returns the raw JSON value of [charges]. - * - * Unlike [charges], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("charges") @ExcludeMissing fun _charges(): JsonField> = charges + /** + * Maps an unknown variant of [TaxRate] to a value of type [T]. + * + * An instance of [TaxRate] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws EInvoiceInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw EInvoiceInvalidDataException("Unknown TaxRate: $json") + } + } - /** - * Returns the raw JSON value of [date]. - * - * Unlike [date], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("date") @ExcludeMissing fun _date(): JsonField = date + internal class Deserializer : BaseDeserializer(TaxRate::class) { - /** - * Returns the raw JSON value of [description]. - * - * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description + override fun ObjectCodec.deserialize(node: JsonNode): TaxRate { + val json = JsonValue.fromJsonNode(node) - /** - * Returns the raw JSON value of [productCode]. - * - * Unlike [productCode], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("product_code") - @ExcludeMissing - fun _productCode(): JsonField = productCode + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + TaxRate(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + TaxRate(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> TaxRate(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } - /** - * Returns the raw JSON value of [quantity]. - * - * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity + internal class Serializer : BaseSerializer(TaxRate::class) { + + override fun serialize( + value: TaxRate, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid TaxRate") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Charge && + amount == other.amount && + baseAmount == other.baseAmount && + multiplierFactor == other.multiplierFactor && + reason == other.reason && + reasonCode == other.reasonCode && + taxCode == other.taxCode && + taxRate == other.taxRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Charge{amount=$amount, baseAmount=$baseAmount, multiplierFactor=$multiplierFactor, reason=$reason, reasonCode=$reasonCode, taxCode=$taxCode, taxRate=$taxRate, additionalProperties=$additionalProperties}" + } + + /** + * The total amount of the invoice including tax (invoice_total = subtotal + total_tax + + * total_discount). Must be positive and rounded to maximum 2 decimals + */ + @JsonDeserialize(using = InvoiceTotal.Deserializer::class) + @JsonSerialize(using = InvoiceTotal.Serializer::class) + class InvoiceTotal + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): InvoiceTotal = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } /** - * Returns the raw JSON value of [tax]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Unlike [tax], this method doesn't throw if the JSON field has an unexpected type. + * Used for best match union deserialization. */ - @JsonProperty("tax") @ExcludeMissing fun _tax(): JsonField = tax + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is InvoiceTotal && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "InvoiceTotal{number=$number}" + string != null -> "InvoiceTotal{string=$string}" + _json != null -> "InvoiceTotal{_unknown=$_json}" + else -> throw IllegalStateException("Invalid InvoiceTotal") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = InvoiceTotal(number = number) + + @JvmStatic fun ofString(string: String) = InvoiceTotal(string = string) + } /** - * Returns the raw JSON value of [taxRate]. - * - * Unlike [taxRate], this method doesn't throw if the JSON field has an unexpected type. + * An interface that defines how to map each variant of [InvoiceTotal] to a value of type + * [T]. */ - @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [InvoiceTotal] to a value of type [T]. + * + * An instance of [InvoiceTotal] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws EInvoiceInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw EInvoiceInvalidDataException("Unknown InvoiceTotal: $json") + } + } + + internal class Deserializer : BaseDeserializer(InvoiceTotal::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): InvoiceTotal { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + InvoiceTotal(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + InvoiceTotal(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from object). + 0 -> InvoiceTotal(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(InvoiceTotal::class) { + + override fun serialize( + value: InvoiceTotal, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid InvoiceTotal") + } + } + } + } + + class Item + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allowances: JsonField>, + private val amount: JsonField, + private val charges: JsonField>, + private val date: JsonField, + private val description: JsonField, + private val priceBaseQuantity: JsonField, + private val productCode: JsonField, + private val quantity: JsonField, + private val tax: JsonField, + private val taxRate: JsonField, + private val unit: JsonField, + private val unitPrice: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allowances") + @ExcludeMissing + allowances: JsonField> = JsonMissing.of(), + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("charges") + @ExcludeMissing + charges: JsonField> = JsonMissing.of(), + @JsonProperty("date") @ExcludeMissing date: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + description: JsonField = JsonMissing.of(), + @JsonProperty("price_base_quantity") + @ExcludeMissing + priceBaseQuantity: JsonField = JsonMissing.of(), + @JsonProperty("product_code") + @ExcludeMissing + productCode: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + quantity: JsonField = JsonMissing.of(), + @JsonProperty("tax") @ExcludeMissing tax: JsonField = JsonMissing.of(), + @JsonProperty("tax_rate") + @ExcludeMissing + taxRate: JsonField = JsonMissing.of(), + @JsonProperty("unit") + @ExcludeMissing + unit: JsonField = JsonMissing.of(), + @JsonProperty("unit_price") + @ExcludeMissing + unitPrice: JsonField = JsonMissing.of(), + ) : this( + allowances, + amount, + charges, + date, + description, + priceBaseQuantity, + productCode, + quantity, + tax, + taxRate, + unit, + unitPrice, + mutableMapOf(), + ) + + /** + * The allowances of the line item. + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun allowances(): Optional> = allowances.getOptional("allowances") + + /** + * The invoice line net amount (BT-131), exclusive of VAT, inclusive of line level + * allowances and charges. Calculated as: ((unit_price / price_base_quantity) * quantity) - + * allowances + charges. Must be rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * The charges of the line item. + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun charges(): Optional> = charges.getOptional("charges") + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun date(): Optional = date.getOptional("date") + + /** + * The description of the line item. + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun description(): Optional = description.getOptional("description") + + /** + * The item price base quantity (BT-149). The number of item units to which the price + * applies. Defaults to 1. Must be rounded to maximum 4 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun priceBaseQuantity(): Optional = + priceBaseQuantity.getOptional("price_base_quantity") + + /** + * The product code of the line item. + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun productCode(): Optional = productCode.getOptional("product_code") + + /** + * The quantity of items (goods or services) that is the subject of the line item. Must be + * rounded to maximum 4 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun quantity(): Optional = quantity.getOptional("quantity") + + /** + * The total VAT amount for the line item. Must be rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun tax(): Optional = tax.getOptional("tax") + + /** + * The VAT rate of the line item expressed as percentage with 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun taxRate(): Optional = taxRate.getOptional("tax_rate") + + /** + * Unit of Measure Codes from UNECERec20 used in Peppol BIS Billing 3.0. + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun unit(): Optional = unit.getOptional("unit") + + /** + * The item net price (BT-146). The price of an item, exclusive of VAT, after subtracting + * item price discount. Must be rounded to maximum 4 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun unitPrice(): Optional = unitPrice.getOptional("unit_price") + + /** + * Returns the raw JSON value of [allowances]. + * + * Unlike [allowances], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("allowances") + @ExcludeMissing + fun _allowances(): JsonField> = allowances + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [charges]. + * + * Unlike [charges], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("charges") @ExcludeMissing fun _charges(): JsonField> = charges + + /** + * Returns the raw JSON value of [date]. + * + * Unlike [date], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("date") @ExcludeMissing fun _date(): JsonField = date + + /** + * Returns the raw JSON value of [description]. + * + * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description + + /** + * Returns the raw JSON value of [priceBaseQuantity]. + * + * Unlike [priceBaseQuantity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("price_base_quantity") + @ExcludeMissing + fun _priceBaseQuantity(): JsonField = priceBaseQuantity + + /** + * Returns the raw JSON value of [productCode]. + * + * Unlike [productCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("product_code") + @ExcludeMissing + fun _productCode(): JsonField = productCode + + /** + * Returns the raw JSON value of [quantity]. + * + * Unlike [quantity], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity + + /** + * Returns the raw JSON value of [tax]. + * + * Unlike [tax], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax") @ExcludeMissing fun _tax(): JsonField = tax + + /** + * Returns the raw JSON value of [taxRate]. + * + * Unlike [taxRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate + + /** + * Returns the raw JSON value of [unit]. + * + * Unlike [unit], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit + + /** + * Returns the raw JSON value of [unitPrice]. + * + * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("unit_price") + @ExcludeMissing + fun _unitPrice(): JsonField = unitPrice + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Item]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Item]. */ + class Builder internal constructor() { + + private var allowances: JsonField>? = null + private var amount: JsonField = JsonMissing.of() + private var charges: JsonField>? = null + private var date: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var priceBaseQuantity: JsonField = JsonMissing.of() + private var productCode: JsonField = JsonMissing.of() + private var quantity: JsonField = JsonMissing.of() + private var tax: JsonField = JsonMissing.of() + private var taxRate: JsonField = JsonMissing.of() + private var unit: JsonField = JsonMissing.of() + private var unitPrice: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(item: Item) = apply { + allowances = item.allowances.map { it.toMutableList() } + amount = item.amount + charges = item.charges.map { it.toMutableList() } + date = item.date + description = item.description + priceBaseQuantity = item.priceBaseQuantity + productCode = item.productCode + quantity = item.quantity + tax = item.tax + taxRate = item.taxRate + unit = item.unit + unitPrice = item.unitPrice + additionalProperties = item.additionalProperties.toMutableMap() + } + + /** The allowances of the line item. */ + fun allowances(allowances: List?) = + allowances(JsonField.ofNullable(allowances)) + + /** Alias for calling [Builder.allowances] with `allowances.orElse(null)`. */ + fun allowances(allowances: Optional>) = + allowances(allowances.getOrNull()) + + /** + * Sets [Builder.allowances] to an arbitrary JSON value. + * + * You should usually call [Builder.allowances] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun allowances(allowances: JsonField>) = apply { + this.allowances = allowances.map { it.toMutableList() } + } + + /** + * Adds a single [Allowance] to [allowances]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAllowance(allowance: Allowance) = apply { + allowances = + (allowances ?: JsonField.of(mutableListOf())).also { + checkKnown("allowances", it).add(allowance) + } + } + + /** + * The invoice line net amount (BT-131), exclusive of VAT, inclusive of line level + * allowances and charges. Calculated as: ((unit_price / price_base_quantity) * + * quantity) - allowances + charges. Must be rounded to maximum 2 decimals + */ + fun amount(amount: Amount?) = amount(JsonField.ofNullable(amount)) + + /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ + fun amount(amount: Optional) = amount(amount.getOrNull()) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Amount] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** Alias for calling [amount] with `Amount.ofNumber(number)`. */ + fun amount(number: Double) = amount(Amount.ofNumber(number)) + + /** Alias for calling [amount] with `Amount.ofString(string)`. */ + fun amount(string: String) = amount(Amount.ofString(string)) + + /** The charges of the line item. */ + fun charges(charges: List?) = charges(JsonField.ofNullable(charges)) + + /** Alias for calling [Builder.charges] with `charges.orElse(null)`. */ + fun charges(charges: Optional>) = charges(charges.getOrNull()) + + /** + * Sets [Builder.charges] to an arbitrary JSON value. + * + * You should usually call [Builder.charges] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun charges(charges: JsonField>) = apply { + this.charges = charges.map { it.toMutableList() } + } + + /** + * Adds a single [Charge] to [charges]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCharge(charge: Charge) = apply { + charges = + (charges ?: JsonField.of(mutableListOf())).also { + checkKnown("charges", it).add(charge) + } + } + + fun date(date: Void?) = date(JsonField.ofNullable(date)) + + /** Alias for calling [Builder.date] with `date.orElse(null)`. */ + fun date(date: Optional) = date(date.getOrNull()) + + /** + * Sets [Builder.date] to an arbitrary JSON value. + * + * You should usually call [Builder.date] with a well-typed [Void] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun date(date: JsonField) = apply { this.date = date } + + /** The description of the line item. */ + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) + + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** + * The item price base quantity (BT-149). The number of item units to which the price + * applies. Defaults to 1. Must be rounded to maximum 4 decimals + */ + fun priceBaseQuantity(priceBaseQuantity: PriceBaseQuantity?) = + priceBaseQuantity(JsonField.ofNullable(priceBaseQuantity)) + + /** + * Alias for calling [Builder.priceBaseQuantity] with `priceBaseQuantity.orElse(null)`. + */ + fun priceBaseQuantity(priceBaseQuantity: Optional) = + priceBaseQuantity(priceBaseQuantity.getOrNull()) + + /** + * Sets [Builder.priceBaseQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.priceBaseQuantity] with a well-typed + * [PriceBaseQuantity] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun priceBaseQuantity(priceBaseQuantity: JsonField) = apply { + this.priceBaseQuantity = priceBaseQuantity + } + + /** Alias for calling [priceBaseQuantity] with `PriceBaseQuantity.ofNumber(number)`. */ + fun priceBaseQuantity(number: Double) = + priceBaseQuantity(PriceBaseQuantity.ofNumber(number)) + + /** Alias for calling [priceBaseQuantity] with `PriceBaseQuantity.ofString(string)`. */ + fun priceBaseQuantity(string: String) = + priceBaseQuantity(PriceBaseQuantity.ofString(string)) + + /** The product code of the line item. */ + fun productCode(productCode: String?) = productCode(JsonField.ofNullable(productCode)) + + /** Alias for calling [Builder.productCode] with `productCode.orElse(null)`. */ + fun productCode(productCode: Optional) = productCode(productCode.getOrNull()) + + /** + * Sets [Builder.productCode] to an arbitrary JSON value. + * + * You should usually call [Builder.productCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun productCode(productCode: JsonField) = apply { + this.productCode = productCode + } + + /** + * The quantity of items (goods or services) that is the subject of the line item. Must + * be rounded to maximum 4 decimals + */ + fun quantity(quantity: Quantity?) = quantity(JsonField.ofNullable(quantity)) + + /** Alias for calling [Builder.quantity] with `quantity.orElse(null)`. */ + fun quantity(quantity: Optional) = quantity(quantity.getOrNull()) + + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Quantity] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + /** Alias for calling [quantity] with `Quantity.ofNumber(number)`. */ + fun quantity(number: Double) = quantity(Quantity.ofNumber(number)) + + /** Alias for calling [quantity] with `Quantity.ofString(string)`. */ + fun quantity(string: String) = quantity(Quantity.ofString(string)) + + /** The total VAT amount for the line item. Must be rounded to maximum 2 decimals */ + fun tax(tax: Tax?) = tax(JsonField.ofNullable(tax)) + + /** Alias for calling [Builder.tax] with `tax.orElse(null)`. */ + fun tax(tax: Optional) = tax(tax.getOrNull()) + + /** + * Sets [Builder.tax] to an arbitrary JSON value. + * + * You should usually call [Builder.tax] with a well-typed [Tax] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tax(tax: JsonField) = apply { this.tax = tax } + + /** Alias for calling [tax] with `Tax.ofNumber(number)`. */ + fun tax(number: Double) = tax(Tax.ofNumber(number)) + + /** Alias for calling [tax] with `Tax.ofString(string)`. */ + fun tax(string: String) = tax(Tax.ofString(string)) + + /** The VAT rate of the line item expressed as percentage with 2 decimals */ + fun taxRate(taxRate: TaxRate?) = taxRate(JsonField.ofNullable(taxRate)) + + /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ + fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) + + /** + * Sets [Builder.taxRate] to an arbitrary JSON value. + * + * You should usually call [Builder.taxRate] with a well-typed [TaxRate] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } + + /** Alias for calling [taxRate] with `TaxRate.ofNumber(number)`. */ + fun taxRate(number: Double) = taxRate(TaxRate.ofNumber(number)) + + /** Alias for calling [taxRate] with `TaxRate.ofString(string)`. */ + fun taxRate(string: String) = taxRate(TaxRate.ofString(string)) + + /** Unit of Measure Codes from UNECERec20 used in Peppol BIS Billing 3.0. */ + fun unit(unit: UnitOfMeasureCode?) = unit(JsonField.ofNullable(unit)) + + /** Alias for calling [Builder.unit] with `unit.orElse(null)`. */ + fun unit(unit: Optional) = unit(unit.getOrNull()) + + /** + * Sets [Builder.unit] to an arbitrary JSON value. + * + * You should usually call [Builder.unit] with a well-typed [UnitOfMeasureCode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun unit(unit: JsonField) = apply { this.unit = unit } + + /** + * The item net price (BT-146). The price of an item, exclusive of VAT, after + * subtracting item price discount. Must be rounded to maximum 4 decimals + */ + fun unitPrice(unitPrice: UnitPrice?) = unitPrice(JsonField.ofNullable(unitPrice)) + + /** Alias for calling [Builder.unitPrice] with `unitPrice.orElse(null)`. */ + fun unitPrice(unitPrice: Optional) = unitPrice(unitPrice.getOrNull()) + + /** + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed [UnitPrice] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } + + /** Alias for calling [unitPrice] with `UnitPrice.ofNumber(number)`. */ + fun unitPrice(number: Double) = unitPrice(UnitPrice.ofNumber(number)) + + /** Alias for calling [unitPrice] with `UnitPrice.ofString(string)`. */ + fun unitPrice(string: String) = unitPrice(UnitPrice.ofString(string)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Item]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Item = + Item( + (allowances ?: JsonMissing.of()).map { it.toImmutable() }, + amount, + (charges ?: JsonMissing.of()).map { it.toImmutable() }, + date, + description, + priceBaseQuantity, + productCode, + quantity, + tax, + taxRate, + unit, + unitPrice, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Item = apply { + if (validated) { + return@apply + } + + allowances().ifPresent { it.forEach { it.validate() } } + amount().ifPresent { it.validate() } + charges().ifPresent { it.forEach { it.validate() } } + date() + description() + priceBaseQuantity().ifPresent { it.validate() } + productCode() + quantity().ifPresent { it.validate() } + tax().ifPresent { it.validate() } + taxRate().ifPresent { it.validate() } + unit().ifPresent { it.validate() } + unitPrice().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (allowances.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (amount.asKnown().getOrNull()?.validity() ?: 0) + + (charges.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (date.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (priceBaseQuantity.asKnown().getOrNull()?.validity() ?: 0) + + (if (productCode.asKnown().isPresent) 1 else 0) + + (quantity.asKnown().getOrNull()?.validity() ?: 0) + + (tax.asKnown().getOrNull()?.validity() ?: 0) + + (taxRate.asKnown().getOrNull()?.validity() ?: 0) + + (unit.asKnown().getOrNull()?.validity() ?: 0) + + (unitPrice.asKnown().getOrNull()?.validity() ?: 0) + + /** An allowance is a discount for example for early payment, volume discount, etc. */ + class Allowance + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val baseAmount: JsonField, + private val multiplierFactor: JsonField, + private val reason: JsonField, + private val reasonCode: JsonField, + private val taxCode: JsonField, + private val taxRate: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("base_amount") + @ExcludeMissing + baseAmount: JsonField = JsonMissing.of(), + @JsonProperty("multiplier_factor") + @ExcludeMissing + multiplierFactor: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + @JsonProperty("reason_code") + @ExcludeMissing + reasonCode: JsonField = JsonMissing.of(), + @JsonProperty("tax_code") + @ExcludeMissing + taxCode: JsonField = JsonMissing.of(), + @JsonProperty("tax_rate") + @ExcludeMissing + taxRate: JsonField = JsonMissing.of(), + ) : this( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + mutableMapOf(), + ) + + /** + * The allowance amount, without VAT. Must be rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * The base amount that may be used, in conjunction with the allowance percentage, to + * calculate the allowance amount. Must be rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun baseAmount(): Optional = baseAmount.getOptional("base_amount") + + /** + * The percentage that may be used, in conjunction with the allowance base amount, to + * calculate the allowance amount. To state 20%, use value 20. Must be rounded to + * maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun multiplierFactor(): Optional = + multiplierFactor.getOptional("multiplier_factor") + + /** + * The reason for the allowance + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun reason(): Optional = reason.getOptional("reason") + + /** + * Allowance reason codes for invoice discounts and charges + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun reasonCode(): Optional = reasonCode.getOptional("reason_code") + + /** + * The VAT category code that applies to the allowance + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun taxCode(): Optional = taxCode.getOptional("tax_code") + + /** + * The VAT rate, represented as percentage that applies to the allowance. Must be + * rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun taxRate(): Optional = taxRate.getOptional("tax_rate") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [baseAmount]. + * + * Unlike [baseAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("base_amount") + @ExcludeMissing + fun _baseAmount(): JsonField = baseAmount + + /** + * Returns the raw JSON value of [multiplierFactor]. + * + * Unlike [multiplierFactor], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("multiplier_factor") + @ExcludeMissing + fun _multiplierFactor(): JsonField = multiplierFactor + + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + + /** + * Returns the raw JSON value of [reasonCode]. + * + * Unlike [reasonCode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reason_code") + @ExcludeMissing + fun _reasonCode(): JsonField = reasonCode + + /** + * Returns the raw JSON value of [taxCode]. + * + * Unlike [taxCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax_code") @ExcludeMissing fun _taxCode(): JsonField = taxCode + + /** + * Returns the raw JSON value of [taxRate]. + * + * Unlike [taxRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Allowance]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Allowance]. */ + class Builder internal constructor() { + + private var amount: JsonField = JsonMissing.of() + private var baseAmount: JsonField = JsonMissing.of() + private var multiplierFactor: JsonField = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var reasonCode: JsonField = JsonMissing.of() + private var taxCode: JsonField = JsonMissing.of() + private var taxRate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(allowance: Allowance) = apply { + amount = allowance.amount + baseAmount = allowance.baseAmount + multiplierFactor = allowance.multiplierFactor + reason = allowance.reason + reasonCode = allowance.reasonCode + taxCode = allowance.taxCode + taxRate = allowance.taxRate + additionalProperties = allowance.additionalProperties.toMutableMap() + } + + /** The allowance amount, without VAT. Must be rounded to maximum 2 decimals */ + fun amount(amount: Amount?) = amount(JsonField.ofNullable(amount)) + + /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ + fun amount(amount: Optional) = amount(amount.getOrNull()) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Amount] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** Alias for calling [amount] with `Amount.ofNumber(number)`. */ + fun amount(number: Double) = amount(Amount.ofNumber(number)) + + /** Alias for calling [amount] with `Amount.ofString(string)`. */ + fun amount(string: String) = amount(Amount.ofString(string)) + + /** + * The base amount that may be used, in conjunction with the allowance percentage, + * to calculate the allowance amount. Must be rounded to maximum 2 decimals + */ + fun baseAmount(baseAmount: BaseAmount?) = + baseAmount(JsonField.ofNullable(baseAmount)) + + /** Alias for calling [Builder.baseAmount] with `baseAmount.orElse(null)`. */ + fun baseAmount(baseAmount: Optional) = + baseAmount(baseAmount.getOrNull()) + + /** + * Sets [Builder.baseAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.baseAmount] with a well-typed [BaseAmount] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun baseAmount(baseAmount: JsonField) = apply { + this.baseAmount = baseAmount + } + + /** Alias for calling [baseAmount] with `BaseAmount.ofNumber(number)`. */ + fun baseAmount(number: Double) = baseAmount(BaseAmount.ofNumber(number)) + + /** Alias for calling [baseAmount] with `BaseAmount.ofString(string)`. */ + fun baseAmount(string: String) = baseAmount(BaseAmount.ofString(string)) + + /** + * The percentage that may be used, in conjunction with the allowance base amount, + * to calculate the allowance amount. To state 20%, use value 20. Must be rounded to + * maximum 2 decimals + */ + fun multiplierFactor(multiplierFactor: MultiplierFactor?) = + multiplierFactor(JsonField.ofNullable(multiplierFactor)) + + /** + * Alias for calling [Builder.multiplierFactor] with + * `multiplierFactor.orElse(null)`. + */ + fun multiplierFactor(multiplierFactor: Optional) = + multiplierFactor(multiplierFactor.getOrNull()) + + /** + * Sets [Builder.multiplierFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.multiplierFactor] with a well-typed + * [MultiplierFactor] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun multiplierFactor(multiplierFactor: JsonField) = apply { + this.multiplierFactor = multiplierFactor + } + + /** + * Alias for calling [multiplierFactor] with `MultiplierFactor.ofNumber(number)`. + */ + fun multiplierFactor(number: Double) = + multiplierFactor(MultiplierFactor.ofNumber(number)) + + /** + * Alias for calling [multiplierFactor] with `MultiplierFactor.ofString(string)`. + */ + fun multiplierFactor(string: String) = + multiplierFactor(MultiplierFactor.ofString(string)) + + /** The reason for the allowance */ + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ + fun reason(reason: Optional) = reason(reason.getOrNull()) + + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } + + /** Allowance reason codes for invoice discounts and charges */ + fun reasonCode(reasonCode: ReasonCode?) = + reasonCode(JsonField.ofNullable(reasonCode)) + + /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ + fun reasonCode(reasonCode: Optional) = + reasonCode(reasonCode.getOrNull()) + + /** + * Sets [Builder.reasonCode] to an arbitrary JSON value. + * + * You should usually call [Builder.reasonCode] with a well-typed [ReasonCode] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun reasonCode(reasonCode: JsonField) = apply { + this.reasonCode = reasonCode + } + + /** The VAT category code that applies to the allowance */ + fun taxCode(taxCode: TaxCode) = taxCode(JsonField.of(taxCode)) + + /** + * Sets [Builder.taxCode] to an arbitrary JSON value. + * + * You should usually call [Builder.taxCode] with a well-typed [TaxCode] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } + + /** + * The VAT rate, represented as percentage that applies to the allowance. Must be + * rounded to maximum 2 decimals + */ + fun taxRate(taxRate: TaxRate?) = taxRate(JsonField.ofNullable(taxRate)) + + /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ + fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) + + /** + * Sets [Builder.taxRate] to an arbitrary JSON value. + * + * You should usually call [Builder.taxRate] with a well-typed [TaxRate] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } + + /** Alias for calling [taxRate] with `TaxRate.ofNumber(number)`. */ + fun taxRate(number: Double) = taxRate(TaxRate.ofNumber(number)) + + /** Alias for calling [taxRate] with `TaxRate.ofString(string)`. */ + fun taxRate(string: String) = taxRate(TaxRate.ofString(string)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Allowance]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Allowance = + Allowance( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Allowance = apply { + if (validated) { + return@apply + } + + amount().ifPresent { it.validate() } + baseAmount().ifPresent { it.validate() } + multiplierFactor().ifPresent { it.validate() } + reason() + reasonCode().ifPresent { it.validate() } + taxCode().ifPresent { it.validate() } + taxRate().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (amount.asKnown().getOrNull()?.validity() ?: 0) + + (baseAmount.asKnown().getOrNull()?.validity() ?: 0) + + (multiplierFactor.asKnown().getOrNull()?.validity() ?: 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (reasonCode.asKnown().getOrNull()?.validity() ?: 0) + + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + + (taxRate.asKnown().getOrNull()?.validity() ?: 0) + + /** The allowance amount, without VAT. Must be rounded to maximum 2 decimals */ + @JsonDeserialize(using = Amount.Deserializer::class) + @JsonSerialize(using = Amount.Serializer::class) + class Amount + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Amount = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Amount && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "Amount{number=$number}" + string != null -> "Amount{string=$string}" + _json != null -> "Amount{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Amount") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = Amount(number = number) + + @JvmStatic fun ofString(string: String) = Amount(string = string) + } + + /** + * An interface that defines how to map each variant of [Amount] to a value of type + * [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [Amount] to a value of type [T]. + * + * An instance of [Amount] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on + * an older version than the API, then the API may respond with new variants + * that the SDK is unaware of. + * + * @throws EInvoiceInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw EInvoiceInvalidDataException("Unknown Amount: $json") + } + } + + internal class Deserializer : BaseDeserializer(Amount::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Amount { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Amount(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Amount(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // object). + 0 -> Amount(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Amount::class) { + + override fun serialize( + value: Amount, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Amount") + } + } + } + } + + /** + * The base amount that may be used, in conjunction with the allowance percentage, to + * calculate the allowance amount. Must be rounded to maximum 2 decimals + */ + @JsonDeserialize(using = BaseAmount.Deserializer::class) + @JsonSerialize(using = BaseAmount.Serializer::class) + class BaseAmount + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): BaseAmount = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BaseAmount && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "BaseAmount{number=$number}" + string != null -> "BaseAmount{string=$string}" + _json != null -> "BaseAmount{_unknown=$_json}" + else -> throw IllegalStateException("Invalid BaseAmount") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = BaseAmount(number = number) + + @JvmStatic fun ofString(string: String) = BaseAmount(string = string) + } + + /** + * An interface that defines how to map each variant of [BaseAmount] to a value of + * type [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [BaseAmount] to a value of type [T]. + * + * An instance of [BaseAmount] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws EInvoiceInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw EInvoiceInvalidDataException("Unknown BaseAmount: $json") + } + } + + internal class Deserializer : BaseDeserializer(BaseAmount::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): BaseAmount { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + BaseAmount(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + BaseAmount(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // object). + 0 -> BaseAmount(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(BaseAmount::class) { + + override fun serialize( + value: BaseAmount, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid BaseAmount") + } + } + } + } + + /** + * The percentage that may be used, in conjunction with the allowance base amount, to + * calculate the allowance amount. To state 20%, use value 20. Must be rounded to + * maximum 2 decimals + */ + @JsonDeserialize(using = MultiplierFactor.Deserializer::class) + @JsonSerialize(using = MultiplierFactor.Serializer::class) + class MultiplierFactor + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): MultiplierFactor = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is MultiplierFactor && + number == other.number && + string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "MultiplierFactor{number=$number}" + string != null -> "MultiplierFactor{string=$string}" + _json != null -> "MultiplierFactor{_unknown=$_json}" + else -> throw IllegalStateException("Invalid MultiplierFactor") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = MultiplierFactor(number = number) + + @JvmStatic fun ofString(string: String) = MultiplierFactor(string = string) + } + + /** + * An interface that defines how to map each variant of [MultiplierFactor] to a + * value of type [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [MultiplierFactor] to a value of type [T]. + * + * An instance of [MultiplierFactor] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws EInvoiceInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw EInvoiceInvalidDataException("Unknown MultiplierFactor: $json") + } + } + + internal class Deserializer : + BaseDeserializer(MultiplierFactor::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): MultiplierFactor { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + MultiplierFactor(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + MultiplierFactor(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // object). + 0 -> MultiplierFactor(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer(MultiplierFactor::class) { + + override fun serialize( + value: MultiplierFactor, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid MultiplierFactor") + } + } + } + } + + /** Allowance reason codes for invoice discounts and charges */ + class ReasonCode + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val _41 = of("41") + + @JvmField val _42 = of("42") + + @JvmField val _60 = of("60") + + @JvmField val _62 = of("62") + + @JvmField val _63 = of("63") + + @JvmField val _64 = of("64") + + @JvmField val _65 = of("65") + + @JvmField val _66 = of("66") + + @JvmField val _67 = of("67") + + @JvmField val _68 = of("68") + + @JvmField val _70 = of("70") + + @JvmField val _71 = of("71") + + @JvmField val _88 = of("88") + + @JvmField val _95 = of("95") + + @JvmField val _100 = of("100") + + @JvmField val _102 = of("102") + + @JvmField val _103 = of("103") + + @JvmField val _104 = of("104") + + @JvmField val _105 = of("105") + + @JvmStatic fun of(value: String) = ReasonCode(JsonField.of(value)) + } + + /** An enum containing [ReasonCode]'s known values. */ + enum class Known { + _41, + _42, + _60, + _62, + _63, + _64, + _65, + _66, + _67, + _68, + _70, + _71, + _88, + _95, + _100, + _102, + _103, + _104, + _105, + } + + /** + * An enum containing [ReasonCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ReasonCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + _41, + _42, + _60, + _62, + _63, + _64, + _65, + _66, + _67, + _68, + _70, + _71, + _88, + _95, + _100, + _102, + _103, + _104, + _105, + /** + * An enum member indicating that [ReasonCode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + _41 -> Value._41 + _42 -> Value._42 + _60 -> Value._60 + _62 -> Value._62 + _63 -> Value._63 + _64 -> Value._64 + _65 -> Value._65 + _66 -> Value._66 + _67 -> Value._67 + _68 -> Value._68 + _70 -> Value._70 + _71 -> Value._71 + _88 -> Value._88 + _95 -> Value._95 + _100 -> Value._100 + _102 -> Value._102 + _103 -> Value._103 + _104 -> Value._104 + _105 -> Value._105 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + _41 -> Known._41 + _42 -> Known._42 + _60 -> Known._60 + _62 -> Known._62 + _63 -> Known._63 + _64 -> Known._64 + _65 -> Known._65 + _66 -> Known._66 + _67 -> Known._67 + _68 -> Known._68 + _70 -> Known._70 + _71 -> Known._71 + _88 -> Known._88 + _95 -> Known._95 + _100 -> Known._100 + _102 -> Known._102 + _103 -> Known._103 + _104 -> Known._104 + _105 -> Known._105 + else -> throw EInvoiceInvalidDataException("Unknown ReasonCode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReasonCode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReasonCode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The VAT category code that applies to the allowance */ + class TaxCode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val AE = of("AE") + + @JvmField val E = of("E") + + @JvmField val S = of("S") + + @JvmField val Z = of("Z") + + @JvmField val G = of("G") + + @JvmField val O = of("O") + + @JvmField val K = of("K") + + @JvmField val L = of("L") + + @JvmField val M = of("M") + + @JvmField val B = of("B") + + @JvmStatic fun of(value: String) = TaxCode(JsonField.of(value)) + } + + /** An enum containing [TaxCode]'s known values. */ + enum class Known { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + } + + /** + * An enum containing [TaxCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TaxCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + /** + * An enum member indicating that [TaxCode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AE -> Value.AE + E -> Value.E + S -> Value.S + Z -> Value.Z + G -> Value.G + O -> Value.O + K -> Value.K + L -> Value.L + M -> Value.M + B -> Value.B + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + AE -> Known.AE + E -> Known.E + S -> Known.S + Z -> Known.Z + G -> Known.G + O -> Known.O + K -> Known.K + L -> Known.L + M -> Known.M + B -> Known.B + else -> throw EInvoiceInvalidDataException("Unknown TaxCode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): TaxCode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TaxCode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * The VAT rate, represented as percentage that applies to the allowance. Must be + * rounded to maximum 2 decimals + */ + @JsonDeserialize(using = TaxRate.Deserializer::class) + @JsonSerialize(using = TaxRate.Serializer::class) + class TaxRate + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) - /** - * Returns the raw JSON value of [unit]. - * - * Unlike [unit], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit + fun isNumber(): Boolean = number != null - /** - * Returns the raw JSON value of [unitPrice]. - * - * Unlike [unitPrice], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("unit_price") - @ExcludeMissing - fun _unitPrice(): JsonField = unitPrice + fun isString(): Boolean = string != null - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + fun asNumber(): Double = number.getOrThrow("number") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + fun asString(): String = string.getOrThrow("string") - fun toBuilder() = Builder().from(this) + fun _json(): Optional = Optional.ofNullable(_json) - companion object { + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } - /** Returns a mutable builder for constructing an instance of [Item]. */ - @JvmStatic fun builder() = Builder() - } + private var validated: Boolean = false - /** A builder for [Item]. */ - class Builder internal constructor() { + fun validate(): TaxRate = apply { + if (validated) { + return@apply + } - private var allowances: JsonField>? = null - private var amount: JsonField = JsonMissing.of() - private var charges: JsonField>? = null - private var date: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var productCode: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var tax: JsonField = JsonMissing.of() - private var taxRate: JsonField = JsonMissing.of() - private var unit: JsonField = JsonMissing.of() - private var unitPrice: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + accept( + object : Visitor { + override fun visitNumber(number: Double) {} - @JvmSynthetic - internal fun from(item: Item) = apply { - allowances = item.allowances.map { it.toMutableList() } - amount = item.amount - charges = item.charges.map { it.toMutableList() } - date = item.date - description = item.description - productCode = item.productCode - quantity = item.quantity - tax = item.tax - taxRate = item.taxRate - unit = item.unit - unitPrice = item.unitPrice - additionalProperties = item.additionalProperties.toMutableMap() - } + override fun visitString(string: String) {} + } + ) + validated = true + } - /** The allowances of the line item. */ - fun allowances(allowances: List?) = - allowances(JsonField.ofNullable(allowances)) + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } - /** Alias for calling [Builder.allowances] with `allowances.orElse(null)`. */ - fun allowances(allowances: Optional>) = - allowances(allowances.getOrNull()) + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 - /** - * Sets [Builder.allowances] to an arbitrary JSON value. - * - * You should usually call [Builder.allowances] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun allowances(allowances: JsonField>) = apply { - this.allowances = allowances.map { it.toMutableList() } - } + override fun visitString(string: String) = 1 - /** - * Adds a single [Allowance] to [allowances]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addAllowance(allowance: Allowance) = apply { - allowances = - (allowances ?: JsonField.of(mutableListOf())).also { - checkKnown("allowances", it).add(allowance) + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - } - /** - * The total amount of the line item, exclusive of VAT, after subtracting line level - * allowances and adding line level charges. Must be rounded to maximum 2 decimals - */ - fun amount(amount: Amount?) = amount(JsonField.ofNullable(amount)) + return other is TaxRate && number == other.number && string == other.string + } - /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ - fun amount(amount: Optional) = amount(amount.getOrNull()) + override fun hashCode(): Int = Objects.hash(number, string) - /** - * Sets [Builder.amount] to an arbitrary JSON value. - * - * You should usually call [Builder.amount] with a well-typed [Amount] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } + override fun toString(): String = + when { + number != null -> "TaxRate{number=$number}" + string != null -> "TaxRate{string=$string}" + _json != null -> "TaxRate{_unknown=$_json}" + else -> throw IllegalStateException("Invalid TaxRate") + } - /** Alias for calling [amount] with `Amount.ofNumber(number)`. */ - fun amount(number: Double) = amount(Amount.ofNumber(number)) + companion object { - /** Alias for calling [amount] with `Amount.ofString(string)`. */ - fun amount(string: String) = amount(Amount.ofString(string)) + @JvmStatic fun ofNumber(number: Double) = TaxRate(number = number) - /** The charges of the line item. */ - fun charges(charges: List?) = charges(JsonField.ofNullable(charges)) + @JvmStatic fun ofString(string: String) = TaxRate(string = string) + } - /** Alias for calling [Builder.charges] with `charges.orElse(null)`. */ - fun charges(charges: Optional>) = charges(charges.getOrNull()) + /** + * An interface that defines how to map each variant of [TaxRate] to a value of type + * [T]. + */ + interface Visitor { - /** - * Sets [Builder.charges] to an arbitrary JSON value. - * - * You should usually call [Builder.charges] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun charges(charges: JsonField>) = apply { - this.charges = charges.map { it.toMutableList() } - } + fun visitNumber(number: Double): T - /** - * Adds a single [Charge] to [charges]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addCharge(charge: Charge) = apply { - charges = - (charges ?: JsonField.of(mutableListOf())).also { - checkKnown("charges", it).add(charge) + fun visitString(string: String): T + + /** + * Maps an unknown variant of [TaxRate] to a value of type [T]. + * + * An instance of [TaxRate] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws EInvoiceInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw EInvoiceInvalidDataException("Unknown TaxRate: $json") } - } + } - fun date(date: Void?) = date(JsonField.ofNullable(date)) + internal class Deserializer : BaseDeserializer(TaxRate::class) { - /** Alias for calling [Builder.date] with `date.orElse(null)`. */ - fun date(date: Optional) = date(date.getOrNull()) + override fun ObjectCodec.deserialize(node: JsonNode): TaxRate { + val json = JsonValue.fromJsonNode(node) - /** - * Sets [Builder.date] to an arbitrary JSON value. - * - * You should usually call [Builder.date] with a well-typed [Void] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun date(date: JsonField) = apply { this.date = date } + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + TaxRate(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + TaxRate(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // object). + 0 -> TaxRate(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } - /** The description of the line item. */ - fun description(description: String?) = description(JsonField.ofNullable(description)) + internal class Serializer : BaseSerializer(TaxRate::class) { - /** Alias for calling [Builder.description] with `description.orElse(null)`. */ - fun description(description: Optional) = description(description.getOrNull()) + override fun serialize( + value: TaxRate, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid TaxRate") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Allowance && + amount == other.amount && + baseAmount == other.baseAmount && + multiplierFactor == other.multiplierFactor && + reason == other.reason && + reasonCode == other.reasonCode && + taxCode == other.taxCode && + taxRate == other.taxRate && + additionalProperties == other.additionalProperties + } - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun description(description: JsonField) = apply { - this.description = description + private val hashCode: Int by lazy { + Objects.hash( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + additionalProperties, + ) } - /** The product code of the line item. */ - fun productCode(productCode: String?) = productCode(JsonField.ofNullable(productCode)) + override fun hashCode(): Int = hashCode - /** Alias for calling [Builder.productCode] with `productCode.orElse(null)`. */ - fun productCode(productCode: Optional) = productCode(productCode.getOrNull()) + override fun toString() = + "Allowance{amount=$amount, baseAmount=$baseAmount, multiplierFactor=$multiplierFactor, reason=$reason, reasonCode=$reasonCode, taxCode=$taxCode, taxRate=$taxRate, additionalProperties=$additionalProperties}" + } - /** - * Sets [Builder.productCode] to an arbitrary JSON value. - * - * You should usually call [Builder.productCode] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun productCode(productCode: JsonField) = apply { - this.productCode = productCode - } + /** + * The invoice line net amount (BT-131), exclusive of VAT, inclusive of line level + * allowances and charges. Calculated as: ((unit_price / price_base_quantity) * quantity) - + * allowances + charges. Must be rounded to maximum 2 decimals + */ + @JsonDeserialize(using = Amount.Deserializer::class) + @JsonSerialize(using = Amount.Serializer::class) + class Amount + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { - /** - * The quantity of items (goods or services) that is the subject of the line item. Must - * be rounded to maximum 4 decimals - */ - fun quantity(quantity: Quantity?) = quantity(JsonField.ofNullable(quantity)) + fun number(): Optional = Optional.ofNullable(number) - /** Alias for calling [Builder.quantity] with `quantity.orElse(null)`. */ - fun quantity(quantity: Optional) = quantity(quantity.getOrNull()) + fun string(): Optional = Optional.ofNullable(string) - /** - * Sets [Builder.quantity] to an arbitrary JSON value. - * - * You should usually call [Builder.quantity] with a well-typed [Quantity] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + fun isNumber(): Boolean = number != null - /** Alias for calling [quantity] with `Quantity.ofNumber(number)`. */ - fun quantity(number: Double) = quantity(Quantity.ofNumber(number)) + fun isString(): Boolean = string != null - /** Alias for calling [quantity] with `Quantity.ofString(string)`. */ - fun quantity(string: String) = quantity(Quantity.ofString(string)) + fun asNumber(): Double = number.getOrThrow("number") - /** The total VAT amount for the line item. Must be rounded to maximum 2 decimals */ - fun tax(tax: Tax?) = tax(JsonField.ofNullable(tax)) + fun asString(): String = string.getOrThrow("string") - /** Alias for calling [Builder.tax] with `tax.orElse(null)`. */ - fun tax(tax: Optional) = tax(tax.getOrNull()) + fun _json(): Optional = Optional.ofNullable(_json) - /** - * Sets [Builder.tax] to an arbitrary JSON value. - * - * You should usually call [Builder.tax] with a well-typed [Tax] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun tax(tax: JsonField) = apply { this.tax = tax } + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } - /** Alias for calling [tax] with `Tax.ofNumber(number)`. */ - fun tax(number: Double) = tax(Tax.ofNumber(number)) + private var validated: Boolean = false - /** Alias for calling [tax] with `Tax.ofString(string)`. */ - fun tax(string: String) = tax(Tax.ofString(string)) + fun validate(): Amount = apply { + if (validated) { + return@apply + } - /** The VAT rate of the line item expressed as percentage with 2 decimals */ - fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) + accept( + object : Visitor { + override fun visitNumber(number: Double) {} - /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ - fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } /** - * Sets [Builder.taxRate] to an arbitrary JSON value. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * You should usually call [Builder.taxRate] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * Used for best match union deserialization. */ - fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 - /** Unit of Measure Codes from UNECERec20 used in Peppol BIS Billing 3.0. */ - fun unit(unit: UnitOfMeasureCode?) = unit(JsonField.ofNullable(unit)) + override fun visitString(string: String) = 1 - /** Alias for calling [Builder.unit] with `unit.orElse(null)`. */ - fun unit(unit: Optional) = unit(unit.getOrNull()) + override fun unknown(json: JsonValue?) = 0 + } + ) - /** - * Sets [Builder.unit] to an arbitrary JSON value. - * - * You should usually call [Builder.unit] with a well-typed [UnitOfMeasureCode] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun unit(unit: JsonField) = apply { this.unit = unit } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** The unit price of the line item. Must be rounded to maximum 2 decimals */ - fun unitPrice(unitPrice: UnitPrice?) = unitPrice(JsonField.ofNullable(unitPrice)) + return other is Amount && number == other.number && string == other.string + } - /** Alias for calling [Builder.unitPrice] with `unitPrice.orElse(null)`. */ - fun unitPrice(unitPrice: Optional) = unitPrice(unitPrice.getOrNull()) + override fun hashCode(): Int = Objects.hash(number, string) - /** - * Sets [Builder.unitPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.unitPrice] with a well-typed [UnitPrice] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } + override fun toString(): String = + when { + number != null -> "Amount{number=$number}" + string != null -> "Amount{string=$string}" + _json != null -> "Amount{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Amount") + } - /** Alias for calling [unitPrice] with `UnitPrice.ofNumber(number)`. */ - fun unitPrice(number: Double) = unitPrice(UnitPrice.ofNumber(number)) + companion object { - /** Alias for calling [unitPrice] with `UnitPrice.ofString(string)`. */ - fun unitPrice(string: String) = unitPrice(UnitPrice.ofString(string)) + @JvmStatic fun ofNumber(number: Double) = Amount(number = number) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + @JvmStatic fun ofString(string: String) = Amount(string = string) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + /** + * An interface that defines how to map each variant of [Amount] to a value of type [T]. + */ + interface Visitor { - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } + fun visitNumber(number: Double): T - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + fun visitString(string: String): T - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + /** + * Maps an unknown variant of [Amount] to a value of type [T]. + * + * An instance of [Amount] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws EInvoiceInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw EInvoiceInvalidDataException("Unknown Amount: $json") + } } - /** - * Returns an immutable instance of [Item]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Item = - Item( - (allowances ?: JsonMissing.of()).map { it.toImmutable() }, - amount, - (charges ?: JsonMissing.of()).map { it.toImmutable() }, - date, - description, - productCode, - quantity, - tax, - taxRate, - unit, - unitPrice, - additionalProperties.toMutableMap(), - ) - } + internal class Deserializer : BaseDeserializer(Amount::class) { - private var validated: Boolean = false + override fun ObjectCodec.deserialize(node: JsonNode): Amount { + val json = JsonValue.fromJsonNode(node) - fun validate(): Item = apply { - if (validated) { - return@apply + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Amount(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Amount(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> Amount(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } } - allowances().ifPresent { it.forEach { it.validate() } } - amount().ifPresent { it.validate() } - charges().ifPresent { it.forEach { it.validate() } } - date() - description() - productCode() - quantity().ifPresent { it.validate() } - tax().ifPresent { it.validate() } - taxRate() - unit().ifPresent { it.validate() } - unitPrice().ifPresent { it.validate() } - validated = true - } + internal class Serializer : BaseSerializer(Amount::class) { - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false + override fun serialize( + value: Amount, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Amount") + } + } } + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (allowances.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (amount.asKnown().getOrNull()?.validity() ?: 0) + - (charges.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (date.asKnown().isPresent) 1 else 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (if (productCode.asKnown().isPresent) 1 else 0) + - (quantity.asKnown().getOrNull()?.validity() ?: 0) + - (tax.asKnown().getOrNull()?.validity() ?: 0) + - (if (taxRate.asKnown().isPresent) 1 else 0) + - (unit.asKnown().getOrNull()?.validity() ?: 0) + - (unitPrice.asKnown().getOrNull()?.validity() ?: 0) - - /** An allowance is a discount for example for early payment, volume discount, etc. */ - class Allowance + /** A charge is an additional fee for example for late payment, late delivery, etc. */ + class Charge @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val baseAmount: JsonField, private val multiplierFactor: JsonField, private val reason: JsonField, - private val reasonCode: JsonField, + private val reasonCode: JsonField, private val taxCode: JsonField, - private val taxRate: JsonField, + private val taxRate: JsonField, private val additionalProperties: MutableMap, ) { @@ -5653,13 +9279,13 @@ private constructor( reason: JsonField = JsonMissing.of(), @JsonProperty("reason_code") @ExcludeMissing - reasonCode: JsonField = JsonMissing.of(), + reasonCode: JsonField = JsonMissing.of(), @JsonProperty("tax_code") @ExcludeMissing taxCode: JsonField = JsonMissing.of(), @JsonProperty("tax_rate") @ExcludeMissing - taxRate: JsonField = JsonMissing.of(), + taxRate: JsonField = JsonMissing.of(), ) : this( amount, baseAmount, @@ -5672,7 +9298,7 @@ private constructor( ) /** - * The allowance amount, without VAT. Must be rounded to maximum 2 decimals + * The charge amount, without VAT. Must be rounded to maximum 2 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -5680,8 +9306,8 @@ private constructor( fun amount(): Optional = amount.getOptional("amount") /** - * The base amount that may be used, in conjunction with the allowance percentage, to - * calculate the allowance amount. Must be rounded to maximum 2 decimals + * The base amount that may be used, in conjunction with the charge percentage, to + * calculate the charge amount. Must be rounded to maximum 2 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -5689,8 +9315,8 @@ private constructor( fun baseAmount(): Optional = baseAmount.getOptional("base_amount") /** - * The percentage that may be used, in conjunction with the allowance base amount, to - * calculate the allowance amount. To state 20%, use value 20 + * The percentage that may be used, in conjunction with the charge base amount, to + * calculate the charge amount. To state 20%, use value 20 * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -5699,7 +9325,7 @@ private constructor( multiplierFactor.getOptional("multiplier_factor") /** - * The reason for the allowance + * The reason for the charge * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -5707,12 +9333,12 @@ private constructor( fun reason(): Optional = reason.getOptional("reason") /** - * The code for the allowance reason + * Charge reason codes for invoice charges and fees * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun reasonCode(): Optional = reasonCode.getOptional("reason_code") + fun reasonCode(): Optional = reasonCode.getOptional("reason_code") /** * Duty or tax or fee category codes (Subset of UNCL5305) @@ -5725,12 +9351,12 @@ private constructor( fun taxCode(): Optional = taxCode.getOptional("tax_code") /** - * The VAT rate, represented as percentage that applies to the allowance + * The VAT rate, represented as percentage that applies to the charge * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun taxRate(): Optional = taxRate.getOptional("tax_rate") + fun taxRate(): Optional = taxRate.getOptional("tax_rate") /** * Returns the raw JSON value of [amount]. @@ -5774,7 +9400,7 @@ private constructor( */ @JsonProperty("reason_code") @ExcludeMissing - fun _reasonCode(): JsonField = reasonCode + fun _reasonCode(): JsonField = reasonCode /** * Returns the raw JSON value of [taxCode]. @@ -5788,7 +9414,7 @@ private constructor( * * Unlike [taxRate], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate + @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -5804,35 +9430,35 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Allowance]. */ + /** Returns a mutable builder for constructing an instance of [Charge]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [Allowance]. */ + /** A builder for [Charge]. */ class Builder internal constructor() { private var amount: JsonField = JsonMissing.of() private var baseAmount: JsonField = JsonMissing.of() private var multiplierFactor: JsonField = JsonMissing.of() private var reason: JsonField = JsonMissing.of() - private var reasonCode: JsonField = JsonMissing.of() + private var reasonCode: JsonField = JsonMissing.of() private var taxCode: JsonField = JsonMissing.of() - private var taxRate: JsonField = JsonMissing.of() + private var taxRate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(allowance: Allowance) = apply { - amount = allowance.amount - baseAmount = allowance.baseAmount - multiplierFactor = allowance.multiplierFactor - reason = allowance.reason - reasonCode = allowance.reasonCode - taxCode = allowance.taxCode - taxRate = allowance.taxRate - additionalProperties = allowance.additionalProperties.toMutableMap() + internal fun from(charge: Charge) = apply { + amount = charge.amount + baseAmount = charge.baseAmount + multiplierFactor = charge.multiplierFactor + reason = charge.reason + reasonCode = charge.reasonCode + taxCode = charge.taxCode + taxRate = charge.taxRate + additionalProperties = charge.additionalProperties.toMutableMap() } - /** The allowance amount, without VAT. Must be rounded to maximum 2 decimals */ + /** The charge amount, without VAT. Must be rounded to maximum 2 decimals */ fun amount(amount: Amount?) = amount(JsonField.ofNullable(amount)) /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ @@ -5854,8 +9480,8 @@ private constructor( fun amount(string: String) = amount(Amount.ofString(string)) /** - * The base amount that may be used, in conjunction with the allowance percentage, - * to calculate the allowance amount. Must be rounded to maximum 2 decimals + * The base amount that may be used, in conjunction with the charge percentage, to + * calculate the charge amount. Must be rounded to maximum 2 decimals */ fun baseAmount(baseAmount: BaseAmount?) = baseAmount(JsonField.ofNullable(baseAmount)) @@ -5882,8 +9508,8 @@ private constructor( fun baseAmount(string: String) = baseAmount(BaseAmount.ofString(string)) /** - * The percentage that may be used, in conjunction with the allowance base amount, - * to calculate the allowance amount. To state 20%, use value 20 + * The percentage that may be used, in conjunction with the charge base amount, to + * calculate the charge amount. To state 20%, use value 20 */ fun multiplierFactor(multiplierFactor: MultiplierFactor?) = multiplierFactor(JsonField.ofNullable(multiplierFactor)) @@ -5918,7 +9544,7 @@ private constructor( fun multiplierFactor(string: String) = multiplierFactor(MultiplierFactor.ofString(string)) - /** The reason for the allowance */ + /** The reason for the charge */ fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ @@ -5933,20 +9559,22 @@ private constructor( */ fun reason(reason: JsonField) = apply { this.reason = reason } - /** The code for the allowance reason */ - fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) + /** Charge reason codes for invoice charges and fees */ + fun reasonCode(reasonCode: ReasonCode?) = + reasonCode(JsonField.ofNullable(reasonCode)) /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ - fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) + fun reasonCode(reasonCode: Optional) = + reasonCode(reasonCode.getOrNull()) /** * Sets [Builder.reasonCode] to an arbitrary JSON value. * - * You should usually call [Builder.reasonCode] with a well-typed [String] value + * You should usually call [Builder.reasonCode] with a well-typed [ReasonCode] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun reasonCode(reasonCode: JsonField) = apply { + fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode } @@ -5969,20 +9597,26 @@ private constructor( */ fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } - /** The VAT rate, represented as percentage that applies to the allowance */ - fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) + /** The VAT rate, represented as percentage that applies to the charge */ + fun taxRate(taxRate: TaxRate?) = taxRate(JsonField.ofNullable(taxRate)) /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ - fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) + fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) /** * Sets [Builder.taxRate] to an arbitrary JSON value. * - * You should usually call [Builder.taxRate] with a well-typed [String] value + * You should usually call [Builder.taxRate] with a well-typed [TaxRate] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } + fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } + + /** Alias for calling [taxRate] with `TaxRate.ofNumber(number)`. */ + fun taxRate(number: Double) = taxRate(TaxRate.ofNumber(number)) + + /** Alias for calling [taxRate] with `TaxRate.ofString(string)`. */ + fun taxRate(string: String) = taxRate(TaxRate.ofString(string)) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -6007,12 +9641,12 @@ private constructor( } /** - * Returns an immutable instance of [Allowance]. + * Returns an immutable instance of [Charge]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): Allowance = - Allowance( + fun build(): Charge = + Charge( amount, baseAmount, multiplierFactor, @@ -6026,7 +9660,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Allowance = apply { + fun validate(): Charge = apply { if (validated) { return@apply } @@ -6035,9 +9669,9 @@ private constructor( baseAmount().ifPresent { it.validate() } multiplierFactor().ifPresent { it.validate() } reason() - reasonCode() + reasonCode().ifPresent { it.validate() } taxCode().ifPresent { it.validate() } - taxRate() + taxRate().ifPresent { it.validate() } validated = true } @@ -6061,11 +9695,11 @@ private constructor( (baseAmount.asKnown().getOrNull()?.validity() ?: 0) + (multiplierFactor.asKnown().getOrNull()?.validity() ?: 0) + (if (reason.asKnown().isPresent) 1 else 0) + - (if (reasonCode.asKnown().isPresent) 1 else 0) + + (reasonCode.asKnown().getOrNull()?.validity() ?: 0) + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + - (if (taxRate.asKnown().isPresent) 1 else 0) + (taxRate.asKnown().getOrNull()?.validity() ?: 0) - /** The allowance amount, without VAT. Must be rounded to maximum 2 decimals */ + /** The charge amount, without VAT. Must be rounded to maximum 2 decimals */ @JsonDeserialize(using = Amount.Deserializer::class) @JsonSerialize(using = Amount.Serializer::class) class Amount @@ -6238,8 +9872,8 @@ private constructor( } /** - * The base amount that may be used, in conjunction with the allowance percentage, to - * calculate the allowance amount. Must be rounded to maximum 2 decimals + * The base amount that may be used, in conjunction with the charge percentage, to + * calculate the charge amount. Must be rounded to maximum 2 decimals */ @JsonDeserialize(using = BaseAmount.Deserializer::class) @JsonSerialize(using = BaseAmount.Serializer::class) @@ -6413,8 +10047,8 @@ private constructor( } /** - * The percentage that may be used, in conjunction with the allowance base amount, to - * calculate the allowance amount. To state 20%, use value 20 + * The percentage that may be used, in conjunction with the charge base amount, to + * calculate the charge amount. To state 20%, use value 20 */ @JsonDeserialize(using = MultiplierFactor.Deserializer::class) @JsonSerialize(using = MultiplierFactor.Serializer::class) @@ -6591,13 +10225,10 @@ private constructor( } } - /** - * Duty or tax or fee category codes (Subset of UNCL5305) - * - * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL - */ - class TaxCode @JsonCreator private constructor(private val value: JsonField) : - Enum { + /** Charge reason codes for invoice charges and fees */ + class ReasonCode + @JsonCreator + private constructor(private val value: JsonField) : Enum { /** * Returns this class instance's raw value. @@ -6611,1040 +10242,1146 @@ private constructor( companion object { - @JvmField val AE = of("AE") + @JvmField val AA = of("AA") - @JvmField val E = of("E") + @JvmField val AAA = of("AAA") - @JvmField val S = of("S") + @JvmField val AAC = of("AAC") - @JvmField val Z = of("Z") + @JvmField val AAD = of("AAD") - @JvmField val G = of("G") + @JvmField val AAE = of("AAE") - @JvmField val O = of("O") + @JvmField val AAF = of("AAF") - @JvmField val K = of("K") + @JvmField val AAH = of("AAH") - @JvmField val L = of("L") + @JvmField val AAI = of("AAI") - @JvmField val M = of("M") + @JvmField val AAS = of("AAS") - @JvmField val B = of("B") + @JvmField val AAT = of("AAT") - @JvmStatic fun of(value: String) = TaxCode(JsonField.of(value)) - } + @JvmField val AAV = of("AAV") - /** An enum containing [TaxCode]'s known values. */ - enum class Known { - AE, - E, - S, - Z, - G, - O, - K, - L, - M, - B, - } + @JvmField val AAY = of("AAY") - /** - * An enum containing [TaxCode]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [TaxCode] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AE, - E, - S, - Z, - G, - O, - K, - L, - M, - B, - /** - * An enum member indicating that [TaxCode] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + @JvmField val AAZ = of("AAZ") - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AE -> Value.AE - E -> Value.E - S -> Value.S - Z -> Value.Z - G -> Value.G - O -> Value.O - K -> Value.K - L -> Value.L - M -> Value.M - B -> Value.B - else -> Value._UNKNOWN - } + @JvmField val ABA = of("ABA") - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws EInvoiceInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AE -> Known.AE - E -> Known.E - S -> Known.S - Z -> Known.Z - G -> Known.G - O -> Known.O - K -> Known.K - L -> Known.L - M -> Known.M - B -> Known.B - else -> throw EInvoiceInvalidDataException("Unknown TaxCode: $value") - } + @JvmField val ABB = of("ABB") - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws EInvoiceInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - EInvoiceInvalidDataException("Value is not a String") - } + @JvmField val ABC = of("ABC") + + @JvmField val ABD = of("ABD") + + @JvmField val ABF = of("ABF") + + @JvmField val ABK = of("ABK") + + @JvmField val ABL = of("ABL") + + @JvmField val ABN = of("ABN") + + @JvmField val ABR = of("ABR") + + @JvmField val ABS = of("ABS") + + @JvmField val ABT = of("ABT") + + @JvmField val ABU = of("ABU") + + @JvmField val ACF = of("ACF") + + @JvmField val ACG = of("ACG") - private var validated: Boolean = false + @JvmField val ACH = of("ACH") - fun validate(): TaxCode = apply { - if (validated) { - return@apply - } + @JvmField val ACI = of("ACI") - known() - validated = true - } + @JvmField val ACJ = of("ACJ") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false - } + @JvmField val ACK = of("ACK") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JvmField val ACL = of("ACL") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JvmField val ACM = of("ACM") - return other is TaxCode && value == other.value - } + @JvmField val ACS = of("ACS") - override fun hashCode() = value.hashCode() + @JvmField val ADC = of("ADC") - override fun toString() = value.toString() - } + @JvmField val ADE = of("ADE") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JvmField val ADJ = of("ADJ") - return other is Allowance && - amount == other.amount && - baseAmount == other.baseAmount && - multiplierFactor == other.multiplierFactor && - reason == other.reason && - reasonCode == other.reasonCode && - taxCode == other.taxCode && - taxRate == other.taxRate && - additionalProperties == other.additionalProperties - } + @JvmField val ADK = of("ADK") - private val hashCode: Int by lazy { - Objects.hash( - amount, - baseAmount, - multiplierFactor, - reason, - reasonCode, - taxCode, - taxRate, - additionalProperties, - ) - } + @JvmField val ADL = of("ADL") - override fun hashCode(): Int = hashCode + @JvmField val ADM = of("ADM") - override fun toString() = - "Allowance{amount=$amount, baseAmount=$baseAmount, multiplierFactor=$multiplierFactor, reason=$reason, reasonCode=$reasonCode, taxCode=$taxCode, taxRate=$taxRate, additionalProperties=$additionalProperties}" - } + @JvmField val ADN = of("ADN") - /** - * The total amount of the line item, exclusive of VAT, after subtracting line level - * allowances and adding line level charges. Must be rounded to maximum 2 decimals - */ - @JsonDeserialize(using = Amount.Deserializer::class) - @JsonSerialize(using = Amount.Serializer::class) - class Amount - private constructor( - private val number: Double? = null, - private val string: String? = null, - private val _json: JsonValue? = null, - ) { + @JvmField val ADO = of("ADO") - fun number(): Optional = Optional.ofNullable(number) + @JvmField val ADP = of("ADP") - fun string(): Optional = Optional.ofNullable(string) + @JvmField val ADQ = of("ADQ") - fun isNumber(): Boolean = number != null + @JvmField val ADR = of("ADR") - fun isString(): Boolean = string != null + @JvmField val ADT = of("ADT") - fun asNumber(): Double = number.getOrThrow("number") + @JvmField val ADW = of("ADW") - fun asString(): String = string.getOrThrow("string") + @JvmField val ADY = of("ADY") - fun _json(): Optional = Optional.ofNullable(_json) + @JvmField val ADZ = of("ADZ") - fun accept(visitor: Visitor): T = - when { - number != null -> visitor.visitNumber(number) - string != null -> visitor.visitString(string) - else -> visitor.unknown(_json) - } + @JvmField val AEA = of("AEA") - private var validated: Boolean = false + @JvmField val AEB = of("AEB") - fun validate(): Amount = apply { - if (validated) { - return@apply - } + @JvmField val AEC = of("AEC") - accept( - object : Visitor { - override fun visitNumber(number: Double) {} + @JvmField val AED = of("AED") - override fun visitString(string: String) {} - } - ) - validated = true - } + @JvmField val AEF = of("AEF") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false - } + @JvmField val AEH = of("AEH") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitNumber(number: Double) = 1 + @JvmField val AEI = of("AEI") - override fun visitString(string: String) = 1 + @JvmField val AEJ = of("AEJ") - override fun unknown(json: JsonValue?) = 0 - } - ) + @JvmField val AEK = of("AEK") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JvmField val AEL = of("AEL") - return other is Amount && number == other.number && string == other.string - } + @JvmField val AEM = of("AEM") - override fun hashCode(): Int = Objects.hash(number, string) + @JvmField val AEN = of("AEN") - override fun toString(): String = - when { - number != null -> "Amount{number=$number}" - string != null -> "Amount{string=$string}" - _json != null -> "Amount{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Amount") - } + @JvmField val AEO = of("AEO") - companion object { + @JvmField val AEP = of("AEP") - @JvmStatic fun ofNumber(number: Double) = Amount(number = number) + @JvmField val AES = of("AES") - @JvmStatic fun ofString(string: String) = Amount(string = string) - } + @JvmField val AET = of("AET") - /** - * An interface that defines how to map each variant of [Amount] to a value of type [T]. - */ - interface Visitor { + @JvmField val AEU = of("AEU") - fun visitNumber(number: Double): T + @JvmField val AEV = of("AEV") - fun visitString(string: String): T + @JvmField val AEW = of("AEW") - /** - * Maps an unknown variant of [Amount] to a value of type [T]. - * - * An instance of [Amount] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws EInvoiceInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw EInvoiceInvalidDataException("Unknown Amount: $json") - } - } + @JvmField val AEX = of("AEX") - internal class Deserializer : BaseDeserializer(Amount::class) { + @JvmField val AEY = of("AEY") - override fun ObjectCodec.deserialize(node: JsonNode): Amount { - val json = JsonValue.fromJsonNode(node) + @JvmField val AEZ = of("AEZ") - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Amount(number = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Amount(string = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from object). - 0 -> Amount(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the - // first completely valid match, or simply the first match if none are - // completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } + @JvmField val AJ = of("AJ") - internal class Serializer : BaseSerializer(Amount::class) { + @JvmField val AU = of("AU") - override fun serialize( - value: Amount, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.number != null -> generator.writeObject(value.number) - value.string != null -> generator.writeObject(value.string) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Amount") - } - } - } - } + @JvmField val CA = of("CA") - /** A charge is an additional fee for example for late payment, late delivery, etc. */ - class Charge - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val amount: JsonField, - private val baseAmount: JsonField, - private val multiplierFactor: JsonField, - private val reason: JsonField, - private val reasonCode: JsonField, - private val taxCode: JsonField, - private val taxRate: JsonField, - private val additionalProperties: MutableMap, - ) { + @JvmField val CAB = of("CAB") - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - amount: JsonField = JsonMissing.of(), - @JsonProperty("base_amount") - @ExcludeMissing - baseAmount: JsonField = JsonMissing.of(), - @JsonProperty("multiplier_factor") - @ExcludeMissing - multiplierFactor: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - reason: JsonField = JsonMissing.of(), - @JsonProperty("reason_code") - @ExcludeMissing - reasonCode: JsonField = JsonMissing.of(), - @JsonProperty("tax_code") - @ExcludeMissing - taxCode: JsonField = JsonMissing.of(), - @JsonProperty("tax_rate") - @ExcludeMissing - taxRate: JsonField = JsonMissing.of(), - ) : this( - amount, - baseAmount, - multiplierFactor, - reason, - reasonCode, - taxCode, - taxRate, - mutableMapOf(), - ) + @JvmField val CAD = of("CAD") - /** - * The charge amount, without VAT. Must be rounded to maximum 2 decimals - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") + @JvmField val CAE = of("CAE") - /** - * The base amount that may be used, in conjunction with the charge percentage, to - * calculate the charge amount. Must be rounded to maximum 2 decimals - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun baseAmount(): Optional = baseAmount.getOptional("base_amount") + @JvmField val CAF = of("CAF") - /** - * The percentage that may be used, in conjunction with the charge base amount, to - * calculate the charge amount. To state 20%, use value 20 - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun multiplierFactor(): Optional = - multiplierFactor.getOptional("multiplier_factor") + @JvmField val CAI = of("CAI") - /** - * The reason for the charge - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun reason(): Optional = reason.getOptional("reason") + @JvmField val CAJ = of("CAJ") - /** - * The code for the charge reason - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun reasonCode(): Optional = reasonCode.getOptional("reason_code") + @JvmField val CAK = of("CAK") - /** - * Duty or tax or fee category codes (Subset of UNCL5305) - * - * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun taxCode(): Optional = taxCode.getOptional("tax_code") + @JvmField val CAL = of("CAL") - /** - * The VAT rate, represented as percentage that applies to the charge - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun taxRate(): Optional = taxRate.getOptional("tax_rate") + @JvmField val CAM = of("CAM") - /** - * Returns the raw JSON value of [amount]. - * - * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + @JvmField val CAN = of("CAN") - /** - * Returns the raw JSON value of [baseAmount]. - * - * Unlike [baseAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("base_amount") - @ExcludeMissing - fun _baseAmount(): JsonField = baseAmount + @JvmField val CAO = of("CAO") - /** - * Returns the raw JSON value of [multiplierFactor]. - * - * Unlike [multiplierFactor], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("multiplier_factor") - @ExcludeMissing - fun _multiplierFactor(): JsonField = multiplierFactor + @JvmField val CAP = of("CAP") - /** - * Returns the raw JSON value of [reason]. - * - * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason + @JvmField val CAQ = of("CAQ") - /** - * Returns the raw JSON value of [reasonCode]. - * - * Unlike [reasonCode], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("reason_code") - @ExcludeMissing - fun _reasonCode(): JsonField = reasonCode + @JvmField val CAR = of("CAR") - /** - * Returns the raw JSON value of [taxCode]. - * - * Unlike [taxCode], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tax_code") @ExcludeMissing fun _taxCode(): JsonField = taxCode + @JvmField val CAS = of("CAS") - /** - * Returns the raw JSON value of [taxRate]. - * - * Unlike [taxRate], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate + @JvmField val CAT = of("CAT") - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + @JvmField val CAU = of("CAU") - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + @JvmField val CAV = of("CAV") - fun toBuilder() = Builder().from(this) + @JvmField val CAW = of("CAW") - companion object { + @JvmField val CAX = of("CAX") - /** Returns a mutable builder for constructing an instance of [Charge]. */ - @JvmStatic fun builder() = Builder() - } + @JvmField val CAY = of("CAY") - /** A builder for [Charge]. */ - class Builder internal constructor() { + @JvmField val CAZ = of("CAZ") - private var amount: JsonField = JsonMissing.of() - private var baseAmount: JsonField = JsonMissing.of() - private var multiplierFactor: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() - private var reasonCode: JsonField = JsonMissing.of() - private var taxCode: JsonField = JsonMissing.of() - private var taxRate: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val CD = of("CD") - @JvmSynthetic - internal fun from(charge: Charge) = apply { - amount = charge.amount - baseAmount = charge.baseAmount - multiplierFactor = charge.multiplierFactor - reason = charge.reason - reasonCode = charge.reasonCode - taxCode = charge.taxCode - taxRate = charge.taxRate - additionalProperties = charge.additionalProperties.toMutableMap() - } + @JvmField val CG = of("CG") - /** The charge amount, without VAT. Must be rounded to maximum 2 decimals */ - fun amount(amount: Amount?) = amount(JsonField.ofNullable(amount)) + @JvmField val CS = of("CS") - /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ - fun amount(amount: Optional) = amount(amount.getOrNull()) + @JvmField val CT = of("CT") - /** - * Sets [Builder.amount] to an arbitrary JSON value. - * - * You should usually call [Builder.amount] with a well-typed [Amount] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } + @JvmField val DAB = of("DAB") - /** Alias for calling [amount] with `Amount.ofNumber(number)`. */ - fun amount(number: Double) = amount(Amount.ofNumber(number)) + @JvmField val DAC = of("DAC") - /** Alias for calling [amount] with `Amount.ofString(string)`. */ - fun amount(string: String) = amount(Amount.ofString(string)) + @JvmField val DAD = of("DAD") - /** - * The base amount that may be used, in conjunction with the charge percentage, to - * calculate the charge amount. Must be rounded to maximum 2 decimals - */ - fun baseAmount(baseAmount: BaseAmount?) = - baseAmount(JsonField.ofNullable(baseAmount)) + @JvmField val DAF = of("DAF") - /** Alias for calling [Builder.baseAmount] with `baseAmount.orElse(null)`. */ - fun baseAmount(baseAmount: Optional) = - baseAmount(baseAmount.getOrNull()) + @JvmField val DAG = of("DAG") - /** - * Sets [Builder.baseAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.baseAmount] with a well-typed [BaseAmount] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun baseAmount(baseAmount: JsonField) = apply { - this.baseAmount = baseAmount - } + @JvmField val DAH = of("DAH") - /** Alias for calling [baseAmount] with `BaseAmount.ofNumber(number)`. */ - fun baseAmount(number: Double) = baseAmount(BaseAmount.ofNumber(number)) + @JvmField val DAI = of("DAI") - /** Alias for calling [baseAmount] with `BaseAmount.ofString(string)`. */ - fun baseAmount(string: String) = baseAmount(BaseAmount.ofString(string)) + @JvmField val DAJ = of("DAJ") - /** - * The percentage that may be used, in conjunction with the charge base amount, to - * calculate the charge amount. To state 20%, use value 20 - */ - fun multiplierFactor(multiplierFactor: MultiplierFactor?) = - multiplierFactor(JsonField.ofNullable(multiplierFactor)) + @JvmField val DAK = of("DAK") - /** - * Alias for calling [Builder.multiplierFactor] with - * `multiplierFactor.orElse(null)`. - */ - fun multiplierFactor(multiplierFactor: Optional) = - multiplierFactor(multiplierFactor.getOrNull()) + @JvmField val DAL = of("DAL") - /** - * Sets [Builder.multiplierFactor] to an arbitrary JSON value. - * - * You should usually call [Builder.multiplierFactor] with a well-typed - * [MultiplierFactor] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun multiplierFactor(multiplierFactor: JsonField) = apply { - this.multiplierFactor = multiplierFactor - } + @JvmField val DAM = of("DAM") - /** - * Alias for calling [multiplierFactor] with `MultiplierFactor.ofNumber(number)`. - */ - fun multiplierFactor(number: Double) = - multiplierFactor(MultiplierFactor.ofNumber(number)) + @JvmField val DAN = of("DAN") - /** - * Alias for calling [multiplierFactor] with `MultiplierFactor.ofString(string)`. - */ - fun multiplierFactor(string: String) = - multiplierFactor(MultiplierFactor.ofString(string)) + @JvmField val DAO = of("DAO") - /** The reason for the charge */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + @JvmField val DAP = of("DAP") - /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ - fun reason(reason: Optional) = reason(reason.getOrNull()) + @JvmField val DAQ = of("DAQ") - /** - * Sets [Builder.reason] to an arbitrary JSON value. - * - * You should usually call [Builder.reason] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun reason(reason: JsonField) = apply { this.reason = reason } + @JvmField val DL = of("DL") - /** The code for the charge reason */ - fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) + @JvmField val EG = of("EG") - /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ - fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) + @JvmField val EP = of("EP") - /** - * Sets [Builder.reasonCode] to an arbitrary JSON value. - * - * You should usually call [Builder.reasonCode] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun reasonCode(reasonCode: JsonField) = apply { - this.reasonCode = reasonCode - } + @JvmField val ER = of("ER") - /** - * Duty or tax or fee category codes (Subset of UNCL5305) - * - * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL - */ - fun taxCode(taxCode: TaxCode?) = taxCode(JsonField.ofNullable(taxCode)) + @JvmField val FAA = of("FAA") - /** Alias for calling [Builder.taxCode] with `taxCode.orElse(null)`. */ - fun taxCode(taxCode: Optional) = taxCode(taxCode.getOrNull()) + @JvmField val FAB = of("FAB") - /** - * Sets [Builder.taxCode] to an arbitrary JSON value. - * - * You should usually call [Builder.taxCode] with a well-typed [TaxCode] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } + @JvmField val FAC = of("FAC") - /** The VAT rate, represented as percentage that applies to the charge */ - fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) + @JvmField val FC = of("FC") - /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ - fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) + @JvmField val FH = of("FH") - /** - * Sets [Builder.taxRate] to an arbitrary JSON value. - * - * You should usually call [Builder.taxRate] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } + @JvmField val FI = of("FI") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JvmField val GAA = of("GAA") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JvmField val HAA = of("HAA") - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + @JvmField val HD = of("HD") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JvmField val HH = of("HH") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JvmField val IAA = of("IAA") + + @JvmField val IAB = of("IAB") + + @JvmField val ID = of("ID") + + @JvmField val IF = of("IF") + + @JvmField val IR = of("IR") + + @JvmField val IS = of("IS") + + @JvmField val KO = of("KO") - /** - * Returns an immutable instance of [Charge]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Charge = - Charge( - amount, - baseAmount, - multiplierFactor, - reason, - reasonCode, - taxCode, - taxRate, - additionalProperties.toMutableMap(), - ) - } + @JvmField val L1 = of("L1") - private var validated: Boolean = false + @JvmField val LA = of("LA") - fun validate(): Charge = apply { - if (validated) { - return@apply - } + @JvmField val LAA = of("LAA") - amount().ifPresent { it.validate() } - baseAmount().ifPresent { it.validate() } - multiplierFactor().ifPresent { it.validate() } - reason() - reasonCode() - taxCode().ifPresent { it.validate() } - taxRate() - validated = true - } + @JvmField val LAB = of("LAB") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false - } + @JvmField val LF = of("LF") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (amount.asKnown().getOrNull()?.validity() ?: 0) + - (baseAmount.asKnown().getOrNull()?.validity() ?: 0) + - (multiplierFactor.asKnown().getOrNull()?.validity() ?: 0) + - (if (reason.asKnown().isPresent) 1 else 0) + - (if (reasonCode.asKnown().isPresent) 1 else 0) + - (taxCode.asKnown().getOrNull()?.validity() ?: 0) + - (if (taxRate.asKnown().isPresent) 1 else 0) + @JvmField val MAE = of("MAE") - /** The charge amount, without VAT. Must be rounded to maximum 2 decimals */ - @JsonDeserialize(using = Amount.Deserializer::class) - @JsonSerialize(using = Amount.Serializer::class) - class Amount - private constructor( - private val number: Double? = null, - private val string: String? = null, - private val _json: JsonValue? = null, - ) { + @JvmField val MI = of("MI") - fun number(): Optional = Optional.ofNullable(number) + @JvmField val ML = of("ML") - fun string(): Optional = Optional.ofNullable(string) + @JvmField val NAA = of("NAA") - fun isNumber(): Boolean = number != null + @JvmField val OA = of("OA") - fun isString(): Boolean = string != null + @JvmField val PA = of("PA") - fun asNumber(): Double = number.getOrThrow("number") + @JvmField val PAA = of("PAA") - fun asString(): String = string.getOrThrow("string") + @JvmField val PC = of("PC") - fun _json(): Optional = Optional.ofNullable(_json) + @JvmField val PL = of("PL") - fun accept(visitor: Visitor): T = - when { - number != null -> visitor.visitNumber(number) - string != null -> visitor.visitString(string) - else -> visitor.unknown(_json) - } + @JvmField val PRV = of("PRV") - private var validated: Boolean = false + @JvmField val RAB = of("RAB") - fun validate(): Amount = apply { - if (validated) { - return@apply - } + @JvmField val RAC = of("RAC") - accept( - object : Visitor { - override fun visitNumber(number: Double) {} + @JvmField val RAD = of("RAD") - override fun visitString(string: String) {} - } - ) - validated = true - } + @JvmField val RAF = of("RAF") - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false - } + @JvmField val RE = of("RE") - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitNumber(number: Double) = 1 + @JvmField val RF = of("RF") - override fun visitString(string: String) = 1 + @JvmField val RH = of("RH") - override fun unknown(json: JsonValue?) = 0 - } - ) + @JvmField val RV = of("RV") - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JvmField val SA = of("SA") - return other is Amount && number == other.number && string == other.string - } + @JvmField val SAA = of("SAA") - override fun hashCode(): Int = Objects.hash(number, string) + @JvmField val SAD = of("SAD") - override fun toString(): String = - when { - number != null -> "Amount{number=$number}" - string != null -> "Amount{string=$string}" - _json != null -> "Amount{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Amount") - } + @JvmField val SAE = of("SAE") - companion object { + @JvmField val SAI = of("SAI") - @JvmStatic fun ofNumber(number: Double) = Amount(number = number) + @JvmField val SG = of("SG") - @JvmStatic fun ofString(string: String) = Amount(string = string) - } + @JvmField val SH = of("SH") - /** - * An interface that defines how to map each variant of [Amount] to a value of type - * [T]. - */ - interface Visitor { + @JvmField val SM = of("SM") - fun visitNumber(number: Double): T + @JvmField val SU = of("SU") - fun visitString(string: String): T + @JvmField val TAB = of("TAB") - /** - * Maps an unknown variant of [Amount] to a value of type [T]. - * - * An instance of [Amount] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on - * an older version than the API, then the API may respond with new variants - * that the SDK is unaware of. - * - * @throws EInvoiceInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw EInvoiceInvalidDataException("Unknown Amount: $json") - } - } + @JvmField val TAC = of("TAC") - internal class Deserializer : BaseDeserializer(Amount::class) { + @JvmField val TT = of("TT") - override fun ObjectCodec.deserialize(node: JsonNode): Amount { - val json = JsonValue.fromJsonNode(node) + @JvmField val TV = of("TV") - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Amount(number = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Amount(string = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely - // incompatible with all the possible variants (e.g. deserializing from - // object). - 0 -> Amount(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use - // the first completely valid match, or simply the first match if none - // are completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } + @JvmField val V1 = of("V1") - internal class Serializer : BaseSerializer(Amount::class) { + @JvmField val V2 = of("V2") - override fun serialize( - value: Amount, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.number != null -> generator.writeObject(value.number) - value.string != null -> generator.writeObject(value.string) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Amount") - } - } - } - } + @JvmField val WH = of("WH") - /** - * The base amount that may be used, in conjunction with the charge percentage, to - * calculate the charge amount. Must be rounded to maximum 2 decimals - */ - @JsonDeserialize(using = BaseAmount.Deserializer::class) - @JsonSerialize(using = BaseAmount.Serializer::class) - class BaseAmount - private constructor( - private val number: Double? = null, - private val string: String? = null, - private val _json: JsonValue? = null, - ) { + @JvmField val XAA = of("XAA") - fun number(): Optional = Optional.ofNullable(number) + @JvmField val YY = of("YY") - fun string(): Optional = Optional.ofNullable(string) + @JvmField val ZZZ = of("ZZZ") - fun isNumber(): Boolean = number != null + @JvmStatic fun of(value: String) = ReasonCode(JsonField.of(value)) + } - fun isString(): Boolean = string != null + /** An enum containing [ReasonCode]'s known values. */ + enum class Known { + AA, + AAA, + AAC, + AAD, + AAE, + AAF, + AAH, + AAI, + AAS, + AAT, + AAV, + AAY, + AAZ, + ABA, + ABB, + ABC, + ABD, + ABF, + ABK, + ABL, + ABN, + ABR, + ABS, + ABT, + ABU, + ACF, + ACG, + ACH, + ACI, + ACJ, + ACK, + ACL, + ACM, + ACS, + ADC, + ADE, + ADJ, + ADK, + ADL, + ADM, + ADN, + ADO, + ADP, + ADQ, + ADR, + ADT, + ADW, + ADY, + ADZ, + AEA, + AEB, + AEC, + AED, + AEF, + AEH, + AEI, + AEJ, + AEK, + AEL, + AEM, + AEN, + AEO, + AEP, + AES, + AET, + AEU, + AEV, + AEW, + AEX, + AEY, + AEZ, + AJ, + AU, + CA, + CAB, + CAD, + CAE, + CAF, + CAI, + CAJ, + CAK, + CAL, + CAM, + CAN, + CAO, + CAP, + CAQ, + CAR, + CAS, + CAT, + CAU, + CAV, + CAW, + CAX, + CAY, + CAZ, + CD, + CG, + CS, + CT, + DAB, + DAC, + DAD, + DAF, + DAG, + DAH, + DAI, + DAJ, + DAK, + DAL, + DAM, + DAN, + DAO, + DAP, + DAQ, + DL, + EG, + EP, + ER, + FAA, + FAB, + FAC, + FC, + FH, + FI, + GAA, + HAA, + HD, + HH, + IAA, + IAB, + ID, + IF, + IR, + IS, + KO, + L1, + LA, + LAA, + LAB, + LF, + MAE, + MI, + ML, + NAA, + OA, + PA, + PAA, + PC, + PL, + PRV, + RAB, + RAC, + RAD, + RAF, + RE, + RF, + RH, + RV, + SA, + SAA, + SAD, + SAE, + SAI, + SG, + SH, + SM, + SU, + TAB, + TAC, + TT, + TV, + V1, + V2, + WH, + XAA, + YY, + ZZZ, + } - fun asNumber(): Double = number.getOrThrow("number") + /** + * An enum containing [ReasonCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ReasonCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AA, + AAA, + AAC, + AAD, + AAE, + AAF, + AAH, + AAI, + AAS, + AAT, + AAV, + AAY, + AAZ, + ABA, + ABB, + ABC, + ABD, + ABF, + ABK, + ABL, + ABN, + ABR, + ABS, + ABT, + ABU, + ACF, + ACG, + ACH, + ACI, + ACJ, + ACK, + ACL, + ACM, + ACS, + ADC, + ADE, + ADJ, + ADK, + ADL, + ADM, + ADN, + ADO, + ADP, + ADQ, + ADR, + ADT, + ADW, + ADY, + ADZ, + AEA, + AEB, + AEC, + AED, + AEF, + AEH, + AEI, + AEJ, + AEK, + AEL, + AEM, + AEN, + AEO, + AEP, + AES, + AET, + AEU, + AEV, + AEW, + AEX, + AEY, + AEZ, + AJ, + AU, + CA, + CAB, + CAD, + CAE, + CAF, + CAI, + CAJ, + CAK, + CAL, + CAM, + CAN, + CAO, + CAP, + CAQ, + CAR, + CAS, + CAT, + CAU, + CAV, + CAW, + CAX, + CAY, + CAZ, + CD, + CG, + CS, + CT, + DAB, + DAC, + DAD, + DAF, + DAG, + DAH, + DAI, + DAJ, + DAK, + DAL, + DAM, + DAN, + DAO, + DAP, + DAQ, + DL, + EG, + EP, + ER, + FAA, + FAB, + FAC, + FC, + FH, + FI, + GAA, + HAA, + HD, + HH, + IAA, + IAB, + ID, + IF, + IR, + IS, + KO, + L1, + LA, + LAA, + LAB, + LF, + MAE, + MI, + ML, + NAA, + OA, + PA, + PAA, + PC, + PL, + PRV, + RAB, + RAC, + RAD, + RAF, + RE, + RF, + RH, + RV, + SA, + SAA, + SAD, + SAE, + SAI, + SG, + SH, + SM, + SU, + TAB, + TAC, + TT, + TV, + V1, + V2, + WH, + XAA, + YY, + ZZZ, + /** + * An enum member indicating that [ReasonCode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - fun asString(): String = string.getOrThrow("string") + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AA -> Value.AA + AAA -> Value.AAA + AAC -> Value.AAC + AAD -> Value.AAD + AAE -> Value.AAE + AAF -> Value.AAF + AAH -> Value.AAH + AAI -> Value.AAI + AAS -> Value.AAS + AAT -> Value.AAT + AAV -> Value.AAV + AAY -> Value.AAY + AAZ -> Value.AAZ + ABA -> Value.ABA + ABB -> Value.ABB + ABC -> Value.ABC + ABD -> Value.ABD + ABF -> Value.ABF + ABK -> Value.ABK + ABL -> Value.ABL + ABN -> Value.ABN + ABR -> Value.ABR + ABS -> Value.ABS + ABT -> Value.ABT + ABU -> Value.ABU + ACF -> Value.ACF + ACG -> Value.ACG + ACH -> Value.ACH + ACI -> Value.ACI + ACJ -> Value.ACJ + ACK -> Value.ACK + ACL -> Value.ACL + ACM -> Value.ACM + ACS -> Value.ACS + ADC -> Value.ADC + ADE -> Value.ADE + ADJ -> Value.ADJ + ADK -> Value.ADK + ADL -> Value.ADL + ADM -> Value.ADM + ADN -> Value.ADN + ADO -> Value.ADO + ADP -> Value.ADP + ADQ -> Value.ADQ + ADR -> Value.ADR + ADT -> Value.ADT + ADW -> Value.ADW + ADY -> Value.ADY + ADZ -> Value.ADZ + AEA -> Value.AEA + AEB -> Value.AEB + AEC -> Value.AEC + AED -> Value.AED + AEF -> Value.AEF + AEH -> Value.AEH + AEI -> Value.AEI + AEJ -> Value.AEJ + AEK -> Value.AEK + AEL -> Value.AEL + AEM -> Value.AEM + AEN -> Value.AEN + AEO -> Value.AEO + AEP -> Value.AEP + AES -> Value.AES + AET -> Value.AET + AEU -> Value.AEU + AEV -> Value.AEV + AEW -> Value.AEW + AEX -> Value.AEX + AEY -> Value.AEY + AEZ -> Value.AEZ + AJ -> Value.AJ + AU -> Value.AU + CA -> Value.CA + CAB -> Value.CAB + CAD -> Value.CAD + CAE -> Value.CAE + CAF -> Value.CAF + CAI -> Value.CAI + CAJ -> Value.CAJ + CAK -> Value.CAK + CAL -> Value.CAL + CAM -> Value.CAM + CAN -> Value.CAN + CAO -> Value.CAO + CAP -> Value.CAP + CAQ -> Value.CAQ + CAR -> Value.CAR + CAS -> Value.CAS + CAT -> Value.CAT + CAU -> Value.CAU + CAV -> Value.CAV + CAW -> Value.CAW + CAX -> Value.CAX + CAY -> Value.CAY + CAZ -> Value.CAZ + CD -> Value.CD + CG -> Value.CG + CS -> Value.CS + CT -> Value.CT + DAB -> Value.DAB + DAC -> Value.DAC + DAD -> Value.DAD + DAF -> Value.DAF + DAG -> Value.DAG + DAH -> Value.DAH + DAI -> Value.DAI + DAJ -> Value.DAJ + DAK -> Value.DAK + DAL -> Value.DAL + DAM -> Value.DAM + DAN -> Value.DAN + DAO -> Value.DAO + DAP -> Value.DAP + DAQ -> Value.DAQ + DL -> Value.DL + EG -> Value.EG + EP -> Value.EP + ER -> Value.ER + FAA -> Value.FAA + FAB -> Value.FAB + FAC -> Value.FAC + FC -> Value.FC + FH -> Value.FH + FI -> Value.FI + GAA -> Value.GAA + HAA -> Value.HAA + HD -> Value.HD + HH -> Value.HH + IAA -> Value.IAA + IAB -> Value.IAB + ID -> Value.ID + IF -> Value.IF + IR -> Value.IR + IS -> Value.IS + KO -> Value.KO + L1 -> Value.L1 + LA -> Value.LA + LAA -> Value.LAA + LAB -> Value.LAB + LF -> Value.LF + MAE -> Value.MAE + MI -> Value.MI + ML -> Value.ML + NAA -> Value.NAA + OA -> Value.OA + PA -> Value.PA + PAA -> Value.PAA + PC -> Value.PC + PL -> Value.PL + PRV -> Value.PRV + RAB -> Value.RAB + RAC -> Value.RAC + RAD -> Value.RAD + RAF -> Value.RAF + RE -> Value.RE + RF -> Value.RF + RH -> Value.RH + RV -> Value.RV + SA -> Value.SA + SAA -> Value.SAA + SAD -> Value.SAD + SAE -> Value.SAE + SAI -> Value.SAI + SG -> Value.SG + SH -> Value.SH + SM -> Value.SM + SU -> Value.SU + TAB -> Value.TAB + TAC -> Value.TAC + TT -> Value.TT + TV -> Value.TV + V1 -> Value.V1 + V2 -> Value.V2 + WH -> Value.WH + XAA -> Value.XAA + YY -> Value.YY + ZZZ -> Value.ZZZ + else -> Value._UNKNOWN + } - fun _json(): Optional = Optional.ofNullable(_json) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + AA -> Known.AA + AAA -> Known.AAA + AAC -> Known.AAC + AAD -> Known.AAD + AAE -> Known.AAE + AAF -> Known.AAF + AAH -> Known.AAH + AAI -> Known.AAI + AAS -> Known.AAS + AAT -> Known.AAT + AAV -> Known.AAV + AAY -> Known.AAY + AAZ -> Known.AAZ + ABA -> Known.ABA + ABB -> Known.ABB + ABC -> Known.ABC + ABD -> Known.ABD + ABF -> Known.ABF + ABK -> Known.ABK + ABL -> Known.ABL + ABN -> Known.ABN + ABR -> Known.ABR + ABS -> Known.ABS + ABT -> Known.ABT + ABU -> Known.ABU + ACF -> Known.ACF + ACG -> Known.ACG + ACH -> Known.ACH + ACI -> Known.ACI + ACJ -> Known.ACJ + ACK -> Known.ACK + ACL -> Known.ACL + ACM -> Known.ACM + ACS -> Known.ACS + ADC -> Known.ADC + ADE -> Known.ADE + ADJ -> Known.ADJ + ADK -> Known.ADK + ADL -> Known.ADL + ADM -> Known.ADM + ADN -> Known.ADN + ADO -> Known.ADO + ADP -> Known.ADP + ADQ -> Known.ADQ + ADR -> Known.ADR + ADT -> Known.ADT + ADW -> Known.ADW + ADY -> Known.ADY + ADZ -> Known.ADZ + AEA -> Known.AEA + AEB -> Known.AEB + AEC -> Known.AEC + AED -> Known.AED + AEF -> Known.AEF + AEH -> Known.AEH + AEI -> Known.AEI + AEJ -> Known.AEJ + AEK -> Known.AEK + AEL -> Known.AEL + AEM -> Known.AEM + AEN -> Known.AEN + AEO -> Known.AEO + AEP -> Known.AEP + AES -> Known.AES + AET -> Known.AET + AEU -> Known.AEU + AEV -> Known.AEV + AEW -> Known.AEW + AEX -> Known.AEX + AEY -> Known.AEY + AEZ -> Known.AEZ + AJ -> Known.AJ + AU -> Known.AU + CA -> Known.CA + CAB -> Known.CAB + CAD -> Known.CAD + CAE -> Known.CAE + CAF -> Known.CAF + CAI -> Known.CAI + CAJ -> Known.CAJ + CAK -> Known.CAK + CAL -> Known.CAL + CAM -> Known.CAM + CAN -> Known.CAN + CAO -> Known.CAO + CAP -> Known.CAP + CAQ -> Known.CAQ + CAR -> Known.CAR + CAS -> Known.CAS + CAT -> Known.CAT + CAU -> Known.CAU + CAV -> Known.CAV + CAW -> Known.CAW + CAX -> Known.CAX + CAY -> Known.CAY + CAZ -> Known.CAZ + CD -> Known.CD + CG -> Known.CG + CS -> Known.CS + CT -> Known.CT + DAB -> Known.DAB + DAC -> Known.DAC + DAD -> Known.DAD + DAF -> Known.DAF + DAG -> Known.DAG + DAH -> Known.DAH + DAI -> Known.DAI + DAJ -> Known.DAJ + DAK -> Known.DAK + DAL -> Known.DAL + DAM -> Known.DAM + DAN -> Known.DAN + DAO -> Known.DAO + DAP -> Known.DAP + DAQ -> Known.DAQ + DL -> Known.DL + EG -> Known.EG + EP -> Known.EP + ER -> Known.ER + FAA -> Known.FAA + FAB -> Known.FAB + FAC -> Known.FAC + FC -> Known.FC + FH -> Known.FH + FI -> Known.FI + GAA -> Known.GAA + HAA -> Known.HAA + HD -> Known.HD + HH -> Known.HH + IAA -> Known.IAA + IAB -> Known.IAB + ID -> Known.ID + IF -> Known.IF + IR -> Known.IR + IS -> Known.IS + KO -> Known.KO + L1 -> Known.L1 + LA -> Known.LA + LAA -> Known.LAA + LAB -> Known.LAB + LF -> Known.LF + MAE -> Known.MAE + MI -> Known.MI + ML -> Known.ML + NAA -> Known.NAA + OA -> Known.OA + PA -> Known.PA + PAA -> Known.PAA + PC -> Known.PC + PL -> Known.PL + PRV -> Known.PRV + RAB -> Known.RAB + RAC -> Known.RAC + RAD -> Known.RAD + RAF -> Known.RAF + RE -> Known.RE + RF -> Known.RF + RH -> Known.RH + RV -> Known.RV + SA -> Known.SA + SAA -> Known.SAA + SAD -> Known.SAD + SAE -> Known.SAE + SAI -> Known.SAI + SG -> Known.SG + SH -> Known.SH + SM -> Known.SM + SU -> Known.SU + TAB -> Known.TAB + TAC -> Known.TAC + TT -> Known.TT + TV -> Known.TV + V1 -> Known.V1 + V2 -> Known.V2 + WH -> Known.WH + XAA -> Known.XAA + YY -> Known.YY + ZZZ -> Known.ZZZ + else -> throw EInvoiceInvalidDataException("Unknown ReasonCode: $value") + } - fun accept(visitor: Visitor): T = - when { - number != null -> visitor.visitNumber(number) - string != null -> visitor.visitString(string) - else -> visitor.unknown(_json) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") } private var validated: Boolean = false - fun validate(): BaseAmount = apply { + fun validate(): ReasonCode = apply { if (validated) { return@apply } - accept( - object : Visitor { - override fun visitNumber(number: Double) {} - - override fun visitString(string: String) {} - } - ) + known() validated = true } @@ -7662,123 +11399,209 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitNumber(number: Double) = 1 - - override fun visitString(string: String) = 1 - - override fun unknown(json: JsonValue?) = 0 - } - ) + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is BaseAmount && number == other.number && string == other.string + return other is ReasonCode && value == other.value } - override fun hashCode(): Int = Objects.hash(number, string) + override fun hashCode() = value.hashCode() - override fun toString(): String = - when { - number != null -> "BaseAmount{number=$number}" - string != null -> "BaseAmount{string=$string}" - _json != null -> "BaseAmount{_unknown=$_json}" - else -> throw IllegalStateException("Invalid BaseAmount") - } + override fun toString() = value.toString() + } + + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + */ + class TaxCode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { - @JvmStatic fun ofNumber(number: Double) = BaseAmount(number = number) + @JvmField val AE = of("AE") - @JvmStatic fun ofString(string: String) = BaseAmount(string = string) - } + @JvmField val E = of("E") - /** - * An interface that defines how to map each variant of [BaseAmount] to a value of - * type [T]. - */ - interface Visitor { + @JvmField val S = of("S") - fun visitNumber(number: Double): T + @JvmField val Z = of("Z") - fun visitString(string: String): T + @JvmField val G = of("G") + + @JvmField val O = of("O") + + @JvmField val K = of("K") + + @JvmField val L = of("L") + + @JvmField val M = of("M") + + @JvmField val B = of("B") + + @JvmStatic fun of(value: String) = TaxCode(JsonField.of(value)) + } + + /** An enum containing [TaxCode]'s known values. */ + enum class Known { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + } + /** + * An enum containing [TaxCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TaxCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, /** - * Maps an unknown variant of [BaseAmount] to a value of type [T]. - * - * An instance of [BaseAmount] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if - * the SDK is on an older version than the API, then the API may respond with - * new variants that the SDK is unaware of. - * - * @throws EInvoiceInvalidDataException in the default implementation. + * An enum member indicating that [TaxCode] was instantiated with an unknown + * value. */ - fun unknown(json: JsonValue?): T { - throw EInvoiceInvalidDataException("Unknown BaseAmount: $json") - } + _UNKNOWN, } - internal class Deserializer : BaseDeserializer(BaseAmount::class) { + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AE -> Value.AE + E -> Value.E + S -> Value.S + Z -> Value.Z + G -> Value.G + O -> Value.O + K -> Value.K + L -> Value.L + M -> Value.M + B -> Value.B + else -> Value._UNKNOWN + } - override fun ObjectCodec.deserialize(node: JsonNode): BaseAmount { - val json = JsonValue.fromJsonNode(node) + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + AE -> Known.AE + E -> Known.E + S -> Known.S + Z -> Known.Z + G -> Known.G + O -> Known.O + K -> Known.K + L -> Known.L + M -> Known.M + B -> Known.B + else -> throw EInvoiceInvalidDataException("Unknown TaxCode: $value") + } - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - BaseAmount(number = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - BaseAmount(string = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely - // incompatible with all the possible variants (e.g. deserializing from - // object). - 0 -> BaseAmount(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use - // the first completely valid match, or simply the first match if none - // are completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): TaxCode = apply { + if (validated) { + return@apply + } + + known() + validated = true } - internal class Serializer : BaseSerializer(BaseAmount::class) { + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } - override fun serialize( - value: BaseAmount, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.number != null -> generator.writeObject(value.number) - value.string != null -> generator.writeObject(value.string) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid BaseAmount") - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } + + return other is TaxCode && value == other.value } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - /** - * The percentage that may be used, in conjunction with the charge base amount, to - * calculate the charge amount. To state 20%, use value 20 - */ - @JsonDeserialize(using = MultiplierFactor.Deserializer::class) - @JsonSerialize(using = MultiplierFactor.Serializer::class) - class MultiplierFactor + /** The VAT rate, represented as percentage that applies to the charge */ + @JsonDeserialize(using = TaxRate.Deserializer::class) + @JsonSerialize(using = TaxRate.Serializer::class) + class TaxRate private constructor( private val number: Double? = null, private val string: String? = null, @@ -7808,7 +11631,7 @@ private constructor( private var validated: Boolean = false - fun validate(): MultiplierFactor = apply { + fun validate(): TaxRate = apply { if (validated) { return@apply } @@ -7854,31 +11677,29 @@ private constructor( return true } - return other is MultiplierFactor && - number == other.number && - string == other.string + return other is TaxRate && number == other.number && string == other.string } override fun hashCode(): Int = Objects.hash(number, string) override fun toString(): String = when { - number != null -> "MultiplierFactor{number=$number}" - string != null -> "MultiplierFactor{string=$string}" - _json != null -> "MultiplierFactor{_unknown=$_json}" - else -> throw IllegalStateException("Invalid MultiplierFactor") + number != null -> "TaxRate{number=$number}" + string != null -> "TaxRate{string=$string}" + _json != null -> "TaxRate{_unknown=$_json}" + else -> throw IllegalStateException("Invalid TaxRate") } companion object { - @JvmStatic fun ofNumber(number: Double) = MultiplierFactor(number = number) + @JvmStatic fun ofNumber(number: Double) = TaxRate(number = number) - @JvmStatic fun ofString(string: String) = MultiplierFactor(string = string) + @JvmStatic fun ofString(string: String) = TaxRate(string = string) } /** - * An interface that defines how to map each variant of [MultiplierFactor] to a - * value of type [T]. + * An interface that defines how to map each variant of [TaxRate] to a value of type + * [T]. */ interface Visitor { @@ -7887,9 +11708,9 @@ private constructor( fun visitString(string: String): T /** - * Maps an unknown variant of [MultiplierFactor] to a value of type [T]. + * Maps an unknown variant of [TaxRate] to a value of type [T]. * - * An instance of [MultiplierFactor] can contain an unknown variant if it was + * An instance of [TaxRate] can contain an unknown variant if it was * deserialized from data that doesn't match any known variant. For example, if * the SDK is on an older version than the API, then the API may respond with * new variants that the SDK is unaware of. @@ -7897,23 +11718,22 @@ private constructor( * @throws EInvoiceInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw EInvoiceInvalidDataException("Unknown MultiplierFactor: $json") + throw EInvoiceInvalidDataException("Unknown TaxRate: $json") } } - internal class Deserializer : - BaseDeserializer(MultiplierFactor::class) { + internal class Deserializer : BaseDeserializer(TaxRate::class) { - override fun ObjectCodec.deserialize(node: JsonNode): MultiplierFactor { + override fun ObjectCodec.deserialize(node: JsonNode): TaxRate { val json = JsonValue.fromJsonNode(node) val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef())?.let { - MultiplierFactor(number = it, _json = json) + TaxRate(number = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - MultiplierFactor(string = it, _json = json) + TaxRate(string = it, _json = json) }, ) .filterNotNull() @@ -7923,7 +11743,7 @@ private constructor( // This can happen if what we're deserializing is completely // incompatible with all the possible variants (e.g. deserializing from // object). - 0 -> MultiplierFactor(_json = json) + 0 -> TaxRate(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use // the first completely valid match, or simply the first match if none @@ -7933,11 +11753,10 @@ private constructor( } } - internal class Serializer : - BaseSerializer(MultiplierFactor::class) { + internal class Serializer : BaseSerializer(TaxRate::class) { override fun serialize( - value: MultiplierFactor, + value: TaxRate, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -7945,229 +11764,223 @@ private constructor( value.number != null -> generator.writeObject(value.number) value.string != null -> generator.writeObject(value.string) value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid MultiplierFactor") + else -> throw IllegalStateException("Invalid TaxRate") } } } } - /** - * Duty or tax or fee category codes (Subset of UNCL5305) - * - * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL - */ - class TaxCode @JsonCreator private constructor(private val value: JsonField) : - Enum { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + return other is Charge && + amount == other.amount && + baseAmount == other.baseAmount && + multiplierFactor == other.multiplierFactor && + reason == other.reason && + reasonCode == other.reasonCode && + taxCode == other.taxCode && + taxRate == other.taxRate && + additionalProperties == other.additionalProperties + } - companion object { + private val hashCode: Int by lazy { + Objects.hash( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + additionalProperties, + ) + } - @JvmField val AE = of("AE") + override fun hashCode(): Int = hashCode - @JvmField val E = of("E") + override fun toString() = + "Charge{amount=$amount, baseAmount=$baseAmount, multiplierFactor=$multiplierFactor, reason=$reason, reasonCode=$reasonCode, taxCode=$taxCode, taxRate=$taxRate, additionalProperties=$additionalProperties}" + } - @JvmField val S = of("S") + /** + * The item price base quantity (BT-149). The number of item units to which the price + * applies. Defaults to 1. Must be rounded to maximum 4 decimals + */ + @JsonDeserialize(using = PriceBaseQuantity.Deserializer::class) + @JsonSerialize(using = PriceBaseQuantity.Serializer::class) + class PriceBaseQuantity + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { - @JvmField val Z = of("Z") + fun number(): Optional = Optional.ofNullable(number) - @JvmField val G = of("G") + fun string(): Optional = Optional.ofNullable(string) - @JvmField val O = of("O") + fun isNumber(): Boolean = number != null - @JvmField val K = of("K") + fun isString(): Boolean = string != null - @JvmField val L = of("L") + fun asNumber(): Double = number.getOrThrow("number") - @JvmField val M = of("M") + fun asString(): String = string.getOrThrow("string") - @JvmField val B = of("B") + fun _json(): Optional = Optional.ofNullable(_json) - @JvmStatic fun of(value: String) = TaxCode(JsonField.of(value)) + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) } - /** An enum containing [TaxCode]'s known values. */ - enum class Known { - AE, - E, - S, - Z, - G, - O, - K, - L, - M, - B, - } + private var validated: Boolean = false - /** - * An enum containing [TaxCode]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [TaxCode] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AE, - E, - S, - Z, - G, - O, - K, - L, - M, - B, - /** - * An enum member indicating that [TaxCode] was instantiated with an unknown - * value. - */ - _UNKNOWN, + fun validate(): PriceBaseQuantity = apply { + if (validated) { + return@apply } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AE -> Value.AE - E -> Value.E - S -> Value.S - Z -> Value.Z - G -> Value.G - O -> Value.O - K -> Value.K - L -> Value.L - M -> Value.M - B -> Value.B - else -> Value._UNKNOWN - } + accept( + object : Visitor { + override fun visitNumber(number: Double) {} - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws EInvoiceInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AE -> Known.AE - E -> Known.E - S -> Known.S - Z -> Known.Z - G -> Known.G - O -> Known.O - K -> Known.K - L -> Known.L - M -> Known.M - B -> Known.B - else -> throw EInvoiceInvalidDataException("Unknown TaxCode: $value") + override fun visitString(string: String) {} } + ) + validated = true + } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws EInvoiceInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - EInvoiceInvalidDataException("Value is not a String") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is PriceBaseQuantity && + number == other.number && + string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "PriceBaseQuantity{number=$number}" + string != null -> "PriceBaseQuantity{string=$string}" + _json != null -> "PriceBaseQuantity{_unknown=$_json}" + else -> throw IllegalStateException("Invalid PriceBaseQuantity") + } - private var validated: Boolean = false + companion object { - fun validate(): TaxCode = apply { - if (validated) { - return@apply - } + @JvmStatic fun ofNumber(number: Double) = PriceBaseQuantity(number = number) - known() - validated = true - } + @JvmStatic fun ofString(string: String) = PriceBaseQuantity(string = string) + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false - } + /** + * An interface that defines how to map each variant of [PriceBaseQuantity] to a value + * of type [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Maps an unknown variant of [PriceBaseQuantity] to a value of type [T]. * - * Used for best match union deserialization. + * An instance of [PriceBaseQuantity] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the + * SDK is on an older version than the API, then the API may respond with new + * variants that the SDK is unaware of. + * + * @throws EInvoiceInvalidDataException in the default implementation. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TaxCode && value == other.value + fun unknown(json: JsonValue?): T { + throw EInvoiceInvalidDataException("Unknown PriceBaseQuantity: $json") } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + internal class Deserializer : + BaseDeserializer(PriceBaseQuantity::class) { - return other is Charge && - amount == other.amount && - baseAmount == other.baseAmount && - multiplierFactor == other.multiplierFactor && - reason == other.reason && - reasonCode == other.reasonCode && - taxCode == other.taxCode && - taxRate == other.taxRate && - additionalProperties == other.additionalProperties - } + override fun ObjectCodec.deserialize(node: JsonNode): PriceBaseQuantity { + val json = JsonValue.fromJsonNode(node) - private val hashCode: Int by lazy { - Objects.hash( - amount, - baseAmount, - multiplierFactor, - reason, - reasonCode, - taxCode, - taxRate, - additionalProperties, - ) + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + PriceBaseQuantity(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + PriceBaseQuantity(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> PriceBaseQuantity(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } } - override fun hashCode(): Int = hashCode + internal class Serializer : + BaseSerializer(PriceBaseQuantity::class) { - override fun toString() = - "Charge{amount=$amount, baseAmount=$baseAmount, multiplierFactor=$multiplierFactor, reason=$reason, reasonCode=$reasonCode, taxCode=$taxCode, taxRate=$taxRate, additionalProperties=$additionalProperties}" + override fun serialize( + value: PriceBaseQuantity, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid PriceBaseQuantity") + } + } + } } /** @@ -8514,7 +12327,181 @@ private constructor( } } - /** The unit price of the line item. Must be rounded to maximum 2 decimals */ + /** The VAT rate of the line item expressed as percentage with 2 decimals */ + @JsonDeserialize(using = TaxRate.Deserializer::class) + @JsonSerialize(using = TaxRate.Serializer::class) + class TaxRate + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): TaxRate = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TaxRate && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "TaxRate{number=$number}" + string != null -> "TaxRate{string=$string}" + _json != null -> "TaxRate{_unknown=$_json}" + else -> throw IllegalStateException("Invalid TaxRate") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = TaxRate(number = number) + + @JvmStatic fun ofString(string: String) = TaxRate(string = string) + } + + /** + * An interface that defines how to map each variant of [TaxRate] to a value of type + * [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [TaxRate] to a value of type [T]. + * + * An instance of [TaxRate] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws EInvoiceInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw EInvoiceInvalidDataException("Unknown TaxRate: $json") + } + } + + internal class Deserializer : BaseDeserializer(TaxRate::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): TaxRate { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + TaxRate(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + TaxRate(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> TaxRate(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(TaxRate::class) { + + override fun serialize( + value: TaxRate, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid TaxRate") + } + } + } + } + + /** + * The item net price (BT-146). The price of an item, exclusive of VAT, after subtracting + * item price discount. Must be rounded to maximum 4 decimals + */ @JsonDeserialize(using = UnitPrice.Deserializer::class) @JsonSerialize(using = UnitPrice.Serializer::class) class UnitPrice @@ -8696,6 +12683,7 @@ private constructor( charges == other.charges && date == other.date && description == other.description && + priceBaseQuantity == other.priceBaseQuantity && productCode == other.productCode && quantity == other.quantity && tax == other.tax && @@ -8712,6 +12700,7 @@ private constructor( charges, date, description, + priceBaseQuantity, productCode, quantity, tax, @@ -8725,7 +12714,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Item{allowances=$allowances, amount=$amount, charges=$charges, date=$date, description=$description, productCode=$productCode, quantity=$quantity, tax=$tax, taxRate=$taxRate, unit=$unit, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" + "Item{allowances=$allowances, amount=$amount, charges=$charges, date=$date, description=$description, priceBaseQuantity=$priceBaseQuantity, productCode=$productCode, quantity=$quantity, tax=$tax, taxRate=$taxRate, unit=$unit, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" } /** diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponse.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponse.kt index f517073..e87c484 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponse.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponse.kt @@ -2389,6 +2389,7 @@ private constructor( private val charges: JsonField>, private val date: JsonField, private val description: JsonField, + private val priceBaseQuantity: JsonField, private val productCode: JsonField, private val quantity: JsonField, private val tax: JsonField, @@ -2411,6 +2412,9 @@ private constructor( @JsonProperty("description") @ExcludeMissing description: JsonField = JsonMissing.of(), + @JsonProperty("price_base_quantity") + @ExcludeMissing + priceBaseQuantity: JsonField = JsonMissing.of(), @JsonProperty("product_code") @ExcludeMissing productCode: JsonField = JsonMissing.of(), @@ -2431,6 +2435,7 @@ private constructor( charges, date, description, + priceBaseQuantity, productCode, quantity, tax, @@ -2449,8 +2454,9 @@ private constructor( fun allowances(): Optional> = allowances.getOptional("allowances") /** - * The total amount of the line item, exclusive of VAT, after subtracting line level - * allowances and adding line level charges. Must be rounded to maximum 2 decimals + * The invoice line net amount (BT-131), exclusive of VAT, inclusive of line level + * allowances and charges. Calculated as: ((unit_price / price_base_quantity) * quantity) - + * allowances + charges. Must be rounded to maximum 2 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -2479,6 +2485,16 @@ private constructor( */ fun description(): Optional = description.getOptional("description") + /** + * The item price base quantity (BT-149). The number of item units to which the price + * applies. Defaults to 1. Must be rounded to maximum 4 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun priceBaseQuantity(): Optional = + priceBaseQuantity.getOptional("price_base_quantity") + /** * The product code of the line item. * @@ -2521,7 +2537,8 @@ private constructor( fun unit(): Optional = unit.getOptional("unit") /** - * The unit price of the line item. Must be rounded to maximum 2 decimals + * The item net price (BT-146). The price of an item, exclusive of VAT, after subtracting + * item price discount. Must be rounded to maximum 4 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -2567,6 +2584,16 @@ private constructor( @ExcludeMissing fun _description(): JsonField = description + /** + * Returns the raw JSON value of [priceBaseQuantity]. + * + * Unlike [priceBaseQuantity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("price_base_quantity") + @ExcludeMissing + fun _priceBaseQuantity(): JsonField = priceBaseQuantity + /** * Returns the raw JSON value of [productCode]. * @@ -2637,6 +2664,7 @@ private constructor( private var charges: JsonField>? = null private var date: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() + private var priceBaseQuantity: JsonField = JsonMissing.of() private var productCode: JsonField = JsonMissing.of() private var quantity: JsonField = JsonMissing.of() private var tax: JsonField = JsonMissing.of() @@ -2652,6 +2680,7 @@ private constructor( charges = item.charges.map { it.toMutableList() } date = item.date description = item.description + priceBaseQuantity = item.priceBaseQuantity productCode = item.productCode quantity = item.quantity tax = item.tax @@ -2693,8 +2722,9 @@ private constructor( } /** - * The total amount of the line item, exclusive of VAT, after subtracting line level - * allowances and adding line level charges. Must be rounded to maximum 2 decimals + * The invoice line net amount (BT-131), exclusive of VAT, inclusive of line level + * allowances and charges. Calculated as: ((unit_price / price_base_quantity) * + * quantity) - allowances + charges. Must be rounded to maximum 2 decimals */ fun amount(amount: String?) = amount(JsonField.ofNullable(amount)) @@ -2770,6 +2800,30 @@ private constructor( this.description = description } + /** + * The item price base quantity (BT-149). The number of item units to which the price + * applies. Defaults to 1. Must be rounded to maximum 4 decimals + */ + fun priceBaseQuantity(priceBaseQuantity: String?) = + priceBaseQuantity(JsonField.ofNullable(priceBaseQuantity)) + + /** + * Alias for calling [Builder.priceBaseQuantity] with `priceBaseQuantity.orElse(null)`. + */ + fun priceBaseQuantity(priceBaseQuantity: Optional) = + priceBaseQuantity(priceBaseQuantity.getOrNull()) + + /** + * Sets [Builder.priceBaseQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.priceBaseQuantity] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceBaseQuantity(priceBaseQuantity: JsonField) = apply { + this.priceBaseQuantity = priceBaseQuantity + } + /** The product code of the line item. */ fun productCode(productCode: String?) = productCode(JsonField.ofNullable(productCode)) @@ -2850,7 +2904,10 @@ private constructor( */ fun unit(unit: JsonField) = apply { this.unit = unit } - /** The unit price of the line item. Must be rounded to maximum 2 decimals */ + /** + * The item net price (BT-146). The price of an item, exclusive of VAT, after + * subtracting item price discount. Must be rounded to maximum 4 decimals + */ fun unitPrice(unitPrice: String?) = unitPrice(JsonField.ofNullable(unitPrice)) /** Alias for calling [Builder.unitPrice] with `unitPrice.orElse(null)`. */ @@ -2896,6 +2953,7 @@ private constructor( (charges ?: JsonMissing.of()).map { it.toImmutable() }, date, description, + priceBaseQuantity, productCode, quantity, tax, @@ -2918,6 +2976,7 @@ private constructor( charges().ifPresent { it.forEach { it.validate() } } date() description() + priceBaseQuantity() productCode() quantity() tax() @@ -2948,6 +3007,7 @@ private constructor( (charges.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (date.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + + (if (priceBaseQuantity.asKnown().isPresent) 1 else 0) + (if (productCode.asKnown().isPresent) 1 else 0) + (if (quantity.asKnown().isPresent) 1 else 0) + (if (tax.asKnown().isPresent) 1 else 0) + @@ -2966,6 +3026,7 @@ private constructor( charges == other.charges && date == other.date && description == other.description && + priceBaseQuantity == other.priceBaseQuantity && productCode == other.productCode && quantity == other.quantity && tax == other.tax && @@ -2982,6 +3043,7 @@ private constructor( charges, date, description, + priceBaseQuantity, productCode, quantity, tax, @@ -2995,7 +3057,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Item{allowances=$allowances, amount=$amount, charges=$charges, date=$date, description=$description, productCode=$productCode, quantity=$quantity, tax=$tax, taxRate=$taxRate, unit=$unit, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" + "Item{allowances=$allowances, amount=$amount, charges=$charges, date=$date, description=$description, priceBaseQuantity=$priceBaseQuantity, productCode=$productCode, quantity=$quantity, tax=$tax, taxRate=$taxRate, unit=$unit, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" } /** diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt index 066f3b6..cc5df98 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt @@ -2355,7 +2355,7 @@ private constructor( private val baseAmount: JsonField, private val multiplierFactor: JsonField, private val reason: JsonField, - private val reasonCode: JsonField, + private val reasonCode: JsonField, private val taxCode: JsonField, private val taxRate: JsonField, private val additionalProperties: MutableMap, @@ -2373,7 +2373,7 @@ private constructor( @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), @JsonProperty("reason_code") @ExcludeMissing - reasonCode: JsonField = JsonMissing.of(), + reasonCode: JsonField = JsonMissing.of(), @JsonProperty("tax_code") @ExcludeMissing taxCode: JsonField = JsonMissing.of(), @@ -2408,7 +2408,8 @@ private constructor( /** * The percentage that may be used, in conjunction with the allowance base amount, to - * calculate the allowance amount. To state 20%, use value 20 + * calculate the allowance amount. To state 20%, use value 20. Must be rounded to maximum 2 + * decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -2424,17 +2425,15 @@ private constructor( fun reason(): Optional = reason.getOptional("reason") /** - * The code for the allowance reason + * Allowance reason codes for invoice discounts and charges * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun reasonCode(): Optional = reasonCode.getOptional("reason_code") + fun reasonCode(): Optional = reasonCode.getOptional("reason_code") /** - * Duty or tax or fee category codes (Subset of UNCL5305) - * - * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + * The VAT category code that applies to the allowance * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -2442,7 +2441,8 @@ private constructor( fun taxCode(): Optional = taxCode.getOptional("tax_code") /** - * The VAT rate, represented as percentage that applies to the allowance + * The VAT rate, represented as percentage that applies to the allowance. Must be rounded to + * maximum 2 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -2489,7 +2489,7 @@ private constructor( */ @JsonProperty("reason_code") @ExcludeMissing - fun _reasonCode(): JsonField = reasonCode + fun _reasonCode(): JsonField = reasonCode /** * Returns the raw JSON value of [taxCode]. @@ -2530,7 +2530,7 @@ private constructor( private var baseAmount: JsonField = JsonMissing.of() private var multiplierFactor: JsonField = JsonMissing.of() private var reason: JsonField = JsonMissing.of() - private var reasonCode: JsonField = JsonMissing.of() + private var reasonCode: JsonField = JsonMissing.of() private var taxCode: JsonField = JsonMissing.of() private var taxRate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -2582,7 +2582,8 @@ private constructor( /** * The percentage that may be used, in conjunction with the allowance base amount, to - * calculate the allowance amount. To state 20%, use value 20 + * calculate the allowance amount. To state 20%, use value 20. Must be rounded to + * maximum 2 decimals */ fun multiplierFactor(multiplierFactor: String?) = multiplierFactor(JsonField.ofNullable(multiplierFactor)) @@ -2619,30 +2620,25 @@ private constructor( */ fun reason(reason: JsonField) = apply { this.reason = reason } - /** The code for the allowance reason */ - fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) + /** Allowance reason codes for invoice discounts and charges */ + fun reasonCode(reasonCode: ReasonCode?) = reasonCode(JsonField.ofNullable(reasonCode)) /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ - fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) + fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) /** * Sets [Builder.reasonCode] to an arbitrary JSON value. * - * You should usually call [Builder.reasonCode] with a well-typed [String] value + * You should usually call [Builder.reasonCode] with a well-typed [ReasonCode] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode } - - /** - * Duty or tax or fee category codes (Subset of UNCL5305) - * - * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL - */ - fun taxCode(taxCode: TaxCode?) = taxCode(JsonField.ofNullable(taxCode)) + fun reasonCode(reasonCode: JsonField) = apply { + this.reasonCode = reasonCode + } - /** Alias for calling [Builder.taxCode] with `taxCode.orElse(null)`. */ - fun taxCode(taxCode: Optional) = taxCode(taxCode.getOrNull()) + /** The VAT category code that applies to the allowance */ + fun taxCode(taxCode: TaxCode) = taxCode(JsonField.of(taxCode)) /** * Sets [Builder.taxCode] to an arbitrary JSON value. @@ -2653,7 +2649,10 @@ private constructor( */ fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } - /** The VAT rate, represented as percentage that applies to the allowance */ + /** + * The VAT rate, represented as percentage that applies to the allowance. Must be + * rounded to maximum 2 decimals + */ fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ @@ -2716,7 +2715,7 @@ private constructor( baseAmount() multiplierFactor() reason() - reasonCode() + reasonCode().ifPresent { it.validate() } taxCode().ifPresent { it.validate() } taxRate() validated = true @@ -2742,15 +2741,245 @@ private constructor( (if (baseAmount.asKnown().isPresent) 1 else 0) + (if (multiplierFactor.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) + - (if (reasonCode.asKnown().isPresent) 1 else 0) + + (reasonCode.asKnown().getOrNull()?.validity() ?: 0) + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + (if (taxRate.asKnown().isPresent) 1 else 0) - /** - * Duty or tax or fee category codes (Subset of UNCL5305) - * - * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL - */ + /** Allowance reason codes for invoice discounts and charges */ + class ReasonCode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val _41 = of("41") + + @JvmField val _42 = of("42") + + @JvmField val _60 = of("60") + + @JvmField val _62 = of("62") + + @JvmField val _63 = of("63") + + @JvmField val _64 = of("64") + + @JvmField val _65 = of("65") + + @JvmField val _66 = of("66") + + @JvmField val _67 = of("67") + + @JvmField val _68 = of("68") + + @JvmField val _70 = of("70") + + @JvmField val _71 = of("71") + + @JvmField val _88 = of("88") + + @JvmField val _95 = of("95") + + @JvmField val _100 = of("100") + + @JvmField val _102 = of("102") + + @JvmField val _103 = of("103") + + @JvmField val _104 = of("104") + + @JvmField val _105 = of("105") + + @JvmStatic fun of(value: String) = ReasonCode(JsonField.of(value)) + } + + /** An enum containing [ReasonCode]'s known values. */ + enum class Known { + _41, + _42, + _60, + _62, + _63, + _64, + _65, + _66, + _67, + _68, + _70, + _71, + _88, + _95, + _100, + _102, + _103, + _104, + _105, + } + + /** + * An enum containing [ReasonCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ReasonCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + _41, + _42, + _60, + _62, + _63, + _64, + _65, + _66, + _67, + _68, + _70, + _71, + _88, + _95, + _100, + _102, + _103, + _104, + _105, + /** + * An enum member indicating that [ReasonCode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + _41 -> Value._41 + _42 -> Value._42 + _60 -> Value._60 + _62 -> Value._62 + _63 -> Value._63 + _64 -> Value._64 + _65 -> Value._65 + _66 -> Value._66 + _67 -> Value._67 + _68 -> Value._68 + _70 -> Value._70 + _71 -> Value._71 + _88 -> Value._88 + _95 -> Value._95 + _100 -> Value._100 + _102 -> Value._102 + _103 -> Value._103 + _104 -> Value._104 + _105 -> Value._105 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + _41 -> Known._41 + _42 -> Known._42 + _60 -> Known._60 + _62 -> Known._62 + _63 -> Known._63 + _64 -> Known._64 + _65 -> Known._65 + _66 -> Known._66 + _67 -> Known._67 + _68 -> Known._68 + _70 -> Known._70 + _71 -> Known._71 + _88 -> Known._88 + _95 -> Known._95 + _100 -> Known._100 + _102 -> Known._102 + _103 -> Known._103 + _104 -> Known._104 + _105 -> Known._105 + else -> throw EInvoiceInvalidDataException("Unknown ReasonCode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReasonCode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReasonCode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The VAT category code that applies to the allowance */ class TaxCode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2971,7 +3200,7 @@ private constructor( private val baseAmount: JsonField, private val multiplierFactor: JsonField, private val reason: JsonField, - private val reasonCode: JsonField, + private val reasonCode: JsonField, private val taxCode: JsonField, private val taxRate: JsonField, private val additionalProperties: MutableMap, @@ -2989,7 +3218,7 @@ private constructor( @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), @JsonProperty("reason_code") @ExcludeMissing - reasonCode: JsonField = JsonMissing.of(), + reasonCode: JsonField = JsonMissing.of(), @JsonProperty("tax_code") @ExcludeMissing taxCode: JsonField = JsonMissing.of(), @@ -3040,12 +3269,12 @@ private constructor( fun reason(): Optional = reason.getOptional("reason") /** - * The code for the charge reason + * Charge reason codes for invoice charges and fees * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun reasonCode(): Optional = reasonCode.getOptional("reason_code") + fun reasonCode(): Optional = reasonCode.getOptional("reason_code") /** * Duty or tax or fee category codes (Subset of UNCL5305) @@ -3105,7 +3334,7 @@ private constructor( */ @JsonProperty("reason_code") @ExcludeMissing - fun _reasonCode(): JsonField = reasonCode + fun _reasonCode(): JsonField = reasonCode /** * Returns the raw JSON value of [taxCode]. @@ -3146,7 +3375,7 @@ private constructor( private var baseAmount: JsonField = JsonMissing.of() private var multiplierFactor: JsonField = JsonMissing.of() private var reason: JsonField = JsonMissing.of() - private var reasonCode: JsonField = JsonMissing.of() + private var reasonCode: JsonField = JsonMissing.of() private var taxCode: JsonField = JsonMissing.of() private var taxRate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -3235,20 +3464,22 @@ private constructor( */ fun reason(reason: JsonField) = apply { this.reason = reason } - /** The code for the charge reason */ - fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) + /** Charge reason codes for invoice charges and fees */ + fun reasonCode(reasonCode: ReasonCode?) = reasonCode(JsonField.ofNullable(reasonCode)) /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ - fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) + fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) /** * Sets [Builder.reasonCode] to an arbitrary JSON value. * - * You should usually call [Builder.reasonCode] with a well-typed [String] value + * You should usually call [Builder.reasonCode] with a well-typed [ReasonCode] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode } + fun reasonCode(reasonCode: JsonField) = apply { + this.reasonCode = reasonCode + } /** * Duty or tax or fee category codes (Subset of UNCL5305) @@ -3332,7 +3563,7 @@ private constructor( baseAmount() multiplierFactor() reason() - reasonCode() + reasonCode().ifPresent { it.validate() } taxCode().ifPresent { it.validate() } taxRate() validated = true @@ -3358,10 +3589,1198 @@ private constructor( (if (baseAmount.asKnown().isPresent) 1 else 0) + (if (multiplierFactor.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) + - (if (reasonCode.asKnown().isPresent) 1 else 0) + + (reasonCode.asKnown().getOrNull()?.validity() ?: 0) + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + (if (taxRate.asKnown().isPresent) 1 else 0) + /** Charge reason codes for invoice charges and fees */ + class ReasonCode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val AA = of("AA") + + @JvmField val AAA = of("AAA") + + @JvmField val AAC = of("AAC") + + @JvmField val AAD = of("AAD") + + @JvmField val AAE = of("AAE") + + @JvmField val AAF = of("AAF") + + @JvmField val AAH = of("AAH") + + @JvmField val AAI = of("AAI") + + @JvmField val AAS = of("AAS") + + @JvmField val AAT = of("AAT") + + @JvmField val AAV = of("AAV") + + @JvmField val AAY = of("AAY") + + @JvmField val AAZ = of("AAZ") + + @JvmField val ABA = of("ABA") + + @JvmField val ABB = of("ABB") + + @JvmField val ABC = of("ABC") + + @JvmField val ABD = of("ABD") + + @JvmField val ABF = of("ABF") + + @JvmField val ABK = of("ABK") + + @JvmField val ABL = of("ABL") + + @JvmField val ABN = of("ABN") + + @JvmField val ABR = of("ABR") + + @JvmField val ABS = of("ABS") + + @JvmField val ABT = of("ABT") + + @JvmField val ABU = of("ABU") + + @JvmField val ACF = of("ACF") + + @JvmField val ACG = of("ACG") + + @JvmField val ACH = of("ACH") + + @JvmField val ACI = of("ACI") + + @JvmField val ACJ = of("ACJ") + + @JvmField val ACK = of("ACK") + + @JvmField val ACL = of("ACL") + + @JvmField val ACM = of("ACM") + + @JvmField val ACS = of("ACS") + + @JvmField val ADC = of("ADC") + + @JvmField val ADE = of("ADE") + + @JvmField val ADJ = of("ADJ") + + @JvmField val ADK = of("ADK") + + @JvmField val ADL = of("ADL") + + @JvmField val ADM = of("ADM") + + @JvmField val ADN = of("ADN") + + @JvmField val ADO = of("ADO") + + @JvmField val ADP = of("ADP") + + @JvmField val ADQ = of("ADQ") + + @JvmField val ADR = of("ADR") + + @JvmField val ADT = of("ADT") + + @JvmField val ADW = of("ADW") + + @JvmField val ADY = of("ADY") + + @JvmField val ADZ = of("ADZ") + + @JvmField val AEA = of("AEA") + + @JvmField val AEB = of("AEB") + + @JvmField val AEC = of("AEC") + + @JvmField val AED = of("AED") + + @JvmField val AEF = of("AEF") + + @JvmField val AEH = of("AEH") + + @JvmField val AEI = of("AEI") + + @JvmField val AEJ = of("AEJ") + + @JvmField val AEK = of("AEK") + + @JvmField val AEL = of("AEL") + + @JvmField val AEM = of("AEM") + + @JvmField val AEN = of("AEN") + + @JvmField val AEO = of("AEO") + + @JvmField val AEP = of("AEP") + + @JvmField val AES = of("AES") + + @JvmField val AET = of("AET") + + @JvmField val AEU = of("AEU") + + @JvmField val AEV = of("AEV") + + @JvmField val AEW = of("AEW") + + @JvmField val AEX = of("AEX") + + @JvmField val AEY = of("AEY") + + @JvmField val AEZ = of("AEZ") + + @JvmField val AJ = of("AJ") + + @JvmField val AU = of("AU") + + @JvmField val CA = of("CA") + + @JvmField val CAB = of("CAB") + + @JvmField val CAD = of("CAD") + + @JvmField val CAE = of("CAE") + + @JvmField val CAF = of("CAF") + + @JvmField val CAI = of("CAI") + + @JvmField val CAJ = of("CAJ") + + @JvmField val CAK = of("CAK") + + @JvmField val CAL = of("CAL") + + @JvmField val CAM = of("CAM") + + @JvmField val CAN = of("CAN") + + @JvmField val CAO = of("CAO") + + @JvmField val CAP = of("CAP") + + @JvmField val CAQ = of("CAQ") + + @JvmField val CAR = of("CAR") + + @JvmField val CAS = of("CAS") + + @JvmField val CAT = of("CAT") + + @JvmField val CAU = of("CAU") + + @JvmField val CAV = of("CAV") + + @JvmField val CAW = of("CAW") + + @JvmField val CAX = of("CAX") + + @JvmField val CAY = of("CAY") + + @JvmField val CAZ = of("CAZ") + + @JvmField val CD = of("CD") + + @JvmField val CG = of("CG") + + @JvmField val CS = of("CS") + + @JvmField val CT = of("CT") + + @JvmField val DAB = of("DAB") + + @JvmField val DAC = of("DAC") + + @JvmField val DAD = of("DAD") + + @JvmField val DAF = of("DAF") + + @JvmField val DAG = of("DAG") + + @JvmField val DAH = of("DAH") + + @JvmField val DAI = of("DAI") + + @JvmField val DAJ = of("DAJ") + + @JvmField val DAK = of("DAK") + + @JvmField val DAL = of("DAL") + + @JvmField val DAM = of("DAM") + + @JvmField val DAN = of("DAN") + + @JvmField val DAO = of("DAO") + + @JvmField val DAP = of("DAP") + + @JvmField val DAQ = of("DAQ") + + @JvmField val DL = of("DL") + + @JvmField val EG = of("EG") + + @JvmField val EP = of("EP") + + @JvmField val ER = of("ER") + + @JvmField val FAA = of("FAA") + + @JvmField val FAB = of("FAB") + + @JvmField val FAC = of("FAC") + + @JvmField val FC = of("FC") + + @JvmField val FH = of("FH") + + @JvmField val FI = of("FI") + + @JvmField val GAA = of("GAA") + + @JvmField val HAA = of("HAA") + + @JvmField val HD = of("HD") + + @JvmField val HH = of("HH") + + @JvmField val IAA = of("IAA") + + @JvmField val IAB = of("IAB") + + @JvmField val ID = of("ID") + + @JvmField val IF = of("IF") + + @JvmField val IR = of("IR") + + @JvmField val IS = of("IS") + + @JvmField val KO = of("KO") + + @JvmField val L1 = of("L1") + + @JvmField val LA = of("LA") + + @JvmField val LAA = of("LAA") + + @JvmField val LAB = of("LAB") + + @JvmField val LF = of("LF") + + @JvmField val MAE = of("MAE") + + @JvmField val MI = of("MI") + + @JvmField val ML = of("ML") + + @JvmField val NAA = of("NAA") + + @JvmField val OA = of("OA") + + @JvmField val PA = of("PA") + + @JvmField val PAA = of("PAA") + + @JvmField val PC = of("PC") + + @JvmField val PL = of("PL") + + @JvmField val PRV = of("PRV") + + @JvmField val RAB = of("RAB") + + @JvmField val RAC = of("RAC") + + @JvmField val RAD = of("RAD") + + @JvmField val RAF = of("RAF") + + @JvmField val RE = of("RE") + + @JvmField val RF = of("RF") + + @JvmField val RH = of("RH") + + @JvmField val RV = of("RV") + + @JvmField val SA = of("SA") + + @JvmField val SAA = of("SAA") + + @JvmField val SAD = of("SAD") + + @JvmField val SAE = of("SAE") + + @JvmField val SAI = of("SAI") + + @JvmField val SG = of("SG") + + @JvmField val SH = of("SH") + + @JvmField val SM = of("SM") + + @JvmField val SU = of("SU") + + @JvmField val TAB = of("TAB") + + @JvmField val TAC = of("TAC") + + @JvmField val TT = of("TT") + + @JvmField val TV = of("TV") + + @JvmField val V1 = of("V1") + + @JvmField val V2 = of("V2") + + @JvmField val WH = of("WH") + + @JvmField val XAA = of("XAA") + + @JvmField val YY = of("YY") + + @JvmField val ZZZ = of("ZZZ") + + @JvmStatic fun of(value: String) = ReasonCode(JsonField.of(value)) + } + + /** An enum containing [ReasonCode]'s known values. */ + enum class Known { + AA, + AAA, + AAC, + AAD, + AAE, + AAF, + AAH, + AAI, + AAS, + AAT, + AAV, + AAY, + AAZ, + ABA, + ABB, + ABC, + ABD, + ABF, + ABK, + ABL, + ABN, + ABR, + ABS, + ABT, + ABU, + ACF, + ACG, + ACH, + ACI, + ACJ, + ACK, + ACL, + ACM, + ACS, + ADC, + ADE, + ADJ, + ADK, + ADL, + ADM, + ADN, + ADO, + ADP, + ADQ, + ADR, + ADT, + ADW, + ADY, + ADZ, + AEA, + AEB, + AEC, + AED, + AEF, + AEH, + AEI, + AEJ, + AEK, + AEL, + AEM, + AEN, + AEO, + AEP, + AES, + AET, + AEU, + AEV, + AEW, + AEX, + AEY, + AEZ, + AJ, + AU, + CA, + CAB, + CAD, + CAE, + CAF, + CAI, + CAJ, + CAK, + CAL, + CAM, + CAN, + CAO, + CAP, + CAQ, + CAR, + CAS, + CAT, + CAU, + CAV, + CAW, + CAX, + CAY, + CAZ, + CD, + CG, + CS, + CT, + DAB, + DAC, + DAD, + DAF, + DAG, + DAH, + DAI, + DAJ, + DAK, + DAL, + DAM, + DAN, + DAO, + DAP, + DAQ, + DL, + EG, + EP, + ER, + FAA, + FAB, + FAC, + FC, + FH, + FI, + GAA, + HAA, + HD, + HH, + IAA, + IAB, + ID, + IF, + IR, + IS, + KO, + L1, + LA, + LAA, + LAB, + LF, + MAE, + MI, + ML, + NAA, + OA, + PA, + PAA, + PC, + PL, + PRV, + RAB, + RAC, + RAD, + RAF, + RE, + RF, + RH, + RV, + SA, + SAA, + SAD, + SAE, + SAI, + SG, + SH, + SM, + SU, + TAB, + TAC, + TT, + TV, + V1, + V2, + WH, + XAA, + YY, + ZZZ, + } + + /** + * An enum containing [ReasonCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ReasonCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AA, + AAA, + AAC, + AAD, + AAE, + AAF, + AAH, + AAI, + AAS, + AAT, + AAV, + AAY, + AAZ, + ABA, + ABB, + ABC, + ABD, + ABF, + ABK, + ABL, + ABN, + ABR, + ABS, + ABT, + ABU, + ACF, + ACG, + ACH, + ACI, + ACJ, + ACK, + ACL, + ACM, + ACS, + ADC, + ADE, + ADJ, + ADK, + ADL, + ADM, + ADN, + ADO, + ADP, + ADQ, + ADR, + ADT, + ADW, + ADY, + ADZ, + AEA, + AEB, + AEC, + AED, + AEF, + AEH, + AEI, + AEJ, + AEK, + AEL, + AEM, + AEN, + AEO, + AEP, + AES, + AET, + AEU, + AEV, + AEW, + AEX, + AEY, + AEZ, + AJ, + AU, + CA, + CAB, + CAD, + CAE, + CAF, + CAI, + CAJ, + CAK, + CAL, + CAM, + CAN, + CAO, + CAP, + CAQ, + CAR, + CAS, + CAT, + CAU, + CAV, + CAW, + CAX, + CAY, + CAZ, + CD, + CG, + CS, + CT, + DAB, + DAC, + DAD, + DAF, + DAG, + DAH, + DAI, + DAJ, + DAK, + DAL, + DAM, + DAN, + DAO, + DAP, + DAQ, + DL, + EG, + EP, + ER, + FAA, + FAB, + FAC, + FC, + FH, + FI, + GAA, + HAA, + HD, + HH, + IAA, + IAB, + ID, + IF, + IR, + IS, + KO, + L1, + LA, + LAA, + LAB, + LF, + MAE, + MI, + ML, + NAA, + OA, + PA, + PAA, + PC, + PL, + PRV, + RAB, + RAC, + RAD, + RAF, + RE, + RF, + RH, + RV, + SA, + SAA, + SAD, + SAE, + SAI, + SG, + SH, + SM, + SU, + TAB, + TAC, + TT, + TV, + V1, + V2, + WH, + XAA, + YY, + ZZZ, + /** + * An enum member indicating that [ReasonCode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AA -> Value.AA + AAA -> Value.AAA + AAC -> Value.AAC + AAD -> Value.AAD + AAE -> Value.AAE + AAF -> Value.AAF + AAH -> Value.AAH + AAI -> Value.AAI + AAS -> Value.AAS + AAT -> Value.AAT + AAV -> Value.AAV + AAY -> Value.AAY + AAZ -> Value.AAZ + ABA -> Value.ABA + ABB -> Value.ABB + ABC -> Value.ABC + ABD -> Value.ABD + ABF -> Value.ABF + ABK -> Value.ABK + ABL -> Value.ABL + ABN -> Value.ABN + ABR -> Value.ABR + ABS -> Value.ABS + ABT -> Value.ABT + ABU -> Value.ABU + ACF -> Value.ACF + ACG -> Value.ACG + ACH -> Value.ACH + ACI -> Value.ACI + ACJ -> Value.ACJ + ACK -> Value.ACK + ACL -> Value.ACL + ACM -> Value.ACM + ACS -> Value.ACS + ADC -> Value.ADC + ADE -> Value.ADE + ADJ -> Value.ADJ + ADK -> Value.ADK + ADL -> Value.ADL + ADM -> Value.ADM + ADN -> Value.ADN + ADO -> Value.ADO + ADP -> Value.ADP + ADQ -> Value.ADQ + ADR -> Value.ADR + ADT -> Value.ADT + ADW -> Value.ADW + ADY -> Value.ADY + ADZ -> Value.ADZ + AEA -> Value.AEA + AEB -> Value.AEB + AEC -> Value.AEC + AED -> Value.AED + AEF -> Value.AEF + AEH -> Value.AEH + AEI -> Value.AEI + AEJ -> Value.AEJ + AEK -> Value.AEK + AEL -> Value.AEL + AEM -> Value.AEM + AEN -> Value.AEN + AEO -> Value.AEO + AEP -> Value.AEP + AES -> Value.AES + AET -> Value.AET + AEU -> Value.AEU + AEV -> Value.AEV + AEW -> Value.AEW + AEX -> Value.AEX + AEY -> Value.AEY + AEZ -> Value.AEZ + AJ -> Value.AJ + AU -> Value.AU + CA -> Value.CA + CAB -> Value.CAB + CAD -> Value.CAD + CAE -> Value.CAE + CAF -> Value.CAF + CAI -> Value.CAI + CAJ -> Value.CAJ + CAK -> Value.CAK + CAL -> Value.CAL + CAM -> Value.CAM + CAN -> Value.CAN + CAO -> Value.CAO + CAP -> Value.CAP + CAQ -> Value.CAQ + CAR -> Value.CAR + CAS -> Value.CAS + CAT -> Value.CAT + CAU -> Value.CAU + CAV -> Value.CAV + CAW -> Value.CAW + CAX -> Value.CAX + CAY -> Value.CAY + CAZ -> Value.CAZ + CD -> Value.CD + CG -> Value.CG + CS -> Value.CS + CT -> Value.CT + DAB -> Value.DAB + DAC -> Value.DAC + DAD -> Value.DAD + DAF -> Value.DAF + DAG -> Value.DAG + DAH -> Value.DAH + DAI -> Value.DAI + DAJ -> Value.DAJ + DAK -> Value.DAK + DAL -> Value.DAL + DAM -> Value.DAM + DAN -> Value.DAN + DAO -> Value.DAO + DAP -> Value.DAP + DAQ -> Value.DAQ + DL -> Value.DL + EG -> Value.EG + EP -> Value.EP + ER -> Value.ER + FAA -> Value.FAA + FAB -> Value.FAB + FAC -> Value.FAC + FC -> Value.FC + FH -> Value.FH + FI -> Value.FI + GAA -> Value.GAA + HAA -> Value.HAA + HD -> Value.HD + HH -> Value.HH + IAA -> Value.IAA + IAB -> Value.IAB + ID -> Value.ID + IF -> Value.IF + IR -> Value.IR + IS -> Value.IS + KO -> Value.KO + L1 -> Value.L1 + LA -> Value.LA + LAA -> Value.LAA + LAB -> Value.LAB + LF -> Value.LF + MAE -> Value.MAE + MI -> Value.MI + ML -> Value.ML + NAA -> Value.NAA + OA -> Value.OA + PA -> Value.PA + PAA -> Value.PAA + PC -> Value.PC + PL -> Value.PL + PRV -> Value.PRV + RAB -> Value.RAB + RAC -> Value.RAC + RAD -> Value.RAD + RAF -> Value.RAF + RE -> Value.RE + RF -> Value.RF + RH -> Value.RH + RV -> Value.RV + SA -> Value.SA + SAA -> Value.SAA + SAD -> Value.SAD + SAE -> Value.SAE + SAI -> Value.SAI + SG -> Value.SG + SH -> Value.SH + SM -> Value.SM + SU -> Value.SU + TAB -> Value.TAB + TAC -> Value.TAC + TT -> Value.TT + TV -> Value.TV + V1 -> Value.V1 + V2 -> Value.V2 + WH -> Value.WH + XAA -> Value.XAA + YY -> Value.YY + ZZZ -> Value.ZZZ + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + AA -> Known.AA + AAA -> Known.AAA + AAC -> Known.AAC + AAD -> Known.AAD + AAE -> Known.AAE + AAF -> Known.AAF + AAH -> Known.AAH + AAI -> Known.AAI + AAS -> Known.AAS + AAT -> Known.AAT + AAV -> Known.AAV + AAY -> Known.AAY + AAZ -> Known.AAZ + ABA -> Known.ABA + ABB -> Known.ABB + ABC -> Known.ABC + ABD -> Known.ABD + ABF -> Known.ABF + ABK -> Known.ABK + ABL -> Known.ABL + ABN -> Known.ABN + ABR -> Known.ABR + ABS -> Known.ABS + ABT -> Known.ABT + ABU -> Known.ABU + ACF -> Known.ACF + ACG -> Known.ACG + ACH -> Known.ACH + ACI -> Known.ACI + ACJ -> Known.ACJ + ACK -> Known.ACK + ACL -> Known.ACL + ACM -> Known.ACM + ACS -> Known.ACS + ADC -> Known.ADC + ADE -> Known.ADE + ADJ -> Known.ADJ + ADK -> Known.ADK + ADL -> Known.ADL + ADM -> Known.ADM + ADN -> Known.ADN + ADO -> Known.ADO + ADP -> Known.ADP + ADQ -> Known.ADQ + ADR -> Known.ADR + ADT -> Known.ADT + ADW -> Known.ADW + ADY -> Known.ADY + ADZ -> Known.ADZ + AEA -> Known.AEA + AEB -> Known.AEB + AEC -> Known.AEC + AED -> Known.AED + AEF -> Known.AEF + AEH -> Known.AEH + AEI -> Known.AEI + AEJ -> Known.AEJ + AEK -> Known.AEK + AEL -> Known.AEL + AEM -> Known.AEM + AEN -> Known.AEN + AEO -> Known.AEO + AEP -> Known.AEP + AES -> Known.AES + AET -> Known.AET + AEU -> Known.AEU + AEV -> Known.AEV + AEW -> Known.AEW + AEX -> Known.AEX + AEY -> Known.AEY + AEZ -> Known.AEZ + AJ -> Known.AJ + AU -> Known.AU + CA -> Known.CA + CAB -> Known.CAB + CAD -> Known.CAD + CAE -> Known.CAE + CAF -> Known.CAF + CAI -> Known.CAI + CAJ -> Known.CAJ + CAK -> Known.CAK + CAL -> Known.CAL + CAM -> Known.CAM + CAN -> Known.CAN + CAO -> Known.CAO + CAP -> Known.CAP + CAQ -> Known.CAQ + CAR -> Known.CAR + CAS -> Known.CAS + CAT -> Known.CAT + CAU -> Known.CAU + CAV -> Known.CAV + CAW -> Known.CAW + CAX -> Known.CAX + CAY -> Known.CAY + CAZ -> Known.CAZ + CD -> Known.CD + CG -> Known.CG + CS -> Known.CS + CT -> Known.CT + DAB -> Known.DAB + DAC -> Known.DAC + DAD -> Known.DAD + DAF -> Known.DAF + DAG -> Known.DAG + DAH -> Known.DAH + DAI -> Known.DAI + DAJ -> Known.DAJ + DAK -> Known.DAK + DAL -> Known.DAL + DAM -> Known.DAM + DAN -> Known.DAN + DAO -> Known.DAO + DAP -> Known.DAP + DAQ -> Known.DAQ + DL -> Known.DL + EG -> Known.EG + EP -> Known.EP + ER -> Known.ER + FAA -> Known.FAA + FAB -> Known.FAB + FAC -> Known.FAC + FC -> Known.FC + FH -> Known.FH + FI -> Known.FI + GAA -> Known.GAA + HAA -> Known.HAA + HD -> Known.HD + HH -> Known.HH + IAA -> Known.IAA + IAB -> Known.IAB + ID -> Known.ID + IF -> Known.IF + IR -> Known.IR + IS -> Known.IS + KO -> Known.KO + L1 -> Known.L1 + LA -> Known.LA + LAA -> Known.LAA + LAB -> Known.LAB + LF -> Known.LF + MAE -> Known.MAE + MI -> Known.MI + ML -> Known.ML + NAA -> Known.NAA + OA -> Known.OA + PA -> Known.PA + PAA -> Known.PAA + PC -> Known.PC + PL -> Known.PL + PRV -> Known.PRV + RAB -> Known.RAB + RAC -> Known.RAC + RAD -> Known.RAD + RAF -> Known.RAF + RE -> Known.RE + RF -> Known.RF + RH -> Known.RH + RV -> Known.RV + SA -> Known.SA + SAA -> Known.SAA + SAD -> Known.SAD + SAE -> Known.SAE + SAI -> Known.SAI + SG -> Known.SG + SH -> Known.SH + SM -> Known.SM + SU -> Known.SU + TAB -> Known.TAB + TAC -> Known.TAC + TT -> Known.TT + TV -> Known.TV + V1 -> Known.V1 + V2 -> Known.V2 + WH -> Known.WH + XAA -> Known.XAA + YY -> Known.YY + ZZZ -> Known.ZZZ + else -> throw EInvoiceInvalidDataException("Unknown ReasonCode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReasonCode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReasonCode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + /** * Duty or tax or fee category codes (Subset of UNCL5305) * @@ -3588,6 +5007,7 @@ private constructor( private val charges: JsonField>, private val date: JsonField, private val description: JsonField, + private val priceBaseQuantity: JsonField, private val productCode: JsonField, private val quantity: JsonField, private val tax: JsonField, @@ -3610,6 +5030,9 @@ private constructor( @JsonProperty("description") @ExcludeMissing description: JsonField = JsonMissing.of(), + @JsonProperty("price_base_quantity") + @ExcludeMissing + priceBaseQuantity: JsonField = JsonMissing.of(), @JsonProperty("product_code") @ExcludeMissing productCode: JsonField = JsonMissing.of(), @@ -3630,6 +5053,7 @@ private constructor( charges, date, description, + priceBaseQuantity, productCode, quantity, tax, @@ -3648,8 +5072,9 @@ private constructor( fun allowances(): Optional> = allowances.getOptional("allowances") /** - * The total amount of the line item, exclusive of VAT, after subtracting line level - * allowances and adding line level charges. Must be rounded to maximum 2 decimals + * The invoice line net amount (BT-131), exclusive of VAT, inclusive of line level + * allowances and charges. Calculated as: ((unit_price / price_base_quantity) * quantity) - + * allowances + charges. Must be rounded to maximum 2 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -3678,6 +5103,16 @@ private constructor( */ fun description(): Optional = description.getOptional("description") + /** + * The item price base quantity (BT-149). The number of item units to which the price + * applies. Defaults to 1. Must be rounded to maximum 4 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun priceBaseQuantity(): Optional = + priceBaseQuantity.getOptional("price_base_quantity") + /** * The product code of the line item. * @@ -3720,7 +5155,8 @@ private constructor( fun unit(): Optional = unit.getOptional("unit") /** - * The unit price of the line item. Must be rounded to maximum 2 decimals + * The item net price (BT-146). The price of an item, exclusive of VAT, after subtracting + * item price discount. Must be rounded to maximum 4 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -3766,6 +5202,16 @@ private constructor( @ExcludeMissing fun _description(): JsonField = description + /** + * Returns the raw JSON value of [priceBaseQuantity]. + * + * Unlike [priceBaseQuantity], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("price_base_quantity") + @ExcludeMissing + fun _priceBaseQuantity(): JsonField = priceBaseQuantity + /** * Returns the raw JSON value of [productCode]. * @@ -3836,6 +5282,7 @@ private constructor( private var charges: JsonField>? = null private var date: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() + private var priceBaseQuantity: JsonField = JsonMissing.of() private var productCode: JsonField = JsonMissing.of() private var quantity: JsonField = JsonMissing.of() private var tax: JsonField = JsonMissing.of() @@ -3851,6 +5298,7 @@ private constructor( charges = item.charges.map { it.toMutableList() } date = item.date description = item.description + priceBaseQuantity = item.priceBaseQuantity productCode = item.productCode quantity = item.quantity tax = item.tax @@ -3892,8 +5340,9 @@ private constructor( } /** - * The total amount of the line item, exclusive of VAT, after subtracting line level - * allowances and adding line level charges. Must be rounded to maximum 2 decimals + * The invoice line net amount (BT-131), exclusive of VAT, inclusive of line level + * allowances and charges. Calculated as: ((unit_price / price_base_quantity) * + * quantity) - allowances + charges. Must be rounded to maximum 2 decimals */ fun amount(amount: String?) = amount(JsonField.ofNullable(amount)) @@ -3969,6 +5418,30 @@ private constructor( this.description = description } + /** + * The item price base quantity (BT-149). The number of item units to which the price + * applies. Defaults to 1. Must be rounded to maximum 4 decimals + */ + fun priceBaseQuantity(priceBaseQuantity: String?) = + priceBaseQuantity(JsonField.ofNullable(priceBaseQuantity)) + + /** + * Alias for calling [Builder.priceBaseQuantity] with `priceBaseQuantity.orElse(null)`. + */ + fun priceBaseQuantity(priceBaseQuantity: Optional) = + priceBaseQuantity(priceBaseQuantity.getOrNull()) + + /** + * Sets [Builder.priceBaseQuantity] to an arbitrary JSON value. + * + * You should usually call [Builder.priceBaseQuantity] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun priceBaseQuantity(priceBaseQuantity: JsonField) = apply { + this.priceBaseQuantity = priceBaseQuantity + } + /** The product code of the line item. */ fun productCode(productCode: String?) = productCode(JsonField.ofNullable(productCode)) @@ -4049,7 +5522,10 @@ private constructor( */ fun unit(unit: JsonField) = apply { this.unit = unit } - /** The unit price of the line item. Must be rounded to maximum 2 decimals */ + /** + * The item net price (BT-146). The price of an item, exclusive of VAT, after + * subtracting item price discount. Must be rounded to maximum 4 decimals + */ fun unitPrice(unitPrice: String?) = unitPrice(JsonField.ofNullable(unitPrice)) /** Alias for calling [Builder.unitPrice] with `unitPrice.orElse(null)`. */ @@ -4095,6 +5571,7 @@ private constructor( (charges ?: JsonMissing.of()).map { it.toImmutable() }, date, description, + priceBaseQuantity, productCode, quantity, tax, @@ -4117,6 +5594,7 @@ private constructor( charges().ifPresent { it.forEach { it.validate() } } date() description() + priceBaseQuantity() productCode() quantity() tax() @@ -4147,6 +5625,7 @@ private constructor( (charges.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (date.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + + (if (priceBaseQuantity.asKnown().isPresent) 1 else 0) + (if (productCode.asKnown().isPresent) 1 else 0) + (if (quantity.asKnown().isPresent) 1 else 0) + (if (tax.asKnown().isPresent) 1 else 0) + @@ -4165,6 +5644,7 @@ private constructor( charges == other.charges && date == other.date && description == other.description && + priceBaseQuantity == other.priceBaseQuantity && productCode == other.productCode && quantity == other.quantity && tax == other.tax && @@ -4181,6 +5661,7 @@ private constructor( charges, date, description, + priceBaseQuantity, productCode, quantity, tax, @@ -4194,7 +5675,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Item{allowances=$allowances, amount=$amount, charges=$charges, date=$date, description=$description, productCode=$productCode, quantity=$quantity, tax=$tax, taxRate=$taxRate, unit=$unit, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" + "Item{allowances=$allowances, amount=$amount, charges=$charges, date=$date, description=$description, priceBaseQuantity=$priceBaseQuantity, productCode=$productCode, quantity=$quantity, tax=$tax, taxRate=$taxRate, unit=$unit, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" } class PaymentDetail diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/AllowanceTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/AllowanceTest.kt index 5f6c011..ecb459f 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/AllowanceTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/AllowanceTest.kt @@ -17,7 +17,7 @@ internal class AllowanceTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Allowance.ReasonCode._41) .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -26,7 +26,7 @@ internal class AllowanceTest { assertThat(allowance.baseAmount()).contains("base_amount") assertThat(allowance.multiplierFactor()).contains("multiplier_factor") assertThat(allowance.reason()).contains("reason") - assertThat(allowance.reasonCode()).contains("reason_code") + assertThat(allowance.reasonCode()).contains(Allowance.ReasonCode._41) assertThat(allowance.taxCode()).contains(Allowance.TaxCode.AE) assertThat(allowance.taxRate()).contains("tax_rate") } @@ -40,7 +40,7 @@ internal class AllowanceTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Allowance.ReasonCode._41) .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/ChargeTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/ChargeTest.kt index 8a868cb..f308f4e 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/ChargeTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/ChargeTest.kt @@ -17,18 +17,18 @@ internal class ChargeTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Charge.ReasonCode.AA) .taxCode(Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() assertThat(charge.amount()).contains("amount") assertThat(charge.baseAmount()).contains("base_amount") assertThat(charge.multiplierFactor()).contains("multiplier_factor") assertThat(charge.reason()).contains("reason") - assertThat(charge.reasonCode()).contains("reason_code") + assertThat(charge.reasonCode()).contains(Charge.ReasonCode.AA) assertThat(charge.taxCode()).contains(Charge.TaxCode.AE) - assertThat(charge.taxRate()).contains("tax_rate") + assertThat(charge.taxRate()).contains("21.00") } @Test @@ -40,9 +40,9 @@ internal class ChargeTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Charge.ReasonCode.AA) .taxCode(Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() val roundtrippedCharge = diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponseTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponseTest.kt index 7c7d640..083e676 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponseTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponseTest.kt @@ -22,7 +22,7 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Allowance.ReasonCode._41) .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -44,9 +44,9 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Charge.ReasonCode.AA) .taxCode(Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -71,7 +71,7 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Allowance.ReasonCode._41) .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -83,17 +83,18 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Charge.ReasonCode.AA) .taxCode(Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity("price_base_quantity") .productCode("product_code") .quantity("quantity") .tax("tax") - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice("unit_price") .build() @@ -148,7 +149,7 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Allowance.ReasonCode._41) .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -173,9 +174,9 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Charge.ReasonCode.AA) .taxCode(Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) assertThat(documentCreateFromPdfResponse.currency()).contains(CurrencyCode.EUR) @@ -203,7 +204,7 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Allowance.ReasonCode._41) .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -215,17 +216,18 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Charge.ReasonCode.AA) .taxCode(Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity("price_base_quantity") .productCode("product_code") .quantity("quantity") .tax("tax") - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice("unit_price") .build() @@ -295,7 +297,7 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Allowance.ReasonCode._41) .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -317,9 +319,9 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Charge.ReasonCode.AA) .taxCode(Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -344,7 +346,7 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Allowance.ReasonCode._41) .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -356,17 +358,18 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Charge.ReasonCode.AA) .taxCode(Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity("price_base_quantity") .productCode("product_code") .quantity("quantity") .tax("tax") - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice("unit_price") .build() diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateParamsTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateParamsTest.kt index 6aec828..0f2de16 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateParamsTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateParamsTest.kt @@ -20,9 +20,9 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -42,9 +42,9 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -69,9 +69,9 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -81,17 +81,18 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -149,9 +150,9 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -171,9 +172,9 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -198,9 +199,9 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -210,17 +211,18 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -276,9 +278,9 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -298,9 +300,9 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -325,9 +327,9 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -337,17 +339,18 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateTest.kt index 655056f..a23844c 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateTest.kt @@ -22,9 +22,9 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -44,9 +44,9 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -71,9 +71,9 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -83,17 +83,18 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -141,9 +142,9 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) assertThat(documentCreate.amountDue()).contains(DocumentCreate.AmountDue.ofNumber(0.0)) @@ -165,9 +166,9 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) assertThat(documentCreate.currency()).contains(CurrencyCode.EUR) @@ -194,9 +195,9 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -206,17 +207,18 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -273,9 +275,9 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -295,9 +297,9 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -322,9 +324,9 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -334,17 +336,18 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentResponseTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentResponseTest.kt index a404ab7..9eb8cdc 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentResponseTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentResponseTest.kt @@ -24,7 +24,7 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentResponse.Allowance.ReasonCode._41) .taxCode(DocumentResponse.Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -47,9 +47,9 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentResponse.Charge.ReasonCode.AA) .taxCode(DocumentResponse.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -74,7 +74,7 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Allowance.ReasonCode._41) .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -86,17 +86,18 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Charge.ReasonCode.AA) .taxCode(Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity("price_base_quantity") .productCode("product_code") .quantity("quantity") .tax("tax") - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice("unit_price") .build() @@ -147,7 +148,7 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentResponse.Allowance.ReasonCode._41) .taxCode(DocumentResponse.Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -172,9 +173,9 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentResponse.Charge.ReasonCode.AA) .taxCode(DocumentResponse.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) assertThat(documentResponse.currency()).contains(CurrencyCode.EUR) @@ -201,7 +202,7 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Allowance.ReasonCode._41) .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -213,17 +214,18 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Charge.ReasonCode.AA) .taxCode(Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity("price_base_quantity") .productCode("product_code") .quantity("quantity") .tax("tax") - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice("unit_price") .build() @@ -282,7 +284,7 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentResponse.Allowance.ReasonCode._41) .taxCode(DocumentResponse.Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -305,9 +307,9 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentResponse.Charge.ReasonCode.AA) .taxCode(DocumentResponse.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -332,7 +334,7 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Allowance.ReasonCode._41) .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -344,17 +346,18 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Charge.ReasonCode.AA) .taxCode(Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity("price_base_quantity") .productCode("product_code") .quantity("quantity") .tax("tax") - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice("unit_price") .build() diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt index 987a7ec..1ab4feb 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt @@ -31,7 +31,7 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentResponse.Allowance.ReasonCode._41) .taxCode(DocumentResponse.Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -54,9 +54,9 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentResponse.Charge.ReasonCode.AA) .taxCode(DocumentResponse.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -81,7 +81,7 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Allowance.ReasonCode._41) .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -93,17 +93,18 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Charge.ReasonCode.AA) .taxCode(Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity("price_base_quantity") .productCode("product_code") .quantity("quantity") .tax("tax") - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice("unit_price") .build() @@ -165,7 +166,7 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentResponse.Allowance.ReasonCode._41) .taxCode(DocumentResponse.Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -188,9 +189,9 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentResponse.Charge.ReasonCode.AA) .taxCode(DocumentResponse.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -215,7 +216,7 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Allowance.ReasonCode._41) .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -227,17 +228,18 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Charge.ReasonCode.AA) .taxCode(Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity("price_base_quantity") .productCode("product_code") .quantity("quantity") .tax("tax") - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice("unit_price") .build() @@ -300,7 +302,7 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentResponse.Allowance.ReasonCode._41) .taxCode(DocumentResponse.Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -323,9 +325,9 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentResponse.Charge.ReasonCode.AA) .taxCode(DocumentResponse.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -350,7 +352,7 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Allowance.ReasonCode._41) .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -362,17 +364,18 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Charge.ReasonCode.AA) .taxCode(Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity("price_base_quantity") .productCode("product_code") .quantity("quantity") .tax("tax") - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice("unit_price") .build() diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/validate/ValidateValidateJsonParamsTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/validate/ValidateValidateJsonParamsTest.kt index 44d2c71..66c0e68 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/validate/ValidateValidateJsonParamsTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/validate/ValidateValidateJsonParamsTest.kt @@ -27,9 +27,9 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -49,9 +49,9 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -76,9 +76,9 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -88,17 +88,18 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -156,9 +157,9 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -178,9 +179,9 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -205,9 +206,9 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -217,17 +218,18 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -283,9 +285,9 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -305,9 +307,9 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -332,9 +334,9 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -344,17 +346,18 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ErrorHandlingTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ErrorHandlingTest.kt index 44a8ed8..ef1c67c 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ErrorHandlingTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ErrorHandlingTest.kt @@ -86,9 +86,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -108,9 +108,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -135,9 +135,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -147,17 +147,18 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -227,9 +228,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -249,9 +250,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -276,9 +277,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -288,17 +289,18 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -368,9 +370,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -390,9 +392,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -417,9 +419,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -429,17 +431,18 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -509,9 +512,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -531,9 +534,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -558,9 +561,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -570,17 +573,18 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -650,9 +654,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -672,9 +676,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -699,9 +703,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -711,17 +715,18 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -791,9 +796,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -813,9 +818,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -840,9 +845,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -852,17 +857,18 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -932,9 +938,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -954,9 +960,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -981,9 +987,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -993,17 +999,18 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -1073,9 +1080,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -1095,9 +1102,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -1122,9 +1129,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -1134,17 +1141,18 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -1214,9 +1222,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -1236,9 +1244,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -1263,9 +1271,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -1275,17 +1283,18 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -1355,9 +1364,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -1377,9 +1386,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -1404,9 +1413,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -1416,17 +1425,18 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -1496,9 +1506,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -1518,9 +1528,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -1545,9 +1555,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -1557,17 +1567,18 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -1637,9 +1648,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -1659,9 +1670,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -1686,9 +1697,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -1698,17 +1709,18 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -1778,9 +1790,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -1800,9 +1812,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -1827,9 +1839,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -1839,17 +1851,18 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -1919,9 +1932,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -1941,9 +1954,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -1968,9 +1981,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -1980,17 +1993,18 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -2060,9 +2074,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -2082,9 +2096,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -2109,9 +2123,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -2121,17 +2135,18 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -2201,9 +2216,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -2223,9 +2238,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -2250,9 +2265,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -2262,17 +2277,18 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -2340,9 +2356,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -2362,9 +2378,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -2389,9 +2405,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -2401,17 +2417,18 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ServiceParamsTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ServiceParamsTest.kt index 44e13bd..1153aaf 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ServiceParamsTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ServiceParamsTest.kt @@ -56,9 +56,9 @@ internal class ServiceParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -78,9 +78,9 @@ internal class ServiceParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -105,9 +105,9 @@ internal class ServiceParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -117,17 +117,18 @@ internal class ServiceParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncTest.kt index c75bf1d..a752360 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncTest.kt @@ -41,9 +41,9 @@ internal class DocumentServiceAsyncTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -63,9 +63,9 @@ internal class DocumentServiceAsyncTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -90,9 +90,9 @@ internal class DocumentServiceAsyncTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -102,17 +102,18 @@ internal class DocumentServiceAsyncTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/ValidateServiceAsyncTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/ValidateServiceAsyncTest.kt index 827c4e0..d62ca64 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/ValidateServiceAsyncTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/ValidateServiceAsyncTest.kt @@ -41,9 +41,9 @@ internal class ValidateServiceAsyncTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -63,9 +63,9 @@ internal class ValidateServiceAsyncTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -90,9 +90,9 @@ internal class ValidateServiceAsyncTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -102,17 +102,18 @@ internal class ValidateServiceAsyncTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/DocumentServiceTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/DocumentServiceTest.kt index c34988c..ad08546 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/DocumentServiceTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/DocumentServiceTest.kt @@ -41,9 +41,9 @@ internal class DocumentServiceTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -63,9 +63,9 @@ internal class DocumentServiceTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -90,9 +90,9 @@ internal class DocumentServiceTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -102,17 +102,18 @@ internal class DocumentServiceTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/ValidateServiceTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/ValidateServiceTest.kt index 936c28c..b35236d 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/ValidateServiceTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/ValidateServiceTest.kt @@ -41,9 +41,9 @@ internal class ValidateServiceTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -63,9 +63,9 @@ internal class ValidateServiceTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -90,9 +90,9 @@ internal class ValidateServiceTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -102,17 +102,18 @@ internal class ValidateServiceTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) .description("description") + .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() diff --git a/e-invoice-java-proguard-test/src/test/kotlin/com/e_invoice/api/proguard/ProGuardCompatibilityTest.kt b/e-invoice-java-proguard-test/src/test/kotlin/com/e_invoice/api/proguard/ProGuardCompatibilityTest.kt index e6113ec..301a053 100644 --- a/e-invoice-java-proguard-test/src/test/kotlin/com/e_invoice/api/proguard/ProGuardCompatibilityTest.kt +++ b/e-invoice-java-proguard-test/src/test/kotlin/com/e_invoice/api/proguard/ProGuardCompatibilityTest.kt @@ -66,7 +66,7 @@ internal class ProGuardCompatibilityTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Allowance.ReasonCode._41) .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() From 010d7f1fc776ed37da2fb55f96ade8267e184cee Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Nov 2025 13:13:54 +0000 Subject: [PATCH 10/43] feat(api): api update --- .stats.yml | 4 +- .../api/models/documents/Allowance.kt | 298 +- .../e_invoice/api/models/documents/Charge.kt | 1218 +-- .../api/models/documents/DocumentCreate.kt | 7501 ++++------------- .../DocumentCreateFromPdfResponse.kt | 76 +- .../api/models/documents/DocumentResponse.kt | 1589 +--- .../api/models/documents/AllowanceTest.kt | 6 +- .../api/models/documents/ChargeTest.kt | 12 +- .../DocumentCreateFromPdfResponseTest.kt | 45 +- .../documents/DocumentCreateParamsTest.kt | 57 +- .../models/documents/DocumentCreateTest.kt | 57 +- .../models/documents/DocumentResponseTest.kt | 45 +- .../inbox/PaginatedDocumentResponseTest.kt | 45 +- .../ValidateValidateJsonParamsTest.kt | 57 +- .../api/services/ErrorHandlingTest.kt | 323 +- .../api/services/ServiceParamsTest.kt | 19 +- .../async/DocumentServiceAsyncTest.kt | 19 +- .../async/ValidateServiceAsyncTest.kt | 19 +- .../services/blocking/DocumentServiceTest.kt | 19 +- .../services/blocking/ValidateServiceTest.kt | 19 +- .../api/proguard/ProGuardCompatibilityTest.kt | 2 +- 21 files changed, 2222 insertions(+), 9208 deletions(-) diff --git a/.stats.yml b/.stats.yml index e83c012..12f0e7f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-59acba77a8b016bab32cdc817ebca4ffda9d446803c3f28d662d85666d49d0ad.yml -openapi_spec_hash: aac8accb851703f53ab7e17a5fb23a48 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-009e20418b5b4a984fbc1a6c74d2148f2ebb823568699babb83ec8a4f2aea1f7.yml +openapi_spec_hash: 8a63ae95d8d7e7beaaf306f1bb2b1cd3 config_hash: 852a0117abb3db077933876ad1185f41 diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Allowance.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Allowance.kt index 0351698..75ac28d 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Allowance.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Allowance.kt @@ -25,7 +25,7 @@ private constructor( private val baseAmount: JsonField, private val multiplierFactor: JsonField, private val reason: JsonField, - private val reasonCode: JsonField, + private val reasonCode: JsonField, private val taxCode: JsonField, private val taxRate: JsonField, private val additionalProperties: MutableMap, @@ -43,7 +43,7 @@ private constructor( @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), @JsonProperty("reason_code") @ExcludeMissing - reasonCode: JsonField = JsonMissing.of(), + reasonCode: JsonField = JsonMissing.of(), @JsonProperty("tax_code") @ExcludeMissing taxCode: JsonField = JsonMissing.of(), @JsonProperty("tax_rate") @ExcludeMissing taxRate: JsonField = JsonMissing.of(), ) : this( @@ -76,7 +76,7 @@ private constructor( /** * The percentage that may be used, in conjunction with the allowance base amount, to calculate - * the allowance amount. To state 20%, use value 20. Must be rounded to maximum 2 decimals + * the allowance amount. To state 20%, use value 20 * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -92,15 +92,17 @@ private constructor( fun reason(): Optional = reason.getOptional("reason") /** - * Allowance reason codes for invoice discounts and charges + * The code for the allowance reason * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun reasonCode(): Optional = reasonCode.getOptional("reason_code") + fun reasonCode(): Optional = reasonCode.getOptional("reason_code") /** - * The VAT category code that applies to the allowance + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -108,8 +110,7 @@ private constructor( fun taxCode(): Optional = taxCode.getOptional("tax_code") /** - * The VAT rate, represented as percentage that applies to the allowance. Must be rounded to - * maximum 2 decimals + * The VAT rate, represented as percentage that applies to the allowance * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -152,9 +153,7 @@ private constructor( * * Unlike [reasonCode], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("reason_code") - @ExcludeMissing - fun _reasonCode(): JsonField = reasonCode + @JsonProperty("reason_code") @ExcludeMissing fun _reasonCode(): JsonField = reasonCode /** * Returns the raw JSON value of [taxCode]. @@ -195,7 +194,7 @@ private constructor( private var baseAmount: JsonField = JsonMissing.of() private var multiplierFactor: JsonField = JsonMissing.of() private var reason: JsonField = JsonMissing.of() - private var reasonCode: JsonField = JsonMissing.of() + private var reasonCode: JsonField = JsonMissing.of() private var taxCode: JsonField = JsonMissing.of() private var taxRate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -246,8 +245,7 @@ private constructor( /** * The percentage that may be used, in conjunction with the allowance base amount, to - * calculate the allowance amount. To state 20%, use value 20. Must be rounded to maximum 2 - * decimals + * calculate the allowance amount. To state 20%, use value 20 */ fun multiplierFactor(multiplierFactor: String?) = multiplierFactor(JsonField.ofNullable(multiplierFactor)) @@ -281,23 +279,30 @@ private constructor( */ fun reason(reason: JsonField) = apply { this.reason = reason } - /** Allowance reason codes for invoice discounts and charges */ - fun reasonCode(reasonCode: ReasonCode?) = reasonCode(JsonField.ofNullable(reasonCode)) + /** The code for the allowance reason */ + fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ - fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) + fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) /** * Sets [Builder.reasonCode] to an arbitrary JSON value. * - * You should usually call [Builder.reasonCode] with a well-typed [ReasonCode] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.reasonCode] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode } + + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL */ - fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode } + fun taxCode(taxCode: TaxCode?) = taxCode(JsonField.ofNullable(taxCode)) - /** The VAT category code that applies to the allowance */ - fun taxCode(taxCode: TaxCode) = taxCode(JsonField.of(taxCode)) + /** Alias for calling [Builder.taxCode] with `taxCode.orElse(null)`. */ + fun taxCode(taxCode: Optional) = taxCode(taxCode.getOrNull()) /** * Sets [Builder.taxCode] to an arbitrary JSON value. @@ -307,10 +312,7 @@ private constructor( */ fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } - /** - * The VAT rate, represented as percentage that applies to the allowance. Must be rounded to - * maximum 2 decimals - */ + /** The VAT rate, represented as percentage that applies to the allowance */ fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ @@ -372,7 +374,7 @@ private constructor( baseAmount() multiplierFactor() reason() - reasonCode().ifPresent { it.validate() } + reasonCode() taxCode().ifPresent { it.validate() } taxRate() validated = true @@ -397,243 +399,15 @@ private constructor( (if (baseAmount.asKnown().isPresent) 1 else 0) + (if (multiplierFactor.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) + - (reasonCode.asKnown().getOrNull()?.validity() ?: 0) + + (if (reasonCode.asKnown().isPresent) 1 else 0) + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + (if (taxRate.asKnown().isPresent) 1 else 0) - /** Allowance reason codes for invoice discounts and charges */ - class ReasonCode @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val _41 = of("41") - - @JvmField val _42 = of("42") - - @JvmField val _60 = of("60") - - @JvmField val _62 = of("62") - - @JvmField val _63 = of("63") - - @JvmField val _64 = of("64") - - @JvmField val _65 = of("65") - - @JvmField val _66 = of("66") - - @JvmField val _67 = of("67") - - @JvmField val _68 = of("68") - - @JvmField val _70 = of("70") - - @JvmField val _71 = of("71") - - @JvmField val _88 = of("88") - - @JvmField val _95 = of("95") - - @JvmField val _100 = of("100") - - @JvmField val _102 = of("102") - - @JvmField val _103 = of("103") - - @JvmField val _104 = of("104") - - @JvmField val _105 = of("105") - - @JvmStatic fun of(value: String) = ReasonCode(JsonField.of(value)) - } - - /** An enum containing [ReasonCode]'s known values. */ - enum class Known { - _41, - _42, - _60, - _62, - _63, - _64, - _65, - _66, - _67, - _68, - _70, - _71, - _88, - _95, - _100, - _102, - _103, - _104, - _105, - } - - /** - * An enum containing [ReasonCode]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ReasonCode] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - _41, - _42, - _60, - _62, - _63, - _64, - _65, - _66, - _67, - _68, - _70, - _71, - _88, - _95, - _100, - _102, - _103, - _104, - _105, - /** - * An enum member indicating that [ReasonCode] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - _41 -> Value._41 - _42 -> Value._42 - _60 -> Value._60 - _62 -> Value._62 - _63 -> Value._63 - _64 -> Value._64 - _65 -> Value._65 - _66 -> Value._66 - _67 -> Value._67 - _68 -> Value._68 - _70 -> Value._70 - _71 -> Value._71 - _88 -> Value._88 - _95 -> Value._95 - _100 -> Value._100 - _102 -> Value._102 - _103 -> Value._103 - _104 -> Value._104 - _105 -> Value._105 - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws EInvoiceInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - _41 -> Known._41 - _42 -> Known._42 - _60 -> Known._60 - _62 -> Known._62 - _63 -> Known._63 - _64 -> Known._64 - _65 -> Known._65 - _66 -> Known._66 - _67 -> Known._67 - _68 -> Known._68 - _70 -> Known._70 - _71 -> Known._71 - _88 -> Known._88 - _95 -> Known._95 - _100 -> Known._100 - _102 -> Known._102 - _103 -> Known._103 - _104 -> Known._104 - _105 -> Known._105 - else -> throw EInvoiceInvalidDataException("Unknown ReasonCode: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws EInvoiceInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - EInvoiceInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): ReasonCode = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ReasonCode && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** The VAT category code that applies to the allowance */ + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + */ class TaxCode @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Charge.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Charge.kt index 45e1ce7..3654cc2 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Charge.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Charge.kt @@ -25,7 +25,7 @@ private constructor( private val baseAmount: JsonField, private val multiplierFactor: JsonField, private val reason: JsonField, - private val reasonCode: JsonField, + private val reasonCode: JsonField, private val taxCode: JsonField, private val taxRate: JsonField, private val additionalProperties: MutableMap, @@ -43,7 +43,7 @@ private constructor( @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), @JsonProperty("reason_code") @ExcludeMissing - reasonCode: JsonField = JsonMissing.of(), + reasonCode: JsonField = JsonMissing.of(), @JsonProperty("tax_code") @ExcludeMissing taxCode: JsonField = JsonMissing.of(), @JsonProperty("tax_rate") @ExcludeMissing taxRate: JsonField = JsonMissing.of(), ) : this( @@ -92,12 +92,12 @@ private constructor( fun reason(): Optional = reason.getOptional("reason") /** - * Charge reason codes for invoice charges and fees + * The code for the charge reason * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun reasonCode(): Optional = reasonCode.getOptional("reason_code") + fun reasonCode(): Optional = reasonCode.getOptional("reason_code") /** * Duty or tax or fee category codes (Subset of UNCL5305) @@ -153,9 +153,7 @@ private constructor( * * Unlike [reasonCode], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("reason_code") - @ExcludeMissing - fun _reasonCode(): JsonField = reasonCode + @JsonProperty("reason_code") @ExcludeMissing fun _reasonCode(): JsonField = reasonCode /** * Returns the raw JSON value of [taxCode]. @@ -196,7 +194,7 @@ private constructor( private var baseAmount: JsonField = JsonMissing.of() private var multiplierFactor: JsonField = JsonMissing.of() private var reason: JsonField = JsonMissing.of() - private var reasonCode: JsonField = JsonMissing.of() + private var reasonCode: JsonField = JsonMissing.of() private var taxCode: JsonField = JsonMissing.of() private var taxRate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -281,20 +279,20 @@ private constructor( */ fun reason(reason: JsonField) = apply { this.reason = reason } - /** Charge reason codes for invoice charges and fees */ - fun reasonCode(reasonCode: ReasonCode?) = reasonCode(JsonField.ofNullable(reasonCode)) + /** The code for the charge reason */ + fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ - fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) + fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) /** * Sets [Builder.reasonCode] to an arbitrary JSON value. * - * You should usually call [Builder.reasonCode] with a well-typed [ReasonCode] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.reasonCode] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode } + fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode } /** * Duty or tax or fee category codes (Subset of UNCL5305) @@ -376,7 +374,7 @@ private constructor( baseAmount() multiplierFactor() reason() - reasonCode().ifPresent { it.validate() } + reasonCode() taxCode().ifPresent { it.validate() } taxRate() validated = true @@ -401,1196 +399,10 @@ private constructor( (if (baseAmount.asKnown().isPresent) 1 else 0) + (if (multiplierFactor.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) + - (reasonCode.asKnown().getOrNull()?.validity() ?: 0) + + (if (reasonCode.asKnown().isPresent) 1 else 0) + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + (if (taxRate.asKnown().isPresent) 1 else 0) - /** Charge reason codes for invoice charges and fees */ - class ReasonCode @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val AA = of("AA") - - @JvmField val AAA = of("AAA") - - @JvmField val AAC = of("AAC") - - @JvmField val AAD = of("AAD") - - @JvmField val AAE = of("AAE") - - @JvmField val AAF = of("AAF") - - @JvmField val AAH = of("AAH") - - @JvmField val AAI = of("AAI") - - @JvmField val AAS = of("AAS") - - @JvmField val AAT = of("AAT") - - @JvmField val AAV = of("AAV") - - @JvmField val AAY = of("AAY") - - @JvmField val AAZ = of("AAZ") - - @JvmField val ABA = of("ABA") - - @JvmField val ABB = of("ABB") - - @JvmField val ABC = of("ABC") - - @JvmField val ABD = of("ABD") - - @JvmField val ABF = of("ABF") - - @JvmField val ABK = of("ABK") - - @JvmField val ABL = of("ABL") - - @JvmField val ABN = of("ABN") - - @JvmField val ABR = of("ABR") - - @JvmField val ABS = of("ABS") - - @JvmField val ABT = of("ABT") - - @JvmField val ABU = of("ABU") - - @JvmField val ACF = of("ACF") - - @JvmField val ACG = of("ACG") - - @JvmField val ACH = of("ACH") - - @JvmField val ACI = of("ACI") - - @JvmField val ACJ = of("ACJ") - - @JvmField val ACK = of("ACK") - - @JvmField val ACL = of("ACL") - - @JvmField val ACM = of("ACM") - - @JvmField val ACS = of("ACS") - - @JvmField val ADC = of("ADC") - - @JvmField val ADE = of("ADE") - - @JvmField val ADJ = of("ADJ") - - @JvmField val ADK = of("ADK") - - @JvmField val ADL = of("ADL") - - @JvmField val ADM = of("ADM") - - @JvmField val ADN = of("ADN") - - @JvmField val ADO = of("ADO") - - @JvmField val ADP = of("ADP") - - @JvmField val ADQ = of("ADQ") - - @JvmField val ADR = of("ADR") - - @JvmField val ADT = of("ADT") - - @JvmField val ADW = of("ADW") - - @JvmField val ADY = of("ADY") - - @JvmField val ADZ = of("ADZ") - - @JvmField val AEA = of("AEA") - - @JvmField val AEB = of("AEB") - - @JvmField val AEC = of("AEC") - - @JvmField val AED = of("AED") - - @JvmField val AEF = of("AEF") - - @JvmField val AEH = of("AEH") - - @JvmField val AEI = of("AEI") - - @JvmField val AEJ = of("AEJ") - - @JvmField val AEK = of("AEK") - - @JvmField val AEL = of("AEL") - - @JvmField val AEM = of("AEM") - - @JvmField val AEN = of("AEN") - - @JvmField val AEO = of("AEO") - - @JvmField val AEP = of("AEP") - - @JvmField val AES = of("AES") - - @JvmField val AET = of("AET") - - @JvmField val AEU = of("AEU") - - @JvmField val AEV = of("AEV") - - @JvmField val AEW = of("AEW") - - @JvmField val AEX = of("AEX") - - @JvmField val AEY = of("AEY") - - @JvmField val AEZ = of("AEZ") - - @JvmField val AJ = of("AJ") - - @JvmField val AU = of("AU") - - @JvmField val CA = of("CA") - - @JvmField val CAB = of("CAB") - - @JvmField val CAD = of("CAD") - - @JvmField val CAE = of("CAE") - - @JvmField val CAF = of("CAF") - - @JvmField val CAI = of("CAI") - - @JvmField val CAJ = of("CAJ") - - @JvmField val CAK = of("CAK") - - @JvmField val CAL = of("CAL") - - @JvmField val CAM = of("CAM") - - @JvmField val CAN = of("CAN") - - @JvmField val CAO = of("CAO") - - @JvmField val CAP = of("CAP") - - @JvmField val CAQ = of("CAQ") - - @JvmField val CAR = of("CAR") - - @JvmField val CAS = of("CAS") - - @JvmField val CAT = of("CAT") - - @JvmField val CAU = of("CAU") - - @JvmField val CAV = of("CAV") - - @JvmField val CAW = of("CAW") - - @JvmField val CAX = of("CAX") - - @JvmField val CAY = of("CAY") - - @JvmField val CAZ = of("CAZ") - - @JvmField val CD = of("CD") - - @JvmField val CG = of("CG") - - @JvmField val CS = of("CS") - - @JvmField val CT = of("CT") - - @JvmField val DAB = of("DAB") - - @JvmField val DAC = of("DAC") - - @JvmField val DAD = of("DAD") - - @JvmField val DAF = of("DAF") - - @JvmField val DAG = of("DAG") - - @JvmField val DAH = of("DAH") - - @JvmField val DAI = of("DAI") - - @JvmField val DAJ = of("DAJ") - - @JvmField val DAK = of("DAK") - - @JvmField val DAL = of("DAL") - - @JvmField val DAM = of("DAM") - - @JvmField val DAN = of("DAN") - - @JvmField val DAO = of("DAO") - - @JvmField val DAP = of("DAP") - - @JvmField val DAQ = of("DAQ") - - @JvmField val DL = of("DL") - - @JvmField val EG = of("EG") - - @JvmField val EP = of("EP") - - @JvmField val ER = of("ER") - - @JvmField val FAA = of("FAA") - - @JvmField val FAB = of("FAB") - - @JvmField val FAC = of("FAC") - - @JvmField val FC = of("FC") - - @JvmField val FH = of("FH") - - @JvmField val FI = of("FI") - - @JvmField val GAA = of("GAA") - - @JvmField val HAA = of("HAA") - - @JvmField val HD = of("HD") - - @JvmField val HH = of("HH") - - @JvmField val IAA = of("IAA") - - @JvmField val IAB = of("IAB") - - @JvmField val ID = of("ID") - - @JvmField val IF = of("IF") - - @JvmField val IR = of("IR") - - @JvmField val IS = of("IS") - - @JvmField val KO = of("KO") - - @JvmField val L1 = of("L1") - - @JvmField val LA = of("LA") - - @JvmField val LAA = of("LAA") - - @JvmField val LAB = of("LAB") - - @JvmField val LF = of("LF") - - @JvmField val MAE = of("MAE") - - @JvmField val MI = of("MI") - - @JvmField val ML = of("ML") - - @JvmField val NAA = of("NAA") - - @JvmField val OA = of("OA") - - @JvmField val PA = of("PA") - - @JvmField val PAA = of("PAA") - - @JvmField val PC = of("PC") - - @JvmField val PL = of("PL") - - @JvmField val PRV = of("PRV") - - @JvmField val RAB = of("RAB") - - @JvmField val RAC = of("RAC") - - @JvmField val RAD = of("RAD") - - @JvmField val RAF = of("RAF") - - @JvmField val RE = of("RE") - - @JvmField val RF = of("RF") - - @JvmField val RH = of("RH") - - @JvmField val RV = of("RV") - - @JvmField val SA = of("SA") - - @JvmField val SAA = of("SAA") - - @JvmField val SAD = of("SAD") - - @JvmField val SAE = of("SAE") - - @JvmField val SAI = of("SAI") - - @JvmField val SG = of("SG") - - @JvmField val SH = of("SH") - - @JvmField val SM = of("SM") - - @JvmField val SU = of("SU") - - @JvmField val TAB = of("TAB") - - @JvmField val TAC = of("TAC") - - @JvmField val TT = of("TT") - - @JvmField val TV = of("TV") - - @JvmField val V1 = of("V1") - - @JvmField val V2 = of("V2") - - @JvmField val WH = of("WH") - - @JvmField val XAA = of("XAA") - - @JvmField val YY = of("YY") - - @JvmField val ZZZ = of("ZZZ") - - @JvmStatic fun of(value: String) = ReasonCode(JsonField.of(value)) - } - - /** An enum containing [ReasonCode]'s known values. */ - enum class Known { - AA, - AAA, - AAC, - AAD, - AAE, - AAF, - AAH, - AAI, - AAS, - AAT, - AAV, - AAY, - AAZ, - ABA, - ABB, - ABC, - ABD, - ABF, - ABK, - ABL, - ABN, - ABR, - ABS, - ABT, - ABU, - ACF, - ACG, - ACH, - ACI, - ACJ, - ACK, - ACL, - ACM, - ACS, - ADC, - ADE, - ADJ, - ADK, - ADL, - ADM, - ADN, - ADO, - ADP, - ADQ, - ADR, - ADT, - ADW, - ADY, - ADZ, - AEA, - AEB, - AEC, - AED, - AEF, - AEH, - AEI, - AEJ, - AEK, - AEL, - AEM, - AEN, - AEO, - AEP, - AES, - AET, - AEU, - AEV, - AEW, - AEX, - AEY, - AEZ, - AJ, - AU, - CA, - CAB, - CAD, - CAE, - CAF, - CAI, - CAJ, - CAK, - CAL, - CAM, - CAN, - CAO, - CAP, - CAQ, - CAR, - CAS, - CAT, - CAU, - CAV, - CAW, - CAX, - CAY, - CAZ, - CD, - CG, - CS, - CT, - DAB, - DAC, - DAD, - DAF, - DAG, - DAH, - DAI, - DAJ, - DAK, - DAL, - DAM, - DAN, - DAO, - DAP, - DAQ, - DL, - EG, - EP, - ER, - FAA, - FAB, - FAC, - FC, - FH, - FI, - GAA, - HAA, - HD, - HH, - IAA, - IAB, - ID, - IF, - IR, - IS, - KO, - L1, - LA, - LAA, - LAB, - LF, - MAE, - MI, - ML, - NAA, - OA, - PA, - PAA, - PC, - PL, - PRV, - RAB, - RAC, - RAD, - RAF, - RE, - RF, - RH, - RV, - SA, - SAA, - SAD, - SAE, - SAI, - SG, - SH, - SM, - SU, - TAB, - TAC, - TT, - TV, - V1, - V2, - WH, - XAA, - YY, - ZZZ, - } - - /** - * An enum containing [ReasonCode]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ReasonCode] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AA, - AAA, - AAC, - AAD, - AAE, - AAF, - AAH, - AAI, - AAS, - AAT, - AAV, - AAY, - AAZ, - ABA, - ABB, - ABC, - ABD, - ABF, - ABK, - ABL, - ABN, - ABR, - ABS, - ABT, - ABU, - ACF, - ACG, - ACH, - ACI, - ACJ, - ACK, - ACL, - ACM, - ACS, - ADC, - ADE, - ADJ, - ADK, - ADL, - ADM, - ADN, - ADO, - ADP, - ADQ, - ADR, - ADT, - ADW, - ADY, - ADZ, - AEA, - AEB, - AEC, - AED, - AEF, - AEH, - AEI, - AEJ, - AEK, - AEL, - AEM, - AEN, - AEO, - AEP, - AES, - AET, - AEU, - AEV, - AEW, - AEX, - AEY, - AEZ, - AJ, - AU, - CA, - CAB, - CAD, - CAE, - CAF, - CAI, - CAJ, - CAK, - CAL, - CAM, - CAN, - CAO, - CAP, - CAQ, - CAR, - CAS, - CAT, - CAU, - CAV, - CAW, - CAX, - CAY, - CAZ, - CD, - CG, - CS, - CT, - DAB, - DAC, - DAD, - DAF, - DAG, - DAH, - DAI, - DAJ, - DAK, - DAL, - DAM, - DAN, - DAO, - DAP, - DAQ, - DL, - EG, - EP, - ER, - FAA, - FAB, - FAC, - FC, - FH, - FI, - GAA, - HAA, - HD, - HH, - IAA, - IAB, - ID, - IF, - IR, - IS, - KO, - L1, - LA, - LAA, - LAB, - LF, - MAE, - MI, - ML, - NAA, - OA, - PA, - PAA, - PC, - PL, - PRV, - RAB, - RAC, - RAD, - RAF, - RE, - RF, - RH, - RV, - SA, - SAA, - SAD, - SAE, - SAI, - SG, - SH, - SM, - SU, - TAB, - TAC, - TT, - TV, - V1, - V2, - WH, - XAA, - YY, - ZZZ, - /** - * An enum member indicating that [ReasonCode] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AA -> Value.AA - AAA -> Value.AAA - AAC -> Value.AAC - AAD -> Value.AAD - AAE -> Value.AAE - AAF -> Value.AAF - AAH -> Value.AAH - AAI -> Value.AAI - AAS -> Value.AAS - AAT -> Value.AAT - AAV -> Value.AAV - AAY -> Value.AAY - AAZ -> Value.AAZ - ABA -> Value.ABA - ABB -> Value.ABB - ABC -> Value.ABC - ABD -> Value.ABD - ABF -> Value.ABF - ABK -> Value.ABK - ABL -> Value.ABL - ABN -> Value.ABN - ABR -> Value.ABR - ABS -> Value.ABS - ABT -> Value.ABT - ABU -> Value.ABU - ACF -> Value.ACF - ACG -> Value.ACG - ACH -> Value.ACH - ACI -> Value.ACI - ACJ -> Value.ACJ - ACK -> Value.ACK - ACL -> Value.ACL - ACM -> Value.ACM - ACS -> Value.ACS - ADC -> Value.ADC - ADE -> Value.ADE - ADJ -> Value.ADJ - ADK -> Value.ADK - ADL -> Value.ADL - ADM -> Value.ADM - ADN -> Value.ADN - ADO -> Value.ADO - ADP -> Value.ADP - ADQ -> Value.ADQ - ADR -> Value.ADR - ADT -> Value.ADT - ADW -> Value.ADW - ADY -> Value.ADY - ADZ -> Value.ADZ - AEA -> Value.AEA - AEB -> Value.AEB - AEC -> Value.AEC - AED -> Value.AED - AEF -> Value.AEF - AEH -> Value.AEH - AEI -> Value.AEI - AEJ -> Value.AEJ - AEK -> Value.AEK - AEL -> Value.AEL - AEM -> Value.AEM - AEN -> Value.AEN - AEO -> Value.AEO - AEP -> Value.AEP - AES -> Value.AES - AET -> Value.AET - AEU -> Value.AEU - AEV -> Value.AEV - AEW -> Value.AEW - AEX -> Value.AEX - AEY -> Value.AEY - AEZ -> Value.AEZ - AJ -> Value.AJ - AU -> Value.AU - CA -> Value.CA - CAB -> Value.CAB - CAD -> Value.CAD - CAE -> Value.CAE - CAF -> Value.CAF - CAI -> Value.CAI - CAJ -> Value.CAJ - CAK -> Value.CAK - CAL -> Value.CAL - CAM -> Value.CAM - CAN -> Value.CAN - CAO -> Value.CAO - CAP -> Value.CAP - CAQ -> Value.CAQ - CAR -> Value.CAR - CAS -> Value.CAS - CAT -> Value.CAT - CAU -> Value.CAU - CAV -> Value.CAV - CAW -> Value.CAW - CAX -> Value.CAX - CAY -> Value.CAY - CAZ -> Value.CAZ - CD -> Value.CD - CG -> Value.CG - CS -> Value.CS - CT -> Value.CT - DAB -> Value.DAB - DAC -> Value.DAC - DAD -> Value.DAD - DAF -> Value.DAF - DAG -> Value.DAG - DAH -> Value.DAH - DAI -> Value.DAI - DAJ -> Value.DAJ - DAK -> Value.DAK - DAL -> Value.DAL - DAM -> Value.DAM - DAN -> Value.DAN - DAO -> Value.DAO - DAP -> Value.DAP - DAQ -> Value.DAQ - DL -> Value.DL - EG -> Value.EG - EP -> Value.EP - ER -> Value.ER - FAA -> Value.FAA - FAB -> Value.FAB - FAC -> Value.FAC - FC -> Value.FC - FH -> Value.FH - FI -> Value.FI - GAA -> Value.GAA - HAA -> Value.HAA - HD -> Value.HD - HH -> Value.HH - IAA -> Value.IAA - IAB -> Value.IAB - ID -> Value.ID - IF -> Value.IF - IR -> Value.IR - IS -> Value.IS - KO -> Value.KO - L1 -> Value.L1 - LA -> Value.LA - LAA -> Value.LAA - LAB -> Value.LAB - LF -> Value.LF - MAE -> Value.MAE - MI -> Value.MI - ML -> Value.ML - NAA -> Value.NAA - OA -> Value.OA - PA -> Value.PA - PAA -> Value.PAA - PC -> Value.PC - PL -> Value.PL - PRV -> Value.PRV - RAB -> Value.RAB - RAC -> Value.RAC - RAD -> Value.RAD - RAF -> Value.RAF - RE -> Value.RE - RF -> Value.RF - RH -> Value.RH - RV -> Value.RV - SA -> Value.SA - SAA -> Value.SAA - SAD -> Value.SAD - SAE -> Value.SAE - SAI -> Value.SAI - SG -> Value.SG - SH -> Value.SH - SM -> Value.SM - SU -> Value.SU - TAB -> Value.TAB - TAC -> Value.TAC - TT -> Value.TT - TV -> Value.TV - V1 -> Value.V1 - V2 -> Value.V2 - WH -> Value.WH - XAA -> Value.XAA - YY -> Value.YY - ZZZ -> Value.ZZZ - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws EInvoiceInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AA -> Known.AA - AAA -> Known.AAA - AAC -> Known.AAC - AAD -> Known.AAD - AAE -> Known.AAE - AAF -> Known.AAF - AAH -> Known.AAH - AAI -> Known.AAI - AAS -> Known.AAS - AAT -> Known.AAT - AAV -> Known.AAV - AAY -> Known.AAY - AAZ -> Known.AAZ - ABA -> Known.ABA - ABB -> Known.ABB - ABC -> Known.ABC - ABD -> Known.ABD - ABF -> Known.ABF - ABK -> Known.ABK - ABL -> Known.ABL - ABN -> Known.ABN - ABR -> Known.ABR - ABS -> Known.ABS - ABT -> Known.ABT - ABU -> Known.ABU - ACF -> Known.ACF - ACG -> Known.ACG - ACH -> Known.ACH - ACI -> Known.ACI - ACJ -> Known.ACJ - ACK -> Known.ACK - ACL -> Known.ACL - ACM -> Known.ACM - ACS -> Known.ACS - ADC -> Known.ADC - ADE -> Known.ADE - ADJ -> Known.ADJ - ADK -> Known.ADK - ADL -> Known.ADL - ADM -> Known.ADM - ADN -> Known.ADN - ADO -> Known.ADO - ADP -> Known.ADP - ADQ -> Known.ADQ - ADR -> Known.ADR - ADT -> Known.ADT - ADW -> Known.ADW - ADY -> Known.ADY - ADZ -> Known.ADZ - AEA -> Known.AEA - AEB -> Known.AEB - AEC -> Known.AEC - AED -> Known.AED - AEF -> Known.AEF - AEH -> Known.AEH - AEI -> Known.AEI - AEJ -> Known.AEJ - AEK -> Known.AEK - AEL -> Known.AEL - AEM -> Known.AEM - AEN -> Known.AEN - AEO -> Known.AEO - AEP -> Known.AEP - AES -> Known.AES - AET -> Known.AET - AEU -> Known.AEU - AEV -> Known.AEV - AEW -> Known.AEW - AEX -> Known.AEX - AEY -> Known.AEY - AEZ -> Known.AEZ - AJ -> Known.AJ - AU -> Known.AU - CA -> Known.CA - CAB -> Known.CAB - CAD -> Known.CAD - CAE -> Known.CAE - CAF -> Known.CAF - CAI -> Known.CAI - CAJ -> Known.CAJ - CAK -> Known.CAK - CAL -> Known.CAL - CAM -> Known.CAM - CAN -> Known.CAN - CAO -> Known.CAO - CAP -> Known.CAP - CAQ -> Known.CAQ - CAR -> Known.CAR - CAS -> Known.CAS - CAT -> Known.CAT - CAU -> Known.CAU - CAV -> Known.CAV - CAW -> Known.CAW - CAX -> Known.CAX - CAY -> Known.CAY - CAZ -> Known.CAZ - CD -> Known.CD - CG -> Known.CG - CS -> Known.CS - CT -> Known.CT - DAB -> Known.DAB - DAC -> Known.DAC - DAD -> Known.DAD - DAF -> Known.DAF - DAG -> Known.DAG - DAH -> Known.DAH - DAI -> Known.DAI - DAJ -> Known.DAJ - DAK -> Known.DAK - DAL -> Known.DAL - DAM -> Known.DAM - DAN -> Known.DAN - DAO -> Known.DAO - DAP -> Known.DAP - DAQ -> Known.DAQ - DL -> Known.DL - EG -> Known.EG - EP -> Known.EP - ER -> Known.ER - FAA -> Known.FAA - FAB -> Known.FAB - FAC -> Known.FAC - FC -> Known.FC - FH -> Known.FH - FI -> Known.FI - GAA -> Known.GAA - HAA -> Known.HAA - HD -> Known.HD - HH -> Known.HH - IAA -> Known.IAA - IAB -> Known.IAB - ID -> Known.ID - IF -> Known.IF - IR -> Known.IR - IS -> Known.IS - KO -> Known.KO - L1 -> Known.L1 - LA -> Known.LA - LAA -> Known.LAA - LAB -> Known.LAB - LF -> Known.LF - MAE -> Known.MAE - MI -> Known.MI - ML -> Known.ML - NAA -> Known.NAA - OA -> Known.OA - PA -> Known.PA - PAA -> Known.PAA - PC -> Known.PC - PL -> Known.PL - PRV -> Known.PRV - RAB -> Known.RAB - RAC -> Known.RAC - RAD -> Known.RAD - RAF -> Known.RAF - RE -> Known.RE - RF -> Known.RF - RH -> Known.RH - RV -> Known.RV - SA -> Known.SA - SAA -> Known.SAA - SAD -> Known.SAD - SAE -> Known.SAE - SAI -> Known.SAI - SG -> Known.SG - SH -> Known.SH - SM -> Known.SM - SU -> Known.SU - TAB -> Known.TAB - TAC -> Known.TAC - TT -> Known.TT - TV -> Known.TV - V1 -> Known.V1 - V2 -> Known.V2 - WH -> Known.WH - XAA -> Known.XAA - YY -> Known.YY - ZZZ -> Known.ZZZ - else -> throw EInvoiceInvalidDataException("Unknown ReasonCode: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws EInvoiceInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - EInvoiceInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): ReasonCode = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ReasonCode && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - /** * Duty or tax or fee category codes (Subset of UNCL5305) * diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt index af5a6d3..5828329 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt @@ -2369,9 +2369,9 @@ private constructor( private val baseAmount: JsonField, private val multiplierFactor: JsonField, private val reason: JsonField, - private val reasonCode: JsonField, + private val reasonCode: JsonField, private val taxCode: JsonField, - private val taxRate: JsonField, + private val taxRate: JsonField, private val additionalProperties: MutableMap, ) { @@ -2387,11 +2387,11 @@ private constructor( @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), @JsonProperty("reason_code") @ExcludeMissing - reasonCode: JsonField = JsonMissing.of(), + reasonCode: JsonField = JsonMissing.of(), @JsonProperty("tax_code") @ExcludeMissing taxCode: JsonField = JsonMissing.of(), - @JsonProperty("tax_rate") @ExcludeMissing taxRate: JsonField = JsonMissing.of(), + @JsonProperty("tax_rate") @ExcludeMissing taxRate: JsonField = JsonMissing.of(), ) : this( amount, baseAmount, @@ -2422,8 +2422,7 @@ private constructor( /** * The percentage that may be used, in conjunction with the allowance base amount, to - * calculate the allowance amount. To state 20%, use value 20. Must be rounded to maximum 2 - * decimals + * calculate the allowance amount. To state 20%, use value 20 * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -2440,15 +2439,17 @@ private constructor( fun reason(): Optional = reason.getOptional("reason") /** - * Allowance reason codes for invoice discounts and charges + * The code for the allowance reason * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun reasonCode(): Optional = reasonCode.getOptional("reason_code") + fun reasonCode(): Optional = reasonCode.getOptional("reason_code") /** - * The VAT category code that applies to the allowance + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -2456,13 +2457,12 @@ private constructor( fun taxCode(): Optional = taxCode.getOptional("tax_code") /** - * The VAT rate, represented as percentage that applies to the allowance. Must be rounded to - * maximum 2 decimals + * The VAT rate, represented as percentage that applies to the allowance * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun taxRate(): Optional = taxRate.getOptional("tax_rate") + fun taxRate(): Optional = taxRate.getOptional("tax_rate") /** * Returns the raw JSON value of [amount]. @@ -2504,7 +2504,7 @@ private constructor( */ @JsonProperty("reason_code") @ExcludeMissing - fun _reasonCode(): JsonField = reasonCode + fun _reasonCode(): JsonField = reasonCode /** * Returns the raw JSON value of [taxCode]. @@ -2518,7 +2518,7 @@ private constructor( * * Unlike [taxRate], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate + @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -2545,9 +2545,9 @@ private constructor( private var baseAmount: JsonField = JsonMissing.of() private var multiplierFactor: JsonField = JsonMissing.of() private var reason: JsonField = JsonMissing.of() - private var reasonCode: JsonField = JsonMissing.of() + private var reasonCode: JsonField = JsonMissing.of() private var taxCode: JsonField = JsonMissing.of() - private var taxRate: JsonField = JsonMissing.of() + private var taxRate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2611,8 +2611,7 @@ private constructor( /** * The percentage that may be used, in conjunction with the allowance base amount, to - * calculate the allowance amount. To state 20%, use value 20. Must be rounded to - * maximum 2 decimals + * calculate the allowance amount. To state 20%, use value 20 */ fun multiplierFactor(multiplierFactor: MultiplierFactor?) = multiplierFactor(JsonField.ofNullable(multiplierFactor)) @@ -2657,25 +2656,30 @@ private constructor( */ fun reason(reason: JsonField) = apply { this.reason = reason } - /** Allowance reason codes for invoice discounts and charges */ - fun reasonCode(reasonCode: ReasonCode?) = reasonCode(JsonField.ofNullable(reasonCode)) + /** The code for the allowance reason */ + fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ - fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) + fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) /** * Sets [Builder.reasonCode] to an arbitrary JSON value. * - * You should usually call [Builder.reasonCode] with a well-typed [ReasonCode] value + * You should usually call [Builder.reasonCode] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun reasonCode(reasonCode: JsonField) = apply { - this.reasonCode = reasonCode - } + fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode } + + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + */ + fun taxCode(taxCode: TaxCode?) = taxCode(JsonField.ofNullable(taxCode)) - /** The VAT category code that applies to the allowance */ - fun taxCode(taxCode: TaxCode) = taxCode(JsonField.of(taxCode)) + /** Alias for calling [Builder.taxCode] with `taxCode.orElse(null)`. */ + fun taxCode(taxCode: Optional) = taxCode(taxCode.getOrNull()) /** * Sets [Builder.taxCode] to an arbitrary JSON value. @@ -2686,29 +2690,20 @@ private constructor( */ fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } - /** - * The VAT rate, represented as percentage that applies to the allowance. Must be - * rounded to maximum 2 decimals - */ - fun taxRate(taxRate: TaxRate?) = taxRate(JsonField.ofNullable(taxRate)) + /** The VAT rate, represented as percentage that applies to the allowance */ + fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ - fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) + fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) /** * Sets [Builder.taxRate] to an arbitrary JSON value. * - * You should usually call [Builder.taxRate] with a well-typed [TaxRate] value instead. + * You should usually call [Builder.taxRate] with a well-typed [String] value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } - - /** Alias for calling [taxRate] with `TaxRate.ofNumber(number)`. */ - fun taxRate(number: Double) = taxRate(TaxRate.ofNumber(number)) - - /** Alias for calling [taxRate] with `TaxRate.ofString(string)`. */ - fun taxRate(string: String) = taxRate(TaxRate.ofString(string)) + fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2758,9 +2753,9 @@ private constructor( baseAmount().ifPresent { it.validate() } multiplierFactor().ifPresent { it.validate() } reason() - reasonCode().ifPresent { it.validate() } + reasonCode() taxCode().ifPresent { it.validate() } - taxRate().ifPresent { it.validate() } + taxRate() validated = true } @@ -2784,9 +2779,9 @@ private constructor( (baseAmount.asKnown().getOrNull()?.validity() ?: 0) + (multiplierFactor.asKnown().getOrNull()?.validity() ?: 0) + (if (reason.asKnown().isPresent) 1 else 0) + - (reasonCode.asKnown().getOrNull()?.validity() ?: 0) + + (if (reasonCode.asKnown().isPresent) 1 else 0) + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + - (taxRate.asKnown().getOrNull()?.validity() ?: 0) + (if (taxRate.asKnown().isPresent) 1 else 0) /** The allowance amount, without VAT. Must be rounded to maximum 2 decimals */ @JsonDeserialize(using = Amount.Deserializer::class) @@ -3134,8 +3129,7 @@ private constructor( /** * The percentage that may be used, in conjunction with the allowance base amount, to - * calculate the allowance amount. To state 20%, use value 20. Must be rounded to maximum 2 - * decimals + * calculate the allowance amount. To state 20%, use value 20 */ @JsonDeserialize(using = MultiplierFactor.Deserializer::class) @JsonSerialize(using = MultiplierFactor.Serializer::class) @@ -3308,241 +3302,11 @@ private constructor( } } - /** Allowance reason codes for invoice discounts and charges */ - class ReasonCode @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val _41 = of("41") - - @JvmField val _42 = of("42") - - @JvmField val _60 = of("60") - - @JvmField val _62 = of("62") - - @JvmField val _63 = of("63") - - @JvmField val _64 = of("64") - - @JvmField val _65 = of("65") - - @JvmField val _66 = of("66") - - @JvmField val _67 = of("67") - - @JvmField val _68 = of("68") - - @JvmField val _70 = of("70") - - @JvmField val _71 = of("71") - - @JvmField val _88 = of("88") - - @JvmField val _95 = of("95") - - @JvmField val _100 = of("100") - - @JvmField val _102 = of("102") - - @JvmField val _103 = of("103") - - @JvmField val _104 = of("104") - - @JvmField val _105 = of("105") - - @JvmStatic fun of(value: String) = ReasonCode(JsonField.of(value)) - } - - /** An enum containing [ReasonCode]'s known values. */ - enum class Known { - _41, - _42, - _60, - _62, - _63, - _64, - _65, - _66, - _67, - _68, - _70, - _71, - _88, - _95, - _100, - _102, - _103, - _104, - _105, - } - - /** - * An enum containing [ReasonCode]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ReasonCode] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - _41, - _42, - _60, - _62, - _63, - _64, - _65, - _66, - _67, - _68, - _70, - _71, - _88, - _95, - _100, - _102, - _103, - _104, - _105, - /** - * An enum member indicating that [ReasonCode] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - _41 -> Value._41 - _42 -> Value._42 - _60 -> Value._60 - _62 -> Value._62 - _63 -> Value._63 - _64 -> Value._64 - _65 -> Value._65 - _66 -> Value._66 - _67 -> Value._67 - _68 -> Value._68 - _70 -> Value._70 - _71 -> Value._71 - _88 -> Value._88 - _95 -> Value._95 - _100 -> Value._100 - _102 -> Value._102 - _103 -> Value._103 - _104 -> Value._104 - _105 -> Value._105 - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws EInvoiceInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - _41 -> Known._41 - _42 -> Known._42 - _60 -> Known._60 - _62 -> Known._62 - _63 -> Known._63 - _64 -> Known._64 - _65 -> Known._65 - _66 -> Known._66 - _67 -> Known._67 - _68 -> Known._68 - _70 -> Known._70 - _71 -> Known._71 - _88 -> Known._88 - _95 -> Known._95 - _100 -> Known._100 - _102 -> Known._102 - _103 -> Known._103 - _104 -> Known._104 - _105 -> Known._105 - else -> throw EInvoiceInvalidDataException("Unknown ReasonCode: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws EInvoiceInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - EInvoiceInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): ReasonCode = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ReasonCode && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** The VAT category code that applies to the allowance */ + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + */ class TaxCode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3721,262 +3485,88 @@ private constructor( override fun toString() = value.toString() } - /** - * The VAT rate, represented as percentage that applies to the allowance. Must be rounded to - * maximum 2 decimals - */ - @JsonDeserialize(using = TaxRate.Deserializer::class) - @JsonSerialize(using = TaxRate.Serializer::class) - class TaxRate - private constructor( - private val number: Double? = null, - private val string: String? = null, - private val _json: JsonValue? = null, - ) { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun number(): Optional = Optional.ofNullable(number) + return other is Allowance && + amount == other.amount && + baseAmount == other.baseAmount && + multiplierFactor == other.multiplierFactor && + reason == other.reason && + reasonCode == other.reasonCode && + taxCode == other.taxCode && + taxRate == other.taxRate && + additionalProperties == other.additionalProperties + } - fun string(): Optional = Optional.ofNullable(string) + private val hashCode: Int by lazy { + Objects.hash( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + additionalProperties, + ) + } - fun isNumber(): Boolean = number != null + override fun hashCode(): Int = hashCode - fun isString(): Boolean = string != null + override fun toString() = + "Allowance{amount=$amount, baseAmount=$baseAmount, multiplierFactor=$multiplierFactor, reason=$reason, reasonCode=$reasonCode, taxCode=$taxCode, taxRate=$taxRate, additionalProperties=$additionalProperties}" + } - fun asNumber(): Double = number.getOrThrow("number") + /** The amount due for payment. Must be positive and rounded to maximum 2 decimals */ + @JsonDeserialize(using = AmountDue.Deserializer::class) + @JsonSerialize(using = AmountDue.Serializer::class) + class AmountDue + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { - fun asString(): String = string.getOrThrow("string") + fun number(): Optional = Optional.ofNullable(number) - fun _json(): Optional = Optional.ofNullable(_json) + fun string(): Optional = Optional.ofNullable(string) - fun accept(visitor: Visitor): T = - when { - number != null -> visitor.visitNumber(number) - string != null -> visitor.visitString(string) - else -> visitor.unknown(_json) - } + fun isNumber(): Boolean = number != null - private var validated: Boolean = false + fun isString(): Boolean = string != null - fun validate(): TaxRate = apply { - if (validated) { - return@apply - } + fun asNumber(): Double = number.getOrThrow("number") - accept( - object : Visitor { - override fun visitNumber(number: Double) {} + fun asString(): String = string.getOrThrow("string") - override fun visitString(string: String) {} - } - ) - validated = true + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false + private var validated: Boolean = false + + fun validate(): AmountDue = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitNumber(number: Double) = 1 - - override fun visitString(string: String) = 1 - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TaxRate && number == other.number && string == other.string - } - - override fun hashCode(): Int = Objects.hash(number, string) - - override fun toString(): String = - when { - number != null -> "TaxRate{number=$number}" - string != null -> "TaxRate{string=$string}" - _json != null -> "TaxRate{_unknown=$_json}" - else -> throw IllegalStateException("Invalid TaxRate") - } - - companion object { - - @JvmStatic fun ofNumber(number: Double) = TaxRate(number = number) - - @JvmStatic fun ofString(string: String) = TaxRate(string = string) - } - - /** - * An interface that defines how to map each variant of [TaxRate] to a value of type - * [T]. - */ - interface Visitor { - - fun visitNumber(number: Double): T - - fun visitString(string: String): T - - /** - * Maps an unknown variant of [TaxRate] to a value of type [T]. - * - * An instance of [TaxRate] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws EInvoiceInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw EInvoiceInvalidDataException("Unknown TaxRate: $json") - } - } - - internal class Deserializer : BaseDeserializer(TaxRate::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): TaxRate { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - TaxRate(number = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - TaxRate(string = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from object). - 0 -> TaxRate(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the - // first completely valid match, or simply the first match if none are - // completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(TaxRate::class) { - - override fun serialize( - value: TaxRate, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.number != null -> generator.writeObject(value.number) - value.string != null -> generator.writeObject(value.string) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid TaxRate") - } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Allowance && - amount == other.amount && - baseAmount == other.baseAmount && - multiplierFactor == other.multiplierFactor && - reason == other.reason && - reasonCode == other.reasonCode && - taxCode == other.taxCode && - taxRate == other.taxRate && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - amount, - baseAmount, - multiplierFactor, - reason, - reasonCode, - taxCode, - taxRate, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Allowance{amount=$amount, baseAmount=$baseAmount, multiplierFactor=$multiplierFactor, reason=$reason, reasonCode=$reasonCode, taxCode=$taxCode, taxRate=$taxRate, additionalProperties=$additionalProperties}" - } - - /** The amount due for payment. Must be positive and rounded to maximum 2 decimals */ - @JsonDeserialize(using = AmountDue.Deserializer::class) - @JsonSerialize(using = AmountDue.Serializer::class) - class AmountDue - private constructor( - private val number: Double? = null, - private val string: String? = null, - private val _json: JsonValue? = null, - ) { - - fun number(): Optional = Optional.ofNullable(number) - - fun string(): Optional = Optional.ofNullable(string) - - fun isNumber(): Boolean = number != null - - fun isString(): Boolean = string != null - - fun asNumber(): Double = number.getOrThrow("number") - - fun asString(): String = string.getOrThrow("string") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - number != null -> visitor.visitNumber(number) - string != null -> visitor.visitString(string) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): AmountDue = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitNumber(number: Double) {} - - override fun visitString(string: String) {} - } - ) - validated = true - } + ) + validated = true + } fun isValid(): Boolean = try { @@ -4108,9 +3698,9 @@ private constructor( private val baseAmount: JsonField, private val multiplierFactor: JsonField, private val reason: JsonField, - private val reasonCode: JsonField, + private val reasonCode: JsonField, private val taxCode: JsonField, - private val taxRate: JsonField, + private val taxRate: JsonField, private val additionalProperties: MutableMap, ) { @@ -4126,11 +3716,11 @@ private constructor( @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), @JsonProperty("reason_code") @ExcludeMissing - reasonCode: JsonField = JsonMissing.of(), + reasonCode: JsonField = JsonMissing.of(), @JsonProperty("tax_code") @ExcludeMissing taxCode: JsonField = JsonMissing.of(), - @JsonProperty("tax_rate") @ExcludeMissing taxRate: JsonField = JsonMissing.of(), + @JsonProperty("tax_rate") @ExcludeMissing taxRate: JsonField = JsonMissing.of(), ) : this( amount, baseAmount, @@ -4178,12 +3768,12 @@ private constructor( fun reason(): Optional = reason.getOptional("reason") /** - * Charge reason codes for invoice charges and fees + * The code for the charge reason * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun reasonCode(): Optional = reasonCode.getOptional("reason_code") + fun reasonCode(): Optional = reasonCode.getOptional("reason_code") /** * Duty or tax or fee category codes (Subset of UNCL5305) @@ -4201,7 +3791,7 @@ private constructor( * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun taxRate(): Optional = taxRate.getOptional("tax_rate") + fun taxRate(): Optional = taxRate.getOptional("tax_rate") /** * Returns the raw JSON value of [amount]. @@ -4243,7 +3833,7 @@ private constructor( */ @JsonProperty("reason_code") @ExcludeMissing - fun _reasonCode(): JsonField = reasonCode + fun _reasonCode(): JsonField = reasonCode /** * Returns the raw JSON value of [taxCode]. @@ -4257,7 +3847,7 @@ private constructor( * * Unlike [taxRate], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate + @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -4284,9 +3874,9 @@ private constructor( private var baseAmount: JsonField = JsonMissing.of() private var multiplierFactor: JsonField = JsonMissing.of() private var reason: JsonField = JsonMissing.of() - private var reasonCode: JsonField = JsonMissing.of() + private var reasonCode: JsonField = JsonMissing.of() private var taxCode: JsonField = JsonMissing.of() - private var taxRate: JsonField = JsonMissing.of() + private var taxRate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4395,22 +3985,20 @@ private constructor( */ fun reason(reason: JsonField) = apply { this.reason = reason } - /** Charge reason codes for invoice charges and fees */ - fun reasonCode(reasonCode: ReasonCode?) = reasonCode(JsonField.ofNullable(reasonCode)) + /** The code for the charge reason */ + fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ - fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) + fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) /** * Sets [Builder.reasonCode] to an arbitrary JSON value. * - * You should usually call [Builder.reasonCode] with a well-typed [ReasonCode] value + * You should usually call [Builder.reasonCode] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun reasonCode(reasonCode: JsonField) = apply { - this.reasonCode = reasonCode - } + fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode } /** * Duty or tax or fee category codes (Subset of UNCL5305) @@ -4432,25 +4020,19 @@ private constructor( fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } /** The VAT rate, represented as percentage that applies to the charge */ - fun taxRate(taxRate: TaxRate?) = taxRate(JsonField.ofNullable(taxRate)) + fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ - fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) + fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) /** * Sets [Builder.taxRate] to an arbitrary JSON value. * - * You should usually call [Builder.taxRate] with a well-typed [TaxRate] value instead. + * You should usually call [Builder.taxRate] with a well-typed [String] value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } - - /** Alias for calling [taxRate] with `TaxRate.ofNumber(number)`. */ - fun taxRate(number: Double) = taxRate(TaxRate.ofNumber(number)) - - /** Alias for calling [taxRate] with `TaxRate.ofString(string)`. */ - fun taxRate(string: String) = taxRate(TaxRate.ofString(string)) + fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -4500,9 +4082,9 @@ private constructor( baseAmount().ifPresent { it.validate() } multiplierFactor().ifPresent { it.validate() } reason() - reasonCode().ifPresent { it.validate() } + reasonCode() taxCode().ifPresent { it.validate() } - taxRate().ifPresent { it.validate() } + taxRate() validated = true } @@ -4526,9 +4108,9 @@ private constructor( (baseAmount.asKnown().getOrNull()?.validity() ?: 0) + (multiplierFactor.asKnown().getOrNull()?.validity() ?: 0) + (if (reason.asKnown().isPresent) 1 else 0) + - (reasonCode.asKnown().getOrNull()?.validity() ?: 0) + + (if (reasonCode.asKnown().isPresent) 1 else 0) + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + - (taxRate.asKnown().getOrNull()?.validity() ?: 0) + (if (taxRate.asKnown().isPresent) 1 else 0) /** The charge amount, without VAT. Must be rounded to maximum 2 decimals */ @JsonDeserialize(using = Amount.Deserializer::class) @@ -5049,8 +4631,12 @@ private constructor( } } - /** Charge reason codes for invoice charges and fees */ - class ReasonCode @JsonCreator private constructor(private val value: JsonField) : + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + */ + class TaxCode @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -5065,741 +4651,68 @@ private constructor( companion object { - @JvmField val AA = of("AA") - - @JvmField val AAA = of("AAA") - - @JvmField val AAC = of("AAC") - - @JvmField val AAD = of("AAD") - - @JvmField val AAE = of("AAE") - - @JvmField val AAF = of("AAF") - - @JvmField val AAH = of("AAH") - - @JvmField val AAI = of("AAI") - - @JvmField val AAS = of("AAS") - - @JvmField val AAT = of("AAT") - - @JvmField val AAV = of("AAV") - - @JvmField val AAY = of("AAY") - - @JvmField val AAZ = of("AAZ") - - @JvmField val ABA = of("ABA") - - @JvmField val ABB = of("ABB") - - @JvmField val ABC = of("ABC") - - @JvmField val ABD = of("ABD") - - @JvmField val ABF = of("ABF") - - @JvmField val ABK = of("ABK") + @JvmField val AE = of("AE") - @JvmField val ABL = of("ABL") + @JvmField val E = of("E") - @JvmField val ABN = of("ABN") + @JvmField val S = of("S") - @JvmField val ABR = of("ABR") + @JvmField val Z = of("Z") - @JvmField val ABS = of("ABS") + @JvmField val G = of("G") - @JvmField val ABT = of("ABT") + @JvmField val O = of("O") - @JvmField val ABU = of("ABU") + @JvmField val K = of("K") - @JvmField val ACF = of("ACF") + @JvmField val L = of("L") - @JvmField val ACG = of("ACG") + @JvmField val M = of("M") - @JvmField val ACH = of("ACH") + @JvmField val B = of("B") - @JvmField val ACI = of("ACI") + @JvmStatic fun of(value: String) = TaxCode(JsonField.of(value)) + } - @JvmField val ACJ = of("ACJ") + /** An enum containing [TaxCode]'s known values. */ + enum class Known { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + } - @JvmField val ACK = of("ACK") - - @JvmField val ACL = of("ACL") - - @JvmField val ACM = of("ACM") - - @JvmField val ACS = of("ACS") - - @JvmField val ADC = of("ADC") - - @JvmField val ADE = of("ADE") - - @JvmField val ADJ = of("ADJ") - - @JvmField val ADK = of("ADK") - - @JvmField val ADL = of("ADL") - - @JvmField val ADM = of("ADM") - - @JvmField val ADN = of("ADN") - - @JvmField val ADO = of("ADO") - - @JvmField val ADP = of("ADP") - - @JvmField val ADQ = of("ADQ") - - @JvmField val ADR = of("ADR") - - @JvmField val ADT = of("ADT") - - @JvmField val ADW = of("ADW") - - @JvmField val ADY = of("ADY") - - @JvmField val ADZ = of("ADZ") - - @JvmField val AEA = of("AEA") - - @JvmField val AEB = of("AEB") - - @JvmField val AEC = of("AEC") - - @JvmField val AED = of("AED") - - @JvmField val AEF = of("AEF") - - @JvmField val AEH = of("AEH") - - @JvmField val AEI = of("AEI") - - @JvmField val AEJ = of("AEJ") - - @JvmField val AEK = of("AEK") - - @JvmField val AEL = of("AEL") - - @JvmField val AEM = of("AEM") - - @JvmField val AEN = of("AEN") - - @JvmField val AEO = of("AEO") - - @JvmField val AEP = of("AEP") - - @JvmField val AES = of("AES") - - @JvmField val AET = of("AET") - - @JvmField val AEU = of("AEU") - - @JvmField val AEV = of("AEV") - - @JvmField val AEW = of("AEW") - - @JvmField val AEX = of("AEX") - - @JvmField val AEY = of("AEY") - - @JvmField val AEZ = of("AEZ") - - @JvmField val AJ = of("AJ") - - @JvmField val AU = of("AU") - - @JvmField val CA = of("CA") - - @JvmField val CAB = of("CAB") - - @JvmField val CAD = of("CAD") - - @JvmField val CAE = of("CAE") - - @JvmField val CAF = of("CAF") - - @JvmField val CAI = of("CAI") - - @JvmField val CAJ = of("CAJ") - - @JvmField val CAK = of("CAK") - - @JvmField val CAL = of("CAL") - - @JvmField val CAM = of("CAM") - - @JvmField val CAN = of("CAN") - - @JvmField val CAO = of("CAO") - - @JvmField val CAP = of("CAP") - - @JvmField val CAQ = of("CAQ") - - @JvmField val CAR = of("CAR") - - @JvmField val CAS = of("CAS") - - @JvmField val CAT = of("CAT") - - @JvmField val CAU = of("CAU") - - @JvmField val CAV = of("CAV") - - @JvmField val CAW = of("CAW") - - @JvmField val CAX = of("CAX") - - @JvmField val CAY = of("CAY") - - @JvmField val CAZ = of("CAZ") - - @JvmField val CD = of("CD") - - @JvmField val CG = of("CG") - - @JvmField val CS = of("CS") - - @JvmField val CT = of("CT") - - @JvmField val DAB = of("DAB") - - @JvmField val DAC = of("DAC") - - @JvmField val DAD = of("DAD") - - @JvmField val DAF = of("DAF") - - @JvmField val DAG = of("DAG") - - @JvmField val DAH = of("DAH") - - @JvmField val DAI = of("DAI") - - @JvmField val DAJ = of("DAJ") - - @JvmField val DAK = of("DAK") - - @JvmField val DAL = of("DAL") - - @JvmField val DAM = of("DAM") - - @JvmField val DAN = of("DAN") - - @JvmField val DAO = of("DAO") - - @JvmField val DAP = of("DAP") - - @JvmField val DAQ = of("DAQ") - - @JvmField val DL = of("DL") - - @JvmField val EG = of("EG") - - @JvmField val EP = of("EP") - - @JvmField val ER = of("ER") - - @JvmField val FAA = of("FAA") - - @JvmField val FAB = of("FAB") - - @JvmField val FAC = of("FAC") - - @JvmField val FC = of("FC") - - @JvmField val FH = of("FH") - - @JvmField val FI = of("FI") - - @JvmField val GAA = of("GAA") - - @JvmField val HAA = of("HAA") - - @JvmField val HD = of("HD") - - @JvmField val HH = of("HH") - - @JvmField val IAA = of("IAA") - - @JvmField val IAB = of("IAB") - - @JvmField val ID = of("ID") - - @JvmField val IF = of("IF") - - @JvmField val IR = of("IR") - - @JvmField val IS = of("IS") - - @JvmField val KO = of("KO") - - @JvmField val L1 = of("L1") - - @JvmField val LA = of("LA") - - @JvmField val LAA = of("LAA") - - @JvmField val LAB = of("LAB") - - @JvmField val LF = of("LF") - - @JvmField val MAE = of("MAE") - - @JvmField val MI = of("MI") - - @JvmField val ML = of("ML") - - @JvmField val NAA = of("NAA") - - @JvmField val OA = of("OA") - - @JvmField val PA = of("PA") - - @JvmField val PAA = of("PAA") - - @JvmField val PC = of("PC") - - @JvmField val PL = of("PL") - - @JvmField val PRV = of("PRV") - - @JvmField val RAB = of("RAB") - - @JvmField val RAC = of("RAC") - - @JvmField val RAD = of("RAD") - - @JvmField val RAF = of("RAF") - - @JvmField val RE = of("RE") - - @JvmField val RF = of("RF") - - @JvmField val RH = of("RH") - - @JvmField val RV = of("RV") - - @JvmField val SA = of("SA") - - @JvmField val SAA = of("SAA") - - @JvmField val SAD = of("SAD") - - @JvmField val SAE = of("SAE") - - @JvmField val SAI = of("SAI") - - @JvmField val SG = of("SG") - - @JvmField val SH = of("SH") - - @JvmField val SM = of("SM") - - @JvmField val SU = of("SU") - - @JvmField val TAB = of("TAB") - - @JvmField val TAC = of("TAC") - - @JvmField val TT = of("TT") - - @JvmField val TV = of("TV") - - @JvmField val V1 = of("V1") - - @JvmField val V2 = of("V2") - - @JvmField val WH = of("WH") - - @JvmField val XAA = of("XAA") - - @JvmField val YY = of("YY") - - @JvmField val ZZZ = of("ZZZ") - - @JvmStatic fun of(value: String) = ReasonCode(JsonField.of(value)) - } - - /** An enum containing [ReasonCode]'s known values. */ - enum class Known { - AA, - AAA, - AAC, - AAD, - AAE, - AAF, - AAH, - AAI, - AAS, - AAT, - AAV, - AAY, - AAZ, - ABA, - ABB, - ABC, - ABD, - ABF, - ABK, - ABL, - ABN, - ABR, - ABS, - ABT, - ABU, - ACF, - ACG, - ACH, - ACI, - ACJ, - ACK, - ACL, - ACM, - ACS, - ADC, - ADE, - ADJ, - ADK, - ADL, - ADM, - ADN, - ADO, - ADP, - ADQ, - ADR, - ADT, - ADW, - ADY, - ADZ, - AEA, - AEB, - AEC, - AED, - AEF, - AEH, - AEI, - AEJ, - AEK, - AEL, - AEM, - AEN, - AEO, - AEP, - AES, - AET, - AEU, - AEV, - AEW, - AEX, - AEY, - AEZ, - AJ, - AU, - CA, - CAB, - CAD, - CAE, - CAF, - CAI, - CAJ, - CAK, - CAL, - CAM, - CAN, - CAO, - CAP, - CAQ, - CAR, - CAS, - CAT, - CAU, - CAV, - CAW, - CAX, - CAY, - CAZ, - CD, - CG, - CS, - CT, - DAB, - DAC, - DAD, - DAF, - DAG, - DAH, - DAI, - DAJ, - DAK, - DAL, - DAM, - DAN, - DAO, - DAP, - DAQ, - DL, - EG, - EP, - ER, - FAA, - FAB, - FAC, - FC, - FH, - FI, - GAA, - HAA, - HD, - HH, - IAA, - IAB, - ID, - IF, - IR, - IS, - KO, - L1, - LA, - LAA, - LAB, - LF, - MAE, - MI, - ML, - NAA, - OA, - PA, - PAA, - PC, - PL, - PRV, - RAB, - RAC, - RAD, - RAF, - RE, - RF, - RH, - RV, - SA, - SAA, - SAD, - SAE, - SAI, - SG, - SH, - SM, - SU, - TAB, - TAC, - TT, - TV, - V1, - V2, - WH, - XAA, - YY, - ZZZ, - } - - /** - * An enum containing [ReasonCode]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ReasonCode] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AA, - AAA, - AAC, - AAD, - AAE, - AAF, - AAH, - AAI, - AAS, - AAT, - AAV, - AAY, - AAZ, - ABA, - ABB, - ABC, - ABD, - ABF, - ABK, - ABL, - ABN, - ABR, - ABS, - ABT, - ABU, - ACF, - ACG, - ACH, - ACI, - ACJ, - ACK, - ACL, - ACM, - ACS, - ADC, - ADE, - ADJ, - ADK, - ADL, - ADM, - ADN, - ADO, - ADP, - ADQ, - ADR, - ADT, - ADW, - ADY, - ADZ, - AEA, - AEB, - AEC, - AED, - AEF, - AEH, - AEI, - AEJ, - AEK, - AEL, - AEM, - AEN, - AEO, - AEP, - AES, - AET, - AEU, - AEV, - AEW, - AEX, - AEY, - AEZ, - AJ, - AU, - CA, - CAB, - CAD, - CAE, - CAF, - CAI, - CAJ, - CAK, - CAL, - CAM, - CAN, - CAO, - CAP, - CAQ, - CAR, - CAS, - CAT, - CAU, - CAV, - CAW, - CAX, - CAY, - CAZ, - CD, - CG, - CS, - CT, - DAB, - DAC, - DAD, - DAF, - DAG, - DAH, - DAI, - DAJ, - DAK, - DAL, - DAM, - DAN, - DAO, - DAP, - DAQ, - DL, - EG, - EP, - ER, - FAA, - FAB, - FAC, - FC, - FH, - FI, - GAA, - HAA, - HD, - HH, - IAA, - IAB, - ID, - IF, - IR, - IS, - KO, - L1, - LA, - LAA, - LAB, - LF, - MAE, - MI, - ML, - NAA, - OA, - PA, - PAA, - PC, - PL, - PRV, - RAB, - RAC, - RAD, - RAF, - RE, - RF, - RH, - RV, - SA, - SAA, - SAD, - SAE, - SAI, - SG, - SH, - SM, - SU, - TAB, - TAC, - TT, - TV, - V1, - V2, - WH, - XAA, - YY, - ZZZ, - /** - * An enum member indicating that [ReasonCode] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + /** + * An enum containing [TaxCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TaxCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + /** + * An enum member indicating that [TaxCode] was instantiated with an unknown value. + */ + _UNKNOWN, + } /** * Returns an enum member corresponding to this class instance's value, or @@ -5810,184 +4723,16 @@ private constructor( */ fun value(): Value = when (this) { - AA -> Value.AA - AAA -> Value.AAA - AAC -> Value.AAC - AAD -> Value.AAD - AAE -> Value.AAE - AAF -> Value.AAF - AAH -> Value.AAH - AAI -> Value.AAI - AAS -> Value.AAS - AAT -> Value.AAT - AAV -> Value.AAV - AAY -> Value.AAY - AAZ -> Value.AAZ - ABA -> Value.ABA - ABB -> Value.ABB - ABC -> Value.ABC - ABD -> Value.ABD - ABF -> Value.ABF - ABK -> Value.ABK - ABL -> Value.ABL - ABN -> Value.ABN - ABR -> Value.ABR - ABS -> Value.ABS - ABT -> Value.ABT - ABU -> Value.ABU - ACF -> Value.ACF - ACG -> Value.ACG - ACH -> Value.ACH - ACI -> Value.ACI - ACJ -> Value.ACJ - ACK -> Value.ACK - ACL -> Value.ACL - ACM -> Value.ACM - ACS -> Value.ACS - ADC -> Value.ADC - ADE -> Value.ADE - ADJ -> Value.ADJ - ADK -> Value.ADK - ADL -> Value.ADL - ADM -> Value.ADM - ADN -> Value.ADN - ADO -> Value.ADO - ADP -> Value.ADP - ADQ -> Value.ADQ - ADR -> Value.ADR - ADT -> Value.ADT - ADW -> Value.ADW - ADY -> Value.ADY - ADZ -> Value.ADZ - AEA -> Value.AEA - AEB -> Value.AEB - AEC -> Value.AEC - AED -> Value.AED - AEF -> Value.AEF - AEH -> Value.AEH - AEI -> Value.AEI - AEJ -> Value.AEJ - AEK -> Value.AEK - AEL -> Value.AEL - AEM -> Value.AEM - AEN -> Value.AEN - AEO -> Value.AEO - AEP -> Value.AEP - AES -> Value.AES - AET -> Value.AET - AEU -> Value.AEU - AEV -> Value.AEV - AEW -> Value.AEW - AEX -> Value.AEX - AEY -> Value.AEY - AEZ -> Value.AEZ - AJ -> Value.AJ - AU -> Value.AU - CA -> Value.CA - CAB -> Value.CAB - CAD -> Value.CAD - CAE -> Value.CAE - CAF -> Value.CAF - CAI -> Value.CAI - CAJ -> Value.CAJ - CAK -> Value.CAK - CAL -> Value.CAL - CAM -> Value.CAM - CAN -> Value.CAN - CAO -> Value.CAO - CAP -> Value.CAP - CAQ -> Value.CAQ - CAR -> Value.CAR - CAS -> Value.CAS - CAT -> Value.CAT - CAU -> Value.CAU - CAV -> Value.CAV - CAW -> Value.CAW - CAX -> Value.CAX - CAY -> Value.CAY - CAZ -> Value.CAZ - CD -> Value.CD - CG -> Value.CG - CS -> Value.CS - CT -> Value.CT - DAB -> Value.DAB - DAC -> Value.DAC - DAD -> Value.DAD - DAF -> Value.DAF - DAG -> Value.DAG - DAH -> Value.DAH - DAI -> Value.DAI - DAJ -> Value.DAJ - DAK -> Value.DAK - DAL -> Value.DAL - DAM -> Value.DAM - DAN -> Value.DAN - DAO -> Value.DAO - DAP -> Value.DAP - DAQ -> Value.DAQ - DL -> Value.DL - EG -> Value.EG - EP -> Value.EP - ER -> Value.ER - FAA -> Value.FAA - FAB -> Value.FAB - FAC -> Value.FAC - FC -> Value.FC - FH -> Value.FH - FI -> Value.FI - GAA -> Value.GAA - HAA -> Value.HAA - HD -> Value.HD - HH -> Value.HH - IAA -> Value.IAA - IAB -> Value.IAB - ID -> Value.ID - IF -> Value.IF - IR -> Value.IR - IS -> Value.IS - KO -> Value.KO - L1 -> Value.L1 - LA -> Value.LA - LAA -> Value.LAA - LAB -> Value.LAB - LF -> Value.LF - MAE -> Value.MAE - MI -> Value.MI - ML -> Value.ML - NAA -> Value.NAA - OA -> Value.OA - PA -> Value.PA - PAA -> Value.PAA - PC -> Value.PC - PL -> Value.PL - PRV -> Value.PRV - RAB -> Value.RAB - RAC -> Value.RAC - RAD -> Value.RAD - RAF -> Value.RAF - RE -> Value.RE - RF -> Value.RF - RH -> Value.RH - RV -> Value.RV - SA -> Value.SA - SAA -> Value.SAA - SAD -> Value.SAD - SAE -> Value.SAE - SAI -> Value.SAI - SG -> Value.SG - SH -> Value.SH - SM -> Value.SM - SU -> Value.SU - TAB -> Value.TAB - TAC -> Value.TAC - TT -> Value.TT - TV -> Value.TV - V1 -> Value.V1 - V2 -> Value.V2 - WH -> Value.WH - XAA -> Value.XAA - YY -> Value.YY - ZZZ -> Value.ZZZ + AE -> Value.AE + E -> Value.E + S -> Value.S + Z -> Value.Z + G -> Value.G + O -> Value.O + K -> Value.K + L -> Value.L + M -> Value.M + B -> Value.B else -> Value._UNKNOWN } @@ -6002,185 +4747,17 @@ private constructor( */ fun known(): Known = when (this) { - AA -> Known.AA - AAA -> Known.AAA - AAC -> Known.AAC - AAD -> Known.AAD - AAE -> Known.AAE - AAF -> Known.AAF - AAH -> Known.AAH - AAI -> Known.AAI - AAS -> Known.AAS - AAT -> Known.AAT - AAV -> Known.AAV - AAY -> Known.AAY - AAZ -> Known.AAZ - ABA -> Known.ABA - ABB -> Known.ABB - ABC -> Known.ABC - ABD -> Known.ABD - ABF -> Known.ABF - ABK -> Known.ABK - ABL -> Known.ABL - ABN -> Known.ABN - ABR -> Known.ABR - ABS -> Known.ABS - ABT -> Known.ABT - ABU -> Known.ABU - ACF -> Known.ACF - ACG -> Known.ACG - ACH -> Known.ACH - ACI -> Known.ACI - ACJ -> Known.ACJ - ACK -> Known.ACK - ACL -> Known.ACL - ACM -> Known.ACM - ACS -> Known.ACS - ADC -> Known.ADC - ADE -> Known.ADE - ADJ -> Known.ADJ - ADK -> Known.ADK - ADL -> Known.ADL - ADM -> Known.ADM - ADN -> Known.ADN - ADO -> Known.ADO - ADP -> Known.ADP - ADQ -> Known.ADQ - ADR -> Known.ADR - ADT -> Known.ADT - ADW -> Known.ADW - ADY -> Known.ADY - ADZ -> Known.ADZ - AEA -> Known.AEA - AEB -> Known.AEB - AEC -> Known.AEC - AED -> Known.AED - AEF -> Known.AEF - AEH -> Known.AEH - AEI -> Known.AEI - AEJ -> Known.AEJ - AEK -> Known.AEK - AEL -> Known.AEL - AEM -> Known.AEM - AEN -> Known.AEN - AEO -> Known.AEO - AEP -> Known.AEP - AES -> Known.AES - AET -> Known.AET - AEU -> Known.AEU - AEV -> Known.AEV - AEW -> Known.AEW - AEX -> Known.AEX - AEY -> Known.AEY - AEZ -> Known.AEZ - AJ -> Known.AJ - AU -> Known.AU - CA -> Known.CA - CAB -> Known.CAB - CAD -> Known.CAD - CAE -> Known.CAE - CAF -> Known.CAF - CAI -> Known.CAI - CAJ -> Known.CAJ - CAK -> Known.CAK - CAL -> Known.CAL - CAM -> Known.CAM - CAN -> Known.CAN - CAO -> Known.CAO - CAP -> Known.CAP - CAQ -> Known.CAQ - CAR -> Known.CAR - CAS -> Known.CAS - CAT -> Known.CAT - CAU -> Known.CAU - CAV -> Known.CAV - CAW -> Known.CAW - CAX -> Known.CAX - CAY -> Known.CAY - CAZ -> Known.CAZ - CD -> Known.CD - CG -> Known.CG - CS -> Known.CS - CT -> Known.CT - DAB -> Known.DAB - DAC -> Known.DAC - DAD -> Known.DAD - DAF -> Known.DAF - DAG -> Known.DAG - DAH -> Known.DAH - DAI -> Known.DAI - DAJ -> Known.DAJ - DAK -> Known.DAK - DAL -> Known.DAL - DAM -> Known.DAM - DAN -> Known.DAN - DAO -> Known.DAO - DAP -> Known.DAP - DAQ -> Known.DAQ - DL -> Known.DL - EG -> Known.EG - EP -> Known.EP - ER -> Known.ER - FAA -> Known.FAA - FAB -> Known.FAB - FAC -> Known.FAC - FC -> Known.FC - FH -> Known.FH - FI -> Known.FI - GAA -> Known.GAA - HAA -> Known.HAA - HD -> Known.HD - HH -> Known.HH - IAA -> Known.IAA - IAB -> Known.IAB - ID -> Known.ID - IF -> Known.IF - IR -> Known.IR - IS -> Known.IS - KO -> Known.KO - L1 -> Known.L1 - LA -> Known.LA - LAA -> Known.LAA - LAB -> Known.LAB - LF -> Known.LF - MAE -> Known.MAE - MI -> Known.MI - ML -> Known.ML - NAA -> Known.NAA - OA -> Known.OA - PA -> Known.PA - PAA -> Known.PAA - PC -> Known.PC - PL -> Known.PL - PRV -> Known.PRV - RAB -> Known.RAB - RAC -> Known.RAC - RAD -> Known.RAD - RAF -> Known.RAF - RE -> Known.RE - RF -> Known.RF - RH -> Known.RH - RV -> Known.RV - SA -> Known.SA - SAA -> Known.SAA - SAD -> Known.SAD - SAE -> Known.SAE - SAI -> Known.SAI - SG -> Known.SG - SH -> Known.SH - SM -> Known.SM - SU -> Known.SU - TAB -> Known.TAB - TAC -> Known.TAC - TT -> Known.TT - TV -> Known.TV - V1 -> Known.V1 - V2 -> Known.V2 - WH -> Known.WH - XAA -> Known.XAA - YY -> Known.YY - ZZZ -> Known.ZZZ - else -> throw EInvoiceInvalidDataException("Unknown ReasonCode: $value") + AE -> Known.AE + E -> Known.E + S -> Known.S + Z -> Known.Z + G -> Known.G + O -> Known.O + K -> Known.K + L -> Known.L + M -> Known.M + B -> Known.B + else -> throw EInvoiceInvalidDataException("Unknown TaxCode: $value") } /** @@ -6199,7 +4776,7 @@ private constructor( private var validated: Boolean = false - fun validate(): ReasonCode = apply { + fun validate(): TaxCode = apply { if (validated) { return@apply } @@ -6229,7 +4806,7 @@ private constructor( return true } - return other is ReasonCode && value == other.value + return other is TaxCode && value == other.value } override fun hashCode() = value.hashCode() @@ -6237,523 +4814,169 @@ private constructor( override fun toString() = value.toString() } - /** - * Duty or tax or fee category codes (Subset of UNCL5305) - * - * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL - */ - class TaxCode @JsonCreator private constructor(private val value: JsonField) : - Enum { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + return other is Charge && + amount == other.amount && + baseAmount == other.baseAmount && + multiplierFactor == other.multiplierFactor && + reason == other.reason && + reasonCode == other.reasonCode && + taxCode == other.taxCode && + taxRate == other.taxRate && + additionalProperties == other.additionalProperties + } - companion object { + private val hashCode: Int by lazy { + Objects.hash( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + additionalProperties, + ) + } - @JvmField val AE = of("AE") + override fun hashCode(): Int = hashCode - @JvmField val E = of("E") + override fun toString() = + "Charge{amount=$amount, baseAmount=$baseAmount, multiplierFactor=$multiplierFactor, reason=$reason, reasonCode=$reasonCode, taxCode=$taxCode, taxRate=$taxRate, additionalProperties=$additionalProperties}" + } - @JvmField val S = of("S") + /** + * The total amount of the invoice including tax (invoice_total = subtotal + total_tax + + * total_discount). Must be positive and rounded to maximum 2 decimals + */ + @JsonDeserialize(using = InvoiceTotal.Deserializer::class) + @JsonSerialize(using = InvoiceTotal.Serializer::class) + class InvoiceTotal + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { - @JvmField val Z = of("Z") + fun number(): Optional = Optional.ofNullable(number) - @JvmField val G = of("G") + fun string(): Optional = Optional.ofNullable(string) - @JvmField val O = of("O") + fun isNumber(): Boolean = number != null - @JvmField val K = of("K") + fun isString(): Boolean = string != null - @JvmField val L = of("L") + fun asNumber(): Double = number.getOrThrow("number") - @JvmField val M = of("M") + fun asString(): String = string.getOrThrow("string") - @JvmField val B = of("B") + fun _json(): Optional = Optional.ofNullable(_json) - @JvmStatic fun of(value: String) = TaxCode(JsonField.of(value)) + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) } - /** An enum containing [TaxCode]'s known values. */ - enum class Known { - AE, - E, - S, - Z, - G, - O, - K, - L, - M, - B, - } + private var validated: Boolean = false - /** - * An enum containing [TaxCode]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [TaxCode] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AE, - E, - S, - Z, - G, - O, - K, - L, - M, - B, - /** - * An enum member indicating that [TaxCode] was instantiated with an unknown value. - */ - _UNKNOWN, + fun validate(): InvoiceTotal = apply { + if (validated) { + return@apply } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AE -> Value.AE - E -> Value.E - S -> Value.S - Z -> Value.Z - G -> Value.G - O -> Value.O - K -> Value.K - L -> Value.L - M -> Value.M - B -> Value.B - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws EInvoiceInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AE -> Known.AE - E -> Known.E - S -> Known.S - Z -> Known.Z - G -> Known.G - O -> Known.O - K -> Known.K - L -> Known.L - M -> Known.M - B -> Known.B - else -> throw EInvoiceInvalidDataException("Unknown TaxCode: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws EInvoiceInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - EInvoiceInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false + accept( + object : Visitor { + override fun visitNumber(number: Double) {} - fun validate(): TaxCode = apply { - if (validated) { - return@apply + override fun visitString(string: String) {} } + ) + validated = true + } - known() - validated = true + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false - } + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + override fun visitString(string: String) = 1 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + override fun unknown(json: JsonValue?) = 0 } + ) - return other is TaxCode && value == other.value + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() + return other is InvoiceTotal && number == other.number && string == other.string } - /** The VAT rate, represented as percentage that applies to the charge */ - @JsonDeserialize(using = TaxRate.Deserializer::class) - @JsonSerialize(using = TaxRate.Serializer::class) - class TaxRate - private constructor( - private val number: Double? = null, - private val string: String? = null, - private val _json: JsonValue? = null, - ) { - - fun number(): Optional = Optional.ofNullable(number) - - fun string(): Optional = Optional.ofNullable(string) - - fun isNumber(): Boolean = number != null - - fun isString(): Boolean = string != null - - fun asNumber(): Double = number.getOrThrow("number") - - fun asString(): String = string.getOrThrow("string") + override fun hashCode(): Int = Objects.hash(number, string) - fun _json(): Optional = Optional.ofNullable(_json) + override fun toString(): String = + when { + number != null -> "InvoiceTotal{number=$number}" + string != null -> "InvoiceTotal{string=$string}" + _json != null -> "InvoiceTotal{_unknown=$_json}" + else -> throw IllegalStateException("Invalid InvoiceTotal") + } - fun accept(visitor: Visitor): T = - when { - number != null -> visitor.visitNumber(number) - string != null -> visitor.visitString(string) - else -> visitor.unknown(_json) - } + companion object { - private var validated: Boolean = false + @JvmStatic fun ofNumber(number: Double) = InvoiceTotal(number = number) - fun validate(): TaxRate = apply { - if (validated) { - return@apply - } + @JvmStatic fun ofString(string: String) = InvoiceTotal(string = string) + } - accept( - object : Visitor { - override fun visitNumber(number: Double) {} + /** + * An interface that defines how to map each variant of [InvoiceTotal] to a value of type + * [T]. + */ + interface Visitor { - override fun visitString(string: String) {} - } - ) - validated = true - } + fun visitNumber(number: Double): T - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false - } + fun visitString(string: String): T /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Maps an unknown variant of [InvoiceTotal] to a value of type [T]. * - * Used for best match union deserialization. + * An instance of [InvoiceTotal] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws EInvoiceInvalidDataException in the default implementation. */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitNumber(number: Double) = 1 + fun unknown(json: JsonValue?): T { + throw EInvoiceInvalidDataException("Unknown InvoiceTotal: $json") + } + } - override fun visitString(string: String) = 1 - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TaxRate && number == other.number && string == other.string - } - - override fun hashCode(): Int = Objects.hash(number, string) - - override fun toString(): String = - when { - number != null -> "TaxRate{number=$number}" - string != null -> "TaxRate{string=$string}" - _json != null -> "TaxRate{_unknown=$_json}" - else -> throw IllegalStateException("Invalid TaxRate") - } - - companion object { - - @JvmStatic fun ofNumber(number: Double) = TaxRate(number = number) - - @JvmStatic fun ofString(string: String) = TaxRate(string = string) - } - - /** - * An interface that defines how to map each variant of [TaxRate] to a value of type - * [T]. - */ - interface Visitor { - - fun visitNumber(number: Double): T - - fun visitString(string: String): T - - /** - * Maps an unknown variant of [TaxRate] to a value of type [T]. - * - * An instance of [TaxRate] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws EInvoiceInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw EInvoiceInvalidDataException("Unknown TaxRate: $json") - } - } - - internal class Deserializer : BaseDeserializer(TaxRate::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): TaxRate { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - TaxRate(number = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - TaxRate(string = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from object). - 0 -> TaxRate(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the - // first completely valid match, or simply the first match if none are - // completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(TaxRate::class) { - - override fun serialize( - value: TaxRate, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.number != null -> generator.writeObject(value.number) - value.string != null -> generator.writeObject(value.string) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid TaxRate") - } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Charge && - amount == other.amount && - baseAmount == other.baseAmount && - multiplierFactor == other.multiplierFactor && - reason == other.reason && - reasonCode == other.reasonCode && - taxCode == other.taxCode && - taxRate == other.taxRate && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - amount, - baseAmount, - multiplierFactor, - reason, - reasonCode, - taxCode, - taxRate, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Charge{amount=$amount, baseAmount=$baseAmount, multiplierFactor=$multiplierFactor, reason=$reason, reasonCode=$reasonCode, taxCode=$taxCode, taxRate=$taxRate, additionalProperties=$additionalProperties}" - } - - /** - * The total amount of the invoice including tax (invoice_total = subtotal + total_tax + - * total_discount). Must be positive and rounded to maximum 2 decimals - */ - @JsonDeserialize(using = InvoiceTotal.Deserializer::class) - @JsonSerialize(using = InvoiceTotal.Serializer::class) - class InvoiceTotal - private constructor( - private val number: Double? = null, - private val string: String? = null, - private val _json: JsonValue? = null, - ) { - - fun number(): Optional = Optional.ofNullable(number) - - fun string(): Optional = Optional.ofNullable(string) - - fun isNumber(): Boolean = number != null - - fun isString(): Boolean = string != null - - fun asNumber(): Double = number.getOrThrow("number") - - fun asString(): String = string.getOrThrow("string") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - number != null -> visitor.visitNumber(number) - string != null -> visitor.visitString(string) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): InvoiceTotal = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitNumber(number: Double) {} - - override fun visitString(string: String) {} - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitNumber(number: Double) = 1 - - override fun visitString(string: String) = 1 - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is InvoiceTotal && number == other.number && string == other.string - } - - override fun hashCode(): Int = Objects.hash(number, string) - - override fun toString(): String = - when { - number != null -> "InvoiceTotal{number=$number}" - string != null -> "InvoiceTotal{string=$string}" - _json != null -> "InvoiceTotal{_unknown=$_json}" - else -> throw IllegalStateException("Invalid InvoiceTotal") - } - - companion object { - - @JvmStatic fun ofNumber(number: Double) = InvoiceTotal(number = number) - - @JvmStatic fun ofString(string: String) = InvoiceTotal(string = string) - } - - /** - * An interface that defines how to map each variant of [InvoiceTotal] to a value of type - * [T]. - */ - interface Visitor { - - fun visitNumber(number: Double): T - - fun visitString(string: String): T - - /** - * Maps an unknown variant of [InvoiceTotal] to a value of type [T]. - * - * An instance of [InvoiceTotal] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the SDK - * is unaware of. - * - * @throws EInvoiceInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw EInvoiceInvalidDataException("Unknown InvoiceTotal: $json") - } - } - - internal class Deserializer : BaseDeserializer(InvoiceTotal::class) { + internal class Deserializer : BaseDeserializer(InvoiceTotal::class) { override fun ObjectCodec.deserialize(node: JsonNode): InvoiceTotal { val json = JsonValue.fromJsonNode(node) @@ -6808,11 +5031,10 @@ private constructor( private val charges: JsonField>, private val date: JsonField, private val description: JsonField, - private val priceBaseQuantity: JsonField, private val productCode: JsonField, private val quantity: JsonField, private val tax: JsonField, - private val taxRate: JsonField, + private val taxRate: JsonField, private val unit: JsonField, private val unitPrice: JsonField, private val additionalProperties: MutableMap, @@ -6831,9 +5053,6 @@ private constructor( @JsonProperty("description") @ExcludeMissing description: JsonField = JsonMissing.of(), - @JsonProperty("price_base_quantity") - @ExcludeMissing - priceBaseQuantity: JsonField = JsonMissing.of(), @JsonProperty("product_code") @ExcludeMissing productCode: JsonField = JsonMissing.of(), @@ -6841,9 +5060,7 @@ private constructor( @ExcludeMissing quantity: JsonField = JsonMissing.of(), @JsonProperty("tax") @ExcludeMissing tax: JsonField = JsonMissing.of(), - @JsonProperty("tax_rate") - @ExcludeMissing - taxRate: JsonField = JsonMissing.of(), + @JsonProperty("tax_rate") @ExcludeMissing taxRate: JsonField = JsonMissing.of(), @JsonProperty("unit") @ExcludeMissing unit: JsonField = JsonMissing.of(), @@ -6856,7 +5073,6 @@ private constructor( charges, date, description, - priceBaseQuantity, productCode, quantity, tax, @@ -6875,9 +5091,8 @@ private constructor( fun allowances(): Optional> = allowances.getOptional("allowances") /** - * The invoice line net amount (BT-131), exclusive of VAT, inclusive of line level - * allowances and charges. Calculated as: ((unit_price / price_base_quantity) * quantity) - - * allowances + charges. Must be rounded to maximum 2 decimals + * The total amount of the line item, exclusive of VAT, after subtracting line level + * allowances and adding line level charges. Must be rounded to maximum 2 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -6906,16 +5121,6 @@ private constructor( */ fun description(): Optional = description.getOptional("description") - /** - * The item price base quantity (BT-149). The number of item units to which the price - * applies. Defaults to 1. Must be rounded to maximum 4 decimals - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun priceBaseQuantity(): Optional = - priceBaseQuantity.getOptional("price_base_quantity") - /** * The product code of the line item. * @@ -6947,7 +5152,7 @@ private constructor( * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun taxRate(): Optional = taxRate.getOptional("tax_rate") + fun taxRate(): Optional = taxRate.getOptional("tax_rate") /** * Unit of Measure Codes from UNECERec20 used in Peppol BIS Billing 3.0. @@ -6958,8 +5163,7 @@ private constructor( fun unit(): Optional = unit.getOptional("unit") /** - * The item net price (BT-146). The price of an item, exclusive of VAT, after subtracting - * item price discount. Must be rounded to maximum 4 decimals + * The unit price of the line item. Must be rounded to maximum 2 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -7006,17 +5210,7 @@ private constructor( fun _description(): JsonField = description /** - * Returns the raw JSON value of [priceBaseQuantity]. - * - * Unlike [priceBaseQuantity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("price_base_quantity") - @ExcludeMissing - fun _priceBaseQuantity(): JsonField = priceBaseQuantity - - /** - * Returns the raw JSON value of [productCode]. + * Returns the raw JSON value of [productCode]. * * Unlike [productCode], this method doesn't throw if the JSON field has an unexpected type. */ @@ -7043,7 +5237,7 @@ private constructor( * * Unlike [taxRate], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate + @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate /** * Returns the raw JSON value of [unit]. @@ -7087,11 +5281,10 @@ private constructor( private var charges: JsonField>? = null private var date: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() - private var priceBaseQuantity: JsonField = JsonMissing.of() private var productCode: JsonField = JsonMissing.of() private var quantity: JsonField = JsonMissing.of() private var tax: JsonField = JsonMissing.of() - private var taxRate: JsonField = JsonMissing.of() + private var taxRate: JsonField = JsonMissing.of() private var unit: JsonField = JsonMissing.of() private var unitPrice: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -7103,7 +5296,6 @@ private constructor( charges = item.charges.map { it.toMutableList() } date = item.date description = item.description - priceBaseQuantity = item.priceBaseQuantity productCode = item.productCode quantity = item.quantity tax = item.tax @@ -7145,9 +5337,8 @@ private constructor( } /** - * The invoice line net amount (BT-131), exclusive of VAT, inclusive of line level - * allowances and charges. Calculated as: ((unit_price / price_base_quantity) * - * quantity) - allowances + charges. Must be rounded to maximum 2 decimals + * The total amount of the line item, exclusive of VAT, after subtracting line level + * allowances and adding line level charges. Must be rounded to maximum 2 decimals */ fun amount(amount: Amount?) = amount(JsonField.ofNullable(amount)) @@ -7200,2066 +5391,249 @@ private constructor( fun date(date: Void?) = date(JsonField.ofNullable(date)) - /** Alias for calling [Builder.date] with `date.orElse(null)`. */ - fun date(date: Optional) = date(date.getOrNull()) - - /** - * Sets [Builder.date] to an arbitrary JSON value. - * - * You should usually call [Builder.date] with a well-typed [Void] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun date(date: JsonField) = apply { this.date = date } - - /** The description of the line item. */ - fun description(description: String?) = description(JsonField.ofNullable(description)) - - /** Alias for calling [Builder.description] with `description.orElse(null)`. */ - fun description(description: Optional) = description(description.getOrNull()) - - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun description(description: JsonField) = apply { - this.description = description - } - - /** - * The item price base quantity (BT-149). The number of item units to which the price - * applies. Defaults to 1. Must be rounded to maximum 4 decimals - */ - fun priceBaseQuantity(priceBaseQuantity: PriceBaseQuantity?) = - priceBaseQuantity(JsonField.ofNullable(priceBaseQuantity)) - - /** - * Alias for calling [Builder.priceBaseQuantity] with `priceBaseQuantity.orElse(null)`. - */ - fun priceBaseQuantity(priceBaseQuantity: Optional) = - priceBaseQuantity(priceBaseQuantity.getOrNull()) - - /** - * Sets [Builder.priceBaseQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.priceBaseQuantity] with a well-typed - * [PriceBaseQuantity] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun priceBaseQuantity(priceBaseQuantity: JsonField) = apply { - this.priceBaseQuantity = priceBaseQuantity - } - - /** Alias for calling [priceBaseQuantity] with `PriceBaseQuantity.ofNumber(number)`. */ - fun priceBaseQuantity(number: Double) = - priceBaseQuantity(PriceBaseQuantity.ofNumber(number)) - - /** Alias for calling [priceBaseQuantity] with `PriceBaseQuantity.ofString(string)`. */ - fun priceBaseQuantity(string: String) = - priceBaseQuantity(PriceBaseQuantity.ofString(string)) - - /** The product code of the line item. */ - fun productCode(productCode: String?) = productCode(JsonField.ofNullable(productCode)) - - /** Alias for calling [Builder.productCode] with `productCode.orElse(null)`. */ - fun productCode(productCode: Optional) = productCode(productCode.getOrNull()) - - /** - * Sets [Builder.productCode] to an arbitrary JSON value. - * - * You should usually call [Builder.productCode] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun productCode(productCode: JsonField) = apply { - this.productCode = productCode - } - - /** - * The quantity of items (goods or services) that is the subject of the line item. Must - * be rounded to maximum 4 decimals - */ - fun quantity(quantity: Quantity?) = quantity(JsonField.ofNullable(quantity)) - - /** Alias for calling [Builder.quantity] with `quantity.orElse(null)`. */ - fun quantity(quantity: Optional) = quantity(quantity.getOrNull()) - - /** - * Sets [Builder.quantity] to an arbitrary JSON value. - * - * You should usually call [Builder.quantity] with a well-typed [Quantity] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - - /** Alias for calling [quantity] with `Quantity.ofNumber(number)`. */ - fun quantity(number: Double) = quantity(Quantity.ofNumber(number)) - - /** Alias for calling [quantity] with `Quantity.ofString(string)`. */ - fun quantity(string: String) = quantity(Quantity.ofString(string)) - - /** The total VAT amount for the line item. Must be rounded to maximum 2 decimals */ - fun tax(tax: Tax?) = tax(JsonField.ofNullable(tax)) - - /** Alias for calling [Builder.tax] with `tax.orElse(null)`. */ - fun tax(tax: Optional) = tax(tax.getOrNull()) - - /** - * Sets [Builder.tax] to an arbitrary JSON value. - * - * You should usually call [Builder.tax] with a well-typed [Tax] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun tax(tax: JsonField) = apply { this.tax = tax } - - /** Alias for calling [tax] with `Tax.ofNumber(number)`. */ - fun tax(number: Double) = tax(Tax.ofNumber(number)) - - /** Alias for calling [tax] with `Tax.ofString(string)`. */ - fun tax(string: String) = tax(Tax.ofString(string)) - - /** The VAT rate of the line item expressed as percentage with 2 decimals */ - fun taxRate(taxRate: TaxRate?) = taxRate(JsonField.ofNullable(taxRate)) - - /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ - fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) - - /** - * Sets [Builder.taxRate] to an arbitrary JSON value. - * - * You should usually call [Builder.taxRate] with a well-typed [TaxRate] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } - - /** Alias for calling [taxRate] with `TaxRate.ofNumber(number)`. */ - fun taxRate(number: Double) = taxRate(TaxRate.ofNumber(number)) - - /** Alias for calling [taxRate] with `TaxRate.ofString(string)`. */ - fun taxRate(string: String) = taxRate(TaxRate.ofString(string)) - - /** Unit of Measure Codes from UNECERec20 used in Peppol BIS Billing 3.0. */ - fun unit(unit: UnitOfMeasureCode?) = unit(JsonField.ofNullable(unit)) - - /** Alias for calling [Builder.unit] with `unit.orElse(null)`. */ - fun unit(unit: Optional) = unit(unit.getOrNull()) - - /** - * Sets [Builder.unit] to an arbitrary JSON value. - * - * You should usually call [Builder.unit] with a well-typed [UnitOfMeasureCode] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun unit(unit: JsonField) = apply { this.unit = unit } - - /** - * The item net price (BT-146). The price of an item, exclusive of VAT, after - * subtracting item price discount. Must be rounded to maximum 4 decimals - */ - fun unitPrice(unitPrice: UnitPrice?) = unitPrice(JsonField.ofNullable(unitPrice)) - - /** Alias for calling [Builder.unitPrice] with `unitPrice.orElse(null)`. */ - fun unitPrice(unitPrice: Optional) = unitPrice(unitPrice.getOrNull()) - - /** - * Sets [Builder.unitPrice] to an arbitrary JSON value. - * - * You should usually call [Builder.unitPrice] with a well-typed [UnitPrice] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } - - /** Alias for calling [unitPrice] with `UnitPrice.ofNumber(number)`. */ - fun unitPrice(number: Double) = unitPrice(UnitPrice.ofNumber(number)) - - /** Alias for calling [unitPrice] with `UnitPrice.ofString(string)`. */ - fun unitPrice(string: String) = unitPrice(UnitPrice.ofString(string)) - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Item]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Item = - Item( - (allowances ?: JsonMissing.of()).map { it.toImmutable() }, - amount, - (charges ?: JsonMissing.of()).map { it.toImmutable() }, - date, - description, - priceBaseQuantity, - productCode, - quantity, - tax, - taxRate, - unit, - unitPrice, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Item = apply { - if (validated) { - return@apply - } - - allowances().ifPresent { it.forEach { it.validate() } } - amount().ifPresent { it.validate() } - charges().ifPresent { it.forEach { it.validate() } } - date() - description() - priceBaseQuantity().ifPresent { it.validate() } - productCode() - quantity().ifPresent { it.validate() } - tax().ifPresent { it.validate() } - taxRate().ifPresent { it.validate() } - unit().ifPresent { it.validate() } - unitPrice().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (allowances.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (amount.asKnown().getOrNull()?.validity() ?: 0) + - (charges.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (date.asKnown().isPresent) 1 else 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (priceBaseQuantity.asKnown().getOrNull()?.validity() ?: 0) + - (if (productCode.asKnown().isPresent) 1 else 0) + - (quantity.asKnown().getOrNull()?.validity() ?: 0) + - (tax.asKnown().getOrNull()?.validity() ?: 0) + - (taxRate.asKnown().getOrNull()?.validity() ?: 0) + - (unit.asKnown().getOrNull()?.validity() ?: 0) + - (unitPrice.asKnown().getOrNull()?.validity() ?: 0) - - /** An allowance is a discount for example for early payment, volume discount, etc. */ - class Allowance - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val amount: JsonField, - private val baseAmount: JsonField, - private val multiplierFactor: JsonField, - private val reason: JsonField, - private val reasonCode: JsonField, - private val taxCode: JsonField, - private val taxRate: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - amount: JsonField = JsonMissing.of(), - @JsonProperty("base_amount") - @ExcludeMissing - baseAmount: JsonField = JsonMissing.of(), - @JsonProperty("multiplier_factor") - @ExcludeMissing - multiplierFactor: JsonField = JsonMissing.of(), - @JsonProperty("reason") - @ExcludeMissing - reason: JsonField = JsonMissing.of(), - @JsonProperty("reason_code") - @ExcludeMissing - reasonCode: JsonField = JsonMissing.of(), - @JsonProperty("tax_code") - @ExcludeMissing - taxCode: JsonField = JsonMissing.of(), - @JsonProperty("tax_rate") - @ExcludeMissing - taxRate: JsonField = JsonMissing.of(), - ) : this( - amount, - baseAmount, - multiplierFactor, - reason, - reasonCode, - taxCode, - taxRate, - mutableMapOf(), - ) - - /** - * The allowance amount, without VAT. Must be rounded to maximum 2 decimals - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * The base amount that may be used, in conjunction with the allowance percentage, to - * calculate the allowance amount. Must be rounded to maximum 2 decimals - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun baseAmount(): Optional = baseAmount.getOptional("base_amount") - - /** - * The percentage that may be used, in conjunction with the allowance base amount, to - * calculate the allowance amount. To state 20%, use value 20. Must be rounded to - * maximum 2 decimals - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun multiplierFactor(): Optional = - multiplierFactor.getOptional("multiplier_factor") - - /** - * The reason for the allowance - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun reason(): Optional = reason.getOptional("reason") - - /** - * Allowance reason codes for invoice discounts and charges - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun reasonCode(): Optional = reasonCode.getOptional("reason_code") - - /** - * The VAT category code that applies to the allowance - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun taxCode(): Optional = taxCode.getOptional("tax_code") - - /** - * The VAT rate, represented as percentage that applies to the allowance. Must be - * rounded to maximum 2 decimals - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun taxRate(): Optional = taxRate.getOptional("tax_rate") - - /** - * Returns the raw JSON value of [amount]. - * - * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** - * Returns the raw JSON value of [baseAmount]. - * - * Unlike [baseAmount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("base_amount") - @ExcludeMissing - fun _baseAmount(): JsonField = baseAmount - - /** - * Returns the raw JSON value of [multiplierFactor]. - * - * Unlike [multiplierFactor], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("multiplier_factor") - @ExcludeMissing - fun _multiplierFactor(): JsonField = multiplierFactor - - /** - * Returns the raw JSON value of [reason]. - * - * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - /** - * Returns the raw JSON value of [reasonCode]. - * - * Unlike [reasonCode], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("reason_code") - @ExcludeMissing - fun _reasonCode(): JsonField = reasonCode - - /** - * Returns the raw JSON value of [taxCode]. - * - * Unlike [taxCode], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tax_code") @ExcludeMissing fun _taxCode(): JsonField = taxCode - - /** - * Returns the raw JSON value of [taxRate]. - * - * Unlike [taxRate], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Allowance]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Allowance]. */ - class Builder internal constructor() { - - private var amount: JsonField = JsonMissing.of() - private var baseAmount: JsonField = JsonMissing.of() - private var multiplierFactor: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() - private var reasonCode: JsonField = JsonMissing.of() - private var taxCode: JsonField = JsonMissing.of() - private var taxRate: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(allowance: Allowance) = apply { - amount = allowance.amount - baseAmount = allowance.baseAmount - multiplierFactor = allowance.multiplierFactor - reason = allowance.reason - reasonCode = allowance.reasonCode - taxCode = allowance.taxCode - taxRate = allowance.taxRate - additionalProperties = allowance.additionalProperties.toMutableMap() - } - - /** The allowance amount, without VAT. Must be rounded to maximum 2 decimals */ - fun amount(amount: Amount?) = amount(JsonField.ofNullable(amount)) - - /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ - fun amount(amount: Optional) = amount(amount.getOrNull()) - - /** - * Sets [Builder.amount] to an arbitrary JSON value. - * - * You should usually call [Builder.amount] with a well-typed [Amount] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** Alias for calling [amount] with `Amount.ofNumber(number)`. */ - fun amount(number: Double) = amount(Amount.ofNumber(number)) - - /** Alias for calling [amount] with `Amount.ofString(string)`. */ - fun amount(string: String) = amount(Amount.ofString(string)) - - /** - * The base amount that may be used, in conjunction with the allowance percentage, - * to calculate the allowance amount. Must be rounded to maximum 2 decimals - */ - fun baseAmount(baseAmount: BaseAmount?) = - baseAmount(JsonField.ofNullable(baseAmount)) - - /** Alias for calling [Builder.baseAmount] with `baseAmount.orElse(null)`. */ - fun baseAmount(baseAmount: Optional) = - baseAmount(baseAmount.getOrNull()) - - /** - * Sets [Builder.baseAmount] to an arbitrary JSON value. - * - * You should usually call [Builder.baseAmount] with a well-typed [BaseAmount] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun baseAmount(baseAmount: JsonField) = apply { - this.baseAmount = baseAmount - } - - /** Alias for calling [baseAmount] with `BaseAmount.ofNumber(number)`. */ - fun baseAmount(number: Double) = baseAmount(BaseAmount.ofNumber(number)) - - /** Alias for calling [baseAmount] with `BaseAmount.ofString(string)`. */ - fun baseAmount(string: String) = baseAmount(BaseAmount.ofString(string)) - - /** - * The percentage that may be used, in conjunction with the allowance base amount, - * to calculate the allowance amount. To state 20%, use value 20. Must be rounded to - * maximum 2 decimals - */ - fun multiplierFactor(multiplierFactor: MultiplierFactor?) = - multiplierFactor(JsonField.ofNullable(multiplierFactor)) - - /** - * Alias for calling [Builder.multiplierFactor] with - * `multiplierFactor.orElse(null)`. - */ - fun multiplierFactor(multiplierFactor: Optional) = - multiplierFactor(multiplierFactor.getOrNull()) - - /** - * Sets [Builder.multiplierFactor] to an arbitrary JSON value. - * - * You should usually call [Builder.multiplierFactor] with a well-typed - * [MultiplierFactor] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun multiplierFactor(multiplierFactor: JsonField) = apply { - this.multiplierFactor = multiplierFactor - } - - /** - * Alias for calling [multiplierFactor] with `MultiplierFactor.ofNumber(number)`. - */ - fun multiplierFactor(number: Double) = - multiplierFactor(MultiplierFactor.ofNumber(number)) - - /** - * Alias for calling [multiplierFactor] with `MultiplierFactor.ofString(string)`. - */ - fun multiplierFactor(string: String) = - multiplierFactor(MultiplierFactor.ofString(string)) - - /** The reason for the allowance */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ - fun reason(reason: Optional) = reason(reason.getOrNull()) - - /** - * Sets [Builder.reason] to an arbitrary JSON value. - * - * You should usually call [Builder.reason] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - /** Allowance reason codes for invoice discounts and charges */ - fun reasonCode(reasonCode: ReasonCode?) = - reasonCode(JsonField.ofNullable(reasonCode)) - - /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ - fun reasonCode(reasonCode: Optional) = - reasonCode(reasonCode.getOrNull()) - - /** - * Sets [Builder.reasonCode] to an arbitrary JSON value. - * - * You should usually call [Builder.reasonCode] with a well-typed [ReasonCode] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun reasonCode(reasonCode: JsonField) = apply { - this.reasonCode = reasonCode - } - - /** The VAT category code that applies to the allowance */ - fun taxCode(taxCode: TaxCode) = taxCode(JsonField.of(taxCode)) - - /** - * Sets [Builder.taxCode] to an arbitrary JSON value. - * - * You should usually call [Builder.taxCode] with a well-typed [TaxCode] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } - - /** - * The VAT rate, represented as percentage that applies to the allowance. Must be - * rounded to maximum 2 decimals - */ - fun taxRate(taxRate: TaxRate?) = taxRate(JsonField.ofNullable(taxRate)) - - /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ - fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) - - /** - * Sets [Builder.taxRate] to an arbitrary JSON value. - * - * You should usually call [Builder.taxRate] with a well-typed [TaxRate] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } - - /** Alias for calling [taxRate] with `TaxRate.ofNumber(number)`. */ - fun taxRate(number: Double) = taxRate(TaxRate.ofNumber(number)) - - /** Alias for calling [taxRate] with `TaxRate.ofString(string)`. */ - fun taxRate(string: String) = taxRate(TaxRate.ofString(string)) - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Allowance]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Allowance = - Allowance( - amount, - baseAmount, - multiplierFactor, - reason, - reasonCode, - taxCode, - taxRate, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Allowance = apply { - if (validated) { - return@apply - } - - amount().ifPresent { it.validate() } - baseAmount().ifPresent { it.validate() } - multiplierFactor().ifPresent { it.validate() } - reason() - reasonCode().ifPresent { it.validate() } - taxCode().ifPresent { it.validate() } - taxRate().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (amount.asKnown().getOrNull()?.validity() ?: 0) + - (baseAmount.asKnown().getOrNull()?.validity() ?: 0) + - (multiplierFactor.asKnown().getOrNull()?.validity() ?: 0) + - (if (reason.asKnown().isPresent) 1 else 0) + - (reasonCode.asKnown().getOrNull()?.validity() ?: 0) + - (taxCode.asKnown().getOrNull()?.validity() ?: 0) + - (taxRate.asKnown().getOrNull()?.validity() ?: 0) - - /** The allowance amount, without VAT. Must be rounded to maximum 2 decimals */ - @JsonDeserialize(using = Amount.Deserializer::class) - @JsonSerialize(using = Amount.Serializer::class) - class Amount - private constructor( - private val number: Double? = null, - private val string: String? = null, - private val _json: JsonValue? = null, - ) { - - fun number(): Optional = Optional.ofNullable(number) - - fun string(): Optional = Optional.ofNullable(string) - - fun isNumber(): Boolean = number != null - - fun isString(): Boolean = string != null - - fun asNumber(): Double = number.getOrThrow("number") - - fun asString(): String = string.getOrThrow("string") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - number != null -> visitor.visitNumber(number) - string != null -> visitor.visitString(string) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): Amount = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitNumber(number: Double) {} - - override fun visitString(string: String) {} - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitNumber(number: Double) = 1 - - override fun visitString(string: String) = 1 - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Amount && number == other.number && string == other.string - } - - override fun hashCode(): Int = Objects.hash(number, string) - - override fun toString(): String = - when { - number != null -> "Amount{number=$number}" - string != null -> "Amount{string=$string}" - _json != null -> "Amount{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Amount") - } - - companion object { - - @JvmStatic fun ofNumber(number: Double) = Amount(number = number) - - @JvmStatic fun ofString(string: String) = Amount(string = string) - } - - /** - * An interface that defines how to map each variant of [Amount] to a value of type - * [T]. - */ - interface Visitor { - - fun visitNumber(number: Double): T - - fun visitString(string: String): T - - /** - * Maps an unknown variant of [Amount] to a value of type [T]. - * - * An instance of [Amount] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on - * an older version than the API, then the API may respond with new variants - * that the SDK is unaware of. - * - * @throws EInvoiceInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw EInvoiceInvalidDataException("Unknown Amount: $json") - } - } - - internal class Deserializer : BaseDeserializer(Amount::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Amount { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Amount(number = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Amount(string = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely - // incompatible with all the possible variants (e.g. deserializing from - // object). - 0 -> Amount(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use - // the first completely valid match, or simply the first match if none - // are completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(Amount::class) { - - override fun serialize( - value: Amount, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.number != null -> generator.writeObject(value.number) - value.string != null -> generator.writeObject(value.string) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Amount") - } - } - } - } - - /** - * The base amount that may be used, in conjunction with the allowance percentage, to - * calculate the allowance amount. Must be rounded to maximum 2 decimals - */ - @JsonDeserialize(using = BaseAmount.Deserializer::class) - @JsonSerialize(using = BaseAmount.Serializer::class) - class BaseAmount - private constructor( - private val number: Double? = null, - private val string: String? = null, - private val _json: JsonValue? = null, - ) { - - fun number(): Optional = Optional.ofNullable(number) - - fun string(): Optional = Optional.ofNullable(string) - - fun isNumber(): Boolean = number != null - - fun isString(): Boolean = string != null - - fun asNumber(): Double = number.getOrThrow("number") - - fun asString(): String = string.getOrThrow("string") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - number != null -> visitor.visitNumber(number) - string != null -> visitor.visitString(string) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): BaseAmount = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitNumber(number: Double) {} - - override fun visitString(string: String) {} - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitNumber(number: Double) = 1 - - override fun visitString(string: String) = 1 - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BaseAmount && number == other.number && string == other.string - } - - override fun hashCode(): Int = Objects.hash(number, string) - - override fun toString(): String = - when { - number != null -> "BaseAmount{number=$number}" - string != null -> "BaseAmount{string=$string}" - _json != null -> "BaseAmount{_unknown=$_json}" - else -> throw IllegalStateException("Invalid BaseAmount") - } - - companion object { - - @JvmStatic fun ofNumber(number: Double) = BaseAmount(number = number) - - @JvmStatic fun ofString(string: String) = BaseAmount(string = string) - } - - /** - * An interface that defines how to map each variant of [BaseAmount] to a value of - * type [T]. - */ - interface Visitor { - - fun visitNumber(number: Double): T - - fun visitString(string: String): T - - /** - * Maps an unknown variant of [BaseAmount] to a value of type [T]. - * - * An instance of [BaseAmount] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if - * the SDK is on an older version than the API, then the API may respond with - * new variants that the SDK is unaware of. - * - * @throws EInvoiceInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw EInvoiceInvalidDataException("Unknown BaseAmount: $json") - } - } - - internal class Deserializer : BaseDeserializer(BaseAmount::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): BaseAmount { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - BaseAmount(number = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - BaseAmount(string = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely - // incompatible with all the possible variants (e.g. deserializing from - // object). - 0 -> BaseAmount(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use - // the first completely valid match, or simply the first match if none - // are completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(BaseAmount::class) { - - override fun serialize( - value: BaseAmount, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.number != null -> generator.writeObject(value.number) - value.string != null -> generator.writeObject(value.string) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid BaseAmount") - } - } - } - } - - /** - * The percentage that may be used, in conjunction with the allowance base amount, to - * calculate the allowance amount. To state 20%, use value 20. Must be rounded to - * maximum 2 decimals - */ - @JsonDeserialize(using = MultiplierFactor.Deserializer::class) - @JsonSerialize(using = MultiplierFactor.Serializer::class) - class MultiplierFactor - private constructor( - private val number: Double? = null, - private val string: String? = null, - private val _json: JsonValue? = null, - ) { - - fun number(): Optional = Optional.ofNullable(number) - - fun string(): Optional = Optional.ofNullable(string) - - fun isNumber(): Boolean = number != null - - fun isString(): Boolean = string != null - - fun asNumber(): Double = number.getOrThrow("number") - - fun asString(): String = string.getOrThrow("string") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - number != null -> visitor.visitNumber(number) - string != null -> visitor.visitString(string) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): MultiplierFactor = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitNumber(number: Double) {} - - override fun visitString(string: String) {} - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitNumber(number: Double) = 1 - - override fun visitString(string: String) = 1 - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is MultiplierFactor && - number == other.number && - string == other.string - } - - override fun hashCode(): Int = Objects.hash(number, string) - - override fun toString(): String = - when { - number != null -> "MultiplierFactor{number=$number}" - string != null -> "MultiplierFactor{string=$string}" - _json != null -> "MultiplierFactor{_unknown=$_json}" - else -> throw IllegalStateException("Invalid MultiplierFactor") - } - - companion object { - - @JvmStatic fun ofNumber(number: Double) = MultiplierFactor(number = number) - - @JvmStatic fun ofString(string: String) = MultiplierFactor(string = string) - } - - /** - * An interface that defines how to map each variant of [MultiplierFactor] to a - * value of type [T]. - */ - interface Visitor { - - fun visitNumber(number: Double): T - - fun visitString(string: String): T - - /** - * Maps an unknown variant of [MultiplierFactor] to a value of type [T]. - * - * An instance of [MultiplierFactor] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if - * the SDK is on an older version than the API, then the API may respond with - * new variants that the SDK is unaware of. - * - * @throws EInvoiceInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw EInvoiceInvalidDataException("Unknown MultiplierFactor: $json") - } - } - - internal class Deserializer : - BaseDeserializer(MultiplierFactor::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): MultiplierFactor { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - MultiplierFactor(number = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - MultiplierFactor(string = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely - // incompatible with all the possible variants (e.g. deserializing from - // object). - 0 -> MultiplierFactor(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use - // the first completely valid match, or simply the first match if none - // are completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : - BaseSerializer(MultiplierFactor::class) { - - override fun serialize( - value: MultiplierFactor, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.number != null -> generator.writeObject(value.number) - value.string != null -> generator.writeObject(value.string) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid MultiplierFactor") - } - } - } - } - - /** Allowance reason codes for invoice discounts and charges */ - class ReasonCode - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val _41 = of("41") - - @JvmField val _42 = of("42") - - @JvmField val _60 = of("60") - - @JvmField val _62 = of("62") - - @JvmField val _63 = of("63") - - @JvmField val _64 = of("64") - - @JvmField val _65 = of("65") - - @JvmField val _66 = of("66") - - @JvmField val _67 = of("67") - - @JvmField val _68 = of("68") - - @JvmField val _70 = of("70") - - @JvmField val _71 = of("71") - - @JvmField val _88 = of("88") - - @JvmField val _95 = of("95") - - @JvmField val _100 = of("100") - - @JvmField val _102 = of("102") - - @JvmField val _103 = of("103") - - @JvmField val _104 = of("104") - - @JvmField val _105 = of("105") - - @JvmStatic fun of(value: String) = ReasonCode(JsonField.of(value)) - } - - /** An enum containing [ReasonCode]'s known values. */ - enum class Known { - _41, - _42, - _60, - _62, - _63, - _64, - _65, - _66, - _67, - _68, - _70, - _71, - _88, - _95, - _100, - _102, - _103, - _104, - _105, - } - - /** - * An enum containing [ReasonCode]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ReasonCode] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - _41, - _42, - _60, - _62, - _63, - _64, - _65, - _66, - _67, - _68, - _70, - _71, - _88, - _95, - _100, - _102, - _103, - _104, - _105, - /** - * An enum member indicating that [ReasonCode] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - _41 -> Value._41 - _42 -> Value._42 - _60 -> Value._60 - _62 -> Value._62 - _63 -> Value._63 - _64 -> Value._64 - _65 -> Value._65 - _66 -> Value._66 - _67 -> Value._67 - _68 -> Value._68 - _70 -> Value._70 - _71 -> Value._71 - _88 -> Value._88 - _95 -> Value._95 - _100 -> Value._100 - _102 -> Value._102 - _103 -> Value._103 - _104 -> Value._104 - _105 -> Value._105 - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws EInvoiceInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - _41 -> Known._41 - _42 -> Known._42 - _60 -> Known._60 - _62 -> Known._62 - _63 -> Known._63 - _64 -> Known._64 - _65 -> Known._65 - _66 -> Known._66 - _67 -> Known._67 - _68 -> Known._68 - _70 -> Known._70 - _71 -> Known._71 - _88 -> Known._88 - _95 -> Known._95 - _100 -> Known._100 - _102 -> Known._102 - _103 -> Known._103 - _104 -> Known._104 - _105 -> Known._105 - else -> throw EInvoiceInvalidDataException("Unknown ReasonCode: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws EInvoiceInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - EInvoiceInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): ReasonCode = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ReasonCode && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** The VAT category code that applies to the allowance */ - class TaxCode @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val AE = of("AE") - - @JvmField val E = of("E") - - @JvmField val S = of("S") - - @JvmField val Z = of("Z") - - @JvmField val G = of("G") - - @JvmField val O = of("O") - - @JvmField val K = of("K") - - @JvmField val L = of("L") - - @JvmField val M = of("M") - - @JvmField val B = of("B") - - @JvmStatic fun of(value: String) = TaxCode(JsonField.of(value)) - } - - /** An enum containing [TaxCode]'s known values. */ - enum class Known { - AE, - E, - S, - Z, - G, - O, - K, - L, - M, - B, - } - - /** - * An enum containing [TaxCode]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [TaxCode] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AE, - E, - S, - Z, - G, - O, - K, - L, - M, - B, - /** - * An enum member indicating that [TaxCode] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AE -> Value.AE - E -> Value.E - S -> Value.S - Z -> Value.Z - G -> Value.G - O -> Value.O - K -> Value.K - L -> Value.L - M -> Value.M - B -> Value.B - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws EInvoiceInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AE -> Known.AE - E -> Known.E - S -> Known.S - Z -> Known.Z - G -> Known.G - O -> Known.O - K -> Known.K - L -> Known.L - M -> Known.M - B -> Known.B - else -> throw EInvoiceInvalidDataException("Unknown TaxCode: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws EInvoiceInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - EInvoiceInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): TaxCode = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TaxCode && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * The VAT rate, represented as percentage that applies to the allowance. Must be - * rounded to maximum 2 decimals - */ - @JsonDeserialize(using = TaxRate.Deserializer::class) - @JsonSerialize(using = TaxRate.Serializer::class) - class TaxRate - private constructor( - private val number: Double? = null, - private val string: String? = null, - private val _json: JsonValue? = null, - ) { - - fun number(): Optional = Optional.ofNullable(number) - - fun string(): Optional = Optional.ofNullable(string) - - fun isNumber(): Boolean = number != null - - fun isString(): Boolean = string != null - - fun asNumber(): Double = number.getOrThrow("number") - - fun asString(): String = string.getOrThrow("string") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - number != null -> visitor.visitNumber(number) - string != null -> visitor.visitString(string) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): TaxRate = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitNumber(number: Double) {} - - override fun visitString(string: String) {} - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitNumber(number: Double) = 1 - - override fun visitString(string: String) = 1 - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TaxRate && number == other.number && string == other.string - } - - override fun hashCode(): Int = Objects.hash(number, string) - - override fun toString(): String = - when { - number != null -> "TaxRate{number=$number}" - string != null -> "TaxRate{string=$string}" - _json != null -> "TaxRate{_unknown=$_json}" - else -> throw IllegalStateException("Invalid TaxRate") - } - - companion object { - - @JvmStatic fun ofNumber(number: Double) = TaxRate(number = number) - - @JvmStatic fun ofString(string: String) = TaxRate(string = string) - } - - /** - * An interface that defines how to map each variant of [TaxRate] to a value of type - * [T]. - */ - interface Visitor { - - fun visitNumber(number: Double): T - - fun visitString(string: String): T - - /** - * Maps an unknown variant of [TaxRate] to a value of type [T]. - * - * An instance of [TaxRate] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if - * the SDK is on an older version than the API, then the API may respond with - * new variants that the SDK is unaware of. - * - * @throws EInvoiceInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw EInvoiceInvalidDataException("Unknown TaxRate: $json") - } - } - - internal class Deserializer : BaseDeserializer(TaxRate::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): TaxRate { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - TaxRate(number = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - TaxRate(string = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely - // incompatible with all the possible variants (e.g. deserializing from - // object). - 0 -> TaxRate(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use - // the first completely valid match, or simply the first match if none - // are completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(TaxRate::class) { - - override fun serialize( - value: TaxRate, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.number != null -> generator.writeObject(value.number) - value.string != null -> generator.writeObject(value.string) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid TaxRate") - } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Allowance && - amount == other.amount && - baseAmount == other.baseAmount && - multiplierFactor == other.multiplierFactor && - reason == other.reason && - reasonCode == other.reasonCode && - taxCode == other.taxCode && - taxRate == other.taxRate && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - amount, - baseAmount, - multiplierFactor, - reason, - reasonCode, - taxCode, - taxRate, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Allowance{amount=$amount, baseAmount=$baseAmount, multiplierFactor=$multiplierFactor, reason=$reason, reasonCode=$reasonCode, taxCode=$taxCode, taxRate=$taxRate, additionalProperties=$additionalProperties}" - } + /** Alias for calling [Builder.date] with `date.orElse(null)`. */ + fun date(date: Optional) = date(date.getOrNull()) - /** - * The invoice line net amount (BT-131), exclusive of VAT, inclusive of line level - * allowances and charges. Calculated as: ((unit_price / price_base_quantity) * quantity) - - * allowances + charges. Must be rounded to maximum 2 decimals - */ - @JsonDeserialize(using = Amount.Deserializer::class) - @JsonSerialize(using = Amount.Serializer::class) - class Amount - private constructor( - private val number: Double? = null, - private val string: String? = null, - private val _json: JsonValue? = null, - ) { + /** + * Sets [Builder.date] to an arbitrary JSON value. + * + * You should usually call [Builder.date] with a well-typed [Void] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun date(date: JsonField) = apply { this.date = date } - fun number(): Optional = Optional.ofNullable(number) + /** The description of the line item. */ + fun description(description: String?) = description(JsonField.ofNullable(description)) - fun string(): Optional = Optional.ofNullable(string) + /** Alias for calling [Builder.description] with `description.orElse(null)`. */ + fun description(description: Optional) = description(description.getOrNull()) - fun isNumber(): Boolean = number != null + /** + * Sets [Builder.description] to an arbitrary JSON value. + * + * You should usually call [Builder.description] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun description(description: JsonField) = apply { + this.description = description + } - fun isString(): Boolean = string != null + /** The product code of the line item. */ + fun productCode(productCode: String?) = productCode(JsonField.ofNullable(productCode)) - fun asNumber(): Double = number.getOrThrow("number") + /** Alias for calling [Builder.productCode] with `productCode.orElse(null)`. */ + fun productCode(productCode: Optional) = productCode(productCode.getOrNull()) - fun asString(): String = string.getOrThrow("string") + /** + * Sets [Builder.productCode] to an arbitrary JSON value. + * + * You should usually call [Builder.productCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun productCode(productCode: JsonField) = apply { + this.productCode = productCode + } - fun _json(): Optional = Optional.ofNullable(_json) + /** + * The quantity of items (goods or services) that is the subject of the line item. Must + * be rounded to maximum 4 decimals + */ + fun quantity(quantity: Quantity?) = quantity(JsonField.ofNullable(quantity)) - fun accept(visitor: Visitor): T = - when { - number != null -> visitor.visitNumber(number) - string != null -> visitor.visitString(string) - else -> visitor.unknown(_json) - } + /** Alias for calling [Builder.quantity] with `quantity.orElse(null)`. */ + fun quantity(quantity: Optional) = quantity(quantity.getOrNull()) - private var validated: Boolean = false + /** + * Sets [Builder.quantity] to an arbitrary JSON value. + * + * You should usually call [Builder.quantity] with a well-typed [Quantity] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - fun validate(): Amount = apply { - if (validated) { - return@apply - } + /** Alias for calling [quantity] with `Quantity.ofNumber(number)`. */ + fun quantity(number: Double) = quantity(Quantity.ofNumber(number)) - accept( - object : Visitor { - override fun visitNumber(number: Double) {} + /** Alias for calling [quantity] with `Quantity.ofString(string)`. */ + fun quantity(string: String) = quantity(Quantity.ofString(string)) - override fun visitString(string: String) {} - } - ) - validated = true - } + /** The total VAT amount for the line item. Must be rounded to maximum 2 decimals */ + fun tax(tax: Tax?) = tax(JsonField.ofNullable(tax)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false - } + /** Alias for calling [Builder.tax] with `tax.orElse(null)`. */ + fun tax(tax: Optional) = tax(tax.getOrNull()) /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Sets [Builder.tax] to an arbitrary JSON value. * - * Used for best match union deserialization. + * You should usually call [Builder.tax] with a well-typed [Tax] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitNumber(number: Double) = 1 + fun tax(tax: JsonField) = apply { this.tax = tax } - override fun visitString(string: String) = 1 + /** Alias for calling [tax] with `Tax.ofNumber(number)`. */ + fun tax(number: Double) = tax(Tax.ofNumber(number)) - override fun unknown(json: JsonValue?) = 0 - } - ) + /** Alias for calling [tax] with `Tax.ofString(string)`. */ + fun tax(string: String) = tax(Tax.ofString(string)) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** The VAT rate of the line item expressed as percentage with 2 decimals */ + fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) - return other is Amount && number == other.number && string == other.string - } + /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ + fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) - override fun hashCode(): Int = Objects.hash(number, string) + /** + * Sets [Builder.taxRate] to an arbitrary JSON value. + * + * You should usually call [Builder.taxRate] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } - override fun toString(): String = - when { - number != null -> "Amount{number=$number}" - string != null -> "Amount{string=$string}" - _json != null -> "Amount{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Amount") - } + /** Unit of Measure Codes from UNECERec20 used in Peppol BIS Billing 3.0. */ + fun unit(unit: UnitOfMeasureCode?) = unit(JsonField.ofNullable(unit)) - companion object { + /** Alias for calling [Builder.unit] with `unit.orElse(null)`. */ + fun unit(unit: Optional) = unit(unit.getOrNull()) - @JvmStatic fun ofNumber(number: Double) = Amount(number = number) + /** + * Sets [Builder.unit] to an arbitrary JSON value. + * + * You should usually call [Builder.unit] with a well-typed [UnitOfMeasureCode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun unit(unit: JsonField) = apply { this.unit = unit } - @JvmStatic fun ofString(string: String) = Amount(string = string) - } + /** The unit price of the line item. Must be rounded to maximum 2 decimals */ + fun unitPrice(unitPrice: UnitPrice?) = unitPrice(JsonField.ofNullable(unitPrice)) + + /** Alias for calling [Builder.unitPrice] with `unitPrice.orElse(null)`. */ + fun unitPrice(unitPrice: Optional) = unitPrice(unitPrice.getOrNull()) /** - * An interface that defines how to map each variant of [Amount] to a value of type [T]. + * Sets [Builder.unitPrice] to an arbitrary JSON value. + * + * You should usually call [Builder.unitPrice] with a well-typed [UnitPrice] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - interface Visitor { + fun unitPrice(unitPrice: JsonField) = apply { this.unitPrice = unitPrice } - fun visitNumber(number: Double): T + /** Alias for calling [unitPrice] with `UnitPrice.ofNumber(number)`. */ + fun unitPrice(number: Double) = unitPrice(UnitPrice.ofNumber(number)) - fun visitString(string: String): T + /** Alias for calling [unitPrice] with `UnitPrice.ofString(string)`. */ + fun unitPrice(string: String) = unitPrice(UnitPrice.ofString(string)) - /** - * Maps an unknown variant of [Amount] to a value of type [T]. - * - * An instance of [Amount] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws EInvoiceInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw EInvoiceInvalidDataException("Unknown Amount: $json") - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - internal class Deserializer : BaseDeserializer(Amount::class) { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun ObjectCodec.deserialize(node: JsonNode): Amount { - val json = JsonValue.fromJsonNode(node) + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Amount(number = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Amount(string = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from object). - 0 -> Amount(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the - // first completely valid match, or simply the first match if none are - // completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } - internal class Serializer : BaseSerializer(Amount::class) { + /** + * Returns an immutable instance of [Item]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Item = + Item( + (allowances ?: JsonMissing.of()).map { it.toImmutable() }, + amount, + (charges ?: JsonMissing.of()).map { it.toImmutable() }, + date, + description, + productCode, + quantity, + tax, + taxRate, + unit, + unitPrice, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false - override fun serialize( - value: Amount, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.number != null -> generator.writeObject(value.number) - value.string != null -> generator.writeObject(value.string) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Amount") - } - } + fun validate(): Item = apply { + if (validated) { + return@apply } + + allowances().ifPresent { it.forEach { it.validate() } } + amount().ifPresent { it.validate() } + charges().ifPresent { it.forEach { it.validate() } } + date() + description() + productCode() + quantity().ifPresent { it.validate() } + tax().ifPresent { it.validate() } + taxRate() + unit().ifPresent { it.validate() } + unitPrice().ifPresent { it.validate() } + validated = true } - /** A charge is an additional fee for example for late payment, late delivery, etc. */ - class Charge + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (allowances.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (amount.asKnown().getOrNull()?.validity() ?: 0) + + (charges.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (date.asKnown().isPresent) 1 else 0) + + (if (description.asKnown().isPresent) 1 else 0) + + (if (productCode.asKnown().isPresent) 1 else 0) + + (quantity.asKnown().getOrNull()?.validity() ?: 0) + + (tax.asKnown().getOrNull()?.validity() ?: 0) + + (if (taxRate.asKnown().isPresent) 1 else 0) + + (unit.asKnown().getOrNull()?.validity() ?: 0) + + (unitPrice.asKnown().getOrNull()?.validity() ?: 0) + + /** An allowance is a discount for example for early payment, volume discount, etc. */ + class Allowance @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val amount: JsonField, private val baseAmount: JsonField, private val multiplierFactor: JsonField, private val reason: JsonField, - private val reasonCode: JsonField, + private val reasonCode: JsonField, private val taxCode: JsonField, - private val taxRate: JsonField, + private val taxRate: JsonField, private val additionalProperties: MutableMap, ) { @@ -9279,13 +5653,13 @@ private constructor( reason: JsonField = JsonMissing.of(), @JsonProperty("reason_code") @ExcludeMissing - reasonCode: JsonField = JsonMissing.of(), + reasonCode: JsonField = JsonMissing.of(), @JsonProperty("tax_code") @ExcludeMissing taxCode: JsonField = JsonMissing.of(), @JsonProperty("tax_rate") @ExcludeMissing - taxRate: JsonField = JsonMissing.of(), + taxRate: JsonField = JsonMissing.of(), ) : this( amount, baseAmount, @@ -9298,7 +5672,7 @@ private constructor( ) /** - * The charge amount, without VAT. Must be rounded to maximum 2 decimals + * The allowance amount, without VAT. Must be rounded to maximum 2 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -9306,8 +5680,8 @@ private constructor( fun amount(): Optional = amount.getOptional("amount") /** - * The base amount that may be used, in conjunction with the charge percentage, to - * calculate the charge amount. Must be rounded to maximum 2 decimals + * The base amount that may be used, in conjunction with the allowance percentage, to + * calculate the allowance amount. Must be rounded to maximum 2 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -9315,8 +5689,8 @@ private constructor( fun baseAmount(): Optional = baseAmount.getOptional("base_amount") /** - * The percentage that may be used, in conjunction with the charge base amount, to - * calculate the charge amount. To state 20%, use value 20 + * The percentage that may be used, in conjunction with the allowance base amount, to + * calculate the allowance amount. To state 20%, use value 20 * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -9325,7 +5699,7 @@ private constructor( multiplierFactor.getOptional("multiplier_factor") /** - * The reason for the charge + * The reason for the allowance * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -9333,12 +5707,12 @@ private constructor( fun reason(): Optional = reason.getOptional("reason") /** - * Charge reason codes for invoice charges and fees + * The code for the allowance reason * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun reasonCode(): Optional = reasonCode.getOptional("reason_code") + fun reasonCode(): Optional = reasonCode.getOptional("reason_code") /** * Duty or tax or fee category codes (Subset of UNCL5305) @@ -9351,12 +5725,12 @@ private constructor( fun taxCode(): Optional = taxCode.getOptional("tax_code") /** - * The VAT rate, represented as percentage that applies to the charge + * The VAT rate, represented as percentage that applies to the allowance * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun taxRate(): Optional = taxRate.getOptional("tax_rate") + fun taxRate(): Optional = taxRate.getOptional("tax_rate") /** * Returns the raw JSON value of [amount]. @@ -9400,7 +5774,7 @@ private constructor( */ @JsonProperty("reason_code") @ExcludeMissing - fun _reasonCode(): JsonField = reasonCode + fun _reasonCode(): JsonField = reasonCode /** * Returns the raw JSON value of [taxCode]. @@ -9414,7 +5788,7 @@ private constructor( * * Unlike [taxRate], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate + @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -9430,35 +5804,35 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Charge]. */ + /** Returns a mutable builder for constructing an instance of [Allowance]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [Charge]. */ + /** A builder for [Allowance]. */ class Builder internal constructor() { private var amount: JsonField = JsonMissing.of() private var baseAmount: JsonField = JsonMissing.of() private var multiplierFactor: JsonField = JsonMissing.of() private var reason: JsonField = JsonMissing.of() - private var reasonCode: JsonField = JsonMissing.of() + private var reasonCode: JsonField = JsonMissing.of() private var taxCode: JsonField = JsonMissing.of() - private var taxRate: JsonField = JsonMissing.of() + private var taxRate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(charge: Charge) = apply { - amount = charge.amount - baseAmount = charge.baseAmount - multiplierFactor = charge.multiplierFactor - reason = charge.reason - reasonCode = charge.reasonCode - taxCode = charge.taxCode - taxRate = charge.taxRate - additionalProperties = charge.additionalProperties.toMutableMap() + internal fun from(allowance: Allowance) = apply { + amount = allowance.amount + baseAmount = allowance.baseAmount + multiplierFactor = allowance.multiplierFactor + reason = allowance.reason + reasonCode = allowance.reasonCode + taxCode = allowance.taxCode + taxRate = allowance.taxRate + additionalProperties = allowance.additionalProperties.toMutableMap() } - /** The charge amount, without VAT. Must be rounded to maximum 2 decimals */ + /** The allowance amount, without VAT. Must be rounded to maximum 2 decimals */ fun amount(amount: Amount?) = amount(JsonField.ofNullable(amount)) /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ @@ -9480,8 +5854,8 @@ private constructor( fun amount(string: String) = amount(Amount.ofString(string)) /** - * The base amount that may be used, in conjunction with the charge percentage, to - * calculate the charge amount. Must be rounded to maximum 2 decimals + * The base amount that may be used, in conjunction with the allowance percentage, + * to calculate the allowance amount. Must be rounded to maximum 2 decimals */ fun baseAmount(baseAmount: BaseAmount?) = baseAmount(JsonField.ofNullable(baseAmount)) @@ -9508,8 +5882,8 @@ private constructor( fun baseAmount(string: String) = baseAmount(BaseAmount.ofString(string)) /** - * The percentage that may be used, in conjunction with the charge base amount, to - * calculate the charge amount. To state 20%, use value 20 + * The percentage that may be used, in conjunction with the allowance base amount, + * to calculate the allowance amount. To state 20%, use value 20 */ fun multiplierFactor(multiplierFactor: MultiplierFactor?) = multiplierFactor(JsonField.ofNullable(multiplierFactor)) @@ -9544,7 +5918,7 @@ private constructor( fun multiplierFactor(string: String) = multiplierFactor(MultiplierFactor.ofString(string)) - /** The reason for the charge */ + /** The reason for the allowance */ fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ @@ -9559,22 +5933,20 @@ private constructor( */ fun reason(reason: JsonField) = apply { this.reason = reason } - /** Charge reason codes for invoice charges and fees */ - fun reasonCode(reasonCode: ReasonCode?) = - reasonCode(JsonField.ofNullable(reasonCode)) + /** The code for the allowance reason */ + fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ - fun reasonCode(reasonCode: Optional) = - reasonCode(reasonCode.getOrNull()) + fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) /** * Sets [Builder.reasonCode] to an arbitrary JSON value. * - * You should usually call [Builder.reasonCode] with a well-typed [ReasonCode] value + * You should usually call [Builder.reasonCode] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun reasonCode(reasonCode: JsonField) = apply { + fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode } @@ -9597,26 +5969,20 @@ private constructor( */ fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } - /** The VAT rate, represented as percentage that applies to the charge */ - fun taxRate(taxRate: TaxRate?) = taxRate(JsonField.ofNullable(taxRate)) + /** The VAT rate, represented as percentage that applies to the allowance */ + fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ - fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) + fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) /** * Sets [Builder.taxRate] to an arbitrary JSON value. * - * You should usually call [Builder.taxRate] with a well-typed [TaxRate] value + * You should usually call [Builder.taxRate] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } - - /** Alias for calling [taxRate] with `TaxRate.ofNumber(number)`. */ - fun taxRate(number: Double) = taxRate(TaxRate.ofNumber(number)) - - /** Alias for calling [taxRate] with `TaxRate.ofString(string)`. */ - fun taxRate(string: String) = taxRate(TaxRate.ofString(string)) + fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -9641,12 +6007,12 @@ private constructor( } /** - * Returns an immutable instance of [Charge]. + * Returns an immutable instance of [Allowance]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): Charge = - Charge( + fun build(): Allowance = + Allowance( amount, baseAmount, multiplierFactor, @@ -9660,7 +6026,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Charge = apply { + fun validate(): Allowance = apply { if (validated) { return@apply } @@ -9669,9 +6035,9 @@ private constructor( baseAmount().ifPresent { it.validate() } multiplierFactor().ifPresent { it.validate() } reason() - reasonCode().ifPresent { it.validate() } + reasonCode() taxCode().ifPresent { it.validate() } - taxRate().ifPresent { it.validate() } + taxRate() validated = true } @@ -9695,11 +6061,11 @@ private constructor( (baseAmount.asKnown().getOrNull()?.validity() ?: 0) + (multiplierFactor.asKnown().getOrNull()?.validity() ?: 0) + (if (reason.asKnown().isPresent) 1 else 0) + - (reasonCode.asKnown().getOrNull()?.validity() ?: 0) + + (if (reasonCode.asKnown().isPresent) 1 else 0) + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + - (taxRate.asKnown().getOrNull()?.validity() ?: 0) + (if (taxRate.asKnown().isPresent) 1 else 0) - /** The charge amount, without VAT. Must be rounded to maximum 2 decimals */ + /** The allowance amount, without VAT. Must be rounded to maximum 2 decimals */ @JsonDeserialize(using = Amount.Deserializer::class) @JsonSerialize(using = Amount.Serializer::class) class Amount @@ -9872,8 +6238,8 @@ private constructor( } /** - * The base amount that may be used, in conjunction with the charge percentage, to - * calculate the charge amount. Must be rounded to maximum 2 decimals + * The base amount that may be used, in conjunction with the allowance percentage, to + * calculate the allowance amount. Must be rounded to maximum 2 decimals */ @JsonDeserialize(using = BaseAmount.Deserializer::class) @JsonSerialize(using = BaseAmount.Serializer::class) @@ -10047,8 +6413,8 @@ private constructor( } /** - * The percentage that may be used, in conjunction with the charge base amount, to - * calculate the charge amount. To state 20%, use value 20 + * The percentage that may be used, in conjunction with the allowance base amount, to + * calculate the allowance amount. To state 20%, use value 20 */ @JsonDeserialize(using = MultiplierFactor.Deserializer::class) @JsonSerialize(using = MultiplierFactor.Serializer::class) @@ -10225,10 +6591,13 @@ private constructor( } } - /** Charge reason codes for invoice charges and fees */ - class ReasonCode - @JsonCreator - private constructor(private val value: JsonField) : Enum { + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + */ + class TaxCode @JsonCreator private constructor(private val value: JsonField) : + Enum { /** * Returns this class instance's raw value. @@ -10242,1146 +6611,1040 @@ private constructor( companion object { - @JvmField val AA = of("AA") - - @JvmField val AAA = of("AAA") - - @JvmField val AAC = of("AAC") - - @JvmField val AAD = of("AAD") - - @JvmField val AAE = of("AAE") - - @JvmField val AAF = of("AAF") - - @JvmField val AAH = of("AAH") - - @JvmField val AAI = of("AAI") - - @JvmField val AAS = of("AAS") - - @JvmField val AAT = of("AAT") - - @JvmField val AAV = of("AAV") - - @JvmField val AAY = of("AAY") - - @JvmField val AAZ = of("AAZ") - - @JvmField val ABA = of("ABA") - - @JvmField val ABB = of("ABB") - - @JvmField val ABC = of("ABC") - - @JvmField val ABD = of("ABD") - - @JvmField val ABF = of("ABF") - - @JvmField val ABK = of("ABK") + @JvmField val AE = of("AE") - @JvmField val ABL = of("ABL") + @JvmField val E = of("E") - @JvmField val ABN = of("ABN") + @JvmField val S = of("S") - @JvmField val ABR = of("ABR") + @JvmField val Z = of("Z") - @JvmField val ABS = of("ABS") + @JvmField val G = of("G") - @JvmField val ABT = of("ABT") + @JvmField val O = of("O") - @JvmField val ABU = of("ABU") + @JvmField val K = of("K") - @JvmField val ACF = of("ACF") + @JvmField val L = of("L") - @JvmField val ACG = of("ACG") + @JvmField val M = of("M") - @JvmField val ACH = of("ACH") + @JvmField val B = of("B") - @JvmField val ACI = of("ACI") + @JvmStatic fun of(value: String) = TaxCode(JsonField.of(value)) + } - @JvmField val ACJ = of("ACJ") + /** An enum containing [TaxCode]'s known values. */ + enum class Known { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + } - @JvmField val ACK = of("ACK") + /** + * An enum containing [TaxCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TaxCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + /** + * An enum member indicating that [TaxCode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } - @JvmField val ACL = of("ACL") + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AE -> Value.AE + E -> Value.E + S -> Value.S + Z -> Value.Z + G -> Value.G + O -> Value.O + K -> Value.K + L -> Value.L + M -> Value.M + B -> Value.B + else -> Value._UNKNOWN + } - @JvmField val ACM = of("ACM") + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + AE -> Known.AE + E -> Known.E + S -> Known.S + Z -> Known.Z + G -> Known.G + O -> Known.O + K -> Known.K + L -> Known.L + M -> Known.M + B -> Known.B + else -> throw EInvoiceInvalidDataException("Unknown TaxCode: $value") + } - @JvmField val ACS = of("ACS") + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } - @JvmField val ADC = of("ADC") + private var validated: Boolean = false - @JvmField val ADE = of("ADE") + fun validate(): TaxCode = apply { + if (validated) { + return@apply + } - @JvmField val ADJ = of("ADJ") + known() + validated = true + } - @JvmField val ADK = of("ADK") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } - @JvmField val ADL = of("ADL") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - @JvmField val ADM = of("ADM") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JvmField val ADN = of("ADN") + return other is TaxCode && value == other.value + } - @JvmField val ADO = of("ADO") + override fun hashCode() = value.hashCode() - @JvmField val ADP = of("ADP") + override fun toString() = value.toString() + } - @JvmField val ADQ = of("ADQ") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JvmField val ADR = of("ADR") + return other is Allowance && + amount == other.amount && + baseAmount == other.baseAmount && + multiplierFactor == other.multiplierFactor && + reason == other.reason && + reasonCode == other.reasonCode && + taxCode == other.taxCode && + taxRate == other.taxRate && + additionalProperties == other.additionalProperties + } - @JvmField val ADT = of("ADT") + private val hashCode: Int by lazy { + Objects.hash( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + additionalProperties, + ) + } - @JvmField val ADW = of("ADW") + override fun hashCode(): Int = hashCode - @JvmField val ADY = of("ADY") + override fun toString() = + "Allowance{amount=$amount, baseAmount=$baseAmount, multiplierFactor=$multiplierFactor, reason=$reason, reasonCode=$reasonCode, taxCode=$taxCode, taxRate=$taxRate, additionalProperties=$additionalProperties}" + } - @JvmField val ADZ = of("ADZ") + /** + * The total amount of the line item, exclusive of VAT, after subtracting line level + * allowances and adding line level charges. Must be rounded to maximum 2 decimals + */ + @JsonDeserialize(using = Amount.Deserializer::class) + @JsonSerialize(using = Amount.Serializer::class) + class Amount + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { - @JvmField val AEA = of("AEA") + fun number(): Optional = Optional.ofNullable(number) - @JvmField val AEB = of("AEB") + fun string(): Optional = Optional.ofNullable(string) - @JvmField val AEC = of("AEC") + fun isNumber(): Boolean = number != null - @JvmField val AED = of("AED") + fun isString(): Boolean = string != null - @JvmField val AEF = of("AEF") + fun asNumber(): Double = number.getOrThrow("number") - @JvmField val AEH = of("AEH") + fun asString(): String = string.getOrThrow("string") - @JvmField val AEI = of("AEI") + fun _json(): Optional = Optional.ofNullable(_json) - @JvmField val AEJ = of("AEJ") + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } - @JvmField val AEK = of("AEK") + private var validated: Boolean = false - @JvmField val AEL = of("AEL") + fun validate(): Amount = apply { + if (validated) { + return@apply + } - @JvmField val AEM = of("AEM") + accept( + object : Visitor { + override fun visitNumber(number: Double) {} - @JvmField val AEN = of("AEN") + override fun visitString(string: String) {} + } + ) + validated = true + } - @JvmField val AEO = of("AEO") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } - @JvmField val AEP = of("AEP") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 - @JvmField val AES = of("AES") + override fun visitString(string: String) = 1 - @JvmField val AET = of("AET") + override fun unknown(json: JsonValue?) = 0 + } + ) - @JvmField val AEU = of("AEU") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JvmField val AEV = of("AEV") + return other is Amount && number == other.number && string == other.string + } - @JvmField val AEW = of("AEW") + override fun hashCode(): Int = Objects.hash(number, string) - @JvmField val AEX = of("AEX") + override fun toString(): String = + when { + number != null -> "Amount{number=$number}" + string != null -> "Amount{string=$string}" + _json != null -> "Amount{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Amount") + } - @JvmField val AEY = of("AEY") + companion object { - @JvmField val AEZ = of("AEZ") + @JvmStatic fun ofNumber(number: Double) = Amount(number = number) - @JvmField val AJ = of("AJ") + @JvmStatic fun ofString(string: String) = Amount(string = string) + } - @JvmField val AU = of("AU") + /** + * An interface that defines how to map each variant of [Amount] to a value of type [T]. + */ + interface Visitor { - @JvmField val CA = of("CA") + fun visitNumber(number: Double): T - @JvmField val CAB = of("CAB") + fun visitString(string: String): T - @JvmField val CAD = of("CAD") + /** + * Maps an unknown variant of [Amount] to a value of type [T]. + * + * An instance of [Amount] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws EInvoiceInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw EInvoiceInvalidDataException("Unknown Amount: $json") + } + } - @JvmField val CAE = of("CAE") + internal class Deserializer : BaseDeserializer(Amount::class) { - @JvmField val CAF = of("CAF") + override fun ObjectCodec.deserialize(node: JsonNode): Amount { + val json = JsonValue.fromJsonNode(node) - @JvmField val CAI = of("CAI") + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Amount(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Amount(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> Amount(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } - @JvmField val CAJ = of("CAJ") + internal class Serializer : BaseSerializer(Amount::class) { - @JvmField val CAK = of("CAK") + override fun serialize( + value: Amount, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Amount") + } + } + } + } - @JvmField val CAL = of("CAL") + /** A charge is an additional fee for example for late payment, late delivery, etc. */ + class Charge + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val amount: JsonField, + private val baseAmount: JsonField, + private val multiplierFactor: JsonField, + private val reason: JsonField, + private val reasonCode: JsonField, + private val taxCode: JsonField, + private val taxRate: JsonField, + private val additionalProperties: MutableMap, + ) { - @JvmField val CAM = of("CAM") + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("base_amount") + @ExcludeMissing + baseAmount: JsonField = JsonMissing.of(), + @JsonProperty("multiplier_factor") + @ExcludeMissing + multiplierFactor: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + reason: JsonField = JsonMissing.of(), + @JsonProperty("reason_code") + @ExcludeMissing + reasonCode: JsonField = JsonMissing.of(), + @JsonProperty("tax_code") + @ExcludeMissing + taxCode: JsonField = JsonMissing.of(), + @JsonProperty("tax_rate") + @ExcludeMissing + taxRate: JsonField = JsonMissing.of(), + ) : this( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + mutableMapOf(), + ) - @JvmField val CAN = of("CAN") + /** + * The charge amount, without VAT. Must be rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") - @JvmField val CAO = of("CAO") + /** + * The base amount that may be used, in conjunction with the charge percentage, to + * calculate the charge amount. Must be rounded to maximum 2 decimals + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun baseAmount(): Optional = baseAmount.getOptional("base_amount") - @JvmField val CAP = of("CAP") + /** + * The percentage that may be used, in conjunction with the charge base amount, to + * calculate the charge amount. To state 20%, use value 20 + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun multiplierFactor(): Optional = + multiplierFactor.getOptional("multiplier_factor") - @JvmField val CAQ = of("CAQ") + /** + * The reason for the charge + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun reason(): Optional = reason.getOptional("reason") - @JvmField val CAR = of("CAR") + /** + * The code for the charge reason + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun reasonCode(): Optional = reasonCode.getOptional("reason_code") - @JvmField val CAS = of("CAS") + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun taxCode(): Optional = taxCode.getOptional("tax_code") - @JvmField val CAT = of("CAT") + /** + * The VAT rate, represented as percentage that applies to the charge + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun taxRate(): Optional = taxRate.getOptional("tax_rate") - @JvmField val CAU = of("CAU") + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JvmField val CAV = of("CAV") + /** + * Returns the raw JSON value of [baseAmount]. + * + * Unlike [baseAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("base_amount") + @ExcludeMissing + fun _baseAmount(): JsonField = baseAmount - @JvmField val CAW = of("CAW") + /** + * Returns the raw JSON value of [multiplierFactor]. + * + * Unlike [multiplierFactor], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("multiplier_factor") + @ExcludeMissing + fun _multiplierFactor(): JsonField = multiplierFactor - @JvmField val CAX = of("CAX") + /** + * Returns the raw JSON value of [reason]. + * + * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - @JvmField val CAY = of("CAY") + /** + * Returns the raw JSON value of [reasonCode]. + * + * Unlike [reasonCode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("reason_code") + @ExcludeMissing + fun _reasonCode(): JsonField = reasonCode - @JvmField val CAZ = of("CAZ") + /** + * Returns the raw JSON value of [taxCode]. + * + * Unlike [taxCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax_code") @ExcludeMissing fun _taxCode(): JsonField = taxCode - @JvmField val CD = of("CD") + /** + * Returns the raw JSON value of [taxRate]. + * + * Unlike [taxRate], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate - @JvmField val CG = of("CG") + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - @JvmField val CS = of("CS") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - @JvmField val CT = of("CT") + fun toBuilder() = Builder().from(this) - @JvmField val DAB = of("DAB") + companion object { - @JvmField val DAC = of("DAC") + /** Returns a mutable builder for constructing an instance of [Charge]. */ + @JvmStatic fun builder() = Builder() + } - @JvmField val DAD = of("DAD") + /** A builder for [Charge]. */ + class Builder internal constructor() { - @JvmField val DAF = of("DAF") + private var amount: JsonField = JsonMissing.of() + private var baseAmount: JsonField = JsonMissing.of() + private var multiplierFactor: JsonField = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() + private var reasonCode: JsonField = JsonMissing.of() + private var taxCode: JsonField = JsonMissing.of() + private var taxRate: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - @JvmField val DAG = of("DAG") + @JvmSynthetic + internal fun from(charge: Charge) = apply { + amount = charge.amount + baseAmount = charge.baseAmount + multiplierFactor = charge.multiplierFactor + reason = charge.reason + reasonCode = charge.reasonCode + taxCode = charge.taxCode + taxRate = charge.taxRate + additionalProperties = charge.additionalProperties.toMutableMap() + } - @JvmField val DAH = of("DAH") + /** The charge amount, without VAT. Must be rounded to maximum 2 decimals */ + fun amount(amount: Amount?) = amount(JsonField.ofNullable(amount)) - @JvmField val DAI = of("DAI") + /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ + fun amount(amount: Optional) = amount(amount.getOrNull()) - @JvmField val DAJ = of("DAJ") + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Amount] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } - @JvmField val DAK = of("DAK") + /** Alias for calling [amount] with `Amount.ofNumber(number)`. */ + fun amount(number: Double) = amount(Amount.ofNumber(number)) - @JvmField val DAL = of("DAL") + /** Alias for calling [amount] with `Amount.ofString(string)`. */ + fun amount(string: String) = amount(Amount.ofString(string)) - @JvmField val DAM = of("DAM") + /** + * The base amount that may be used, in conjunction with the charge percentage, to + * calculate the charge amount. Must be rounded to maximum 2 decimals + */ + fun baseAmount(baseAmount: BaseAmount?) = + baseAmount(JsonField.ofNullable(baseAmount)) - @JvmField val DAN = of("DAN") + /** Alias for calling [Builder.baseAmount] with `baseAmount.orElse(null)`. */ + fun baseAmount(baseAmount: Optional) = + baseAmount(baseAmount.getOrNull()) - @JvmField val DAO = of("DAO") + /** + * Sets [Builder.baseAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.baseAmount] with a well-typed [BaseAmount] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun baseAmount(baseAmount: JsonField) = apply { + this.baseAmount = baseAmount + } - @JvmField val DAP = of("DAP") + /** Alias for calling [baseAmount] with `BaseAmount.ofNumber(number)`. */ + fun baseAmount(number: Double) = baseAmount(BaseAmount.ofNumber(number)) - @JvmField val DAQ = of("DAQ") + /** Alias for calling [baseAmount] with `BaseAmount.ofString(string)`. */ + fun baseAmount(string: String) = baseAmount(BaseAmount.ofString(string)) - @JvmField val DL = of("DL") + /** + * The percentage that may be used, in conjunction with the charge base amount, to + * calculate the charge amount. To state 20%, use value 20 + */ + fun multiplierFactor(multiplierFactor: MultiplierFactor?) = + multiplierFactor(JsonField.ofNullable(multiplierFactor)) - @JvmField val EG = of("EG") + /** + * Alias for calling [Builder.multiplierFactor] with + * `multiplierFactor.orElse(null)`. + */ + fun multiplierFactor(multiplierFactor: Optional) = + multiplierFactor(multiplierFactor.getOrNull()) - @JvmField val EP = of("EP") + /** + * Sets [Builder.multiplierFactor] to an arbitrary JSON value. + * + * You should usually call [Builder.multiplierFactor] with a well-typed + * [MultiplierFactor] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun multiplierFactor(multiplierFactor: JsonField) = apply { + this.multiplierFactor = multiplierFactor + } - @JvmField val ER = of("ER") + /** + * Alias for calling [multiplierFactor] with `MultiplierFactor.ofNumber(number)`. + */ + fun multiplierFactor(number: Double) = + multiplierFactor(MultiplierFactor.ofNumber(number)) - @JvmField val FAA = of("FAA") + /** + * Alias for calling [multiplierFactor] with `MultiplierFactor.ofString(string)`. + */ + fun multiplierFactor(string: String) = + multiplierFactor(MultiplierFactor.ofString(string)) - @JvmField val FAB = of("FAB") + /** The reason for the charge */ + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - @JvmField val FAC = of("FAC") + /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ + fun reason(reason: Optional) = reason(reason.getOrNull()) - @JvmField val FC = of("FC") + /** + * Sets [Builder.reason] to an arbitrary JSON value. + * + * You should usually call [Builder.reason] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun reason(reason: JsonField) = apply { this.reason = reason } - @JvmField val FH = of("FH") + /** The code for the charge reason */ + fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) - @JvmField val FI = of("FI") + /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ + fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) - @JvmField val GAA = of("GAA") + /** + * Sets [Builder.reasonCode] to an arbitrary JSON value. + * + * You should usually call [Builder.reasonCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun reasonCode(reasonCode: JsonField) = apply { + this.reasonCode = reasonCode + } - @JvmField val HAA = of("HAA") + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + */ + fun taxCode(taxCode: TaxCode?) = taxCode(JsonField.ofNullable(taxCode)) - @JvmField val HD = of("HD") + /** Alias for calling [Builder.taxCode] with `taxCode.orElse(null)`. */ + fun taxCode(taxCode: Optional) = taxCode(taxCode.getOrNull()) - @JvmField val HH = of("HH") + /** + * Sets [Builder.taxCode] to an arbitrary JSON value. + * + * You should usually call [Builder.taxCode] with a well-typed [TaxCode] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } - @JvmField val IAA = of("IAA") + /** The VAT rate, represented as percentage that applies to the charge */ + fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) - @JvmField val IAB = of("IAB") + /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ + fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) - @JvmField val ID = of("ID") + /** + * Sets [Builder.taxRate] to an arbitrary JSON value. + * + * You should usually call [Builder.taxRate] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } - @JvmField val IF = of("IF") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - @JvmField val IR = of("IR") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - @JvmField val IS = of("IS") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } - @JvmField val KO = of("KO") + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - @JvmField val L1 = of("L1") + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } - @JvmField val LA = of("LA") + /** + * Returns an immutable instance of [Charge]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Charge = + Charge( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + additionalProperties.toMutableMap(), + ) + } - @JvmField val LAA = of("LAA") + private var validated: Boolean = false - @JvmField val LAB = of("LAB") + fun validate(): Charge = apply { + if (validated) { + return@apply + } - @JvmField val LF = of("LF") + amount().ifPresent { it.validate() } + baseAmount().ifPresent { it.validate() } + multiplierFactor().ifPresent { it.validate() } + reason() + reasonCode() + taxCode().ifPresent { it.validate() } + taxRate() + validated = true + } - @JvmField val MAE = of("MAE") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } - @JvmField val MI = of("MI") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (amount.asKnown().getOrNull()?.validity() ?: 0) + + (baseAmount.asKnown().getOrNull()?.validity() ?: 0) + + (multiplierFactor.asKnown().getOrNull()?.validity() ?: 0) + + (if (reason.asKnown().isPresent) 1 else 0) + + (if (reasonCode.asKnown().isPresent) 1 else 0) + + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + + (if (taxRate.asKnown().isPresent) 1 else 0) - @JvmField val ML = of("ML") + /** The charge amount, without VAT. Must be rounded to maximum 2 decimals */ + @JsonDeserialize(using = Amount.Deserializer::class) + @JsonSerialize(using = Amount.Serializer::class) + class Amount + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { - @JvmField val NAA = of("NAA") + fun number(): Optional = Optional.ofNullable(number) - @JvmField val OA = of("OA") + fun string(): Optional = Optional.ofNullable(string) - @JvmField val PA = of("PA") + fun isNumber(): Boolean = number != null - @JvmField val PAA = of("PAA") + fun isString(): Boolean = string != null - @JvmField val PC = of("PC") + fun asNumber(): Double = number.getOrThrow("number") - @JvmField val PL = of("PL") + fun asString(): String = string.getOrThrow("string") - @JvmField val PRV = of("PRV") + fun _json(): Optional = Optional.ofNullable(_json) - @JvmField val RAB = of("RAB") + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } - @JvmField val RAC = of("RAC") + private var validated: Boolean = false - @JvmField val RAD = of("RAD") + fun validate(): Amount = apply { + if (validated) { + return@apply + } - @JvmField val RAF = of("RAF") + accept( + object : Visitor { + override fun visitNumber(number: Double) {} - @JvmField val RE = of("RE") + override fun visitString(string: String) {} + } + ) + validated = true + } - @JvmField val RF = of("RF") + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } - @JvmField val RH = of("RH") + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 - @JvmField val RV = of("RV") + override fun visitString(string: String) = 1 - @JvmField val SA = of("SA") + override fun unknown(json: JsonValue?) = 0 + } + ) - @JvmField val SAA = of("SAA") + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - @JvmField val SAD = of("SAD") + return other is Amount && number == other.number && string == other.string + } - @JvmField val SAE = of("SAE") + override fun hashCode(): Int = Objects.hash(number, string) - @JvmField val SAI = of("SAI") + override fun toString(): String = + when { + number != null -> "Amount{number=$number}" + string != null -> "Amount{string=$string}" + _json != null -> "Amount{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Amount") + } - @JvmField val SG = of("SG") + companion object { - @JvmField val SH = of("SH") + @JvmStatic fun ofNumber(number: Double) = Amount(number = number) - @JvmField val SM = of("SM") + @JvmStatic fun ofString(string: String) = Amount(string = string) + } - @JvmField val SU = of("SU") + /** + * An interface that defines how to map each variant of [Amount] to a value of type + * [T]. + */ + interface Visitor { - @JvmField val TAB = of("TAB") + fun visitNumber(number: Double): T - @JvmField val TAC = of("TAC") + fun visitString(string: String): T - @JvmField val TT = of("TT") + /** + * Maps an unknown variant of [Amount] to a value of type [T]. + * + * An instance of [Amount] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on + * an older version than the API, then the API may respond with new variants + * that the SDK is unaware of. + * + * @throws EInvoiceInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw EInvoiceInvalidDataException("Unknown Amount: $json") + } + } - @JvmField val TV = of("TV") + internal class Deserializer : BaseDeserializer(Amount::class) { - @JvmField val V1 = of("V1") + override fun ObjectCodec.deserialize(node: JsonNode): Amount { + val json = JsonValue.fromJsonNode(node) - @JvmField val V2 = of("V2") + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Amount(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Amount(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // object). + 0 -> Amount(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } - @JvmField val WH = of("WH") + internal class Serializer : BaseSerializer(Amount::class) { - @JvmField val XAA = of("XAA") + override fun serialize( + value: Amount, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Amount") + } + } + } + } - @JvmField val YY = of("YY") + /** + * The base amount that may be used, in conjunction with the charge percentage, to + * calculate the charge amount. Must be rounded to maximum 2 decimals + */ + @JsonDeserialize(using = BaseAmount.Deserializer::class) + @JsonSerialize(using = BaseAmount.Serializer::class) + class BaseAmount + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { - @JvmField val ZZZ = of("ZZZ") + fun number(): Optional = Optional.ofNullable(number) - @JvmStatic fun of(value: String) = ReasonCode(JsonField.of(value)) - } + fun string(): Optional = Optional.ofNullable(string) - /** An enum containing [ReasonCode]'s known values. */ - enum class Known { - AA, - AAA, - AAC, - AAD, - AAE, - AAF, - AAH, - AAI, - AAS, - AAT, - AAV, - AAY, - AAZ, - ABA, - ABB, - ABC, - ABD, - ABF, - ABK, - ABL, - ABN, - ABR, - ABS, - ABT, - ABU, - ACF, - ACG, - ACH, - ACI, - ACJ, - ACK, - ACL, - ACM, - ACS, - ADC, - ADE, - ADJ, - ADK, - ADL, - ADM, - ADN, - ADO, - ADP, - ADQ, - ADR, - ADT, - ADW, - ADY, - ADZ, - AEA, - AEB, - AEC, - AED, - AEF, - AEH, - AEI, - AEJ, - AEK, - AEL, - AEM, - AEN, - AEO, - AEP, - AES, - AET, - AEU, - AEV, - AEW, - AEX, - AEY, - AEZ, - AJ, - AU, - CA, - CAB, - CAD, - CAE, - CAF, - CAI, - CAJ, - CAK, - CAL, - CAM, - CAN, - CAO, - CAP, - CAQ, - CAR, - CAS, - CAT, - CAU, - CAV, - CAW, - CAX, - CAY, - CAZ, - CD, - CG, - CS, - CT, - DAB, - DAC, - DAD, - DAF, - DAG, - DAH, - DAI, - DAJ, - DAK, - DAL, - DAM, - DAN, - DAO, - DAP, - DAQ, - DL, - EG, - EP, - ER, - FAA, - FAB, - FAC, - FC, - FH, - FI, - GAA, - HAA, - HD, - HH, - IAA, - IAB, - ID, - IF, - IR, - IS, - KO, - L1, - LA, - LAA, - LAB, - LF, - MAE, - MI, - ML, - NAA, - OA, - PA, - PAA, - PC, - PL, - PRV, - RAB, - RAC, - RAD, - RAF, - RE, - RF, - RH, - RV, - SA, - SAA, - SAD, - SAE, - SAI, - SG, - SH, - SM, - SU, - TAB, - TAC, - TT, - TV, - V1, - V2, - WH, - XAA, - YY, - ZZZ, - } + fun isNumber(): Boolean = number != null - /** - * An enum containing [ReasonCode]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ReasonCode] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AA, - AAA, - AAC, - AAD, - AAE, - AAF, - AAH, - AAI, - AAS, - AAT, - AAV, - AAY, - AAZ, - ABA, - ABB, - ABC, - ABD, - ABF, - ABK, - ABL, - ABN, - ABR, - ABS, - ABT, - ABU, - ACF, - ACG, - ACH, - ACI, - ACJ, - ACK, - ACL, - ACM, - ACS, - ADC, - ADE, - ADJ, - ADK, - ADL, - ADM, - ADN, - ADO, - ADP, - ADQ, - ADR, - ADT, - ADW, - ADY, - ADZ, - AEA, - AEB, - AEC, - AED, - AEF, - AEH, - AEI, - AEJ, - AEK, - AEL, - AEM, - AEN, - AEO, - AEP, - AES, - AET, - AEU, - AEV, - AEW, - AEX, - AEY, - AEZ, - AJ, - AU, - CA, - CAB, - CAD, - CAE, - CAF, - CAI, - CAJ, - CAK, - CAL, - CAM, - CAN, - CAO, - CAP, - CAQ, - CAR, - CAS, - CAT, - CAU, - CAV, - CAW, - CAX, - CAY, - CAZ, - CD, - CG, - CS, - CT, - DAB, - DAC, - DAD, - DAF, - DAG, - DAH, - DAI, - DAJ, - DAK, - DAL, - DAM, - DAN, - DAO, - DAP, - DAQ, - DL, - EG, - EP, - ER, - FAA, - FAB, - FAC, - FC, - FH, - FI, - GAA, - HAA, - HD, - HH, - IAA, - IAB, - ID, - IF, - IR, - IS, - KO, - L1, - LA, - LAA, - LAB, - LF, - MAE, - MI, - ML, - NAA, - OA, - PA, - PAA, - PC, - PL, - PRV, - RAB, - RAC, - RAD, - RAF, - RE, - RF, - RH, - RV, - SA, - SAA, - SAD, - SAE, - SAI, - SG, - SH, - SM, - SU, - TAB, - TAC, - TT, - TV, - V1, - V2, - WH, - XAA, - YY, - ZZZ, - /** - * An enum member indicating that [ReasonCode] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + fun isString(): Boolean = string != null - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AA -> Value.AA - AAA -> Value.AAA - AAC -> Value.AAC - AAD -> Value.AAD - AAE -> Value.AAE - AAF -> Value.AAF - AAH -> Value.AAH - AAI -> Value.AAI - AAS -> Value.AAS - AAT -> Value.AAT - AAV -> Value.AAV - AAY -> Value.AAY - AAZ -> Value.AAZ - ABA -> Value.ABA - ABB -> Value.ABB - ABC -> Value.ABC - ABD -> Value.ABD - ABF -> Value.ABF - ABK -> Value.ABK - ABL -> Value.ABL - ABN -> Value.ABN - ABR -> Value.ABR - ABS -> Value.ABS - ABT -> Value.ABT - ABU -> Value.ABU - ACF -> Value.ACF - ACG -> Value.ACG - ACH -> Value.ACH - ACI -> Value.ACI - ACJ -> Value.ACJ - ACK -> Value.ACK - ACL -> Value.ACL - ACM -> Value.ACM - ACS -> Value.ACS - ADC -> Value.ADC - ADE -> Value.ADE - ADJ -> Value.ADJ - ADK -> Value.ADK - ADL -> Value.ADL - ADM -> Value.ADM - ADN -> Value.ADN - ADO -> Value.ADO - ADP -> Value.ADP - ADQ -> Value.ADQ - ADR -> Value.ADR - ADT -> Value.ADT - ADW -> Value.ADW - ADY -> Value.ADY - ADZ -> Value.ADZ - AEA -> Value.AEA - AEB -> Value.AEB - AEC -> Value.AEC - AED -> Value.AED - AEF -> Value.AEF - AEH -> Value.AEH - AEI -> Value.AEI - AEJ -> Value.AEJ - AEK -> Value.AEK - AEL -> Value.AEL - AEM -> Value.AEM - AEN -> Value.AEN - AEO -> Value.AEO - AEP -> Value.AEP - AES -> Value.AES - AET -> Value.AET - AEU -> Value.AEU - AEV -> Value.AEV - AEW -> Value.AEW - AEX -> Value.AEX - AEY -> Value.AEY - AEZ -> Value.AEZ - AJ -> Value.AJ - AU -> Value.AU - CA -> Value.CA - CAB -> Value.CAB - CAD -> Value.CAD - CAE -> Value.CAE - CAF -> Value.CAF - CAI -> Value.CAI - CAJ -> Value.CAJ - CAK -> Value.CAK - CAL -> Value.CAL - CAM -> Value.CAM - CAN -> Value.CAN - CAO -> Value.CAO - CAP -> Value.CAP - CAQ -> Value.CAQ - CAR -> Value.CAR - CAS -> Value.CAS - CAT -> Value.CAT - CAU -> Value.CAU - CAV -> Value.CAV - CAW -> Value.CAW - CAX -> Value.CAX - CAY -> Value.CAY - CAZ -> Value.CAZ - CD -> Value.CD - CG -> Value.CG - CS -> Value.CS - CT -> Value.CT - DAB -> Value.DAB - DAC -> Value.DAC - DAD -> Value.DAD - DAF -> Value.DAF - DAG -> Value.DAG - DAH -> Value.DAH - DAI -> Value.DAI - DAJ -> Value.DAJ - DAK -> Value.DAK - DAL -> Value.DAL - DAM -> Value.DAM - DAN -> Value.DAN - DAO -> Value.DAO - DAP -> Value.DAP - DAQ -> Value.DAQ - DL -> Value.DL - EG -> Value.EG - EP -> Value.EP - ER -> Value.ER - FAA -> Value.FAA - FAB -> Value.FAB - FAC -> Value.FAC - FC -> Value.FC - FH -> Value.FH - FI -> Value.FI - GAA -> Value.GAA - HAA -> Value.HAA - HD -> Value.HD - HH -> Value.HH - IAA -> Value.IAA - IAB -> Value.IAB - ID -> Value.ID - IF -> Value.IF - IR -> Value.IR - IS -> Value.IS - KO -> Value.KO - L1 -> Value.L1 - LA -> Value.LA - LAA -> Value.LAA - LAB -> Value.LAB - LF -> Value.LF - MAE -> Value.MAE - MI -> Value.MI - ML -> Value.ML - NAA -> Value.NAA - OA -> Value.OA - PA -> Value.PA - PAA -> Value.PAA - PC -> Value.PC - PL -> Value.PL - PRV -> Value.PRV - RAB -> Value.RAB - RAC -> Value.RAC - RAD -> Value.RAD - RAF -> Value.RAF - RE -> Value.RE - RF -> Value.RF - RH -> Value.RH - RV -> Value.RV - SA -> Value.SA - SAA -> Value.SAA - SAD -> Value.SAD - SAE -> Value.SAE - SAI -> Value.SAI - SG -> Value.SG - SH -> Value.SH - SM -> Value.SM - SU -> Value.SU - TAB -> Value.TAB - TAC -> Value.TAC - TT -> Value.TT - TV -> Value.TV - V1 -> Value.V1 - V2 -> Value.V2 - WH -> Value.WH - XAA -> Value.XAA - YY -> Value.YY - ZZZ -> Value.ZZZ - else -> Value._UNKNOWN - } + fun asNumber(): Double = number.getOrThrow("number") - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws EInvoiceInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AA -> Known.AA - AAA -> Known.AAA - AAC -> Known.AAC - AAD -> Known.AAD - AAE -> Known.AAE - AAF -> Known.AAF - AAH -> Known.AAH - AAI -> Known.AAI - AAS -> Known.AAS - AAT -> Known.AAT - AAV -> Known.AAV - AAY -> Known.AAY - AAZ -> Known.AAZ - ABA -> Known.ABA - ABB -> Known.ABB - ABC -> Known.ABC - ABD -> Known.ABD - ABF -> Known.ABF - ABK -> Known.ABK - ABL -> Known.ABL - ABN -> Known.ABN - ABR -> Known.ABR - ABS -> Known.ABS - ABT -> Known.ABT - ABU -> Known.ABU - ACF -> Known.ACF - ACG -> Known.ACG - ACH -> Known.ACH - ACI -> Known.ACI - ACJ -> Known.ACJ - ACK -> Known.ACK - ACL -> Known.ACL - ACM -> Known.ACM - ACS -> Known.ACS - ADC -> Known.ADC - ADE -> Known.ADE - ADJ -> Known.ADJ - ADK -> Known.ADK - ADL -> Known.ADL - ADM -> Known.ADM - ADN -> Known.ADN - ADO -> Known.ADO - ADP -> Known.ADP - ADQ -> Known.ADQ - ADR -> Known.ADR - ADT -> Known.ADT - ADW -> Known.ADW - ADY -> Known.ADY - ADZ -> Known.ADZ - AEA -> Known.AEA - AEB -> Known.AEB - AEC -> Known.AEC - AED -> Known.AED - AEF -> Known.AEF - AEH -> Known.AEH - AEI -> Known.AEI - AEJ -> Known.AEJ - AEK -> Known.AEK - AEL -> Known.AEL - AEM -> Known.AEM - AEN -> Known.AEN - AEO -> Known.AEO - AEP -> Known.AEP - AES -> Known.AES - AET -> Known.AET - AEU -> Known.AEU - AEV -> Known.AEV - AEW -> Known.AEW - AEX -> Known.AEX - AEY -> Known.AEY - AEZ -> Known.AEZ - AJ -> Known.AJ - AU -> Known.AU - CA -> Known.CA - CAB -> Known.CAB - CAD -> Known.CAD - CAE -> Known.CAE - CAF -> Known.CAF - CAI -> Known.CAI - CAJ -> Known.CAJ - CAK -> Known.CAK - CAL -> Known.CAL - CAM -> Known.CAM - CAN -> Known.CAN - CAO -> Known.CAO - CAP -> Known.CAP - CAQ -> Known.CAQ - CAR -> Known.CAR - CAS -> Known.CAS - CAT -> Known.CAT - CAU -> Known.CAU - CAV -> Known.CAV - CAW -> Known.CAW - CAX -> Known.CAX - CAY -> Known.CAY - CAZ -> Known.CAZ - CD -> Known.CD - CG -> Known.CG - CS -> Known.CS - CT -> Known.CT - DAB -> Known.DAB - DAC -> Known.DAC - DAD -> Known.DAD - DAF -> Known.DAF - DAG -> Known.DAG - DAH -> Known.DAH - DAI -> Known.DAI - DAJ -> Known.DAJ - DAK -> Known.DAK - DAL -> Known.DAL - DAM -> Known.DAM - DAN -> Known.DAN - DAO -> Known.DAO - DAP -> Known.DAP - DAQ -> Known.DAQ - DL -> Known.DL - EG -> Known.EG - EP -> Known.EP - ER -> Known.ER - FAA -> Known.FAA - FAB -> Known.FAB - FAC -> Known.FAC - FC -> Known.FC - FH -> Known.FH - FI -> Known.FI - GAA -> Known.GAA - HAA -> Known.HAA - HD -> Known.HD - HH -> Known.HH - IAA -> Known.IAA - IAB -> Known.IAB - ID -> Known.ID - IF -> Known.IF - IR -> Known.IR - IS -> Known.IS - KO -> Known.KO - L1 -> Known.L1 - LA -> Known.LA - LAA -> Known.LAA - LAB -> Known.LAB - LF -> Known.LF - MAE -> Known.MAE - MI -> Known.MI - ML -> Known.ML - NAA -> Known.NAA - OA -> Known.OA - PA -> Known.PA - PAA -> Known.PAA - PC -> Known.PC - PL -> Known.PL - PRV -> Known.PRV - RAB -> Known.RAB - RAC -> Known.RAC - RAD -> Known.RAD - RAF -> Known.RAF - RE -> Known.RE - RF -> Known.RF - RH -> Known.RH - RV -> Known.RV - SA -> Known.SA - SAA -> Known.SAA - SAD -> Known.SAD - SAE -> Known.SAE - SAI -> Known.SAI - SG -> Known.SG - SH -> Known.SH - SM -> Known.SM - SU -> Known.SU - TAB -> Known.TAB - TAC -> Known.TAC - TT -> Known.TT - TV -> Known.TV - V1 -> Known.V1 - V2 -> Known.V2 - WH -> Known.WH - XAA -> Known.XAA - YY -> Known.YY - ZZZ -> Known.ZZZ - else -> throw EInvoiceInvalidDataException("Unknown ReasonCode: $value") - } + fun asString(): String = string.getOrThrow("string") - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws EInvoiceInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - EInvoiceInvalidDataException("Value is not a String") + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) } private var validated: Boolean = false - fun validate(): ReasonCode = apply { + fun validate(): BaseAmount = apply { if (validated) { return@apply } - known() + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) validated = true } @@ -11399,209 +7662,123 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is ReasonCode && value == other.value + return other is BaseAmount && number == other.number && string == other.string } - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * Duty or tax or fee category codes (Subset of UNCL5305) - * - * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL - */ - class TaxCode @JsonCreator private constructor(private val value: JsonField) : - Enum { + override fun hashCode(): Int = Objects.hash(number, string) - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + override fun toString(): String = + when { + number != null -> "BaseAmount{number=$number}" + string != null -> "BaseAmount{string=$string}" + _json != null -> "BaseAmount{_unknown=$_json}" + else -> throw IllegalStateException("Invalid BaseAmount") + } companion object { - @JvmField val AE = of("AE") - - @JvmField val E = of("E") - - @JvmField val S = of("S") - - @JvmField val Z = of("Z") - - @JvmField val G = of("G") - - @JvmField val O = of("O") - - @JvmField val K = of("K") - - @JvmField val L = of("L") - - @JvmField val M = of("M") - - @JvmField val B = of("B") - - @JvmStatic fun of(value: String) = TaxCode(JsonField.of(value)) - } + @JvmStatic fun ofNumber(number: Double) = BaseAmount(number = number) - /** An enum containing [TaxCode]'s known values. */ - enum class Known { - AE, - E, - S, - Z, - G, - O, - K, - L, - M, - B, + @JvmStatic fun ofString(string: String) = BaseAmount(string = string) } /** - * An enum containing [TaxCode]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [TaxCode] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. + * An interface that defines how to map each variant of [BaseAmount] to a value of + * type [T]. */ - enum class Value { - AE, - E, - S, - Z, - G, - O, - K, - L, - M, - B, - /** - * An enum member indicating that [TaxCode] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } + interface Visitor { - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AE -> Value.AE - E -> Value.E - S -> Value.S - Z -> Value.Z - G -> Value.G - O -> Value.O - K -> Value.K - L -> Value.L - M -> Value.M - B -> Value.B - else -> Value._UNKNOWN - } + fun visitNumber(number: Double): T - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws EInvoiceInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - AE -> Known.AE - E -> Known.E - S -> Known.S - Z -> Known.Z - G -> Known.G - O -> Known.O - K -> Known.K - L -> Known.L - M -> Known.M - B -> Known.B - else -> throw EInvoiceInvalidDataException("Unknown TaxCode: $value") - } + fun visitString(string: String): T - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws EInvoiceInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - EInvoiceInvalidDataException("Value is not a String") + /** + * Maps an unknown variant of [BaseAmount] to a value of type [T]. + * + * An instance of [BaseAmount] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws EInvoiceInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw EInvoiceInvalidDataException("Unknown BaseAmount: $json") } + } - private var validated: Boolean = false - - fun validate(): TaxCode = apply { - if (validated) { - return@apply - } + internal class Deserializer : BaseDeserializer(BaseAmount::class) { - known() - validated = true - } + override fun ObjectCodec.deserialize(node: JsonNode): BaseAmount { + val json = JsonValue.fromJsonNode(node) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + BaseAmount(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + BaseAmount(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // object). + 0 -> BaseAmount(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } } + } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + internal class Serializer : BaseSerializer(BaseAmount::class) { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + override fun serialize( + value: BaseAmount, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid BaseAmount") + } } - - return other is TaxCode && value == other.value } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() } - /** The VAT rate, represented as percentage that applies to the charge */ - @JsonDeserialize(using = TaxRate.Deserializer::class) - @JsonSerialize(using = TaxRate.Serializer::class) - class TaxRate + /** + * The percentage that may be used, in conjunction with the charge base amount, to + * calculate the charge amount. To state 20%, use value 20 + */ + @JsonDeserialize(using = MultiplierFactor.Deserializer::class) + @JsonSerialize(using = MultiplierFactor.Serializer::class) + class MultiplierFactor private constructor( private val number: Double? = null, private val string: String? = null, @@ -11631,7 +7808,7 @@ private constructor( private var validated: Boolean = false - fun validate(): TaxRate = apply { + fun validate(): MultiplierFactor = apply { if (validated) { return@apply } @@ -11677,29 +7854,31 @@ private constructor( return true } - return other is TaxRate && number == other.number && string == other.string + return other is MultiplierFactor && + number == other.number && + string == other.string } override fun hashCode(): Int = Objects.hash(number, string) override fun toString(): String = when { - number != null -> "TaxRate{number=$number}" - string != null -> "TaxRate{string=$string}" - _json != null -> "TaxRate{_unknown=$_json}" - else -> throw IllegalStateException("Invalid TaxRate") + number != null -> "MultiplierFactor{number=$number}" + string != null -> "MultiplierFactor{string=$string}" + _json != null -> "MultiplierFactor{_unknown=$_json}" + else -> throw IllegalStateException("Invalid MultiplierFactor") } companion object { - @JvmStatic fun ofNumber(number: Double) = TaxRate(number = number) + @JvmStatic fun ofNumber(number: Double) = MultiplierFactor(number = number) - @JvmStatic fun ofString(string: String) = TaxRate(string = string) + @JvmStatic fun ofString(string: String) = MultiplierFactor(string = string) } /** - * An interface that defines how to map each variant of [TaxRate] to a value of type - * [T]. + * An interface that defines how to map each variant of [MultiplierFactor] to a + * value of type [T]. */ interface Visitor { @@ -11708,9 +7887,9 @@ private constructor( fun visitString(string: String): T /** - * Maps an unknown variant of [TaxRate] to a value of type [T]. + * Maps an unknown variant of [MultiplierFactor] to a value of type [T]. * - * An instance of [TaxRate] can contain an unknown variant if it was + * An instance of [MultiplierFactor] can contain an unknown variant if it was * deserialized from data that doesn't match any known variant. For example, if * the SDK is on an older version than the API, then the API may respond with * new variants that the SDK is unaware of. @@ -11718,22 +7897,23 @@ private constructor( * @throws EInvoiceInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw EInvoiceInvalidDataException("Unknown TaxRate: $json") + throw EInvoiceInvalidDataException("Unknown MultiplierFactor: $json") } } - internal class Deserializer : BaseDeserializer(TaxRate::class) { + internal class Deserializer : + BaseDeserializer(MultiplierFactor::class) { - override fun ObjectCodec.deserialize(node: JsonNode): TaxRate { + override fun ObjectCodec.deserialize(node: JsonNode): MultiplierFactor { val json = JsonValue.fromJsonNode(node) val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef())?.let { - TaxRate(number = it, _json = json) + MultiplierFactor(number = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - TaxRate(string = it, _json = json) + MultiplierFactor(string = it, _json = json) }, ) .filterNotNull() @@ -11743,7 +7923,7 @@ private constructor( // This can happen if what we're deserializing is completely // incompatible with all the possible variants (e.g. deserializing from // object). - 0 -> TaxRate(_json = json) + 0 -> MultiplierFactor(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use // the first completely valid match, or simply the first match if none @@ -11753,10 +7933,11 @@ private constructor( } } - internal class Serializer : BaseSerializer(TaxRate::class) { + internal class Serializer : + BaseSerializer(MultiplierFactor::class) { override fun serialize( - value: TaxRate, + value: MultiplierFactor, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -11764,223 +7945,229 @@ private constructor( value.number != null -> generator.writeObject(value.number) value.string != null -> generator.writeObject(value.string) value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid TaxRate") + else -> throw IllegalStateException("Invalid MultiplierFactor") } } } } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + */ + class TaxCode @JsonCreator private constructor(private val value: JsonField) : + Enum { - return other is Charge && - amount == other.amount && - baseAmount == other.baseAmount && - multiplierFactor == other.multiplierFactor && - reason == other.reason && - reasonCode == other.reasonCode && - taxCode == other.taxCode && - taxRate == other.taxRate && - additionalProperties == other.additionalProperties - } + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - private val hashCode: Int by lazy { - Objects.hash( - amount, - baseAmount, - multiplierFactor, - reason, - reasonCode, - taxCode, - taxRate, - additionalProperties, - ) - } + companion object { - override fun hashCode(): Int = hashCode + @JvmField val AE = of("AE") - override fun toString() = - "Charge{amount=$amount, baseAmount=$baseAmount, multiplierFactor=$multiplierFactor, reason=$reason, reasonCode=$reasonCode, taxCode=$taxCode, taxRate=$taxRate, additionalProperties=$additionalProperties}" - } + @JvmField val E = of("E") - /** - * The item price base quantity (BT-149). The number of item units to which the price - * applies. Defaults to 1. Must be rounded to maximum 4 decimals - */ - @JsonDeserialize(using = PriceBaseQuantity.Deserializer::class) - @JsonSerialize(using = PriceBaseQuantity.Serializer::class) - class PriceBaseQuantity - private constructor( - private val number: Double? = null, - private val string: String? = null, - private val _json: JsonValue? = null, - ) { + @JvmField val S = of("S") - fun number(): Optional = Optional.ofNullable(number) + @JvmField val Z = of("Z") - fun string(): Optional = Optional.ofNullable(string) + @JvmField val G = of("G") - fun isNumber(): Boolean = number != null + @JvmField val O = of("O") - fun isString(): Boolean = string != null + @JvmField val K = of("K") - fun asNumber(): Double = number.getOrThrow("number") + @JvmField val L = of("L") - fun asString(): String = string.getOrThrow("string") + @JvmField val M = of("M") - fun _json(): Optional = Optional.ofNullable(_json) + @JvmField val B = of("B") - fun accept(visitor: Visitor): T = - when { - number != null -> visitor.visitNumber(number) - string != null -> visitor.visitString(string) - else -> visitor.unknown(_json) + @JvmStatic fun of(value: String) = TaxCode(JsonField.of(value)) } - private var validated: Boolean = false - - fun validate(): PriceBaseQuantity = apply { - if (validated) { - return@apply + /** An enum containing [TaxCode]'s known values. */ + enum class Known { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, } - accept( - object : Visitor { - override fun visitNumber(number: Double) {} - - override fun visitString(string: String) {} - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false + /** + * An enum containing [TaxCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TaxCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + /** + * An enum member indicating that [TaxCode] was instantiated with an unknown + * value. + */ + _UNKNOWN, } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitNumber(number: Double) = 1 - - override fun visitString(string: String) = 1 - - override fun unknown(json: JsonValue?) = 0 + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AE -> Value.AE + E -> Value.E + S -> Value.S + Z -> Value.Z + G -> Value.G + O -> Value.O + K -> Value.K + L -> Value.L + M -> Value.M + B -> Value.B + else -> Value._UNKNOWN } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is PriceBaseQuantity && - number == other.number && - string == other.string - } - - override fun hashCode(): Int = Objects.hash(number, string) - - override fun toString(): String = - when { - number != null -> "PriceBaseQuantity{number=$number}" - string != null -> "PriceBaseQuantity{string=$string}" - _json != null -> "PriceBaseQuantity{_unknown=$_json}" - else -> throw IllegalStateException("Invalid PriceBaseQuantity") - } - companion object { + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + AE -> Known.AE + E -> Known.E + S -> Known.S + Z -> Known.Z + G -> Known.G + O -> Known.O + K -> Known.K + L -> Known.L + M -> Known.M + B -> Known.B + else -> throw EInvoiceInvalidDataException("Unknown TaxCode: $value") + } - @JvmStatic fun ofNumber(number: Double) = PriceBaseQuantity(number = number) + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } - @JvmStatic fun ofString(string: String) = PriceBaseQuantity(string = string) - } + private var validated: Boolean = false - /** - * An interface that defines how to map each variant of [PriceBaseQuantity] to a value - * of type [T]. - */ - interface Visitor { + fun validate(): TaxCode = apply { + if (validated) { + return@apply + } - fun visitNumber(number: Double): T + known() + validated = true + } - fun visitString(string: String): T + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } /** - * Maps an unknown variant of [PriceBaseQuantity] to a value of type [T]. - * - * An instance of [PriceBaseQuantity] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the - * SDK is on an older version than the API, then the API may respond with new - * variants that the SDK is unaware of. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * @throws EInvoiceInvalidDataException in the default implementation. + * Used for best match union deserialization. */ - fun unknown(json: JsonValue?): T { - throw EInvoiceInvalidDataException("Unknown PriceBaseQuantity: $json") + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TaxCode && value == other.value } - } - internal class Deserializer : - BaseDeserializer(PriceBaseQuantity::class) { + override fun hashCode() = value.hashCode() - override fun ObjectCodec.deserialize(node: JsonNode): PriceBaseQuantity { - val json = JsonValue.fromJsonNode(node) + override fun toString() = value.toString() + } - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - PriceBaseQuantity(number = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - PriceBaseQuantity(string = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from object). - 0 -> PriceBaseQuantity(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the - // first completely valid match, or simply the first match if none are - // completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - } - internal class Serializer : - BaseSerializer(PriceBaseQuantity::class) { + return other is Charge && + amount == other.amount && + baseAmount == other.baseAmount && + multiplierFactor == other.multiplierFactor && + reason == other.reason && + reasonCode == other.reasonCode && + taxCode == other.taxCode && + taxRate == other.taxRate && + additionalProperties == other.additionalProperties + } - override fun serialize( - value: PriceBaseQuantity, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.number != null -> generator.writeObject(value.number) - value.string != null -> generator.writeObject(value.string) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid PriceBaseQuantity") - } - } + private val hashCode: Int by lazy { + Objects.hash( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + additionalProperties, + ) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Charge{amount=$amount, baseAmount=$baseAmount, multiplierFactor=$multiplierFactor, reason=$reason, reasonCode=$reasonCode, taxCode=$taxCode, taxRate=$taxRate, additionalProperties=$additionalProperties}" } /** @@ -12327,181 +8514,7 @@ private constructor( } } - /** The VAT rate of the line item expressed as percentage with 2 decimals */ - @JsonDeserialize(using = TaxRate.Deserializer::class) - @JsonSerialize(using = TaxRate.Serializer::class) - class TaxRate - private constructor( - private val number: Double? = null, - private val string: String? = null, - private val _json: JsonValue? = null, - ) { - - fun number(): Optional = Optional.ofNullable(number) - - fun string(): Optional = Optional.ofNullable(string) - - fun isNumber(): Boolean = number != null - - fun isString(): Boolean = string != null - - fun asNumber(): Double = number.getOrThrow("number") - - fun asString(): String = string.getOrThrow("string") - - fun _json(): Optional = Optional.ofNullable(_json) - - fun accept(visitor: Visitor): T = - when { - number != null -> visitor.visitNumber(number) - string != null -> visitor.visitString(string) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - fun validate(): TaxRate = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitNumber(number: Double) {} - - override fun visitString(string: String) {} - } - ) - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitNumber(number: Double) = 1 - - override fun visitString(string: String) = 1 - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is TaxRate && number == other.number && string == other.string - } - - override fun hashCode(): Int = Objects.hash(number, string) - - override fun toString(): String = - when { - number != null -> "TaxRate{number=$number}" - string != null -> "TaxRate{string=$string}" - _json != null -> "TaxRate{_unknown=$_json}" - else -> throw IllegalStateException("Invalid TaxRate") - } - - companion object { - - @JvmStatic fun ofNumber(number: Double) = TaxRate(number = number) - - @JvmStatic fun ofString(string: String) = TaxRate(string = string) - } - - /** - * An interface that defines how to map each variant of [TaxRate] to a value of type - * [T]. - */ - interface Visitor { - - fun visitNumber(number: Double): T - - fun visitString(string: String): T - - /** - * Maps an unknown variant of [TaxRate] to a value of type [T]. - * - * An instance of [TaxRate] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws EInvoiceInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw EInvoiceInvalidDataException("Unknown TaxRate: $json") - } - } - - internal class Deserializer : BaseDeserializer(TaxRate::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): TaxRate { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - TaxRate(number = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - TaxRate(string = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from object). - 0 -> TaxRate(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the - // first completely valid match, or simply the first match if none are - // completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(TaxRate::class) { - - override fun serialize( - value: TaxRate, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.number != null -> generator.writeObject(value.number) - value.string != null -> generator.writeObject(value.string) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid TaxRate") - } - } - } - } - - /** - * The item net price (BT-146). The price of an item, exclusive of VAT, after subtracting - * item price discount. Must be rounded to maximum 4 decimals - */ + /** The unit price of the line item. Must be rounded to maximum 2 decimals */ @JsonDeserialize(using = UnitPrice.Deserializer::class) @JsonSerialize(using = UnitPrice.Serializer::class) class UnitPrice @@ -12683,7 +8696,6 @@ private constructor( charges == other.charges && date == other.date && description == other.description && - priceBaseQuantity == other.priceBaseQuantity && productCode == other.productCode && quantity == other.quantity && tax == other.tax && @@ -12700,7 +8712,6 @@ private constructor( charges, date, description, - priceBaseQuantity, productCode, quantity, tax, @@ -12714,7 +8725,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Item{allowances=$allowances, amount=$amount, charges=$charges, date=$date, description=$description, priceBaseQuantity=$priceBaseQuantity, productCode=$productCode, quantity=$quantity, tax=$tax, taxRate=$taxRate, unit=$unit, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" + "Item{allowances=$allowances, amount=$amount, charges=$charges, date=$date, description=$description, productCode=$productCode, quantity=$quantity, tax=$tax, taxRate=$taxRate, unit=$unit, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" } /** diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponse.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponse.kt index e87c484..f517073 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponse.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponse.kt @@ -2389,7 +2389,6 @@ private constructor( private val charges: JsonField>, private val date: JsonField, private val description: JsonField, - private val priceBaseQuantity: JsonField, private val productCode: JsonField, private val quantity: JsonField, private val tax: JsonField, @@ -2412,9 +2411,6 @@ private constructor( @JsonProperty("description") @ExcludeMissing description: JsonField = JsonMissing.of(), - @JsonProperty("price_base_quantity") - @ExcludeMissing - priceBaseQuantity: JsonField = JsonMissing.of(), @JsonProperty("product_code") @ExcludeMissing productCode: JsonField = JsonMissing.of(), @@ -2435,7 +2431,6 @@ private constructor( charges, date, description, - priceBaseQuantity, productCode, quantity, tax, @@ -2454,9 +2449,8 @@ private constructor( fun allowances(): Optional> = allowances.getOptional("allowances") /** - * The invoice line net amount (BT-131), exclusive of VAT, inclusive of line level - * allowances and charges. Calculated as: ((unit_price / price_base_quantity) * quantity) - - * allowances + charges. Must be rounded to maximum 2 decimals + * The total amount of the line item, exclusive of VAT, after subtracting line level + * allowances and adding line level charges. Must be rounded to maximum 2 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -2485,16 +2479,6 @@ private constructor( */ fun description(): Optional = description.getOptional("description") - /** - * The item price base quantity (BT-149). The number of item units to which the price - * applies. Defaults to 1. Must be rounded to maximum 4 decimals - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun priceBaseQuantity(): Optional = - priceBaseQuantity.getOptional("price_base_quantity") - /** * The product code of the line item. * @@ -2537,8 +2521,7 @@ private constructor( fun unit(): Optional = unit.getOptional("unit") /** - * The item net price (BT-146). The price of an item, exclusive of VAT, after subtracting - * item price discount. Must be rounded to maximum 4 decimals + * The unit price of the line item. Must be rounded to maximum 2 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -2584,16 +2567,6 @@ private constructor( @ExcludeMissing fun _description(): JsonField = description - /** - * Returns the raw JSON value of [priceBaseQuantity]. - * - * Unlike [priceBaseQuantity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("price_base_quantity") - @ExcludeMissing - fun _priceBaseQuantity(): JsonField = priceBaseQuantity - /** * Returns the raw JSON value of [productCode]. * @@ -2664,7 +2637,6 @@ private constructor( private var charges: JsonField>? = null private var date: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() - private var priceBaseQuantity: JsonField = JsonMissing.of() private var productCode: JsonField = JsonMissing.of() private var quantity: JsonField = JsonMissing.of() private var tax: JsonField = JsonMissing.of() @@ -2680,7 +2652,6 @@ private constructor( charges = item.charges.map { it.toMutableList() } date = item.date description = item.description - priceBaseQuantity = item.priceBaseQuantity productCode = item.productCode quantity = item.quantity tax = item.tax @@ -2722,9 +2693,8 @@ private constructor( } /** - * The invoice line net amount (BT-131), exclusive of VAT, inclusive of line level - * allowances and charges. Calculated as: ((unit_price / price_base_quantity) * - * quantity) - allowances + charges. Must be rounded to maximum 2 decimals + * The total amount of the line item, exclusive of VAT, after subtracting line level + * allowances and adding line level charges. Must be rounded to maximum 2 decimals */ fun amount(amount: String?) = amount(JsonField.ofNullable(amount)) @@ -2800,30 +2770,6 @@ private constructor( this.description = description } - /** - * The item price base quantity (BT-149). The number of item units to which the price - * applies. Defaults to 1. Must be rounded to maximum 4 decimals - */ - fun priceBaseQuantity(priceBaseQuantity: String?) = - priceBaseQuantity(JsonField.ofNullable(priceBaseQuantity)) - - /** - * Alias for calling [Builder.priceBaseQuantity] with `priceBaseQuantity.orElse(null)`. - */ - fun priceBaseQuantity(priceBaseQuantity: Optional) = - priceBaseQuantity(priceBaseQuantity.getOrNull()) - - /** - * Sets [Builder.priceBaseQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.priceBaseQuantity] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceBaseQuantity(priceBaseQuantity: JsonField) = apply { - this.priceBaseQuantity = priceBaseQuantity - } - /** The product code of the line item. */ fun productCode(productCode: String?) = productCode(JsonField.ofNullable(productCode)) @@ -2904,10 +2850,7 @@ private constructor( */ fun unit(unit: JsonField) = apply { this.unit = unit } - /** - * The item net price (BT-146). The price of an item, exclusive of VAT, after - * subtracting item price discount. Must be rounded to maximum 4 decimals - */ + /** The unit price of the line item. Must be rounded to maximum 2 decimals */ fun unitPrice(unitPrice: String?) = unitPrice(JsonField.ofNullable(unitPrice)) /** Alias for calling [Builder.unitPrice] with `unitPrice.orElse(null)`. */ @@ -2953,7 +2896,6 @@ private constructor( (charges ?: JsonMissing.of()).map { it.toImmutable() }, date, description, - priceBaseQuantity, productCode, quantity, tax, @@ -2976,7 +2918,6 @@ private constructor( charges().ifPresent { it.forEach { it.validate() } } date() description() - priceBaseQuantity() productCode() quantity() tax() @@ -3007,7 +2948,6 @@ private constructor( (charges.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (date.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + - (if (priceBaseQuantity.asKnown().isPresent) 1 else 0) + (if (productCode.asKnown().isPresent) 1 else 0) + (if (quantity.asKnown().isPresent) 1 else 0) + (if (tax.asKnown().isPresent) 1 else 0) + @@ -3026,7 +2966,6 @@ private constructor( charges == other.charges && date == other.date && description == other.description && - priceBaseQuantity == other.priceBaseQuantity && productCode == other.productCode && quantity == other.quantity && tax == other.tax && @@ -3043,7 +2982,6 @@ private constructor( charges, date, description, - priceBaseQuantity, productCode, quantity, tax, @@ -3057,7 +2995,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Item{allowances=$allowances, amount=$amount, charges=$charges, date=$date, description=$description, priceBaseQuantity=$priceBaseQuantity, productCode=$productCode, quantity=$quantity, tax=$tax, taxRate=$taxRate, unit=$unit, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" + "Item{allowances=$allowances, amount=$amount, charges=$charges, date=$date, description=$description, productCode=$productCode, quantity=$quantity, tax=$tax, taxRate=$taxRate, unit=$unit, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" } /** diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt index cc5df98..066f3b6 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt @@ -2355,7 +2355,7 @@ private constructor( private val baseAmount: JsonField, private val multiplierFactor: JsonField, private val reason: JsonField, - private val reasonCode: JsonField, + private val reasonCode: JsonField, private val taxCode: JsonField, private val taxRate: JsonField, private val additionalProperties: MutableMap, @@ -2373,7 +2373,7 @@ private constructor( @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), @JsonProperty("reason_code") @ExcludeMissing - reasonCode: JsonField = JsonMissing.of(), + reasonCode: JsonField = JsonMissing.of(), @JsonProperty("tax_code") @ExcludeMissing taxCode: JsonField = JsonMissing.of(), @@ -2408,8 +2408,7 @@ private constructor( /** * The percentage that may be used, in conjunction with the allowance base amount, to - * calculate the allowance amount. To state 20%, use value 20. Must be rounded to maximum 2 - * decimals + * calculate the allowance amount. To state 20%, use value 20 * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -2425,15 +2424,17 @@ private constructor( fun reason(): Optional = reason.getOptional("reason") /** - * Allowance reason codes for invoice discounts and charges + * The code for the allowance reason * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun reasonCode(): Optional = reasonCode.getOptional("reason_code") + fun reasonCode(): Optional = reasonCode.getOptional("reason_code") /** - * The VAT category code that applies to the allowance + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -2441,8 +2442,7 @@ private constructor( fun taxCode(): Optional = taxCode.getOptional("tax_code") /** - * The VAT rate, represented as percentage that applies to the allowance. Must be rounded to - * maximum 2 decimals + * The VAT rate, represented as percentage that applies to the allowance * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -2489,7 +2489,7 @@ private constructor( */ @JsonProperty("reason_code") @ExcludeMissing - fun _reasonCode(): JsonField = reasonCode + fun _reasonCode(): JsonField = reasonCode /** * Returns the raw JSON value of [taxCode]. @@ -2530,7 +2530,7 @@ private constructor( private var baseAmount: JsonField = JsonMissing.of() private var multiplierFactor: JsonField = JsonMissing.of() private var reason: JsonField = JsonMissing.of() - private var reasonCode: JsonField = JsonMissing.of() + private var reasonCode: JsonField = JsonMissing.of() private var taxCode: JsonField = JsonMissing.of() private var taxRate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -2582,8 +2582,7 @@ private constructor( /** * The percentage that may be used, in conjunction with the allowance base amount, to - * calculate the allowance amount. To state 20%, use value 20. Must be rounded to - * maximum 2 decimals + * calculate the allowance amount. To state 20%, use value 20 */ fun multiplierFactor(multiplierFactor: String?) = multiplierFactor(JsonField.ofNullable(multiplierFactor)) @@ -2620,25 +2619,30 @@ private constructor( */ fun reason(reason: JsonField) = apply { this.reason = reason } - /** Allowance reason codes for invoice discounts and charges */ - fun reasonCode(reasonCode: ReasonCode?) = reasonCode(JsonField.ofNullable(reasonCode)) + /** The code for the allowance reason */ + fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ - fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) + fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) /** * Sets [Builder.reasonCode] to an arbitrary JSON value. * - * You should usually call [Builder.reasonCode] with a well-typed [ReasonCode] value + * You should usually call [Builder.reasonCode] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun reasonCode(reasonCode: JsonField) = apply { - this.reasonCode = reasonCode - } + fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode } - /** The VAT category code that applies to the allowance */ - fun taxCode(taxCode: TaxCode) = taxCode(JsonField.of(taxCode)) + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + */ + fun taxCode(taxCode: TaxCode?) = taxCode(JsonField.ofNullable(taxCode)) + + /** Alias for calling [Builder.taxCode] with `taxCode.orElse(null)`. */ + fun taxCode(taxCode: Optional) = taxCode(taxCode.getOrNull()) /** * Sets [Builder.taxCode] to an arbitrary JSON value. @@ -2649,10 +2653,7 @@ private constructor( */ fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } - /** - * The VAT rate, represented as percentage that applies to the allowance. Must be - * rounded to maximum 2 decimals - */ + /** The VAT rate, represented as percentage that applies to the allowance */ fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ @@ -2715,7 +2716,7 @@ private constructor( baseAmount() multiplierFactor() reason() - reasonCode().ifPresent { it.validate() } + reasonCode() taxCode().ifPresent { it.validate() } taxRate() validated = true @@ -2741,245 +2742,15 @@ private constructor( (if (baseAmount.asKnown().isPresent) 1 else 0) + (if (multiplierFactor.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) + - (reasonCode.asKnown().getOrNull()?.validity() ?: 0) + + (if (reasonCode.asKnown().isPresent) 1 else 0) + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + (if (taxRate.asKnown().isPresent) 1 else 0) - /** Allowance reason codes for invoice discounts and charges */ - class ReasonCode @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val _41 = of("41") - - @JvmField val _42 = of("42") - - @JvmField val _60 = of("60") - - @JvmField val _62 = of("62") - - @JvmField val _63 = of("63") - - @JvmField val _64 = of("64") - - @JvmField val _65 = of("65") - - @JvmField val _66 = of("66") - - @JvmField val _67 = of("67") - - @JvmField val _68 = of("68") - - @JvmField val _70 = of("70") - - @JvmField val _71 = of("71") - - @JvmField val _88 = of("88") - - @JvmField val _95 = of("95") - - @JvmField val _100 = of("100") - - @JvmField val _102 = of("102") - - @JvmField val _103 = of("103") - - @JvmField val _104 = of("104") - - @JvmField val _105 = of("105") - - @JvmStatic fun of(value: String) = ReasonCode(JsonField.of(value)) - } - - /** An enum containing [ReasonCode]'s known values. */ - enum class Known { - _41, - _42, - _60, - _62, - _63, - _64, - _65, - _66, - _67, - _68, - _70, - _71, - _88, - _95, - _100, - _102, - _103, - _104, - _105, - } - - /** - * An enum containing [ReasonCode]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ReasonCode] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - _41, - _42, - _60, - _62, - _63, - _64, - _65, - _66, - _67, - _68, - _70, - _71, - _88, - _95, - _100, - _102, - _103, - _104, - _105, - /** - * An enum member indicating that [ReasonCode] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - _41 -> Value._41 - _42 -> Value._42 - _60 -> Value._60 - _62 -> Value._62 - _63 -> Value._63 - _64 -> Value._64 - _65 -> Value._65 - _66 -> Value._66 - _67 -> Value._67 - _68 -> Value._68 - _70 -> Value._70 - _71 -> Value._71 - _88 -> Value._88 - _95 -> Value._95 - _100 -> Value._100 - _102 -> Value._102 - _103 -> Value._103 - _104 -> Value._104 - _105 -> Value._105 - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws EInvoiceInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - _41 -> Known._41 - _42 -> Known._42 - _60 -> Known._60 - _62 -> Known._62 - _63 -> Known._63 - _64 -> Known._64 - _65 -> Known._65 - _66 -> Known._66 - _67 -> Known._67 - _68 -> Known._68 - _70 -> Known._70 - _71 -> Known._71 - _88 -> Known._88 - _95 -> Known._95 - _100 -> Known._100 - _102 -> Known._102 - _103 -> Known._103 - _104 -> Known._104 - _105 -> Known._105 - else -> throw EInvoiceInvalidDataException("Unknown ReasonCode: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws EInvoiceInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - EInvoiceInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): ReasonCode = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ReasonCode && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** The VAT category code that applies to the allowance */ + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + */ class TaxCode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3200,7 +2971,7 @@ private constructor( private val baseAmount: JsonField, private val multiplierFactor: JsonField, private val reason: JsonField, - private val reasonCode: JsonField, + private val reasonCode: JsonField, private val taxCode: JsonField, private val taxRate: JsonField, private val additionalProperties: MutableMap, @@ -3218,7 +2989,7 @@ private constructor( @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), @JsonProperty("reason_code") @ExcludeMissing - reasonCode: JsonField = JsonMissing.of(), + reasonCode: JsonField = JsonMissing.of(), @JsonProperty("tax_code") @ExcludeMissing taxCode: JsonField = JsonMissing.of(), @@ -3269,12 +3040,12 @@ private constructor( fun reason(): Optional = reason.getOptional("reason") /** - * Charge reason codes for invoice charges and fees + * The code for the charge reason * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun reasonCode(): Optional = reasonCode.getOptional("reason_code") + fun reasonCode(): Optional = reasonCode.getOptional("reason_code") /** * Duty or tax or fee category codes (Subset of UNCL5305) @@ -3334,7 +3105,7 @@ private constructor( */ @JsonProperty("reason_code") @ExcludeMissing - fun _reasonCode(): JsonField = reasonCode + fun _reasonCode(): JsonField = reasonCode /** * Returns the raw JSON value of [taxCode]. @@ -3375,7 +3146,7 @@ private constructor( private var baseAmount: JsonField = JsonMissing.of() private var multiplierFactor: JsonField = JsonMissing.of() private var reason: JsonField = JsonMissing.of() - private var reasonCode: JsonField = JsonMissing.of() + private var reasonCode: JsonField = JsonMissing.of() private var taxCode: JsonField = JsonMissing.of() private var taxRate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -3464,22 +3235,20 @@ private constructor( */ fun reason(reason: JsonField) = apply { this.reason = reason } - /** Charge reason codes for invoice charges and fees */ - fun reasonCode(reasonCode: ReasonCode?) = reasonCode(JsonField.ofNullable(reasonCode)) + /** The code for the charge reason */ + fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ - fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) + fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) /** * Sets [Builder.reasonCode] to an arbitrary JSON value. * - * You should usually call [Builder.reasonCode] with a well-typed [ReasonCode] value + * You should usually call [Builder.reasonCode] with a well-typed [String] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun reasonCode(reasonCode: JsonField) = apply { - this.reasonCode = reasonCode - } + fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode } /** * Duty or tax or fee category codes (Subset of UNCL5305) @@ -3563,7 +3332,7 @@ private constructor( baseAmount() multiplierFactor() reason() - reasonCode().ifPresent { it.validate() } + reasonCode() taxCode().ifPresent { it.validate() } taxRate() validated = true @@ -3589,1198 +3358,10 @@ private constructor( (if (baseAmount.asKnown().isPresent) 1 else 0) + (if (multiplierFactor.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) + - (reasonCode.asKnown().getOrNull()?.validity() ?: 0) + + (if (reasonCode.asKnown().isPresent) 1 else 0) + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + (if (taxRate.asKnown().isPresent) 1 else 0) - /** Charge reason codes for invoice charges and fees */ - class ReasonCode @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val AA = of("AA") - - @JvmField val AAA = of("AAA") - - @JvmField val AAC = of("AAC") - - @JvmField val AAD = of("AAD") - - @JvmField val AAE = of("AAE") - - @JvmField val AAF = of("AAF") - - @JvmField val AAH = of("AAH") - - @JvmField val AAI = of("AAI") - - @JvmField val AAS = of("AAS") - - @JvmField val AAT = of("AAT") - - @JvmField val AAV = of("AAV") - - @JvmField val AAY = of("AAY") - - @JvmField val AAZ = of("AAZ") - - @JvmField val ABA = of("ABA") - - @JvmField val ABB = of("ABB") - - @JvmField val ABC = of("ABC") - - @JvmField val ABD = of("ABD") - - @JvmField val ABF = of("ABF") - - @JvmField val ABK = of("ABK") - - @JvmField val ABL = of("ABL") - - @JvmField val ABN = of("ABN") - - @JvmField val ABR = of("ABR") - - @JvmField val ABS = of("ABS") - - @JvmField val ABT = of("ABT") - - @JvmField val ABU = of("ABU") - - @JvmField val ACF = of("ACF") - - @JvmField val ACG = of("ACG") - - @JvmField val ACH = of("ACH") - - @JvmField val ACI = of("ACI") - - @JvmField val ACJ = of("ACJ") - - @JvmField val ACK = of("ACK") - - @JvmField val ACL = of("ACL") - - @JvmField val ACM = of("ACM") - - @JvmField val ACS = of("ACS") - - @JvmField val ADC = of("ADC") - - @JvmField val ADE = of("ADE") - - @JvmField val ADJ = of("ADJ") - - @JvmField val ADK = of("ADK") - - @JvmField val ADL = of("ADL") - - @JvmField val ADM = of("ADM") - - @JvmField val ADN = of("ADN") - - @JvmField val ADO = of("ADO") - - @JvmField val ADP = of("ADP") - - @JvmField val ADQ = of("ADQ") - - @JvmField val ADR = of("ADR") - - @JvmField val ADT = of("ADT") - - @JvmField val ADW = of("ADW") - - @JvmField val ADY = of("ADY") - - @JvmField val ADZ = of("ADZ") - - @JvmField val AEA = of("AEA") - - @JvmField val AEB = of("AEB") - - @JvmField val AEC = of("AEC") - - @JvmField val AED = of("AED") - - @JvmField val AEF = of("AEF") - - @JvmField val AEH = of("AEH") - - @JvmField val AEI = of("AEI") - - @JvmField val AEJ = of("AEJ") - - @JvmField val AEK = of("AEK") - - @JvmField val AEL = of("AEL") - - @JvmField val AEM = of("AEM") - - @JvmField val AEN = of("AEN") - - @JvmField val AEO = of("AEO") - - @JvmField val AEP = of("AEP") - - @JvmField val AES = of("AES") - - @JvmField val AET = of("AET") - - @JvmField val AEU = of("AEU") - - @JvmField val AEV = of("AEV") - - @JvmField val AEW = of("AEW") - - @JvmField val AEX = of("AEX") - - @JvmField val AEY = of("AEY") - - @JvmField val AEZ = of("AEZ") - - @JvmField val AJ = of("AJ") - - @JvmField val AU = of("AU") - - @JvmField val CA = of("CA") - - @JvmField val CAB = of("CAB") - - @JvmField val CAD = of("CAD") - - @JvmField val CAE = of("CAE") - - @JvmField val CAF = of("CAF") - - @JvmField val CAI = of("CAI") - - @JvmField val CAJ = of("CAJ") - - @JvmField val CAK = of("CAK") - - @JvmField val CAL = of("CAL") - - @JvmField val CAM = of("CAM") - - @JvmField val CAN = of("CAN") - - @JvmField val CAO = of("CAO") - - @JvmField val CAP = of("CAP") - - @JvmField val CAQ = of("CAQ") - - @JvmField val CAR = of("CAR") - - @JvmField val CAS = of("CAS") - - @JvmField val CAT = of("CAT") - - @JvmField val CAU = of("CAU") - - @JvmField val CAV = of("CAV") - - @JvmField val CAW = of("CAW") - - @JvmField val CAX = of("CAX") - - @JvmField val CAY = of("CAY") - - @JvmField val CAZ = of("CAZ") - - @JvmField val CD = of("CD") - - @JvmField val CG = of("CG") - - @JvmField val CS = of("CS") - - @JvmField val CT = of("CT") - - @JvmField val DAB = of("DAB") - - @JvmField val DAC = of("DAC") - - @JvmField val DAD = of("DAD") - - @JvmField val DAF = of("DAF") - - @JvmField val DAG = of("DAG") - - @JvmField val DAH = of("DAH") - - @JvmField val DAI = of("DAI") - - @JvmField val DAJ = of("DAJ") - - @JvmField val DAK = of("DAK") - - @JvmField val DAL = of("DAL") - - @JvmField val DAM = of("DAM") - - @JvmField val DAN = of("DAN") - - @JvmField val DAO = of("DAO") - - @JvmField val DAP = of("DAP") - - @JvmField val DAQ = of("DAQ") - - @JvmField val DL = of("DL") - - @JvmField val EG = of("EG") - - @JvmField val EP = of("EP") - - @JvmField val ER = of("ER") - - @JvmField val FAA = of("FAA") - - @JvmField val FAB = of("FAB") - - @JvmField val FAC = of("FAC") - - @JvmField val FC = of("FC") - - @JvmField val FH = of("FH") - - @JvmField val FI = of("FI") - - @JvmField val GAA = of("GAA") - - @JvmField val HAA = of("HAA") - - @JvmField val HD = of("HD") - - @JvmField val HH = of("HH") - - @JvmField val IAA = of("IAA") - - @JvmField val IAB = of("IAB") - - @JvmField val ID = of("ID") - - @JvmField val IF = of("IF") - - @JvmField val IR = of("IR") - - @JvmField val IS = of("IS") - - @JvmField val KO = of("KO") - - @JvmField val L1 = of("L1") - - @JvmField val LA = of("LA") - - @JvmField val LAA = of("LAA") - - @JvmField val LAB = of("LAB") - - @JvmField val LF = of("LF") - - @JvmField val MAE = of("MAE") - - @JvmField val MI = of("MI") - - @JvmField val ML = of("ML") - - @JvmField val NAA = of("NAA") - - @JvmField val OA = of("OA") - - @JvmField val PA = of("PA") - - @JvmField val PAA = of("PAA") - - @JvmField val PC = of("PC") - - @JvmField val PL = of("PL") - - @JvmField val PRV = of("PRV") - - @JvmField val RAB = of("RAB") - - @JvmField val RAC = of("RAC") - - @JvmField val RAD = of("RAD") - - @JvmField val RAF = of("RAF") - - @JvmField val RE = of("RE") - - @JvmField val RF = of("RF") - - @JvmField val RH = of("RH") - - @JvmField val RV = of("RV") - - @JvmField val SA = of("SA") - - @JvmField val SAA = of("SAA") - - @JvmField val SAD = of("SAD") - - @JvmField val SAE = of("SAE") - - @JvmField val SAI = of("SAI") - - @JvmField val SG = of("SG") - - @JvmField val SH = of("SH") - - @JvmField val SM = of("SM") - - @JvmField val SU = of("SU") - - @JvmField val TAB = of("TAB") - - @JvmField val TAC = of("TAC") - - @JvmField val TT = of("TT") - - @JvmField val TV = of("TV") - - @JvmField val V1 = of("V1") - - @JvmField val V2 = of("V2") - - @JvmField val WH = of("WH") - - @JvmField val XAA = of("XAA") - - @JvmField val YY = of("YY") - - @JvmField val ZZZ = of("ZZZ") - - @JvmStatic fun of(value: String) = ReasonCode(JsonField.of(value)) - } - - /** An enum containing [ReasonCode]'s known values. */ - enum class Known { - AA, - AAA, - AAC, - AAD, - AAE, - AAF, - AAH, - AAI, - AAS, - AAT, - AAV, - AAY, - AAZ, - ABA, - ABB, - ABC, - ABD, - ABF, - ABK, - ABL, - ABN, - ABR, - ABS, - ABT, - ABU, - ACF, - ACG, - ACH, - ACI, - ACJ, - ACK, - ACL, - ACM, - ACS, - ADC, - ADE, - ADJ, - ADK, - ADL, - ADM, - ADN, - ADO, - ADP, - ADQ, - ADR, - ADT, - ADW, - ADY, - ADZ, - AEA, - AEB, - AEC, - AED, - AEF, - AEH, - AEI, - AEJ, - AEK, - AEL, - AEM, - AEN, - AEO, - AEP, - AES, - AET, - AEU, - AEV, - AEW, - AEX, - AEY, - AEZ, - AJ, - AU, - CA, - CAB, - CAD, - CAE, - CAF, - CAI, - CAJ, - CAK, - CAL, - CAM, - CAN, - CAO, - CAP, - CAQ, - CAR, - CAS, - CAT, - CAU, - CAV, - CAW, - CAX, - CAY, - CAZ, - CD, - CG, - CS, - CT, - DAB, - DAC, - DAD, - DAF, - DAG, - DAH, - DAI, - DAJ, - DAK, - DAL, - DAM, - DAN, - DAO, - DAP, - DAQ, - DL, - EG, - EP, - ER, - FAA, - FAB, - FAC, - FC, - FH, - FI, - GAA, - HAA, - HD, - HH, - IAA, - IAB, - ID, - IF, - IR, - IS, - KO, - L1, - LA, - LAA, - LAB, - LF, - MAE, - MI, - ML, - NAA, - OA, - PA, - PAA, - PC, - PL, - PRV, - RAB, - RAC, - RAD, - RAF, - RE, - RF, - RH, - RV, - SA, - SAA, - SAD, - SAE, - SAI, - SG, - SH, - SM, - SU, - TAB, - TAC, - TT, - TV, - V1, - V2, - WH, - XAA, - YY, - ZZZ, - } - - /** - * An enum containing [ReasonCode]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [ReasonCode] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AA, - AAA, - AAC, - AAD, - AAE, - AAF, - AAH, - AAI, - AAS, - AAT, - AAV, - AAY, - AAZ, - ABA, - ABB, - ABC, - ABD, - ABF, - ABK, - ABL, - ABN, - ABR, - ABS, - ABT, - ABU, - ACF, - ACG, - ACH, - ACI, - ACJ, - ACK, - ACL, - ACM, - ACS, - ADC, - ADE, - ADJ, - ADK, - ADL, - ADM, - ADN, - ADO, - ADP, - ADQ, - ADR, - ADT, - ADW, - ADY, - ADZ, - AEA, - AEB, - AEC, - AED, - AEF, - AEH, - AEI, - AEJ, - AEK, - AEL, - AEM, - AEN, - AEO, - AEP, - AES, - AET, - AEU, - AEV, - AEW, - AEX, - AEY, - AEZ, - AJ, - AU, - CA, - CAB, - CAD, - CAE, - CAF, - CAI, - CAJ, - CAK, - CAL, - CAM, - CAN, - CAO, - CAP, - CAQ, - CAR, - CAS, - CAT, - CAU, - CAV, - CAW, - CAX, - CAY, - CAZ, - CD, - CG, - CS, - CT, - DAB, - DAC, - DAD, - DAF, - DAG, - DAH, - DAI, - DAJ, - DAK, - DAL, - DAM, - DAN, - DAO, - DAP, - DAQ, - DL, - EG, - EP, - ER, - FAA, - FAB, - FAC, - FC, - FH, - FI, - GAA, - HAA, - HD, - HH, - IAA, - IAB, - ID, - IF, - IR, - IS, - KO, - L1, - LA, - LAA, - LAB, - LF, - MAE, - MI, - ML, - NAA, - OA, - PA, - PAA, - PC, - PL, - PRV, - RAB, - RAC, - RAD, - RAF, - RE, - RF, - RH, - RV, - SA, - SAA, - SAD, - SAE, - SAI, - SG, - SH, - SM, - SU, - TAB, - TAC, - TT, - TV, - V1, - V2, - WH, - XAA, - YY, - ZZZ, - /** - * An enum member indicating that [ReasonCode] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AA -> Value.AA - AAA -> Value.AAA - AAC -> Value.AAC - AAD -> Value.AAD - AAE -> Value.AAE - AAF -> Value.AAF - AAH -> Value.AAH - AAI -> Value.AAI - AAS -> Value.AAS - AAT -> Value.AAT - AAV -> Value.AAV - AAY -> Value.AAY - AAZ -> Value.AAZ - ABA -> Value.ABA - ABB -> Value.ABB - ABC -> Value.ABC - ABD -> Value.ABD - ABF -> Value.ABF - ABK -> Value.ABK - ABL -> Value.ABL - ABN -> Value.ABN - ABR -> Value.ABR - ABS -> Value.ABS - ABT -> Value.ABT - ABU -> Value.ABU - ACF -> Value.ACF - ACG -> Value.ACG - ACH -> Value.ACH - ACI -> Value.ACI - ACJ -> Value.ACJ - ACK -> Value.ACK - ACL -> Value.ACL - ACM -> Value.ACM - ACS -> Value.ACS - ADC -> Value.ADC - ADE -> Value.ADE - ADJ -> Value.ADJ - ADK -> Value.ADK - ADL -> Value.ADL - ADM -> Value.ADM - ADN -> Value.ADN - ADO -> Value.ADO - ADP -> Value.ADP - ADQ -> Value.ADQ - ADR -> Value.ADR - ADT -> Value.ADT - ADW -> Value.ADW - ADY -> Value.ADY - ADZ -> Value.ADZ - AEA -> Value.AEA - AEB -> Value.AEB - AEC -> Value.AEC - AED -> Value.AED - AEF -> Value.AEF - AEH -> Value.AEH - AEI -> Value.AEI - AEJ -> Value.AEJ - AEK -> Value.AEK - AEL -> Value.AEL - AEM -> Value.AEM - AEN -> Value.AEN - AEO -> Value.AEO - AEP -> Value.AEP - AES -> Value.AES - AET -> Value.AET - AEU -> Value.AEU - AEV -> Value.AEV - AEW -> Value.AEW - AEX -> Value.AEX - AEY -> Value.AEY - AEZ -> Value.AEZ - AJ -> Value.AJ - AU -> Value.AU - CA -> Value.CA - CAB -> Value.CAB - CAD -> Value.CAD - CAE -> Value.CAE - CAF -> Value.CAF - CAI -> Value.CAI - CAJ -> Value.CAJ - CAK -> Value.CAK - CAL -> Value.CAL - CAM -> Value.CAM - CAN -> Value.CAN - CAO -> Value.CAO - CAP -> Value.CAP - CAQ -> Value.CAQ - CAR -> Value.CAR - CAS -> Value.CAS - CAT -> Value.CAT - CAU -> Value.CAU - CAV -> Value.CAV - CAW -> Value.CAW - CAX -> Value.CAX - CAY -> Value.CAY - CAZ -> Value.CAZ - CD -> Value.CD - CG -> Value.CG - CS -> Value.CS - CT -> Value.CT - DAB -> Value.DAB - DAC -> Value.DAC - DAD -> Value.DAD - DAF -> Value.DAF - DAG -> Value.DAG - DAH -> Value.DAH - DAI -> Value.DAI - DAJ -> Value.DAJ - DAK -> Value.DAK - DAL -> Value.DAL - DAM -> Value.DAM - DAN -> Value.DAN - DAO -> Value.DAO - DAP -> Value.DAP - DAQ -> Value.DAQ - DL -> Value.DL - EG -> Value.EG - EP -> Value.EP - ER -> Value.ER - FAA -> Value.FAA - FAB -> Value.FAB - FAC -> Value.FAC - FC -> Value.FC - FH -> Value.FH - FI -> Value.FI - GAA -> Value.GAA - HAA -> Value.HAA - HD -> Value.HD - HH -> Value.HH - IAA -> Value.IAA - IAB -> Value.IAB - ID -> Value.ID - IF -> Value.IF - IR -> Value.IR - IS -> Value.IS - KO -> Value.KO - L1 -> Value.L1 - LA -> Value.LA - LAA -> Value.LAA - LAB -> Value.LAB - LF -> Value.LF - MAE -> Value.MAE - MI -> Value.MI - ML -> Value.ML - NAA -> Value.NAA - OA -> Value.OA - PA -> Value.PA - PAA -> Value.PAA - PC -> Value.PC - PL -> Value.PL - PRV -> Value.PRV - RAB -> Value.RAB - RAC -> Value.RAC - RAD -> Value.RAD - RAF -> Value.RAF - RE -> Value.RE - RF -> Value.RF - RH -> Value.RH - RV -> Value.RV - SA -> Value.SA - SAA -> Value.SAA - SAD -> Value.SAD - SAE -> Value.SAE - SAI -> Value.SAI - SG -> Value.SG - SH -> Value.SH - SM -> Value.SM - SU -> Value.SU - TAB -> Value.TAB - TAC -> Value.TAC - TT -> Value.TT - TV -> Value.TV - V1 -> Value.V1 - V2 -> Value.V2 - WH -> Value.WH - XAA -> Value.XAA - YY -> Value.YY - ZZZ -> Value.ZZZ - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws EInvoiceInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - AA -> Known.AA - AAA -> Known.AAA - AAC -> Known.AAC - AAD -> Known.AAD - AAE -> Known.AAE - AAF -> Known.AAF - AAH -> Known.AAH - AAI -> Known.AAI - AAS -> Known.AAS - AAT -> Known.AAT - AAV -> Known.AAV - AAY -> Known.AAY - AAZ -> Known.AAZ - ABA -> Known.ABA - ABB -> Known.ABB - ABC -> Known.ABC - ABD -> Known.ABD - ABF -> Known.ABF - ABK -> Known.ABK - ABL -> Known.ABL - ABN -> Known.ABN - ABR -> Known.ABR - ABS -> Known.ABS - ABT -> Known.ABT - ABU -> Known.ABU - ACF -> Known.ACF - ACG -> Known.ACG - ACH -> Known.ACH - ACI -> Known.ACI - ACJ -> Known.ACJ - ACK -> Known.ACK - ACL -> Known.ACL - ACM -> Known.ACM - ACS -> Known.ACS - ADC -> Known.ADC - ADE -> Known.ADE - ADJ -> Known.ADJ - ADK -> Known.ADK - ADL -> Known.ADL - ADM -> Known.ADM - ADN -> Known.ADN - ADO -> Known.ADO - ADP -> Known.ADP - ADQ -> Known.ADQ - ADR -> Known.ADR - ADT -> Known.ADT - ADW -> Known.ADW - ADY -> Known.ADY - ADZ -> Known.ADZ - AEA -> Known.AEA - AEB -> Known.AEB - AEC -> Known.AEC - AED -> Known.AED - AEF -> Known.AEF - AEH -> Known.AEH - AEI -> Known.AEI - AEJ -> Known.AEJ - AEK -> Known.AEK - AEL -> Known.AEL - AEM -> Known.AEM - AEN -> Known.AEN - AEO -> Known.AEO - AEP -> Known.AEP - AES -> Known.AES - AET -> Known.AET - AEU -> Known.AEU - AEV -> Known.AEV - AEW -> Known.AEW - AEX -> Known.AEX - AEY -> Known.AEY - AEZ -> Known.AEZ - AJ -> Known.AJ - AU -> Known.AU - CA -> Known.CA - CAB -> Known.CAB - CAD -> Known.CAD - CAE -> Known.CAE - CAF -> Known.CAF - CAI -> Known.CAI - CAJ -> Known.CAJ - CAK -> Known.CAK - CAL -> Known.CAL - CAM -> Known.CAM - CAN -> Known.CAN - CAO -> Known.CAO - CAP -> Known.CAP - CAQ -> Known.CAQ - CAR -> Known.CAR - CAS -> Known.CAS - CAT -> Known.CAT - CAU -> Known.CAU - CAV -> Known.CAV - CAW -> Known.CAW - CAX -> Known.CAX - CAY -> Known.CAY - CAZ -> Known.CAZ - CD -> Known.CD - CG -> Known.CG - CS -> Known.CS - CT -> Known.CT - DAB -> Known.DAB - DAC -> Known.DAC - DAD -> Known.DAD - DAF -> Known.DAF - DAG -> Known.DAG - DAH -> Known.DAH - DAI -> Known.DAI - DAJ -> Known.DAJ - DAK -> Known.DAK - DAL -> Known.DAL - DAM -> Known.DAM - DAN -> Known.DAN - DAO -> Known.DAO - DAP -> Known.DAP - DAQ -> Known.DAQ - DL -> Known.DL - EG -> Known.EG - EP -> Known.EP - ER -> Known.ER - FAA -> Known.FAA - FAB -> Known.FAB - FAC -> Known.FAC - FC -> Known.FC - FH -> Known.FH - FI -> Known.FI - GAA -> Known.GAA - HAA -> Known.HAA - HD -> Known.HD - HH -> Known.HH - IAA -> Known.IAA - IAB -> Known.IAB - ID -> Known.ID - IF -> Known.IF - IR -> Known.IR - IS -> Known.IS - KO -> Known.KO - L1 -> Known.L1 - LA -> Known.LA - LAA -> Known.LAA - LAB -> Known.LAB - LF -> Known.LF - MAE -> Known.MAE - MI -> Known.MI - ML -> Known.ML - NAA -> Known.NAA - OA -> Known.OA - PA -> Known.PA - PAA -> Known.PAA - PC -> Known.PC - PL -> Known.PL - PRV -> Known.PRV - RAB -> Known.RAB - RAC -> Known.RAC - RAD -> Known.RAD - RAF -> Known.RAF - RE -> Known.RE - RF -> Known.RF - RH -> Known.RH - RV -> Known.RV - SA -> Known.SA - SAA -> Known.SAA - SAD -> Known.SAD - SAE -> Known.SAE - SAI -> Known.SAI - SG -> Known.SG - SH -> Known.SH - SM -> Known.SM - SU -> Known.SU - TAB -> Known.TAB - TAC -> Known.TAC - TT -> Known.TT - TV -> Known.TV - V1 -> Known.V1 - V2 -> Known.V2 - WH -> Known.WH - XAA -> Known.XAA - YY -> Known.YY - ZZZ -> Known.ZZZ - else -> throw EInvoiceInvalidDataException("Unknown ReasonCode: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws EInvoiceInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - EInvoiceInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): ReasonCode = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is ReasonCode && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - /** * Duty or tax or fee category codes (Subset of UNCL5305) * @@ -5007,7 +3588,6 @@ private constructor( private val charges: JsonField>, private val date: JsonField, private val description: JsonField, - private val priceBaseQuantity: JsonField, private val productCode: JsonField, private val quantity: JsonField, private val tax: JsonField, @@ -5030,9 +3610,6 @@ private constructor( @JsonProperty("description") @ExcludeMissing description: JsonField = JsonMissing.of(), - @JsonProperty("price_base_quantity") - @ExcludeMissing - priceBaseQuantity: JsonField = JsonMissing.of(), @JsonProperty("product_code") @ExcludeMissing productCode: JsonField = JsonMissing.of(), @@ -5053,7 +3630,6 @@ private constructor( charges, date, description, - priceBaseQuantity, productCode, quantity, tax, @@ -5072,9 +3648,8 @@ private constructor( fun allowances(): Optional> = allowances.getOptional("allowances") /** - * The invoice line net amount (BT-131), exclusive of VAT, inclusive of line level - * allowances and charges. Calculated as: ((unit_price / price_base_quantity) * quantity) - - * allowances + charges. Must be rounded to maximum 2 decimals + * The total amount of the line item, exclusive of VAT, after subtracting line level + * allowances and adding line level charges. Must be rounded to maximum 2 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -5103,16 +3678,6 @@ private constructor( */ fun description(): Optional = description.getOptional("description") - /** - * The item price base quantity (BT-149). The number of item units to which the price - * applies. Defaults to 1. Must be rounded to maximum 4 decimals - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun priceBaseQuantity(): Optional = - priceBaseQuantity.getOptional("price_base_quantity") - /** * The product code of the line item. * @@ -5155,8 +3720,7 @@ private constructor( fun unit(): Optional = unit.getOptional("unit") /** - * The item net price (BT-146). The price of an item, exclusive of VAT, after subtracting - * item price discount. Must be rounded to maximum 4 decimals + * The unit price of the line item. Must be rounded to maximum 2 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -5202,16 +3766,6 @@ private constructor( @ExcludeMissing fun _description(): JsonField = description - /** - * Returns the raw JSON value of [priceBaseQuantity]. - * - * Unlike [priceBaseQuantity], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("price_base_quantity") - @ExcludeMissing - fun _priceBaseQuantity(): JsonField = priceBaseQuantity - /** * Returns the raw JSON value of [productCode]. * @@ -5282,7 +3836,6 @@ private constructor( private var charges: JsonField>? = null private var date: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() - private var priceBaseQuantity: JsonField = JsonMissing.of() private var productCode: JsonField = JsonMissing.of() private var quantity: JsonField = JsonMissing.of() private var tax: JsonField = JsonMissing.of() @@ -5298,7 +3851,6 @@ private constructor( charges = item.charges.map { it.toMutableList() } date = item.date description = item.description - priceBaseQuantity = item.priceBaseQuantity productCode = item.productCode quantity = item.quantity tax = item.tax @@ -5340,9 +3892,8 @@ private constructor( } /** - * The invoice line net amount (BT-131), exclusive of VAT, inclusive of line level - * allowances and charges. Calculated as: ((unit_price / price_base_quantity) * - * quantity) - allowances + charges. Must be rounded to maximum 2 decimals + * The total amount of the line item, exclusive of VAT, after subtracting line level + * allowances and adding line level charges. Must be rounded to maximum 2 decimals */ fun amount(amount: String?) = amount(JsonField.ofNullable(amount)) @@ -5418,30 +3969,6 @@ private constructor( this.description = description } - /** - * The item price base quantity (BT-149). The number of item units to which the price - * applies. Defaults to 1. Must be rounded to maximum 4 decimals - */ - fun priceBaseQuantity(priceBaseQuantity: String?) = - priceBaseQuantity(JsonField.ofNullable(priceBaseQuantity)) - - /** - * Alias for calling [Builder.priceBaseQuantity] with `priceBaseQuantity.orElse(null)`. - */ - fun priceBaseQuantity(priceBaseQuantity: Optional) = - priceBaseQuantity(priceBaseQuantity.getOrNull()) - - /** - * Sets [Builder.priceBaseQuantity] to an arbitrary JSON value. - * - * You should usually call [Builder.priceBaseQuantity] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun priceBaseQuantity(priceBaseQuantity: JsonField) = apply { - this.priceBaseQuantity = priceBaseQuantity - } - /** The product code of the line item. */ fun productCode(productCode: String?) = productCode(JsonField.ofNullable(productCode)) @@ -5522,10 +4049,7 @@ private constructor( */ fun unit(unit: JsonField) = apply { this.unit = unit } - /** - * The item net price (BT-146). The price of an item, exclusive of VAT, after - * subtracting item price discount. Must be rounded to maximum 4 decimals - */ + /** The unit price of the line item. Must be rounded to maximum 2 decimals */ fun unitPrice(unitPrice: String?) = unitPrice(JsonField.ofNullable(unitPrice)) /** Alias for calling [Builder.unitPrice] with `unitPrice.orElse(null)`. */ @@ -5571,7 +4095,6 @@ private constructor( (charges ?: JsonMissing.of()).map { it.toImmutable() }, date, description, - priceBaseQuantity, productCode, quantity, tax, @@ -5594,7 +4117,6 @@ private constructor( charges().ifPresent { it.forEach { it.validate() } } date() description() - priceBaseQuantity() productCode() quantity() tax() @@ -5625,7 +4147,6 @@ private constructor( (charges.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (date.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + - (if (priceBaseQuantity.asKnown().isPresent) 1 else 0) + (if (productCode.asKnown().isPresent) 1 else 0) + (if (quantity.asKnown().isPresent) 1 else 0) + (if (tax.asKnown().isPresent) 1 else 0) + @@ -5644,7 +4165,6 @@ private constructor( charges == other.charges && date == other.date && description == other.description && - priceBaseQuantity == other.priceBaseQuantity && productCode == other.productCode && quantity == other.quantity && tax == other.tax && @@ -5661,7 +4181,6 @@ private constructor( charges, date, description, - priceBaseQuantity, productCode, quantity, tax, @@ -5675,7 +4194,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Item{allowances=$allowances, amount=$amount, charges=$charges, date=$date, description=$description, priceBaseQuantity=$priceBaseQuantity, productCode=$productCode, quantity=$quantity, tax=$tax, taxRate=$taxRate, unit=$unit, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" + "Item{allowances=$allowances, amount=$amount, charges=$charges, date=$date, description=$description, productCode=$productCode, quantity=$quantity, tax=$tax, taxRate=$taxRate, unit=$unit, unitPrice=$unitPrice, additionalProperties=$additionalProperties}" } class PaymentDetail diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/AllowanceTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/AllowanceTest.kt index ecb459f..5f6c011 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/AllowanceTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/AllowanceTest.kt @@ -17,7 +17,7 @@ internal class AllowanceTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -26,7 +26,7 @@ internal class AllowanceTest { assertThat(allowance.baseAmount()).contains("base_amount") assertThat(allowance.multiplierFactor()).contains("multiplier_factor") assertThat(allowance.reason()).contains("reason") - assertThat(allowance.reasonCode()).contains(Allowance.ReasonCode._41) + assertThat(allowance.reasonCode()).contains("reason_code") assertThat(allowance.taxCode()).contains(Allowance.TaxCode.AE) assertThat(allowance.taxRate()).contains("tax_rate") } @@ -40,7 +40,7 @@ internal class AllowanceTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/ChargeTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/ChargeTest.kt index f308f4e..8a868cb 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/ChargeTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/ChargeTest.kt @@ -17,18 +17,18 @@ internal class ChargeTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() assertThat(charge.amount()).contains("amount") assertThat(charge.baseAmount()).contains("base_amount") assertThat(charge.multiplierFactor()).contains("multiplier_factor") assertThat(charge.reason()).contains("reason") - assertThat(charge.reasonCode()).contains(Charge.ReasonCode.AA) + assertThat(charge.reasonCode()).contains("reason_code") assertThat(charge.taxCode()).contains(Charge.TaxCode.AE) - assertThat(charge.taxRate()).contains("21.00") + assertThat(charge.taxRate()).contains("tax_rate") } @Test @@ -40,9 +40,9 @@ internal class ChargeTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() val roundtrippedCharge = diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponseTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponseTest.kt index 083e676..7c7d640 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponseTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponseTest.kt @@ -22,7 +22,7 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -44,9 +44,9 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -71,7 +71,7 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -83,18 +83,17 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity("price_base_quantity") .productCode("product_code") .quantity("quantity") .tax("tax") - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice("unit_price") .build() @@ -149,7 +148,7 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -174,9 +173,9 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) assertThat(documentCreateFromPdfResponse.currency()).contains(CurrencyCode.EUR) @@ -204,7 +203,7 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -216,18 +215,17 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity("price_base_quantity") .productCode("product_code") .quantity("quantity") .tax("tax") - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice("unit_price") .build() @@ -297,7 +295,7 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -319,9 +317,9 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -346,7 +344,7 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -358,18 +356,17 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity("price_base_quantity") .productCode("product_code") .quantity("quantity") .tax("tax") - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice("unit_price") .build() diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateParamsTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateParamsTest.kt index 0f2de16..6aec828 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateParamsTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateParamsTest.kt @@ -20,9 +20,9 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amountDue(0.0) @@ -42,9 +42,9 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -69,9 +69,9 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amount(0.0) @@ -81,18 +81,17 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -150,9 +149,9 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amountDue(0.0) @@ -172,9 +171,9 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -199,9 +198,9 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amount(0.0) @@ -211,18 +210,17 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -278,9 +276,9 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amountDue(0.0) @@ -300,9 +298,9 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -327,9 +325,9 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amount(0.0) @@ -339,18 +337,17 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateTest.kt index a23844c..655056f 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateTest.kt @@ -22,9 +22,9 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amountDue(0.0) @@ -44,9 +44,9 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -71,9 +71,9 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amount(0.0) @@ -83,18 +83,17 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -142,9 +141,9 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) assertThat(documentCreate.amountDue()).contains(DocumentCreate.AmountDue.ofNumber(0.0)) @@ -166,9 +165,9 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) assertThat(documentCreate.currency()).contains(CurrencyCode.EUR) @@ -195,9 +194,9 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amount(0.0) @@ -207,18 +206,17 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -275,9 +273,9 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amountDue(0.0) @@ -297,9 +295,9 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -324,9 +322,9 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amount(0.0) @@ -336,18 +334,17 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentResponseTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentResponseTest.kt index 9eb8cdc..a404ab7 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentResponseTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentResponseTest.kt @@ -24,7 +24,7 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(DocumentResponse.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentResponse.Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -47,9 +47,9 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(DocumentResponse.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentResponse.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -74,7 +74,7 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -86,18 +86,17 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity("price_base_quantity") .productCode("product_code") .quantity("quantity") .tax("tax") - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice("unit_price") .build() @@ -148,7 +147,7 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(DocumentResponse.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentResponse.Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -173,9 +172,9 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(DocumentResponse.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentResponse.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) assertThat(documentResponse.currency()).contains(CurrencyCode.EUR) @@ -202,7 +201,7 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -214,18 +213,17 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity("price_base_quantity") .productCode("product_code") .quantity("quantity") .tax("tax") - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice("unit_price") .build() @@ -284,7 +282,7 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(DocumentResponse.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentResponse.Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -307,9 +305,9 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(DocumentResponse.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentResponse.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -334,7 +332,7 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -346,18 +344,17 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity("price_base_quantity") .productCode("product_code") .quantity("quantity") .tax("tax") - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice("unit_price") .build() diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt index 1ab4feb..987a7ec 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt @@ -31,7 +31,7 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(DocumentResponse.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentResponse.Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -54,9 +54,9 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(DocumentResponse.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentResponse.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -81,7 +81,7 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -93,18 +93,17 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity("price_base_quantity") .productCode("product_code") .quantity("quantity") .tax("tax") - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice("unit_price") .build() @@ -166,7 +165,7 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(DocumentResponse.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentResponse.Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -189,9 +188,9 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(DocumentResponse.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentResponse.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -216,7 +215,7 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -228,18 +227,17 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity("price_base_quantity") .productCode("product_code") .quantity("quantity") .tax("tax") - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice("unit_price") .build() @@ -302,7 +300,7 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(DocumentResponse.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentResponse.Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -325,9 +323,9 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(DocumentResponse.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentResponse.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -352,7 +350,7 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -364,18 +362,17 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity("price_base_quantity") .productCode("product_code") .quantity("quantity") .tax("tax") - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice("unit_price") .build() diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/validate/ValidateValidateJsonParamsTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/validate/ValidateValidateJsonParamsTest.kt index 66c0e68..44d2c71 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/validate/ValidateValidateJsonParamsTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/validate/ValidateValidateJsonParamsTest.kt @@ -27,9 +27,9 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amountDue(0.0) @@ -49,9 +49,9 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -76,9 +76,9 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amount(0.0) @@ -88,18 +88,17 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -157,9 +156,9 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amountDue(0.0) @@ -179,9 +178,9 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -206,9 +205,9 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amount(0.0) @@ -218,18 +217,17 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -285,9 +283,9 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amountDue(0.0) @@ -307,9 +305,9 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -334,9 +332,9 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amount(0.0) @@ -346,18 +344,17 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ErrorHandlingTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ErrorHandlingTest.kt index ef1c67c..44a8ed8 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ErrorHandlingTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ErrorHandlingTest.kt @@ -86,9 +86,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amountDue(0.0) @@ -108,9 +108,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -135,9 +135,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amount(0.0) @@ -147,18 +147,17 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -228,9 +227,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amountDue(0.0) @@ -250,9 +249,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -277,9 +276,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amount(0.0) @@ -289,18 +288,17 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -370,9 +368,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amountDue(0.0) @@ -392,9 +390,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -419,9 +417,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amount(0.0) @@ -431,18 +429,17 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -512,9 +509,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amountDue(0.0) @@ -534,9 +531,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -561,9 +558,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amount(0.0) @@ -573,18 +570,17 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -654,9 +650,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amountDue(0.0) @@ -676,9 +672,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -703,9 +699,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amount(0.0) @@ -715,18 +711,17 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -796,9 +791,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amountDue(0.0) @@ -818,9 +813,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -845,9 +840,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amount(0.0) @@ -857,18 +852,17 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -938,9 +932,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amountDue(0.0) @@ -960,9 +954,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -987,9 +981,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amount(0.0) @@ -999,18 +993,17 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -1080,9 +1073,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amountDue(0.0) @@ -1102,9 +1095,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -1129,9 +1122,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amount(0.0) @@ -1141,18 +1134,17 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -1222,9 +1214,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amountDue(0.0) @@ -1244,9 +1236,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -1271,9 +1263,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amount(0.0) @@ -1283,18 +1275,17 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -1364,9 +1355,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amountDue(0.0) @@ -1386,9 +1377,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -1413,9 +1404,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amount(0.0) @@ -1425,18 +1416,17 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -1506,9 +1496,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amountDue(0.0) @@ -1528,9 +1518,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -1555,9 +1545,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amount(0.0) @@ -1567,18 +1557,17 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -1648,9 +1637,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amountDue(0.0) @@ -1670,9 +1659,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -1697,9 +1686,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amount(0.0) @@ -1709,18 +1698,17 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -1790,9 +1778,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amountDue(0.0) @@ -1812,9 +1800,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -1839,9 +1827,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amount(0.0) @@ -1851,18 +1839,17 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -1932,9 +1919,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amountDue(0.0) @@ -1954,9 +1941,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -1981,9 +1968,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amount(0.0) @@ -1993,18 +1980,17 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -2074,9 +2060,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amountDue(0.0) @@ -2096,9 +2082,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -2123,9 +2109,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amount(0.0) @@ -2135,18 +2121,17 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -2216,9 +2201,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amountDue(0.0) @@ -2238,9 +2223,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -2265,9 +2250,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amount(0.0) @@ -2277,18 +2262,17 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -2356,9 +2340,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amountDue(0.0) @@ -2378,9 +2362,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -2405,9 +2389,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amount(0.0) @@ -2417,18 +2401,17 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ServiceParamsTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ServiceParamsTest.kt index 1153aaf..44e13bd 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ServiceParamsTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ServiceParamsTest.kt @@ -56,9 +56,9 @@ internal class ServiceParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amountDue(0.0) @@ -78,9 +78,9 @@ internal class ServiceParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -105,9 +105,9 @@ internal class ServiceParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amount(0.0) @@ -117,18 +117,17 @@ internal class ServiceParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncTest.kt index a752360..c75bf1d 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncTest.kt @@ -41,9 +41,9 @@ internal class DocumentServiceAsyncTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amountDue(0.0) @@ -63,9 +63,9 @@ internal class DocumentServiceAsyncTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -90,9 +90,9 @@ internal class DocumentServiceAsyncTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amount(0.0) @@ -102,18 +102,17 @@ internal class DocumentServiceAsyncTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/ValidateServiceAsyncTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/ValidateServiceAsyncTest.kt index d62ca64..827c4e0 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/ValidateServiceAsyncTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/ValidateServiceAsyncTest.kt @@ -41,9 +41,9 @@ internal class ValidateServiceAsyncTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amountDue(0.0) @@ -63,9 +63,9 @@ internal class ValidateServiceAsyncTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -90,9 +90,9 @@ internal class ValidateServiceAsyncTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amount(0.0) @@ -102,18 +102,17 @@ internal class ValidateServiceAsyncTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/DocumentServiceTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/DocumentServiceTest.kt index ad08546..c34988c 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/DocumentServiceTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/DocumentServiceTest.kt @@ -41,9 +41,9 @@ internal class DocumentServiceTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amountDue(0.0) @@ -63,9 +63,9 @@ internal class DocumentServiceTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -90,9 +90,9 @@ internal class DocumentServiceTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amount(0.0) @@ -102,18 +102,17 @@ internal class DocumentServiceTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/ValidateServiceTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/ValidateServiceTest.kt index b35236d..936c28c 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/ValidateServiceTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/ValidateServiceTest.kt @@ -41,9 +41,9 @@ internal class ValidateServiceTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amountDue(0.0) @@ -63,9 +63,9 @@ internal class ValidateServiceTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .currency(CurrencyCode.EUR) @@ -90,9 +90,9 @@ internal class ValidateServiceTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate(0.0) + .taxRate("tax_rate") .build() ) .amount(0.0) @@ -102,18 +102,17 @@ internal class ValidateServiceTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) + .reasonCode("reason_code") .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("21.00") + .taxRate("tax_rate") .build() ) .date(null) .description("description") - .priceBaseQuantity(1.0) .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("21.00") + .taxRate("tax_rate") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() diff --git a/e-invoice-java-proguard-test/src/test/kotlin/com/e_invoice/api/proguard/ProGuardCompatibilityTest.kt b/e-invoice-java-proguard-test/src/test/kotlin/com/e_invoice/api/proguard/ProGuardCompatibilityTest.kt index 301a053..e6113ec 100644 --- a/e-invoice-java-proguard-test/src/test/kotlin/com/e_invoice/api/proguard/ProGuardCompatibilityTest.kt +++ b/e-invoice-java-proguard-test/src/test/kotlin/com/e_invoice/api/proguard/ProGuardCompatibilityTest.kt @@ -66,7 +66,7 @@ internal class ProGuardCompatibilityTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode(Allowance.ReasonCode._41) + .reasonCode("reason_code") .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() From 3bc4883a59e0cc7352dfa41a3c6f67f4efc8ba19 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 14 Nov 2025 16:14:06 +0000 Subject: [PATCH 11/43] feat(api): api update --- .stats.yml | 4 +- .../api/models/documents/Allowance.kt | 298 +- .../e_invoice/api/models/documents/Charge.kt | 1218 ++++- .../api/models/documents/DocumentCreate.kt | 4761 +++++++++++++++-- .../DocumentCreateFromPdfResponse.kt | 91 +- .../api/models/documents/DocumentResponse.kt | 1604 +++++- .../api/models/documents/UnitOfMeasureCode.kt | 6 + .../api/models/documents/AllowanceTest.kt | 6 +- .../api/models/documents/ChargeTest.kt | 12 +- .../DocumentCreateFromPdfResponseTest.kt | 46 +- .../documents/DocumentCreateParamsTest.kt | 54 +- .../models/documents/DocumentCreateTest.kt | 54 +- .../models/documents/DocumentResponseTest.kt | 45 +- .../inbox/PaginatedDocumentResponseTest.kt | 45 +- .../ValidateValidateJsonParamsTest.kt | 54 +- .../api/services/ErrorHandlingTest.kt | 306 +- .../api/services/ServiceParamsTest.kt | 18 +- .../async/DocumentServiceAsyncTest.kt | 18 +- .../async/ValidateServiceAsyncTest.kt | 18 +- .../services/blocking/DocumentServiceTest.kt | 18 +- .../services/blocking/ValidateServiceTest.kt | 18 +- .../api/proguard/ProGuardCompatibilityTest.kt | 2 +- 22 files changed, 7596 insertions(+), 1100 deletions(-) diff --git a/.stats.yml b/.stats.yml index 12f0e7f..815fcb2 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-009e20418b5b4a984fbc1a6c74d2148f2ebb823568699babb83ec8a4f2aea1f7.yml -openapi_spec_hash: 8a63ae95d8d7e7beaaf306f1bb2b1cd3 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-02fc6edfd7a172a933949a07f213b54f85b0cfe6859e4ae38f928f74b162341b.yml +openapi_spec_hash: 7d6d996d1a3ffe372b6e263033050aec config_hash: 852a0117abb3db077933876ad1185f41 diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Allowance.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Allowance.kt index 75ac28d..0351698 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Allowance.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Allowance.kt @@ -25,7 +25,7 @@ private constructor( private val baseAmount: JsonField, private val multiplierFactor: JsonField, private val reason: JsonField, - private val reasonCode: JsonField, + private val reasonCode: JsonField, private val taxCode: JsonField, private val taxRate: JsonField, private val additionalProperties: MutableMap, @@ -43,7 +43,7 @@ private constructor( @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), @JsonProperty("reason_code") @ExcludeMissing - reasonCode: JsonField = JsonMissing.of(), + reasonCode: JsonField = JsonMissing.of(), @JsonProperty("tax_code") @ExcludeMissing taxCode: JsonField = JsonMissing.of(), @JsonProperty("tax_rate") @ExcludeMissing taxRate: JsonField = JsonMissing.of(), ) : this( @@ -76,7 +76,7 @@ private constructor( /** * The percentage that may be used, in conjunction with the allowance base amount, to calculate - * the allowance amount. To state 20%, use value 20 + * the allowance amount. To state 20%, use value 20. Must be rounded to maximum 2 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -92,17 +92,15 @@ private constructor( fun reason(): Optional = reason.getOptional("reason") /** - * The code for the allowance reason + * Allowance reason codes for invoice discounts and charges * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun reasonCode(): Optional = reasonCode.getOptional("reason_code") + fun reasonCode(): Optional = reasonCode.getOptional("reason_code") /** - * Duty or tax or fee category codes (Subset of UNCL5305) - * - * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + * The VAT category code that applies to the allowance * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -110,7 +108,8 @@ private constructor( fun taxCode(): Optional = taxCode.getOptional("tax_code") /** - * The VAT rate, represented as percentage that applies to the allowance + * The VAT rate, represented as percentage that applies to the allowance. Must be rounded to + * maximum 2 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -153,7 +152,9 @@ private constructor( * * Unlike [reasonCode], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("reason_code") @ExcludeMissing fun _reasonCode(): JsonField = reasonCode + @JsonProperty("reason_code") + @ExcludeMissing + fun _reasonCode(): JsonField = reasonCode /** * Returns the raw JSON value of [taxCode]. @@ -194,7 +195,7 @@ private constructor( private var baseAmount: JsonField = JsonMissing.of() private var multiplierFactor: JsonField = JsonMissing.of() private var reason: JsonField = JsonMissing.of() - private var reasonCode: JsonField = JsonMissing.of() + private var reasonCode: JsonField = JsonMissing.of() private var taxCode: JsonField = JsonMissing.of() private var taxRate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -245,7 +246,8 @@ private constructor( /** * The percentage that may be used, in conjunction with the allowance base amount, to - * calculate the allowance amount. To state 20%, use value 20 + * calculate the allowance amount. To state 20%, use value 20. Must be rounded to maximum 2 + * decimals */ fun multiplierFactor(multiplierFactor: String?) = multiplierFactor(JsonField.ofNullable(multiplierFactor)) @@ -279,30 +281,23 @@ private constructor( */ fun reason(reason: JsonField) = apply { this.reason = reason } - /** The code for the allowance reason */ - fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) + /** Allowance reason codes for invoice discounts and charges */ + fun reasonCode(reasonCode: ReasonCode?) = reasonCode(JsonField.ofNullable(reasonCode)) /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ - fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) + fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) /** * Sets [Builder.reasonCode] to an arbitrary JSON value. * - * You should usually call [Builder.reasonCode] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode } - - /** - * Duty or tax or fee category codes (Subset of UNCL5305) - * - * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + * You should usually call [Builder.reasonCode] with a well-typed [ReasonCode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun taxCode(taxCode: TaxCode?) = taxCode(JsonField.ofNullable(taxCode)) + fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode } - /** Alias for calling [Builder.taxCode] with `taxCode.orElse(null)`. */ - fun taxCode(taxCode: Optional) = taxCode(taxCode.getOrNull()) + /** The VAT category code that applies to the allowance */ + fun taxCode(taxCode: TaxCode) = taxCode(JsonField.of(taxCode)) /** * Sets [Builder.taxCode] to an arbitrary JSON value. @@ -312,7 +307,10 @@ private constructor( */ fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } - /** The VAT rate, represented as percentage that applies to the allowance */ + /** + * The VAT rate, represented as percentage that applies to the allowance. Must be rounded to + * maximum 2 decimals + */ fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ @@ -374,7 +372,7 @@ private constructor( baseAmount() multiplierFactor() reason() - reasonCode() + reasonCode().ifPresent { it.validate() } taxCode().ifPresent { it.validate() } taxRate() validated = true @@ -399,15 +397,243 @@ private constructor( (if (baseAmount.asKnown().isPresent) 1 else 0) + (if (multiplierFactor.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) + - (if (reasonCode.asKnown().isPresent) 1 else 0) + + (reasonCode.asKnown().getOrNull()?.validity() ?: 0) + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + (if (taxRate.asKnown().isPresent) 1 else 0) - /** - * Duty or tax or fee category codes (Subset of UNCL5305) - * - * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL - */ + /** Allowance reason codes for invoice discounts and charges */ + class ReasonCode @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val _41 = of("41") + + @JvmField val _42 = of("42") + + @JvmField val _60 = of("60") + + @JvmField val _62 = of("62") + + @JvmField val _63 = of("63") + + @JvmField val _64 = of("64") + + @JvmField val _65 = of("65") + + @JvmField val _66 = of("66") + + @JvmField val _67 = of("67") + + @JvmField val _68 = of("68") + + @JvmField val _70 = of("70") + + @JvmField val _71 = of("71") + + @JvmField val _88 = of("88") + + @JvmField val _95 = of("95") + + @JvmField val _100 = of("100") + + @JvmField val _102 = of("102") + + @JvmField val _103 = of("103") + + @JvmField val _104 = of("104") + + @JvmField val _105 = of("105") + + @JvmStatic fun of(value: String) = ReasonCode(JsonField.of(value)) + } + + /** An enum containing [ReasonCode]'s known values. */ + enum class Known { + _41, + _42, + _60, + _62, + _63, + _64, + _65, + _66, + _67, + _68, + _70, + _71, + _88, + _95, + _100, + _102, + _103, + _104, + _105, + } + + /** + * An enum containing [ReasonCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ReasonCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + _41, + _42, + _60, + _62, + _63, + _64, + _65, + _66, + _67, + _68, + _70, + _71, + _88, + _95, + _100, + _102, + _103, + _104, + _105, + /** + * An enum member indicating that [ReasonCode] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + _41 -> Value._41 + _42 -> Value._42 + _60 -> Value._60 + _62 -> Value._62 + _63 -> Value._63 + _64 -> Value._64 + _65 -> Value._65 + _66 -> Value._66 + _67 -> Value._67 + _68 -> Value._68 + _70 -> Value._70 + _71 -> Value._71 + _88 -> Value._88 + _95 -> Value._95 + _100 -> Value._100 + _102 -> Value._102 + _103 -> Value._103 + _104 -> Value._104 + _105 -> Value._105 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + _41 -> Known._41 + _42 -> Known._42 + _60 -> Known._60 + _62 -> Known._62 + _63 -> Known._63 + _64 -> Known._64 + _65 -> Known._65 + _66 -> Known._66 + _67 -> Known._67 + _68 -> Known._68 + _70 -> Known._70 + _71 -> Known._71 + _88 -> Known._88 + _95 -> Known._95 + _100 -> Known._100 + _102 -> Known._102 + _103 -> Known._103 + _104 -> Known._104 + _105 -> Known._105 + else -> throw EInvoiceInvalidDataException("Unknown ReasonCode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReasonCode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReasonCode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The VAT category code that applies to the allowance */ class TaxCode @JsonCreator private constructor(private val value: JsonField) : Enum { /** diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Charge.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Charge.kt index 3654cc2..45e1ce7 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Charge.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/Charge.kt @@ -25,7 +25,7 @@ private constructor( private val baseAmount: JsonField, private val multiplierFactor: JsonField, private val reason: JsonField, - private val reasonCode: JsonField, + private val reasonCode: JsonField, private val taxCode: JsonField, private val taxRate: JsonField, private val additionalProperties: MutableMap, @@ -43,7 +43,7 @@ private constructor( @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), @JsonProperty("reason_code") @ExcludeMissing - reasonCode: JsonField = JsonMissing.of(), + reasonCode: JsonField = JsonMissing.of(), @JsonProperty("tax_code") @ExcludeMissing taxCode: JsonField = JsonMissing.of(), @JsonProperty("tax_rate") @ExcludeMissing taxRate: JsonField = JsonMissing.of(), ) : this( @@ -92,12 +92,12 @@ private constructor( fun reason(): Optional = reason.getOptional("reason") /** - * The code for the charge reason + * Charge reason codes for invoice charges and fees * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun reasonCode(): Optional = reasonCode.getOptional("reason_code") + fun reasonCode(): Optional = reasonCode.getOptional("reason_code") /** * Duty or tax or fee category codes (Subset of UNCL5305) @@ -153,7 +153,9 @@ private constructor( * * Unlike [reasonCode], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("reason_code") @ExcludeMissing fun _reasonCode(): JsonField = reasonCode + @JsonProperty("reason_code") + @ExcludeMissing + fun _reasonCode(): JsonField = reasonCode /** * Returns the raw JSON value of [taxCode]. @@ -194,7 +196,7 @@ private constructor( private var baseAmount: JsonField = JsonMissing.of() private var multiplierFactor: JsonField = JsonMissing.of() private var reason: JsonField = JsonMissing.of() - private var reasonCode: JsonField = JsonMissing.of() + private var reasonCode: JsonField = JsonMissing.of() private var taxCode: JsonField = JsonMissing.of() private var taxRate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -279,20 +281,20 @@ private constructor( */ fun reason(reason: JsonField) = apply { this.reason = reason } - /** The code for the charge reason */ - fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) + /** Charge reason codes for invoice charges and fees */ + fun reasonCode(reasonCode: ReasonCode?) = reasonCode(JsonField.ofNullable(reasonCode)) /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ - fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) + fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) /** * Sets [Builder.reasonCode] to an arbitrary JSON value. * - * You should usually call [Builder.reasonCode] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. + * You should usually call [Builder.reasonCode] with a well-typed [ReasonCode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode } + fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode } /** * Duty or tax or fee category codes (Subset of UNCL5305) @@ -374,7 +376,7 @@ private constructor( baseAmount() multiplierFactor() reason() - reasonCode() + reasonCode().ifPresent { it.validate() } taxCode().ifPresent { it.validate() } taxRate() validated = true @@ -399,10 +401,1196 @@ private constructor( (if (baseAmount.asKnown().isPresent) 1 else 0) + (if (multiplierFactor.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) + - (if (reasonCode.asKnown().isPresent) 1 else 0) + + (reasonCode.asKnown().getOrNull()?.validity() ?: 0) + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + (if (taxRate.asKnown().isPresent) 1 else 0) + /** Charge reason codes for invoice charges and fees */ + class ReasonCode @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val AA = of("AA") + + @JvmField val AAA = of("AAA") + + @JvmField val AAC = of("AAC") + + @JvmField val AAD = of("AAD") + + @JvmField val AAE = of("AAE") + + @JvmField val AAF = of("AAF") + + @JvmField val AAH = of("AAH") + + @JvmField val AAI = of("AAI") + + @JvmField val AAS = of("AAS") + + @JvmField val AAT = of("AAT") + + @JvmField val AAV = of("AAV") + + @JvmField val AAY = of("AAY") + + @JvmField val AAZ = of("AAZ") + + @JvmField val ABA = of("ABA") + + @JvmField val ABB = of("ABB") + + @JvmField val ABC = of("ABC") + + @JvmField val ABD = of("ABD") + + @JvmField val ABF = of("ABF") + + @JvmField val ABK = of("ABK") + + @JvmField val ABL = of("ABL") + + @JvmField val ABN = of("ABN") + + @JvmField val ABR = of("ABR") + + @JvmField val ABS = of("ABS") + + @JvmField val ABT = of("ABT") + + @JvmField val ABU = of("ABU") + + @JvmField val ACF = of("ACF") + + @JvmField val ACG = of("ACG") + + @JvmField val ACH = of("ACH") + + @JvmField val ACI = of("ACI") + + @JvmField val ACJ = of("ACJ") + + @JvmField val ACK = of("ACK") + + @JvmField val ACL = of("ACL") + + @JvmField val ACM = of("ACM") + + @JvmField val ACS = of("ACS") + + @JvmField val ADC = of("ADC") + + @JvmField val ADE = of("ADE") + + @JvmField val ADJ = of("ADJ") + + @JvmField val ADK = of("ADK") + + @JvmField val ADL = of("ADL") + + @JvmField val ADM = of("ADM") + + @JvmField val ADN = of("ADN") + + @JvmField val ADO = of("ADO") + + @JvmField val ADP = of("ADP") + + @JvmField val ADQ = of("ADQ") + + @JvmField val ADR = of("ADR") + + @JvmField val ADT = of("ADT") + + @JvmField val ADW = of("ADW") + + @JvmField val ADY = of("ADY") + + @JvmField val ADZ = of("ADZ") + + @JvmField val AEA = of("AEA") + + @JvmField val AEB = of("AEB") + + @JvmField val AEC = of("AEC") + + @JvmField val AED = of("AED") + + @JvmField val AEF = of("AEF") + + @JvmField val AEH = of("AEH") + + @JvmField val AEI = of("AEI") + + @JvmField val AEJ = of("AEJ") + + @JvmField val AEK = of("AEK") + + @JvmField val AEL = of("AEL") + + @JvmField val AEM = of("AEM") + + @JvmField val AEN = of("AEN") + + @JvmField val AEO = of("AEO") + + @JvmField val AEP = of("AEP") + + @JvmField val AES = of("AES") + + @JvmField val AET = of("AET") + + @JvmField val AEU = of("AEU") + + @JvmField val AEV = of("AEV") + + @JvmField val AEW = of("AEW") + + @JvmField val AEX = of("AEX") + + @JvmField val AEY = of("AEY") + + @JvmField val AEZ = of("AEZ") + + @JvmField val AJ = of("AJ") + + @JvmField val AU = of("AU") + + @JvmField val CA = of("CA") + + @JvmField val CAB = of("CAB") + + @JvmField val CAD = of("CAD") + + @JvmField val CAE = of("CAE") + + @JvmField val CAF = of("CAF") + + @JvmField val CAI = of("CAI") + + @JvmField val CAJ = of("CAJ") + + @JvmField val CAK = of("CAK") + + @JvmField val CAL = of("CAL") + + @JvmField val CAM = of("CAM") + + @JvmField val CAN = of("CAN") + + @JvmField val CAO = of("CAO") + + @JvmField val CAP = of("CAP") + + @JvmField val CAQ = of("CAQ") + + @JvmField val CAR = of("CAR") + + @JvmField val CAS = of("CAS") + + @JvmField val CAT = of("CAT") + + @JvmField val CAU = of("CAU") + + @JvmField val CAV = of("CAV") + + @JvmField val CAW = of("CAW") + + @JvmField val CAX = of("CAX") + + @JvmField val CAY = of("CAY") + + @JvmField val CAZ = of("CAZ") + + @JvmField val CD = of("CD") + + @JvmField val CG = of("CG") + + @JvmField val CS = of("CS") + + @JvmField val CT = of("CT") + + @JvmField val DAB = of("DAB") + + @JvmField val DAC = of("DAC") + + @JvmField val DAD = of("DAD") + + @JvmField val DAF = of("DAF") + + @JvmField val DAG = of("DAG") + + @JvmField val DAH = of("DAH") + + @JvmField val DAI = of("DAI") + + @JvmField val DAJ = of("DAJ") + + @JvmField val DAK = of("DAK") + + @JvmField val DAL = of("DAL") + + @JvmField val DAM = of("DAM") + + @JvmField val DAN = of("DAN") + + @JvmField val DAO = of("DAO") + + @JvmField val DAP = of("DAP") + + @JvmField val DAQ = of("DAQ") + + @JvmField val DL = of("DL") + + @JvmField val EG = of("EG") + + @JvmField val EP = of("EP") + + @JvmField val ER = of("ER") + + @JvmField val FAA = of("FAA") + + @JvmField val FAB = of("FAB") + + @JvmField val FAC = of("FAC") + + @JvmField val FC = of("FC") + + @JvmField val FH = of("FH") + + @JvmField val FI = of("FI") + + @JvmField val GAA = of("GAA") + + @JvmField val HAA = of("HAA") + + @JvmField val HD = of("HD") + + @JvmField val HH = of("HH") + + @JvmField val IAA = of("IAA") + + @JvmField val IAB = of("IAB") + + @JvmField val ID = of("ID") + + @JvmField val IF = of("IF") + + @JvmField val IR = of("IR") + + @JvmField val IS = of("IS") + + @JvmField val KO = of("KO") + + @JvmField val L1 = of("L1") + + @JvmField val LA = of("LA") + + @JvmField val LAA = of("LAA") + + @JvmField val LAB = of("LAB") + + @JvmField val LF = of("LF") + + @JvmField val MAE = of("MAE") + + @JvmField val MI = of("MI") + + @JvmField val ML = of("ML") + + @JvmField val NAA = of("NAA") + + @JvmField val OA = of("OA") + + @JvmField val PA = of("PA") + + @JvmField val PAA = of("PAA") + + @JvmField val PC = of("PC") + + @JvmField val PL = of("PL") + + @JvmField val PRV = of("PRV") + + @JvmField val RAB = of("RAB") + + @JvmField val RAC = of("RAC") + + @JvmField val RAD = of("RAD") + + @JvmField val RAF = of("RAF") + + @JvmField val RE = of("RE") + + @JvmField val RF = of("RF") + + @JvmField val RH = of("RH") + + @JvmField val RV = of("RV") + + @JvmField val SA = of("SA") + + @JvmField val SAA = of("SAA") + + @JvmField val SAD = of("SAD") + + @JvmField val SAE = of("SAE") + + @JvmField val SAI = of("SAI") + + @JvmField val SG = of("SG") + + @JvmField val SH = of("SH") + + @JvmField val SM = of("SM") + + @JvmField val SU = of("SU") + + @JvmField val TAB = of("TAB") + + @JvmField val TAC = of("TAC") + + @JvmField val TT = of("TT") + + @JvmField val TV = of("TV") + + @JvmField val V1 = of("V1") + + @JvmField val V2 = of("V2") + + @JvmField val WH = of("WH") + + @JvmField val XAA = of("XAA") + + @JvmField val YY = of("YY") + + @JvmField val ZZZ = of("ZZZ") + + @JvmStatic fun of(value: String) = ReasonCode(JsonField.of(value)) + } + + /** An enum containing [ReasonCode]'s known values. */ + enum class Known { + AA, + AAA, + AAC, + AAD, + AAE, + AAF, + AAH, + AAI, + AAS, + AAT, + AAV, + AAY, + AAZ, + ABA, + ABB, + ABC, + ABD, + ABF, + ABK, + ABL, + ABN, + ABR, + ABS, + ABT, + ABU, + ACF, + ACG, + ACH, + ACI, + ACJ, + ACK, + ACL, + ACM, + ACS, + ADC, + ADE, + ADJ, + ADK, + ADL, + ADM, + ADN, + ADO, + ADP, + ADQ, + ADR, + ADT, + ADW, + ADY, + ADZ, + AEA, + AEB, + AEC, + AED, + AEF, + AEH, + AEI, + AEJ, + AEK, + AEL, + AEM, + AEN, + AEO, + AEP, + AES, + AET, + AEU, + AEV, + AEW, + AEX, + AEY, + AEZ, + AJ, + AU, + CA, + CAB, + CAD, + CAE, + CAF, + CAI, + CAJ, + CAK, + CAL, + CAM, + CAN, + CAO, + CAP, + CAQ, + CAR, + CAS, + CAT, + CAU, + CAV, + CAW, + CAX, + CAY, + CAZ, + CD, + CG, + CS, + CT, + DAB, + DAC, + DAD, + DAF, + DAG, + DAH, + DAI, + DAJ, + DAK, + DAL, + DAM, + DAN, + DAO, + DAP, + DAQ, + DL, + EG, + EP, + ER, + FAA, + FAB, + FAC, + FC, + FH, + FI, + GAA, + HAA, + HD, + HH, + IAA, + IAB, + ID, + IF, + IR, + IS, + KO, + L1, + LA, + LAA, + LAB, + LF, + MAE, + MI, + ML, + NAA, + OA, + PA, + PAA, + PC, + PL, + PRV, + RAB, + RAC, + RAD, + RAF, + RE, + RF, + RH, + RV, + SA, + SAA, + SAD, + SAE, + SAI, + SG, + SH, + SM, + SU, + TAB, + TAC, + TT, + TV, + V1, + V2, + WH, + XAA, + YY, + ZZZ, + } + + /** + * An enum containing [ReasonCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ReasonCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AA, + AAA, + AAC, + AAD, + AAE, + AAF, + AAH, + AAI, + AAS, + AAT, + AAV, + AAY, + AAZ, + ABA, + ABB, + ABC, + ABD, + ABF, + ABK, + ABL, + ABN, + ABR, + ABS, + ABT, + ABU, + ACF, + ACG, + ACH, + ACI, + ACJ, + ACK, + ACL, + ACM, + ACS, + ADC, + ADE, + ADJ, + ADK, + ADL, + ADM, + ADN, + ADO, + ADP, + ADQ, + ADR, + ADT, + ADW, + ADY, + ADZ, + AEA, + AEB, + AEC, + AED, + AEF, + AEH, + AEI, + AEJ, + AEK, + AEL, + AEM, + AEN, + AEO, + AEP, + AES, + AET, + AEU, + AEV, + AEW, + AEX, + AEY, + AEZ, + AJ, + AU, + CA, + CAB, + CAD, + CAE, + CAF, + CAI, + CAJ, + CAK, + CAL, + CAM, + CAN, + CAO, + CAP, + CAQ, + CAR, + CAS, + CAT, + CAU, + CAV, + CAW, + CAX, + CAY, + CAZ, + CD, + CG, + CS, + CT, + DAB, + DAC, + DAD, + DAF, + DAG, + DAH, + DAI, + DAJ, + DAK, + DAL, + DAM, + DAN, + DAO, + DAP, + DAQ, + DL, + EG, + EP, + ER, + FAA, + FAB, + FAC, + FC, + FH, + FI, + GAA, + HAA, + HD, + HH, + IAA, + IAB, + ID, + IF, + IR, + IS, + KO, + L1, + LA, + LAA, + LAB, + LF, + MAE, + MI, + ML, + NAA, + OA, + PA, + PAA, + PC, + PL, + PRV, + RAB, + RAC, + RAD, + RAF, + RE, + RF, + RH, + RV, + SA, + SAA, + SAD, + SAE, + SAI, + SG, + SH, + SM, + SU, + TAB, + TAC, + TT, + TV, + V1, + V2, + WH, + XAA, + YY, + ZZZ, + /** + * An enum member indicating that [ReasonCode] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AA -> Value.AA + AAA -> Value.AAA + AAC -> Value.AAC + AAD -> Value.AAD + AAE -> Value.AAE + AAF -> Value.AAF + AAH -> Value.AAH + AAI -> Value.AAI + AAS -> Value.AAS + AAT -> Value.AAT + AAV -> Value.AAV + AAY -> Value.AAY + AAZ -> Value.AAZ + ABA -> Value.ABA + ABB -> Value.ABB + ABC -> Value.ABC + ABD -> Value.ABD + ABF -> Value.ABF + ABK -> Value.ABK + ABL -> Value.ABL + ABN -> Value.ABN + ABR -> Value.ABR + ABS -> Value.ABS + ABT -> Value.ABT + ABU -> Value.ABU + ACF -> Value.ACF + ACG -> Value.ACG + ACH -> Value.ACH + ACI -> Value.ACI + ACJ -> Value.ACJ + ACK -> Value.ACK + ACL -> Value.ACL + ACM -> Value.ACM + ACS -> Value.ACS + ADC -> Value.ADC + ADE -> Value.ADE + ADJ -> Value.ADJ + ADK -> Value.ADK + ADL -> Value.ADL + ADM -> Value.ADM + ADN -> Value.ADN + ADO -> Value.ADO + ADP -> Value.ADP + ADQ -> Value.ADQ + ADR -> Value.ADR + ADT -> Value.ADT + ADW -> Value.ADW + ADY -> Value.ADY + ADZ -> Value.ADZ + AEA -> Value.AEA + AEB -> Value.AEB + AEC -> Value.AEC + AED -> Value.AED + AEF -> Value.AEF + AEH -> Value.AEH + AEI -> Value.AEI + AEJ -> Value.AEJ + AEK -> Value.AEK + AEL -> Value.AEL + AEM -> Value.AEM + AEN -> Value.AEN + AEO -> Value.AEO + AEP -> Value.AEP + AES -> Value.AES + AET -> Value.AET + AEU -> Value.AEU + AEV -> Value.AEV + AEW -> Value.AEW + AEX -> Value.AEX + AEY -> Value.AEY + AEZ -> Value.AEZ + AJ -> Value.AJ + AU -> Value.AU + CA -> Value.CA + CAB -> Value.CAB + CAD -> Value.CAD + CAE -> Value.CAE + CAF -> Value.CAF + CAI -> Value.CAI + CAJ -> Value.CAJ + CAK -> Value.CAK + CAL -> Value.CAL + CAM -> Value.CAM + CAN -> Value.CAN + CAO -> Value.CAO + CAP -> Value.CAP + CAQ -> Value.CAQ + CAR -> Value.CAR + CAS -> Value.CAS + CAT -> Value.CAT + CAU -> Value.CAU + CAV -> Value.CAV + CAW -> Value.CAW + CAX -> Value.CAX + CAY -> Value.CAY + CAZ -> Value.CAZ + CD -> Value.CD + CG -> Value.CG + CS -> Value.CS + CT -> Value.CT + DAB -> Value.DAB + DAC -> Value.DAC + DAD -> Value.DAD + DAF -> Value.DAF + DAG -> Value.DAG + DAH -> Value.DAH + DAI -> Value.DAI + DAJ -> Value.DAJ + DAK -> Value.DAK + DAL -> Value.DAL + DAM -> Value.DAM + DAN -> Value.DAN + DAO -> Value.DAO + DAP -> Value.DAP + DAQ -> Value.DAQ + DL -> Value.DL + EG -> Value.EG + EP -> Value.EP + ER -> Value.ER + FAA -> Value.FAA + FAB -> Value.FAB + FAC -> Value.FAC + FC -> Value.FC + FH -> Value.FH + FI -> Value.FI + GAA -> Value.GAA + HAA -> Value.HAA + HD -> Value.HD + HH -> Value.HH + IAA -> Value.IAA + IAB -> Value.IAB + ID -> Value.ID + IF -> Value.IF + IR -> Value.IR + IS -> Value.IS + KO -> Value.KO + L1 -> Value.L1 + LA -> Value.LA + LAA -> Value.LAA + LAB -> Value.LAB + LF -> Value.LF + MAE -> Value.MAE + MI -> Value.MI + ML -> Value.ML + NAA -> Value.NAA + OA -> Value.OA + PA -> Value.PA + PAA -> Value.PAA + PC -> Value.PC + PL -> Value.PL + PRV -> Value.PRV + RAB -> Value.RAB + RAC -> Value.RAC + RAD -> Value.RAD + RAF -> Value.RAF + RE -> Value.RE + RF -> Value.RF + RH -> Value.RH + RV -> Value.RV + SA -> Value.SA + SAA -> Value.SAA + SAD -> Value.SAD + SAE -> Value.SAE + SAI -> Value.SAI + SG -> Value.SG + SH -> Value.SH + SM -> Value.SM + SU -> Value.SU + TAB -> Value.TAB + TAC -> Value.TAC + TT -> Value.TT + TV -> Value.TV + V1 -> Value.V1 + V2 -> Value.V2 + WH -> Value.WH + XAA -> Value.XAA + YY -> Value.YY + ZZZ -> Value.ZZZ + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + AA -> Known.AA + AAA -> Known.AAA + AAC -> Known.AAC + AAD -> Known.AAD + AAE -> Known.AAE + AAF -> Known.AAF + AAH -> Known.AAH + AAI -> Known.AAI + AAS -> Known.AAS + AAT -> Known.AAT + AAV -> Known.AAV + AAY -> Known.AAY + AAZ -> Known.AAZ + ABA -> Known.ABA + ABB -> Known.ABB + ABC -> Known.ABC + ABD -> Known.ABD + ABF -> Known.ABF + ABK -> Known.ABK + ABL -> Known.ABL + ABN -> Known.ABN + ABR -> Known.ABR + ABS -> Known.ABS + ABT -> Known.ABT + ABU -> Known.ABU + ACF -> Known.ACF + ACG -> Known.ACG + ACH -> Known.ACH + ACI -> Known.ACI + ACJ -> Known.ACJ + ACK -> Known.ACK + ACL -> Known.ACL + ACM -> Known.ACM + ACS -> Known.ACS + ADC -> Known.ADC + ADE -> Known.ADE + ADJ -> Known.ADJ + ADK -> Known.ADK + ADL -> Known.ADL + ADM -> Known.ADM + ADN -> Known.ADN + ADO -> Known.ADO + ADP -> Known.ADP + ADQ -> Known.ADQ + ADR -> Known.ADR + ADT -> Known.ADT + ADW -> Known.ADW + ADY -> Known.ADY + ADZ -> Known.ADZ + AEA -> Known.AEA + AEB -> Known.AEB + AEC -> Known.AEC + AED -> Known.AED + AEF -> Known.AEF + AEH -> Known.AEH + AEI -> Known.AEI + AEJ -> Known.AEJ + AEK -> Known.AEK + AEL -> Known.AEL + AEM -> Known.AEM + AEN -> Known.AEN + AEO -> Known.AEO + AEP -> Known.AEP + AES -> Known.AES + AET -> Known.AET + AEU -> Known.AEU + AEV -> Known.AEV + AEW -> Known.AEW + AEX -> Known.AEX + AEY -> Known.AEY + AEZ -> Known.AEZ + AJ -> Known.AJ + AU -> Known.AU + CA -> Known.CA + CAB -> Known.CAB + CAD -> Known.CAD + CAE -> Known.CAE + CAF -> Known.CAF + CAI -> Known.CAI + CAJ -> Known.CAJ + CAK -> Known.CAK + CAL -> Known.CAL + CAM -> Known.CAM + CAN -> Known.CAN + CAO -> Known.CAO + CAP -> Known.CAP + CAQ -> Known.CAQ + CAR -> Known.CAR + CAS -> Known.CAS + CAT -> Known.CAT + CAU -> Known.CAU + CAV -> Known.CAV + CAW -> Known.CAW + CAX -> Known.CAX + CAY -> Known.CAY + CAZ -> Known.CAZ + CD -> Known.CD + CG -> Known.CG + CS -> Known.CS + CT -> Known.CT + DAB -> Known.DAB + DAC -> Known.DAC + DAD -> Known.DAD + DAF -> Known.DAF + DAG -> Known.DAG + DAH -> Known.DAH + DAI -> Known.DAI + DAJ -> Known.DAJ + DAK -> Known.DAK + DAL -> Known.DAL + DAM -> Known.DAM + DAN -> Known.DAN + DAO -> Known.DAO + DAP -> Known.DAP + DAQ -> Known.DAQ + DL -> Known.DL + EG -> Known.EG + EP -> Known.EP + ER -> Known.ER + FAA -> Known.FAA + FAB -> Known.FAB + FAC -> Known.FAC + FC -> Known.FC + FH -> Known.FH + FI -> Known.FI + GAA -> Known.GAA + HAA -> Known.HAA + HD -> Known.HD + HH -> Known.HH + IAA -> Known.IAA + IAB -> Known.IAB + ID -> Known.ID + IF -> Known.IF + IR -> Known.IR + IS -> Known.IS + KO -> Known.KO + L1 -> Known.L1 + LA -> Known.LA + LAA -> Known.LAA + LAB -> Known.LAB + LF -> Known.LF + MAE -> Known.MAE + MI -> Known.MI + ML -> Known.ML + NAA -> Known.NAA + OA -> Known.OA + PA -> Known.PA + PAA -> Known.PAA + PC -> Known.PC + PL -> Known.PL + PRV -> Known.PRV + RAB -> Known.RAB + RAC -> Known.RAC + RAD -> Known.RAD + RAF -> Known.RAF + RE -> Known.RE + RF -> Known.RF + RH -> Known.RH + RV -> Known.RV + SA -> Known.SA + SAA -> Known.SAA + SAD -> Known.SAD + SAE -> Known.SAE + SAI -> Known.SAI + SG -> Known.SG + SH -> Known.SH + SM -> Known.SM + SU -> Known.SU + TAB -> Known.TAB + TAC -> Known.TAC + TT -> Known.TT + TV -> Known.TV + V1 -> Known.V1 + V2 -> Known.V2 + WH -> Known.WH + XAA -> Known.XAA + YY -> Known.YY + ZZZ -> Known.ZZZ + else -> throw EInvoiceInvalidDataException("Unknown ReasonCode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReasonCode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReasonCode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + /** * Duty or tax or fee category codes (Subset of UNCL5305) * diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt index 5828329..14cbd5a 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt @@ -2369,9 +2369,9 @@ private constructor( private val baseAmount: JsonField, private val multiplierFactor: JsonField, private val reason: JsonField, - private val reasonCode: JsonField, + private val reasonCode: JsonField, private val taxCode: JsonField, - private val taxRate: JsonField, + private val taxRate: JsonField, private val additionalProperties: MutableMap, ) { @@ -2387,11 +2387,11 @@ private constructor( @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), @JsonProperty("reason_code") @ExcludeMissing - reasonCode: JsonField = JsonMissing.of(), + reasonCode: JsonField = JsonMissing.of(), @JsonProperty("tax_code") @ExcludeMissing taxCode: JsonField = JsonMissing.of(), - @JsonProperty("tax_rate") @ExcludeMissing taxRate: JsonField = JsonMissing.of(), + @JsonProperty("tax_rate") @ExcludeMissing taxRate: JsonField = JsonMissing.of(), ) : this( amount, baseAmount, @@ -2422,7 +2422,8 @@ private constructor( /** * The percentage that may be used, in conjunction with the allowance base amount, to - * calculate the allowance amount. To state 20%, use value 20 + * calculate the allowance amount. To state 20%, use value 20. Must be rounded to maximum 2 + * decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -2439,17 +2440,15 @@ private constructor( fun reason(): Optional = reason.getOptional("reason") /** - * The code for the allowance reason + * Allowance reason codes for invoice discounts and charges * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun reasonCode(): Optional = reasonCode.getOptional("reason_code") + fun reasonCode(): Optional = reasonCode.getOptional("reason_code") /** - * Duty or tax or fee category codes (Subset of UNCL5305) - * - * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + * The VAT category code that applies to the allowance * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -2457,12 +2456,13 @@ private constructor( fun taxCode(): Optional = taxCode.getOptional("tax_code") /** - * The VAT rate, represented as percentage that applies to the allowance + * The VAT rate, represented as percentage that applies to the allowance. Must be rounded to + * maximum 2 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun taxRate(): Optional = taxRate.getOptional("tax_rate") + fun taxRate(): Optional = taxRate.getOptional("tax_rate") /** * Returns the raw JSON value of [amount]. @@ -2504,7 +2504,7 @@ private constructor( */ @JsonProperty("reason_code") @ExcludeMissing - fun _reasonCode(): JsonField = reasonCode + fun _reasonCode(): JsonField = reasonCode /** * Returns the raw JSON value of [taxCode]. @@ -2518,7 +2518,7 @@ private constructor( * * Unlike [taxRate], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate + @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -2545,9 +2545,9 @@ private constructor( private var baseAmount: JsonField = JsonMissing.of() private var multiplierFactor: JsonField = JsonMissing.of() private var reason: JsonField = JsonMissing.of() - private var reasonCode: JsonField = JsonMissing.of() + private var reasonCode: JsonField = JsonMissing.of() private var taxCode: JsonField = JsonMissing.of() - private var taxRate: JsonField = JsonMissing.of() + private var taxRate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2611,7 +2611,8 @@ private constructor( /** * The percentage that may be used, in conjunction with the allowance base amount, to - * calculate the allowance amount. To state 20%, use value 20 + * calculate the allowance amount. To state 20%, use value 20. Must be rounded to + * maximum 2 decimals */ fun multiplierFactor(multiplierFactor: MultiplierFactor?) = multiplierFactor(JsonField.ofNullable(multiplierFactor)) @@ -2656,30 +2657,25 @@ private constructor( */ fun reason(reason: JsonField) = apply { this.reason = reason } - /** The code for the allowance reason */ - fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) + /** Allowance reason codes for invoice discounts and charges */ + fun reasonCode(reasonCode: ReasonCode?) = reasonCode(JsonField.ofNullable(reasonCode)) /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ - fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) + fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) /** * Sets [Builder.reasonCode] to an arbitrary JSON value. * - * You should usually call [Builder.reasonCode] with a well-typed [String] value + * You should usually call [Builder.reasonCode] with a well-typed [ReasonCode] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode } - - /** - * Duty or tax or fee category codes (Subset of UNCL5305) - * - * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL - */ - fun taxCode(taxCode: TaxCode?) = taxCode(JsonField.ofNullable(taxCode)) + fun reasonCode(reasonCode: JsonField) = apply { + this.reasonCode = reasonCode + } - /** Alias for calling [Builder.taxCode] with `taxCode.orElse(null)`. */ - fun taxCode(taxCode: Optional) = taxCode(taxCode.getOrNull()) + /** The VAT category code that applies to the allowance */ + fun taxCode(taxCode: TaxCode) = taxCode(JsonField.of(taxCode)) /** * Sets [Builder.taxCode] to an arbitrary JSON value. @@ -2690,20 +2686,29 @@ private constructor( */ fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } - /** The VAT rate, represented as percentage that applies to the allowance */ - fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) + /** + * The VAT rate, represented as percentage that applies to the allowance. Must be + * rounded to maximum 2 decimals + */ + fun taxRate(taxRate: TaxRate?) = taxRate(JsonField.ofNullable(taxRate)) /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ - fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) + fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) /** * Sets [Builder.taxRate] to an arbitrary JSON value. * - * You should usually call [Builder.taxRate] with a well-typed [String] value instead. + * You should usually call [Builder.taxRate] with a well-typed [TaxRate] value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } + fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } + + /** Alias for calling [taxRate] with `TaxRate.ofNumber(number)`. */ + fun taxRate(number: Double) = taxRate(TaxRate.ofNumber(number)) + + /** Alias for calling [taxRate] with `TaxRate.ofString(string)`. */ + fun taxRate(string: String) = taxRate(TaxRate.ofString(string)) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2753,9 +2758,9 @@ private constructor( baseAmount().ifPresent { it.validate() } multiplierFactor().ifPresent { it.validate() } reason() - reasonCode() + reasonCode().ifPresent { it.validate() } taxCode().ifPresent { it.validate() } - taxRate() + taxRate().ifPresent { it.validate() } validated = true } @@ -2779,9 +2784,9 @@ private constructor( (baseAmount.asKnown().getOrNull()?.validity() ?: 0) + (multiplierFactor.asKnown().getOrNull()?.validity() ?: 0) + (if (reason.asKnown().isPresent) 1 else 0) + - (if (reasonCode.asKnown().isPresent) 1 else 0) + + (reasonCode.asKnown().getOrNull()?.validity() ?: 0) + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + - (if (taxRate.asKnown().isPresent) 1 else 0) + (taxRate.asKnown().getOrNull()?.validity() ?: 0) /** The allowance amount, without VAT. Must be rounded to maximum 2 decimals */ @JsonDeserialize(using = Amount.Deserializer::class) @@ -3129,7 +3134,8 @@ private constructor( /** * The percentage that may be used, in conjunction with the allowance base amount, to - * calculate the allowance amount. To state 20%, use value 20 + * calculate the allowance amount. To state 20%, use value 20. Must be rounded to maximum 2 + * decimals */ @JsonDeserialize(using = MultiplierFactor.Deserializer::class) @JsonSerialize(using = MultiplierFactor.Serializer::class) @@ -3302,11 +3308,241 @@ private constructor( } } - /** - * Duty or tax or fee category codes (Subset of UNCL5305) - * - * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL - */ + /** Allowance reason codes for invoice discounts and charges */ + class ReasonCode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val _41 = of("41") + + @JvmField val _42 = of("42") + + @JvmField val _60 = of("60") + + @JvmField val _62 = of("62") + + @JvmField val _63 = of("63") + + @JvmField val _64 = of("64") + + @JvmField val _65 = of("65") + + @JvmField val _66 = of("66") + + @JvmField val _67 = of("67") + + @JvmField val _68 = of("68") + + @JvmField val _70 = of("70") + + @JvmField val _71 = of("71") + + @JvmField val _88 = of("88") + + @JvmField val _95 = of("95") + + @JvmField val _100 = of("100") + + @JvmField val _102 = of("102") + + @JvmField val _103 = of("103") + + @JvmField val _104 = of("104") + + @JvmField val _105 = of("105") + + @JvmStatic fun of(value: String) = ReasonCode(JsonField.of(value)) + } + + /** An enum containing [ReasonCode]'s known values. */ + enum class Known { + _41, + _42, + _60, + _62, + _63, + _64, + _65, + _66, + _67, + _68, + _70, + _71, + _88, + _95, + _100, + _102, + _103, + _104, + _105, + } + + /** + * An enum containing [ReasonCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ReasonCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + _41, + _42, + _60, + _62, + _63, + _64, + _65, + _66, + _67, + _68, + _70, + _71, + _88, + _95, + _100, + _102, + _103, + _104, + _105, + /** + * An enum member indicating that [ReasonCode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + _41 -> Value._41 + _42 -> Value._42 + _60 -> Value._60 + _62 -> Value._62 + _63 -> Value._63 + _64 -> Value._64 + _65 -> Value._65 + _66 -> Value._66 + _67 -> Value._67 + _68 -> Value._68 + _70 -> Value._70 + _71 -> Value._71 + _88 -> Value._88 + _95 -> Value._95 + _100 -> Value._100 + _102 -> Value._102 + _103 -> Value._103 + _104 -> Value._104 + _105 -> Value._105 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + _41 -> Known._41 + _42 -> Known._42 + _60 -> Known._60 + _62 -> Known._62 + _63 -> Known._63 + _64 -> Known._64 + _65 -> Known._65 + _66 -> Known._66 + _67 -> Known._67 + _68 -> Known._68 + _70 -> Known._70 + _71 -> Known._71 + _88 -> Known._88 + _95 -> Known._95 + _100 -> Known._100 + _102 -> Known._102 + _103 -> Known._103 + _104 -> Known._104 + _105 -> Known._105 + else -> throw EInvoiceInvalidDataException("Unknown ReasonCode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReasonCode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReasonCode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The VAT category code that applies to the allowance */ class TaxCode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3485,88 +3721,262 @@ private constructor( override fun toString() = value.toString() } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Allowance && - amount == other.amount && - baseAmount == other.baseAmount && - multiplierFactor == other.multiplierFactor && - reason == other.reason && - reasonCode == other.reasonCode && - taxCode == other.taxCode && - taxRate == other.taxRate && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - amount, - baseAmount, - multiplierFactor, - reason, - reasonCode, - taxCode, - taxRate, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode + /** + * The VAT rate, represented as percentage that applies to the allowance. Must be rounded to + * maximum 2 decimals + */ + @JsonDeserialize(using = TaxRate.Deserializer::class) + @JsonSerialize(using = TaxRate.Serializer::class) + class TaxRate + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { - override fun toString() = - "Allowance{amount=$amount, baseAmount=$baseAmount, multiplierFactor=$multiplierFactor, reason=$reason, reasonCode=$reasonCode, taxCode=$taxCode, taxRate=$taxRate, additionalProperties=$additionalProperties}" - } + fun number(): Optional = Optional.ofNullable(number) - /** The amount due for payment. Must be positive and rounded to maximum 2 decimals */ - @JsonDeserialize(using = AmountDue.Deserializer::class) - @JsonSerialize(using = AmountDue.Serializer::class) - class AmountDue - private constructor( - private val number: Double? = null, - private val string: String? = null, - private val _json: JsonValue? = null, - ) { + fun string(): Optional = Optional.ofNullable(string) - fun number(): Optional = Optional.ofNullable(number) + fun isNumber(): Boolean = number != null - fun string(): Optional = Optional.ofNullable(string) + fun isString(): Boolean = string != null - fun isNumber(): Boolean = number != null + fun asNumber(): Double = number.getOrThrow("number") - fun isString(): Boolean = string != null + fun asString(): String = string.getOrThrow("string") - fun asNumber(): Double = number.getOrThrow("number") + fun _json(): Optional = Optional.ofNullable(_json) - fun asString(): String = string.getOrThrow("string") + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } - fun _json(): Optional = Optional.ofNullable(_json) + private var validated: Boolean = false - fun accept(visitor: Visitor): T = - when { - number != null -> visitor.visitNumber(number) - string != null -> visitor.visitString(string) - else -> visitor.unknown(_json) - } + fun validate(): TaxRate = apply { + if (validated) { + return@apply + } - private var validated: Boolean = false + accept( + object : Visitor { + override fun visitNumber(number: Double) {} - fun validate(): AmountDue = apply { - if (validated) { - return@apply + override fun visitString(string: String) {} + } + ) + validated = true } - accept( - object : Visitor { - override fun visitNumber(number: Double) {} - - override fun visitString(string: String) {} + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false } - ) - validated = true - } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TaxRate && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "TaxRate{number=$number}" + string != null -> "TaxRate{string=$string}" + _json != null -> "TaxRate{_unknown=$_json}" + else -> throw IllegalStateException("Invalid TaxRate") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = TaxRate(number = number) + + @JvmStatic fun ofString(string: String) = TaxRate(string = string) + } + + /** + * An interface that defines how to map each variant of [TaxRate] to a value of type + * [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [TaxRate] to a value of type [T]. + * + * An instance of [TaxRate] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws EInvoiceInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw EInvoiceInvalidDataException("Unknown TaxRate: $json") + } + } + + internal class Deserializer : BaseDeserializer(TaxRate::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): TaxRate { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + TaxRate(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + TaxRate(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> TaxRate(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(TaxRate::class) { + + override fun serialize( + value: TaxRate, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid TaxRate") + } + } + } + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Allowance && + amount == other.amount && + baseAmount == other.baseAmount && + multiplierFactor == other.multiplierFactor && + reason == other.reason && + reasonCode == other.reasonCode && + taxCode == other.taxCode && + taxRate == other.taxRate && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + amount, + baseAmount, + multiplierFactor, + reason, + reasonCode, + taxCode, + taxRate, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Allowance{amount=$amount, baseAmount=$baseAmount, multiplierFactor=$multiplierFactor, reason=$reason, reasonCode=$reasonCode, taxCode=$taxCode, taxRate=$taxRate, additionalProperties=$additionalProperties}" + } + + /** The amount due for payment. Must be positive and rounded to maximum 2 decimals */ + @JsonDeserialize(using = AmountDue.Deserializer::class) + @JsonSerialize(using = AmountDue.Serializer::class) + class AmountDue + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): AmountDue = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } fun isValid(): Boolean = try { @@ -3698,9 +4108,9 @@ private constructor( private val baseAmount: JsonField, private val multiplierFactor: JsonField, private val reason: JsonField, - private val reasonCode: JsonField, + private val reasonCode: JsonField, private val taxCode: JsonField, - private val taxRate: JsonField, + private val taxRate: JsonField, private val additionalProperties: MutableMap, ) { @@ -3716,11 +4126,11 @@ private constructor( @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), @JsonProperty("reason_code") @ExcludeMissing - reasonCode: JsonField = JsonMissing.of(), + reasonCode: JsonField = JsonMissing.of(), @JsonProperty("tax_code") @ExcludeMissing taxCode: JsonField = JsonMissing.of(), - @JsonProperty("tax_rate") @ExcludeMissing taxRate: JsonField = JsonMissing.of(), + @JsonProperty("tax_rate") @ExcludeMissing taxRate: JsonField = JsonMissing.of(), ) : this( amount, baseAmount, @@ -3768,12 +4178,12 @@ private constructor( fun reason(): Optional = reason.getOptional("reason") /** - * The code for the charge reason + * Charge reason codes for invoice charges and fees * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun reasonCode(): Optional = reasonCode.getOptional("reason_code") + fun reasonCode(): Optional = reasonCode.getOptional("reason_code") /** * Duty or tax or fee category codes (Subset of UNCL5305) @@ -3791,7 +4201,7 @@ private constructor( * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun taxRate(): Optional = taxRate.getOptional("tax_rate") + fun taxRate(): Optional = taxRate.getOptional("tax_rate") /** * Returns the raw JSON value of [amount]. @@ -3833,7 +4243,7 @@ private constructor( */ @JsonProperty("reason_code") @ExcludeMissing - fun _reasonCode(): JsonField = reasonCode + fun _reasonCode(): JsonField = reasonCode /** * Returns the raw JSON value of [taxCode]. @@ -3847,7 +4257,7 @@ private constructor( * * Unlike [taxRate], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate + @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -3874,9 +4284,9 @@ private constructor( private var baseAmount: JsonField = JsonMissing.of() private var multiplierFactor: JsonField = JsonMissing.of() private var reason: JsonField = JsonMissing.of() - private var reasonCode: JsonField = JsonMissing.of() + private var reasonCode: JsonField = JsonMissing.of() private var taxCode: JsonField = JsonMissing.of() - private var taxRate: JsonField = JsonMissing.of() + private var taxRate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3985,20 +4395,22 @@ private constructor( */ fun reason(reason: JsonField) = apply { this.reason = reason } - /** The code for the charge reason */ - fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) + /** Charge reason codes for invoice charges and fees */ + fun reasonCode(reasonCode: ReasonCode?) = reasonCode(JsonField.ofNullable(reasonCode)) /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ - fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) + fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) /** * Sets [Builder.reasonCode] to an arbitrary JSON value. * - * You should usually call [Builder.reasonCode] with a well-typed [String] value + * You should usually call [Builder.reasonCode] with a well-typed [ReasonCode] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode } + fun reasonCode(reasonCode: JsonField) = apply { + this.reasonCode = reasonCode + } /** * Duty or tax or fee category codes (Subset of UNCL5305) @@ -4020,19 +4432,25 @@ private constructor( fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } /** The VAT rate, represented as percentage that applies to the charge */ - fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) + fun taxRate(taxRate: TaxRate?) = taxRate(JsonField.ofNullable(taxRate)) /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ - fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) + fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) /** * Sets [Builder.taxRate] to an arbitrary JSON value. * - * You should usually call [Builder.taxRate] with a well-typed [String] value instead. + * You should usually call [Builder.taxRate] with a well-typed [TaxRate] value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } + fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } + + /** Alias for calling [taxRate] with `TaxRate.ofNumber(number)`. */ + fun taxRate(number: Double) = taxRate(TaxRate.ofNumber(number)) + + /** Alias for calling [taxRate] with `TaxRate.ofString(string)`. */ + fun taxRate(string: String) = taxRate(TaxRate.ofString(string)) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -4082,9 +4500,9 @@ private constructor( baseAmount().ifPresent { it.validate() } multiplierFactor().ifPresent { it.validate() } reason() - reasonCode() + reasonCode().ifPresent { it.validate() } taxCode().ifPresent { it.validate() } - taxRate() + taxRate().ifPresent { it.validate() } validated = true } @@ -4108,9 +4526,9 @@ private constructor( (baseAmount.asKnown().getOrNull()?.validity() ?: 0) + (multiplierFactor.asKnown().getOrNull()?.validity() ?: 0) + (if (reason.asKnown().isPresent) 1 else 0) + - (if (reasonCode.asKnown().isPresent) 1 else 0) + + (reasonCode.asKnown().getOrNull()?.validity() ?: 0) + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + - (if (taxRate.asKnown().isPresent) 1 else 0) + (taxRate.asKnown().getOrNull()?.validity() ?: 0) /** The charge amount, without VAT. Must be rounded to maximum 2 decimals */ @JsonDeserialize(using = Amount.Deserializer::class) @@ -4631,12 +5049,8 @@ private constructor( } } - /** - * Duty or tax or fee category codes (Subset of UNCL5305) - * - * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL - */ - class TaxCode @JsonCreator private constructor(private val value: JsonField) : + /** Charge reason codes for invoice charges and fees */ + class ReasonCode @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -4651,87 +5065,1279 @@ private constructor( companion object { - @JvmField val AE = of("AE") + @JvmField val AA = of("AA") - @JvmField val E = of("E") + @JvmField val AAA = of("AAA") - @JvmField val S = of("S") + @JvmField val AAC = of("AAC") - @JvmField val Z = of("Z") + @JvmField val AAD = of("AAD") - @JvmField val G = of("G") + @JvmField val AAE = of("AAE") - @JvmField val O = of("O") + @JvmField val AAF = of("AAF") - @JvmField val K = of("K") + @JvmField val AAH = of("AAH") - @JvmField val L = of("L") + @JvmField val AAI = of("AAI") - @JvmField val M = of("M") + @JvmField val AAS = of("AAS") - @JvmField val B = of("B") + @JvmField val AAT = of("AAT") - @JvmStatic fun of(value: String) = TaxCode(JsonField.of(value)) - } + @JvmField val AAV = of("AAV") - /** An enum containing [TaxCode]'s known values. */ - enum class Known { - AE, - E, - S, - Z, - G, - O, - K, - L, - M, - B, - } + @JvmField val AAY = of("AAY") - /** - * An enum containing [TaxCode]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [TaxCode] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - AE, - E, - S, - Z, - G, - O, - K, - L, - M, - B, - /** - * An enum member indicating that [TaxCode] was instantiated with an unknown value. - */ - _UNKNOWN, - } + @JvmField val AAZ = of("AAZ") - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - AE -> Value.AE - E -> Value.E - S -> Value.S - Z -> Value.Z - G -> Value.G - O -> Value.O - K -> Value.K - L -> Value.L - M -> Value.M + @JvmField val ABA = of("ABA") + + @JvmField val ABB = of("ABB") + + @JvmField val ABC = of("ABC") + + @JvmField val ABD = of("ABD") + + @JvmField val ABF = of("ABF") + + @JvmField val ABK = of("ABK") + + @JvmField val ABL = of("ABL") + + @JvmField val ABN = of("ABN") + + @JvmField val ABR = of("ABR") + + @JvmField val ABS = of("ABS") + + @JvmField val ABT = of("ABT") + + @JvmField val ABU = of("ABU") + + @JvmField val ACF = of("ACF") + + @JvmField val ACG = of("ACG") + + @JvmField val ACH = of("ACH") + + @JvmField val ACI = of("ACI") + + @JvmField val ACJ = of("ACJ") + + @JvmField val ACK = of("ACK") + + @JvmField val ACL = of("ACL") + + @JvmField val ACM = of("ACM") + + @JvmField val ACS = of("ACS") + + @JvmField val ADC = of("ADC") + + @JvmField val ADE = of("ADE") + + @JvmField val ADJ = of("ADJ") + + @JvmField val ADK = of("ADK") + + @JvmField val ADL = of("ADL") + + @JvmField val ADM = of("ADM") + + @JvmField val ADN = of("ADN") + + @JvmField val ADO = of("ADO") + + @JvmField val ADP = of("ADP") + + @JvmField val ADQ = of("ADQ") + + @JvmField val ADR = of("ADR") + + @JvmField val ADT = of("ADT") + + @JvmField val ADW = of("ADW") + + @JvmField val ADY = of("ADY") + + @JvmField val ADZ = of("ADZ") + + @JvmField val AEA = of("AEA") + + @JvmField val AEB = of("AEB") + + @JvmField val AEC = of("AEC") + + @JvmField val AED = of("AED") + + @JvmField val AEF = of("AEF") + + @JvmField val AEH = of("AEH") + + @JvmField val AEI = of("AEI") + + @JvmField val AEJ = of("AEJ") + + @JvmField val AEK = of("AEK") + + @JvmField val AEL = of("AEL") + + @JvmField val AEM = of("AEM") + + @JvmField val AEN = of("AEN") + + @JvmField val AEO = of("AEO") + + @JvmField val AEP = of("AEP") + + @JvmField val AES = of("AES") + + @JvmField val AET = of("AET") + + @JvmField val AEU = of("AEU") + + @JvmField val AEV = of("AEV") + + @JvmField val AEW = of("AEW") + + @JvmField val AEX = of("AEX") + + @JvmField val AEY = of("AEY") + + @JvmField val AEZ = of("AEZ") + + @JvmField val AJ = of("AJ") + + @JvmField val AU = of("AU") + + @JvmField val CA = of("CA") + + @JvmField val CAB = of("CAB") + + @JvmField val CAD = of("CAD") + + @JvmField val CAE = of("CAE") + + @JvmField val CAF = of("CAF") + + @JvmField val CAI = of("CAI") + + @JvmField val CAJ = of("CAJ") + + @JvmField val CAK = of("CAK") + + @JvmField val CAL = of("CAL") + + @JvmField val CAM = of("CAM") + + @JvmField val CAN = of("CAN") + + @JvmField val CAO = of("CAO") + + @JvmField val CAP = of("CAP") + + @JvmField val CAQ = of("CAQ") + + @JvmField val CAR = of("CAR") + + @JvmField val CAS = of("CAS") + + @JvmField val CAT = of("CAT") + + @JvmField val CAU = of("CAU") + + @JvmField val CAV = of("CAV") + + @JvmField val CAW = of("CAW") + + @JvmField val CAX = of("CAX") + + @JvmField val CAY = of("CAY") + + @JvmField val CAZ = of("CAZ") + + @JvmField val CD = of("CD") + + @JvmField val CG = of("CG") + + @JvmField val CS = of("CS") + + @JvmField val CT = of("CT") + + @JvmField val DAB = of("DAB") + + @JvmField val DAC = of("DAC") + + @JvmField val DAD = of("DAD") + + @JvmField val DAF = of("DAF") + + @JvmField val DAG = of("DAG") + + @JvmField val DAH = of("DAH") + + @JvmField val DAI = of("DAI") + + @JvmField val DAJ = of("DAJ") + + @JvmField val DAK = of("DAK") + + @JvmField val DAL = of("DAL") + + @JvmField val DAM = of("DAM") + + @JvmField val DAN = of("DAN") + + @JvmField val DAO = of("DAO") + + @JvmField val DAP = of("DAP") + + @JvmField val DAQ = of("DAQ") + + @JvmField val DL = of("DL") + + @JvmField val EG = of("EG") + + @JvmField val EP = of("EP") + + @JvmField val ER = of("ER") + + @JvmField val FAA = of("FAA") + + @JvmField val FAB = of("FAB") + + @JvmField val FAC = of("FAC") + + @JvmField val FC = of("FC") + + @JvmField val FH = of("FH") + + @JvmField val FI = of("FI") + + @JvmField val GAA = of("GAA") + + @JvmField val HAA = of("HAA") + + @JvmField val HD = of("HD") + + @JvmField val HH = of("HH") + + @JvmField val IAA = of("IAA") + + @JvmField val IAB = of("IAB") + + @JvmField val ID = of("ID") + + @JvmField val IF = of("IF") + + @JvmField val IR = of("IR") + + @JvmField val IS = of("IS") + + @JvmField val KO = of("KO") + + @JvmField val L1 = of("L1") + + @JvmField val LA = of("LA") + + @JvmField val LAA = of("LAA") + + @JvmField val LAB = of("LAB") + + @JvmField val LF = of("LF") + + @JvmField val MAE = of("MAE") + + @JvmField val MI = of("MI") + + @JvmField val ML = of("ML") + + @JvmField val NAA = of("NAA") + + @JvmField val OA = of("OA") + + @JvmField val PA = of("PA") + + @JvmField val PAA = of("PAA") + + @JvmField val PC = of("PC") + + @JvmField val PL = of("PL") + + @JvmField val PRV = of("PRV") + + @JvmField val RAB = of("RAB") + + @JvmField val RAC = of("RAC") + + @JvmField val RAD = of("RAD") + + @JvmField val RAF = of("RAF") + + @JvmField val RE = of("RE") + + @JvmField val RF = of("RF") + + @JvmField val RH = of("RH") + + @JvmField val RV = of("RV") + + @JvmField val SA = of("SA") + + @JvmField val SAA = of("SAA") + + @JvmField val SAD = of("SAD") + + @JvmField val SAE = of("SAE") + + @JvmField val SAI = of("SAI") + + @JvmField val SG = of("SG") + + @JvmField val SH = of("SH") + + @JvmField val SM = of("SM") + + @JvmField val SU = of("SU") + + @JvmField val TAB = of("TAB") + + @JvmField val TAC = of("TAC") + + @JvmField val TT = of("TT") + + @JvmField val TV = of("TV") + + @JvmField val V1 = of("V1") + + @JvmField val V2 = of("V2") + + @JvmField val WH = of("WH") + + @JvmField val XAA = of("XAA") + + @JvmField val YY = of("YY") + + @JvmField val ZZZ = of("ZZZ") + + @JvmStatic fun of(value: String) = ReasonCode(JsonField.of(value)) + } + + /** An enum containing [ReasonCode]'s known values. */ + enum class Known { + AA, + AAA, + AAC, + AAD, + AAE, + AAF, + AAH, + AAI, + AAS, + AAT, + AAV, + AAY, + AAZ, + ABA, + ABB, + ABC, + ABD, + ABF, + ABK, + ABL, + ABN, + ABR, + ABS, + ABT, + ABU, + ACF, + ACG, + ACH, + ACI, + ACJ, + ACK, + ACL, + ACM, + ACS, + ADC, + ADE, + ADJ, + ADK, + ADL, + ADM, + ADN, + ADO, + ADP, + ADQ, + ADR, + ADT, + ADW, + ADY, + ADZ, + AEA, + AEB, + AEC, + AED, + AEF, + AEH, + AEI, + AEJ, + AEK, + AEL, + AEM, + AEN, + AEO, + AEP, + AES, + AET, + AEU, + AEV, + AEW, + AEX, + AEY, + AEZ, + AJ, + AU, + CA, + CAB, + CAD, + CAE, + CAF, + CAI, + CAJ, + CAK, + CAL, + CAM, + CAN, + CAO, + CAP, + CAQ, + CAR, + CAS, + CAT, + CAU, + CAV, + CAW, + CAX, + CAY, + CAZ, + CD, + CG, + CS, + CT, + DAB, + DAC, + DAD, + DAF, + DAG, + DAH, + DAI, + DAJ, + DAK, + DAL, + DAM, + DAN, + DAO, + DAP, + DAQ, + DL, + EG, + EP, + ER, + FAA, + FAB, + FAC, + FC, + FH, + FI, + GAA, + HAA, + HD, + HH, + IAA, + IAB, + ID, + IF, + IR, + IS, + KO, + L1, + LA, + LAA, + LAB, + LF, + MAE, + MI, + ML, + NAA, + OA, + PA, + PAA, + PC, + PL, + PRV, + RAB, + RAC, + RAD, + RAF, + RE, + RF, + RH, + RV, + SA, + SAA, + SAD, + SAE, + SAI, + SG, + SH, + SM, + SU, + TAB, + TAC, + TT, + TV, + V1, + V2, + WH, + XAA, + YY, + ZZZ, + } + + /** + * An enum containing [ReasonCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ReasonCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AA, + AAA, + AAC, + AAD, + AAE, + AAF, + AAH, + AAI, + AAS, + AAT, + AAV, + AAY, + AAZ, + ABA, + ABB, + ABC, + ABD, + ABF, + ABK, + ABL, + ABN, + ABR, + ABS, + ABT, + ABU, + ACF, + ACG, + ACH, + ACI, + ACJ, + ACK, + ACL, + ACM, + ACS, + ADC, + ADE, + ADJ, + ADK, + ADL, + ADM, + ADN, + ADO, + ADP, + ADQ, + ADR, + ADT, + ADW, + ADY, + ADZ, + AEA, + AEB, + AEC, + AED, + AEF, + AEH, + AEI, + AEJ, + AEK, + AEL, + AEM, + AEN, + AEO, + AEP, + AES, + AET, + AEU, + AEV, + AEW, + AEX, + AEY, + AEZ, + AJ, + AU, + CA, + CAB, + CAD, + CAE, + CAF, + CAI, + CAJ, + CAK, + CAL, + CAM, + CAN, + CAO, + CAP, + CAQ, + CAR, + CAS, + CAT, + CAU, + CAV, + CAW, + CAX, + CAY, + CAZ, + CD, + CG, + CS, + CT, + DAB, + DAC, + DAD, + DAF, + DAG, + DAH, + DAI, + DAJ, + DAK, + DAL, + DAM, + DAN, + DAO, + DAP, + DAQ, + DL, + EG, + EP, + ER, + FAA, + FAB, + FAC, + FC, + FH, + FI, + GAA, + HAA, + HD, + HH, + IAA, + IAB, + ID, + IF, + IR, + IS, + KO, + L1, + LA, + LAA, + LAB, + LF, + MAE, + MI, + ML, + NAA, + OA, + PA, + PAA, + PC, + PL, + PRV, + RAB, + RAC, + RAD, + RAF, + RE, + RF, + RH, + RV, + SA, + SAA, + SAD, + SAE, + SAI, + SG, + SH, + SM, + SU, + TAB, + TAC, + TT, + TV, + V1, + V2, + WH, + XAA, + YY, + ZZZ, + /** + * An enum member indicating that [ReasonCode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AA -> Value.AA + AAA -> Value.AAA + AAC -> Value.AAC + AAD -> Value.AAD + AAE -> Value.AAE + AAF -> Value.AAF + AAH -> Value.AAH + AAI -> Value.AAI + AAS -> Value.AAS + AAT -> Value.AAT + AAV -> Value.AAV + AAY -> Value.AAY + AAZ -> Value.AAZ + ABA -> Value.ABA + ABB -> Value.ABB + ABC -> Value.ABC + ABD -> Value.ABD + ABF -> Value.ABF + ABK -> Value.ABK + ABL -> Value.ABL + ABN -> Value.ABN + ABR -> Value.ABR + ABS -> Value.ABS + ABT -> Value.ABT + ABU -> Value.ABU + ACF -> Value.ACF + ACG -> Value.ACG + ACH -> Value.ACH + ACI -> Value.ACI + ACJ -> Value.ACJ + ACK -> Value.ACK + ACL -> Value.ACL + ACM -> Value.ACM + ACS -> Value.ACS + ADC -> Value.ADC + ADE -> Value.ADE + ADJ -> Value.ADJ + ADK -> Value.ADK + ADL -> Value.ADL + ADM -> Value.ADM + ADN -> Value.ADN + ADO -> Value.ADO + ADP -> Value.ADP + ADQ -> Value.ADQ + ADR -> Value.ADR + ADT -> Value.ADT + ADW -> Value.ADW + ADY -> Value.ADY + ADZ -> Value.ADZ + AEA -> Value.AEA + AEB -> Value.AEB + AEC -> Value.AEC + AED -> Value.AED + AEF -> Value.AEF + AEH -> Value.AEH + AEI -> Value.AEI + AEJ -> Value.AEJ + AEK -> Value.AEK + AEL -> Value.AEL + AEM -> Value.AEM + AEN -> Value.AEN + AEO -> Value.AEO + AEP -> Value.AEP + AES -> Value.AES + AET -> Value.AET + AEU -> Value.AEU + AEV -> Value.AEV + AEW -> Value.AEW + AEX -> Value.AEX + AEY -> Value.AEY + AEZ -> Value.AEZ + AJ -> Value.AJ + AU -> Value.AU + CA -> Value.CA + CAB -> Value.CAB + CAD -> Value.CAD + CAE -> Value.CAE + CAF -> Value.CAF + CAI -> Value.CAI + CAJ -> Value.CAJ + CAK -> Value.CAK + CAL -> Value.CAL + CAM -> Value.CAM + CAN -> Value.CAN + CAO -> Value.CAO + CAP -> Value.CAP + CAQ -> Value.CAQ + CAR -> Value.CAR + CAS -> Value.CAS + CAT -> Value.CAT + CAU -> Value.CAU + CAV -> Value.CAV + CAW -> Value.CAW + CAX -> Value.CAX + CAY -> Value.CAY + CAZ -> Value.CAZ + CD -> Value.CD + CG -> Value.CG + CS -> Value.CS + CT -> Value.CT + DAB -> Value.DAB + DAC -> Value.DAC + DAD -> Value.DAD + DAF -> Value.DAF + DAG -> Value.DAG + DAH -> Value.DAH + DAI -> Value.DAI + DAJ -> Value.DAJ + DAK -> Value.DAK + DAL -> Value.DAL + DAM -> Value.DAM + DAN -> Value.DAN + DAO -> Value.DAO + DAP -> Value.DAP + DAQ -> Value.DAQ + DL -> Value.DL + EG -> Value.EG + EP -> Value.EP + ER -> Value.ER + FAA -> Value.FAA + FAB -> Value.FAB + FAC -> Value.FAC + FC -> Value.FC + FH -> Value.FH + FI -> Value.FI + GAA -> Value.GAA + HAA -> Value.HAA + HD -> Value.HD + HH -> Value.HH + IAA -> Value.IAA + IAB -> Value.IAB + ID -> Value.ID + IF -> Value.IF + IR -> Value.IR + IS -> Value.IS + KO -> Value.KO + L1 -> Value.L1 + LA -> Value.LA + LAA -> Value.LAA + LAB -> Value.LAB + LF -> Value.LF + MAE -> Value.MAE + MI -> Value.MI + ML -> Value.ML + NAA -> Value.NAA + OA -> Value.OA + PA -> Value.PA + PAA -> Value.PAA + PC -> Value.PC + PL -> Value.PL + PRV -> Value.PRV + RAB -> Value.RAB + RAC -> Value.RAC + RAD -> Value.RAD + RAF -> Value.RAF + RE -> Value.RE + RF -> Value.RF + RH -> Value.RH + RV -> Value.RV + SA -> Value.SA + SAA -> Value.SAA + SAD -> Value.SAD + SAE -> Value.SAE + SAI -> Value.SAI + SG -> Value.SG + SH -> Value.SH + SM -> Value.SM + SU -> Value.SU + TAB -> Value.TAB + TAC -> Value.TAC + TT -> Value.TT + TV -> Value.TV + V1 -> Value.V1 + V2 -> Value.V2 + WH -> Value.WH + XAA -> Value.XAA + YY -> Value.YY + ZZZ -> Value.ZZZ + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + AA -> Known.AA + AAA -> Known.AAA + AAC -> Known.AAC + AAD -> Known.AAD + AAE -> Known.AAE + AAF -> Known.AAF + AAH -> Known.AAH + AAI -> Known.AAI + AAS -> Known.AAS + AAT -> Known.AAT + AAV -> Known.AAV + AAY -> Known.AAY + AAZ -> Known.AAZ + ABA -> Known.ABA + ABB -> Known.ABB + ABC -> Known.ABC + ABD -> Known.ABD + ABF -> Known.ABF + ABK -> Known.ABK + ABL -> Known.ABL + ABN -> Known.ABN + ABR -> Known.ABR + ABS -> Known.ABS + ABT -> Known.ABT + ABU -> Known.ABU + ACF -> Known.ACF + ACG -> Known.ACG + ACH -> Known.ACH + ACI -> Known.ACI + ACJ -> Known.ACJ + ACK -> Known.ACK + ACL -> Known.ACL + ACM -> Known.ACM + ACS -> Known.ACS + ADC -> Known.ADC + ADE -> Known.ADE + ADJ -> Known.ADJ + ADK -> Known.ADK + ADL -> Known.ADL + ADM -> Known.ADM + ADN -> Known.ADN + ADO -> Known.ADO + ADP -> Known.ADP + ADQ -> Known.ADQ + ADR -> Known.ADR + ADT -> Known.ADT + ADW -> Known.ADW + ADY -> Known.ADY + ADZ -> Known.ADZ + AEA -> Known.AEA + AEB -> Known.AEB + AEC -> Known.AEC + AED -> Known.AED + AEF -> Known.AEF + AEH -> Known.AEH + AEI -> Known.AEI + AEJ -> Known.AEJ + AEK -> Known.AEK + AEL -> Known.AEL + AEM -> Known.AEM + AEN -> Known.AEN + AEO -> Known.AEO + AEP -> Known.AEP + AES -> Known.AES + AET -> Known.AET + AEU -> Known.AEU + AEV -> Known.AEV + AEW -> Known.AEW + AEX -> Known.AEX + AEY -> Known.AEY + AEZ -> Known.AEZ + AJ -> Known.AJ + AU -> Known.AU + CA -> Known.CA + CAB -> Known.CAB + CAD -> Known.CAD + CAE -> Known.CAE + CAF -> Known.CAF + CAI -> Known.CAI + CAJ -> Known.CAJ + CAK -> Known.CAK + CAL -> Known.CAL + CAM -> Known.CAM + CAN -> Known.CAN + CAO -> Known.CAO + CAP -> Known.CAP + CAQ -> Known.CAQ + CAR -> Known.CAR + CAS -> Known.CAS + CAT -> Known.CAT + CAU -> Known.CAU + CAV -> Known.CAV + CAW -> Known.CAW + CAX -> Known.CAX + CAY -> Known.CAY + CAZ -> Known.CAZ + CD -> Known.CD + CG -> Known.CG + CS -> Known.CS + CT -> Known.CT + DAB -> Known.DAB + DAC -> Known.DAC + DAD -> Known.DAD + DAF -> Known.DAF + DAG -> Known.DAG + DAH -> Known.DAH + DAI -> Known.DAI + DAJ -> Known.DAJ + DAK -> Known.DAK + DAL -> Known.DAL + DAM -> Known.DAM + DAN -> Known.DAN + DAO -> Known.DAO + DAP -> Known.DAP + DAQ -> Known.DAQ + DL -> Known.DL + EG -> Known.EG + EP -> Known.EP + ER -> Known.ER + FAA -> Known.FAA + FAB -> Known.FAB + FAC -> Known.FAC + FC -> Known.FC + FH -> Known.FH + FI -> Known.FI + GAA -> Known.GAA + HAA -> Known.HAA + HD -> Known.HD + HH -> Known.HH + IAA -> Known.IAA + IAB -> Known.IAB + ID -> Known.ID + IF -> Known.IF + IR -> Known.IR + IS -> Known.IS + KO -> Known.KO + L1 -> Known.L1 + LA -> Known.LA + LAA -> Known.LAA + LAB -> Known.LAB + LF -> Known.LF + MAE -> Known.MAE + MI -> Known.MI + ML -> Known.ML + NAA -> Known.NAA + OA -> Known.OA + PA -> Known.PA + PAA -> Known.PAA + PC -> Known.PC + PL -> Known.PL + PRV -> Known.PRV + RAB -> Known.RAB + RAC -> Known.RAC + RAD -> Known.RAD + RAF -> Known.RAF + RE -> Known.RE + RF -> Known.RF + RH -> Known.RH + RV -> Known.RV + SA -> Known.SA + SAA -> Known.SAA + SAD -> Known.SAD + SAE -> Known.SAE + SAI -> Known.SAI + SG -> Known.SG + SH -> Known.SH + SM -> Known.SM + SU -> Known.SU + TAB -> Known.TAB + TAC -> Known.TAC + TT -> Known.TT + TV -> Known.TV + V1 -> Known.V1 + V2 -> Known.V2 + WH -> Known.WH + XAA -> Known.XAA + YY -> Known.YY + ZZZ -> Known.ZZZ + else -> throw EInvoiceInvalidDataException("Unknown ReasonCode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReasonCode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReasonCode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Duty or tax or fee category codes (Subset of UNCL5305) + * + * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + */ + class TaxCode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val AE = of("AE") + + @JvmField val E = of("E") + + @JvmField val S = of("S") + + @JvmField val Z = of("Z") + + @JvmField val G = of("G") + + @JvmField val O = of("O") + + @JvmField val K = of("K") + + @JvmField val L = of("L") + + @JvmField val M = of("M") + + @JvmField val B = of("B") + + @JvmStatic fun of(value: String) = TaxCode(JsonField.of(value)) + } + + /** An enum containing [TaxCode]'s known values. */ + enum class Known { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + } + + /** + * An enum containing [TaxCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [TaxCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AE, + E, + S, + Z, + G, + O, + K, + L, + M, + B, + /** + * An enum member indicating that [TaxCode] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AE -> Value.AE + E -> Value.E + S -> Value.S + Z -> Value.Z + G -> Value.G + O -> Value.O + K -> Value.K + L -> Value.L + M -> Value.M B -> Value.B else -> Value._UNKNOWN } @@ -4814,6 +6420,177 @@ private constructor( override fun toString() = value.toString() } + /** The VAT rate, represented as percentage that applies to the charge */ + @JsonDeserialize(using = TaxRate.Deserializer::class) + @JsonSerialize(using = TaxRate.Serializer::class) + class TaxRate + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): TaxRate = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TaxRate && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "TaxRate{number=$number}" + string != null -> "TaxRate{string=$string}" + _json != null -> "TaxRate{_unknown=$_json}" + else -> throw IllegalStateException("Invalid TaxRate") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = TaxRate(number = number) + + @JvmStatic fun ofString(string: String) = TaxRate(string = string) + } + + /** + * An interface that defines how to map each variant of [TaxRate] to a value of type + * [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [TaxRate] to a value of type [T]. + * + * An instance of [TaxRate] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws EInvoiceInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw EInvoiceInvalidDataException("Unknown TaxRate: $json") + } + } + + internal class Deserializer : BaseDeserializer(TaxRate::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): TaxRate { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + TaxRate(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + TaxRate(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> TaxRate(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(TaxRate::class) { + + override fun serialize( + value: TaxRate, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid TaxRate") + } + } + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -5034,7 +6811,7 @@ private constructor( private val productCode: JsonField, private val quantity: JsonField, private val tax: JsonField, - private val taxRate: JsonField, + private val taxRate: JsonField, private val unit: JsonField, private val unitPrice: JsonField, private val additionalProperties: MutableMap, @@ -5060,7 +6837,9 @@ private constructor( @ExcludeMissing quantity: JsonField = JsonMissing.of(), @JsonProperty("tax") @ExcludeMissing tax: JsonField = JsonMissing.of(), - @JsonProperty("tax_rate") @ExcludeMissing taxRate: JsonField = JsonMissing.of(), + @JsonProperty("tax_rate") + @ExcludeMissing + taxRate: JsonField = JsonMissing.of(), @JsonProperty("unit") @ExcludeMissing unit: JsonField = JsonMissing.of(), @@ -5091,8 +6870,10 @@ private constructor( fun allowances(): Optional> = allowances.getOptional("allowances") /** - * The total amount of the line item, exclusive of VAT, after subtracting line level - * allowances and adding line level charges. Must be rounded to maximum 2 decimals + * The invoice line net amount (BT-131), exclusive of VAT, inclusive of line level + * allowances and charges. Calculated as: ((unit_price / price_base_quantity) * quantity) - + * allowances + charges. Must be rounded to maximum 2 decimals. Can be negative for credit + * notes or corrections. * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -5131,7 +6912,7 @@ private constructor( /** * The quantity of items (goods or services) that is the subject of the line item. Must be - * rounded to maximum 4 decimals + * rounded to maximum 4 decimals. Can be negative for credit notes or corrections. * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -5139,7 +6920,8 @@ private constructor( fun quantity(): Optional = quantity.getOptional("quantity") /** - * The total VAT amount for the line item. Must be rounded to maximum 2 decimals + * The total VAT amount for the line item. Must be rounded to maximum 2 decimals. Can be + * negative for credit notes or corrections. * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -5152,7 +6934,7 @@ private constructor( * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun taxRate(): Optional = taxRate.getOptional("tax_rate") + fun taxRate(): Optional = taxRate.getOptional("tax_rate") /** * Unit of Measure Codes from UNECERec20 used in Peppol BIS Billing 3.0. @@ -5163,7 +6945,8 @@ private constructor( fun unit(): Optional = unit.getOptional("unit") /** - * The unit price of the line item. Must be rounded to maximum 2 decimals + * The item net price (BT-146). The price of an item, exclusive of VAT, after subtracting + * item price discount. Must be rounded to maximum 4 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -5237,7 +7020,7 @@ private constructor( * * Unlike [taxRate], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate + @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate /** * Returns the raw JSON value of [unit]. @@ -5284,7 +7067,7 @@ private constructor( private var productCode: JsonField = JsonMissing.of() private var quantity: JsonField = JsonMissing.of() private var tax: JsonField = JsonMissing.of() - private var taxRate: JsonField = JsonMissing.of() + private var taxRate: JsonField = JsonMissing.of() private var unit: JsonField = JsonMissing.of() private var unitPrice: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -5337,8 +7120,10 @@ private constructor( } /** - * The total amount of the line item, exclusive of VAT, after subtracting line level - * allowances and adding line level charges. Must be rounded to maximum 2 decimals + * The invoice line net amount (BT-131), exclusive of VAT, inclusive of line level + * allowances and charges. Calculated as: ((unit_price / price_base_quantity) * + * quantity) - allowances + charges. Must be rounded to maximum 2 decimals. Can be + * negative for credit notes or corrections. */ fun amount(amount: Amount?) = amount(JsonField.ofNullable(amount)) @@ -5439,7 +7224,7 @@ private constructor( /** * The quantity of items (goods or services) that is the subject of the line item. Must - * be rounded to maximum 4 decimals + * be rounded to maximum 4 decimals. Can be negative for credit notes or corrections. */ fun quantity(quantity: Quantity?) = quantity(JsonField.ofNullable(quantity)) @@ -5461,7 +7246,10 @@ private constructor( /** Alias for calling [quantity] with `Quantity.ofString(string)`. */ fun quantity(string: String) = quantity(Quantity.ofString(string)) - /** The total VAT amount for the line item. Must be rounded to maximum 2 decimals */ + /** + * The total VAT amount for the line item. Must be rounded to maximum 2 decimals. Can be + * negative for credit notes or corrections. + */ fun tax(tax: Tax?) = tax(JsonField.ofNullable(tax)) /** Alias for calling [Builder.tax] with `tax.orElse(null)`. */ @@ -5483,19 +7271,25 @@ private constructor( fun tax(string: String) = tax(Tax.ofString(string)) /** The VAT rate of the line item expressed as percentage with 2 decimals */ - fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) + fun taxRate(taxRate: TaxRate?) = taxRate(JsonField.ofNullable(taxRate)) /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ - fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) + fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) /** * Sets [Builder.taxRate] to an arbitrary JSON value. * - * You should usually call [Builder.taxRate] with a well-typed [String] value instead. + * You should usually call [Builder.taxRate] with a well-typed [TaxRate] value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } + fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } + + /** Alias for calling [taxRate] with `TaxRate.ofNumber(number)`. */ + fun taxRate(number: Double) = taxRate(TaxRate.ofNumber(number)) + + /** Alias for calling [taxRate] with `TaxRate.ofString(string)`. */ + fun taxRate(string: String) = taxRate(TaxRate.ofString(string)) /** Unit of Measure Codes from UNECERec20 used in Peppol BIS Billing 3.0. */ fun unit(unit: UnitOfMeasureCode?) = unit(JsonField.ofNullable(unit)) @@ -5512,7 +7306,10 @@ private constructor( */ fun unit(unit: JsonField) = apply { this.unit = unit } - /** The unit price of the line item. Must be rounded to maximum 2 decimals */ + /** + * The item net price (BT-146). The price of an item, exclusive of VAT, after + * subtracting item price discount. Must be rounded to maximum 4 decimals + */ fun unitPrice(unitPrice: UnitPrice?) = unitPrice(JsonField.ofNullable(unitPrice)) /** Alias for calling [Builder.unitPrice] with `unitPrice.orElse(null)`. */ @@ -5589,7 +7386,7 @@ private constructor( productCode() quantity().ifPresent { it.validate() } tax().ifPresent { it.validate() } - taxRate() + taxRate().ifPresent { it.validate() } unit().ifPresent { it.validate() } unitPrice().ifPresent { it.validate() } validated = true @@ -5619,7 +7416,7 @@ private constructor( (if (productCode.asKnown().isPresent) 1 else 0) + (quantity.asKnown().getOrNull()?.validity() ?: 0) + (tax.asKnown().getOrNull()?.validity() ?: 0) + - (if (taxRate.asKnown().isPresent) 1 else 0) + + (taxRate.asKnown().getOrNull()?.validity() ?: 0) + (unit.asKnown().getOrNull()?.validity() ?: 0) + (unitPrice.asKnown().getOrNull()?.validity() ?: 0) @@ -5631,9 +7428,9 @@ private constructor( private val baseAmount: JsonField, private val multiplierFactor: JsonField, private val reason: JsonField, - private val reasonCode: JsonField, + private val reasonCode: JsonField, private val taxCode: JsonField, - private val taxRate: JsonField, + private val taxRate: JsonField, private val additionalProperties: MutableMap, ) { @@ -5653,13 +7450,13 @@ private constructor( reason: JsonField = JsonMissing.of(), @JsonProperty("reason_code") @ExcludeMissing - reasonCode: JsonField = JsonMissing.of(), + reasonCode: JsonField = JsonMissing.of(), @JsonProperty("tax_code") @ExcludeMissing taxCode: JsonField = JsonMissing.of(), @JsonProperty("tax_rate") @ExcludeMissing - taxRate: JsonField = JsonMissing.of(), + taxRate: JsonField = JsonMissing.of(), ) : this( amount, baseAmount, @@ -5690,7 +7487,8 @@ private constructor( /** * The percentage that may be used, in conjunction with the allowance base amount, to - * calculate the allowance amount. To state 20%, use value 20 + * calculate the allowance amount. To state 20%, use value 20. Must be rounded to + * maximum 2 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -5707,17 +7505,15 @@ private constructor( fun reason(): Optional = reason.getOptional("reason") /** - * The code for the allowance reason + * Allowance reason codes for invoice discounts and charges * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun reasonCode(): Optional = reasonCode.getOptional("reason_code") + fun reasonCode(): Optional = reasonCode.getOptional("reason_code") /** - * Duty or tax or fee category codes (Subset of UNCL5305) - * - * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + * The VAT category code that applies to the allowance * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). @@ -5725,12 +7521,13 @@ private constructor( fun taxCode(): Optional = taxCode.getOptional("tax_code") /** - * The VAT rate, represented as percentage that applies to the allowance + * The VAT rate, represented as percentage that applies to the allowance. Must be + * rounded to maximum 2 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun taxRate(): Optional = taxRate.getOptional("tax_rate") + fun taxRate(): Optional = taxRate.getOptional("tax_rate") /** * Returns the raw JSON value of [amount]. @@ -5774,7 +7571,7 @@ private constructor( */ @JsonProperty("reason_code") @ExcludeMissing - fun _reasonCode(): JsonField = reasonCode + fun _reasonCode(): JsonField = reasonCode /** * Returns the raw JSON value of [taxCode]. @@ -5788,7 +7585,7 @@ private constructor( * * Unlike [taxRate], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate + @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -5815,9 +7612,9 @@ private constructor( private var baseAmount: JsonField = JsonMissing.of() private var multiplierFactor: JsonField = JsonMissing.of() private var reason: JsonField = JsonMissing.of() - private var reasonCode: JsonField = JsonMissing.of() + private var reasonCode: JsonField = JsonMissing.of() private var taxCode: JsonField = JsonMissing.of() - private var taxRate: JsonField = JsonMissing.of() + private var taxRate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5883,7 +7680,8 @@ private constructor( /** * The percentage that may be used, in conjunction with the allowance base amount, - * to calculate the allowance amount. To state 20%, use value 20 + * to calculate the allowance amount. To state 20%, use value 20. Must be rounded to + * maximum 2 decimals */ fun multiplierFactor(multiplierFactor: MultiplierFactor?) = multiplierFactor(JsonField.ofNullable(multiplierFactor)) @@ -5933,32 +7731,27 @@ private constructor( */ fun reason(reason: JsonField) = apply { this.reason = reason } - /** The code for the allowance reason */ - fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) + /** Allowance reason codes for invoice discounts and charges */ + fun reasonCode(reasonCode: ReasonCode?) = + reasonCode(JsonField.ofNullable(reasonCode)) /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ - fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) + fun reasonCode(reasonCode: Optional) = + reasonCode(reasonCode.getOrNull()) /** * Sets [Builder.reasonCode] to an arbitrary JSON value. * - * You should usually call [Builder.reasonCode] with a well-typed [String] value + * You should usually call [Builder.reasonCode] with a well-typed [ReasonCode] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun reasonCode(reasonCode: JsonField) = apply { + fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode } - /** - * Duty or tax or fee category codes (Subset of UNCL5305) - * - * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL - */ - fun taxCode(taxCode: TaxCode?) = taxCode(JsonField.ofNullable(taxCode)) - - /** Alias for calling [Builder.taxCode] with `taxCode.orElse(null)`. */ - fun taxCode(taxCode: Optional) = taxCode(taxCode.getOrNull()) + /** The VAT category code that applies to the allowance */ + fun taxCode(taxCode: TaxCode) = taxCode(JsonField.of(taxCode)) /** * Sets [Builder.taxCode] to an arbitrary JSON value. @@ -5969,20 +7762,29 @@ private constructor( */ fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } - /** The VAT rate, represented as percentage that applies to the allowance */ - fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) + /** + * The VAT rate, represented as percentage that applies to the allowance. Must be + * rounded to maximum 2 decimals + */ + fun taxRate(taxRate: TaxRate?) = taxRate(JsonField.ofNullable(taxRate)) /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ - fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) + fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) /** * Sets [Builder.taxRate] to an arbitrary JSON value. * - * You should usually call [Builder.taxRate] with a well-typed [String] value + * You should usually call [Builder.taxRate] with a well-typed [TaxRate] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } + fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } + + /** Alias for calling [taxRate] with `TaxRate.ofNumber(number)`. */ + fun taxRate(number: Double) = taxRate(TaxRate.ofNumber(number)) + + /** Alias for calling [taxRate] with `TaxRate.ofString(string)`. */ + fun taxRate(string: String) = taxRate(TaxRate.ofString(string)) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -6035,9 +7837,9 @@ private constructor( baseAmount().ifPresent { it.validate() } multiplierFactor().ifPresent { it.validate() } reason() - reasonCode() + reasonCode().ifPresent { it.validate() } taxCode().ifPresent { it.validate() } - taxRate() + taxRate().ifPresent { it.validate() } validated = true } @@ -6061,9 +7863,9 @@ private constructor( (baseAmount.asKnown().getOrNull()?.validity() ?: 0) + (multiplierFactor.asKnown().getOrNull()?.validity() ?: 0) + (if (reason.asKnown().isPresent) 1 else 0) + - (if (reasonCode.asKnown().isPresent) 1 else 0) + + (reasonCode.asKnown().getOrNull()?.validity() ?: 0) + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + - (if (taxRate.asKnown().isPresent) 1 else 0) + (taxRate.asKnown().getOrNull()?.validity() ?: 0) /** The allowance amount, without VAT. Must be rounded to maximum 2 decimals */ @JsonDeserialize(using = Amount.Deserializer::class) @@ -6414,7 +8216,8 @@ private constructor( /** * The percentage that may be used, in conjunction with the allowance base amount, to - * calculate the allowance amount. To state 20%, use value 20 + * calculate the allowance amount. To state 20%, use value 20. Must be rounded to + * maximum 2 decimals */ @JsonDeserialize(using = MultiplierFactor.Deserializer::class) @JsonSerialize(using = MultiplierFactor.Serializer::class) @@ -6591,11 +8394,242 @@ private constructor( } } - /** - * Duty or tax or fee category codes (Subset of UNCL5305) - * - * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL - */ + /** Allowance reason codes for invoice discounts and charges */ + class ReasonCode + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val _41 = of("41") + + @JvmField val _42 = of("42") + + @JvmField val _60 = of("60") + + @JvmField val _62 = of("62") + + @JvmField val _63 = of("63") + + @JvmField val _64 = of("64") + + @JvmField val _65 = of("65") + + @JvmField val _66 = of("66") + + @JvmField val _67 = of("67") + + @JvmField val _68 = of("68") + + @JvmField val _70 = of("70") + + @JvmField val _71 = of("71") + + @JvmField val _88 = of("88") + + @JvmField val _95 = of("95") + + @JvmField val _100 = of("100") + + @JvmField val _102 = of("102") + + @JvmField val _103 = of("103") + + @JvmField val _104 = of("104") + + @JvmField val _105 = of("105") + + @JvmStatic fun of(value: String) = ReasonCode(JsonField.of(value)) + } + + /** An enum containing [ReasonCode]'s known values. */ + enum class Known { + _41, + _42, + _60, + _62, + _63, + _64, + _65, + _66, + _67, + _68, + _70, + _71, + _88, + _95, + _100, + _102, + _103, + _104, + _105, + } + + /** + * An enum containing [ReasonCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ReasonCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + _41, + _42, + _60, + _62, + _63, + _64, + _65, + _66, + _67, + _68, + _70, + _71, + _88, + _95, + _100, + _102, + _103, + _104, + _105, + /** + * An enum member indicating that [ReasonCode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + _41 -> Value._41 + _42 -> Value._42 + _60 -> Value._60 + _62 -> Value._62 + _63 -> Value._63 + _64 -> Value._64 + _65 -> Value._65 + _66 -> Value._66 + _67 -> Value._67 + _68 -> Value._68 + _70 -> Value._70 + _71 -> Value._71 + _88 -> Value._88 + _95 -> Value._95 + _100 -> Value._100 + _102 -> Value._102 + _103 -> Value._103 + _104 -> Value._104 + _105 -> Value._105 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + _41 -> Known._41 + _42 -> Known._42 + _60 -> Known._60 + _62 -> Known._62 + _63 -> Known._63 + _64 -> Known._64 + _65 -> Known._65 + _66 -> Known._66 + _67 -> Known._67 + _68 -> Known._68 + _70 -> Known._70 + _71 -> Known._71 + _88 -> Known._88 + _95 -> Known._95 + _100 -> Known._100 + _102 -> Known._102 + _103 -> Known._103 + _104 -> Known._104 + _105 -> Known._105 + else -> throw EInvoiceInvalidDataException("Unknown ReasonCode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReasonCode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReasonCode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The VAT category code that applies to the allowance */ class TaxCode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -6742,37 +8776,212 @@ private constructor( return@apply } - known() - validated = true + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TaxCode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * The VAT rate, represented as percentage that applies to the allowance. Must be + * rounded to maximum 2 decimals + */ + @JsonDeserialize(using = TaxRate.Deserializer::class) + @JsonSerialize(using = TaxRate.Serializer::class) + class TaxRate + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): TaxRate = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TaxRate && number == other.number && string == other.string } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: EInvoiceInvalidDataException) { - false + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "TaxRate{number=$number}" + string != null -> "TaxRate{string=$string}" + _json != null -> "TaxRate{_unknown=$_json}" + else -> throw IllegalStateException("Invalid TaxRate") } + companion object { + + @JvmStatic fun ofNumber(number: Double) = TaxRate(number = number) + + @JvmStatic fun ofString(string: String) = TaxRate(string = string) + } + /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. + * An interface that defines how to map each variant of [TaxRate] to a value of type + * [T]. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + interface Visitor { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [TaxRate] to a value of type [T]. + * + * An instance of [TaxRate] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws EInvoiceInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw EInvoiceInvalidDataException("Unknown TaxRate: $json") } + } - return other is TaxCode && value == other.value + internal class Deserializer : BaseDeserializer(TaxRate::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): TaxRate { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + TaxRate(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + TaxRate(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // object). + 0 -> TaxRate(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } } - override fun hashCode() = value.hashCode() + internal class Serializer : BaseSerializer(TaxRate::class) { - override fun toString() = value.toString() + override fun serialize( + value: TaxRate, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid TaxRate") + } + } + } } override fun equals(other: Any?): Boolean { @@ -6811,8 +9020,10 @@ private constructor( } /** - * The total amount of the line item, exclusive of VAT, after subtracting line level - * allowances and adding line level charges. Must be rounded to maximum 2 decimals + * The invoice line net amount (BT-131), exclusive of VAT, inclusive of line level + * allowances and charges. Calculated as: ((unit_price / price_base_quantity) * quantity) - + * allowances + charges. Must be rounded to maximum 2 decimals. Can be negative for credit + * notes or corrections. */ @JsonDeserialize(using = Amount.Deserializer::class) @JsonSerialize(using = Amount.Serializer::class) @@ -6991,9 +9202,9 @@ private constructor( private val baseAmount: JsonField, private val multiplierFactor: JsonField, private val reason: JsonField, - private val reasonCode: JsonField, + private val reasonCode: JsonField, private val taxCode: JsonField, - private val taxRate: JsonField, + private val taxRate: JsonField, private val additionalProperties: MutableMap, ) { @@ -7013,13 +9224,13 @@ private constructor( reason: JsonField = JsonMissing.of(), @JsonProperty("reason_code") @ExcludeMissing - reasonCode: JsonField = JsonMissing.of(), + reasonCode: JsonField = JsonMissing.of(), @JsonProperty("tax_code") @ExcludeMissing taxCode: JsonField = JsonMissing.of(), @JsonProperty("tax_rate") @ExcludeMissing - taxRate: JsonField = JsonMissing.of(), + taxRate: JsonField = JsonMissing.of(), ) : this( amount, baseAmount, @@ -7067,12 +9278,12 @@ private constructor( fun reason(): Optional = reason.getOptional("reason") /** - * The code for the charge reason + * Charge reason codes for invoice charges and fees * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun reasonCode(): Optional = reasonCode.getOptional("reason_code") + fun reasonCode(): Optional = reasonCode.getOptional("reason_code") /** * Duty or tax or fee category codes (Subset of UNCL5305) @@ -7090,7 +9301,7 @@ private constructor( * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. * if the server responded with an unexpected value). */ - fun taxRate(): Optional = taxRate.getOptional("tax_rate") + fun taxRate(): Optional = taxRate.getOptional("tax_rate") /** * Returns the raw JSON value of [amount]. @@ -7134,7 +9345,7 @@ private constructor( */ @JsonProperty("reason_code") @ExcludeMissing - fun _reasonCode(): JsonField = reasonCode + fun _reasonCode(): JsonField = reasonCode /** * Returns the raw JSON value of [taxCode]. @@ -7148,7 +9359,7 @@ private constructor( * * Unlike [taxRate], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate + @JsonProperty("tax_rate") @ExcludeMissing fun _taxRate(): JsonField = taxRate @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -7175,9 +9386,9 @@ private constructor( private var baseAmount: JsonField = JsonMissing.of() private var multiplierFactor: JsonField = JsonMissing.of() private var reason: JsonField = JsonMissing.of() - private var reasonCode: JsonField = JsonMissing.of() + private var reasonCode: JsonField = JsonMissing.of() private var taxCode: JsonField = JsonMissing.of() - private var taxRate: JsonField = JsonMissing.of() + private var taxRate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -7293,20 +9504,22 @@ private constructor( */ fun reason(reason: JsonField) = apply { this.reason = reason } - /** The code for the charge reason */ - fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) + /** Charge reason codes for invoice charges and fees */ + fun reasonCode(reasonCode: ReasonCode?) = + reasonCode(JsonField.ofNullable(reasonCode)) /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ - fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) + fun reasonCode(reasonCode: Optional) = + reasonCode(reasonCode.getOrNull()) /** * Sets [Builder.reasonCode] to an arbitrary JSON value. * - * You should usually call [Builder.reasonCode] with a well-typed [String] value + * You should usually call [Builder.reasonCode] with a well-typed [ReasonCode] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun reasonCode(reasonCode: JsonField) = apply { + fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode } @@ -7330,19 +9543,25 @@ private constructor( fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } /** The VAT rate, represented as percentage that applies to the charge */ - fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) + fun taxRate(taxRate: TaxRate?) = taxRate(JsonField.ofNullable(taxRate)) /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ - fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) + fun taxRate(taxRate: Optional) = taxRate(taxRate.getOrNull()) /** * Sets [Builder.taxRate] to an arbitrary JSON value. * - * You should usually call [Builder.taxRate] with a well-typed [String] value + * You should usually call [Builder.taxRate] with a well-typed [TaxRate] value * instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } + fun taxRate(taxRate: JsonField) = apply { this.taxRate = taxRate } + + /** Alias for calling [taxRate] with `TaxRate.ofNumber(number)`. */ + fun taxRate(number: Double) = taxRate(TaxRate.ofNumber(number)) + + /** Alias for calling [taxRate] with `TaxRate.ofString(string)`. */ + fun taxRate(string: String) = taxRate(TaxRate.ofString(string)) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -7395,9 +9614,9 @@ private constructor( baseAmount().ifPresent { it.validate() } multiplierFactor().ifPresent { it.validate() } reason() - reasonCode() + reasonCode().ifPresent { it.validate() } taxCode().ifPresent { it.validate() } - taxRate() + taxRate().ifPresent { it.validate() } validated = true } @@ -7421,9 +9640,9 @@ private constructor( (baseAmount.asKnown().getOrNull()?.validity() ?: 0) + (multiplierFactor.asKnown().getOrNull()?.validity() ?: 0) + (if (reason.asKnown().isPresent) 1 else 0) + - (if (reasonCode.asKnown().isPresent) 1 else 0) + + (reasonCode.asKnown().getOrNull()?.validity() ?: 0) + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + - (if (taxRate.asKnown().isPresent) 1 else 0) + (taxRate.asKnown().getOrNull()?.validity() ?: 0) /** The charge amount, without VAT. Must be rounded to maximum 2 decimals */ @JsonDeserialize(using = Amount.Deserializer::class) @@ -7545,22 +9764,197 @@ private constructor( * @throws EInvoiceInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw EInvoiceInvalidDataException("Unknown Amount: $json") + throw EInvoiceInvalidDataException("Unknown Amount: $json") + } + } + + internal class Deserializer : BaseDeserializer(Amount::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Amount { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Amount(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Amount(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // object). + 0 -> Amount(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Amount::class) { + + override fun serialize( + value: Amount, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Amount") + } + } + } + } + + /** + * The base amount that may be used, in conjunction with the charge percentage, to + * calculate the charge amount. Must be rounded to maximum 2 decimals + */ + @JsonDeserialize(using = BaseAmount.Deserializer::class) + @JsonSerialize(using = BaseAmount.Serializer::class) + class BaseAmount + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): BaseAmount = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BaseAmount && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "BaseAmount{number=$number}" + string != null -> "BaseAmount{string=$string}" + _json != null -> "BaseAmount{_unknown=$_json}" + else -> throw IllegalStateException("Invalid BaseAmount") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = BaseAmount(number = number) + + @JvmStatic fun ofString(string: String) = BaseAmount(string = string) + } + + /** + * An interface that defines how to map each variant of [BaseAmount] to a value of + * type [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [BaseAmount] to a value of type [T]. + * + * An instance of [BaseAmount] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws EInvoiceInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw EInvoiceInvalidDataException("Unknown BaseAmount: $json") } } - internal class Deserializer : BaseDeserializer(Amount::class) { + internal class Deserializer : BaseDeserializer(BaseAmount::class) { - override fun ObjectCodec.deserialize(node: JsonNode): Amount { + override fun ObjectCodec.deserialize(node: JsonNode): BaseAmount { val json = JsonValue.fromJsonNode(node) val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef())?.let { - Amount(number = it, _json = json) + BaseAmount(number = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - Amount(string = it, _json = json) + BaseAmount(string = it, _json = json) }, ) .filterNotNull() @@ -7570,7 +9964,7 @@ private constructor( // This can happen if what we're deserializing is completely // incompatible with all the possible variants (e.g. deserializing from // object). - 0 -> Amount(_json = json) + 0 -> BaseAmount(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use // the first completely valid match, or simply the first match if none @@ -7580,10 +9974,10 @@ private constructor( } } - internal class Serializer : BaseSerializer(Amount::class) { + internal class Serializer : BaseSerializer(BaseAmount::class) { override fun serialize( - value: Amount, + value: BaseAmount, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -7591,19 +9985,19 @@ private constructor( value.number != null -> generator.writeObject(value.number) value.string != null -> generator.writeObject(value.string) value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Amount") + else -> throw IllegalStateException("Invalid BaseAmount") } } } } /** - * The base amount that may be used, in conjunction with the charge percentage, to - * calculate the charge amount. Must be rounded to maximum 2 decimals + * The percentage that may be used, in conjunction with the charge base amount, to + * calculate the charge amount. To state 20%, use value 20 */ - @JsonDeserialize(using = BaseAmount.Deserializer::class) - @JsonSerialize(using = BaseAmount.Serializer::class) - class BaseAmount + @JsonDeserialize(using = MultiplierFactor.Deserializer::class) + @JsonSerialize(using = MultiplierFactor.Serializer::class) + class MultiplierFactor private constructor( private val number: Double? = null, private val string: String? = null, @@ -7633,7 +10027,7 @@ private constructor( private var validated: Boolean = false - fun validate(): BaseAmount = apply { + fun validate(): MultiplierFactor = apply { if (validated) { return@apply } @@ -7679,29 +10073,31 @@ private constructor( return true } - return other is BaseAmount && number == other.number && string == other.string + return other is MultiplierFactor && + number == other.number && + string == other.string } override fun hashCode(): Int = Objects.hash(number, string) override fun toString(): String = when { - number != null -> "BaseAmount{number=$number}" - string != null -> "BaseAmount{string=$string}" - _json != null -> "BaseAmount{_unknown=$_json}" - else -> throw IllegalStateException("Invalid BaseAmount") + number != null -> "MultiplierFactor{number=$number}" + string != null -> "MultiplierFactor{string=$string}" + _json != null -> "MultiplierFactor{_unknown=$_json}" + else -> throw IllegalStateException("Invalid MultiplierFactor") } companion object { - @JvmStatic fun ofNumber(number: Double) = BaseAmount(number = number) + @JvmStatic fun ofNumber(number: Double) = MultiplierFactor(number = number) - @JvmStatic fun ofString(string: String) = BaseAmount(string = string) + @JvmStatic fun ofString(string: String) = MultiplierFactor(string = string) } /** - * An interface that defines how to map each variant of [BaseAmount] to a value of - * type [T]. + * An interface that defines how to map each variant of [MultiplierFactor] to a + * value of type [T]. */ interface Visitor { @@ -7710,9 +10106,9 @@ private constructor( fun visitString(string: String): T /** - * Maps an unknown variant of [BaseAmount] to a value of type [T]. + * Maps an unknown variant of [MultiplierFactor] to a value of type [T]. * - * An instance of [BaseAmount] can contain an unknown variant if it was + * An instance of [MultiplierFactor] can contain an unknown variant if it was * deserialized from data that doesn't match any known variant. For example, if * the SDK is on an older version than the API, then the API may respond with * new variants that the SDK is unaware of. @@ -7720,22 +10116,23 @@ private constructor( * @throws EInvoiceInvalidDataException in the default implementation. */ fun unknown(json: JsonValue?): T { - throw EInvoiceInvalidDataException("Unknown BaseAmount: $json") + throw EInvoiceInvalidDataException("Unknown MultiplierFactor: $json") } } - internal class Deserializer : BaseDeserializer(BaseAmount::class) { + internal class Deserializer : + BaseDeserializer(MultiplierFactor::class) { - override fun ObjectCodec.deserialize(node: JsonNode): BaseAmount { + override fun ObjectCodec.deserialize(node: JsonNode): MultiplierFactor { val json = JsonValue.fromJsonNode(node) val bestMatches = sequenceOf( tryDeserialize(node, jacksonTypeRef())?.let { - BaseAmount(number = it, _json = json) + MultiplierFactor(number = it, _json = json) }, tryDeserialize(node, jacksonTypeRef())?.let { - BaseAmount(string = it, _json = json) + MultiplierFactor(string = it, _json = json) }, ) .filterNotNull() @@ -7745,7 +10142,7 @@ private constructor( // This can happen if what we're deserializing is completely // incompatible with all the possible variants (e.g. deserializing from // object). - 0 -> BaseAmount(_json = json) + 0 -> MultiplierFactor(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use // the first completely valid match, or simply the first match if none @@ -7755,10 +10152,11 @@ private constructor( } } - internal class Serializer : BaseSerializer(BaseAmount::class) { + internal class Serializer : + BaseSerializer(MultiplierFactor::class) { override fun serialize( - value: BaseAmount, + value: MultiplierFactor, generator: JsonGenerator, provider: SerializerProvider, ) { @@ -7766,60 +10164,1169 @@ private constructor( value.number != null -> generator.writeObject(value.number) value.string != null -> generator.writeObject(value.string) value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid BaseAmount") + else -> throw IllegalStateException("Invalid MultiplierFactor") } } } } - /** - * The percentage that may be used, in conjunction with the charge base amount, to - * calculate the charge amount. To state 20%, use value 20 - */ - @JsonDeserialize(using = MultiplierFactor.Deserializer::class) - @JsonSerialize(using = MultiplierFactor.Serializer::class) - class MultiplierFactor - private constructor( - private val number: Double? = null, - private val string: String? = null, - private val _json: JsonValue? = null, - ) { + /** Charge reason codes for invoice charges and fees */ + class ReasonCode + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val AA = of("AA") + + @JvmField val AAA = of("AAA") + + @JvmField val AAC = of("AAC") + + @JvmField val AAD = of("AAD") + + @JvmField val AAE = of("AAE") + + @JvmField val AAF = of("AAF") + + @JvmField val AAH = of("AAH") + + @JvmField val AAI = of("AAI") + + @JvmField val AAS = of("AAS") + + @JvmField val AAT = of("AAT") + + @JvmField val AAV = of("AAV") + + @JvmField val AAY = of("AAY") + + @JvmField val AAZ = of("AAZ") + + @JvmField val ABA = of("ABA") + + @JvmField val ABB = of("ABB") + + @JvmField val ABC = of("ABC") + + @JvmField val ABD = of("ABD") + + @JvmField val ABF = of("ABF") + + @JvmField val ABK = of("ABK") + + @JvmField val ABL = of("ABL") + + @JvmField val ABN = of("ABN") + + @JvmField val ABR = of("ABR") + + @JvmField val ABS = of("ABS") + + @JvmField val ABT = of("ABT") + + @JvmField val ABU = of("ABU") + + @JvmField val ACF = of("ACF") + + @JvmField val ACG = of("ACG") + + @JvmField val ACH = of("ACH") + + @JvmField val ACI = of("ACI") + + @JvmField val ACJ = of("ACJ") + + @JvmField val ACK = of("ACK") + + @JvmField val ACL = of("ACL") + + @JvmField val ACM = of("ACM") + + @JvmField val ACS = of("ACS") + + @JvmField val ADC = of("ADC") + + @JvmField val ADE = of("ADE") + + @JvmField val ADJ = of("ADJ") + + @JvmField val ADK = of("ADK") + + @JvmField val ADL = of("ADL") + + @JvmField val ADM = of("ADM") + + @JvmField val ADN = of("ADN") + + @JvmField val ADO = of("ADO") + + @JvmField val ADP = of("ADP") + + @JvmField val ADQ = of("ADQ") + + @JvmField val ADR = of("ADR") + + @JvmField val ADT = of("ADT") + + @JvmField val ADW = of("ADW") + + @JvmField val ADY = of("ADY") + + @JvmField val ADZ = of("ADZ") + + @JvmField val AEA = of("AEA") + + @JvmField val AEB = of("AEB") + + @JvmField val AEC = of("AEC") + + @JvmField val AED = of("AED") + + @JvmField val AEF = of("AEF") + + @JvmField val AEH = of("AEH") + + @JvmField val AEI = of("AEI") + + @JvmField val AEJ = of("AEJ") + + @JvmField val AEK = of("AEK") + + @JvmField val AEL = of("AEL") + + @JvmField val AEM = of("AEM") + + @JvmField val AEN = of("AEN") + + @JvmField val AEO = of("AEO") + + @JvmField val AEP = of("AEP") + + @JvmField val AES = of("AES") + + @JvmField val AET = of("AET") + + @JvmField val AEU = of("AEU") + + @JvmField val AEV = of("AEV") + + @JvmField val AEW = of("AEW") + + @JvmField val AEX = of("AEX") + + @JvmField val AEY = of("AEY") + + @JvmField val AEZ = of("AEZ") + + @JvmField val AJ = of("AJ") + + @JvmField val AU = of("AU") + + @JvmField val CA = of("CA") + + @JvmField val CAB = of("CAB") + + @JvmField val CAD = of("CAD") + + @JvmField val CAE = of("CAE") + + @JvmField val CAF = of("CAF") + + @JvmField val CAI = of("CAI") + + @JvmField val CAJ = of("CAJ") + + @JvmField val CAK = of("CAK") + + @JvmField val CAL = of("CAL") + + @JvmField val CAM = of("CAM") + + @JvmField val CAN = of("CAN") + + @JvmField val CAO = of("CAO") + + @JvmField val CAP = of("CAP") + + @JvmField val CAQ = of("CAQ") + + @JvmField val CAR = of("CAR") + + @JvmField val CAS = of("CAS") + + @JvmField val CAT = of("CAT") + + @JvmField val CAU = of("CAU") + + @JvmField val CAV = of("CAV") + + @JvmField val CAW = of("CAW") + + @JvmField val CAX = of("CAX") + + @JvmField val CAY = of("CAY") + + @JvmField val CAZ = of("CAZ") + + @JvmField val CD = of("CD") + + @JvmField val CG = of("CG") + + @JvmField val CS = of("CS") + + @JvmField val CT = of("CT") + + @JvmField val DAB = of("DAB") + + @JvmField val DAC = of("DAC") + + @JvmField val DAD = of("DAD") + + @JvmField val DAF = of("DAF") + + @JvmField val DAG = of("DAG") + + @JvmField val DAH = of("DAH") + + @JvmField val DAI = of("DAI") + + @JvmField val DAJ = of("DAJ") + + @JvmField val DAK = of("DAK") + + @JvmField val DAL = of("DAL") + + @JvmField val DAM = of("DAM") + + @JvmField val DAN = of("DAN") + + @JvmField val DAO = of("DAO") + + @JvmField val DAP = of("DAP") + + @JvmField val DAQ = of("DAQ") + + @JvmField val DL = of("DL") + + @JvmField val EG = of("EG") + + @JvmField val EP = of("EP") + + @JvmField val ER = of("ER") + + @JvmField val FAA = of("FAA") + + @JvmField val FAB = of("FAB") + + @JvmField val FAC = of("FAC") + + @JvmField val FC = of("FC") + + @JvmField val FH = of("FH") + + @JvmField val FI = of("FI") + + @JvmField val GAA = of("GAA") + + @JvmField val HAA = of("HAA") + + @JvmField val HD = of("HD") + + @JvmField val HH = of("HH") + + @JvmField val IAA = of("IAA") + + @JvmField val IAB = of("IAB") + + @JvmField val ID = of("ID") + + @JvmField val IF = of("IF") + + @JvmField val IR = of("IR") + + @JvmField val IS = of("IS") + + @JvmField val KO = of("KO") + + @JvmField val L1 = of("L1") + + @JvmField val LA = of("LA") + + @JvmField val LAA = of("LAA") + + @JvmField val LAB = of("LAB") + + @JvmField val LF = of("LF") + + @JvmField val MAE = of("MAE") + + @JvmField val MI = of("MI") + + @JvmField val ML = of("ML") + + @JvmField val NAA = of("NAA") + + @JvmField val OA = of("OA") + + @JvmField val PA = of("PA") + + @JvmField val PAA = of("PAA") + + @JvmField val PC = of("PC") + + @JvmField val PL = of("PL") + + @JvmField val PRV = of("PRV") + + @JvmField val RAB = of("RAB") + + @JvmField val RAC = of("RAC") + + @JvmField val RAD = of("RAD") + + @JvmField val RAF = of("RAF") + + @JvmField val RE = of("RE") + + @JvmField val RF = of("RF") + + @JvmField val RH = of("RH") + + @JvmField val RV = of("RV") + + @JvmField val SA = of("SA") + + @JvmField val SAA = of("SAA") + + @JvmField val SAD = of("SAD") + + @JvmField val SAE = of("SAE") + + @JvmField val SAI = of("SAI") + + @JvmField val SG = of("SG") + + @JvmField val SH = of("SH") - fun number(): Optional = Optional.ofNullable(number) + @JvmField val SM = of("SM") - fun string(): Optional = Optional.ofNullable(string) + @JvmField val SU = of("SU") - fun isNumber(): Boolean = number != null + @JvmField val TAB = of("TAB") - fun isString(): Boolean = string != null + @JvmField val TAC = of("TAC") - fun asNumber(): Double = number.getOrThrow("number") + @JvmField val TT = of("TT") - fun asString(): String = string.getOrThrow("string") + @JvmField val TV = of("TV") - fun _json(): Optional = Optional.ofNullable(_json) + @JvmField val V1 = of("V1") - fun accept(visitor: Visitor): T = - when { - number != null -> visitor.visitNumber(number) - string != null -> visitor.visitString(string) - else -> visitor.unknown(_json) + @JvmField val V2 = of("V2") + + @JvmField val WH = of("WH") + + @JvmField val XAA = of("XAA") + + @JvmField val YY = of("YY") + + @JvmField val ZZZ = of("ZZZ") + + @JvmStatic fun of(value: String) = ReasonCode(JsonField.of(value)) + } + + /** An enum containing [ReasonCode]'s known values. */ + enum class Known { + AA, + AAA, + AAC, + AAD, + AAE, + AAF, + AAH, + AAI, + AAS, + AAT, + AAV, + AAY, + AAZ, + ABA, + ABB, + ABC, + ABD, + ABF, + ABK, + ABL, + ABN, + ABR, + ABS, + ABT, + ABU, + ACF, + ACG, + ACH, + ACI, + ACJ, + ACK, + ACL, + ACM, + ACS, + ADC, + ADE, + ADJ, + ADK, + ADL, + ADM, + ADN, + ADO, + ADP, + ADQ, + ADR, + ADT, + ADW, + ADY, + ADZ, + AEA, + AEB, + AEC, + AED, + AEF, + AEH, + AEI, + AEJ, + AEK, + AEL, + AEM, + AEN, + AEO, + AEP, + AES, + AET, + AEU, + AEV, + AEW, + AEX, + AEY, + AEZ, + AJ, + AU, + CA, + CAB, + CAD, + CAE, + CAF, + CAI, + CAJ, + CAK, + CAL, + CAM, + CAN, + CAO, + CAP, + CAQ, + CAR, + CAS, + CAT, + CAU, + CAV, + CAW, + CAX, + CAY, + CAZ, + CD, + CG, + CS, + CT, + DAB, + DAC, + DAD, + DAF, + DAG, + DAH, + DAI, + DAJ, + DAK, + DAL, + DAM, + DAN, + DAO, + DAP, + DAQ, + DL, + EG, + EP, + ER, + FAA, + FAB, + FAC, + FC, + FH, + FI, + GAA, + HAA, + HD, + HH, + IAA, + IAB, + ID, + IF, + IR, + IS, + KO, + L1, + LA, + LAA, + LAB, + LF, + MAE, + MI, + ML, + NAA, + OA, + PA, + PAA, + PC, + PL, + PRV, + RAB, + RAC, + RAD, + RAF, + RE, + RF, + RH, + RV, + SA, + SAA, + SAD, + SAE, + SAI, + SG, + SH, + SM, + SU, + TAB, + TAC, + TT, + TV, + V1, + V2, + WH, + XAA, + YY, + ZZZ, + } + + /** + * An enum containing [ReasonCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ReasonCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AA, + AAA, + AAC, + AAD, + AAE, + AAF, + AAH, + AAI, + AAS, + AAT, + AAV, + AAY, + AAZ, + ABA, + ABB, + ABC, + ABD, + ABF, + ABK, + ABL, + ABN, + ABR, + ABS, + ABT, + ABU, + ACF, + ACG, + ACH, + ACI, + ACJ, + ACK, + ACL, + ACM, + ACS, + ADC, + ADE, + ADJ, + ADK, + ADL, + ADM, + ADN, + ADO, + ADP, + ADQ, + ADR, + ADT, + ADW, + ADY, + ADZ, + AEA, + AEB, + AEC, + AED, + AEF, + AEH, + AEI, + AEJ, + AEK, + AEL, + AEM, + AEN, + AEO, + AEP, + AES, + AET, + AEU, + AEV, + AEW, + AEX, + AEY, + AEZ, + AJ, + AU, + CA, + CAB, + CAD, + CAE, + CAF, + CAI, + CAJ, + CAK, + CAL, + CAM, + CAN, + CAO, + CAP, + CAQ, + CAR, + CAS, + CAT, + CAU, + CAV, + CAW, + CAX, + CAY, + CAZ, + CD, + CG, + CS, + CT, + DAB, + DAC, + DAD, + DAF, + DAG, + DAH, + DAI, + DAJ, + DAK, + DAL, + DAM, + DAN, + DAO, + DAP, + DAQ, + DL, + EG, + EP, + ER, + FAA, + FAB, + FAC, + FC, + FH, + FI, + GAA, + HAA, + HD, + HH, + IAA, + IAB, + ID, + IF, + IR, + IS, + KO, + L1, + LA, + LAA, + LAB, + LF, + MAE, + MI, + ML, + NAA, + OA, + PA, + PAA, + PC, + PL, + PRV, + RAB, + RAC, + RAD, + RAF, + RE, + RF, + RH, + RV, + SA, + SAA, + SAD, + SAE, + SAI, + SG, + SH, + SM, + SU, + TAB, + TAC, + TT, + TV, + V1, + V2, + WH, + XAA, + YY, + ZZZ, + /** + * An enum member indicating that [ReasonCode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AA -> Value.AA + AAA -> Value.AAA + AAC -> Value.AAC + AAD -> Value.AAD + AAE -> Value.AAE + AAF -> Value.AAF + AAH -> Value.AAH + AAI -> Value.AAI + AAS -> Value.AAS + AAT -> Value.AAT + AAV -> Value.AAV + AAY -> Value.AAY + AAZ -> Value.AAZ + ABA -> Value.ABA + ABB -> Value.ABB + ABC -> Value.ABC + ABD -> Value.ABD + ABF -> Value.ABF + ABK -> Value.ABK + ABL -> Value.ABL + ABN -> Value.ABN + ABR -> Value.ABR + ABS -> Value.ABS + ABT -> Value.ABT + ABU -> Value.ABU + ACF -> Value.ACF + ACG -> Value.ACG + ACH -> Value.ACH + ACI -> Value.ACI + ACJ -> Value.ACJ + ACK -> Value.ACK + ACL -> Value.ACL + ACM -> Value.ACM + ACS -> Value.ACS + ADC -> Value.ADC + ADE -> Value.ADE + ADJ -> Value.ADJ + ADK -> Value.ADK + ADL -> Value.ADL + ADM -> Value.ADM + ADN -> Value.ADN + ADO -> Value.ADO + ADP -> Value.ADP + ADQ -> Value.ADQ + ADR -> Value.ADR + ADT -> Value.ADT + ADW -> Value.ADW + ADY -> Value.ADY + ADZ -> Value.ADZ + AEA -> Value.AEA + AEB -> Value.AEB + AEC -> Value.AEC + AED -> Value.AED + AEF -> Value.AEF + AEH -> Value.AEH + AEI -> Value.AEI + AEJ -> Value.AEJ + AEK -> Value.AEK + AEL -> Value.AEL + AEM -> Value.AEM + AEN -> Value.AEN + AEO -> Value.AEO + AEP -> Value.AEP + AES -> Value.AES + AET -> Value.AET + AEU -> Value.AEU + AEV -> Value.AEV + AEW -> Value.AEW + AEX -> Value.AEX + AEY -> Value.AEY + AEZ -> Value.AEZ + AJ -> Value.AJ + AU -> Value.AU + CA -> Value.CA + CAB -> Value.CAB + CAD -> Value.CAD + CAE -> Value.CAE + CAF -> Value.CAF + CAI -> Value.CAI + CAJ -> Value.CAJ + CAK -> Value.CAK + CAL -> Value.CAL + CAM -> Value.CAM + CAN -> Value.CAN + CAO -> Value.CAO + CAP -> Value.CAP + CAQ -> Value.CAQ + CAR -> Value.CAR + CAS -> Value.CAS + CAT -> Value.CAT + CAU -> Value.CAU + CAV -> Value.CAV + CAW -> Value.CAW + CAX -> Value.CAX + CAY -> Value.CAY + CAZ -> Value.CAZ + CD -> Value.CD + CG -> Value.CG + CS -> Value.CS + CT -> Value.CT + DAB -> Value.DAB + DAC -> Value.DAC + DAD -> Value.DAD + DAF -> Value.DAF + DAG -> Value.DAG + DAH -> Value.DAH + DAI -> Value.DAI + DAJ -> Value.DAJ + DAK -> Value.DAK + DAL -> Value.DAL + DAM -> Value.DAM + DAN -> Value.DAN + DAO -> Value.DAO + DAP -> Value.DAP + DAQ -> Value.DAQ + DL -> Value.DL + EG -> Value.EG + EP -> Value.EP + ER -> Value.ER + FAA -> Value.FAA + FAB -> Value.FAB + FAC -> Value.FAC + FC -> Value.FC + FH -> Value.FH + FI -> Value.FI + GAA -> Value.GAA + HAA -> Value.HAA + HD -> Value.HD + HH -> Value.HH + IAA -> Value.IAA + IAB -> Value.IAB + ID -> Value.ID + IF -> Value.IF + IR -> Value.IR + IS -> Value.IS + KO -> Value.KO + L1 -> Value.L1 + LA -> Value.LA + LAA -> Value.LAA + LAB -> Value.LAB + LF -> Value.LF + MAE -> Value.MAE + MI -> Value.MI + ML -> Value.ML + NAA -> Value.NAA + OA -> Value.OA + PA -> Value.PA + PAA -> Value.PAA + PC -> Value.PC + PL -> Value.PL + PRV -> Value.PRV + RAB -> Value.RAB + RAC -> Value.RAC + RAD -> Value.RAD + RAF -> Value.RAF + RE -> Value.RE + RF -> Value.RF + RH -> Value.RH + RV -> Value.RV + SA -> Value.SA + SAA -> Value.SAA + SAD -> Value.SAD + SAE -> Value.SAE + SAI -> Value.SAI + SG -> Value.SG + SH -> Value.SH + SM -> Value.SM + SU -> Value.SU + TAB -> Value.TAB + TAC -> Value.TAC + TT -> Value.TT + TV -> Value.TV + V1 -> Value.V1 + V2 -> Value.V2 + WH -> Value.WH + XAA -> Value.XAA + YY -> Value.YY + ZZZ -> Value.ZZZ + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + AA -> Known.AA + AAA -> Known.AAA + AAC -> Known.AAC + AAD -> Known.AAD + AAE -> Known.AAE + AAF -> Known.AAF + AAH -> Known.AAH + AAI -> Known.AAI + AAS -> Known.AAS + AAT -> Known.AAT + AAV -> Known.AAV + AAY -> Known.AAY + AAZ -> Known.AAZ + ABA -> Known.ABA + ABB -> Known.ABB + ABC -> Known.ABC + ABD -> Known.ABD + ABF -> Known.ABF + ABK -> Known.ABK + ABL -> Known.ABL + ABN -> Known.ABN + ABR -> Known.ABR + ABS -> Known.ABS + ABT -> Known.ABT + ABU -> Known.ABU + ACF -> Known.ACF + ACG -> Known.ACG + ACH -> Known.ACH + ACI -> Known.ACI + ACJ -> Known.ACJ + ACK -> Known.ACK + ACL -> Known.ACL + ACM -> Known.ACM + ACS -> Known.ACS + ADC -> Known.ADC + ADE -> Known.ADE + ADJ -> Known.ADJ + ADK -> Known.ADK + ADL -> Known.ADL + ADM -> Known.ADM + ADN -> Known.ADN + ADO -> Known.ADO + ADP -> Known.ADP + ADQ -> Known.ADQ + ADR -> Known.ADR + ADT -> Known.ADT + ADW -> Known.ADW + ADY -> Known.ADY + ADZ -> Known.ADZ + AEA -> Known.AEA + AEB -> Known.AEB + AEC -> Known.AEC + AED -> Known.AED + AEF -> Known.AEF + AEH -> Known.AEH + AEI -> Known.AEI + AEJ -> Known.AEJ + AEK -> Known.AEK + AEL -> Known.AEL + AEM -> Known.AEM + AEN -> Known.AEN + AEO -> Known.AEO + AEP -> Known.AEP + AES -> Known.AES + AET -> Known.AET + AEU -> Known.AEU + AEV -> Known.AEV + AEW -> Known.AEW + AEX -> Known.AEX + AEY -> Known.AEY + AEZ -> Known.AEZ + AJ -> Known.AJ + AU -> Known.AU + CA -> Known.CA + CAB -> Known.CAB + CAD -> Known.CAD + CAE -> Known.CAE + CAF -> Known.CAF + CAI -> Known.CAI + CAJ -> Known.CAJ + CAK -> Known.CAK + CAL -> Known.CAL + CAM -> Known.CAM + CAN -> Known.CAN + CAO -> Known.CAO + CAP -> Known.CAP + CAQ -> Known.CAQ + CAR -> Known.CAR + CAS -> Known.CAS + CAT -> Known.CAT + CAU -> Known.CAU + CAV -> Known.CAV + CAW -> Known.CAW + CAX -> Known.CAX + CAY -> Known.CAY + CAZ -> Known.CAZ + CD -> Known.CD + CG -> Known.CG + CS -> Known.CS + CT -> Known.CT + DAB -> Known.DAB + DAC -> Known.DAC + DAD -> Known.DAD + DAF -> Known.DAF + DAG -> Known.DAG + DAH -> Known.DAH + DAI -> Known.DAI + DAJ -> Known.DAJ + DAK -> Known.DAK + DAL -> Known.DAL + DAM -> Known.DAM + DAN -> Known.DAN + DAO -> Known.DAO + DAP -> Known.DAP + DAQ -> Known.DAQ + DL -> Known.DL + EG -> Known.EG + EP -> Known.EP + ER -> Known.ER + FAA -> Known.FAA + FAB -> Known.FAB + FAC -> Known.FAC + FC -> Known.FC + FH -> Known.FH + FI -> Known.FI + GAA -> Known.GAA + HAA -> Known.HAA + HD -> Known.HD + HH -> Known.HH + IAA -> Known.IAA + IAB -> Known.IAB + ID -> Known.ID + IF -> Known.IF + IR -> Known.IR + IS -> Known.IS + KO -> Known.KO + L1 -> Known.L1 + LA -> Known.LA + LAA -> Known.LAA + LAB -> Known.LAB + LF -> Known.LF + MAE -> Known.MAE + MI -> Known.MI + ML -> Known.ML + NAA -> Known.NAA + OA -> Known.OA + PA -> Known.PA + PAA -> Known.PAA + PC -> Known.PC + PL -> Known.PL + PRV -> Known.PRV + RAB -> Known.RAB + RAC -> Known.RAC + RAD -> Known.RAD + RAF -> Known.RAF + RE -> Known.RE + RF -> Known.RF + RH -> Known.RH + RV -> Known.RV + SA -> Known.SA + SAA -> Known.SAA + SAD -> Known.SAD + SAE -> Known.SAE + SAI -> Known.SAI + SG -> Known.SG + SH -> Known.SH + SM -> Known.SM + SU -> Known.SU + TAB -> Known.TAB + TAC -> Known.TAC + TT -> Known.TT + TV -> Known.TV + V1 -> Known.V1 + V2 -> Known.V2 + WH -> Known.WH + XAA -> Known.XAA + YY -> Known.YY + ZZZ -> Known.ZZZ + else -> throw EInvoiceInvalidDataException("Unknown ReasonCode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") } private var validated: Boolean = false - fun validate(): MultiplierFactor = apply { + fun validate(): ReasonCode = apply { if (validated) { return@apply } - accept( - object : Visitor { - override fun visitNumber(number: Double) {} - - override fun visitString(string: String) {} - } - ) + known() validated = true } @@ -7837,118 +11344,19 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitNumber(number: Double) = 1 - - override fun visitString(string: String) = 1 - - override fun unknown(json: JsonValue?) = 0 - } - ) + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is MultiplierFactor && - number == other.number && - string == other.string - } - - override fun hashCode(): Int = Objects.hash(number, string) - - override fun toString(): String = - when { - number != null -> "MultiplierFactor{number=$number}" - string != null -> "MultiplierFactor{string=$string}" - _json != null -> "MultiplierFactor{_unknown=$_json}" - else -> throw IllegalStateException("Invalid MultiplierFactor") - } - - companion object { - - @JvmStatic fun ofNumber(number: Double) = MultiplierFactor(number = number) - - @JvmStatic fun ofString(string: String) = MultiplierFactor(string = string) - } - - /** - * An interface that defines how to map each variant of [MultiplierFactor] to a - * value of type [T]. - */ - interface Visitor { - - fun visitNumber(number: Double): T - - fun visitString(string: String): T - - /** - * Maps an unknown variant of [MultiplierFactor] to a value of type [T]. - * - * An instance of [MultiplierFactor] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if - * the SDK is on an older version than the API, then the API may respond with - * new variants that the SDK is unaware of. - * - * @throws EInvoiceInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw EInvoiceInvalidDataException("Unknown MultiplierFactor: $json") - } - } - - internal class Deserializer : - BaseDeserializer(MultiplierFactor::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): MultiplierFactor { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - MultiplierFactor(number = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - MultiplierFactor(string = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely - // incompatible with all the possible variants (e.g. deserializing from - // object). - 0 -> MultiplierFactor(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use - // the first completely valid match, or simply the first match if none - // are completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } + return other is ReasonCode && value == other.value } - internal class Serializer : - BaseSerializer(MultiplierFactor::class) { + override fun hashCode() = value.hashCode() - override fun serialize( - value: MultiplierFactor, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.number != null -> generator.writeObject(value.number) - value.string != null -> generator.writeObject(value.string) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid MultiplierFactor") - } - } - } + override fun toString() = value.toString() } /** @@ -8097,12 +11505,89 @@ private constructor( private var validated: Boolean = false - fun validate(): TaxCode = apply { + fun validate(): TaxCode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TaxCode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The VAT rate, represented as percentage that applies to the charge */ + @JsonDeserialize(using = TaxRate.Deserializer::class) + @JsonSerialize(using = TaxRate.Serializer::class) + class TaxRate + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): TaxRate = apply { if (validated) { return@apply } - known() + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) validated = true } @@ -8120,19 +11605,114 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is TaxCode && value == other.value + return other is TaxRate && number == other.number && string == other.string } - override fun hashCode() = value.hashCode() + override fun hashCode(): Int = Objects.hash(number, string) - override fun toString() = value.toString() + override fun toString(): String = + when { + number != null -> "TaxRate{number=$number}" + string != null -> "TaxRate{string=$string}" + _json != null -> "TaxRate{_unknown=$_json}" + else -> throw IllegalStateException("Invalid TaxRate") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = TaxRate(number = number) + + @JvmStatic fun ofString(string: String) = TaxRate(string = string) + } + + /** + * An interface that defines how to map each variant of [TaxRate] to a value of type + * [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [TaxRate] to a value of type [T]. + * + * An instance of [TaxRate] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if + * the SDK is on an older version than the API, then the API may respond with + * new variants that the SDK is unaware of. + * + * @throws EInvoiceInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw EInvoiceInvalidDataException("Unknown TaxRate: $json") + } + } + + internal class Deserializer : BaseDeserializer(TaxRate::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): TaxRate { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + TaxRate(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + TaxRate(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants (e.g. deserializing from + // object). + 0 -> TaxRate(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(TaxRate::class) { + + override fun serialize( + value: TaxRate, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid TaxRate") + } + } + } } override fun equals(other: Any?): Boolean { @@ -8172,7 +11752,7 @@ private constructor( /** * The quantity of items (goods or services) that is the subject of the line item. Must be - * rounded to maximum 4 decimals + * rounded to maximum 4 decimals. Can be negative for credit notes or corrections. */ @JsonDeserialize(using = Quantity.Deserializer::class) @JsonSerialize(using = Quantity.Serializer::class) @@ -8344,7 +11924,10 @@ private constructor( } } - /** The total VAT amount for the line item. Must be rounded to maximum 2 decimals */ + /** + * The total VAT amount for the line item. Must be rounded to maximum 2 decimals. Can be + * negative for credit notes or corrections. + */ @JsonDeserialize(using = Tax.Deserializer::class) @JsonSerialize(using = Tax.Serializer::class) class Tax @@ -8514,7 +12097,181 @@ private constructor( } } - /** The unit price of the line item. Must be rounded to maximum 2 decimals */ + /** The VAT rate of the line item expressed as percentage with 2 decimals */ + @JsonDeserialize(using = TaxRate.Deserializer::class) + @JsonSerialize(using = TaxRate.Serializer::class) + class TaxRate + private constructor( + private val number: Double? = null, + private val string: String? = null, + private val _json: JsonValue? = null, + ) { + + fun number(): Optional = Optional.ofNullable(number) + + fun string(): Optional = Optional.ofNullable(string) + + fun isNumber(): Boolean = number != null + + fun isString(): Boolean = string != null + + fun asNumber(): Double = number.getOrThrow("number") + + fun asString(): String = string.getOrThrow("string") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + number != null -> visitor.visitNumber(number) + string != null -> visitor.visitString(string) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): TaxRate = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitNumber(number: Double) {} + + override fun visitString(string: String) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitNumber(number: Double) = 1 + + override fun visitString(string: String) = 1 + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TaxRate && number == other.number && string == other.string + } + + override fun hashCode(): Int = Objects.hash(number, string) + + override fun toString(): String = + when { + number != null -> "TaxRate{number=$number}" + string != null -> "TaxRate{string=$string}" + _json != null -> "TaxRate{_unknown=$_json}" + else -> throw IllegalStateException("Invalid TaxRate") + } + + companion object { + + @JvmStatic fun ofNumber(number: Double) = TaxRate(number = number) + + @JvmStatic fun ofString(string: String) = TaxRate(string = string) + } + + /** + * An interface that defines how to map each variant of [TaxRate] to a value of type + * [T]. + */ + interface Visitor { + + fun visitNumber(number: Double): T + + fun visitString(string: String): T + + /** + * Maps an unknown variant of [TaxRate] to a value of type [T]. + * + * An instance of [TaxRate] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on an + * older version than the API, then the API may respond with new variants that the + * SDK is unaware of. + * + * @throws EInvoiceInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw EInvoiceInvalidDataException("Unknown TaxRate: $json") + } + } + + internal class Deserializer : BaseDeserializer(TaxRate::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): TaxRate { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + TaxRate(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + TaxRate(string = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible + // with all the possible variants (e.g. deserializing from object). + 0 -> TaxRate(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the + // first completely valid match, or simply the first match if none are + // completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(TaxRate::class) { + + override fun serialize( + value: TaxRate, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.number != null -> generator.writeObject(value.number) + value.string != null -> generator.writeObject(value.string) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid TaxRate") + } + } + } + } + + /** + * The item net price (BT-146). The price of an item, exclusive of VAT, after subtracting + * item price discount. Must be rounded to maximum 4 decimals + */ @JsonDeserialize(using = UnitPrice.Deserializer::class) @JsonSerialize(using = UnitPrice.Serializer::class) class UnitPrice diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponse.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponse.kt index f517073..51fa325 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponse.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponse.kt @@ -48,7 +48,6 @@ private constructor( private val note: JsonField, private val paymentDetails: JsonField>, private val paymentTerm: JsonField, - private val previousUnpaidBalance: JsonField, private val purchaseOrder: JsonField, private val remittanceAddress: JsonField, private val remittanceAddressRecipient: JsonField, @@ -141,9 +140,6 @@ private constructor( @JsonProperty("payment_term") @ExcludeMissing paymentTerm: JsonField = JsonMissing.of(), - @JsonProperty("previous_unpaid_balance") - @ExcludeMissing - previousUnpaidBalance: JsonField = JsonMissing.of(), @JsonProperty("purchase_order") @ExcludeMissing purchaseOrder: JsonField = JsonMissing.of(), @@ -230,7 +226,6 @@ private constructor( note, paymentDetails, paymentTerm, - previousUnpaidBalance, purchaseOrder, remittanceAddress, remittanceAddressRecipient, @@ -449,16 +444,6 @@ private constructor( */ fun paymentTerm(): Optional = paymentTerm.getOptional("payment_term") - /** - * The previous unpaid balance from prior invoices, if any. Must be positive and rounded to - * maximum 2 decimals - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun previousUnpaidBalance(): Optional = - previousUnpaidBalance.getOptional("previous_unpaid_balance") - /** * The purchase order reference number * @@ -871,16 +856,6 @@ private constructor( @ExcludeMissing fun _paymentTerm(): JsonField = paymentTerm - /** - * Returns the raw JSON value of [previousUnpaidBalance]. - * - * Unlike [previousUnpaidBalance], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("previous_unpaid_balance") - @ExcludeMissing - fun _previousUnpaidBalance(): JsonField = previousUnpaidBalance - /** * Returns the raw JSON value of [purchaseOrder]. * @@ -1144,7 +1119,6 @@ private constructor( private var note: JsonField = JsonMissing.of() private var paymentDetails: JsonField>? = null private var paymentTerm: JsonField = JsonMissing.of() - private var previousUnpaidBalance: JsonField = JsonMissing.of() private var purchaseOrder: JsonField = JsonMissing.of() private var remittanceAddress: JsonField = JsonMissing.of() private var remittanceAddressRecipient: JsonField = JsonMissing.of() @@ -1198,7 +1172,6 @@ private constructor( note = documentCreateFromPdfResponse.note paymentDetails = documentCreateFromPdfResponse.paymentDetails.map { it.toMutableList() } paymentTerm = documentCreateFromPdfResponse.paymentTerm - previousUnpaidBalance = documentCreateFromPdfResponse.previousUnpaidBalance purchaseOrder = documentCreateFromPdfResponse.purchaseOrder remittanceAddress = documentCreateFromPdfResponse.remittanceAddress remittanceAddressRecipient = documentCreateFromPdfResponse.remittanceAddressRecipient @@ -1692,31 +1665,6 @@ private constructor( */ fun paymentTerm(paymentTerm: JsonField) = apply { this.paymentTerm = paymentTerm } - /** - * The previous unpaid balance from prior invoices, if any. Must be positive and rounded to - * maximum 2 decimals - */ - fun previousUnpaidBalance(previousUnpaidBalance: String?) = - previousUnpaidBalance(JsonField.ofNullable(previousUnpaidBalance)) - - /** - * Alias for calling [Builder.previousUnpaidBalance] with - * `previousUnpaidBalance.orElse(null)`. - */ - fun previousUnpaidBalance(previousUnpaidBalance: Optional) = - previousUnpaidBalance(previousUnpaidBalance.getOrNull()) - - /** - * Sets [Builder.previousUnpaidBalance] to an arbitrary JSON value. - * - * You should usually call [Builder.previousUnpaidBalance] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun previousUnpaidBalance(previousUnpaidBalance: JsonField) = apply { - this.previousUnpaidBalance = previousUnpaidBalance - } - /** The purchase order reference number */ fun purchaseOrder(purchaseOrder: String?) = purchaseOrder(JsonField.ofNullable(purchaseOrder)) @@ -2225,7 +2173,6 @@ private constructor( note, (paymentDetails ?: JsonMissing.of()).map { it.toImmutable() }, paymentTerm, - previousUnpaidBalance, purchaseOrder, remittanceAddress, remittanceAddressRecipient, @@ -2286,7 +2233,6 @@ private constructor( note() paymentDetails().ifPresent { it.forEach { it.validate() } } paymentTerm() - previousUnpaidBalance() purchaseOrder() remittanceAddress() remittanceAddressRecipient() @@ -2354,7 +2300,6 @@ private constructor( (if (note.asKnown().isPresent) 1 else 0) + (paymentDetails.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (paymentTerm.asKnown().isPresent) 1 else 0) + - (if (previousUnpaidBalance.asKnown().isPresent) 1 else 0) + (if (purchaseOrder.asKnown().isPresent) 1 else 0) + (if (remittanceAddress.asKnown().isPresent) 1 else 0) + (if (remittanceAddressRecipient.asKnown().isPresent) 1 else 0) + @@ -2449,8 +2394,10 @@ private constructor( fun allowances(): Optional> = allowances.getOptional("allowances") /** - * The total amount of the line item, exclusive of VAT, after subtracting line level - * allowances and adding line level charges. Must be rounded to maximum 2 decimals + * The invoice line net amount (BT-131), exclusive of VAT, inclusive of line level + * allowances and charges. Calculated as: ((unit_price / price_base_quantity) * quantity) - + * allowances + charges. Must be rounded to maximum 2 decimals. Can be negative for credit + * notes or corrections. * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -2489,7 +2436,7 @@ private constructor( /** * The quantity of items (goods or services) that is the subject of the line item. Must be - * rounded to maximum 4 decimals + * rounded to maximum 4 decimals. Can be negative for credit notes or corrections. * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -2497,7 +2444,8 @@ private constructor( fun quantity(): Optional = quantity.getOptional("quantity") /** - * The total VAT amount for the line item. Must be rounded to maximum 2 decimals + * The total VAT amount for the line item. Must be rounded to maximum 2 decimals. Can be + * negative for credit notes or corrections. * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -2521,7 +2469,8 @@ private constructor( fun unit(): Optional = unit.getOptional("unit") /** - * The unit price of the line item. Must be rounded to maximum 2 decimals + * The item net price (BT-146). The price of an item, exclusive of VAT, after subtracting + * item price discount. Must be rounded to maximum 4 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -2693,8 +2642,10 @@ private constructor( } /** - * The total amount of the line item, exclusive of VAT, after subtracting line level - * allowances and adding line level charges. Must be rounded to maximum 2 decimals + * The invoice line net amount (BT-131), exclusive of VAT, inclusive of line level + * allowances and charges. Calculated as: ((unit_price / price_base_quantity) * + * quantity) - allowances + charges. Must be rounded to maximum 2 decimals. Can be + * negative for credit notes or corrections. */ fun amount(amount: String?) = amount(JsonField.ofNullable(amount)) @@ -2789,7 +2740,7 @@ private constructor( /** * The quantity of items (goods or services) that is the subject of the line item. Must - * be rounded to maximum 4 decimals + * be rounded to maximum 4 decimals. Can be negative for credit notes or corrections. */ fun quantity(quantity: String?) = quantity(JsonField.ofNullable(quantity)) @@ -2805,7 +2756,10 @@ private constructor( */ fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - /** The total VAT amount for the line item. Must be rounded to maximum 2 decimals */ + /** + * The total VAT amount for the line item. Must be rounded to maximum 2 decimals. Can be + * negative for credit notes or corrections. + */ fun tax(tax: String?) = tax(JsonField.ofNullable(tax)) /** Alias for calling [Builder.tax] with `tax.orElse(null)`. */ @@ -2850,7 +2804,10 @@ private constructor( */ fun unit(unit: JsonField) = apply { this.unit = unit } - /** The unit price of the line item. Must be rounded to maximum 2 decimals */ + /** + * The item net price (BT-146). The price of an item, exclusive of VAT, after + * subtracting item price discount. Must be rounded to maximum 4 decimals + */ fun unitPrice(unitPrice: String?) = unitPrice(JsonField.ofNullable(unitPrice)) /** Alias for calling [Builder.unitPrice] with `unitPrice.orElse(null)`. */ @@ -3880,7 +3837,6 @@ private constructor( note == other.note && paymentDetails == other.paymentDetails && paymentTerm == other.paymentTerm && - previousUnpaidBalance == other.previousUnpaidBalance && purchaseOrder == other.purchaseOrder && remittanceAddress == other.remittanceAddress && remittanceAddressRecipient == other.remittanceAddressRecipient && @@ -3935,7 +3891,6 @@ private constructor( note, paymentDetails, paymentTerm, - previousUnpaidBalance, purchaseOrder, remittanceAddress, remittanceAddressRecipient, @@ -3968,5 +3923,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "DocumentCreateFromPdfResponse{allowances=$allowances, amountDue=$amountDue, attachments=$attachments, billingAddress=$billingAddress, billingAddressRecipient=$billingAddressRecipient, charges=$charges, currency=$currency, customerAddress=$customerAddress, customerAddressRecipient=$customerAddressRecipient, customerCompanyId=$customerCompanyId, customerEmail=$customerEmail, customerId=$customerId, customerName=$customerName, customerTaxId=$customerTaxId, direction=$direction, documentType=$documentType, dueDate=$dueDate, invoiceDate=$invoiceDate, invoiceId=$invoiceId, invoiceTotal=$invoiceTotal, items=$items, note=$note, paymentDetails=$paymentDetails, paymentTerm=$paymentTerm, previousUnpaidBalance=$previousUnpaidBalance, purchaseOrder=$purchaseOrder, remittanceAddress=$remittanceAddress, remittanceAddressRecipient=$remittanceAddressRecipient, serviceAddress=$serviceAddress, serviceAddressRecipient=$serviceAddressRecipient, serviceEndDate=$serviceEndDate, serviceStartDate=$serviceStartDate, shippingAddress=$shippingAddress, shippingAddressRecipient=$shippingAddressRecipient, state=$state, subtotal=$subtotal, success=$success, taxCode=$taxCode, taxDetails=$taxDetails, totalDiscount=$totalDiscount, totalTax=$totalTax, ublDocument=$ublDocument, vatex=$vatex, vatexNote=$vatexNote, vendorAddress=$vendorAddress, vendorAddressRecipient=$vendorAddressRecipient, vendorCompanyId=$vendorCompanyId, vendorEmail=$vendorEmail, vendorName=$vendorName, vendorTaxId=$vendorTaxId, additionalProperties=$additionalProperties}" + "DocumentCreateFromPdfResponse{allowances=$allowances, amountDue=$amountDue, attachments=$attachments, billingAddress=$billingAddress, billingAddressRecipient=$billingAddressRecipient, charges=$charges, currency=$currency, customerAddress=$customerAddress, customerAddressRecipient=$customerAddressRecipient, customerCompanyId=$customerCompanyId, customerEmail=$customerEmail, customerId=$customerId, customerName=$customerName, customerTaxId=$customerTaxId, direction=$direction, documentType=$documentType, dueDate=$dueDate, invoiceDate=$invoiceDate, invoiceId=$invoiceId, invoiceTotal=$invoiceTotal, items=$items, note=$note, paymentDetails=$paymentDetails, paymentTerm=$paymentTerm, purchaseOrder=$purchaseOrder, remittanceAddress=$remittanceAddress, remittanceAddressRecipient=$remittanceAddressRecipient, serviceAddress=$serviceAddress, serviceAddressRecipient=$serviceAddressRecipient, serviceEndDate=$serviceEndDate, serviceStartDate=$serviceStartDate, shippingAddress=$shippingAddress, shippingAddressRecipient=$shippingAddressRecipient, state=$state, subtotal=$subtotal, success=$success, taxCode=$taxCode, taxDetails=$taxDetails, totalDiscount=$totalDiscount, totalTax=$totalTax, ublDocument=$ublDocument, vatex=$vatex, vatexNote=$vatexNote, vendorAddress=$vendorAddress, vendorAddressRecipient=$vendorAddressRecipient, vendorCompanyId=$vendorCompanyId, vendorEmail=$vendorEmail, vendorName=$vendorName, vendorTaxId=$vendorTaxId, additionalProperties=$additionalProperties}" } diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt index 066f3b6..332b8da 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt @@ -51,7 +51,6 @@ private constructor( private val note: JsonField, private val paymentDetails: JsonField>, private val paymentTerm: JsonField, - private val previousUnpaidBalance: JsonField, private val purchaseOrder: JsonField, private val remittanceAddress: JsonField, private val remittanceAddressRecipient: JsonField, @@ -143,9 +142,6 @@ private constructor( @JsonProperty("payment_term") @ExcludeMissing paymentTerm: JsonField = JsonMissing.of(), - @JsonProperty("previous_unpaid_balance") - @ExcludeMissing - previousUnpaidBalance: JsonField = JsonMissing.of(), @JsonProperty("purchase_order") @ExcludeMissing purchaseOrder: JsonField = JsonMissing.of(), @@ -229,7 +225,6 @@ private constructor( note, paymentDetails, paymentTerm, - previousUnpaidBalance, purchaseOrder, remittanceAddress, remittanceAddressRecipient, @@ -449,16 +444,6 @@ private constructor( */ fun paymentTerm(): Optional = paymentTerm.getOptional("payment_term") - /** - * The previous unpaid balance from prior invoices, if any. Must be positive and rounded to - * maximum 2 decimals - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun previousUnpaidBalance(): Optional = - previousUnpaidBalance.getOptional("previous_unpaid_balance") - /** * The purchase order reference number * @@ -862,16 +847,6 @@ private constructor( @ExcludeMissing fun _paymentTerm(): JsonField = paymentTerm - /** - * Returns the raw JSON value of [previousUnpaidBalance]. - * - * Unlike [previousUnpaidBalance], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("previous_unpaid_balance") - @ExcludeMissing - fun _previousUnpaidBalance(): JsonField = previousUnpaidBalance - /** * Returns the raw JSON value of [purchaseOrder]. * @@ -1124,7 +1099,6 @@ private constructor( private var note: JsonField = JsonMissing.of() private var paymentDetails: JsonField>? = null private var paymentTerm: JsonField = JsonMissing.of() - private var previousUnpaidBalance: JsonField = JsonMissing.of() private var purchaseOrder: JsonField = JsonMissing.of() private var remittanceAddress: JsonField = JsonMissing.of() private var remittanceAddressRecipient: JsonField = JsonMissing.of() @@ -1177,7 +1151,6 @@ private constructor( note = documentResponse.note paymentDetails = documentResponse.paymentDetails.map { it.toMutableList() } paymentTerm = documentResponse.paymentTerm - previousUnpaidBalance = documentResponse.previousUnpaidBalance purchaseOrder = documentResponse.purchaseOrder remittanceAddress = documentResponse.remittanceAddress remittanceAddressRecipient = documentResponse.remittanceAddressRecipient @@ -1681,31 +1654,6 @@ private constructor( */ fun paymentTerm(paymentTerm: JsonField) = apply { this.paymentTerm = paymentTerm } - /** - * The previous unpaid balance from prior invoices, if any. Must be positive and rounded to - * maximum 2 decimals - */ - fun previousUnpaidBalance(previousUnpaidBalance: String?) = - previousUnpaidBalance(JsonField.ofNullable(previousUnpaidBalance)) - - /** - * Alias for calling [Builder.previousUnpaidBalance] with - * `previousUnpaidBalance.orElse(null)`. - */ - fun previousUnpaidBalance(previousUnpaidBalance: Optional) = - previousUnpaidBalance(previousUnpaidBalance.getOrNull()) - - /** - * Sets [Builder.previousUnpaidBalance] to an arbitrary JSON value. - * - * You should usually call [Builder.previousUnpaidBalance] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun previousUnpaidBalance(previousUnpaidBalance: JsonField) = apply { - this.previousUnpaidBalance = previousUnpaidBalance - } - /** The purchase order reference number */ fun purchaseOrder(purchaseOrder: String?) = purchaseOrder(JsonField.ofNullable(purchaseOrder)) @@ -2196,7 +2144,6 @@ private constructor( note, (paymentDetails ?: JsonMissing.of()).map { it.toImmutable() }, paymentTerm, - previousUnpaidBalance, purchaseOrder, remittanceAddress, remittanceAddressRecipient, @@ -2256,7 +2203,6 @@ private constructor( note() paymentDetails().ifPresent { it.forEach { it.validate() } } paymentTerm() - previousUnpaidBalance() purchaseOrder() remittanceAddress() remittanceAddressRecipient() @@ -2323,7 +2269,6 @@ private constructor( (if (note.asKnown().isPresent) 1 else 0) + (paymentDetails.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (paymentTerm.asKnown().isPresent) 1 else 0) + - (if (previousUnpaidBalance.asKnown().isPresent) 1 else 0) + (if (purchaseOrder.asKnown().isPresent) 1 else 0) + (if (remittanceAddress.asKnown().isPresent) 1 else 0) + (if (remittanceAddressRecipient.asKnown().isPresent) 1 else 0) + @@ -2355,7 +2300,7 @@ private constructor( private val baseAmount: JsonField, private val multiplierFactor: JsonField, private val reason: JsonField, - private val reasonCode: JsonField, + private val reasonCode: JsonField, private val taxCode: JsonField, private val taxRate: JsonField, private val additionalProperties: MutableMap, @@ -2373,7 +2318,7 @@ private constructor( @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), @JsonProperty("reason_code") @ExcludeMissing - reasonCode: JsonField = JsonMissing.of(), + reasonCode: JsonField = JsonMissing.of(), @JsonProperty("tax_code") @ExcludeMissing taxCode: JsonField = JsonMissing.of(), @@ -2408,7 +2353,8 @@ private constructor( /** * The percentage that may be used, in conjunction with the allowance base amount, to - * calculate the allowance amount. To state 20%, use value 20 + * calculate the allowance amount. To state 20%, use value 20. Must be rounded to maximum 2 + * decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -2424,17 +2370,15 @@ private constructor( fun reason(): Optional = reason.getOptional("reason") /** - * The code for the allowance reason + * Allowance reason codes for invoice discounts and charges * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun reasonCode(): Optional = reasonCode.getOptional("reason_code") + fun reasonCode(): Optional = reasonCode.getOptional("reason_code") /** - * Duty or tax or fee category codes (Subset of UNCL5305) - * - * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL + * The VAT category code that applies to the allowance * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -2442,7 +2386,8 @@ private constructor( fun taxCode(): Optional = taxCode.getOptional("tax_code") /** - * The VAT rate, represented as percentage that applies to the allowance + * The VAT rate, represented as percentage that applies to the allowance. Must be rounded to + * maximum 2 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -2489,7 +2434,7 @@ private constructor( */ @JsonProperty("reason_code") @ExcludeMissing - fun _reasonCode(): JsonField = reasonCode + fun _reasonCode(): JsonField = reasonCode /** * Returns the raw JSON value of [taxCode]. @@ -2530,7 +2475,7 @@ private constructor( private var baseAmount: JsonField = JsonMissing.of() private var multiplierFactor: JsonField = JsonMissing.of() private var reason: JsonField = JsonMissing.of() - private var reasonCode: JsonField = JsonMissing.of() + private var reasonCode: JsonField = JsonMissing.of() private var taxCode: JsonField = JsonMissing.of() private var taxRate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -2582,7 +2527,8 @@ private constructor( /** * The percentage that may be used, in conjunction with the allowance base amount, to - * calculate the allowance amount. To state 20%, use value 20 + * calculate the allowance amount. To state 20%, use value 20. Must be rounded to + * maximum 2 decimals */ fun multiplierFactor(multiplierFactor: String?) = multiplierFactor(JsonField.ofNullable(multiplierFactor)) @@ -2619,30 +2565,25 @@ private constructor( */ fun reason(reason: JsonField) = apply { this.reason = reason } - /** The code for the allowance reason */ - fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) + /** Allowance reason codes for invoice discounts and charges */ + fun reasonCode(reasonCode: ReasonCode?) = reasonCode(JsonField.ofNullable(reasonCode)) /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ - fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) + fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) /** * Sets [Builder.reasonCode] to an arbitrary JSON value. * - * You should usually call [Builder.reasonCode] with a well-typed [String] value + * You should usually call [Builder.reasonCode] with a well-typed [ReasonCode] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode } - - /** - * Duty or tax or fee category codes (Subset of UNCL5305) - * - * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL - */ - fun taxCode(taxCode: TaxCode?) = taxCode(JsonField.ofNullable(taxCode)) + fun reasonCode(reasonCode: JsonField) = apply { + this.reasonCode = reasonCode + } - /** Alias for calling [Builder.taxCode] with `taxCode.orElse(null)`. */ - fun taxCode(taxCode: Optional) = taxCode(taxCode.getOrNull()) + /** The VAT category code that applies to the allowance */ + fun taxCode(taxCode: TaxCode) = taxCode(JsonField.of(taxCode)) /** * Sets [Builder.taxCode] to an arbitrary JSON value. @@ -2653,7 +2594,10 @@ private constructor( */ fun taxCode(taxCode: JsonField) = apply { this.taxCode = taxCode } - /** The VAT rate, represented as percentage that applies to the allowance */ + /** + * The VAT rate, represented as percentage that applies to the allowance. Must be + * rounded to maximum 2 decimals + */ fun taxRate(taxRate: String?) = taxRate(JsonField.ofNullable(taxRate)) /** Alias for calling [Builder.taxRate] with `taxRate.orElse(null)`. */ @@ -2716,7 +2660,7 @@ private constructor( baseAmount() multiplierFactor() reason() - reasonCode() + reasonCode().ifPresent { it.validate() } taxCode().ifPresent { it.validate() } taxRate() validated = true @@ -2742,15 +2686,245 @@ private constructor( (if (baseAmount.asKnown().isPresent) 1 else 0) + (if (multiplierFactor.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) + - (if (reasonCode.asKnown().isPresent) 1 else 0) + + (reasonCode.asKnown().getOrNull()?.validity() ?: 0) + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + (if (taxRate.asKnown().isPresent) 1 else 0) - /** - * Duty or tax or fee category codes (Subset of UNCL5305) - * - * Agency: UN/CEFACT Version: D.16B Subset: OpenPEPPOL - */ + /** Allowance reason codes for invoice discounts and charges */ + class ReasonCode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val _41 = of("41") + + @JvmField val _42 = of("42") + + @JvmField val _60 = of("60") + + @JvmField val _62 = of("62") + + @JvmField val _63 = of("63") + + @JvmField val _64 = of("64") + + @JvmField val _65 = of("65") + + @JvmField val _66 = of("66") + + @JvmField val _67 = of("67") + + @JvmField val _68 = of("68") + + @JvmField val _70 = of("70") + + @JvmField val _71 = of("71") + + @JvmField val _88 = of("88") + + @JvmField val _95 = of("95") + + @JvmField val _100 = of("100") + + @JvmField val _102 = of("102") + + @JvmField val _103 = of("103") + + @JvmField val _104 = of("104") + + @JvmField val _105 = of("105") + + @JvmStatic fun of(value: String) = ReasonCode(JsonField.of(value)) + } + + /** An enum containing [ReasonCode]'s known values. */ + enum class Known { + _41, + _42, + _60, + _62, + _63, + _64, + _65, + _66, + _67, + _68, + _70, + _71, + _88, + _95, + _100, + _102, + _103, + _104, + _105, + } + + /** + * An enum containing [ReasonCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ReasonCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + _41, + _42, + _60, + _62, + _63, + _64, + _65, + _66, + _67, + _68, + _70, + _71, + _88, + _95, + _100, + _102, + _103, + _104, + _105, + /** + * An enum member indicating that [ReasonCode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + _41 -> Value._41 + _42 -> Value._42 + _60 -> Value._60 + _62 -> Value._62 + _63 -> Value._63 + _64 -> Value._64 + _65 -> Value._65 + _66 -> Value._66 + _67 -> Value._67 + _68 -> Value._68 + _70 -> Value._70 + _71 -> Value._71 + _88 -> Value._88 + _95 -> Value._95 + _100 -> Value._100 + _102 -> Value._102 + _103 -> Value._103 + _104 -> Value._104 + _105 -> Value._105 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + _41 -> Known._41 + _42 -> Known._42 + _60 -> Known._60 + _62 -> Known._62 + _63 -> Known._63 + _64 -> Known._64 + _65 -> Known._65 + _66 -> Known._66 + _67 -> Known._67 + _68 -> Known._68 + _70 -> Known._70 + _71 -> Known._71 + _88 -> Known._88 + _95 -> Known._95 + _100 -> Known._100 + _102 -> Known._102 + _103 -> Known._103 + _104 -> Known._104 + _105 -> Known._105 + else -> throw EInvoiceInvalidDataException("Unknown ReasonCode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReasonCode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReasonCode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The VAT category code that applies to the allowance */ class TaxCode @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -2971,7 +3145,7 @@ private constructor( private val baseAmount: JsonField, private val multiplierFactor: JsonField, private val reason: JsonField, - private val reasonCode: JsonField, + private val reasonCode: JsonField, private val taxCode: JsonField, private val taxRate: JsonField, private val additionalProperties: MutableMap, @@ -2989,7 +3163,7 @@ private constructor( @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of(), @JsonProperty("reason_code") @ExcludeMissing - reasonCode: JsonField = JsonMissing.of(), + reasonCode: JsonField = JsonMissing.of(), @JsonProperty("tax_code") @ExcludeMissing taxCode: JsonField = JsonMissing.of(), @@ -3040,12 +3214,12 @@ private constructor( fun reason(): Optional = reason.getOptional("reason") /** - * The code for the charge reason + * Charge reason codes for invoice charges and fees * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun reasonCode(): Optional = reasonCode.getOptional("reason_code") + fun reasonCode(): Optional = reasonCode.getOptional("reason_code") /** * Duty or tax or fee category codes (Subset of UNCL5305) @@ -3105,7 +3279,7 @@ private constructor( */ @JsonProperty("reason_code") @ExcludeMissing - fun _reasonCode(): JsonField = reasonCode + fun _reasonCode(): JsonField = reasonCode /** * Returns the raw JSON value of [taxCode]. @@ -3146,7 +3320,7 @@ private constructor( private var baseAmount: JsonField = JsonMissing.of() private var multiplierFactor: JsonField = JsonMissing.of() private var reason: JsonField = JsonMissing.of() - private var reasonCode: JsonField = JsonMissing.of() + private var reasonCode: JsonField = JsonMissing.of() private var taxCode: JsonField = JsonMissing.of() private var taxRate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -3235,20 +3409,22 @@ private constructor( */ fun reason(reason: JsonField) = apply { this.reason = reason } - /** The code for the charge reason */ - fun reasonCode(reasonCode: String?) = reasonCode(JsonField.ofNullable(reasonCode)) + /** Charge reason codes for invoice charges and fees */ + fun reasonCode(reasonCode: ReasonCode?) = reasonCode(JsonField.ofNullable(reasonCode)) /** Alias for calling [Builder.reasonCode] with `reasonCode.orElse(null)`. */ - fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) + fun reasonCode(reasonCode: Optional) = reasonCode(reasonCode.getOrNull()) /** * Sets [Builder.reasonCode] to an arbitrary JSON value. * - * You should usually call [Builder.reasonCode] with a well-typed [String] value + * You should usually call [Builder.reasonCode] with a well-typed [ReasonCode] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun reasonCode(reasonCode: JsonField) = apply { this.reasonCode = reasonCode } + fun reasonCode(reasonCode: JsonField) = apply { + this.reasonCode = reasonCode + } /** * Duty or tax or fee category codes (Subset of UNCL5305) @@ -3332,7 +3508,7 @@ private constructor( baseAmount() multiplierFactor() reason() - reasonCode() + reasonCode().ifPresent { it.validate() } taxCode().ifPresent { it.validate() } taxRate() validated = true @@ -3358,10 +3534,1198 @@ private constructor( (if (baseAmount.asKnown().isPresent) 1 else 0) + (if (multiplierFactor.asKnown().isPresent) 1 else 0) + (if (reason.asKnown().isPresent) 1 else 0) + - (if (reasonCode.asKnown().isPresent) 1 else 0) + + (reasonCode.asKnown().getOrNull()?.validity() ?: 0) + (taxCode.asKnown().getOrNull()?.validity() ?: 0) + (if (taxRate.asKnown().isPresent) 1 else 0) + /** Charge reason codes for invoice charges and fees */ + class ReasonCode @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val AA = of("AA") + + @JvmField val AAA = of("AAA") + + @JvmField val AAC = of("AAC") + + @JvmField val AAD = of("AAD") + + @JvmField val AAE = of("AAE") + + @JvmField val AAF = of("AAF") + + @JvmField val AAH = of("AAH") + + @JvmField val AAI = of("AAI") + + @JvmField val AAS = of("AAS") + + @JvmField val AAT = of("AAT") + + @JvmField val AAV = of("AAV") + + @JvmField val AAY = of("AAY") + + @JvmField val AAZ = of("AAZ") + + @JvmField val ABA = of("ABA") + + @JvmField val ABB = of("ABB") + + @JvmField val ABC = of("ABC") + + @JvmField val ABD = of("ABD") + + @JvmField val ABF = of("ABF") + + @JvmField val ABK = of("ABK") + + @JvmField val ABL = of("ABL") + + @JvmField val ABN = of("ABN") + + @JvmField val ABR = of("ABR") + + @JvmField val ABS = of("ABS") + + @JvmField val ABT = of("ABT") + + @JvmField val ABU = of("ABU") + + @JvmField val ACF = of("ACF") + + @JvmField val ACG = of("ACG") + + @JvmField val ACH = of("ACH") + + @JvmField val ACI = of("ACI") + + @JvmField val ACJ = of("ACJ") + + @JvmField val ACK = of("ACK") + + @JvmField val ACL = of("ACL") + + @JvmField val ACM = of("ACM") + + @JvmField val ACS = of("ACS") + + @JvmField val ADC = of("ADC") + + @JvmField val ADE = of("ADE") + + @JvmField val ADJ = of("ADJ") + + @JvmField val ADK = of("ADK") + + @JvmField val ADL = of("ADL") + + @JvmField val ADM = of("ADM") + + @JvmField val ADN = of("ADN") + + @JvmField val ADO = of("ADO") + + @JvmField val ADP = of("ADP") + + @JvmField val ADQ = of("ADQ") + + @JvmField val ADR = of("ADR") + + @JvmField val ADT = of("ADT") + + @JvmField val ADW = of("ADW") + + @JvmField val ADY = of("ADY") + + @JvmField val ADZ = of("ADZ") + + @JvmField val AEA = of("AEA") + + @JvmField val AEB = of("AEB") + + @JvmField val AEC = of("AEC") + + @JvmField val AED = of("AED") + + @JvmField val AEF = of("AEF") + + @JvmField val AEH = of("AEH") + + @JvmField val AEI = of("AEI") + + @JvmField val AEJ = of("AEJ") + + @JvmField val AEK = of("AEK") + + @JvmField val AEL = of("AEL") + + @JvmField val AEM = of("AEM") + + @JvmField val AEN = of("AEN") + + @JvmField val AEO = of("AEO") + + @JvmField val AEP = of("AEP") + + @JvmField val AES = of("AES") + + @JvmField val AET = of("AET") + + @JvmField val AEU = of("AEU") + + @JvmField val AEV = of("AEV") + + @JvmField val AEW = of("AEW") + + @JvmField val AEX = of("AEX") + + @JvmField val AEY = of("AEY") + + @JvmField val AEZ = of("AEZ") + + @JvmField val AJ = of("AJ") + + @JvmField val AU = of("AU") + + @JvmField val CA = of("CA") + + @JvmField val CAB = of("CAB") + + @JvmField val CAD = of("CAD") + + @JvmField val CAE = of("CAE") + + @JvmField val CAF = of("CAF") + + @JvmField val CAI = of("CAI") + + @JvmField val CAJ = of("CAJ") + + @JvmField val CAK = of("CAK") + + @JvmField val CAL = of("CAL") + + @JvmField val CAM = of("CAM") + + @JvmField val CAN = of("CAN") + + @JvmField val CAO = of("CAO") + + @JvmField val CAP = of("CAP") + + @JvmField val CAQ = of("CAQ") + + @JvmField val CAR = of("CAR") + + @JvmField val CAS = of("CAS") + + @JvmField val CAT = of("CAT") + + @JvmField val CAU = of("CAU") + + @JvmField val CAV = of("CAV") + + @JvmField val CAW = of("CAW") + + @JvmField val CAX = of("CAX") + + @JvmField val CAY = of("CAY") + + @JvmField val CAZ = of("CAZ") + + @JvmField val CD = of("CD") + + @JvmField val CG = of("CG") + + @JvmField val CS = of("CS") + + @JvmField val CT = of("CT") + + @JvmField val DAB = of("DAB") + + @JvmField val DAC = of("DAC") + + @JvmField val DAD = of("DAD") + + @JvmField val DAF = of("DAF") + + @JvmField val DAG = of("DAG") + + @JvmField val DAH = of("DAH") + + @JvmField val DAI = of("DAI") + + @JvmField val DAJ = of("DAJ") + + @JvmField val DAK = of("DAK") + + @JvmField val DAL = of("DAL") + + @JvmField val DAM = of("DAM") + + @JvmField val DAN = of("DAN") + + @JvmField val DAO = of("DAO") + + @JvmField val DAP = of("DAP") + + @JvmField val DAQ = of("DAQ") + + @JvmField val DL = of("DL") + + @JvmField val EG = of("EG") + + @JvmField val EP = of("EP") + + @JvmField val ER = of("ER") + + @JvmField val FAA = of("FAA") + + @JvmField val FAB = of("FAB") + + @JvmField val FAC = of("FAC") + + @JvmField val FC = of("FC") + + @JvmField val FH = of("FH") + + @JvmField val FI = of("FI") + + @JvmField val GAA = of("GAA") + + @JvmField val HAA = of("HAA") + + @JvmField val HD = of("HD") + + @JvmField val HH = of("HH") + + @JvmField val IAA = of("IAA") + + @JvmField val IAB = of("IAB") + + @JvmField val ID = of("ID") + + @JvmField val IF = of("IF") + + @JvmField val IR = of("IR") + + @JvmField val IS = of("IS") + + @JvmField val KO = of("KO") + + @JvmField val L1 = of("L1") + + @JvmField val LA = of("LA") + + @JvmField val LAA = of("LAA") + + @JvmField val LAB = of("LAB") + + @JvmField val LF = of("LF") + + @JvmField val MAE = of("MAE") + + @JvmField val MI = of("MI") + + @JvmField val ML = of("ML") + + @JvmField val NAA = of("NAA") + + @JvmField val OA = of("OA") + + @JvmField val PA = of("PA") + + @JvmField val PAA = of("PAA") + + @JvmField val PC = of("PC") + + @JvmField val PL = of("PL") + + @JvmField val PRV = of("PRV") + + @JvmField val RAB = of("RAB") + + @JvmField val RAC = of("RAC") + + @JvmField val RAD = of("RAD") + + @JvmField val RAF = of("RAF") + + @JvmField val RE = of("RE") + + @JvmField val RF = of("RF") + + @JvmField val RH = of("RH") + + @JvmField val RV = of("RV") + + @JvmField val SA = of("SA") + + @JvmField val SAA = of("SAA") + + @JvmField val SAD = of("SAD") + + @JvmField val SAE = of("SAE") + + @JvmField val SAI = of("SAI") + + @JvmField val SG = of("SG") + + @JvmField val SH = of("SH") + + @JvmField val SM = of("SM") + + @JvmField val SU = of("SU") + + @JvmField val TAB = of("TAB") + + @JvmField val TAC = of("TAC") + + @JvmField val TT = of("TT") + + @JvmField val TV = of("TV") + + @JvmField val V1 = of("V1") + + @JvmField val V2 = of("V2") + + @JvmField val WH = of("WH") + + @JvmField val XAA = of("XAA") + + @JvmField val YY = of("YY") + + @JvmField val ZZZ = of("ZZZ") + + @JvmStatic fun of(value: String) = ReasonCode(JsonField.of(value)) + } + + /** An enum containing [ReasonCode]'s known values. */ + enum class Known { + AA, + AAA, + AAC, + AAD, + AAE, + AAF, + AAH, + AAI, + AAS, + AAT, + AAV, + AAY, + AAZ, + ABA, + ABB, + ABC, + ABD, + ABF, + ABK, + ABL, + ABN, + ABR, + ABS, + ABT, + ABU, + ACF, + ACG, + ACH, + ACI, + ACJ, + ACK, + ACL, + ACM, + ACS, + ADC, + ADE, + ADJ, + ADK, + ADL, + ADM, + ADN, + ADO, + ADP, + ADQ, + ADR, + ADT, + ADW, + ADY, + ADZ, + AEA, + AEB, + AEC, + AED, + AEF, + AEH, + AEI, + AEJ, + AEK, + AEL, + AEM, + AEN, + AEO, + AEP, + AES, + AET, + AEU, + AEV, + AEW, + AEX, + AEY, + AEZ, + AJ, + AU, + CA, + CAB, + CAD, + CAE, + CAF, + CAI, + CAJ, + CAK, + CAL, + CAM, + CAN, + CAO, + CAP, + CAQ, + CAR, + CAS, + CAT, + CAU, + CAV, + CAW, + CAX, + CAY, + CAZ, + CD, + CG, + CS, + CT, + DAB, + DAC, + DAD, + DAF, + DAG, + DAH, + DAI, + DAJ, + DAK, + DAL, + DAM, + DAN, + DAO, + DAP, + DAQ, + DL, + EG, + EP, + ER, + FAA, + FAB, + FAC, + FC, + FH, + FI, + GAA, + HAA, + HD, + HH, + IAA, + IAB, + ID, + IF, + IR, + IS, + KO, + L1, + LA, + LAA, + LAB, + LF, + MAE, + MI, + ML, + NAA, + OA, + PA, + PAA, + PC, + PL, + PRV, + RAB, + RAC, + RAD, + RAF, + RE, + RF, + RH, + RV, + SA, + SAA, + SAD, + SAE, + SAI, + SG, + SH, + SM, + SU, + TAB, + TAC, + TT, + TV, + V1, + V2, + WH, + XAA, + YY, + ZZZ, + } + + /** + * An enum containing [ReasonCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [ReasonCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + AA, + AAA, + AAC, + AAD, + AAE, + AAF, + AAH, + AAI, + AAS, + AAT, + AAV, + AAY, + AAZ, + ABA, + ABB, + ABC, + ABD, + ABF, + ABK, + ABL, + ABN, + ABR, + ABS, + ABT, + ABU, + ACF, + ACG, + ACH, + ACI, + ACJ, + ACK, + ACL, + ACM, + ACS, + ADC, + ADE, + ADJ, + ADK, + ADL, + ADM, + ADN, + ADO, + ADP, + ADQ, + ADR, + ADT, + ADW, + ADY, + ADZ, + AEA, + AEB, + AEC, + AED, + AEF, + AEH, + AEI, + AEJ, + AEK, + AEL, + AEM, + AEN, + AEO, + AEP, + AES, + AET, + AEU, + AEV, + AEW, + AEX, + AEY, + AEZ, + AJ, + AU, + CA, + CAB, + CAD, + CAE, + CAF, + CAI, + CAJ, + CAK, + CAL, + CAM, + CAN, + CAO, + CAP, + CAQ, + CAR, + CAS, + CAT, + CAU, + CAV, + CAW, + CAX, + CAY, + CAZ, + CD, + CG, + CS, + CT, + DAB, + DAC, + DAD, + DAF, + DAG, + DAH, + DAI, + DAJ, + DAK, + DAL, + DAM, + DAN, + DAO, + DAP, + DAQ, + DL, + EG, + EP, + ER, + FAA, + FAB, + FAC, + FC, + FH, + FI, + GAA, + HAA, + HD, + HH, + IAA, + IAB, + ID, + IF, + IR, + IS, + KO, + L1, + LA, + LAA, + LAB, + LF, + MAE, + MI, + ML, + NAA, + OA, + PA, + PAA, + PC, + PL, + PRV, + RAB, + RAC, + RAD, + RAF, + RE, + RF, + RH, + RV, + SA, + SAA, + SAD, + SAE, + SAI, + SG, + SH, + SM, + SU, + TAB, + TAC, + TT, + TV, + V1, + V2, + WH, + XAA, + YY, + ZZZ, + /** + * An enum member indicating that [ReasonCode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + AA -> Value.AA + AAA -> Value.AAA + AAC -> Value.AAC + AAD -> Value.AAD + AAE -> Value.AAE + AAF -> Value.AAF + AAH -> Value.AAH + AAI -> Value.AAI + AAS -> Value.AAS + AAT -> Value.AAT + AAV -> Value.AAV + AAY -> Value.AAY + AAZ -> Value.AAZ + ABA -> Value.ABA + ABB -> Value.ABB + ABC -> Value.ABC + ABD -> Value.ABD + ABF -> Value.ABF + ABK -> Value.ABK + ABL -> Value.ABL + ABN -> Value.ABN + ABR -> Value.ABR + ABS -> Value.ABS + ABT -> Value.ABT + ABU -> Value.ABU + ACF -> Value.ACF + ACG -> Value.ACG + ACH -> Value.ACH + ACI -> Value.ACI + ACJ -> Value.ACJ + ACK -> Value.ACK + ACL -> Value.ACL + ACM -> Value.ACM + ACS -> Value.ACS + ADC -> Value.ADC + ADE -> Value.ADE + ADJ -> Value.ADJ + ADK -> Value.ADK + ADL -> Value.ADL + ADM -> Value.ADM + ADN -> Value.ADN + ADO -> Value.ADO + ADP -> Value.ADP + ADQ -> Value.ADQ + ADR -> Value.ADR + ADT -> Value.ADT + ADW -> Value.ADW + ADY -> Value.ADY + ADZ -> Value.ADZ + AEA -> Value.AEA + AEB -> Value.AEB + AEC -> Value.AEC + AED -> Value.AED + AEF -> Value.AEF + AEH -> Value.AEH + AEI -> Value.AEI + AEJ -> Value.AEJ + AEK -> Value.AEK + AEL -> Value.AEL + AEM -> Value.AEM + AEN -> Value.AEN + AEO -> Value.AEO + AEP -> Value.AEP + AES -> Value.AES + AET -> Value.AET + AEU -> Value.AEU + AEV -> Value.AEV + AEW -> Value.AEW + AEX -> Value.AEX + AEY -> Value.AEY + AEZ -> Value.AEZ + AJ -> Value.AJ + AU -> Value.AU + CA -> Value.CA + CAB -> Value.CAB + CAD -> Value.CAD + CAE -> Value.CAE + CAF -> Value.CAF + CAI -> Value.CAI + CAJ -> Value.CAJ + CAK -> Value.CAK + CAL -> Value.CAL + CAM -> Value.CAM + CAN -> Value.CAN + CAO -> Value.CAO + CAP -> Value.CAP + CAQ -> Value.CAQ + CAR -> Value.CAR + CAS -> Value.CAS + CAT -> Value.CAT + CAU -> Value.CAU + CAV -> Value.CAV + CAW -> Value.CAW + CAX -> Value.CAX + CAY -> Value.CAY + CAZ -> Value.CAZ + CD -> Value.CD + CG -> Value.CG + CS -> Value.CS + CT -> Value.CT + DAB -> Value.DAB + DAC -> Value.DAC + DAD -> Value.DAD + DAF -> Value.DAF + DAG -> Value.DAG + DAH -> Value.DAH + DAI -> Value.DAI + DAJ -> Value.DAJ + DAK -> Value.DAK + DAL -> Value.DAL + DAM -> Value.DAM + DAN -> Value.DAN + DAO -> Value.DAO + DAP -> Value.DAP + DAQ -> Value.DAQ + DL -> Value.DL + EG -> Value.EG + EP -> Value.EP + ER -> Value.ER + FAA -> Value.FAA + FAB -> Value.FAB + FAC -> Value.FAC + FC -> Value.FC + FH -> Value.FH + FI -> Value.FI + GAA -> Value.GAA + HAA -> Value.HAA + HD -> Value.HD + HH -> Value.HH + IAA -> Value.IAA + IAB -> Value.IAB + ID -> Value.ID + IF -> Value.IF + IR -> Value.IR + IS -> Value.IS + KO -> Value.KO + L1 -> Value.L1 + LA -> Value.LA + LAA -> Value.LAA + LAB -> Value.LAB + LF -> Value.LF + MAE -> Value.MAE + MI -> Value.MI + ML -> Value.ML + NAA -> Value.NAA + OA -> Value.OA + PA -> Value.PA + PAA -> Value.PAA + PC -> Value.PC + PL -> Value.PL + PRV -> Value.PRV + RAB -> Value.RAB + RAC -> Value.RAC + RAD -> Value.RAD + RAF -> Value.RAF + RE -> Value.RE + RF -> Value.RF + RH -> Value.RH + RV -> Value.RV + SA -> Value.SA + SAA -> Value.SAA + SAD -> Value.SAD + SAE -> Value.SAE + SAI -> Value.SAI + SG -> Value.SG + SH -> Value.SH + SM -> Value.SM + SU -> Value.SU + TAB -> Value.TAB + TAC -> Value.TAC + TT -> Value.TT + TV -> Value.TV + V1 -> Value.V1 + V2 -> Value.V2 + WH -> Value.WH + XAA -> Value.XAA + YY -> Value.YY + ZZZ -> Value.ZZZ + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + AA -> Known.AA + AAA -> Known.AAA + AAC -> Known.AAC + AAD -> Known.AAD + AAE -> Known.AAE + AAF -> Known.AAF + AAH -> Known.AAH + AAI -> Known.AAI + AAS -> Known.AAS + AAT -> Known.AAT + AAV -> Known.AAV + AAY -> Known.AAY + AAZ -> Known.AAZ + ABA -> Known.ABA + ABB -> Known.ABB + ABC -> Known.ABC + ABD -> Known.ABD + ABF -> Known.ABF + ABK -> Known.ABK + ABL -> Known.ABL + ABN -> Known.ABN + ABR -> Known.ABR + ABS -> Known.ABS + ABT -> Known.ABT + ABU -> Known.ABU + ACF -> Known.ACF + ACG -> Known.ACG + ACH -> Known.ACH + ACI -> Known.ACI + ACJ -> Known.ACJ + ACK -> Known.ACK + ACL -> Known.ACL + ACM -> Known.ACM + ACS -> Known.ACS + ADC -> Known.ADC + ADE -> Known.ADE + ADJ -> Known.ADJ + ADK -> Known.ADK + ADL -> Known.ADL + ADM -> Known.ADM + ADN -> Known.ADN + ADO -> Known.ADO + ADP -> Known.ADP + ADQ -> Known.ADQ + ADR -> Known.ADR + ADT -> Known.ADT + ADW -> Known.ADW + ADY -> Known.ADY + ADZ -> Known.ADZ + AEA -> Known.AEA + AEB -> Known.AEB + AEC -> Known.AEC + AED -> Known.AED + AEF -> Known.AEF + AEH -> Known.AEH + AEI -> Known.AEI + AEJ -> Known.AEJ + AEK -> Known.AEK + AEL -> Known.AEL + AEM -> Known.AEM + AEN -> Known.AEN + AEO -> Known.AEO + AEP -> Known.AEP + AES -> Known.AES + AET -> Known.AET + AEU -> Known.AEU + AEV -> Known.AEV + AEW -> Known.AEW + AEX -> Known.AEX + AEY -> Known.AEY + AEZ -> Known.AEZ + AJ -> Known.AJ + AU -> Known.AU + CA -> Known.CA + CAB -> Known.CAB + CAD -> Known.CAD + CAE -> Known.CAE + CAF -> Known.CAF + CAI -> Known.CAI + CAJ -> Known.CAJ + CAK -> Known.CAK + CAL -> Known.CAL + CAM -> Known.CAM + CAN -> Known.CAN + CAO -> Known.CAO + CAP -> Known.CAP + CAQ -> Known.CAQ + CAR -> Known.CAR + CAS -> Known.CAS + CAT -> Known.CAT + CAU -> Known.CAU + CAV -> Known.CAV + CAW -> Known.CAW + CAX -> Known.CAX + CAY -> Known.CAY + CAZ -> Known.CAZ + CD -> Known.CD + CG -> Known.CG + CS -> Known.CS + CT -> Known.CT + DAB -> Known.DAB + DAC -> Known.DAC + DAD -> Known.DAD + DAF -> Known.DAF + DAG -> Known.DAG + DAH -> Known.DAH + DAI -> Known.DAI + DAJ -> Known.DAJ + DAK -> Known.DAK + DAL -> Known.DAL + DAM -> Known.DAM + DAN -> Known.DAN + DAO -> Known.DAO + DAP -> Known.DAP + DAQ -> Known.DAQ + DL -> Known.DL + EG -> Known.EG + EP -> Known.EP + ER -> Known.ER + FAA -> Known.FAA + FAB -> Known.FAB + FAC -> Known.FAC + FC -> Known.FC + FH -> Known.FH + FI -> Known.FI + GAA -> Known.GAA + HAA -> Known.HAA + HD -> Known.HD + HH -> Known.HH + IAA -> Known.IAA + IAB -> Known.IAB + ID -> Known.ID + IF -> Known.IF + IR -> Known.IR + IS -> Known.IS + KO -> Known.KO + L1 -> Known.L1 + LA -> Known.LA + LAA -> Known.LAA + LAB -> Known.LAB + LF -> Known.LF + MAE -> Known.MAE + MI -> Known.MI + ML -> Known.ML + NAA -> Known.NAA + OA -> Known.OA + PA -> Known.PA + PAA -> Known.PAA + PC -> Known.PC + PL -> Known.PL + PRV -> Known.PRV + RAB -> Known.RAB + RAC -> Known.RAC + RAD -> Known.RAD + RAF -> Known.RAF + RE -> Known.RE + RF -> Known.RF + RH -> Known.RH + RV -> Known.RV + SA -> Known.SA + SAA -> Known.SAA + SAD -> Known.SAD + SAE -> Known.SAE + SAI -> Known.SAI + SG -> Known.SG + SH -> Known.SH + SM -> Known.SM + SU -> Known.SU + TAB -> Known.TAB + TAC -> Known.TAC + TT -> Known.TT + TV -> Known.TV + V1 -> Known.V1 + V2 -> Known.V2 + WH -> Known.WH + XAA -> Known.XAA + YY -> Known.YY + ZZZ -> Known.ZZZ + else -> throw EInvoiceInvalidDataException("Unknown ReasonCode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): ReasonCode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ReasonCode && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + /** * Duty or tax or fee category codes (Subset of UNCL5305) * @@ -3648,8 +5012,10 @@ private constructor( fun allowances(): Optional> = allowances.getOptional("allowances") /** - * The total amount of the line item, exclusive of VAT, after subtracting line level - * allowances and adding line level charges. Must be rounded to maximum 2 decimals + * The invoice line net amount (BT-131), exclusive of VAT, inclusive of line level + * allowances and charges. Calculated as: ((unit_price / price_base_quantity) * quantity) - + * allowances + charges. Must be rounded to maximum 2 decimals. Can be negative for credit + * notes or corrections. * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -3688,7 +5054,7 @@ private constructor( /** * The quantity of items (goods or services) that is the subject of the line item. Must be - * rounded to maximum 4 decimals + * rounded to maximum 4 decimals. Can be negative for credit notes or corrections. * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -3696,7 +5062,8 @@ private constructor( fun quantity(): Optional = quantity.getOptional("quantity") /** - * The total VAT amount for the line item. Must be rounded to maximum 2 decimals + * The total VAT amount for the line item. Must be rounded to maximum 2 decimals. Can be + * negative for credit notes or corrections. * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -3720,7 +5087,8 @@ private constructor( fun unit(): Optional = unit.getOptional("unit") /** - * The unit price of the line item. Must be rounded to maximum 2 decimals + * The item net price (BT-146). The price of an item, exclusive of VAT, after subtracting + * item price discount. Must be rounded to maximum 4 decimals * * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -3892,8 +5260,10 @@ private constructor( } /** - * The total amount of the line item, exclusive of VAT, after subtracting line level - * allowances and adding line level charges. Must be rounded to maximum 2 decimals + * The invoice line net amount (BT-131), exclusive of VAT, inclusive of line level + * allowances and charges. Calculated as: ((unit_price / price_base_quantity) * + * quantity) - allowances + charges. Must be rounded to maximum 2 decimals. Can be + * negative for credit notes or corrections. */ fun amount(amount: String?) = amount(JsonField.ofNullable(amount)) @@ -3988,7 +5358,7 @@ private constructor( /** * The quantity of items (goods or services) that is the subject of the line item. Must - * be rounded to maximum 4 decimals + * be rounded to maximum 4 decimals. Can be negative for credit notes or corrections. */ fun quantity(quantity: String?) = quantity(JsonField.ofNullable(quantity)) @@ -4004,7 +5374,10 @@ private constructor( */ fun quantity(quantity: JsonField) = apply { this.quantity = quantity } - /** The total VAT amount for the line item. Must be rounded to maximum 2 decimals */ + /** + * The total VAT amount for the line item. Must be rounded to maximum 2 decimals. Can be + * negative for credit notes or corrections. + */ fun tax(tax: String?) = tax(JsonField.ofNullable(tax)) /** Alias for calling [Builder.tax] with `tax.orElse(null)`. */ @@ -4049,7 +5422,10 @@ private constructor( */ fun unit(unit: JsonField) = apply { this.unit = unit } - /** The unit price of the line item. Must be rounded to maximum 2 decimals */ + /** + * The item net price (BT-146). The price of an item, exclusive of VAT, after + * subtracting item price discount. Must be rounded to maximum 4 decimals + */ fun unitPrice(unitPrice: String?) = unitPrice(JsonField.ofNullable(unitPrice)) /** Alias for calling [Builder.unitPrice] with `unitPrice.orElse(null)`. */ @@ -5373,7 +6749,6 @@ private constructor( note == other.note && paymentDetails == other.paymentDetails && paymentTerm == other.paymentTerm && - previousUnpaidBalance == other.previousUnpaidBalance && purchaseOrder == other.purchaseOrder && remittanceAddress == other.remittanceAddress && remittanceAddressRecipient == other.remittanceAddressRecipient && @@ -5427,7 +6802,6 @@ private constructor( note, paymentDetails, paymentTerm, - previousUnpaidBalance, purchaseOrder, remittanceAddress, remittanceAddressRecipient, @@ -5458,5 +6832,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "DocumentResponse{id=$id, allowances=$allowances, amountDue=$amountDue, attachments=$attachments, billingAddress=$billingAddress, billingAddressRecipient=$billingAddressRecipient, charges=$charges, currency=$currency, customerAddress=$customerAddress, customerAddressRecipient=$customerAddressRecipient, customerCompanyId=$customerCompanyId, customerEmail=$customerEmail, customerId=$customerId, customerName=$customerName, customerTaxId=$customerTaxId, direction=$direction, documentType=$documentType, dueDate=$dueDate, invoiceDate=$invoiceDate, invoiceId=$invoiceId, invoiceTotal=$invoiceTotal, items=$items, note=$note, paymentDetails=$paymentDetails, paymentTerm=$paymentTerm, previousUnpaidBalance=$previousUnpaidBalance, purchaseOrder=$purchaseOrder, remittanceAddress=$remittanceAddress, remittanceAddressRecipient=$remittanceAddressRecipient, serviceAddress=$serviceAddress, serviceAddressRecipient=$serviceAddressRecipient, serviceEndDate=$serviceEndDate, serviceStartDate=$serviceStartDate, shippingAddress=$shippingAddress, shippingAddressRecipient=$shippingAddressRecipient, state=$state, subtotal=$subtotal, taxCode=$taxCode, taxDetails=$taxDetails, totalDiscount=$totalDiscount, totalTax=$totalTax, vatex=$vatex, vatexNote=$vatexNote, vendorAddress=$vendorAddress, vendorAddressRecipient=$vendorAddressRecipient, vendorCompanyId=$vendorCompanyId, vendorEmail=$vendorEmail, vendorName=$vendorName, vendorTaxId=$vendorTaxId, additionalProperties=$additionalProperties}" + "DocumentResponse{id=$id, allowances=$allowances, amountDue=$amountDue, attachments=$attachments, billingAddress=$billingAddress, billingAddressRecipient=$billingAddressRecipient, charges=$charges, currency=$currency, customerAddress=$customerAddress, customerAddressRecipient=$customerAddressRecipient, customerCompanyId=$customerCompanyId, customerEmail=$customerEmail, customerId=$customerId, customerName=$customerName, customerTaxId=$customerTaxId, direction=$direction, documentType=$documentType, dueDate=$dueDate, invoiceDate=$invoiceDate, invoiceId=$invoiceId, invoiceTotal=$invoiceTotal, items=$items, note=$note, paymentDetails=$paymentDetails, paymentTerm=$paymentTerm, purchaseOrder=$purchaseOrder, remittanceAddress=$remittanceAddress, remittanceAddressRecipient=$remittanceAddressRecipient, serviceAddress=$serviceAddress, serviceAddressRecipient=$serviceAddressRecipient, serviceEndDate=$serviceEndDate, serviceStartDate=$serviceStartDate, shippingAddress=$shippingAddress, shippingAddressRecipient=$shippingAddressRecipient, state=$state, subtotal=$subtotal, taxCode=$taxCode, taxDetails=$taxDetails, totalDiscount=$totalDiscount, totalTax=$totalTax, vatex=$vatex, vatexNote=$vatexNote, vendorAddress=$vendorAddress, vendorAddressRecipient=$vendorAddressRecipient, vendorCompanyId=$vendorCompanyId, vendorEmail=$vendorEmail, vendorName=$vendorName, vendorTaxId=$vendorTaxId, additionalProperties=$additionalProperties}" } diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/UnitOfMeasureCode.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/UnitOfMeasureCode.kt index 2214a3c..c28df16 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/UnitOfMeasureCode.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/UnitOfMeasureCode.kt @@ -2084,6 +2084,8 @@ class UnitOfMeasureCode @JsonCreator private constructor(private val value: Json @JvmField val LTR = of("LTR") + @JvmField val H87 = of("H87") + @JvmStatic fun of(value: String) = UnitOfMeasureCode(JsonField.of(value)) } @@ -3120,6 +3122,7 @@ class UnitOfMeasureCode @JsonCreator private constructor(private val value: Json NAR, C62, LTR, + H87, } /** @@ -4163,6 +4166,7 @@ class UnitOfMeasureCode @JsonCreator private constructor(private val value: Json NAR, C62, LTR, + H87, /** * An enum member indicating that [UnitOfMeasureCode] was instantiated with an unknown * value. @@ -5210,6 +5214,7 @@ class UnitOfMeasureCode @JsonCreator private constructor(private val value: Json NAR -> Value.NAR C62 -> Value.C62 LTR -> Value.LTR + H87 -> Value.H87 else -> Value._UNKNOWN } @@ -6254,6 +6259,7 @@ class UnitOfMeasureCode @JsonCreator private constructor(private val value: Json NAR -> Known.NAR C62 -> Known.C62 LTR -> Known.LTR + H87 -> Known.H87 else -> throw EInvoiceInvalidDataException("Unknown UnitOfMeasureCode: $value") } diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/AllowanceTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/AllowanceTest.kt index 5f6c011..ecb459f 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/AllowanceTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/AllowanceTest.kt @@ -17,7 +17,7 @@ internal class AllowanceTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Allowance.ReasonCode._41) .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -26,7 +26,7 @@ internal class AllowanceTest { assertThat(allowance.baseAmount()).contains("base_amount") assertThat(allowance.multiplierFactor()).contains("multiplier_factor") assertThat(allowance.reason()).contains("reason") - assertThat(allowance.reasonCode()).contains("reason_code") + assertThat(allowance.reasonCode()).contains(Allowance.ReasonCode._41) assertThat(allowance.taxCode()).contains(Allowance.TaxCode.AE) assertThat(allowance.taxRate()).contains("tax_rate") } @@ -40,7 +40,7 @@ internal class AllowanceTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Allowance.ReasonCode._41) .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/ChargeTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/ChargeTest.kt index 8a868cb..f308f4e 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/ChargeTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/ChargeTest.kt @@ -17,18 +17,18 @@ internal class ChargeTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Charge.ReasonCode.AA) .taxCode(Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() assertThat(charge.amount()).contains("amount") assertThat(charge.baseAmount()).contains("base_amount") assertThat(charge.multiplierFactor()).contains("multiplier_factor") assertThat(charge.reason()).contains("reason") - assertThat(charge.reasonCode()).contains("reason_code") + assertThat(charge.reasonCode()).contains(Charge.ReasonCode.AA) assertThat(charge.taxCode()).contains(Charge.TaxCode.AE) - assertThat(charge.taxRate()).contains("tax_rate") + assertThat(charge.taxRate()).contains("21.00") } @Test @@ -40,9 +40,9 @@ internal class ChargeTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Charge.ReasonCode.AA) .taxCode(Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() val roundtrippedCharge = diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponseTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponseTest.kt index 7c7d640..0b348a2 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponseTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateFromPdfResponseTest.kt @@ -22,7 +22,7 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Allowance.ReasonCode._41) .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -44,9 +44,9 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Charge.ReasonCode.AA) .taxCode(Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -71,7 +71,7 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Allowance.ReasonCode._41) .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -83,9 +83,9 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Charge.ReasonCode.AA) .taxCode(Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -93,7 +93,7 @@ internal class DocumentCreateFromPdfResponseTest { .productCode("product_code") .quantity("quantity") .tax("tax") - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice("unit_price") .build() @@ -108,7 +108,6 @@ internal class DocumentCreateFromPdfResponseTest { .build() ) .paymentTerm("payment_term") - .previousUnpaidBalance("previous_unpaid_balance") .purchaseOrder("purchase_order") .remittanceAddress("remittance_address") .remittanceAddressRecipient("remittance_address_recipient") @@ -148,7 +147,7 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Allowance.ReasonCode._41) .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -173,9 +172,9 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Charge.ReasonCode.AA) .taxCode(Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) assertThat(documentCreateFromPdfResponse.currency()).contains(CurrencyCode.EUR) @@ -203,7 +202,7 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Allowance.ReasonCode._41) .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -215,9 +214,9 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Charge.ReasonCode.AA) .taxCode(Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -225,7 +224,7 @@ internal class DocumentCreateFromPdfResponseTest { .productCode("product_code") .quantity("quantity") .tax("tax") - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice("unit_price") .build() @@ -241,8 +240,6 @@ internal class DocumentCreateFromPdfResponseTest { .build() ) assertThat(documentCreateFromPdfResponse.paymentTerm()).contains("payment_term") - assertThat(documentCreateFromPdfResponse.previousUnpaidBalance()) - .contains("previous_unpaid_balance") assertThat(documentCreateFromPdfResponse.purchaseOrder()).contains("purchase_order") assertThat(documentCreateFromPdfResponse.remittanceAddress()).contains("remittance_address") assertThat(documentCreateFromPdfResponse.remittanceAddressRecipient()) @@ -295,7 +292,7 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Allowance.ReasonCode._41) .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -317,9 +314,9 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Charge.ReasonCode.AA) .taxCode(Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -344,7 +341,7 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Allowance.ReasonCode._41) .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -356,9 +353,9 @@ internal class DocumentCreateFromPdfResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Charge.ReasonCode.AA) .taxCode(Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -366,7 +363,7 @@ internal class DocumentCreateFromPdfResponseTest { .productCode("product_code") .quantity("quantity") .tax("tax") - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice("unit_price") .build() @@ -381,7 +378,6 @@ internal class DocumentCreateFromPdfResponseTest { .build() ) .paymentTerm("payment_term") - .previousUnpaidBalance("previous_unpaid_balance") .purchaseOrder("purchase_order") .remittanceAddress("remittance_address") .remittanceAddressRecipient("remittance_address_recipient") diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateParamsTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateParamsTest.kt index 6aec828..fd62996 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateParamsTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateParamsTest.kt @@ -20,9 +20,9 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -42,9 +42,9 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -69,9 +69,9 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -81,9 +81,9 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -91,7 +91,7 @@ internal class DocumentCreateParamsTest { .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -149,9 +149,9 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -171,9 +171,9 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -198,9 +198,9 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -210,9 +210,9 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -220,7 +220,7 @@ internal class DocumentCreateParamsTest { .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -276,9 +276,9 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -298,9 +298,9 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -325,9 +325,9 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -337,9 +337,9 @@ internal class DocumentCreateParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -347,7 +347,7 @@ internal class DocumentCreateParamsTest { .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateTest.kt index 655056f..f98cbd4 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateTest.kt @@ -22,9 +22,9 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -44,9 +44,9 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -71,9 +71,9 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -83,9 +83,9 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -93,7 +93,7 @@ internal class DocumentCreateTest { .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -141,9 +141,9 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) assertThat(documentCreate.amountDue()).contains(DocumentCreate.AmountDue.ofNumber(0.0)) @@ -165,9 +165,9 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) assertThat(documentCreate.currency()).contains(CurrencyCode.EUR) @@ -194,9 +194,9 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -206,9 +206,9 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -216,7 +216,7 @@ internal class DocumentCreateTest { .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -273,9 +273,9 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -295,9 +295,9 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -322,9 +322,9 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -334,9 +334,9 @@ internal class DocumentCreateTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -344,7 +344,7 @@ internal class DocumentCreateTest { .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentResponseTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentResponseTest.kt index a404ab7..38050f5 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentResponseTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentResponseTest.kt @@ -24,7 +24,7 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentResponse.Allowance.ReasonCode._41) .taxCode(DocumentResponse.Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -47,9 +47,9 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentResponse.Charge.ReasonCode.AA) .taxCode(DocumentResponse.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -74,7 +74,7 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Allowance.ReasonCode._41) .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -86,9 +86,9 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Charge.ReasonCode.AA) .taxCode(Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -96,7 +96,7 @@ internal class DocumentResponseTest { .productCode("product_code") .quantity("quantity") .tax("tax") - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice("unit_price") .build() @@ -111,7 +111,6 @@ internal class DocumentResponseTest { .build() ) .paymentTerm("payment_term") - .previousUnpaidBalance("previous_unpaid_balance") .purchaseOrder("purchase_order") .remittanceAddress("remittance_address") .remittanceAddressRecipient("remittance_address_recipient") @@ -147,7 +146,7 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentResponse.Allowance.ReasonCode._41) .taxCode(DocumentResponse.Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -172,9 +171,9 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentResponse.Charge.ReasonCode.AA) .taxCode(DocumentResponse.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) assertThat(documentResponse.currency()).contains(CurrencyCode.EUR) @@ -201,7 +200,7 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Allowance.ReasonCode._41) .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -213,9 +212,9 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Charge.ReasonCode.AA) .taxCode(Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -223,7 +222,7 @@ internal class DocumentResponseTest { .productCode("product_code") .quantity("quantity") .tax("tax") - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice("unit_price") .build() @@ -239,7 +238,6 @@ internal class DocumentResponseTest { .build() ) assertThat(documentResponse.paymentTerm()).contains("payment_term") - assertThat(documentResponse.previousUnpaidBalance()).contains("previous_unpaid_balance") assertThat(documentResponse.purchaseOrder()).contains("purchase_order") assertThat(documentResponse.remittanceAddress()).contains("remittance_address") assertThat(documentResponse.remittanceAddressRecipient()) @@ -282,7 +280,7 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentResponse.Allowance.ReasonCode._41) .taxCode(DocumentResponse.Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -305,9 +303,9 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentResponse.Charge.ReasonCode.AA) .taxCode(DocumentResponse.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -332,7 +330,7 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Allowance.ReasonCode._41) .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -344,9 +342,9 @@ internal class DocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Charge.ReasonCode.AA) .taxCode(Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -354,7 +352,7 @@ internal class DocumentResponseTest { .productCode("product_code") .quantity("quantity") .tax("tax") - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice("unit_price") .build() @@ -369,7 +367,6 @@ internal class DocumentResponseTest { .build() ) .paymentTerm("payment_term") - .previousUnpaidBalance("previous_unpaid_balance") .purchaseOrder("purchase_order") .remittanceAddress("remittance_address") .remittanceAddressRecipient("remittance_address_recipient") diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt index 987a7ec..89ac0d1 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt @@ -31,7 +31,7 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentResponse.Allowance.ReasonCode._41) .taxCode(DocumentResponse.Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -54,9 +54,9 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentResponse.Charge.ReasonCode.AA) .taxCode(DocumentResponse.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -81,7 +81,7 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Allowance.ReasonCode._41) .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -93,9 +93,9 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Charge.ReasonCode.AA) .taxCode(Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -103,7 +103,7 @@ internal class PaginatedDocumentResponseTest { .productCode("product_code") .quantity("quantity") .tax("tax") - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice("unit_price") .build() @@ -118,7 +118,6 @@ internal class PaginatedDocumentResponseTest { .build() ) .paymentTerm("payment_term") - .previousUnpaidBalance("previous_unpaid_balance") .purchaseOrder("purchase_order") .remittanceAddress("remittance_address") .remittanceAddressRecipient("remittance_address_recipient") @@ -165,7 +164,7 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentResponse.Allowance.ReasonCode._41) .taxCode(DocumentResponse.Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -188,9 +187,9 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentResponse.Charge.ReasonCode.AA) .taxCode(DocumentResponse.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -215,7 +214,7 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Allowance.ReasonCode._41) .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -227,9 +226,9 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Charge.ReasonCode.AA) .taxCode(Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -237,7 +236,7 @@ internal class PaginatedDocumentResponseTest { .productCode("product_code") .quantity("quantity") .tax("tax") - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice("unit_price") .build() @@ -252,7 +251,6 @@ internal class PaginatedDocumentResponseTest { .build() ) .paymentTerm("payment_term") - .previousUnpaidBalance("previous_unpaid_balance") .purchaseOrder("purchase_order") .remittanceAddress("remittance_address") .remittanceAddressRecipient("remittance_address_recipient") @@ -300,7 +298,7 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentResponse.Allowance.ReasonCode._41) .taxCode(DocumentResponse.Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -323,9 +321,9 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentResponse.Charge.ReasonCode.AA) .taxCode(DocumentResponse.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -350,7 +348,7 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Allowance.ReasonCode._41) .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() @@ -362,9 +360,9 @@ internal class PaginatedDocumentResponseTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Charge.ReasonCode.AA) .taxCode(Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -372,7 +370,7 @@ internal class PaginatedDocumentResponseTest { .productCode("product_code") .quantity("quantity") .tax("tax") - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice("unit_price") .build() @@ -387,7 +385,6 @@ internal class PaginatedDocumentResponseTest { .build() ) .paymentTerm("payment_term") - .previousUnpaidBalance("previous_unpaid_balance") .purchaseOrder("purchase_order") .remittanceAddress("remittance_address") .remittanceAddressRecipient("remittance_address_recipient") diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/validate/ValidateValidateJsonParamsTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/validate/ValidateValidateJsonParamsTest.kt index 44d2c71..c7813a7 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/validate/ValidateValidateJsonParamsTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/validate/ValidateValidateJsonParamsTest.kt @@ -27,9 +27,9 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -49,9 +49,9 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -76,9 +76,9 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -88,9 +88,9 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -98,7 +98,7 @@ internal class ValidateValidateJsonParamsTest { .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -156,9 +156,9 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -178,9 +178,9 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -205,9 +205,9 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -217,9 +217,9 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -227,7 +227,7 @@ internal class ValidateValidateJsonParamsTest { .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -283,9 +283,9 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -305,9 +305,9 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -332,9 +332,9 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -344,9 +344,9 @@ internal class ValidateValidateJsonParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -354,7 +354,7 @@ internal class ValidateValidateJsonParamsTest { .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ErrorHandlingTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ErrorHandlingTest.kt index 44a8ed8..586b80b 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ErrorHandlingTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ErrorHandlingTest.kt @@ -86,9 +86,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -108,9 +108,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -135,9 +135,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -147,9 +147,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -157,7 +157,7 @@ internal class ErrorHandlingTest { .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -227,9 +227,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -249,9 +249,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -276,9 +276,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -288,9 +288,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -298,7 +298,7 @@ internal class ErrorHandlingTest { .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -368,9 +368,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -390,9 +390,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -417,9 +417,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -429,9 +429,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -439,7 +439,7 @@ internal class ErrorHandlingTest { .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -509,9 +509,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -531,9 +531,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -558,9 +558,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -570,9 +570,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -580,7 +580,7 @@ internal class ErrorHandlingTest { .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -650,9 +650,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -672,9 +672,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -699,9 +699,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -711,9 +711,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -721,7 +721,7 @@ internal class ErrorHandlingTest { .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -791,9 +791,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -813,9 +813,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -840,9 +840,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -852,9 +852,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -862,7 +862,7 @@ internal class ErrorHandlingTest { .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -932,9 +932,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -954,9 +954,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -981,9 +981,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -993,9 +993,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -1003,7 +1003,7 @@ internal class ErrorHandlingTest { .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -1073,9 +1073,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -1095,9 +1095,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -1122,9 +1122,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -1134,9 +1134,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -1144,7 +1144,7 @@ internal class ErrorHandlingTest { .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -1214,9 +1214,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -1236,9 +1236,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -1263,9 +1263,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -1275,9 +1275,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -1285,7 +1285,7 @@ internal class ErrorHandlingTest { .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -1355,9 +1355,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -1377,9 +1377,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -1404,9 +1404,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -1416,9 +1416,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -1426,7 +1426,7 @@ internal class ErrorHandlingTest { .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -1496,9 +1496,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -1518,9 +1518,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -1545,9 +1545,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -1557,9 +1557,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -1567,7 +1567,7 @@ internal class ErrorHandlingTest { .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -1637,9 +1637,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -1659,9 +1659,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -1686,9 +1686,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -1698,9 +1698,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -1708,7 +1708,7 @@ internal class ErrorHandlingTest { .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -1778,9 +1778,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -1800,9 +1800,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -1827,9 +1827,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -1839,9 +1839,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -1849,7 +1849,7 @@ internal class ErrorHandlingTest { .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -1919,9 +1919,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -1941,9 +1941,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -1968,9 +1968,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -1980,9 +1980,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -1990,7 +1990,7 @@ internal class ErrorHandlingTest { .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -2060,9 +2060,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -2082,9 +2082,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -2109,9 +2109,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -2121,9 +2121,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -2131,7 +2131,7 @@ internal class ErrorHandlingTest { .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -2201,9 +2201,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -2223,9 +2223,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -2250,9 +2250,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -2262,9 +2262,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -2272,7 +2272,7 @@ internal class ErrorHandlingTest { .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() @@ -2340,9 +2340,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -2362,9 +2362,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -2389,9 +2389,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -2401,9 +2401,9 @@ internal class ErrorHandlingTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -2411,7 +2411,7 @@ internal class ErrorHandlingTest { .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ServiceParamsTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ServiceParamsTest.kt index 44e13bd..90cf21d 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ServiceParamsTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ServiceParamsTest.kt @@ -56,9 +56,9 @@ internal class ServiceParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -78,9 +78,9 @@ internal class ServiceParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -105,9 +105,9 @@ internal class ServiceParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -117,9 +117,9 @@ internal class ServiceParamsTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -127,7 +127,7 @@ internal class ServiceParamsTest { .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncTest.kt index c75bf1d..1186a27 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncTest.kt @@ -41,9 +41,9 @@ internal class DocumentServiceAsyncTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -63,9 +63,9 @@ internal class DocumentServiceAsyncTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -90,9 +90,9 @@ internal class DocumentServiceAsyncTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -102,9 +102,9 @@ internal class DocumentServiceAsyncTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -112,7 +112,7 @@ internal class DocumentServiceAsyncTest { .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/ValidateServiceAsyncTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/ValidateServiceAsyncTest.kt index 827c4e0..cf0d0f2 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/ValidateServiceAsyncTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/ValidateServiceAsyncTest.kt @@ -41,9 +41,9 @@ internal class ValidateServiceAsyncTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -63,9 +63,9 @@ internal class ValidateServiceAsyncTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -90,9 +90,9 @@ internal class ValidateServiceAsyncTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -102,9 +102,9 @@ internal class ValidateServiceAsyncTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -112,7 +112,7 @@ internal class ValidateServiceAsyncTest { .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/DocumentServiceTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/DocumentServiceTest.kt index c34988c..0c1d2fd 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/DocumentServiceTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/DocumentServiceTest.kt @@ -41,9 +41,9 @@ internal class DocumentServiceTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -63,9 +63,9 @@ internal class DocumentServiceTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -90,9 +90,9 @@ internal class DocumentServiceTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -102,9 +102,9 @@ internal class DocumentServiceTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -112,7 +112,7 @@ internal class DocumentServiceTest { .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/ValidateServiceTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/ValidateServiceTest.kt index 936c28c..e53bd7e 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/ValidateServiceTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/ValidateServiceTest.kt @@ -41,9 +41,9 @@ internal class ValidateServiceTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amountDue(0.0) @@ -63,9 +63,9 @@ internal class ValidateServiceTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .currency(CurrencyCode.EUR) @@ -90,9 +90,9 @@ internal class ValidateServiceTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) - .taxRate("tax_rate") + .taxRate(0.0) .build() ) .amount(0.0) @@ -102,9 +102,9 @@ internal class ValidateServiceTest { .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode("reason_code") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) - .taxRate("tax_rate") + .taxRate("21.00") .build() ) .date(null) @@ -112,7 +112,7 @@ internal class ValidateServiceTest { .productCode("product_code") .quantity(0.0) .tax(0.0) - .taxRate("tax_rate") + .taxRate("21.00") .unit(UnitOfMeasureCode._10) .unitPrice(0.0) .build() diff --git a/e-invoice-java-proguard-test/src/test/kotlin/com/e_invoice/api/proguard/ProGuardCompatibilityTest.kt b/e-invoice-java-proguard-test/src/test/kotlin/com/e_invoice/api/proguard/ProGuardCompatibilityTest.kt index e6113ec..301a053 100644 --- a/e-invoice-java-proguard-test/src/test/kotlin/com/e_invoice/api/proguard/ProGuardCompatibilityTest.kt +++ b/e-invoice-java-proguard-test/src/test/kotlin/com/e_invoice/api/proguard/ProGuardCompatibilityTest.kt @@ -66,7 +66,7 @@ internal class ProGuardCompatibilityTest { .baseAmount("base_amount") .multiplierFactor("multiplier_factor") .reason("reason") - .reasonCode("reason_code") + .reasonCode(Allowance.ReasonCode._41) .taxCode(Allowance.TaxCode.AE) .taxRate("tax_rate") .build() From d42fb14927fcae080a39896743dade19a3f23c81 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 18 Nov 2025 16:13:53 +0000 Subject: [PATCH 12/43] feat(api): api update --- .stats.yml | 4 ++-- .../com/e_invoice/api/models/documents/UnitOfMeasureCode.kt | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/.stats.yml b/.stats.yml index 815fcb2..00fabc6 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-02fc6edfd7a172a933949a07f213b54f85b0cfe6859e4ae38f928f74b162341b.yml -openapi_spec_hash: 7d6d996d1a3ffe372b6e263033050aec +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-182387bf8051a1abc636ec4bf40836eef295840607dee4a7e4b95237fb4fe8db.yml +openapi_spec_hash: ccbf2ae9168607211f6d3fbf07c8358f config_hash: 852a0117abb3db077933876ad1185f41 diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/UnitOfMeasureCode.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/UnitOfMeasureCode.kt index c28df16..362bb6a 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/UnitOfMeasureCode.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/UnitOfMeasureCode.kt @@ -958,8 +958,6 @@ class UnitOfMeasureCode @JsonCreator private constructor(private val value: Json @JvmField val ONZ = of("ONZ") - @JvmField val PCE = of("PCE") - @JvmField val LBR = of("LBR") @JvmField val QT = of("QT") @@ -2559,7 +2557,6 @@ class UnitOfMeasureCode @JsonCreator private constructor(private val value: Json MIN, MON, ONZ, - PCE, LBR, QT, SEC, @@ -3603,7 +3600,6 @@ class UnitOfMeasureCode @JsonCreator private constructor(private val value: Json MIN, MON, ONZ, - PCE, LBR, QT, SEC, @@ -4651,7 +4647,6 @@ class UnitOfMeasureCode @JsonCreator private constructor(private val value: Json MIN -> Value.MIN MON -> Value.MON ONZ -> Value.ONZ - PCE -> Value.PCE LBR -> Value.LBR QT -> Value.QT SEC -> Value.SEC @@ -5696,7 +5691,6 @@ class UnitOfMeasureCode @JsonCreator private constructor(private val value: Json MIN -> Known.MIN MON -> Known.MON ONZ -> Known.ONZ - PCE -> Known.PCE LBR -> Known.LBR QT -> Known.QT SEC -> Known.SEC From 294d175693d4002378462c1c09afcd99bff91362 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 19 Nov 2025 16:14:09 +0000 Subject: [PATCH 13/43] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 00fabc6..fa11d94 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-182387bf8051a1abc636ec4bf40836eef295840607dee4a7e4b95237fb4fe8db.yml -openapi_spec_hash: ccbf2ae9168607211f6d3fbf07c8358f +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-ca22461602de3efa8a6d3613bf3acc73eca2c9c9896726e3f3b0e2482d33de8d.yml +openapi_spec_hash: facbfc4f7425e40ae1191b7bacbb73b8 config_hash: 852a0117abb3db077933876ad1185f41 From f34d373cab9477deb15c0c5670166984fe83c850 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 27 Nov 2025 03:16:07 +0000 Subject: [PATCH 14/43] fix(client): cancel okhttp call when future cancelled --- e-invoice-java-client-okhttp/build.gradle.kts | 1 + .../api/client/okhttp/OkHttpClient.kt | 34 ++++++++------ .../api/client/okhttp/OkHttpClientTest.kt | 44 +++++++++++++++++++ 3 files changed, 65 insertions(+), 14 deletions(-) create mode 100644 e-invoice-java-client-okhttp/src/test/kotlin/com/e_invoice/api/client/okhttp/OkHttpClientTest.kt diff --git a/e-invoice-java-client-okhttp/build.gradle.kts b/e-invoice-java-client-okhttp/build.gradle.kts index 83540c1..218298a 100644 --- a/e-invoice-java-client-okhttp/build.gradle.kts +++ b/e-invoice-java-client-okhttp/build.gradle.kts @@ -11,4 +11,5 @@ dependencies { testImplementation(kotlin("test")) testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("com.github.tomakehurst:wiremock-jre8:2.35.2") } diff --git a/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/OkHttpClient.kt b/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/OkHttpClient.kt index 6836d72..aded9cc 100644 --- a/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/OkHttpClient.kt +++ b/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/OkHttpClient.kt @@ -13,6 +13,7 @@ import java.io.IOException import java.io.InputStream import java.net.Proxy import java.time.Duration +import java.util.concurrent.CancellationException import java.util.concurrent.CompletableFuture import javax.net.ssl.HostnameVerifier import javax.net.ssl.SSLSocketFactory @@ -29,8 +30,8 @@ import okhttp3.Response import okhttp3.logging.HttpLoggingInterceptor import okio.BufferedSink -class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpClient) : - HttpClient { +class OkHttpClient +private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClient) : HttpClient { override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { val call = newCall(request, requestOptions) @@ -50,20 +51,25 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpC ): CompletableFuture { val future = CompletableFuture() - request.body?.run { future.whenComplete { _, _ -> close() } } - - newCall(request, requestOptions) - .enqueue( - object : Callback { - override fun onResponse(call: Call, response: Response) { - future.complete(response.toResponse()) - } + val call = newCall(request, requestOptions) + call.enqueue( + object : Callback { + override fun onResponse(call: Call, response: Response) { + future.complete(response.toResponse()) + } - override fun onFailure(call: Call, e: IOException) { - future.completeExceptionally(EInvoiceIoException("Request failed", e)) - } + override fun onFailure(call: Call, e: IOException) { + future.completeExceptionally(EInvoiceIoException("Request failed", e)) } - ) + } + ) + + future.whenComplete { _, e -> + if (e is CancellationException) { + call.cancel() + } + request.body?.close() + } return future } diff --git a/e-invoice-java-client-okhttp/src/test/kotlin/com/e_invoice/api/client/okhttp/OkHttpClientTest.kt b/e-invoice-java-client-okhttp/src/test/kotlin/com/e_invoice/api/client/okhttp/OkHttpClientTest.kt new file mode 100644 index 0000000..faec5b4 --- /dev/null +++ b/e-invoice-java-client-okhttp/src/test/kotlin/com/e_invoice/api/client/okhttp/OkHttpClientTest.kt @@ -0,0 +1,44 @@ +package com.e_invoice.api.client.okhttp + +import com.e_invoice.api.core.http.HttpMethod +import com.e_invoice.api.core.http.HttpRequest +import com.github.tomakehurst.wiremock.client.WireMock.* +import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo +import com.github.tomakehurst.wiremock.junit5.WireMockTest +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.BeforeEach +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.parallel.ResourceLock + +@WireMockTest +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") +internal class OkHttpClientTest { + + private lateinit var baseUrl: String + private lateinit var httpClient: OkHttpClient + + @BeforeEach + fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { + baseUrl = wmRuntimeInfo.httpBaseUrl + httpClient = OkHttpClient.builder().build() + } + + @Test + fun executeAsync_whenFutureCancelled_cancelsUnderlyingCall() { + stubFor(post(urlPathEqualTo("/something")).willReturn(ok())) + val responseFuture = + httpClient.executeAsync( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build() + ) + val call = httpClient.okHttpClient.dispatcher.runningCalls().single() + + responseFuture.cancel(false) + + // Should have cancelled the underlying call + assertThat(call.isCanceled()).isTrue() + } +} From 4b1c946cf5e6403194165bf0c92f5160a5e95e32 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 3 Dec 2025 03:20:46 +0000 Subject: [PATCH 15/43] docs: remove `$` for better copy-pasteabality --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e974c26..53a454d 100644 --- a/README.md +++ b/README.md @@ -398,13 +398,13 @@ The SDK uses the standard [OkHttp logging interceptor](https://github.com/square Enable logging by setting the `E_INVOICE_LOG` environment variable to `info`: ```sh -$ export E_INVOICE_LOG=info +export E_INVOICE_LOG=info ``` Or to `debug` for more verbose logging: ```sh -$ export E_INVOICE_LOG=debug +export E_INVOICE_LOG=debug ``` ## ProGuard and R8 From 4a468b27a6b2a2c8e748131b3d4f35176a4e3d98 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 11 Dec 2025 14:13:46 +0000 Subject: [PATCH 16/43] feat(api): api update --- .stats.yml | 4 ++-- .../documents/attachments/AttachmentAddParams.kt | 5 ++++- .../async/documents/AttachmentServiceAsync.kt | 13 ++++++++++++- .../async/documents/AttachmentServiceAsyncImpl.kt | 2 ++ .../blocking/documents/AttachmentService.kt | 13 ++++++++++++- .../blocking/documents/AttachmentServiceImpl.kt | 2 ++ 6 files changed, 34 insertions(+), 5 deletions(-) diff --git a/.stats.yml b/.stats.yml index fa11d94..d07cdc0 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-ca22461602de3efa8a6d3613bf3acc73eca2c9c9896726e3f3b0e2482d33de8d.yml -openapi_spec_hash: facbfc4f7425e40ae1191b7bacbb73b8 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-a5b8396effe8b5c5db6514a0761a56fafd9c28fdfb704582a8f7023c019ee75e.yml +openapi_spec_hash: 9cff5c5919d2b5aa9304124d9f14cbf7 config_hash: 852a0117abb3db077933876ad1185f41 diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/attachments/AttachmentAddParams.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/attachments/AttachmentAddParams.kt index 9dc465e..5ab2774 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/attachments/AttachmentAddParams.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/attachments/AttachmentAddParams.kt @@ -23,7 +23,10 @@ import kotlin.io.path.inputStream import kotlin.io.path.name import kotlin.jvm.optionals.getOrNull -/** Add a new attachment to an invoice or credit note */ +/** + * Add one or more attachments when creating a new invoice or credit note via POST /api/documents/ + */ +@Deprecated("deprecated") class AttachmentAddParams private constructor( private val documentId: String?, diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/documents/AttachmentServiceAsync.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/documents/AttachmentServiceAsync.kt index 78bd70e..32a8561 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/documents/AttachmentServiceAsync.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/documents/AttachmentServiceAsync.kt @@ -115,13 +115,18 @@ interface AttachmentServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** Add a new attachment to an invoice or credit note */ + /** + * Add one or more attachments when creating a new invoice or credit note via POST + * /api/documents/ + */ + @Deprecated("deprecated") fun add( documentId: String, params: AttachmentAddParams, ): CompletableFuture = add(documentId, params, RequestOptions.none()) /** @see add */ + @Deprecated("deprecated") fun add( documentId: String, params: AttachmentAddParams, @@ -130,10 +135,12 @@ interface AttachmentServiceAsync { add(params.toBuilder().documentId(documentId).build(), requestOptions) /** @see add */ + @Deprecated("deprecated") fun add(params: AttachmentAddParams): CompletableFuture = add(params, RequestOptions.none()) /** @see add */ + @Deprecated("deprecated") fun add( params: AttachmentAddParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -261,6 +268,7 @@ interface AttachmentServiceAsync { * Returns a raw HTTP response for `post /api/documents/{document_id}/attachments`, but is * otherwise the same as [AttachmentServiceAsync.add]. */ + @Deprecated("deprecated") fun add( documentId: String, params: AttachmentAddParams, @@ -268,6 +276,7 @@ interface AttachmentServiceAsync { add(documentId, params, RequestOptions.none()) /** @see add */ + @Deprecated("deprecated") fun add( documentId: String, params: AttachmentAddParams, @@ -276,12 +285,14 @@ interface AttachmentServiceAsync { add(params.toBuilder().documentId(documentId).build(), requestOptions) /** @see add */ + @Deprecated("deprecated") fun add( params: AttachmentAddParams ): CompletableFuture> = add(params, RequestOptions.none()) /** @see add */ + @Deprecated("deprecated") fun add( params: AttachmentAddParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/documents/AttachmentServiceAsyncImpl.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/documents/AttachmentServiceAsyncImpl.kt index 162a1da..507877f 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/documents/AttachmentServiceAsyncImpl.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/documents/AttachmentServiceAsyncImpl.kt @@ -60,6 +60,7 @@ class AttachmentServiceAsyncImpl internal constructor(private val clientOptions: // delete /api/documents/{document_id}/attachments/{attachment_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + @Deprecated("deprecated") override fun add( params: AttachmentAddParams, requestOptions: RequestOptions, @@ -195,6 +196,7 @@ class AttachmentServiceAsyncImpl internal constructor(private val clientOptions: private val addHandler: Handler = jsonHandler(clientOptions.jsonMapper) + @Deprecated("deprecated") override fun add( params: AttachmentAddParams, requestOptions: RequestOptions, diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/documents/AttachmentService.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/documents/AttachmentService.kt index bb9d834..1152751 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/documents/AttachmentService.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/documents/AttachmentService.kt @@ -107,11 +107,16 @@ interface AttachmentService { requestOptions: RequestOptions = RequestOptions.none(), ): AttachmentDeleteResponse - /** Add a new attachment to an invoice or credit note */ + /** + * Add one or more attachments when creating a new invoice or credit note via POST + * /api/documents/ + */ + @Deprecated("deprecated") fun add(documentId: String, params: AttachmentAddParams): DocumentAttachment = add(documentId, params, RequestOptions.none()) /** @see add */ + @Deprecated("deprecated") fun add( documentId: String, params: AttachmentAddParams, @@ -119,9 +124,11 @@ interface AttachmentService { ): DocumentAttachment = add(params.toBuilder().documentId(documentId).build(), requestOptions) /** @see add */ + @Deprecated("deprecated") fun add(params: AttachmentAddParams): DocumentAttachment = add(params, RequestOptions.none()) /** @see add */ + @Deprecated("deprecated") fun add( params: AttachmentAddParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -254,6 +261,7 @@ interface AttachmentService { * Returns a raw HTTP response for `post /api/documents/{document_id}/attachments`, but is * otherwise the same as [AttachmentService.add]. */ + @Deprecated("deprecated") @MustBeClosed fun add( documentId: String, @@ -261,6 +269,7 @@ interface AttachmentService { ): HttpResponseFor = add(documentId, params, RequestOptions.none()) /** @see add */ + @Deprecated("deprecated") @MustBeClosed fun add( documentId: String, @@ -270,11 +279,13 @@ interface AttachmentService { add(params.toBuilder().documentId(documentId).build(), requestOptions) /** @see add */ + @Deprecated("deprecated") @MustBeClosed fun add(params: AttachmentAddParams): HttpResponseFor = add(params, RequestOptions.none()) /** @see add */ + @Deprecated("deprecated") @MustBeClosed fun add( params: AttachmentAddParams, diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/documents/AttachmentServiceImpl.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/documents/AttachmentServiceImpl.kt index 3aa1f15..a75ae6c 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/documents/AttachmentServiceImpl.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/documents/AttachmentServiceImpl.kt @@ -59,6 +59,7 @@ class AttachmentServiceImpl internal constructor(private val clientOptions: Clie // delete /api/documents/{document_id}/attachments/{attachment_id} withRawResponse().delete(params, requestOptions).parse() + @Deprecated("deprecated") override fun add( params: AttachmentAddParams, requestOptions: RequestOptions, @@ -185,6 +186,7 @@ class AttachmentServiceImpl internal constructor(private val clientOptions: Clie private val addHandler: Handler = jsonHandler(clientOptions.jsonMapper) + @Deprecated("deprecated") override fun add( params: AttachmentAddParams, requestOptions: RequestOptions, From fcaf0b4d28f4037247d3be0a444bec5914454af8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 18 Dec 2025 08:13:51 +0000 Subject: [PATCH 17/43] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index d07cdc0..8c4a55c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-a5b8396effe8b5c5db6514a0761a56fafd9c28fdfb704582a8f7023c019ee75e.yml -openapi_spec_hash: 9cff5c5919d2b5aa9304124d9f14cbf7 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-a110eeaf4b6b3ece41e2f41191c9b52424ebd53be9d8104832a2fd93d40f06fb.yml +openapi_spec_hash: 07e58094375dd15a98ca53d1bfbcdcf5 config_hash: 852a0117abb3db077933876ad1185f41 From c376703c4f7c9478e73fa106c540a6346c6aefed Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 19 Dec 2025 16:13:44 +0000 Subject: [PATCH 18/43] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 8c4a55c..8faad04 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-a110eeaf4b6b3ece41e2f41191c9b52424ebd53be9d8104832a2fd93d40f06fb.yml -openapi_spec_hash: 07e58094375dd15a98ca53d1bfbcdcf5 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-2512d9c2253d07736ac24f92b7fdb5b91673ba88bfbca6e9f1543e1d0d887671.yml +openapi_spec_hash: ac9e1d21f62b0dfed53079ce6bb25ce2 config_hash: 852a0117abb3db077933876ad1185f41 From b5a6a0f7aa5ed8d9a44f27f818da15da3ff30d3f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 1 Jan 2026 03:00:19 +0000 Subject: [PATCH 19/43] chore(internal): codegen related update --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 735c9bb..05f8e0b 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2025 E Invoice + Copyright 2026 E Invoice Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From b3aad10fd43571a39c18361ddf3597d68a643531 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 6 Jan 2026 03:17:16 +0000 Subject: [PATCH 20/43] chore(internal): codegen related update --- README.md | 9 ++ .../e_invoice/api/core/http/HttpRequest.kt | 30 +++++ .../api/core/http/HttpRequestTest.kt | 110 ++++++++++++++++++ 3 files changed, 149 insertions(+) create mode 100644 e-invoice-java-core/src/test/kotlin/com/e_invoice/api/core/http/HttpRequestTest.kt diff --git a/README.md b/README.md index 53a454d..874b5c1 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,15 @@ The e-invoice.be Peppol SDK provides convenient access to the [e-invoice.be REST API](https://api.e-invoice.be) from applications written in Java. +## MCP Server + +Use the E Invoice MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application. + +[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=e-invoice-api-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsImUtaW52b2ljZS1hcGktbWNwIl19) +[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22e-invoice-api-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22e-invoice-api-mcp%22%5D%7D) + +> Note: You may need to set environment variables in your MCP client. + The REST API documentation can be found on [api.e-invoice.be](https://api.e-invoice.be). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.e_invoice.api/e-invoice-java/0.1.0-alpha.12). diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/http/HttpRequest.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/http/HttpRequest.kt index 9a52e88..9a0db4d 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/http/HttpRequest.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/http/HttpRequest.kt @@ -2,6 +2,7 @@ package com.e_invoice.api.core.http import com.e_invoice.api.core.checkRequired import com.e_invoice.api.core.toImmutable +import java.net.URLEncoder class HttpRequest private constructor( @@ -13,6 +14,35 @@ private constructor( @get:JvmName("body") val body: HttpRequestBody?, ) { + fun url(): String = buildString { + append(baseUrl) + + pathSegments.forEach { segment -> + if (!endsWith("/")) { + append("/") + } + append(URLEncoder.encode(segment, "UTF-8")) + } + + if (queryParams.isEmpty()) { + return@buildString + } + + append("?") + var isFirst = true + queryParams.keys().forEach { key -> + queryParams.values(key).forEach { value -> + if (!isFirst) { + append("&") + } + append(URLEncoder.encode(key, "UTF-8")) + append("=") + append(URLEncoder.encode(value, "UTF-8")) + isFirst = false + } + } + } + fun toBuilder(): Builder = Builder().from(this) override fun toString(): String = diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/core/http/HttpRequestTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/core/http/HttpRequestTest.kt new file mode 100644 index 0000000..c85ec05 --- /dev/null +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/core/http/HttpRequestTest.kt @@ -0,0 +1,110 @@ +package com.e_invoice.api.core.http + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class HttpRequestTest { + + enum class UrlTestCase(val request: HttpRequest, val expectedUrl: String) { + BASE_URL_ONLY( + HttpRequest.builder().method(HttpMethod.GET).baseUrl("https://api.example.com").build(), + expectedUrl = "https://api.example.com", + ), + BASE_URL_WITH_TRAILING_SLASH( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com/") + .build(), + expectedUrl = "https://api.example.com/", + ), + SINGLE_PATH_SEGMENT( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegment("users") + .build(), + expectedUrl = "https://api.example.com/users", + ), + MULTIPLE_PATH_SEGMENTS( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegments("users", "123", "profile") + .build(), + expectedUrl = "https://api.example.com/users/123/profile", + ), + PATH_SEGMENT_WITH_SPECIAL_CHARS( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegment("user name") + .build(), + expectedUrl = "https://api.example.com/user+name", + ), + SINGLE_QUERY_PARAM( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegment("users") + .putQueryParam("limit", "10") + .build(), + expectedUrl = "https://api.example.com/users?limit=10", + ), + MULTIPLE_QUERY_PARAMS( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegment("users") + .putQueryParam("limit", "10") + .putQueryParam("offset", "20") + .build(), + expectedUrl = "https://api.example.com/users?limit=10&offset=20", + ), + QUERY_PARAM_WITH_SPECIAL_CHARS( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegment("search") + .putQueryParam("q", "hello world") + .build(), + expectedUrl = "https://api.example.com/search?q=hello+world", + ), + MULTIPLE_VALUES_SAME_PARAM( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com") + .addPathSegment("users") + .putQueryParams("tags", listOf("admin", "user")) + .build(), + expectedUrl = "https://api.example.com/users?tags=admin&tags=user", + ), + BASE_URL_WITH_TRAILING_SLASH_AND_PATH( + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl("https://api.example.com/") + .addPathSegment("users") + .build(), + expectedUrl = "https://api.example.com/users", + ), + COMPLEX_URL( + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl("https://api.example.com") + .addPathSegments("v1", "users", "123") + .putQueryParams("include", listOf("profile", "settings")) + .putQueryParam("format", "json") + .build(), + expectedUrl = + "https://api.example.com/v1/users/123?include=profile&include=settings&format=json", + ), + } + + @ParameterizedTest + @EnumSource + fun url(testCase: UrlTestCase) { + val actualUrl = testCase.request.url() + + assertThat(actualUrl).isEqualTo(testCase.expectedUrl) + } +} From 52e1ebbb83280db67feb3581a08d3f7241a500f0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 9 Jan 2026 03:25:12 +0000 Subject: [PATCH 21/43] chore(internal): codegen related update --- .../api/client/okhttp/EInvoiceOkHttpClient.kt | 22 +++++++++++++++++++ .../okhttp/EInvoiceOkHttpClientAsync.kt | 22 +++++++++++++++++++ .../api/client/okhttp/OkHttpClient.kt | 9 ++++++++ 3 files changed, 53 insertions(+) diff --git a/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/EInvoiceOkHttpClient.kt b/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/EInvoiceOkHttpClient.kt index f723839..4dbfcfc 100644 --- a/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/EInvoiceOkHttpClient.kt +++ b/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/EInvoiceOkHttpClient.kt @@ -18,6 +18,7 @@ import java.time.Clock import java.time.Duration import java.util.Optional import java.util.concurrent.Executor +import java.util.concurrent.ExecutorService import javax.net.ssl.HostnameVerifier import javax.net.ssl.SSLSocketFactory import javax.net.ssl.X509TrustManager @@ -46,11 +47,31 @@ class EInvoiceOkHttpClient private constructor() { class Builder internal constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() + private var dispatcherExecutorService: ExecutorService? = null private var proxy: Proxy? = null private var sslSocketFactory: SSLSocketFactory? = null private var trustManager: X509TrustManager? = null private var hostnameVerifier: HostnameVerifier? = null + /** + * The executor service to use for running HTTP requests. + * + * Defaults to OkHttp's + * [default executor service](https://github.com/square/okhttp/blob/ace792f443b2ffb17974f5c0d1cecdf589309f26/okhttp/src/commonJvmAndroid/kotlin/okhttp3/Dispatcher.kt#L98-L104). + * + * This class takes ownership of the executor service and shuts it down when closed. + */ + fun dispatcherExecutorService(dispatcherExecutorService: ExecutorService?) = apply { + this.dispatcherExecutorService = dispatcherExecutorService + } + + /** + * Alias for calling [Builder.dispatcherExecutorService] with + * `dispatcherExecutorService.orElse(null)`. + */ + fun dispatcherExecutorService(dispatcherExecutorService: Optional) = + dispatcherExecutorService(dispatcherExecutorService.getOrNull()) + fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ @@ -309,6 +330,7 @@ class EInvoiceOkHttpClient private constructor() { OkHttpClient.builder() .timeout(clientOptions.timeout()) .proxy(proxy) + .dispatcherExecutorService(dispatcherExecutorService) .sslSocketFactory(sslSocketFactory) .trustManager(trustManager) .hostnameVerifier(hostnameVerifier) diff --git a/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/EInvoiceOkHttpClientAsync.kt b/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/EInvoiceOkHttpClientAsync.kt index 225db7f..2f4d1e2 100644 --- a/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/EInvoiceOkHttpClientAsync.kt +++ b/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/EInvoiceOkHttpClientAsync.kt @@ -18,6 +18,7 @@ import java.time.Clock import java.time.Duration import java.util.Optional import java.util.concurrent.Executor +import java.util.concurrent.ExecutorService import javax.net.ssl.HostnameVerifier import javax.net.ssl.SSLSocketFactory import javax.net.ssl.X509TrustManager @@ -46,11 +47,31 @@ class EInvoiceOkHttpClientAsync private constructor() { class Builder internal constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() + private var dispatcherExecutorService: ExecutorService? = null private var proxy: Proxy? = null private var sslSocketFactory: SSLSocketFactory? = null private var trustManager: X509TrustManager? = null private var hostnameVerifier: HostnameVerifier? = null + /** + * The executor service to use for running HTTP requests. + * + * Defaults to OkHttp's + * [default executor service](https://github.com/square/okhttp/blob/ace792f443b2ffb17974f5c0d1cecdf589309f26/okhttp/src/commonJvmAndroid/kotlin/okhttp3/Dispatcher.kt#L98-L104). + * + * This class takes ownership of the executor service and shuts it down when closed. + */ + fun dispatcherExecutorService(dispatcherExecutorService: ExecutorService?) = apply { + this.dispatcherExecutorService = dispatcherExecutorService + } + + /** + * Alias for calling [Builder.dispatcherExecutorService] with + * `dispatcherExecutorService.orElse(null)`. + */ + fun dispatcherExecutorService(dispatcherExecutorService: Optional) = + dispatcherExecutorService(dispatcherExecutorService.getOrNull()) + fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } /** Alias for calling [Builder.proxy] with `proxy.orElse(null)`. */ @@ -309,6 +330,7 @@ class EInvoiceOkHttpClientAsync private constructor() { OkHttpClient.builder() .timeout(clientOptions.timeout()) .proxy(proxy) + .dispatcherExecutorService(dispatcherExecutorService) .sslSocketFactory(sslSocketFactory) .trustManager(trustManager) .hostnameVerifier(hostnameVerifier) diff --git a/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/OkHttpClient.kt b/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/OkHttpClient.kt index aded9cc..35098a6 100644 --- a/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/OkHttpClient.kt +++ b/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/OkHttpClient.kt @@ -15,11 +15,13 @@ import java.net.Proxy import java.time.Duration import java.util.concurrent.CancellationException import java.util.concurrent.CompletableFuture +import java.util.concurrent.ExecutorService import javax.net.ssl.HostnameVerifier import javax.net.ssl.SSLSocketFactory import javax.net.ssl.X509TrustManager import okhttp3.Call import okhttp3.Callback +import okhttp3.Dispatcher import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.MediaType import okhttp3.MediaType.Companion.toMediaType @@ -198,6 +200,7 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null + private var dispatcherExecutorService: ExecutorService? = null private var sslSocketFactory: SSLSocketFactory? = null private var trustManager: X509TrustManager? = null private var hostnameVerifier: HostnameVerifier? = null @@ -208,6 +211,10 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien fun proxy(proxy: Proxy?) = apply { this.proxy = proxy } + fun dispatcherExecutorService(dispatcherExecutorService: ExecutorService?) = apply { + this.dispatcherExecutorService = dispatcherExecutorService + } + fun sslSocketFactory(sslSocketFactory: SSLSocketFactory?) = apply { this.sslSocketFactory = sslSocketFactory } @@ -229,6 +236,8 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien .callTimeout(timeout.request()) .proxy(proxy) .apply { + dispatcherExecutorService?.let { dispatcher(Dispatcher(it)) } + val sslSocketFactory = sslSocketFactory val trustManager = trustManager if (sslSocketFactory != null && trustManager != null) { From ee9459ac80af991d3a9d719f46d28bee16ac1d49 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 13 Jan 2026 04:32:08 +0000 Subject: [PATCH 22/43] chore(internal): codegen related update --- .github/workflows/ci.yml | 18 ++++ .../main/kotlin/e-invoice.publish.gradle.kts | 8 ++ scripts/upload-artifacts | 96 +++++++++++++++++++ 3 files changed, 122 insertions(+) create mode 100755 scripts/upload-artifacts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b2cacc9..e832cac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,6 +40,9 @@ jobs: build: timeout-minutes: 15 name: build + permissions: + contents: read + id-token: write runs-on: ${{ github.repository == 'stainless-sdks/e-invoice-api-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} if: github.event_name == 'push' || github.event.pull_request.head.repo.fork @@ -61,6 +64,21 @@ jobs: - name: Build SDK run: ./scripts/build + - name: Get GitHub OIDC Token + if: github.repository == 'stainless-sdks/e-invoice-api-java' + id: github-oidc + uses: actions/github-script@v6 + with: + script: core.setOutput('github_token', await core.getIDToken()); + + - name: Build and upload Maven artifacts + if: github.repository == 'stainless-sdks/e-invoice-api-java' + env: + URL: https://pkg.stainless.com/s + AUTH: ${{ steps.github-oidc.outputs.github_token }} + SHA: ${{ github.sha }} + PROJECT: e-invoice-api-java + run: ./scripts/upload-artifacts test: timeout-minutes: 15 name: test diff --git a/buildSrc/src/main/kotlin/e-invoice.publish.gradle.kts b/buildSrc/src/main/kotlin/e-invoice.publish.gradle.kts index dc41057..078189f 100644 --- a/buildSrc/src/main/kotlin/e-invoice.publish.gradle.kts +++ b/buildSrc/src/main/kotlin/e-invoice.publish.gradle.kts @@ -40,6 +40,14 @@ configure { } } } + repositories { + if (project.hasProperty("publishLocal")) { + maven { + name = "LocalFileSystem" + url = uri("${rootProject.layout.buildDirectory.get()}/local-maven-repo") + } + } + } } signing { diff --git a/scripts/upload-artifacts b/scripts/upload-artifacts new file mode 100755 index 0000000..729e6f2 --- /dev/null +++ b/scripts/upload-artifacts @@ -0,0 +1,96 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# ANSI Color Codes +GREEN='\033[32m' +RED='\033[31m' +NC='\033[0m' # No Color + +log_error() { + local msg="$1" + local headers="$2" + local body="$3" + echo -e "${RED}${msg}${NC}" + [[ -f "$headers" ]] && echo -e "${RED}Headers:$(cat "$headers")${NC}" + echo -e "${RED}Body: ${body}${NC}" + exit 1 +} + +upload_file() { + local file_name="$1" + local tmp_headers + tmp_headers=$(mktemp) + + if [ -f "$file_name" ]; then + echo -e "${GREEN}Processing file: $file_name${NC}" + pkg_file_name="mvn${file_name#./build/local-maven-repo}" + + # Get signed URL for uploading artifact file + signed_url_response=$(curl -X POST -G "$URL" \ + -sS --retry 5 \ + -D "$tmp_headers" \ + --data-urlencode "filename=$pkg_file_name" \ + -H "Authorization: Bearer $AUTH" \ + -H "Content-Type: application/json") + + # Validate JSON and extract URL + if ! signed_url=$(echo "$signed_url_response" | jq -e -r '.url' 2>/dev/null) || [[ "$signed_url" == "null" ]]; then + log_error "Failed to get valid signed URL" "$tmp_headers" "$signed_url_response" + fi + + # Set content-type based on file extension + local extension="${file_name##*.}" + local content_type + case "$extension" in + jar) content_type="application/java-archive" ;; + md5|sha1|sha256|sha512) content_type="text/plain" ;; + module) content_type="application/json" ;; + pom|xml) content_type="application/xml" ;; + *) content_type="application/octet-stream" ;; + esac + + # Upload file + upload_response=$(curl -v -X PUT \ + --retry 5 \ + -D "$tmp_headers" \ + -H "Content-Type: $content_type" \ + --data-binary "@${file_name}" "$signed_url" 2>&1) + + if ! echo "$upload_response" | grep -q "HTTP/[0-9.]* 200"; then + log_error "Failed upload artifact file" "$tmp_headers" "$upload_response" + fi + + # Insert small throttle to reduce rate limiting risk + sleep 0.1 + fi +} + +walk_tree() { + local current_dir="$1" + + for entry in "$current_dir"/*; do + # Check that entry is valid + [ -e "$entry" ] || [ -h "$entry" ] || continue + + if [ -d "$entry" ]; then + walk_tree "$entry" + else + upload_file "$entry" + fi + done +} + +cd "$(dirname "$0")/.." + +echo "::group::Creating local Maven content" +./gradlew publishMavenPublicationToLocalFileSystemRepository -PpublishLocal +echo "::endgroup::" + +echo "::group::Uploading to pkg.stainless.com" +walk_tree "./build/local-maven-repo" +echo "::endgroup::" + +echo "::group::Generating instructions" +echo "Configure maven or gradle to use the repo located at 'https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn'" +echo "::endgroup::" From 0059a2f619a5e17c3bc9f17e7f684e4af983fe60 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 14 Jan 2026 04:07:25 +0000 Subject: [PATCH 23/43] chore(internal): codegen related update --- .../e_invoice/api/models/inbox/InboxListCreditNotesPage.kt | 4 ++-- .../api/models/inbox/InboxListCreditNotesPageAsync.kt | 4 ++-- .../com/e_invoice/api/models/inbox/InboxListInvoicesPage.kt | 4 ++-- .../e_invoice/api/models/inbox/InboxListInvoicesPageAsync.kt | 4 ++-- .../kotlin/com/e_invoice/api/models/inbox/InboxListPage.kt | 4 ++-- .../com/e_invoice/api/models/inbox/InboxListPageAsync.kt | 4 ++-- .../api/models/outbox/OutboxListDraftDocumentsPage.kt | 4 ++-- .../api/models/outbox/OutboxListDraftDocumentsPageAsync.kt | 4 ++-- .../api/models/outbox/OutboxListReceivedDocumentsPage.kt | 4 ++-- .../api/models/outbox/OutboxListReceivedDocumentsPageAsync.kt | 4 ++-- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListCreditNotesPage.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListCreditNotesPage.kt index be65901..b8cfb3f 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListCreditNotesPage.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListCreditNotesPage.kt @@ -55,8 +55,8 @@ private constructor( } val pageNumber = page().getOrDefault(1) - val pageCount = total().getOrDefault(Long.MAX_VALUE) - return pageNumber < pageCount + val pageCount = total().getOrNull() + return pageCount == null || pageNumber < pageCount } fun nextPageParams(): InboxListCreditNotesParams { diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListCreditNotesPageAsync.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListCreditNotesPageAsync.kt index b38b74c..193f7c5 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListCreditNotesPageAsync.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListCreditNotesPageAsync.kt @@ -58,8 +58,8 @@ private constructor( } val pageNumber = page().getOrDefault(1) - val pageCount = total().getOrDefault(Long.MAX_VALUE) - return pageNumber < pageCount + val pageCount = total().getOrNull() + return pageCount == null || pageNumber < pageCount } fun nextPageParams(): InboxListCreditNotesParams { diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListInvoicesPage.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListInvoicesPage.kt index ab7be57..4036b02 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListInvoicesPage.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListInvoicesPage.kt @@ -55,8 +55,8 @@ private constructor( } val pageNumber = page().getOrDefault(1) - val pageCount = total().getOrDefault(Long.MAX_VALUE) - return pageNumber < pageCount + val pageCount = total().getOrNull() + return pageCount == null || pageNumber < pageCount } fun nextPageParams(): InboxListInvoicesParams { diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListInvoicesPageAsync.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListInvoicesPageAsync.kt index e7e6a10..a68631d 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListInvoicesPageAsync.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListInvoicesPageAsync.kt @@ -58,8 +58,8 @@ private constructor( } val pageNumber = page().getOrDefault(1) - val pageCount = total().getOrDefault(Long.MAX_VALUE) - return pageNumber < pageCount + val pageCount = total().getOrNull() + return pageCount == null || pageNumber < pageCount } fun nextPageParams(): InboxListInvoicesParams { diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListPage.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListPage.kt index a3118c4..2117818 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListPage.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListPage.kt @@ -55,8 +55,8 @@ private constructor( } val pageNumber = page().getOrDefault(1) - val pageCount = total().getOrDefault(Long.MAX_VALUE) - return pageNumber < pageCount + val pageCount = total().getOrNull() + return pageCount == null || pageNumber < pageCount } fun nextPageParams(): InboxListParams { diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListPageAsync.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListPageAsync.kt index d83775d..4be7c5b 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListPageAsync.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListPageAsync.kt @@ -58,8 +58,8 @@ private constructor( } val pageNumber = page().getOrDefault(1) - val pageCount = total().getOrDefault(Long.MAX_VALUE) - return pageNumber < pageCount + val pageCount = total().getOrNull() + return pageCount == null || pageNumber < pageCount } fun nextPageParams(): InboxListParams { diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListDraftDocumentsPage.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListDraftDocumentsPage.kt index f99adc8..b9ddd19 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListDraftDocumentsPage.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListDraftDocumentsPage.kt @@ -56,8 +56,8 @@ private constructor( } val pageNumber = page().getOrDefault(1) - val pageCount = total().getOrDefault(Long.MAX_VALUE) - return pageNumber < pageCount + val pageCount = total().getOrNull() + return pageCount == null || pageNumber < pageCount } fun nextPageParams(): OutboxListDraftDocumentsParams { diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListDraftDocumentsPageAsync.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListDraftDocumentsPageAsync.kt index f1757aa..0c394b1 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListDraftDocumentsPageAsync.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListDraftDocumentsPageAsync.kt @@ -59,8 +59,8 @@ private constructor( } val pageNumber = page().getOrDefault(1) - val pageCount = total().getOrDefault(Long.MAX_VALUE) - return pageNumber < pageCount + val pageCount = total().getOrNull() + return pageCount == null || pageNumber < pageCount } fun nextPageParams(): OutboxListDraftDocumentsParams { diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListReceivedDocumentsPage.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListReceivedDocumentsPage.kt index 3c05d1b..d10118e 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListReceivedDocumentsPage.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListReceivedDocumentsPage.kt @@ -56,8 +56,8 @@ private constructor( } val pageNumber = page().getOrDefault(1) - val pageCount = total().getOrDefault(Long.MAX_VALUE) - return pageNumber < pageCount + val pageCount = total().getOrNull() + return pageCount == null || pageNumber < pageCount } fun nextPageParams(): OutboxListReceivedDocumentsParams { diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListReceivedDocumentsPageAsync.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListReceivedDocumentsPageAsync.kt index 168fcdf..4517f3c 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListReceivedDocumentsPageAsync.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListReceivedDocumentsPageAsync.kt @@ -59,8 +59,8 @@ private constructor( } val pageNumber = page().getOrDefault(1) - val pageCount = total().getOrDefault(Long.MAX_VALUE) - return pageNumber < pageCount + val pageCount = total().getOrNull() + return pageCount == null || pageNumber < pageCount } fun nextPageParams(): OutboxListReceivedDocumentsParams { From 3ef5ab9f1fd50c8dc83094c6d58212e350e1000e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 15 Jan 2026 08:13:57 +0000 Subject: [PATCH 24/43] feat(api): api update --- .stats.yml | 4 +- .../api/models/documents/DocumentType.kt | 12 + .../inbox/InboxListCreditNotesParams.kt | 326 ++++++++++++++- .../models/inbox/InboxListInvoicesParams.kt | 326 ++++++++++++++- .../api/models/inbox/InboxListParams.kt | 330 ++++++++++++++- .../models/inbox/PaginatedDocumentResponse.kt | 46 ++- .../outbox/OutboxListDraftDocumentsParams.kt | 388 +++++++++++++++++- .../OutboxListReceivedDocumentsParams.kt | 358 +++++++++++++++- .../api/services/async/OutboxServiceAsync.kt | 5 +- .../api/services/blocking/OutboxService.kt | 5 +- .../inbox/InboxListCreditNotesParamsTest.kt | 24 +- .../inbox/InboxListInvoicesParamsTest.kt | 24 +- .../api/models/inbox/InboxListParamsTest.kt | 6 + .../inbox/PaginatedDocumentResponseTest.kt | 3 + .../OutboxListDraftDocumentsParamsTest.kt | 35 +- .../OutboxListReceivedDocumentsParamsTest.kt | 9 + 16 files changed, 1868 insertions(+), 33 deletions(-) diff --git a/.stats.yml b/.stats.yml index 8faad04..57cbc8b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-2512d9c2253d07736ac24f92b7fdb5b91673ba88bfbca6e9f1543e1d0d887671.yml -openapi_spec_hash: ac9e1d21f62b0dfed53079ce6bb25ce2 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-48678c6950d97996112c09651dc22fb6c1cfb2781c273c1869a3c4ac5a5982de.yml +openapi_spec_hash: d3b789cbfa46761ca437bcc7f91f6640 config_hash: 852a0117abb3db077933876ad1185f41 diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentType.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentType.kt index 4e8edd5..cb1613a 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentType.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentType.kt @@ -26,6 +26,10 @@ class DocumentType @JsonCreator private constructor(private val value: JsonField @JvmField val DEBIT_NOTE = of("DEBIT_NOTE") + @JvmField val SELFBILLING_INVOICE = of("SELFBILLING_INVOICE") + + @JvmField val SELFBILLING_CREDIT_NOTE = of("SELFBILLING_CREDIT_NOTE") + @JvmStatic fun of(value: String) = DocumentType(JsonField.of(value)) } @@ -34,6 +38,8 @@ class DocumentType @JsonCreator private constructor(private val value: JsonField INVOICE, CREDIT_NOTE, DEBIT_NOTE, + SELFBILLING_INVOICE, + SELFBILLING_CREDIT_NOTE, } /** @@ -49,6 +55,8 @@ class DocumentType @JsonCreator private constructor(private val value: JsonField INVOICE, CREDIT_NOTE, DEBIT_NOTE, + SELFBILLING_INVOICE, + SELFBILLING_CREDIT_NOTE, /** An enum member indicating that [DocumentType] was instantiated with an unknown value. */ _UNKNOWN, } @@ -65,6 +73,8 @@ class DocumentType @JsonCreator private constructor(private val value: JsonField INVOICE -> Value.INVOICE CREDIT_NOTE -> Value.CREDIT_NOTE DEBIT_NOTE -> Value.DEBIT_NOTE + SELFBILLING_INVOICE -> Value.SELFBILLING_INVOICE + SELFBILLING_CREDIT_NOTE -> Value.SELFBILLING_CREDIT_NOTE else -> Value._UNKNOWN } @@ -81,6 +91,8 @@ class DocumentType @JsonCreator private constructor(private val value: JsonField INVOICE -> Known.INVOICE CREDIT_NOTE -> Known.CREDIT_NOTE DEBIT_NOTE -> Known.DEBIT_NOTE + SELFBILLING_INVOICE -> Known.SELFBILLING_INVOICE + SELFBILLING_CREDIT_NOTE -> Known.SELFBILLING_CREDIT_NOTE else -> throw EInvoiceInvalidDataException("Unknown DocumentType: $value") } diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListCreditNotesParams.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListCreditNotesParams.kt index 03f6bda..4891f17 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListCreditNotesParams.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListCreditNotesParams.kt @@ -2,9 +2,13 @@ package com.e_invoice.api.models.inbox +import com.e_invoice.api.core.Enum +import com.e_invoice.api.core.JsonField import com.e_invoice.api.core.Params import com.e_invoice.api.core.http.Headers import com.e_invoice.api.core.http.QueryParams +import com.e_invoice.api.errors.EInvoiceInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -14,6 +18,8 @@ class InboxListCreditNotesParams private constructor( private val page: Long?, private val pageSize: Long?, + private val sortBy: SortBy?, + private val sortOrder: SortOrder?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -24,6 +30,12 @@ private constructor( /** Number of items per page */ fun pageSize(): Optional = Optional.ofNullable(pageSize) + /** Field to sort by */ + fun sortBy(): Optional = Optional.ofNullable(sortBy) + + /** Sort direction (asc/desc) */ + fun sortOrder(): Optional = Optional.ofNullable(sortOrder) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -47,6 +59,8 @@ private constructor( private var page: Long? = null private var pageSize: Long? = null + private var sortBy: SortBy? = null + private var sortOrder: SortOrder? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -54,6 +68,8 @@ private constructor( internal fun from(inboxListCreditNotesParams: InboxListCreditNotesParams) = apply { page = inboxListCreditNotesParams.page pageSize = inboxListCreditNotesParams.pageSize + sortBy = inboxListCreditNotesParams.sortBy + sortOrder = inboxListCreditNotesParams.sortOrder additionalHeaders = inboxListCreditNotesParams.additionalHeaders.toBuilder() additionalQueryParams = inboxListCreditNotesParams.additionalQueryParams.toBuilder() } @@ -84,6 +100,18 @@ private constructor( /** Alias for calling [Builder.pageSize] with `pageSize.orElse(null)`. */ fun pageSize(pageSize: Optional) = pageSize(pageSize.getOrNull()) + /** Field to sort by */ + fun sortBy(sortBy: SortBy?) = apply { this.sortBy = sortBy } + + /** Alias for calling [Builder.sortBy] with `sortBy.orElse(null)`. */ + fun sortBy(sortBy: Optional) = sortBy(sortBy.getOrNull()) + + /** Sort direction (asc/desc) */ + fun sortOrder(sortOrder: SortOrder?) = apply { this.sortOrder = sortOrder } + + /** Alias for calling [Builder.sortOrder] with `sortOrder.orElse(null)`. */ + fun sortOrder(sortOrder: Optional) = sortOrder(sortOrder.getOrNull()) + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -191,6 +219,8 @@ private constructor( InboxListCreditNotesParams( page, pageSize, + sortBy, + sortOrder, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -203,10 +233,300 @@ private constructor( .apply { page?.let { put("page", it.toString()) } pageSize?.let { put("page_size", it.toString()) } + sortBy?.let { put("sort_by", it.toString()) } + sortOrder?.let { put("sort_order", it.toString()) } putAll(additionalQueryParams) } .build() + /** Field to sort by */ + class SortBy @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CREATED_AT = of("created_at") + + @JvmField val INVOICE_DATE = of("invoice_date") + + @JvmField val DUE_DATE = of("due_date") + + @JvmField val INVOICE_TOTAL = of("invoice_total") + + @JvmField val CUSTOMER_NAME = of("customer_name") + + @JvmField val VENDOR_NAME = of("vendor_name") + + @JvmField val INVOICE_ID = of("invoice_id") + + @JvmStatic fun of(value: String) = SortBy(JsonField.of(value)) + } + + /** An enum containing [SortBy]'s known values. */ + enum class Known { + CREATED_AT, + INVOICE_DATE, + DUE_DATE, + INVOICE_TOTAL, + CUSTOMER_NAME, + VENDOR_NAME, + INVOICE_ID, + } + + /** + * An enum containing [SortBy]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [SortBy] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CREATED_AT, + INVOICE_DATE, + DUE_DATE, + INVOICE_TOTAL, + CUSTOMER_NAME, + VENDOR_NAME, + INVOICE_ID, + /** An enum member indicating that [SortBy] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CREATED_AT -> Value.CREATED_AT + INVOICE_DATE -> Value.INVOICE_DATE + DUE_DATE -> Value.DUE_DATE + INVOICE_TOTAL -> Value.INVOICE_TOTAL + CUSTOMER_NAME -> Value.CUSTOMER_NAME + VENDOR_NAME -> Value.VENDOR_NAME + INVOICE_ID -> Value.INVOICE_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CREATED_AT -> Known.CREATED_AT + INVOICE_DATE -> Known.INVOICE_DATE + DUE_DATE -> Known.DUE_DATE + INVOICE_TOTAL -> Known.INVOICE_TOTAL + CUSTOMER_NAME -> Known.CUSTOMER_NAME + VENDOR_NAME -> Known.VENDOR_NAME + INVOICE_ID -> Known.INVOICE_ID + else -> throw EInvoiceInvalidDataException("Unknown SortBy: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): SortBy = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SortBy && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Sort direction (asc/desc) */ + class SortOrder @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ASC = of("asc") + + @JvmField val DESC = of("desc") + + @JvmStatic fun of(value: String) = SortOrder(JsonField.of(value)) + } + + /** An enum containing [SortOrder]'s known values. */ + enum class Known { + ASC, + DESC, + } + + /** + * An enum containing [SortOrder]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [SortOrder] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ASC, + DESC, + /** + * An enum member indicating that [SortOrder] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ASC -> Value.ASC + DESC -> Value.DESC + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ASC -> Known.ASC + DESC -> Known.DESC + else -> throw EInvoiceInvalidDataException("Unknown SortOrder: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): SortOrder = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SortOrder && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -215,13 +535,15 @@ private constructor( return other is InboxListCreditNotesParams && page == other.page && pageSize == other.pageSize && + sortBy == other.sortBy && + sortOrder == other.sortOrder && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } override fun hashCode(): Int = - Objects.hash(page, pageSize, additionalHeaders, additionalQueryParams) + Objects.hash(page, pageSize, sortBy, sortOrder, additionalHeaders, additionalQueryParams) override fun toString() = - "InboxListCreditNotesParams{page=$page, pageSize=$pageSize, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "InboxListCreditNotesParams{page=$page, pageSize=$pageSize, sortBy=$sortBy, sortOrder=$sortOrder, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListInvoicesParams.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListInvoicesParams.kt index 6114365..6c806d6 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListInvoicesParams.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListInvoicesParams.kt @@ -2,9 +2,13 @@ package com.e_invoice.api.models.inbox +import com.e_invoice.api.core.Enum +import com.e_invoice.api.core.JsonField import com.e_invoice.api.core.Params import com.e_invoice.api.core.http.Headers import com.e_invoice.api.core.http.QueryParams +import com.e_invoice.api.errors.EInvoiceInvalidDataException +import com.fasterxml.jackson.annotation.JsonCreator import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull @@ -14,6 +18,8 @@ class InboxListInvoicesParams private constructor( private val page: Long?, private val pageSize: Long?, + private val sortBy: SortBy?, + private val sortOrder: SortOrder?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -24,6 +30,12 @@ private constructor( /** Number of items per page */ fun pageSize(): Optional = Optional.ofNullable(pageSize) + /** Field to sort by */ + fun sortBy(): Optional = Optional.ofNullable(sortBy) + + /** Sort direction (asc/desc) */ + fun sortOrder(): Optional = Optional.ofNullable(sortOrder) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -45,6 +57,8 @@ private constructor( private var page: Long? = null private var pageSize: Long? = null + private var sortBy: SortBy? = null + private var sortOrder: SortOrder? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -52,6 +66,8 @@ private constructor( internal fun from(inboxListInvoicesParams: InboxListInvoicesParams) = apply { page = inboxListInvoicesParams.page pageSize = inboxListInvoicesParams.pageSize + sortBy = inboxListInvoicesParams.sortBy + sortOrder = inboxListInvoicesParams.sortOrder additionalHeaders = inboxListInvoicesParams.additionalHeaders.toBuilder() additionalQueryParams = inboxListInvoicesParams.additionalQueryParams.toBuilder() } @@ -82,6 +98,18 @@ private constructor( /** Alias for calling [Builder.pageSize] with `pageSize.orElse(null)`. */ fun pageSize(pageSize: Optional) = pageSize(pageSize.getOrNull()) + /** Field to sort by */ + fun sortBy(sortBy: SortBy?) = apply { this.sortBy = sortBy } + + /** Alias for calling [Builder.sortBy] with `sortBy.orElse(null)`. */ + fun sortBy(sortBy: Optional) = sortBy(sortBy.getOrNull()) + + /** Sort direction (asc/desc) */ + fun sortOrder(sortOrder: SortOrder?) = apply { this.sortOrder = sortOrder } + + /** Alias for calling [Builder.sortOrder] with `sortOrder.orElse(null)`. */ + fun sortOrder(sortOrder: Optional) = sortOrder(sortOrder.getOrNull()) + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -189,6 +217,8 @@ private constructor( InboxListInvoicesParams( page, pageSize, + sortBy, + sortOrder, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -201,10 +231,300 @@ private constructor( .apply { page?.let { put("page", it.toString()) } pageSize?.let { put("page_size", it.toString()) } + sortBy?.let { put("sort_by", it.toString()) } + sortOrder?.let { put("sort_order", it.toString()) } putAll(additionalQueryParams) } .build() + /** Field to sort by */ + class SortBy @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CREATED_AT = of("created_at") + + @JvmField val INVOICE_DATE = of("invoice_date") + + @JvmField val DUE_DATE = of("due_date") + + @JvmField val INVOICE_TOTAL = of("invoice_total") + + @JvmField val CUSTOMER_NAME = of("customer_name") + + @JvmField val VENDOR_NAME = of("vendor_name") + + @JvmField val INVOICE_ID = of("invoice_id") + + @JvmStatic fun of(value: String) = SortBy(JsonField.of(value)) + } + + /** An enum containing [SortBy]'s known values. */ + enum class Known { + CREATED_AT, + INVOICE_DATE, + DUE_DATE, + INVOICE_TOTAL, + CUSTOMER_NAME, + VENDOR_NAME, + INVOICE_ID, + } + + /** + * An enum containing [SortBy]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [SortBy] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CREATED_AT, + INVOICE_DATE, + DUE_DATE, + INVOICE_TOTAL, + CUSTOMER_NAME, + VENDOR_NAME, + INVOICE_ID, + /** An enum member indicating that [SortBy] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CREATED_AT -> Value.CREATED_AT + INVOICE_DATE -> Value.INVOICE_DATE + DUE_DATE -> Value.DUE_DATE + INVOICE_TOTAL -> Value.INVOICE_TOTAL + CUSTOMER_NAME -> Value.CUSTOMER_NAME + VENDOR_NAME -> Value.VENDOR_NAME + INVOICE_ID -> Value.INVOICE_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CREATED_AT -> Known.CREATED_AT + INVOICE_DATE -> Known.INVOICE_DATE + DUE_DATE -> Known.DUE_DATE + INVOICE_TOTAL -> Known.INVOICE_TOTAL + CUSTOMER_NAME -> Known.CUSTOMER_NAME + VENDOR_NAME -> Known.VENDOR_NAME + INVOICE_ID -> Known.INVOICE_ID + else -> throw EInvoiceInvalidDataException("Unknown SortBy: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): SortBy = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SortBy && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Sort direction (asc/desc) */ + class SortOrder @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ASC = of("asc") + + @JvmField val DESC = of("desc") + + @JvmStatic fun of(value: String) = SortOrder(JsonField.of(value)) + } + + /** An enum containing [SortOrder]'s known values. */ + enum class Known { + ASC, + DESC, + } + + /** + * An enum containing [SortOrder]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [SortOrder] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ASC, + DESC, + /** + * An enum member indicating that [SortOrder] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ASC -> Value.ASC + DESC -> Value.DESC + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ASC -> Known.ASC + DESC -> Known.DESC + else -> throw EInvoiceInvalidDataException("Unknown SortOrder: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): SortOrder = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SortOrder && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -213,13 +533,15 @@ private constructor( return other is InboxListInvoicesParams && page == other.page && pageSize == other.pageSize && + sortBy == other.sortBy && + sortOrder == other.sortOrder && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } override fun hashCode(): Int = - Objects.hash(page, pageSize, additionalHeaders, additionalQueryParams) + Objects.hash(page, pageSize, sortBy, sortOrder, additionalHeaders, additionalQueryParams) override fun toString() = - "InboxListInvoicesParams{page=$page, pageSize=$pageSize, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "InboxListInvoicesParams{page=$page, pageSize=$pageSize, sortBy=$sortBy, sortOrder=$sortOrder, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListParams.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListParams.kt index 4b06da2..6d8f748 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListParams.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListParams.kt @@ -2,10 +2,14 @@ package com.e_invoice.api.models.inbox +import com.e_invoice.api.core.Enum +import com.e_invoice.api.core.JsonField import com.e_invoice.api.core.Params import com.e_invoice.api.core.http.Headers import com.e_invoice.api.core.http.QueryParams +import com.e_invoice.api.errors.EInvoiceInvalidDataException import com.e_invoice.api.models.documents.DocumentType +import com.fasterxml.jackson.annotation.JsonCreator import java.time.OffsetDateTime import java.time.format.DateTimeFormatter import java.util.Objects @@ -24,6 +28,8 @@ private constructor( private val pageSize: Long?, private val search: String?, private val sender: String?, + private val sortBy: SortBy?, + private val sortOrder: SortOrder?, private val state: DocumentState?, private val type: DocumentType?, private val additionalHeaders: Headers, @@ -45,9 +51,15 @@ private constructor( /** Search in invoice number, seller/buyer names */ fun search(): Optional = Optional.ofNullable(search) - /** Filter by sender ID */ + /** Filter by sender (vendor_name, vendor_email, vendor_tax_id, vendor_company_id) */ fun sender(): Optional = Optional.ofNullable(sender) + /** Field to sort by */ + fun sortBy(): Optional = Optional.ofNullable(sortBy) + + /** Sort direction (asc/desc) */ + fun sortOrder(): Optional = Optional.ofNullable(sortOrder) + /** Filter by document state */ fun state(): Optional = Optional.ofNullable(state) @@ -79,6 +91,8 @@ private constructor( private var pageSize: Long? = null private var search: String? = null private var sender: String? = null + private var sortBy: SortBy? = null + private var sortOrder: SortOrder? = null private var state: DocumentState? = null private var type: DocumentType? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -92,6 +106,8 @@ private constructor( pageSize = inboxListParams.pageSize search = inboxListParams.search sender = inboxListParams.sender + sortBy = inboxListParams.sortBy + sortOrder = inboxListParams.sortOrder state = inboxListParams.state type = inboxListParams.type additionalHeaders = inboxListParams.additionalHeaders.toBuilder() @@ -142,12 +158,24 @@ private constructor( /** Alias for calling [Builder.search] with `search.orElse(null)`. */ fun search(search: Optional) = search(search.getOrNull()) - /** Filter by sender ID */ + /** Filter by sender (vendor_name, vendor_email, vendor_tax_id, vendor_company_id) */ fun sender(sender: String?) = apply { this.sender = sender } /** Alias for calling [Builder.sender] with `sender.orElse(null)`. */ fun sender(sender: Optional) = sender(sender.getOrNull()) + /** Field to sort by */ + fun sortBy(sortBy: SortBy?) = apply { this.sortBy = sortBy } + + /** Alias for calling [Builder.sortBy] with `sortBy.orElse(null)`. */ + fun sortBy(sortBy: Optional) = sortBy(sortBy.getOrNull()) + + /** Sort direction (asc/desc) */ + fun sortOrder(sortOrder: SortOrder?) = apply { this.sortOrder = sortOrder } + + /** Alias for calling [Builder.sortOrder] with `sortOrder.orElse(null)`. */ + fun sortOrder(sortOrder: Optional) = sortOrder(sortOrder.getOrNull()) + /** Filter by document state */ fun state(state: DocumentState?) = apply { this.state = state } @@ -271,6 +299,8 @@ private constructor( pageSize, search, sender, + sortBy, + sortOrder, state, type, additionalHeaders.build(), @@ -291,12 +321,302 @@ private constructor( pageSize?.let { put("page_size", it.toString()) } search?.let { put("search", it) } sender?.let { put("sender", it) } + sortBy?.let { put("sort_by", it.toString()) } + sortOrder?.let { put("sort_order", it.toString()) } state?.let { put("state", it.toString()) } type?.let { put("type", it.toString()) } putAll(additionalQueryParams) } .build() + /** Field to sort by */ + class SortBy @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CREATED_AT = of("created_at") + + @JvmField val INVOICE_DATE = of("invoice_date") + + @JvmField val DUE_DATE = of("due_date") + + @JvmField val INVOICE_TOTAL = of("invoice_total") + + @JvmField val CUSTOMER_NAME = of("customer_name") + + @JvmField val VENDOR_NAME = of("vendor_name") + + @JvmField val INVOICE_ID = of("invoice_id") + + @JvmStatic fun of(value: String) = SortBy(JsonField.of(value)) + } + + /** An enum containing [SortBy]'s known values. */ + enum class Known { + CREATED_AT, + INVOICE_DATE, + DUE_DATE, + INVOICE_TOTAL, + CUSTOMER_NAME, + VENDOR_NAME, + INVOICE_ID, + } + + /** + * An enum containing [SortBy]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [SortBy] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CREATED_AT, + INVOICE_DATE, + DUE_DATE, + INVOICE_TOTAL, + CUSTOMER_NAME, + VENDOR_NAME, + INVOICE_ID, + /** An enum member indicating that [SortBy] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CREATED_AT -> Value.CREATED_AT + INVOICE_DATE -> Value.INVOICE_DATE + DUE_DATE -> Value.DUE_DATE + INVOICE_TOTAL -> Value.INVOICE_TOTAL + CUSTOMER_NAME -> Value.CUSTOMER_NAME + VENDOR_NAME -> Value.VENDOR_NAME + INVOICE_ID -> Value.INVOICE_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CREATED_AT -> Known.CREATED_AT + INVOICE_DATE -> Known.INVOICE_DATE + DUE_DATE -> Known.DUE_DATE + INVOICE_TOTAL -> Known.INVOICE_TOTAL + CUSTOMER_NAME -> Known.CUSTOMER_NAME + VENDOR_NAME -> Known.VENDOR_NAME + INVOICE_ID -> Known.INVOICE_ID + else -> throw EInvoiceInvalidDataException("Unknown SortBy: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): SortBy = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SortBy && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Sort direction (asc/desc) */ + class SortOrder @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ASC = of("asc") + + @JvmField val DESC = of("desc") + + @JvmStatic fun of(value: String) = SortOrder(JsonField.of(value)) + } + + /** An enum containing [SortOrder]'s known values. */ + enum class Known { + ASC, + DESC, + } + + /** + * An enum containing [SortOrder]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [SortOrder] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ASC, + DESC, + /** + * An enum member indicating that [SortOrder] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ASC -> Value.ASC + DESC -> Value.DESC + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ASC -> Known.ASC + DESC -> Known.DESC + else -> throw EInvoiceInvalidDataException("Unknown SortOrder: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): SortOrder = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SortOrder && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -309,6 +629,8 @@ private constructor( pageSize == other.pageSize && search == other.search && sender == other.sender && + sortBy == other.sortBy && + sortOrder == other.sortOrder && state == other.state && type == other.type && additionalHeaders == other.additionalHeaders && @@ -323,6 +645,8 @@ private constructor( pageSize, search, sender, + sortBy, + sortOrder, state, type, additionalHeaders, @@ -330,5 +654,5 @@ private constructor( ) override fun toString() = - "InboxListParams{dateFrom=$dateFrom, dateTo=$dateTo, page=$page, pageSize=$pageSize, search=$search, sender=$sender, state=$state, type=$type, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "InboxListParams{dateFrom=$dateFrom, dateTo=$dateTo, page=$page, pageSize=$pageSize, search=$search, sender=$sender, sortBy=$sortBy, sortOrder=$sortOrder, state=$state, type=$type, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponse.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponse.kt index 1eefc67..236e300 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponse.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponse.kt @@ -22,6 +22,7 @@ import kotlin.jvm.optionals.getOrNull class PaginatedDocumentResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( + private val hasNextPage: JsonField, private val items: JsonField>, private val page: JsonField, private val pageSize: JsonField, @@ -32,6 +33,9 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("has_next_page") + @ExcludeMissing + hasNextPage: JsonField = JsonMissing.of(), @JsonProperty("items") @ExcludeMissing items: JsonField> = JsonMissing.of(), @@ -39,7 +43,13 @@ private constructor( @JsonProperty("page_size") @ExcludeMissing pageSize: JsonField = JsonMissing.of(), @JsonProperty("pages") @ExcludeMissing pages: JsonField = JsonMissing.of(), @JsonProperty("total") @ExcludeMissing total: JsonField = JsonMissing.of(), - ) : this(items, page, pageSize, pages, total, mutableMapOf()) + ) : this(hasNextPage, items, page, pageSize, pages, total, mutableMapOf()) + + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun hasNextPage(): Boolean = hasNextPage.getRequired("has_next_page") /** * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type or is @@ -71,6 +81,15 @@ private constructor( */ fun total(): Long = total.getRequired("total") + /** + * Returns the raw JSON value of [hasNextPage]. + * + * Unlike [hasNextPage], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("has_next_page") + @ExcludeMissing + fun _hasNextPage(): JsonField = hasNextPage + /** * Returns the raw JSON value of [items]. * @@ -125,6 +144,7 @@ private constructor( * * The following fields are required: * ```java + * .hasNextPage() * .items() * .page() * .pageSize() @@ -138,6 +158,7 @@ private constructor( /** A builder for [PaginatedDocumentResponse]. */ class Builder internal constructor() { + private var hasNextPage: JsonField? = null private var items: JsonField>? = null private var page: JsonField? = null private var pageSize: JsonField? = null @@ -147,6 +168,7 @@ private constructor( @JvmSynthetic internal fun from(paginatedDocumentResponse: PaginatedDocumentResponse) = apply { + hasNextPage = paginatedDocumentResponse.hasNextPage items = paginatedDocumentResponse.items.map { it.toMutableList() } page = paginatedDocumentResponse.page pageSize = paginatedDocumentResponse.pageSize @@ -155,6 +177,17 @@ private constructor( additionalProperties = paginatedDocumentResponse.additionalProperties.toMutableMap() } + fun hasNextPage(hasNextPage: Boolean) = hasNextPage(JsonField.of(hasNextPage)) + + /** + * Sets [Builder.hasNextPage] to an arbitrary JSON value. + * + * You should usually call [Builder.hasNextPage] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun hasNextPage(hasNextPage: JsonField) = apply { this.hasNextPage = hasNextPage } + fun items(items: List) = items(JsonField.of(items)) /** @@ -244,6 +277,7 @@ private constructor( * * The following fields are required: * ```java + * .hasNextPage() * .items() * .page() * .pageSize() @@ -255,6 +289,7 @@ private constructor( */ fun build(): PaginatedDocumentResponse = PaginatedDocumentResponse( + checkRequired("hasNextPage", hasNextPage), checkRequired("items", items).map { it.toImmutable() }, checkRequired("page", page), checkRequired("pageSize", pageSize), @@ -271,6 +306,7 @@ private constructor( return@apply } + hasNextPage() items().forEach { it.validate() } page() pageSize() @@ -294,7 +330,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (hasNextPage.asKnown().isPresent) 1 else 0) + + (items.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (page.asKnown().isPresent) 1 else 0) + (if (pageSize.asKnown().isPresent) 1 else 0) + (if (pages.asKnown().isPresent) 1 else 0) + @@ -306,6 +343,7 @@ private constructor( } return other is PaginatedDocumentResponse && + hasNextPage == other.hasNextPage && items == other.items && page == other.page && pageSize == other.pageSize && @@ -315,11 +353,11 @@ private constructor( } private val hashCode: Int by lazy { - Objects.hash(items, page, pageSize, pages, total, additionalProperties) + Objects.hash(hasNextPage, items, page, pageSize, pages, total, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "PaginatedDocumentResponse{items=$items, page=$page, pageSize=$pageSize, pages=$pages, total=$total, additionalProperties=$additionalProperties}" + "PaginatedDocumentResponse{hasNextPage=$hasNextPage, items=$items, page=$page, pageSize=$pageSize, pages=$pages, total=$total, additionalProperties=$additionalProperties}" } diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListDraftDocumentsParams.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListDraftDocumentsParams.kt index 0907192..1014480 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListDraftDocumentsParams.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListDraftDocumentsParams.kt @@ -2,18 +2,32 @@ package com.e_invoice.api.models.outbox +import com.e_invoice.api.core.Enum +import com.e_invoice.api.core.JsonField import com.e_invoice.api.core.Params import com.e_invoice.api.core.http.Headers import com.e_invoice.api.core.http.QueryParams +import com.e_invoice.api.errors.EInvoiceInvalidDataException +import com.e_invoice.api.models.documents.DocumentType +import com.e_invoice.api.models.inbox.DocumentState +import com.fasterxml.jackson.annotation.JsonCreator import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** Retrieve a paginated list of draft documents with filtering options. */ +/** + * Retrieve a paginated list of draft documents with filtering options including state and text + * search. + */ class OutboxListDraftDocumentsParams private constructor( private val page: Long?, private val pageSize: Long?, + private val search: String?, + private val sortBy: SortBy?, + private val sortOrder: SortOrder?, + private val state: DocumentState?, + private val type: DocumentType?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -24,6 +38,21 @@ private constructor( /** Number of items per page */ fun pageSize(): Optional = Optional.ofNullable(pageSize) + /** Search in invoice number, seller/buyer names */ + fun search(): Optional = Optional.ofNullable(search) + + /** Field to sort by */ + fun sortBy(): Optional = Optional.ofNullable(sortBy) + + /** Sort direction (asc/desc) */ + fun sortOrder(): Optional = Optional.ofNullable(sortOrder) + + /** Filter by document state */ + fun state(): Optional = Optional.ofNullable(state) + + /** Filter by document type */ + fun type(): Optional = Optional.ofNullable(type) + /** Additional headers to send with the request. */ fun _additionalHeaders(): Headers = additionalHeaders @@ -48,6 +77,11 @@ private constructor( private var page: Long? = null private var pageSize: Long? = null + private var search: String? = null + private var sortBy: SortBy? = null + private var sortOrder: SortOrder? = null + private var state: DocumentState? = null + private var type: DocumentType? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -55,6 +89,11 @@ private constructor( internal fun from(outboxListDraftDocumentsParams: OutboxListDraftDocumentsParams) = apply { page = outboxListDraftDocumentsParams.page pageSize = outboxListDraftDocumentsParams.pageSize + search = outboxListDraftDocumentsParams.search + sortBy = outboxListDraftDocumentsParams.sortBy + sortOrder = outboxListDraftDocumentsParams.sortOrder + state = outboxListDraftDocumentsParams.state + type = outboxListDraftDocumentsParams.type additionalHeaders = outboxListDraftDocumentsParams.additionalHeaders.toBuilder() additionalQueryParams = outboxListDraftDocumentsParams.additionalQueryParams.toBuilder() } @@ -85,6 +124,36 @@ private constructor( /** Alias for calling [Builder.pageSize] with `pageSize.orElse(null)`. */ fun pageSize(pageSize: Optional) = pageSize(pageSize.getOrNull()) + /** Search in invoice number, seller/buyer names */ + fun search(search: String?) = apply { this.search = search } + + /** Alias for calling [Builder.search] with `search.orElse(null)`. */ + fun search(search: Optional) = search(search.getOrNull()) + + /** Field to sort by */ + fun sortBy(sortBy: SortBy?) = apply { this.sortBy = sortBy } + + /** Alias for calling [Builder.sortBy] with `sortBy.orElse(null)`. */ + fun sortBy(sortBy: Optional) = sortBy(sortBy.getOrNull()) + + /** Sort direction (asc/desc) */ + fun sortOrder(sortOrder: SortOrder?) = apply { this.sortOrder = sortOrder } + + /** Alias for calling [Builder.sortOrder] with `sortOrder.orElse(null)`. */ + fun sortOrder(sortOrder: Optional) = sortOrder(sortOrder.getOrNull()) + + /** Filter by document state */ + fun state(state: DocumentState?) = apply { this.state = state } + + /** Alias for calling [Builder.state] with `state.orElse(null)`. */ + fun state(state: Optional) = state(state.getOrNull()) + + /** Filter by document type */ + fun type(type: DocumentType?) = apply { this.type = type } + + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ + fun type(type: Optional) = type(type.getOrNull()) + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -192,6 +261,11 @@ private constructor( OutboxListDraftDocumentsParams( page, pageSize, + search, + sortBy, + sortOrder, + state, + type, additionalHeaders.build(), additionalQueryParams.build(), ) @@ -204,10 +278,303 @@ private constructor( .apply { page?.let { put("page", it.toString()) } pageSize?.let { put("page_size", it.toString()) } + search?.let { put("search", it) } + sortBy?.let { put("sort_by", it.toString()) } + sortOrder?.let { put("sort_order", it.toString()) } + state?.let { put("state", it.toString()) } + type?.let { put("type", it.toString()) } putAll(additionalQueryParams) } .build() + /** Field to sort by */ + class SortBy @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CREATED_AT = of("created_at") + + @JvmField val INVOICE_DATE = of("invoice_date") + + @JvmField val DUE_DATE = of("due_date") + + @JvmField val INVOICE_TOTAL = of("invoice_total") + + @JvmField val CUSTOMER_NAME = of("customer_name") + + @JvmField val VENDOR_NAME = of("vendor_name") + + @JvmField val INVOICE_ID = of("invoice_id") + + @JvmStatic fun of(value: String) = SortBy(JsonField.of(value)) + } + + /** An enum containing [SortBy]'s known values. */ + enum class Known { + CREATED_AT, + INVOICE_DATE, + DUE_DATE, + INVOICE_TOTAL, + CUSTOMER_NAME, + VENDOR_NAME, + INVOICE_ID, + } + + /** + * An enum containing [SortBy]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [SortBy] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CREATED_AT, + INVOICE_DATE, + DUE_DATE, + INVOICE_TOTAL, + CUSTOMER_NAME, + VENDOR_NAME, + INVOICE_ID, + /** An enum member indicating that [SortBy] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CREATED_AT -> Value.CREATED_AT + INVOICE_DATE -> Value.INVOICE_DATE + DUE_DATE -> Value.DUE_DATE + INVOICE_TOTAL -> Value.INVOICE_TOTAL + CUSTOMER_NAME -> Value.CUSTOMER_NAME + VENDOR_NAME -> Value.VENDOR_NAME + INVOICE_ID -> Value.INVOICE_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CREATED_AT -> Known.CREATED_AT + INVOICE_DATE -> Known.INVOICE_DATE + DUE_DATE -> Known.DUE_DATE + INVOICE_TOTAL -> Known.INVOICE_TOTAL + CUSTOMER_NAME -> Known.CUSTOMER_NAME + VENDOR_NAME -> Known.VENDOR_NAME + INVOICE_ID -> Known.INVOICE_ID + else -> throw EInvoiceInvalidDataException("Unknown SortBy: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): SortBy = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SortBy && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Sort direction (asc/desc) */ + class SortOrder @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ASC = of("asc") + + @JvmField val DESC = of("desc") + + @JvmStatic fun of(value: String) = SortOrder(JsonField.of(value)) + } + + /** An enum containing [SortOrder]'s known values. */ + enum class Known { + ASC, + DESC, + } + + /** + * An enum containing [SortOrder]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [SortOrder] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ASC, + DESC, + /** + * An enum member indicating that [SortOrder] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ASC -> Value.ASC + DESC -> Value.DESC + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ASC -> Known.ASC + DESC -> Known.DESC + else -> throw EInvoiceInvalidDataException("Unknown SortOrder: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): SortOrder = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SortOrder && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -216,13 +583,28 @@ private constructor( return other is OutboxListDraftDocumentsParams && page == other.page && pageSize == other.pageSize && + search == other.search && + sortBy == other.sortBy && + sortOrder == other.sortOrder && + state == other.state && + type == other.type && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } override fun hashCode(): Int = - Objects.hash(page, pageSize, additionalHeaders, additionalQueryParams) + Objects.hash( + page, + pageSize, + search, + sortBy, + sortOrder, + state, + type, + additionalHeaders, + additionalQueryParams, + ) override fun toString() = - "OutboxListDraftDocumentsParams{page=$page, pageSize=$pageSize, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "OutboxListDraftDocumentsParams{page=$page, pageSize=$pageSize, search=$search, sortBy=$sortBy, sortOrder=$sortOrder, state=$state, type=$type, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListReceivedDocumentsParams.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListReceivedDocumentsParams.kt index 1439ad2..c7ccaba 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListReceivedDocumentsParams.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListReceivedDocumentsParams.kt @@ -2,11 +2,15 @@ package com.e_invoice.api.models.outbox +import com.e_invoice.api.core.Enum +import com.e_invoice.api.core.JsonField import com.e_invoice.api.core.Params import com.e_invoice.api.core.http.Headers import com.e_invoice.api.core.http.QueryParams +import com.e_invoice.api.errors.EInvoiceInvalidDataException import com.e_invoice.api.models.documents.DocumentType import com.e_invoice.api.models.inbox.DocumentState +import com.fasterxml.jackson.annotation.JsonCreator import java.time.OffsetDateTime import java.time.format.DateTimeFormatter import java.util.Objects @@ -23,8 +27,11 @@ private constructor( private val dateTo: OffsetDateTime?, private val page: Long?, private val pageSize: Long?, + private val receiver: String?, private val search: String?, private val sender: String?, + private val sortBy: SortBy?, + private val sortOrder: SortOrder?, private val state: DocumentState?, private val type: DocumentType?, private val additionalHeaders: Headers, @@ -43,11 +50,23 @@ private constructor( /** Number of items per page */ fun pageSize(): Optional = Optional.ofNullable(pageSize) + /** + * Filter by receiver (customer_name, customer_email, customer_tax_id, customer_company_id, + * customer_id) + */ + fun receiver(): Optional = Optional.ofNullable(receiver) + /** Search in invoice number, seller/buyer names */ fun search(): Optional = Optional.ofNullable(search) - /** Filter by sender ID */ - fun sender(): Optional = Optional.ofNullable(sender) + /** (Deprecated) Filter by sender ID */ + @Deprecated("deprecated") fun sender(): Optional = Optional.ofNullable(sender) + + /** Field to sort by */ + fun sortBy(): Optional = Optional.ofNullable(sortBy) + + /** Sort direction (asc/desc) */ + fun sortOrder(): Optional = Optional.ofNullable(sortOrder) /** Filter by document state */ fun state(): Optional = Optional.ofNullable(state) @@ -81,8 +100,11 @@ private constructor( private var dateTo: OffsetDateTime? = null private var page: Long? = null private var pageSize: Long? = null + private var receiver: String? = null private var search: String? = null private var sender: String? = null + private var sortBy: SortBy? = null + private var sortOrder: SortOrder? = null private var state: DocumentState? = null private var type: DocumentType? = null private var additionalHeaders: Headers.Builder = Headers.builder() @@ -95,8 +117,11 @@ private constructor( dateTo = outboxListReceivedDocumentsParams.dateTo page = outboxListReceivedDocumentsParams.page pageSize = outboxListReceivedDocumentsParams.pageSize + receiver = outboxListReceivedDocumentsParams.receiver search = outboxListReceivedDocumentsParams.search sender = outboxListReceivedDocumentsParams.sender + sortBy = outboxListReceivedDocumentsParams.sortBy + sortOrder = outboxListReceivedDocumentsParams.sortOrder state = outboxListReceivedDocumentsParams.state type = outboxListReceivedDocumentsParams.type additionalHeaders = outboxListReceivedDocumentsParams.additionalHeaders.toBuilder() @@ -142,17 +167,38 @@ private constructor( /** Alias for calling [Builder.pageSize] with `pageSize.orElse(null)`. */ fun pageSize(pageSize: Optional) = pageSize(pageSize.getOrNull()) + /** + * Filter by receiver (customer_name, customer_email, customer_tax_id, customer_company_id, + * customer_id) + */ + fun receiver(receiver: String?) = apply { this.receiver = receiver } + + /** Alias for calling [Builder.receiver] with `receiver.orElse(null)`. */ + fun receiver(receiver: Optional) = receiver(receiver.getOrNull()) + /** Search in invoice number, seller/buyer names */ fun search(search: String?) = apply { this.search = search } /** Alias for calling [Builder.search] with `search.orElse(null)`. */ fun search(search: Optional) = search(search.getOrNull()) - /** Filter by sender ID */ - fun sender(sender: String?) = apply { this.sender = sender } + /** (Deprecated) Filter by sender ID */ + @Deprecated("deprecated") fun sender(sender: String?) = apply { this.sender = sender } /** Alias for calling [Builder.sender] with `sender.orElse(null)`. */ - fun sender(sender: Optional) = sender(sender.getOrNull()) + @Deprecated("deprecated") fun sender(sender: Optional) = sender(sender.getOrNull()) + + /** Field to sort by */ + fun sortBy(sortBy: SortBy?) = apply { this.sortBy = sortBy } + + /** Alias for calling [Builder.sortBy] with `sortBy.orElse(null)`. */ + fun sortBy(sortBy: Optional) = sortBy(sortBy.getOrNull()) + + /** Sort direction (asc/desc) */ + fun sortOrder(sortOrder: SortOrder?) = apply { this.sortOrder = sortOrder } + + /** Alias for calling [Builder.sortOrder] with `sortOrder.orElse(null)`. */ + fun sortOrder(sortOrder: Optional) = sortOrder(sortOrder.getOrNull()) /** Filter by document state */ fun state(state: DocumentState?) = apply { this.state = state } @@ -275,8 +321,11 @@ private constructor( dateTo, page, pageSize, + receiver, search, sender, + sortBy, + sortOrder, state, type, additionalHeaders.build(), @@ -295,14 +344,305 @@ private constructor( dateTo?.let { put("date_to", DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)) } page?.let { put("page", it.toString()) } pageSize?.let { put("page_size", it.toString()) } + receiver?.let { put("receiver", it) } search?.let { put("search", it) } sender?.let { put("sender", it) } + sortBy?.let { put("sort_by", it.toString()) } + sortOrder?.let { put("sort_order", it.toString()) } state?.let { put("state", it.toString()) } type?.let { put("type", it.toString()) } putAll(additionalQueryParams) } .build() + /** Field to sort by */ + class SortBy @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CREATED_AT = of("created_at") + + @JvmField val INVOICE_DATE = of("invoice_date") + + @JvmField val DUE_DATE = of("due_date") + + @JvmField val INVOICE_TOTAL = of("invoice_total") + + @JvmField val CUSTOMER_NAME = of("customer_name") + + @JvmField val VENDOR_NAME = of("vendor_name") + + @JvmField val INVOICE_ID = of("invoice_id") + + @JvmStatic fun of(value: String) = SortBy(JsonField.of(value)) + } + + /** An enum containing [SortBy]'s known values. */ + enum class Known { + CREATED_AT, + INVOICE_DATE, + DUE_DATE, + INVOICE_TOTAL, + CUSTOMER_NAME, + VENDOR_NAME, + INVOICE_ID, + } + + /** + * An enum containing [SortBy]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [SortBy] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CREATED_AT, + INVOICE_DATE, + DUE_DATE, + INVOICE_TOTAL, + CUSTOMER_NAME, + VENDOR_NAME, + INVOICE_ID, + /** An enum member indicating that [SortBy] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CREATED_AT -> Value.CREATED_AT + INVOICE_DATE -> Value.INVOICE_DATE + DUE_DATE -> Value.DUE_DATE + INVOICE_TOTAL -> Value.INVOICE_TOTAL + CUSTOMER_NAME -> Value.CUSTOMER_NAME + VENDOR_NAME -> Value.VENDOR_NAME + INVOICE_ID -> Value.INVOICE_ID + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CREATED_AT -> Known.CREATED_AT + INVOICE_DATE -> Known.INVOICE_DATE + DUE_DATE -> Known.DUE_DATE + INVOICE_TOTAL -> Known.INVOICE_TOTAL + CUSTOMER_NAME -> Known.CUSTOMER_NAME + VENDOR_NAME -> Known.VENDOR_NAME + INVOICE_ID -> Known.INVOICE_ID + else -> throw EInvoiceInvalidDataException("Unknown SortBy: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): SortBy = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SortBy && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Sort direction (asc/desc) */ + class SortOrder @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ASC = of("asc") + + @JvmField val DESC = of("desc") + + @JvmStatic fun of(value: String) = SortOrder(JsonField.of(value)) + } + + /** An enum containing [SortOrder]'s known values. */ + enum class Known { + ASC, + DESC, + } + + /** + * An enum containing [SortOrder]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [SortOrder] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ASC, + DESC, + /** + * An enum member indicating that [SortOrder] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ASC -> Value.ASC + DESC -> Value.DESC + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws EInvoiceInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ASC -> Known.ASC + DESC -> Known.DESC + else -> throw EInvoiceInvalidDataException("Unknown SortOrder: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws EInvoiceInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + EInvoiceInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): SortOrder = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: EInvoiceInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SortOrder && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -313,8 +653,11 @@ private constructor( dateTo == other.dateTo && page == other.page && pageSize == other.pageSize && + receiver == other.receiver && search == other.search && sender == other.sender && + sortBy == other.sortBy && + sortOrder == other.sortOrder && state == other.state && type == other.type && additionalHeaders == other.additionalHeaders && @@ -327,8 +670,11 @@ private constructor( dateTo, page, pageSize, + receiver, search, sender, + sortBy, + sortOrder, state, type, additionalHeaders, @@ -336,5 +682,5 @@ private constructor( ) override fun toString() = - "OutboxListReceivedDocumentsParams{dateFrom=$dateFrom, dateTo=$dateTo, page=$page, pageSize=$pageSize, search=$search, sender=$sender, state=$state, type=$type, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "OutboxListReceivedDocumentsParams{dateFrom=$dateFrom, dateTo=$dateTo, page=$page, pageSize=$pageSize, receiver=$receiver, search=$search, sender=$sender, sortBy=$sortBy, sortOrder=$sortOrder, state=$state, type=$type, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/OutboxServiceAsync.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/OutboxServiceAsync.kt index 70ed926..916d730 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/OutboxServiceAsync.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/OutboxServiceAsync.kt @@ -26,7 +26,10 @@ interface OutboxServiceAsync { */ fun withOptions(modifier: Consumer): OutboxServiceAsync - /** Retrieve a paginated list of draft documents with filtering options. */ + /** + * Retrieve a paginated list of draft documents with filtering options including state and text + * search. + */ fun listDraftDocuments(): CompletableFuture = listDraftDocuments(OutboxListDraftDocumentsParams.none()) diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/OutboxService.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/OutboxService.kt index ddb3045..2704fab 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/OutboxService.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/OutboxService.kt @@ -26,7 +26,10 @@ interface OutboxService { */ fun withOptions(modifier: Consumer): OutboxService - /** Retrieve a paginated list of draft documents with filtering options. */ + /** + * Retrieve a paginated list of draft documents with filtering options including state and text + * search. + */ fun listDraftDocuments(): OutboxListDraftDocumentsPage = listDraftDocuments(OutboxListDraftDocumentsParams.none()) diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/InboxListCreditNotesParamsTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/InboxListCreditNotesParamsTest.kt index 4410f38..ecb45de 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/InboxListCreditNotesParamsTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/InboxListCreditNotesParamsTest.kt @@ -10,17 +10,35 @@ internal class InboxListCreditNotesParamsTest { @Test fun create() { - InboxListCreditNotesParams.builder().page(1L).pageSize(1L).build() + InboxListCreditNotesParams.builder() + .page(1L) + .pageSize(1L) + .sortBy(InboxListCreditNotesParams.SortBy.CREATED_AT) + .sortOrder(InboxListCreditNotesParams.SortOrder.ASC) + .build() } @Test fun queryParams() { - val params = InboxListCreditNotesParams.builder().page(1L).pageSize(1L).build() + val params = + InboxListCreditNotesParams.builder() + .page(1L) + .pageSize(1L) + .sortBy(InboxListCreditNotesParams.SortBy.CREATED_AT) + .sortOrder(InboxListCreditNotesParams.SortOrder.ASC) + .build() val queryParams = params._queryParams() assertThat(queryParams) - .isEqualTo(QueryParams.builder().put("page", "1").put("page_size", "1").build()) + .isEqualTo( + QueryParams.builder() + .put("page", "1") + .put("page_size", "1") + .put("sort_by", "created_at") + .put("sort_order", "asc") + .build() + ) } @Test diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/InboxListInvoicesParamsTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/InboxListInvoicesParamsTest.kt index a50637f..9533902 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/InboxListInvoicesParamsTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/InboxListInvoicesParamsTest.kt @@ -10,17 +10,35 @@ internal class InboxListInvoicesParamsTest { @Test fun create() { - InboxListInvoicesParams.builder().page(1L).pageSize(1L).build() + InboxListInvoicesParams.builder() + .page(1L) + .pageSize(1L) + .sortBy(InboxListInvoicesParams.SortBy.CREATED_AT) + .sortOrder(InboxListInvoicesParams.SortOrder.ASC) + .build() } @Test fun queryParams() { - val params = InboxListInvoicesParams.builder().page(1L).pageSize(1L).build() + val params = + InboxListInvoicesParams.builder() + .page(1L) + .pageSize(1L) + .sortBy(InboxListInvoicesParams.SortBy.CREATED_AT) + .sortOrder(InboxListInvoicesParams.SortOrder.ASC) + .build() val queryParams = params._queryParams() assertThat(queryParams) - .isEqualTo(QueryParams.builder().put("page", "1").put("page_size", "1").build()) + .isEqualTo( + QueryParams.builder() + .put("page", "1") + .put("page_size", "1") + .put("sort_by", "created_at") + .put("sort_order", "asc") + .build() + ) } @Test diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/InboxListParamsTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/InboxListParamsTest.kt index 82caeb7..54fd6fc 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/InboxListParamsTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/InboxListParamsTest.kt @@ -19,6 +19,8 @@ internal class InboxListParamsTest { .pageSize(1L) .search("search") .sender("sender") + .sortBy(InboxListParams.SortBy.CREATED_AT) + .sortOrder(InboxListParams.SortOrder.ASC) .state(DocumentState.DRAFT) .type(DocumentType.INVOICE) .build() @@ -34,6 +36,8 @@ internal class InboxListParamsTest { .pageSize(1L) .search("search") .sender("sender") + .sortBy(InboxListParams.SortBy.CREATED_AT) + .sortOrder(InboxListParams.SortOrder.ASC) .state(DocumentState.DRAFT) .type(DocumentType.INVOICE) .build() @@ -49,6 +53,8 @@ internal class InboxListParamsTest { .put("page_size", "1") .put("search", "search") .put("sender", "sender") + .put("sort_by", "created_at") + .put("sort_order", "asc") .put("state", "DRAFT") .put("type", "INVOICE") .build() diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt index 89ac0d1..c19e79e 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt @@ -22,6 +22,7 @@ internal class PaginatedDocumentResponseTest { fun create() { val paginatedDocumentResponse = PaginatedDocumentResponse.builder() + .hasNextPage(true) .addItem( DocumentResponse.builder() .id("id") @@ -154,6 +155,7 @@ internal class PaginatedDocumentResponseTest { .total(0L) .build() + assertThat(paginatedDocumentResponse.hasNextPage()).isEqualTo(true) assertThat(paginatedDocumentResponse.items()) .containsExactly( DocumentResponse.builder() @@ -289,6 +291,7 @@ internal class PaginatedDocumentResponseTest { val jsonMapper = jsonMapper() val paginatedDocumentResponse = PaginatedDocumentResponse.builder() + .hasNextPage(true) .addItem( DocumentResponse.builder() .id("id") diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/outbox/OutboxListDraftDocumentsParamsTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/outbox/OutboxListDraftDocumentsParamsTest.kt index df4033e..45b6567 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/outbox/OutboxListDraftDocumentsParamsTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/outbox/OutboxListDraftDocumentsParamsTest.kt @@ -3,6 +3,8 @@ package com.e_invoice.api.models.outbox import com.e_invoice.api.core.http.QueryParams +import com.e_invoice.api.models.documents.DocumentType +import com.e_invoice.api.models.inbox.DocumentState import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -10,17 +12,44 @@ internal class OutboxListDraftDocumentsParamsTest { @Test fun create() { - OutboxListDraftDocumentsParams.builder().page(1L).pageSize(1L).build() + OutboxListDraftDocumentsParams.builder() + .page(1L) + .pageSize(1L) + .search("search") + .sortBy(OutboxListDraftDocumentsParams.SortBy.CREATED_AT) + .sortOrder(OutboxListDraftDocumentsParams.SortOrder.ASC) + .state(DocumentState.DRAFT) + .type(DocumentType.INVOICE) + .build() } @Test fun queryParams() { - val params = OutboxListDraftDocumentsParams.builder().page(1L).pageSize(1L).build() + val params = + OutboxListDraftDocumentsParams.builder() + .page(1L) + .pageSize(1L) + .search("search") + .sortBy(OutboxListDraftDocumentsParams.SortBy.CREATED_AT) + .sortOrder(OutboxListDraftDocumentsParams.SortOrder.ASC) + .state(DocumentState.DRAFT) + .type(DocumentType.INVOICE) + .build() val queryParams = params._queryParams() assertThat(queryParams) - .isEqualTo(QueryParams.builder().put("page", "1").put("page_size", "1").build()) + .isEqualTo( + QueryParams.builder() + .put("page", "1") + .put("page_size", "1") + .put("search", "search") + .put("sort_by", "created_at") + .put("sort_order", "asc") + .put("state", "DRAFT") + .put("type", "INVOICE") + .build() + ) } @Test diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/outbox/OutboxListReceivedDocumentsParamsTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/outbox/OutboxListReceivedDocumentsParamsTest.kt index 0148e9f..6d353c8 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/outbox/OutboxListReceivedDocumentsParamsTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/outbox/OutboxListReceivedDocumentsParamsTest.kt @@ -18,8 +18,11 @@ internal class OutboxListReceivedDocumentsParamsTest { .dateTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .page(1L) .pageSize(1L) + .receiver("receiver") .search("search") .sender("sender") + .sortBy(OutboxListReceivedDocumentsParams.SortBy.CREATED_AT) + .sortOrder(OutboxListReceivedDocumentsParams.SortOrder.ASC) .state(DocumentState.DRAFT) .type(DocumentType.INVOICE) .build() @@ -33,8 +36,11 @@ internal class OutboxListReceivedDocumentsParamsTest { .dateTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .page(1L) .pageSize(1L) + .receiver("receiver") .search("search") .sender("sender") + .sortBy(OutboxListReceivedDocumentsParams.SortBy.CREATED_AT) + .sortOrder(OutboxListReceivedDocumentsParams.SortOrder.ASC) .state(DocumentState.DRAFT) .type(DocumentType.INVOICE) .build() @@ -48,8 +54,11 @@ internal class OutboxListReceivedDocumentsParamsTest { .put("date_to", "2019-12-27T18:11:19.117Z") .put("page", "1") .put("page_size", "1") + .put("receiver", "receiver") .put("search", "search") .put("sender", "sender") + .put("sort_by", "created_at") + .put("sort_order", "asc") .put("state", "DRAFT") .put("type", "INVOICE") .build() From 6c5b4313f318f8c7e7a99cade9644bbb2103be72 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 16 Jan 2026 03:24:25 +0000 Subject: [PATCH 25/43] chore(internal): codegen related update --- scripts/upload-artifacts | 44 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/scripts/upload-artifacts b/scripts/upload-artifacts index 729e6f2..df0c8d9 100755 --- a/scripts/upload-artifacts +++ b/scripts/upload-artifacts @@ -7,6 +7,8 @@ GREEN='\033[32m' RED='\033[31m' NC='\033[0m' # No Color +MAVEN_REPO_PATH="./build/local-maven-repo" + log_error() { local msg="$1" local headers="$2" @@ -24,7 +26,7 @@ upload_file() { if [ -f "$file_name" ]; then echo -e "${GREEN}Processing file: $file_name${NC}" - pkg_file_name="mvn${file_name#./build/local-maven-repo}" + pkg_file_name="mvn${file_name#"${MAVEN_REPO_PATH}"}" # Get signed URL for uploading artifact file signed_url_response=$(curl -X POST -G "$URL" \ @@ -47,6 +49,7 @@ upload_file() { md5|sha1|sha256|sha512) content_type="text/plain" ;; module) content_type="application/json" ;; pom|xml) content_type="application/xml" ;; + html) content_type="text/html" ;; *) content_type="application/octet-stream" ;; esac @@ -81,6 +84,41 @@ walk_tree() { done } +generate_instructions() { + cat << EOF > "$MAVEN_REPO_PATH/index.html" + + + + Maven Repo + + +

Stainless SDK Maven Repository

+

This is the Maven repository for your Stainless Java SDK build.

+ +

Directions

+

To use the uploaded Maven repository, add the following to your project's pom.xml:

+
<repositories>
+    <repository>
+        <id>stainless-sdk-repo</id>
+        <url>https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn</url>
+    </repository>
+</repositories>
+ +

If you're using Gradle, add the following to your build.gradle file:

+
repositories {
+    maven {
+        url 'https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn'
+    }
+}
+ + +EOF + upload_file "${MAVEN_REPO_PATH}/index.html" + + echo "Configure maven or gradle to use the repo located at 'https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn'" + echo "For more details, see the directions in https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn/index.html" +} + cd "$(dirname "$0")/.." echo "::group::Creating local Maven content" @@ -88,9 +126,9 @@ echo "::group::Creating local Maven content" echo "::endgroup::" echo "::group::Uploading to pkg.stainless.com" -walk_tree "./build/local-maven-repo" +walk_tree "$MAVEN_REPO_PATH" echo "::endgroup::" echo "::group::Generating instructions" -echo "Configure maven or gradle to use the repo located at 'https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn'" +generate_instructions echo "::endgroup::" From 34d3b2519e014679f33b0e66e807b13134c12741 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 17 Jan 2026 03:45:21 +0000 Subject: [PATCH 26/43] chore(internal): codegen related update --- .github/workflows/ci.yml | 12 +- .github/workflows/publish-sonatype.yml | 4 +- .github/workflows/release-doctor.yml | 2 +- README.md | 2 + .../api/client/okhttp/OkHttpClient.kt | 2 + e-invoice-java-core/build.gradle.kts | 18 +- .../com/e_invoice/api/core/ObjectMappers.kt | 34 ++- .../api/core/http/RetryingHttpClient.kt | 20 +- .../api/models/documents/DocumentCreate.kt | 224 +++++++++--------- .../e_invoice/api/core/ObjectMappersTest.kt | 20 +- e-invoice-java-proguard-test/build.gradle.kts | 2 +- scripts/upload-artifacts | 7 +- 12 files changed, 178 insertions(+), 169 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e832cac..1b93074 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,10 +20,10 @@ jobs: if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up Java - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: distribution: temurin java-version: | @@ -47,10 +47,10 @@ jobs: if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up Java - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: distribution: temurin java-version: | @@ -85,10 +85,10 @@ jobs: runs-on: ${{ github.repository == 'stainless-sdks/e-invoice-api-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up Java - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: distribution: temurin java-version: | diff --git a/.github/workflows/publish-sonatype.yml b/.github/workflows/publish-sonatype.yml index c498ce6..8e5483e 100644 --- a/.github/workflows/publish-sonatype.yml +++ b/.github/workflows/publish-sonatype.yml @@ -14,10 +14,10 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up Java - uses: actions/setup-java@v4 + uses: actions/setup-java@v5 with: distribution: temurin java-version: | diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml index 4c260b7..6a059b2 100644 --- a/.github/workflows/release-doctor.yml +++ b/.github/workflows/release-doctor.yml @@ -12,7 +12,7 @@ jobs: if: github.repository == 'e-invoice-be/e-invoice-java' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Check release environment run: | diff --git a/README.md b/README.md index 874b5c1..b1a6e93 100644 --- a/README.md +++ b/README.md @@ -433,6 +433,8 @@ If the SDK threw an exception, but you're _certain_ the version is compatible, t > [!CAUTION] > We make no guarantee that the SDK works correctly when the Jackson version check is disabled. +Also note that there are bugs in older Jackson versions that can affect the SDK. We don't work around all Jackson bugs ([example](https://github.com/FasterXML/jackson-databind/issues/3240)) and expect users to upgrade Jackson for those instead. + ## Network options ### Retries diff --git a/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/OkHttpClient.kt b/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/OkHttpClient.kt index 35098a6..9d16508 100644 --- a/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/OkHttpClient.kt +++ b/e-invoice-java-client-okhttp/src/main/kotlin/com/e_invoice/api/client/okhttp/OkHttpClient.kt @@ -230,6 +230,8 @@ private constructor(@JvmSynthetic internal val okHttpClient: okhttp3.OkHttpClien fun build(): OkHttpClient = OkHttpClient( okhttp3.OkHttpClient.Builder() + // `RetryingHttpClient` handles retries if the user enabled them. + .retryOnConnectionFailure(false) .connectTimeout(timeout.connect()) .readTimeout(timeout.read()) .writeTimeout(timeout.write()) diff --git a/e-invoice-java-core/build.gradle.kts b/e-invoice-java-core/build.gradle.kts index 50c3534..b8c6afb 100644 --- a/e-invoice-java-core/build.gradle.kts +++ b/e-invoice-java-core/build.gradle.kts @@ -5,14 +5,16 @@ plugins { configurations.all { resolutionStrategy { - // Compile and test against a lower Jackson version to ensure we're compatible with it. - // We publish with a higher version (see below) to ensure users depend on a secure version by default. - force("com.fasterxml.jackson.core:jackson-core:2.13.4") - force("com.fasterxml.jackson.core:jackson-databind:2.13.4") - force("com.fasterxml.jackson.core:jackson-annotations:2.13.4") - force("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.13.4") - force("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.4") - force("com.fasterxml.jackson.module:jackson-module-kotlin:2.13.4") + // Compile and test against a lower Jackson version to ensure we're compatible with it. Note that + // we generally support 2.13.4, but test against 2.14.0 because 2.13.4 has some annoying (but + // niche) bugs (users should upgrade if they encounter them). We publish with a higher version + // (see below) to ensure users depend on a secure version by default. + force("com.fasterxml.jackson.core:jackson-core:2.14.0") + force("com.fasterxml.jackson.core:jackson-databind:2.14.0") + force("com.fasterxml.jackson.core:jackson-annotations:2.14.0") + force("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.14.0") + force("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.14.0") + force("com.fasterxml.jackson.module:jackson-module-kotlin:2.14.0") } } diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/ObjectMappers.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/ObjectMappers.kt index 50e9584..6258886 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/ObjectMappers.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/ObjectMappers.kt @@ -24,6 +24,7 @@ import java.io.InputStream import java.time.DateTimeException import java.time.LocalDate import java.time.LocalDateTime +import java.time.OffsetDateTime import java.time.ZonedDateTime import java.time.format.DateTimeFormatter import java.time.temporal.ChronoField @@ -36,7 +37,7 @@ fun jsonMapper(): JsonMapper = .addModule( SimpleModule() .addSerializer(InputStreamSerializer) - .addDeserializer(LocalDateTime::class.java, LenientLocalDateTimeDeserializer()) + .addDeserializer(OffsetDateTime::class.java, LenientOffsetDateTimeDeserializer()) ) .withCoercionConfig(LogicalType.Boolean) { it.setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) @@ -47,6 +48,7 @@ fun jsonMapper(): JsonMapper = } .withCoercionConfig(LogicalType.Integer) { it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) .setCoercion(CoercionInputShape.String, CoercionAction.Fail) .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) @@ -64,6 +66,12 @@ fun jsonMapper(): JsonMapper = .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) } + .withCoercionConfig(LogicalType.DateTime) { + it.setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Float, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Array, CoercionAction.Fail) + .setCoercion(CoercionInputShape.Object, CoercionAction.Fail) + } .withCoercionConfig(LogicalType.Array) { it.setCoercion(CoercionInputShape.Boolean, CoercionAction.Fail) .setCoercion(CoercionInputShape.Integer, CoercionAction.Fail) @@ -124,10 +132,10 @@ private object InputStreamSerializer : BaseSerializer(InputStream:: } /** - * A deserializer that can deserialize [LocalDateTime] from datetimes, dates, and zoned datetimes. + * A deserializer that can deserialize [OffsetDateTime] from datetimes, dates, and zoned datetimes. */ -private class LenientLocalDateTimeDeserializer : - StdDeserializer(LocalDateTime::class.java) { +private class LenientOffsetDateTimeDeserializer : + StdDeserializer(OffsetDateTime::class.java) { companion object { @@ -141,7 +149,7 @@ private class LenientLocalDateTimeDeserializer : override fun logicalType(): LogicalType = LogicalType.DateTime - override fun deserialize(p: JsonParser, context: DeserializationContext?): LocalDateTime { + override fun deserialize(p: JsonParser, context: DeserializationContext): OffsetDateTime { val exceptions = mutableListOf() for (formatter in DATE_TIME_FORMATTERS) { @@ -149,18 +157,20 @@ private class LenientLocalDateTimeDeserializer : val temporal = formatter.parse(p.text) return when { - !temporal.isSupported(ChronoField.HOUR_OF_DAY) -> - LocalDate.from(temporal).atStartOfDay() - !temporal.isSupported(ChronoField.OFFSET_SECONDS) -> - LocalDateTime.from(temporal) - else -> ZonedDateTime.from(temporal).toLocalDateTime() - } + !temporal.isSupported(ChronoField.HOUR_OF_DAY) -> + LocalDate.from(temporal).atStartOfDay() + !temporal.isSupported(ChronoField.OFFSET_SECONDS) -> + LocalDateTime.from(temporal) + else -> ZonedDateTime.from(temporal).toLocalDateTime() + } + .atZone(context.timeZone.toZoneId()) + .toOffsetDateTime() } catch (e: DateTimeException) { exceptions.add(e) } } - throw JsonParseException(p, "Cannot parse `LocalDateTime` from value: ${p.text}").apply { + throw JsonParseException(p, "Cannot parse `OffsetDateTime` from value: ${p.text}").apply { exceptions.forEach { addSuppressed(it) } } } diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/http/RetryingHttpClient.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/http/RetryingHttpClient.kt index be62ba9..db2fef5 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/http/RetryingHttpClient.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/http/RetryingHttpClient.kt @@ -31,10 +31,6 @@ private constructor( ) : HttpClient { override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { - if (!isRetryable(request) || maxRetries <= 0) { - return httpClient.execute(request, requestOptions) - } - var modifiedRequest = maybeAddIdempotencyHeader(request) // Don't send the current retry count in the headers if the caller set their own value. @@ -48,6 +44,10 @@ private constructor( modifiedRequest = setRetryCountHeader(modifiedRequest, retries) } + if (!isRetryable(modifiedRequest)) { + return httpClient.execute(modifiedRequest, requestOptions) + } + val response = try { val response = httpClient.execute(modifiedRequest, requestOptions) @@ -75,10 +75,6 @@ private constructor( request: HttpRequest, requestOptions: RequestOptions, ): CompletableFuture { - if (!isRetryable(request) || maxRetries <= 0) { - return httpClient.executeAsync(request, requestOptions) - } - val modifiedRequest = maybeAddIdempotencyHeader(request) // Don't send the current retry count in the headers if the caller set their own value. @@ -94,8 +90,12 @@ private constructor( val requestWithRetryCount = if (shouldSendRetryCount) setRetryCountHeader(request, retries) else request - return httpClient - .executeAsync(requestWithRetryCount, requestOptions) + val responseFuture = httpClient.executeAsync(requestWithRetryCount, requestOptions) + if (!isRetryable(requestWithRetryCount)) { + return responseFuture + } + + return responseFuture .handleAsync( fun( response: HttpResponse?, diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt index 14cbd5a..a713762 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreate.kt @@ -2918,19 +2918,19 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Amount(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { Amount(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Amount(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from object). + // with all the possible variants (e.g. deserializing from boolean). 0 -> Amount(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the @@ -3092,19 +3092,19 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - BaseAmount(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { BaseAmount(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + BaseAmount(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from object). + // with all the possible variants (e.g. deserializing from boolean). 0 -> BaseAmount(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the @@ -3268,19 +3268,19 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - MultiplierFactor(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { MultiplierFactor(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + MultiplierFactor(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from object). + // with all the possible variants (e.g. deserializing from boolean). 0 -> MultiplierFactor(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the @@ -3855,19 +3855,19 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - TaxRate(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { TaxRate(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + TaxRate(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from object). + // with all the possible variants (e.g. deserializing from boolean). 0 -> TaxRate(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the @@ -4060,19 +4060,19 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - AmountDue(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { AmountDue(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + AmountDue(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> AmountDue(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -4660,19 +4660,19 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Amount(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { Amount(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Amount(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from object). + // with all the possible variants (e.g. deserializing from boolean). 0 -> Amount(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the @@ -4834,19 +4834,19 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - BaseAmount(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { BaseAmount(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + BaseAmount(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from object). + // with all the possible variants (e.g. deserializing from boolean). 0 -> BaseAmount(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the @@ -5009,19 +5009,19 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - MultiplierFactor(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { MultiplierFactor(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + MultiplierFactor(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from object). + // with all the possible variants (e.g. deserializing from boolean). 0 -> MultiplierFactor(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the @@ -6551,19 +6551,19 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - TaxRate(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { TaxRate(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + TaxRate(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from object). + // with all the possible variants (e.g. deserializing from boolean). 0 -> TaxRate(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the @@ -6760,19 +6760,19 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - InvoiceTotal(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { InvoiceTotal(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + InvoiceTotal(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> InvoiceTotal(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -7998,12 +7998,12 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Amount(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { Amount(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Amount(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -8011,7 +8011,7 @@ private constructor( return when (bestMatches.size) { // This can happen if what we're deserializing is completely // incompatible with all the possible variants (e.g. deserializing from - // object). + // boolean). 0 -> Amount(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use @@ -8173,12 +8173,12 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - BaseAmount(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { BaseAmount(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + BaseAmount(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -8186,7 +8186,7 @@ private constructor( return when (bestMatches.size) { // This can happen if what we're deserializing is completely // incompatible with all the possible variants (e.g. deserializing from - // object). + // boolean). 0 -> BaseAmount(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use @@ -8352,12 +8352,12 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - MultiplierFactor(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { MultiplierFactor(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + MultiplierFactor(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -8365,7 +8365,7 @@ private constructor( return when (bestMatches.size) { // This can happen if what we're deserializing is completely // incompatible with all the possible variants (e.g. deserializing from - // object). + // boolean). 0 -> MultiplierFactor(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use @@ -8943,12 +8943,12 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - TaxRate(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { TaxRate(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + TaxRate(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -8956,7 +8956,7 @@ private constructor( return when (bestMatches.size) { // This can happen if what we're deserializing is completely // incompatible with all the possible variants (e.g. deserializing from - // object). + // boolean). 0 -> TaxRate(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use @@ -9154,19 +9154,19 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Amount(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { Amount(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Amount(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from object). + // with all the possible variants (e.g. deserializing from boolean). 0 -> Amount(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the @@ -9775,12 +9775,12 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Amount(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { Amount(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Amount(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -9788,7 +9788,7 @@ private constructor( return when (bestMatches.size) { // This can happen if what we're deserializing is completely // incompatible with all the possible variants (e.g. deserializing from - // object). + // boolean). 0 -> Amount(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use @@ -9950,12 +9950,12 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - BaseAmount(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { BaseAmount(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + BaseAmount(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -9963,7 +9963,7 @@ private constructor( return when (bestMatches.size) { // This can happen if what we're deserializing is completely // incompatible with all the possible variants (e.g. deserializing from - // object). + // boolean). 0 -> BaseAmount(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use @@ -10128,12 +10128,12 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - MultiplierFactor(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { MultiplierFactor(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + MultiplierFactor(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -10141,7 +10141,7 @@ private constructor( return when (bestMatches.size) { // This can happen if what we're deserializing is completely // incompatible with all the possible variants (e.g. deserializing from - // object). + // boolean). 0 -> MultiplierFactor(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use @@ -11674,12 +11674,12 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - TaxRate(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { TaxRate(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + TaxRate(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -11687,7 +11687,7 @@ private constructor( return when (bestMatches.size) { // This can happen if what we're deserializing is completely // incompatible with all the possible variants (e.g. deserializing from - // object). + // boolean). 0 -> TaxRate(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use @@ -11884,19 +11884,19 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Quantity(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { Quantity(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Quantity(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from object). + // with all the possible variants (e.g. deserializing from boolean). 0 -> Quantity(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the @@ -12057,19 +12057,19 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Tax(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { Tax(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Tax(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from object). + // with all the possible variants (e.g. deserializing from boolean). 0 -> Tax(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the @@ -12228,19 +12228,19 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - TaxRate(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { TaxRate(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + TaxRate(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from object). + // with all the possible variants (e.g. deserializing from boolean). 0 -> TaxRate(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the @@ -12402,19 +12402,19 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - UnitPrice(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { UnitPrice(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + UnitPrice(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from object). + // with all the possible variants (e.g. deserializing from boolean). 0 -> UnitPrice(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the @@ -12622,19 +12622,19 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - PreviousUnpaidBalance(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { PreviousUnpaidBalance(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + PreviousUnpaidBalance(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> PreviousUnpaidBalance(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -12797,19 +12797,19 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Subtotal(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { Subtotal(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Subtotal(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> Subtotal(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -13315,19 +13315,19 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Amount(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { Amount(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + Amount(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from object). + // with all the possible variants (e.g. deserializing from boolean). 0 -> Amount(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the @@ -13509,19 +13509,19 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - TotalDiscount(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { TotalDiscount(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + TotalDiscount(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> TotalDiscount(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first @@ -13679,19 +13679,19 @@ private constructor( val bestMatches = sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - TotalTax(number = it, _json = json) - }, tryDeserialize(node, jacksonTypeRef())?.let { TotalTax(string = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + TotalTax(number = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } .toList() return when (bestMatches.size) { // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from object). + // all the possible variants (e.g. deserializing from boolean). 0 -> TotalTax(_json = json) 1 -> bestMatches.single() // If there's more than one match with the highest validity, then use the first diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/core/ObjectMappersTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/core/ObjectMappersTest.kt index 7cb2251..b222b4a 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/core/ObjectMappersTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/core/ObjectMappersTest.kt @@ -3,7 +3,7 @@ package com.e_invoice.api.core import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.exc.MismatchedInputException import com.fasterxml.jackson.module.kotlin.readValue -import java.time.LocalDateTime +import java.time.OffsetDateTime import kotlin.reflect.KClass import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.catchThrowable @@ -46,11 +46,7 @@ internal class ObjectMappersTest { val VALID_CONVERSIONS = listOf( FLOAT to DOUBLE, - FLOAT to INTEGER, - FLOAT to LONG, DOUBLE to FLOAT, - DOUBLE to INTEGER, - DOUBLE to LONG, INTEGER to FLOAT, INTEGER to DOUBLE, INTEGER to LONG, @@ -58,14 +54,6 @@ internal class ObjectMappersTest { LONG to DOUBLE, LONG to INTEGER, CLASS to MAP, - // These aren't actually valid, but coercion configs don't work for String until - // v2.14.0: https://github.com/FasterXML/jackson-databind/issues/3240 - // We currently test on v2.13.4. - BOOLEAN to STRING, - FLOAT to STRING, - DOUBLE to STRING, - INTEGER to STRING, - LONG to STRING, ) } } @@ -84,7 +72,7 @@ internal class ObjectMappersTest { } } - enum class LenientLocalDateTimeTestCase(val string: String) { + enum class LenientOffsetDateTimeTestCase(val string: String) { DATE("1998-04-21"), DATE_TIME("1998-04-21T04:00:00"), ZONED_DATE_TIME_1("1998-04-21T04:00:00+03:00"), @@ -93,10 +81,10 @@ internal class ObjectMappersTest { @ParameterizedTest @EnumSource - fun readLocalDateTime_lenient(testCase: LenientLocalDateTimeTestCase) { + fun readOffsetDateTime_lenient(testCase: LenientOffsetDateTimeTestCase) { val jsonMapper = jsonMapper() val json = jsonMapper.writeValueAsString(testCase.string) - assertDoesNotThrow { jsonMapper().readValue(json) } + assertDoesNotThrow { jsonMapper().readValue(json) } } } diff --git a/e-invoice-java-proguard-test/build.gradle.kts b/e-invoice-java-proguard-test/build.gradle.kts index 3bd9779..e682b62 100644 --- a/e-invoice-java-proguard-test/build.gradle.kts +++ b/e-invoice-java-proguard-test/build.gradle.kts @@ -19,7 +19,7 @@ dependencies { testImplementation(kotlin("test")) testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") testImplementation("org.assertj:assertj-core:3.25.3") - testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.13.4") + testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.14.0") } tasks.shadowJar { diff --git a/scripts/upload-artifacts b/scripts/upload-artifacts index df0c8d9..548d152 100755 --- a/scripts/upload-artifacts +++ b/scripts/upload-artifacts @@ -56,12 +56,13 @@ upload_file() { # Upload file upload_response=$(curl -v -X PUT \ --retry 5 \ + --retry-all-errors \ -D "$tmp_headers" \ -H "Content-Type: $content_type" \ --data-binary "@${file_name}" "$signed_url" 2>&1) if ! echo "$upload_response" | grep -q "HTTP/[0-9.]* 200"; then - log_error "Failed upload artifact file" "$tmp_headers" "$upload_response" + log_error "Failed to upload artifact file" "$tmp_headers" "$upload_response" fi # Insert small throttle to reduce rate limiting risk @@ -110,6 +111,10 @@ generate_instructions() { url 'https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn' } } + +

Once you've added the repository, you can include dependencies from it as usual. See your + project README + for more details.

EOF From 5c0871400561a727de59401802a44d4722e6a09a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 19 Jan 2026 15:13:55 +0000 Subject: [PATCH 27/43] feat(api): api update --- .stats.yml | 4 +- .../api/models/documents/DocumentResponse.kt | 43 ++++++- .../attachments/AttachmentAddParams.kt | 4 +- .../models/lookup/LookupRetrieveResponse.kt | 107 +++++++++++++++++- .../async/documents/AttachmentServiceAsync.kt | 5 +- .../blocking/documents/AttachmentService.kt | 5 +- .../models/documents/DocumentResponseTest.kt | 5 + .../inbox/PaginatedDocumentResponseTest.kt | 4 + .../lookup/LookupRetrieveResponseTest.kt | 18 ++- 9 files changed, 177 insertions(+), 18 deletions(-) diff --git a/.stats.yml b/.stats.yml index 57cbc8b..d47f28c 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-48678c6950d97996112c09651dc22fb6c1cfb2781c273c1869a3c4ac5a5982de.yml -openapi_spec_hash: d3b789cbfa46761ca437bcc7f91f6640 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-f11d671d8a4664bdfd3a2348e5424189f8d186933cc96c1a7c7dbef3f2b54308.yml +openapi_spec_hash: 39611aee5b72e96b816a257ba0ef6ccb config_hash: 852a0117abb3db077933876ad1185f41 diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt index 332b8da..ee70256 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentResponse.kt @@ -18,6 +18,7 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import java.time.LocalDate +import java.time.OffsetDateTime import java.util.Collections import java.util.Objects import java.util.Optional @@ -27,6 +28,7 @@ class DocumentResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val id: JsonField, + private val createdAt: JsonField, private val allowances: JsonField>, private val amountDue: JsonField, private val attachments: JsonField>, @@ -80,6 +82,9 @@ private constructor( @JsonCreator private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), @JsonProperty("allowances") @ExcludeMissing allowances: JsonField> = JsonMissing.of(), @@ -201,6 +206,7 @@ private constructor( vendorTaxId: JsonField = JsonMissing.of(), ) : this( id, + createdAt, allowances, amountDue, attachments, @@ -257,6 +263,12 @@ private constructor( */ fun id(): String = id.getRequired("id") + /** + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun createdAt(): OffsetDateTime = createdAt.getRequired("created_at") + /** * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -644,6 +656,15 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + /** + * Returns the raw JSON value of [createdAt]. + * + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt + /** * Returns the raw JSON value of [allowances]. * @@ -1066,6 +1087,7 @@ private constructor( * The following fields are required: * ```java * .id() + * .createdAt() * ``` */ @JvmStatic fun builder() = Builder() @@ -1075,6 +1097,7 @@ private constructor( class Builder internal constructor() { private var id: JsonField? = null + private var createdAt: JsonField? = null private var allowances: JsonField>? = null private var amountDue: JsonField = JsonMissing.of() private var attachments: JsonField>? = null @@ -1127,6 +1150,7 @@ private constructor( @JvmSynthetic internal fun from(documentResponse: DocumentResponse) = apply { id = documentResponse.id + createdAt = documentResponse.createdAt allowances = documentResponse.allowances.map { it.toMutableList() } amountDue = documentResponse.amountDue attachments = documentResponse.attachments.map { it.toMutableList() } @@ -1187,6 +1211,17 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } + fun createdAt(createdAt: OffsetDateTime) = createdAt(JsonField.of(createdAt)) + + /** + * Sets [Builder.createdAt] to an arbitrary JSON value. + * + * You should usually call [Builder.createdAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } + fun allowances(allowances: List?) = allowances(JsonField.ofNullable(allowances)) /** Alias for calling [Builder.allowances] with `allowances.orElse(null)`. */ @@ -2113,6 +2148,7 @@ private constructor( * The following fields are required: * ```java * .id() + * .createdAt() * ``` * * @throws IllegalStateException if any required field is unset. @@ -2120,6 +2156,7 @@ private constructor( fun build(): DocumentResponse = DocumentResponse( checkRequired("id", id), + checkRequired("createdAt", createdAt), (allowances ?: JsonMissing.of()).map { it.toImmutable() }, amountDue, (attachments ?: JsonMissing.of()).map { it.toImmutable() }, @@ -2179,6 +2216,7 @@ private constructor( } id() + createdAt() allowances().ifPresent { it.forEach { it.validate() } } amountDue() attachments().ifPresent { it.forEach { it.validate() } } @@ -2245,6 +2283,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + (allowances.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (amountDue.asKnown().isPresent) 1 else 0) + (attachments.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + @@ -6725,6 +6764,7 @@ private constructor( return other is DocumentResponse && id == other.id && + createdAt == other.createdAt && allowances == other.allowances && amountDue == other.amountDue && attachments == other.attachments && @@ -6778,6 +6818,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( id, + createdAt, allowances, amountDue, attachments, @@ -6832,5 +6873,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "DocumentResponse{id=$id, allowances=$allowances, amountDue=$amountDue, attachments=$attachments, billingAddress=$billingAddress, billingAddressRecipient=$billingAddressRecipient, charges=$charges, currency=$currency, customerAddress=$customerAddress, customerAddressRecipient=$customerAddressRecipient, customerCompanyId=$customerCompanyId, customerEmail=$customerEmail, customerId=$customerId, customerName=$customerName, customerTaxId=$customerTaxId, direction=$direction, documentType=$documentType, dueDate=$dueDate, invoiceDate=$invoiceDate, invoiceId=$invoiceId, invoiceTotal=$invoiceTotal, items=$items, note=$note, paymentDetails=$paymentDetails, paymentTerm=$paymentTerm, purchaseOrder=$purchaseOrder, remittanceAddress=$remittanceAddress, remittanceAddressRecipient=$remittanceAddressRecipient, serviceAddress=$serviceAddress, serviceAddressRecipient=$serviceAddressRecipient, serviceEndDate=$serviceEndDate, serviceStartDate=$serviceStartDate, shippingAddress=$shippingAddress, shippingAddressRecipient=$shippingAddressRecipient, state=$state, subtotal=$subtotal, taxCode=$taxCode, taxDetails=$taxDetails, totalDiscount=$totalDiscount, totalTax=$totalTax, vatex=$vatex, vatexNote=$vatexNote, vendorAddress=$vendorAddress, vendorAddressRecipient=$vendorAddressRecipient, vendorCompanyId=$vendorCompanyId, vendorEmail=$vendorEmail, vendorName=$vendorName, vendorTaxId=$vendorTaxId, additionalProperties=$additionalProperties}" + "DocumentResponse{id=$id, createdAt=$createdAt, allowances=$allowances, amountDue=$amountDue, attachments=$attachments, billingAddress=$billingAddress, billingAddressRecipient=$billingAddressRecipient, charges=$charges, currency=$currency, customerAddress=$customerAddress, customerAddressRecipient=$customerAddressRecipient, customerCompanyId=$customerCompanyId, customerEmail=$customerEmail, customerId=$customerId, customerName=$customerName, customerTaxId=$customerTaxId, direction=$direction, documentType=$documentType, dueDate=$dueDate, invoiceDate=$invoiceDate, invoiceId=$invoiceId, invoiceTotal=$invoiceTotal, items=$items, note=$note, paymentDetails=$paymentDetails, paymentTerm=$paymentTerm, purchaseOrder=$purchaseOrder, remittanceAddress=$remittanceAddress, remittanceAddressRecipient=$remittanceAddressRecipient, serviceAddress=$serviceAddress, serviceAddressRecipient=$serviceAddressRecipient, serviceEndDate=$serviceEndDate, serviceStartDate=$serviceStartDate, shippingAddress=$shippingAddress, shippingAddressRecipient=$shippingAddressRecipient, state=$state, subtotal=$subtotal, taxCode=$taxCode, taxDetails=$taxDetails, totalDiscount=$totalDiscount, totalTax=$totalTax, vatex=$vatex, vatexNote=$vatexNote, vendorAddress=$vendorAddress, vendorAddressRecipient=$vendorAddressRecipient, vendorCompanyId=$vendorCompanyId, vendorEmail=$vendorEmail, vendorName=$vendorName, vendorTaxId=$vendorTaxId, additionalProperties=$additionalProperties}" } diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/attachments/AttachmentAddParams.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/attachments/AttachmentAddParams.kt index 5ab2774..b64d645 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/attachments/AttachmentAddParams.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/attachments/AttachmentAddParams.kt @@ -24,7 +24,9 @@ import kotlin.io.path.name import kotlin.jvm.optionals.getOrNull /** - * Add one or more attachments when creating a new invoice or credit note via POST /api/documents/ + * Add one or more attachments to an invoice. Be careful: the attachments ARE NOT ADDED to the UBL! + * They are only stored in our database and can be downloaded later. To add attachments to the UBL, + * you need to add the attachment(s) via POST /api/documents */ @Deprecated("deprecated") class AttachmentAddParams diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/lookup/LookupRetrieveResponse.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/lookup/LookupRetrieveResponse.kt index 0c9449a..91abeb9 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/lookup/LookupRetrieveResponse.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/lookup/LookupRetrieveResponse.kt @@ -1121,6 +1121,8 @@ private constructor( private val smlHostname: JsonField, private val status: JsonField, private val error: JsonField, + private val lookupMethod: JsonField, + private val smpHostname: JsonField, private val additionalProperties: MutableMap, ) { @@ -1134,7 +1136,13 @@ private constructor( smlHostname: JsonField = JsonMissing.of(), @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), @JsonProperty("error") @ExcludeMissing error: JsonField = JsonMissing.of(), - ) : this(dnsRecords, smlHostname, status, error, mutableMapOf()) + @JsonProperty("lookupMethod") + @ExcludeMissing + lookupMethod: JsonField = JsonMissing.of(), + @JsonProperty("smpHostname") + @ExcludeMissing + smpHostname: JsonField = JsonMissing.of(), + ) : this(dnsRecords, smlHostname, status, error, lookupMethod, smpHostname, mutableMapOf()) /** * List of DNS records found for the Peppol participant @@ -1168,6 +1176,22 @@ private constructor( */ fun error(): Optional = error.getOptional("error") + /** + * DNS lookup method used: 'naptr' (new spec) or 'busdox' (legacy) + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun lookupMethod(): Optional = lookupMethod.getOptional("lookupMethod") + + /** + * Hostname of the SMP (Service Metadata Publisher) discovered via DNS + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun smpHostname(): Optional = smpHostname.getOptional("smpHostname") + /** * Returns the raw JSON value of [dnsRecords]. * @@ -1200,6 +1224,25 @@ private constructor( */ @JsonProperty("error") @ExcludeMissing fun _error(): JsonField = error + /** + * Returns the raw JSON value of [lookupMethod]. + * + * Unlike [lookupMethod], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("lookupMethod") + @ExcludeMissing + fun _lookupMethod(): JsonField = lookupMethod + + /** + * Returns the raw JSON value of [smpHostname]. + * + * Unlike [smpHostname], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("smpHostname") + @ExcludeMissing + fun _smpHostname(): JsonField = smpHostname + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -1234,6 +1277,8 @@ private constructor( private var smlHostname: JsonField? = null private var status: JsonField? = null private var error: JsonField = JsonMissing.of() + private var lookupMethod: JsonField = JsonMissing.of() + private var smpHostname: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1242,6 +1287,8 @@ private constructor( smlHostname = dnsInfo.smlHostname status = dnsInfo.status error = dnsInfo.error + lookupMethod = dnsInfo.lookupMethod + smpHostname = dnsInfo.smpHostname additionalProperties = dnsInfo.additionalProperties.toMutableMap() } @@ -1312,6 +1359,42 @@ private constructor( */ fun error(error: JsonField) = apply { this.error = error } + /** DNS lookup method used: 'naptr' (new spec) or 'busdox' (legacy) */ + fun lookupMethod(lookupMethod: String?) = + lookupMethod(JsonField.ofNullable(lookupMethod)) + + /** Alias for calling [Builder.lookupMethod] with `lookupMethod.orElse(null)`. */ + fun lookupMethod(lookupMethod: Optional) = + lookupMethod(lookupMethod.getOrNull()) + + /** + * Sets [Builder.lookupMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.lookupMethod] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lookupMethod(lookupMethod: JsonField) = apply { + this.lookupMethod = lookupMethod + } + + /** Hostname of the SMP (Service Metadata Publisher) discovered via DNS */ + fun smpHostname(smpHostname: String?) = smpHostname(JsonField.ofNullable(smpHostname)) + + /** Alias for calling [Builder.smpHostname] with `smpHostname.orElse(null)`. */ + fun smpHostname(smpHostname: Optional) = smpHostname(smpHostname.getOrNull()) + + /** + * Sets [Builder.smpHostname] to an arbitrary JSON value. + * + * You should usually call [Builder.smpHostname] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun smpHostname(smpHostname: JsonField) = apply { + this.smpHostname = smpHostname + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1351,6 +1434,8 @@ private constructor( checkRequired("smlHostname", smlHostname), checkRequired("status", status), error, + lookupMethod, + smpHostname, additionalProperties.toMutableMap(), ) } @@ -1366,6 +1451,8 @@ private constructor( smlHostname() status() error() + lookupMethod() + smpHostname() validated = true } @@ -1388,7 +1475,9 @@ private constructor( (dnsRecords.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (smlHostname.asKnown().isPresent) 1 else 0) + (if (status.asKnown().isPresent) 1 else 0) + - (if (error.asKnown().isPresent) 1 else 0) + (if (error.asKnown().isPresent) 1 else 0) + + (if (lookupMethod.asKnown().isPresent) 1 else 0) + + (if (smpHostname.asKnown().isPresent) 1 else 0) /** DNS record information for a Peppol participant. */ class DnsRecord @@ -1561,17 +1650,27 @@ private constructor( smlHostname == other.smlHostname && status == other.status && error == other.error && + lookupMethod == other.lookupMethod && + smpHostname == other.smpHostname && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(dnsRecords, smlHostname, status, error, additionalProperties) + Objects.hash( + dnsRecords, + smlHostname, + status, + error, + lookupMethod, + smpHostname, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "DnsInfo{dnsRecords=$dnsRecords, smlHostname=$smlHostname, status=$status, error=$error, additionalProperties=$additionalProperties}" + "DnsInfo{dnsRecords=$dnsRecords, smlHostname=$smlHostname, status=$status, error=$error, lookupMethod=$lookupMethod, smpHostname=$smpHostname, additionalProperties=$additionalProperties}" } /** Metadata about the query that was performed */ diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/documents/AttachmentServiceAsync.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/documents/AttachmentServiceAsync.kt index 32a8561..710113d 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/documents/AttachmentServiceAsync.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/documents/AttachmentServiceAsync.kt @@ -116,8 +116,9 @@ interface AttachmentServiceAsync { ): CompletableFuture /** - * Add one or more attachments when creating a new invoice or credit note via POST - * /api/documents/ + * Add one or more attachments to an invoice. Be careful: the attachments ARE NOT ADDED to the + * UBL! They are only stored in our database and can be downloaded later. To add attachments to + * the UBL, you need to add the attachment(s) via POST /api/documents */ @Deprecated("deprecated") fun add( diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/documents/AttachmentService.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/documents/AttachmentService.kt index 1152751..6bd87a2 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/documents/AttachmentService.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/documents/AttachmentService.kt @@ -108,8 +108,9 @@ interface AttachmentService { ): AttachmentDeleteResponse /** - * Add one or more attachments when creating a new invoice or credit note via POST - * /api/documents/ + * Add one or more attachments to an invoice. Be careful: the attachments ARE NOT ADDED to the + * UBL! They are only stored in our database and can be downloaded later. To add attachments to + * the UBL, you need to add the attachment(s) via POST /api/documents */ @Deprecated("deprecated") fun add(documentId: String, params: AttachmentAddParams): DocumentAttachment = diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentResponseTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentResponseTest.kt index 38050f5..73740db 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentResponseTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentResponseTest.kt @@ -7,6 +7,7 @@ import com.e_invoice.api.models.documents.attachments.DocumentAttachment import com.e_invoice.api.models.inbox.DocumentState import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.time.LocalDate +import java.time.OffsetDateTime import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -18,6 +19,7 @@ internal class DocumentResponseTest { val documentResponse = DocumentResponse.builder() .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addAllowance( DocumentResponse.Allowance.builder() .amount("amount") @@ -139,6 +141,8 @@ internal class DocumentResponseTest { .build() assertThat(documentResponse.id()).isEqualTo("id") + assertThat(documentResponse.createdAt()) + .isEqualTo(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(documentResponse.allowances().getOrNull()) .containsExactly( DocumentResponse.Allowance.builder() @@ -274,6 +278,7 @@ internal class DocumentResponseTest { val documentResponse = DocumentResponse.builder() .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addAllowance( DocumentResponse.Allowance.builder() .amount("amount") diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt index c19e79e..a006f2e 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/PaginatedDocumentResponseTest.kt @@ -13,6 +13,7 @@ import com.e_invoice.api.models.documents.UnitOfMeasureCode import com.e_invoice.api.models.documents.attachments.DocumentAttachment import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import java.time.LocalDate +import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -26,6 +27,7 @@ internal class PaginatedDocumentResponseTest { .addItem( DocumentResponse.builder() .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addAllowance( DocumentResponse.Allowance.builder() .amount("amount") @@ -160,6 +162,7 @@ internal class PaginatedDocumentResponseTest { .containsExactly( DocumentResponse.builder() .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addAllowance( DocumentResponse.Allowance.builder() .amount("amount") @@ -295,6 +298,7 @@ internal class PaginatedDocumentResponseTest { .addItem( DocumentResponse.builder() .id("id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .addAllowance( DocumentResponse.Allowance.builder() .amount("amount") diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/lookup/LookupRetrieveResponseTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/lookup/LookupRetrieveResponseTest.kt index bc695d1..ab81f34 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/lookup/LookupRetrieveResponseTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/lookup/LookupRetrieveResponseTest.kt @@ -51,6 +51,8 @@ internal class LookupRetrieveResponseTest { .smlHostname("edelivery.tech.ec.europa.eu") .status("success") .error("DNS lookup failed: no such domain") + .lookupMethod("naptr") + .smpHostname("smp.e-invoice.be") .build() ) .addError("DNS lookup failed") @@ -59,9 +61,9 @@ internal class LookupRetrieveResponseTest { .queryMetadata( LookupRetrieveResponse.QueryMetadata.builder() .identifierScheme("iso6523-actorid-upis") - .identifierValue("0192:991825827") + .identifierValue("0208:1018265814") .smlDomain("edelivery.tech.ec.europa.eu") - .timestamp("2023-04-12T14:32:10.123456") + .timestamp("2026-01-12T14:32:10.123456") .version("1.0.0") .build() ) @@ -173,6 +175,8 @@ internal class LookupRetrieveResponseTest { .smlHostname("edelivery.tech.ec.europa.eu") .status("success") .error("DNS lookup failed: no such domain") + .lookupMethod("naptr") + .smpHostname("smp.e-invoice.be") .build() ) assertThat(lookupRetrieveResponse.errors()) @@ -182,9 +186,9 @@ internal class LookupRetrieveResponseTest { .isEqualTo( LookupRetrieveResponse.QueryMetadata.builder() .identifierScheme("iso6523-actorid-upis") - .identifierValue("0192:991825827") + .identifierValue("0208:1018265814") .smlDomain("edelivery.tech.ec.europa.eu") - .timestamp("2023-04-12T14:32:10.123456") + .timestamp("2026-01-12T14:32:10.123456") .version("1.0.0") .build() ) @@ -296,6 +300,8 @@ internal class LookupRetrieveResponseTest { .smlHostname("edelivery.tech.ec.europa.eu") .status("success") .error("DNS lookup failed: no such domain") + .lookupMethod("naptr") + .smpHostname("smp.e-invoice.be") .build() ) .addError("DNS lookup failed") @@ -304,9 +310,9 @@ internal class LookupRetrieveResponseTest { .queryMetadata( LookupRetrieveResponse.QueryMetadata.builder() .identifierScheme("iso6523-actorid-upis") - .identifierValue("0192:991825827") + .identifierValue("0208:1018265814") .smlDomain("edelivery.tech.ec.europa.eu") - .timestamp("2023-04-12T14:32:10.123456") + .timestamp("2026-01-12T14:32:10.123456") .version("1.0.0") .build() ) From 74c4c9e381b260df4545a7180365cf517a65b26f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 20 Jan 2026 10:13:54 +0000 Subject: [PATCH 28/43] feat(api): api update --- .stats.yml | 4 +- .../api/models/inbox/InboxListParams.kt | 8 +- .../api/models/me/MeRetrieveResponse.kt | 166 +++++++++--------- .../OutboxListReceivedDocumentsParams.kt | 8 +- .../api/models/me/MeRetrieveResponseTest.kt | 12 +- 5 files changed, 97 insertions(+), 101 deletions(-) diff --git a/.stats.yml b/.stats.yml index d47f28c..51690cf 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-f11d671d8a4664bdfd3a2348e5424189f8d186933cc96c1a7c7dbef3f2b54308.yml -openapi_spec_hash: 39611aee5b72e96b816a257ba0ef6ccb +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-8636c114cc033ac15d6da0b3232f790b6d3be8e93ab7fc0ba90eb17db2d04b63.yml +openapi_spec_hash: d01360d15f55e15f42ce0faf5d4c032d config_hash: 852a0117abb3db077933876ad1185f41 diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListParams.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListParams.kt index 6d8f748..6297954 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListParams.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListParams.kt @@ -60,10 +60,10 @@ private constructor( /** Sort direction (asc/desc) */ fun sortOrder(): Optional = Optional.ofNullable(sortOrder) - /** Filter by document state */ + /** Filter by document state. If not provided, returns all states. */ fun state(): Optional = Optional.ofNullable(state) - /** Filter by document type */ + /** Filter by document type. If not provided, returns all types. */ fun type(): Optional = Optional.ofNullable(type) /** Additional headers to send with the request. */ @@ -176,13 +176,13 @@ private constructor( /** Alias for calling [Builder.sortOrder] with `sortOrder.orElse(null)`. */ fun sortOrder(sortOrder: Optional) = sortOrder(sortOrder.getOrNull()) - /** Filter by document state */ + /** Filter by document state. If not provided, returns all states. */ fun state(state: DocumentState?) = apply { this.state = state } /** Alias for calling [Builder.state] with `state.orElse(null)`. */ fun state(state: Optional) = state(state.getOrNull()) - /** Filter by document type */ + /** Filter by document type. If not provided, returns all types. */ fun type(type: DocumentType?) = apply { this.type = type } /** Alias for calling [Builder.type] with `type.orElse(null)`. */ diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/me/MeRetrieveResponse.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/me/MeRetrieveResponse.kt index 68c57a4..91e13de 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/me/MeRetrieveResponse.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/me/MeRetrieveResponse.kt @@ -24,9 +24,7 @@ import kotlin.jvm.optionals.getOrNull class MeRetrieveResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val creditBalance: JsonField, private val name: JsonField, - private val plan: JsonField, private val bccRecipientEmail: JsonField, private val companyAddress: JsonField, private val companyCity: JsonField, @@ -36,9 +34,11 @@ private constructor( private val companyNumber: JsonField, private val companyTaxId: JsonField, private val companyZip: JsonField, + private val creditBalance: JsonField, private val description: JsonField, private val ibans: JsonField>, private val peppolIds: JsonField>, + private val plan: JsonField, private val smpRegistration: JsonField, private val smpRegistrationDate: JsonField, private val additionalProperties: MutableMap, @@ -46,11 +46,7 @@ private constructor( @JsonCreator private constructor( - @JsonProperty("credit_balance") - @ExcludeMissing - creditBalance: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("plan") @ExcludeMissing plan: JsonField = JsonMissing.of(), @JsonProperty("bcc_recipient_email") @ExcludeMissing bccRecipientEmail: JsonField = JsonMissing.of(), @@ -78,6 +74,9 @@ private constructor( @JsonProperty("company_zip") @ExcludeMissing companyZip: JsonField = JsonMissing.of(), + @JsonProperty("credit_balance") + @ExcludeMissing + creditBalance: JsonField = JsonMissing.of(), @JsonProperty("description") @ExcludeMissing description: JsonField = JsonMissing.of(), @@ -85,6 +84,7 @@ private constructor( @JsonProperty("peppol_ids") @ExcludeMissing peppolIds: JsonField> = JsonMissing.of(), + @JsonProperty("plan") @ExcludeMissing plan: JsonField = JsonMissing.of(), @JsonProperty("smp_registration") @ExcludeMissing smpRegistration: JsonField = JsonMissing.of(), @@ -92,9 +92,7 @@ private constructor( @ExcludeMissing smpRegistrationDate: JsonField = JsonMissing.of(), ) : this( - creditBalance, name, - plan, bccRecipientEmail, companyAddress, companyCity, @@ -104,36 +102,22 @@ private constructor( companyNumber, companyTaxId, companyZip, + creditBalance, description, ibans, peppolIds, + plan, smpRegistration, smpRegistrationDate, mutableMapOf(), ) - /** - * Credit balance of the tenant - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun creditBalance(): Long = creditBalance.getRequired("credit_balance") - /** * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ fun name(): String = name.getRequired("name") - /** - * Plan of the tenant - * - * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun plan(): Plan = plan.getRequired("plan") - /** * BCC recipient email to deliver documents * @@ -207,6 +191,14 @@ private constructor( */ fun companyZip(): Optional = companyZip.getOptional("company_zip") + /** + * Credit balance of the tenant + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun creditBalance(): Optional = creditBalance.getOptional("credit_balance") + /** * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -229,6 +221,14 @@ private constructor( */ fun peppolIds(): Optional> = peppolIds.getOptional("peppol_ids") + /** + * Plan of the tenant + * + * @throws EInvoiceInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun plan(): Optional = plan.getOptional("plan") + /** * Whether the tenant is registered on our SMP * @@ -246,15 +246,6 @@ private constructor( fun smpRegistrationDate(): Optional = smpRegistrationDate.getOptional("smp_registration_date") - /** - * Returns the raw JSON value of [creditBalance]. - * - * Unlike [creditBalance], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("credit_balance") - @ExcludeMissing - fun _creditBalance(): JsonField = creditBalance - /** * Returns the raw JSON value of [name]. * @@ -262,13 +253,6 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [plan]. - * - * Unlike [plan], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan - /** * Returns the raw JSON value of [bccRecipientEmail]. * @@ -349,6 +333,15 @@ private constructor( */ @JsonProperty("company_zip") @ExcludeMissing fun _companyZip(): JsonField = companyZip + /** + * Returns the raw JSON value of [creditBalance]. + * + * Unlike [creditBalance], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("credit_balance") + @ExcludeMissing + fun _creditBalance(): JsonField = creditBalance + /** * Returns the raw JSON value of [description]. * @@ -372,6 +365,13 @@ private constructor( @ExcludeMissing fun _peppolIds(): JsonField> = peppolIds + /** + * Returns the raw JSON value of [plan]. + * + * Unlike [plan], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan + /** * Returns the raw JSON value of [smpRegistration]. * @@ -410,9 +410,7 @@ private constructor( * * The following fields are required: * ```java - * .creditBalance() * .name() - * .plan() * ``` */ @JvmStatic fun builder() = Builder() @@ -421,9 +419,7 @@ private constructor( /** A builder for [MeRetrieveResponse]. */ class Builder internal constructor() { - private var creditBalance: JsonField? = null private var name: JsonField? = null - private var plan: JsonField? = null private var bccRecipientEmail: JsonField = JsonMissing.of() private var companyAddress: JsonField = JsonMissing.of() private var companyCity: JsonField = JsonMissing.of() @@ -433,18 +429,18 @@ private constructor( private var companyNumber: JsonField = JsonMissing.of() private var companyTaxId: JsonField = JsonMissing.of() private var companyZip: JsonField = JsonMissing.of() + private var creditBalance: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() private var ibans: JsonField>? = null private var peppolIds: JsonField>? = null + private var plan: JsonField = JsonMissing.of() private var smpRegistration: JsonField = JsonMissing.of() private var smpRegistrationDate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(meRetrieveResponse: MeRetrieveResponse) = apply { - creditBalance = meRetrieveResponse.creditBalance name = meRetrieveResponse.name - plan = meRetrieveResponse.plan bccRecipientEmail = meRetrieveResponse.bccRecipientEmail companyAddress = meRetrieveResponse.companyAddress companyCity = meRetrieveResponse.companyCity @@ -454,28 +450,16 @@ private constructor( companyNumber = meRetrieveResponse.companyNumber companyTaxId = meRetrieveResponse.companyTaxId companyZip = meRetrieveResponse.companyZip + creditBalance = meRetrieveResponse.creditBalance description = meRetrieveResponse.description ibans = meRetrieveResponse.ibans.map { it.toMutableList() } peppolIds = meRetrieveResponse.peppolIds.map { it.toMutableList() } + plan = meRetrieveResponse.plan smpRegistration = meRetrieveResponse.smpRegistration smpRegistrationDate = meRetrieveResponse.smpRegistrationDate additionalProperties = meRetrieveResponse.additionalProperties.toMutableMap() } - /** Credit balance of the tenant */ - fun creditBalance(creditBalance: Long) = creditBalance(JsonField.of(creditBalance)) - - /** - * Sets [Builder.creditBalance] to an arbitrary JSON value. - * - * You should usually call [Builder.creditBalance] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun creditBalance(creditBalance: JsonField) = apply { - this.creditBalance = creditBalance - } - fun name(name: String) = name(JsonField.of(name)) /** @@ -486,17 +470,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Plan of the tenant */ - fun plan(plan: Plan) = plan(JsonField.of(plan)) - - /** - * Sets [Builder.plan] to an arbitrary JSON value. - * - * You should usually call [Builder.plan] with a well-typed [Plan] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun plan(plan: JsonField) = apply { this.plan = plan } - /** BCC recipient email to deliver documents */ fun bccRecipientEmail(bccRecipientEmail: String?) = bccRecipientEmail(JsonField.ofNullable(bccRecipientEmail)) @@ -658,6 +631,20 @@ private constructor( */ fun companyZip(companyZip: JsonField) = apply { this.companyZip = companyZip } + /** Credit balance of the tenant */ + fun creditBalance(creditBalance: Long) = creditBalance(JsonField.of(creditBalance)) + + /** + * Sets [Builder.creditBalance] to an arbitrary JSON value. + * + * You should usually call [Builder.creditBalance] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun creditBalance(creditBalance: JsonField) = apply { + this.creditBalance = creditBalance + } + fun description(description: String?) = description(JsonField.ofNullable(description)) /** Alias for calling [Builder.description] with `description.orElse(null)`. */ @@ -728,6 +715,17 @@ private constructor( } } + /** Plan of the tenant */ + fun plan(plan: Plan) = plan(JsonField.of(plan)) + + /** + * Sets [Builder.plan] to an arbitrary JSON value. + * + * You should usually call [Builder.plan] with a well-typed [Plan] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun plan(plan: JsonField) = apply { this.plan = plan } + /** Whether the tenant is registered on our SMP */ fun smpRegistration(smpRegistration: Boolean?) = smpRegistration(JsonField.ofNullable(smpRegistration)) @@ -801,18 +799,14 @@ private constructor( * * The following fields are required: * ```java - * .creditBalance() * .name() - * .plan() * ``` * * @throws IllegalStateException if any required field is unset. */ fun build(): MeRetrieveResponse = MeRetrieveResponse( - checkRequired("creditBalance", creditBalance), checkRequired("name", name), - checkRequired("plan", plan), bccRecipientEmail, companyAddress, companyCity, @@ -822,9 +816,11 @@ private constructor( companyNumber, companyTaxId, companyZip, + creditBalance, description, (ibans ?: JsonMissing.of()).map { it.toImmutable() }, (peppolIds ?: JsonMissing.of()).map { it.toImmutable() }, + plan, smpRegistration, smpRegistrationDate, additionalProperties.toMutableMap(), @@ -838,9 +834,7 @@ private constructor( return@apply } - creditBalance() name() - plan().validate() bccRecipientEmail() companyAddress() companyCity() @@ -850,9 +844,11 @@ private constructor( companyNumber() companyTaxId() companyZip() + creditBalance() description() ibans() peppolIds() + plan().ifPresent { it.validate() } smpRegistration() smpRegistrationDate() validated = true @@ -873,9 +869,7 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (creditBalance.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (plan.asKnown().getOrNull()?.validity() ?: 0) + + (if (name.asKnown().isPresent) 1 else 0) + (if (bccRecipientEmail.asKnown().isPresent) 1 else 0) + (if (companyAddress.asKnown().isPresent) 1 else 0) + (if (companyCity.asKnown().isPresent) 1 else 0) + @@ -885,9 +879,11 @@ private constructor( (if (companyNumber.asKnown().isPresent) 1 else 0) + (if (companyTaxId.asKnown().isPresent) 1 else 0) + (if (companyZip.asKnown().isPresent) 1 else 0) + + (if (creditBalance.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + (ibans.asKnown().getOrNull()?.size ?: 0) + (peppolIds.asKnown().getOrNull()?.size ?: 0) + + (plan.asKnown().getOrNull()?.validity() ?: 0) + (if (smpRegistration.asKnown().isPresent) 1 else 0) + (if (smpRegistrationDate.asKnown().isPresent) 1 else 0) @@ -1031,9 +1027,7 @@ private constructor( } return other is MeRetrieveResponse && - creditBalance == other.creditBalance && name == other.name && - plan == other.plan && bccRecipientEmail == other.bccRecipientEmail && companyAddress == other.companyAddress && companyCity == other.companyCity && @@ -1043,9 +1037,11 @@ private constructor( companyNumber == other.companyNumber && companyTaxId == other.companyTaxId && companyZip == other.companyZip && + creditBalance == other.creditBalance && description == other.description && ibans == other.ibans && peppolIds == other.peppolIds && + plan == other.plan && smpRegistration == other.smpRegistration && smpRegistrationDate == other.smpRegistrationDate && additionalProperties == other.additionalProperties @@ -1053,9 +1049,7 @@ private constructor( private val hashCode: Int by lazy { Objects.hash( - creditBalance, name, - plan, bccRecipientEmail, companyAddress, companyCity, @@ -1065,9 +1059,11 @@ private constructor( companyNumber, companyTaxId, companyZip, + creditBalance, description, ibans, peppolIds, + plan, smpRegistration, smpRegistrationDate, additionalProperties, @@ -1077,5 +1073,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "MeRetrieveResponse{creditBalance=$creditBalance, name=$name, plan=$plan, bccRecipientEmail=$bccRecipientEmail, companyAddress=$companyAddress, companyCity=$companyCity, companyCountry=$companyCountry, companyEmail=$companyEmail, companyName=$companyName, companyNumber=$companyNumber, companyTaxId=$companyTaxId, companyZip=$companyZip, description=$description, ibans=$ibans, peppolIds=$peppolIds, smpRegistration=$smpRegistration, smpRegistrationDate=$smpRegistrationDate, additionalProperties=$additionalProperties}" + "MeRetrieveResponse{name=$name, bccRecipientEmail=$bccRecipientEmail, companyAddress=$companyAddress, companyCity=$companyCity, companyCountry=$companyCountry, companyEmail=$companyEmail, companyName=$companyName, companyNumber=$companyNumber, companyTaxId=$companyTaxId, companyZip=$companyZip, creditBalance=$creditBalance, description=$description, ibans=$ibans, peppolIds=$peppolIds, plan=$plan, smpRegistration=$smpRegistration, smpRegistrationDate=$smpRegistrationDate, additionalProperties=$additionalProperties}" } diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListReceivedDocumentsParams.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListReceivedDocumentsParams.kt index c7ccaba..3628fcc 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListReceivedDocumentsParams.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListReceivedDocumentsParams.kt @@ -68,10 +68,10 @@ private constructor( /** Sort direction (asc/desc) */ fun sortOrder(): Optional = Optional.ofNullable(sortOrder) - /** Filter by document state */ + /** Filter by document state. If not provided, returns all states. */ fun state(): Optional = Optional.ofNullable(state) - /** Filter by document type */ + /** Filter by document type. If not provided, returns all types. */ fun type(): Optional = Optional.ofNullable(type) /** Additional headers to send with the request. */ @@ -200,13 +200,13 @@ private constructor( /** Alias for calling [Builder.sortOrder] with `sortOrder.orElse(null)`. */ fun sortOrder(sortOrder: Optional) = sortOrder(sortOrder.getOrNull()) - /** Filter by document state */ + /** Filter by document state. If not provided, returns all states. */ fun state(state: DocumentState?) = apply { this.state = state } /** Alias for calling [Builder.state] with `state.orElse(null)`. */ fun state(state: Optional) = state(state.getOrNull()) - /** Filter by document type */ + /** Filter by document type. If not provided, returns all types. */ fun type(type: DocumentType?) = apply { this.type = type } /** Alias for calling [Builder.type] with `type.orElse(null)`. */ diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/me/MeRetrieveResponseTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/me/MeRetrieveResponseTest.kt index 28da861..b2625c9 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/me/MeRetrieveResponseTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/me/MeRetrieveResponseTest.kt @@ -15,9 +15,7 @@ internal class MeRetrieveResponseTest { fun create() { val meRetrieveResponse = MeRetrieveResponse.builder() - .creditBalance(0L) .name("name") - .plan(MeRetrieveResponse.Plan.STARTER) .bccRecipientEmail("bcc_recipient_email") .companyAddress("Brusselsesteenweg 119/A") .companyCity("Zemst") @@ -27,16 +25,16 @@ internal class MeRetrieveResponseTest { .companyNumber("1018265814") .companyTaxId("BE1018265814") .companyZip("1980") + .creditBalance(0L) .description("description") .addIban("string") .addPeppolId("string") + .plan(MeRetrieveResponse.Plan.STARTER) .smpRegistration(true) .smpRegistrationDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() - assertThat(meRetrieveResponse.creditBalance()).isEqualTo(0L) assertThat(meRetrieveResponse.name()).isEqualTo("name") - assertThat(meRetrieveResponse.plan()).isEqualTo(MeRetrieveResponse.Plan.STARTER) assertThat(meRetrieveResponse.bccRecipientEmail()).contains("bcc_recipient_email") assertThat(meRetrieveResponse.companyAddress()).contains("Brusselsesteenweg 119/A") assertThat(meRetrieveResponse.companyCity()).contains("Zemst") @@ -46,9 +44,11 @@ internal class MeRetrieveResponseTest { assertThat(meRetrieveResponse.companyNumber()).contains("1018265814") assertThat(meRetrieveResponse.companyTaxId()).contains("BE1018265814") assertThat(meRetrieveResponse.companyZip()).contains("1980") + assertThat(meRetrieveResponse.creditBalance()).contains(0L) assertThat(meRetrieveResponse.description()).contains("description") assertThat(meRetrieveResponse.ibans().getOrNull()).containsExactly("string") assertThat(meRetrieveResponse.peppolIds().getOrNull()).containsExactly("string") + assertThat(meRetrieveResponse.plan()).contains(MeRetrieveResponse.Plan.STARTER) assertThat(meRetrieveResponse.smpRegistration()).contains(true) assertThat(meRetrieveResponse.smpRegistrationDate()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) @@ -59,9 +59,7 @@ internal class MeRetrieveResponseTest { val jsonMapper = jsonMapper() val meRetrieveResponse = MeRetrieveResponse.builder() - .creditBalance(0L) .name("name") - .plan(MeRetrieveResponse.Plan.STARTER) .bccRecipientEmail("bcc_recipient_email") .companyAddress("Brusselsesteenweg 119/A") .companyCity("Zemst") @@ -71,9 +69,11 @@ internal class MeRetrieveResponseTest { .companyNumber("1018265814") .companyTaxId("BE1018265814") .companyZip("1980") + .creditBalance(0L) .description("description") .addIban("string") .addPeppolId("string") + .plan(MeRetrieveResponse.Plan.STARTER) .smpRegistration(true) .smpRegistrationDate(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .build() From 2b90fa4367258ccc96cdf4fe039efeede2a7048e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 20 Jan 2026 16:13:54 +0000 Subject: [PATCH 29/43] feat(api): api update --- .stats.yml | 4 ++-- .../api/models/inbox/InboxListParams.kt | 18 +----------------- .../OutboxListReceivedDocumentsParams.kt | 19 +------------------ .../api/models/inbox/InboxListParamsTest.kt | 3 --- .../OutboxListReceivedDocumentsParamsTest.kt | 4 ---- 5 files changed, 4 insertions(+), 44 deletions(-) diff --git a/.stats.yml b/.stats.yml index 51690cf..5fb08a6 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-8636c114cc033ac15d6da0b3232f790b6d3be8e93ab7fc0ba90eb17db2d04b63.yml -openapi_spec_hash: d01360d15f55e15f42ce0faf5d4c032d +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-07521d20d758ce7c6b93b16102088279015007b55fd9c70849598955fa97164f.yml +openapi_spec_hash: 35f6509d3376a52c2abec7471f488592 config_hash: 852a0117abb3db077933876ad1185f41 diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListParams.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListParams.kt index 6297954..63839bd 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListParams.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/inbox/InboxListParams.kt @@ -30,7 +30,6 @@ private constructor( private val sender: String?, private val sortBy: SortBy?, private val sortOrder: SortOrder?, - private val state: DocumentState?, private val type: DocumentType?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, @@ -60,9 +59,6 @@ private constructor( /** Sort direction (asc/desc) */ fun sortOrder(): Optional = Optional.ofNullable(sortOrder) - /** Filter by document state. If not provided, returns all states. */ - fun state(): Optional = Optional.ofNullable(state) - /** Filter by document type. If not provided, returns all types. */ fun type(): Optional = Optional.ofNullable(type) @@ -93,7 +89,6 @@ private constructor( private var sender: String? = null private var sortBy: SortBy? = null private var sortOrder: SortOrder? = null - private var state: DocumentState? = null private var type: DocumentType? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -108,7 +103,6 @@ private constructor( sender = inboxListParams.sender sortBy = inboxListParams.sortBy sortOrder = inboxListParams.sortOrder - state = inboxListParams.state type = inboxListParams.type additionalHeaders = inboxListParams.additionalHeaders.toBuilder() additionalQueryParams = inboxListParams.additionalQueryParams.toBuilder() @@ -176,12 +170,6 @@ private constructor( /** Alias for calling [Builder.sortOrder] with `sortOrder.orElse(null)`. */ fun sortOrder(sortOrder: Optional) = sortOrder(sortOrder.getOrNull()) - /** Filter by document state. If not provided, returns all states. */ - fun state(state: DocumentState?) = apply { this.state = state } - - /** Alias for calling [Builder.state] with `state.orElse(null)`. */ - fun state(state: Optional) = state(state.getOrNull()) - /** Filter by document type. If not provided, returns all types. */ fun type(type: DocumentType?) = apply { this.type = type } @@ -301,7 +289,6 @@ private constructor( sender, sortBy, sortOrder, - state, type, additionalHeaders.build(), additionalQueryParams.build(), @@ -323,7 +310,6 @@ private constructor( sender?.let { put("sender", it) } sortBy?.let { put("sort_by", it.toString()) } sortOrder?.let { put("sort_order", it.toString()) } - state?.let { put("state", it.toString()) } type?.let { put("type", it.toString()) } putAll(additionalQueryParams) } @@ -631,7 +617,6 @@ private constructor( sender == other.sender && sortBy == other.sortBy && sortOrder == other.sortOrder && - state == other.state && type == other.type && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams @@ -647,12 +632,11 @@ private constructor( sender, sortBy, sortOrder, - state, type, additionalHeaders, additionalQueryParams, ) override fun toString() = - "InboxListParams{dateFrom=$dateFrom, dateTo=$dateTo, page=$page, pageSize=$pageSize, search=$search, sender=$sender, sortBy=$sortBy, sortOrder=$sortOrder, state=$state, type=$type, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "InboxListParams{dateFrom=$dateFrom, dateTo=$dateTo, page=$page, pageSize=$pageSize, search=$search, sender=$sender, sortBy=$sortBy, sortOrder=$sortOrder, type=$type, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListReceivedDocumentsParams.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListReceivedDocumentsParams.kt index 3628fcc..5f4b330 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListReceivedDocumentsParams.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListReceivedDocumentsParams.kt @@ -9,7 +9,6 @@ import com.e_invoice.api.core.http.Headers import com.e_invoice.api.core.http.QueryParams import com.e_invoice.api.errors.EInvoiceInvalidDataException import com.e_invoice.api.models.documents.DocumentType -import com.e_invoice.api.models.inbox.DocumentState import com.fasterxml.jackson.annotation.JsonCreator import java.time.OffsetDateTime import java.time.format.DateTimeFormatter @@ -32,7 +31,6 @@ private constructor( private val sender: String?, private val sortBy: SortBy?, private val sortOrder: SortOrder?, - private val state: DocumentState?, private val type: DocumentType?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, @@ -68,9 +66,6 @@ private constructor( /** Sort direction (asc/desc) */ fun sortOrder(): Optional = Optional.ofNullable(sortOrder) - /** Filter by document state. If not provided, returns all states. */ - fun state(): Optional = Optional.ofNullable(state) - /** Filter by document type. If not provided, returns all types. */ fun type(): Optional = Optional.ofNullable(type) @@ -105,7 +100,6 @@ private constructor( private var sender: String? = null private var sortBy: SortBy? = null private var sortOrder: SortOrder? = null - private var state: DocumentState? = null private var type: DocumentType? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -122,7 +116,6 @@ private constructor( sender = outboxListReceivedDocumentsParams.sender sortBy = outboxListReceivedDocumentsParams.sortBy sortOrder = outboxListReceivedDocumentsParams.sortOrder - state = outboxListReceivedDocumentsParams.state type = outboxListReceivedDocumentsParams.type additionalHeaders = outboxListReceivedDocumentsParams.additionalHeaders.toBuilder() additionalQueryParams = @@ -200,12 +193,6 @@ private constructor( /** Alias for calling [Builder.sortOrder] with `sortOrder.orElse(null)`. */ fun sortOrder(sortOrder: Optional) = sortOrder(sortOrder.getOrNull()) - /** Filter by document state. If not provided, returns all states. */ - fun state(state: DocumentState?) = apply { this.state = state } - - /** Alias for calling [Builder.state] with `state.orElse(null)`. */ - fun state(state: Optional) = state(state.getOrNull()) - /** Filter by document type. If not provided, returns all types. */ fun type(type: DocumentType?) = apply { this.type = type } @@ -326,7 +313,6 @@ private constructor( sender, sortBy, sortOrder, - state, type, additionalHeaders.build(), additionalQueryParams.build(), @@ -349,7 +335,6 @@ private constructor( sender?.let { put("sender", it) } sortBy?.let { put("sort_by", it.toString()) } sortOrder?.let { put("sort_order", it.toString()) } - state?.let { put("state", it.toString()) } type?.let { put("type", it.toString()) } putAll(additionalQueryParams) } @@ -658,7 +643,6 @@ private constructor( sender == other.sender && sortBy == other.sortBy && sortOrder == other.sortOrder && - state == other.state && type == other.type && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams @@ -675,12 +659,11 @@ private constructor( sender, sortBy, sortOrder, - state, type, additionalHeaders, additionalQueryParams, ) override fun toString() = - "OutboxListReceivedDocumentsParams{dateFrom=$dateFrom, dateTo=$dateTo, page=$page, pageSize=$pageSize, receiver=$receiver, search=$search, sender=$sender, sortBy=$sortBy, sortOrder=$sortOrder, state=$state, type=$type, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "OutboxListReceivedDocumentsParams{dateFrom=$dateFrom, dateTo=$dateTo, page=$page, pageSize=$pageSize, receiver=$receiver, search=$search, sender=$sender, sortBy=$sortBy, sortOrder=$sortOrder, type=$type, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/InboxListParamsTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/InboxListParamsTest.kt index 54fd6fc..094ac87 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/InboxListParamsTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/inbox/InboxListParamsTest.kt @@ -21,7 +21,6 @@ internal class InboxListParamsTest { .sender("sender") .sortBy(InboxListParams.SortBy.CREATED_AT) .sortOrder(InboxListParams.SortOrder.ASC) - .state(DocumentState.DRAFT) .type(DocumentType.INVOICE) .build() } @@ -38,7 +37,6 @@ internal class InboxListParamsTest { .sender("sender") .sortBy(InboxListParams.SortBy.CREATED_AT) .sortOrder(InboxListParams.SortOrder.ASC) - .state(DocumentState.DRAFT) .type(DocumentType.INVOICE) .build() @@ -55,7 +53,6 @@ internal class InboxListParamsTest { .put("sender", "sender") .put("sort_by", "created_at") .put("sort_order", "asc") - .put("state", "DRAFT") .put("type", "INVOICE") .build() ) diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/outbox/OutboxListReceivedDocumentsParamsTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/outbox/OutboxListReceivedDocumentsParamsTest.kt index 6d353c8..345ce6b 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/outbox/OutboxListReceivedDocumentsParamsTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/outbox/OutboxListReceivedDocumentsParamsTest.kt @@ -4,7 +4,6 @@ package com.e_invoice.api.models.outbox import com.e_invoice.api.core.http.QueryParams import com.e_invoice.api.models.documents.DocumentType -import com.e_invoice.api.models.inbox.DocumentState import java.time.OffsetDateTime import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -23,7 +22,6 @@ internal class OutboxListReceivedDocumentsParamsTest { .sender("sender") .sortBy(OutboxListReceivedDocumentsParams.SortBy.CREATED_AT) .sortOrder(OutboxListReceivedDocumentsParams.SortOrder.ASC) - .state(DocumentState.DRAFT) .type(DocumentType.INVOICE) .build() } @@ -41,7 +39,6 @@ internal class OutboxListReceivedDocumentsParamsTest { .sender("sender") .sortBy(OutboxListReceivedDocumentsParams.SortBy.CREATED_AT) .sortOrder(OutboxListReceivedDocumentsParams.SortOrder.ASC) - .state(DocumentState.DRAFT) .type(DocumentType.INVOICE) .build() @@ -59,7 +56,6 @@ internal class OutboxListReceivedDocumentsParamsTest { .put("sender", "sender") .put("sort_by", "created_at") .put("sort_order", "asc") - .put("state", "DRAFT") .put("type", "INVOICE") .build() ) From 8af9305dcb70550adbd23bc6b31119eaa5aaf23c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 21 Jan 2026 15:13:48 +0000 Subject: [PATCH 30/43] feat(api): api update --- .stats.yml | 4 ++-- .../api/models/outbox/OutboxListDraftDocumentsPage.kt | 1 + .../models/outbox/OutboxListDraftDocumentsPageAsync.kt | 1 + .../api/models/outbox/OutboxListDraftDocumentsParams.kt | 1 + .../models/outbox/OutboxListReceivedDocumentsParams.kt | 6 +++--- .../e_invoice/api/services/async/OutboxServiceAsync.kt | 8 ++++++++ .../api/services/async/OutboxServiceAsyncImpl.kt | 2 ++ .../com/e_invoice/api/services/blocking/OutboxService.kt | 8 ++++++++ .../e_invoice/api/services/blocking/OutboxServiceImpl.kt | 2 ++ 9 files changed, 28 insertions(+), 5 deletions(-) diff --git a/.stats.yml b/.stats.yml index 5fb08a6..be00032 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-07521d20d758ce7c6b93b16102088279015007b55fd9c70849598955fa97164f.yml -openapi_spec_hash: 35f6509d3376a52c2abec7471f488592 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-2ace27cb846c575ffc8c9aadc1d9c6014847cbbf5966c98e73b3c67b15962728.yml +openapi_spec_hash: a589bc0f9eae2e99de7c319a4d185363 config_hash: 852a0117abb3db077933876ad1185f41 diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListDraftDocumentsPage.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListDraftDocumentsPage.kt index b9ddd19..40e8445 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListDraftDocumentsPage.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListDraftDocumentsPage.kt @@ -14,6 +14,7 @@ import kotlin.jvm.optionals.getOrDefault import kotlin.jvm.optionals.getOrNull /** @see OutboxService.listDraftDocuments */ +@Deprecated("deprecated") class OutboxListDraftDocumentsPage private constructor( private val service: OutboxService, diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListDraftDocumentsPageAsync.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListDraftDocumentsPageAsync.kt index 0c394b1..88bd8f6 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListDraftDocumentsPageAsync.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListDraftDocumentsPageAsync.kt @@ -16,6 +16,7 @@ import kotlin.jvm.optionals.getOrDefault import kotlin.jvm.optionals.getOrNull /** @see OutboxServiceAsync.listDraftDocuments */ +@Deprecated("deprecated") class OutboxListDraftDocumentsPageAsync private constructor( private val service: OutboxServiceAsync, diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListDraftDocumentsParams.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListDraftDocumentsParams.kt index 1014480..d7c984a 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListDraftDocumentsParams.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListDraftDocumentsParams.kt @@ -19,6 +19,7 @@ import kotlin.jvm.optionals.getOrNull * Retrieve a paginated list of draft documents with filtering options including state and text * search. */ +@Deprecated("deprecated") class OutboxListDraftDocumentsParams private constructor( private val page: Long?, diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListReceivedDocumentsParams.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListReceivedDocumentsParams.kt index 5f4b330..315ae20 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListReceivedDocumentsParams.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/outbox/OutboxListReceivedDocumentsParams.kt @@ -58,7 +58,7 @@ private constructor( fun search(): Optional = Optional.ofNullable(search) /** (Deprecated) Filter by sender ID */ - @Deprecated("deprecated") fun sender(): Optional = Optional.ofNullable(sender) + fun sender(): Optional = Optional.ofNullable(sender) /** Field to sort by */ fun sortBy(): Optional = Optional.ofNullable(sortBy) @@ -176,10 +176,10 @@ private constructor( fun search(search: Optional) = search(search.getOrNull()) /** (Deprecated) Filter by sender ID */ - @Deprecated("deprecated") fun sender(sender: String?) = apply { this.sender = sender } + fun sender(sender: String?) = apply { this.sender = sender } /** Alias for calling [Builder.sender] with `sender.orElse(null)`. */ - @Deprecated("deprecated") fun sender(sender: Optional) = sender(sender.getOrNull()) + fun sender(sender: Optional) = sender(sender.getOrNull()) /** Field to sort by */ fun sortBy(sortBy: SortBy?) = apply { this.sortBy = sortBy } diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/OutboxServiceAsync.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/OutboxServiceAsync.kt index 916d730..bc29152 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/OutboxServiceAsync.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/OutboxServiceAsync.kt @@ -30,22 +30,26 @@ interface OutboxServiceAsync { * Retrieve a paginated list of draft documents with filtering options including state and text * search. */ + @Deprecated("deprecated") fun listDraftDocuments(): CompletableFuture = listDraftDocuments(OutboxListDraftDocumentsParams.none()) /** @see listDraftDocuments */ + @Deprecated("deprecated") fun listDraftDocuments( params: OutboxListDraftDocumentsParams = OutboxListDraftDocumentsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture /** @see listDraftDocuments */ + @Deprecated("deprecated") fun listDraftDocuments( params: OutboxListDraftDocumentsParams = OutboxListDraftDocumentsParams.none() ): CompletableFuture = listDraftDocuments(params, RequestOptions.none()) /** @see listDraftDocuments */ + @Deprecated("deprecated") fun listDraftDocuments( requestOptions: RequestOptions ): CompletableFuture = @@ -94,23 +98,27 @@ interface OutboxServiceAsync { * Returns a raw HTTP response for `get /api/outbox/drafts`, but is otherwise the same as * [OutboxServiceAsync.listDraftDocuments]. */ + @Deprecated("deprecated") fun listDraftDocuments(): CompletableFuture> = listDraftDocuments(OutboxListDraftDocumentsParams.none()) /** @see listDraftDocuments */ + @Deprecated("deprecated") fun listDraftDocuments( params: OutboxListDraftDocumentsParams = OutboxListDraftDocumentsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see listDraftDocuments */ + @Deprecated("deprecated") fun listDraftDocuments( params: OutboxListDraftDocumentsParams = OutboxListDraftDocumentsParams.none() ): CompletableFuture> = listDraftDocuments(params, RequestOptions.none()) /** @see listDraftDocuments */ + @Deprecated("deprecated") fun listDraftDocuments( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/OutboxServiceAsyncImpl.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/OutboxServiceAsyncImpl.kt index f89c860..c1c0edd 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/OutboxServiceAsyncImpl.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/OutboxServiceAsyncImpl.kt @@ -34,6 +34,7 @@ class OutboxServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withOptions(modifier: Consumer): OutboxServiceAsync = OutboxServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + @Deprecated("deprecated") override fun listDraftDocuments( params: OutboxListDraftDocumentsParams, requestOptions: RequestOptions, @@ -64,6 +65,7 @@ class OutboxServiceAsyncImpl internal constructor(private val clientOptions: Cli private val listDraftDocumentsHandler: Handler = jsonHandler(clientOptions.jsonMapper) + @Deprecated("deprecated") override fun listDraftDocuments( params: OutboxListDraftDocumentsParams, requestOptions: RequestOptions, diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/OutboxService.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/OutboxService.kt index 2704fab..397cbaa 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/OutboxService.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/OutboxService.kt @@ -30,21 +30,25 @@ interface OutboxService { * Retrieve a paginated list of draft documents with filtering options including state and text * search. */ + @Deprecated("deprecated") fun listDraftDocuments(): OutboxListDraftDocumentsPage = listDraftDocuments(OutboxListDraftDocumentsParams.none()) /** @see listDraftDocuments */ + @Deprecated("deprecated") fun listDraftDocuments( params: OutboxListDraftDocumentsParams = OutboxListDraftDocumentsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): OutboxListDraftDocumentsPage /** @see listDraftDocuments */ + @Deprecated("deprecated") fun listDraftDocuments( params: OutboxListDraftDocumentsParams = OutboxListDraftDocumentsParams.none() ): OutboxListDraftDocumentsPage = listDraftDocuments(params, RequestOptions.none()) /** @see listDraftDocuments */ + @Deprecated("deprecated") fun listDraftDocuments(requestOptions: RequestOptions): OutboxListDraftDocumentsPage = listDraftDocuments(OutboxListDraftDocumentsParams.none(), requestOptions) @@ -84,11 +88,13 @@ interface OutboxService { * Returns a raw HTTP response for `get /api/outbox/drafts`, but is otherwise the same as * [OutboxService.listDraftDocuments]. */ + @Deprecated("deprecated") @MustBeClosed fun listDraftDocuments(): HttpResponseFor = listDraftDocuments(OutboxListDraftDocumentsParams.none()) /** @see listDraftDocuments */ + @Deprecated("deprecated") @MustBeClosed fun listDraftDocuments( params: OutboxListDraftDocumentsParams = OutboxListDraftDocumentsParams.none(), @@ -96,6 +102,7 @@ interface OutboxService { ): HttpResponseFor /** @see listDraftDocuments */ + @Deprecated("deprecated") @MustBeClosed fun listDraftDocuments( params: OutboxListDraftDocumentsParams = OutboxListDraftDocumentsParams.none() @@ -103,6 +110,7 @@ interface OutboxService { listDraftDocuments(params, RequestOptions.none()) /** @see listDraftDocuments */ + @Deprecated("deprecated") @MustBeClosed fun listDraftDocuments( requestOptions: RequestOptions diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/OutboxServiceImpl.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/OutboxServiceImpl.kt index d71a19e..ffe4da6 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/OutboxServiceImpl.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/OutboxServiceImpl.kt @@ -33,6 +33,7 @@ class OutboxServiceImpl internal constructor(private val clientOptions: ClientOp override fun withOptions(modifier: Consumer): OutboxService = OutboxServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + @Deprecated("deprecated") override fun listDraftDocuments( params: OutboxListDraftDocumentsParams, requestOptions: RequestOptions, @@ -63,6 +64,7 @@ class OutboxServiceImpl internal constructor(private val clientOptions: ClientOp private val listDraftDocumentsHandler: Handler = jsonHandler(clientOptions.jsonMapper) + @Deprecated("deprecated") override fun listDraftDocuments( params: OutboxListDraftDocumentsParams, requestOptions: RequestOptions, From 9e69b7ff607be2392d5ab6e9796518e129c46fcc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 22 Jan 2026 03:15:02 +0000 Subject: [PATCH 31/43] chore(internal): update maven repo doc to include authentication --- scripts/upload-artifacts | 64 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 5 deletions(-) diff --git a/scripts/upload-artifacts b/scripts/upload-artifacts index 548d152..10f3c70 100755 --- a/scripts/upload-artifacts +++ b/scripts/upload-artifacts @@ -96,8 +96,52 @@ generate_instructions() {

Stainless SDK Maven Repository

This is the Maven repository for your Stainless Java SDK build.

-

Directions

-

To use the uploaded Maven repository, add the following to your project's pom.xml:

+

Project configuration

+ +

The details depend on whether you're using Maven or Gradle as your build tool.

+ +

Maven

+ +

Add the following to your project's pom.xml:

+
<repositories>
+    <repository>
+        <id>stainless-sdk-repo</id>
+        <url>https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn</url>
+    </repository>
+</repositories>
+ +

Gradle

+

Add the following to your build.gradle file:

+
repositories {
+    maven {
+        url "https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn"
+    }
+}
+ +
+

Configuring authentication (if required)

+ +

Some accounts may require authentication to access the repository. If so, use the + following instructions, replacing YOUR_STAINLESS_API_TOKEN with your actual token.

+ +

Maven with authentication

+ +

First, ensure you have the following in your Maven settings.xml for repo authentication:

+
<servers>
+    <server>
+        <id>stainless-sdk-repo</id>
+        <configuration>
+            <httpHeaders>
+                <property>
+                    <name>Authorization</name>
+                    <value>Bearer YOUR_STAINLESS_API_TOKEN</value>
+                </property>
+            </httpHeaders>
+        </configuration>
+    </server>
+</servers>
+ +

Then, add the following to your project's pom.xml:

<repositories>
     <repository>
         <id>stainless-sdk-repo</id>
@@ -105,14 +149,24 @@ generate_instructions() {
     </repository>
 </repositories>
-

If you're using Gradle, add the following to your build.gradle file:

+

Gradle with authentication

+

Add the following to your build.gradle file:

repositories {
     maven {
-        url 'https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn'
+        url "https://pkg.stainless.com/s/${PROJECT}/${SHA}/mvn"
+        credentials(HttpHeaderCredentials) {
+            name = "Authorization"
+            value = "Bearer YOUR_STAINLESS_API_TOKEN"
+        }
+        authentication {
+            header(HttpHeaderAuthentication)
+        }
     }
 }
+
-

Once you've added the repository, you can include dependencies from it as usual. See your +

Using the repository

+

Once you've configured the repository, you can include dependencies from it as usual. See your project README for more details.

From 310f45e949318fdc406d157cebe1525e048e1f7c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 22 Jan 2026 03:15:52 +0000 Subject: [PATCH 32/43] feat(client): send `X-Stainless-Kotlin-Version` header --- .../src/main/kotlin/com/e_invoice/api/core/ClientOptions.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/ClientOptions.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/ClientOptions.kt index 2586a9d..a29ecb3 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/ClientOptions.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/ClientOptions.kt @@ -450,6 +450,7 @@ private constructor( headers.put("X-Stainless-Package-Version", getPackageVersion()) headers.put("X-Stainless-Runtime", "JRE") headers.put("X-Stainless-Runtime-Version", getJavaVersion()) + headers.put("X-Stainless-Kotlin-Version", KotlinVersion.CURRENT.toString()) apiKey.let { if (!it.isEmpty()) { headers.put("Authorization", "Bearer $it") From c63457882b2760456275e531d05f289c716e5934 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 22 Jan 2026 16:13:49 +0000 Subject: [PATCH 33/43] feat(api): api update --- .stats.yml | 4 ++-- .../e_invoice/api/models/documents/DocumentSendParams.kt | 8 +++++++- .../e_invoice/api/services/async/DocumentServiceAsync.kt | 8 +++++++- .../e_invoice/api/services/blocking/DocumentService.kt | 8 +++++++- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/.stats.yml b/.stats.yml index be00032..a7c51bf 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-2ace27cb846c575ffc8c9aadc1d9c6014847cbbf5966c98e73b3c67b15962728.yml -openapi_spec_hash: a589bc0f9eae2e99de7c319a4d185363 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-74b18e3a16a518001ce7039a1d8ceeef82bb55bccf09237fa1063aa94ca5e074.yml +openapi_spec_hash: 9cb61453abdb2c9bdba52c86913f1d6c config_hash: 852a0117abb3db077933876ad1185f41 diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentSendParams.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentSendParams.kt index f20b196..8c80d37 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentSendParams.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentSendParams.kt @@ -11,7 +11,13 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** Send an invoice or credit note via Peppol */ +/** + * Send an invoice or credit note via Peppol. By default, the sender and receiver Peppol IDs are + * derived from the company (tax) IDs in the document, regardless of whether the document was + * created from a UBL with a different endpoint ID. To explicitly set the sender or receiver Peppol + * ID, provide them via the query parameters (sender_peppol_scheme, sender_peppol_id, + * receiver_peppol_scheme, receiver_peppol_id). + */ class DocumentSendParams private constructor( private val documentId: String?, diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/DocumentServiceAsync.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/DocumentServiceAsync.kt index 56b20a6..2ad35b5 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/DocumentServiceAsync.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/async/DocumentServiceAsync.kt @@ -150,7 +150,13 @@ interface DocumentServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** Send an invoice or credit note via Peppol */ + /** + * Send an invoice or credit note via Peppol. By default, the sender and receiver Peppol IDs are + * derived from the company (tax) IDs in the document, regardless of whether the document was + * created from a UBL with a different endpoint ID. To explicitly set the sender or receiver + * Peppol ID, provide them via the query parameters (sender_peppol_scheme, sender_peppol_id, + * receiver_peppol_scheme, receiver_peppol_id). + */ fun send(documentId: String): CompletableFuture = send(documentId, DocumentSendParams.none()) diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/DocumentService.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/DocumentService.kt index 80373f8..5ba74d0 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/DocumentService.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/services/blocking/DocumentService.kt @@ -142,7 +142,13 @@ interface DocumentService { requestOptions: RequestOptions = RequestOptions.none(), ): DocumentCreateFromPdfResponse - /** Send an invoice or credit note via Peppol */ + /** + * Send an invoice or credit note via Peppol. By default, the sender and receiver Peppol IDs are + * derived from the company (tax) IDs in the document, regardless of whether the document was + * created from a UBL with a different endpoint ID. To explicitly set the sender or receiver + * Peppol ID, provide them via the query parameters (sender_peppol_scheme, sender_peppol_id, + * receiver_peppol_scheme, receiver_peppol_id). + */ fun send(documentId: String): DocumentResponse = send(documentId, DocumentSendParams.none()) /** @see send */ From a1039c67421588b13f9a5d522b5baa7c1b150931 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 23 Jan 2026 03:30:12 +0000 Subject: [PATCH 34/43] fix(tests): add missing query/header params --- .../api/services/ServiceParamsTest.kt | 207 +++++++++--------- 1 file changed, 108 insertions(+), 99 deletions(-) diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ServiceParamsTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ServiceParamsTest.kt index 90cf21d..7d184da 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ServiceParamsTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ServiceParamsTest.kt @@ -7,6 +7,7 @@ import com.e_invoice.api.client.okhttp.EInvoiceOkHttpClient import com.e_invoice.api.models.documents.CurrencyCode import com.e_invoice.api.models.documents.DocumentAttachmentCreate import com.e_invoice.api.models.documents.DocumentCreate +import com.e_invoice.api.models.documents.DocumentCreateParams import com.e_invoice.api.models.documents.DocumentDirection import com.e_invoice.api.models.documents.DocumentType import com.e_invoice.api.models.documents.PaymentDetailCreate @@ -49,123 +50,131 @@ internal class ServiceParamsTest { stubFor(post(anyUrl()).willReturn(ok("{}"))) documentService.create( - DocumentCreate.builder() - .addAllowance( - DocumentCreate.Allowance.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) - .build() - ) - .amountDue(0.0) - .addAttachment( - DocumentAttachmentCreate.builder() - .fileName("file_name") - .fileData("file_data") - .fileSize(0L) - .fileType("file_type") - .build() - ) - .billingAddress("billing_address") - .billingAddressRecipient("billing_address_recipient") - .addCharge( - DocumentCreate.Charge.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") - .build() - ) - .currency(CurrencyCode.EUR) - .customerAddress("customer_address") - .customerAddressRecipient("customer_address_recipient") - .customerCompanyId("1018265814") - .customerEmail("customer_email") - .customerId("customer_id") - .customerName("customer_name") - .customerTaxId("BE1018265814") - .direction(DocumentDirection.INBOUND) - .documentType(DocumentType.INVOICE) - .dueDate(LocalDate.parse("2019-12-27")) - .invoiceDate(LocalDate.parse("2019-12-27")) - .invoiceId("invoice_id") - .invoiceTotal(0.0) - .addItem( - DocumentCreate.Item.builder() + DocumentCreateParams.builder() + .documentCreate( + DocumentCreate.builder() .addAllowance( - DocumentCreate.Item.Allowance.builder() + DocumentCreate.Allowance.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .taxCode(DocumentCreate.Allowance.TaxCode.AE) .taxRate(0.0) .build() ) - .amount(0.0) + .amountDue(0.0) + .addAttachment( + DocumentAttachmentCreate.builder() + .fileName("file_name") + .fileData("file_data") + .fileSize(0L) + .fileType("file_type") + .build() + ) + .billingAddress("billing_address") + .billingAddressRecipient("billing_address_recipient") .addCharge( - DocumentCreate.Item.Charge.builder() + DocumentCreate.Charge.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .taxCode(DocumentCreate.Charge.TaxCode.AE) .taxRate("21.00") .build() ) - .date(null) - .description("description") - .productCode("product_code") - .quantity(0.0) - .tax(0.0) - .taxRate("21.00") - .unit(UnitOfMeasureCode._10) - .unitPrice(0.0) - .build() - ) - .note("note") - .addPaymentDetail( - PaymentDetailCreate.builder() - .bankAccountNumber("bank_account_number") - .iban("iban") - .paymentReference("payment_reference") - .swift("swift") + .currency(CurrencyCode.EUR) + .customerAddress("customer_address") + .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") + .customerEmail("customer_email") + .customerId("customer_id") + .customerName("customer_name") + .customerTaxId("BE1018265814") + .direction(DocumentDirection.INBOUND) + .documentType(DocumentType.INVOICE) + .dueDate(LocalDate.parse("2019-12-27")) + .invoiceDate(LocalDate.parse("2019-12-27")) + .invoiceId("invoice_id") + .invoiceTotal(0.0) + .addItem( + DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate(0.0) + .build() + ) + .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("21.00") + .build() + ) + .date(null) + .description("description") + .productCode("product_code") + .quantity(0.0) + .tax(0.0) + .taxRate("21.00") + .unit(UnitOfMeasureCode._10) + .unitPrice(0.0) + .build() + ) + .note("note") + .addPaymentDetail( + PaymentDetailCreate.builder() + .bankAccountNumber("bank_account_number") + .iban("iban") + .paymentReference("payment_reference") + .swift("swift") + .build() + ) + .paymentTerm("payment_term") + .previousUnpaidBalance(0.0) + .purchaseOrder("purchase_order") + .remittanceAddress("remittance_address") + .remittanceAddressRecipient("remittance_address_recipient") + .serviceAddress("service_address") + .serviceAddressRecipient("service_address_recipient") + .serviceEndDate(LocalDate.parse("2019-12-27")) + .serviceStartDate(LocalDate.parse("2019-12-27")) + .shippingAddress("shipping_address") + .shippingAddressRecipient("shipping_address_recipient") + .state(DocumentState.DRAFT) + .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) + .addTaxDetail( + DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() + ) + .totalDiscount(0.0) + .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") + .vendorAddress("vendor_address") + .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") + .vendorEmail("vendor_email") + .vendorName("vendor_name") + .vendorTaxId("BE1018265814") .build() ) - .paymentTerm("payment_term") - .previousUnpaidBalance(0.0) - .purchaseOrder("purchase_order") - .remittanceAddress("remittance_address") - .remittanceAddressRecipient("remittance_address_recipient") - .serviceAddress("service_address") - .serviceAddressRecipient("service_address_recipient") - .serviceEndDate(LocalDate.parse("2019-12-27")) - .serviceStartDate(LocalDate.parse("2019-12-27")) - .shippingAddress("shipping_address") - .shippingAddressRecipient("shipping_address_recipient") - .state(DocumentState.DRAFT) - .subtotal(0.0) - .taxCode(DocumentCreate.TaxCode.AE) - .addTaxDetail(DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build()) - .totalDiscount(0.0) - .totalTax(0.0) - .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) - .vatexNote("vatex_note") - .vendorAddress("vendor_address") - .vendorAddressRecipient("vendor_address_recipient") - .vendorCompanyId("1018265814") - .vendorEmail("vendor_email") - .vendorName("vendor_name") - .vendorTaxId("BE1018265814") + .putAdditionalHeader("Secret-Header", "42") + .putAdditionalQueryParam("secret_query_param", "42") .build() ) From 524c0373a029f9e0ac7429d05d0e9869dca8a723 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 23 Jan 2026 03:34:50 +0000 Subject: [PATCH 35/43] chore(internal): correct cache invalidation for `SKIP_MOCK_TESTS` --- buildSrc/src/main/kotlin/e-invoice.kotlin.gradle.kts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/buildSrc/src/main/kotlin/e-invoice.kotlin.gradle.kts b/buildSrc/src/main/kotlin/e-invoice.kotlin.gradle.kts index 8541ea6..16c0db2 100644 --- a/buildSrc/src/main/kotlin/e-invoice.kotlin.gradle.kts +++ b/buildSrc/src/main/kotlin/e-invoice.kotlin.gradle.kts @@ -33,6 +33,9 @@ kotlin { tasks.withType().configureEach { systemProperty("junit.jupiter.execution.parallel.enabled", true) systemProperty("junit.jupiter.execution.parallel.mode.default", "concurrent") + + // `SKIP_MOCK_TESTS` affects which tests run so it must be added as input for proper cache invalidation. + inputs.property("skipMockTests", System.getenv("SKIP_MOCK_TESTS")).optional(true) } val ktfmt by configurations.creating From 2bc9f757bcc64596e9db1b2fab3bdeb504e92534 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 23 Jan 2026 03:38:21 +0000 Subject: [PATCH 36/43] fix(client): preserve time zone in lenient date-time parsing --- .../com/e_invoice/api/core/ObjectMappers.kt | 19 +++++---- .../e_invoice/api/core/ObjectMappersTest.kt | 41 +++++++++++++++---- 2 files changed, 44 insertions(+), 16 deletions(-) diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/ObjectMappers.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/ObjectMappers.kt index 6258886..54ad6ad 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/ObjectMappers.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/core/ObjectMappers.kt @@ -25,7 +25,7 @@ import java.time.DateTimeException import java.time.LocalDate import java.time.LocalDateTime import java.time.OffsetDateTime -import java.time.ZonedDateTime +import java.time.ZoneId import java.time.format.DateTimeFormatter import java.time.temporal.ChronoField @@ -157,14 +157,15 @@ private class LenientOffsetDateTimeDeserializer : val temporal = formatter.parse(p.text) return when { - !temporal.isSupported(ChronoField.HOUR_OF_DAY) -> - LocalDate.from(temporal).atStartOfDay() - !temporal.isSupported(ChronoField.OFFSET_SECONDS) -> - LocalDateTime.from(temporal) - else -> ZonedDateTime.from(temporal).toLocalDateTime() - } - .atZone(context.timeZone.toZoneId()) - .toOffsetDateTime() + !temporal.isSupported(ChronoField.HOUR_OF_DAY) -> + LocalDate.from(temporal) + .atStartOfDay() + .atZone(ZoneId.of("UTC")) + .toOffsetDateTime() + !temporal.isSupported(ChronoField.OFFSET_SECONDS) -> + LocalDateTime.from(temporal).atZone(ZoneId.of("UTC")).toOffsetDateTime() + else -> OffsetDateTime.from(temporal) + } } catch (e: DateTimeException) { exceptions.add(e) } diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/core/ObjectMappersTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/core/ObjectMappersTest.kt index b222b4a..f20d04a 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/core/ObjectMappersTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/core/ObjectMappersTest.kt @@ -3,12 +3,14 @@ package com.e_invoice.api.core import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.exc.MismatchedInputException import com.fasterxml.jackson.module.kotlin.readValue +import java.time.LocalDate +import java.time.LocalTime import java.time.OffsetDateTime +import java.time.ZoneOffset import kotlin.reflect.KClass import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.catchThrowable import org.junit.jupiter.api.Test -import org.junit.jupiter.api.assertDoesNotThrow import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.EnumSource import org.junitpioneer.jupiter.cartesian.CartesianTest @@ -72,11 +74,34 @@ internal class ObjectMappersTest { } } - enum class LenientOffsetDateTimeTestCase(val string: String) { - DATE("1998-04-21"), - DATE_TIME("1998-04-21T04:00:00"), - ZONED_DATE_TIME_1("1998-04-21T04:00:00+03:00"), - ZONED_DATE_TIME_2("1998-04-21T04:00:00Z"), + enum class LenientOffsetDateTimeTestCase( + val string: String, + val expectedOffsetDateTime: OffsetDateTime, + ) { + DATE( + "1998-04-21", + expectedOffsetDateTime = + OffsetDateTime.of(LocalDate.of(1998, 4, 21), LocalTime.of(0, 0), ZoneOffset.UTC), + ), + DATE_TIME( + "1998-04-21T04:00:00", + expectedOffsetDateTime = + OffsetDateTime.of(LocalDate.of(1998, 4, 21), LocalTime.of(4, 0), ZoneOffset.UTC), + ), + ZONED_DATE_TIME_1( + "1998-04-21T04:00:00+03:00", + expectedOffsetDateTime = + OffsetDateTime.of( + LocalDate.of(1998, 4, 21), + LocalTime.of(4, 0), + ZoneOffset.ofHours(3), + ), + ), + ZONED_DATE_TIME_2( + "1998-04-21T04:00:00Z", + expectedOffsetDateTime = + OffsetDateTime.of(LocalDate.of(1998, 4, 21), LocalTime.of(4, 0), ZoneOffset.UTC), + ), } @ParameterizedTest @@ -85,6 +110,8 @@ internal class ObjectMappersTest { val jsonMapper = jsonMapper() val json = jsonMapper.writeValueAsString(testCase.string) - assertDoesNotThrow { jsonMapper().readValue(json) } + val offsetDateTime = jsonMapper().readValue(json) + + assertThat(offsetDateTime).isEqualTo(testCase.expectedOffsetDateTime) } } From eb5c7e54df6ca465861af705907ed654e844d5a5 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 24 Jan 2026 03:34:46 +0000 Subject: [PATCH 37/43] chore(internal): codegen related update --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1b93074..cc9f68a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,7 +67,7 @@ jobs: - name: Get GitHub OIDC Token if: github.repository == 'stainless-sdks/e-invoice-api-java' id: github-oidc - uses: actions/github-script@v6 + uses: actions/github-script@v8 with: script: core.setOutput('github_token', await core.getIDToken()); From 04ffe93692ea6714f8825df585864c39b84a2663 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 29 Jan 2026 03:47:58 +0000 Subject: [PATCH 38/43] chore(internal): codegen related update --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b1a6e93..c30f901 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,8 @@ The e-invoice.be Peppol SDK provides convenient access to the [e-invoice.be REST Use the E Invoice MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application. -[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=e-invoice-api-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsImUtaW52b2ljZS1hcGktbWNwIl19) -[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22e-invoice-api-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22e-invoice-api-mcp%22%5D%7D) +[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=e-invoice-api-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsImUtaW52b2ljZS1hcGktbWNwIl0sImVudiI6eyJFX0lOVk9JQ0VfQVBJX0tFWSI6Ik15IEFQSSBLZXkifX0) +[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22e-invoice-api-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22e-invoice-api-mcp%22%5D%2C%22env%22%3A%7B%22E_INVOICE_API_KEY%22%3A%22My%20API%20Key%22%7D%7D) > Note: You may need to set environment variables in your MCP client. From 20dd5a8e841a3649ffe0f76098e1046e1d8f00e9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 31 Jan 2026 03:59:48 +0000 Subject: [PATCH 39/43] chore(internal): codegen related update --- scripts/build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build b/scripts/build index f406348..16a2b00 100755 --- a/scripts/build +++ b/scripts/build @@ -5,4 +5,4 @@ set -e cd "$(dirname "$0")/.." echo "==> Building classes" -./gradlew build testClasses -x test +./gradlew build testClasses "$@" -x test From c34c50778f12b11cf1ce4efc7131a84938376c4d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 5 Feb 2026 11:13:47 +0000 Subject: [PATCH 40/43] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index a7c51bf..7e57a99 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-74b18e3a16a518001ce7039a1d8ceeef82bb55bccf09237fa1063aa94ca5e074.yml -openapi_spec_hash: 9cb61453abdb2c9bdba52c86913f1d6c +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-78b341320f6c544bbaeb423eef98a49bfa9f5d1119cb6c71746e4dcbe2ee6a39.yml +openapi_spec_hash: 60872cbbede6bd4fccfb2b76b295270c config_hash: 852a0117abb3db077933876ad1185f41 From 0bd96de349c640f0757190242e91a9e315c133e1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 7 Feb 2026 05:42:59 +0000 Subject: [PATCH 41/43] chore(internal): codegen related update --- e-invoice-java-client-okhttp/build.gradle.kts | 2 +- e-invoice-java-core/build.gradle.kts | 2 +- e-invoice-java-proguard-test/build.gradle.kts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/e-invoice-java-client-okhttp/build.gradle.kts b/e-invoice-java-client-okhttp/build.gradle.kts index 218298a..20efb7d 100644 --- a/e-invoice-java-client-okhttp/build.gradle.kts +++ b/e-invoice-java-client-okhttp/build.gradle.kts @@ -10,6 +10,6 @@ dependencies { implementation("com.squareup.okhttp3:logging-interceptor:4.12.0") testImplementation(kotlin("test")) - testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("org.assertj:assertj-core:3.27.7") testImplementation("com.github.tomakehurst:wiremock-jre8:2.35.2") } diff --git a/e-invoice-java-core/build.gradle.kts b/e-invoice-java-core/build.gradle.kts index b8c6afb..0465618 100644 --- a/e-invoice-java-core/build.gradle.kts +++ b/e-invoice-java-core/build.gradle.kts @@ -33,7 +33,7 @@ dependencies { testImplementation(kotlin("test")) testImplementation(project(":e-invoice-java-client-okhttp")) testImplementation("com.github.tomakehurst:wiremock-jre8:2.35.2") - testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("org.assertj:assertj-core:3.27.7") testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") testImplementation("org.junit.jupiter:junit-jupiter-params:5.9.3") testImplementation("org.junit-pioneer:junit-pioneer:1.9.1") diff --git a/e-invoice-java-proguard-test/build.gradle.kts b/e-invoice-java-proguard-test/build.gradle.kts index e682b62..60afc8d 100644 --- a/e-invoice-java-proguard-test/build.gradle.kts +++ b/e-invoice-java-proguard-test/build.gradle.kts @@ -18,7 +18,7 @@ dependencies { testImplementation(project(":e-invoice-java")) testImplementation(kotlin("test")) testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") - testImplementation("org.assertj:assertj-core:3.25.3") + testImplementation("org.assertj:assertj-core:3.27.7") testImplementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.14.0") } From 60dbcea186a99adbde90154602023e831daf3632 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 9 Feb 2026 10:17:06 +0000 Subject: [PATCH 42/43] feat(api): api update --- .stats.yml | 4 +- .../models/documents/DocumentCreateParams.kt | 41 +- .../documents/DocumentCreateParamsTest.kt | 148 + .../api/services/ErrorHandlingTest.kt | 3639 +++++++++-------- .../api/services/ServiceParamsTest.kt | 1 + .../async/DocumentServiceAsyncTest.kt | 210 +- .../services/blocking/DocumentServiceTest.kt | 210 +- 7 files changed, 2329 insertions(+), 1924 deletions(-) diff --git a/.stats.yml b/.stats.yml index 7e57a99..6da94ee 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 28 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-78b341320f6c544bbaeb423eef98a49bfa9f5d1119cb6c71746e4dcbe2ee6a39.yml -openapi_spec_hash: 60872cbbede6bd4fccfb2b76b295270c +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/e-invoice-be%2Fe-invoice-api-456484895d394520a1179d60cd2df0b377207849fa84562e406d66886bf8244f.yml +openapi_spec_hash: b51d0365469bbe89d7e1e8c13983475d config_hash: 852a0117abb3db077933876ad1185f41 diff --git a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreateParams.kt b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreateParams.kt index 2c4d977..e8cf143 100644 --- a/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreateParams.kt +++ b/e-invoice-java-core/src/main/kotlin/com/e_invoice/api/models/documents/DocumentCreateParams.kt @@ -8,15 +8,24 @@ import com.e_invoice.api.core.checkRequired import com.e_invoice.api.core.http.Headers import com.e_invoice.api.core.http.QueryParams import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull /** Create a new invoice or credit note */ class DocumentCreateParams private constructor( + private val constructPdf: Boolean?, private val documentCreate: DocumentCreate, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { + /** + * If true, generate a constructed PDF from the document and include it both as document + * attachment and embedded in the UBL. + */ + fun constructPdf(): Optional = Optional.ofNullable(constructPdf) + fun documentCreate(): DocumentCreate = documentCreate fun _additionalBodyProperties(): Map = documentCreate._additionalProperties() @@ -45,17 +54,35 @@ private constructor( /** A builder for [DocumentCreateParams]. */ class Builder internal constructor() { + private var constructPdf: Boolean? = null private var documentCreate: DocumentCreate? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic internal fun from(documentCreateParams: DocumentCreateParams) = apply { + constructPdf = documentCreateParams.constructPdf documentCreate = documentCreateParams.documentCreate additionalHeaders = documentCreateParams.additionalHeaders.toBuilder() additionalQueryParams = documentCreateParams.additionalQueryParams.toBuilder() } + /** + * If true, generate a constructed PDF from the document and include it both as document + * attachment and embedded in the UBL. + */ + fun constructPdf(constructPdf: Boolean?) = apply { this.constructPdf = constructPdf } + + /** + * Alias for [Builder.constructPdf]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun constructPdf(constructPdf: Boolean) = constructPdf(constructPdf as Boolean?) + + /** Alias for calling [Builder.constructPdf] with `constructPdf.orElse(null)`. */ + fun constructPdf(constructPdf: Optional) = constructPdf(constructPdf.getOrNull()) + fun documentCreate(documentCreate: DocumentCreate) = apply { this.documentCreate = documentCreate } @@ -172,6 +199,7 @@ private constructor( */ fun build(): DocumentCreateParams = DocumentCreateParams( + constructPdf, checkRequired("documentCreate", documentCreate), additionalHeaders.build(), additionalQueryParams.build(), @@ -182,7 +210,13 @@ private constructor( override fun _headers(): Headers = additionalHeaders - override fun _queryParams(): QueryParams = additionalQueryParams + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + constructPdf?.let { put("construct_pdf", it.toString()) } + putAll(additionalQueryParams) + } + .build() override fun equals(other: Any?): Boolean { if (this === other) { @@ -190,14 +224,15 @@ private constructor( } return other is DocumentCreateParams && + constructPdf == other.constructPdf && documentCreate == other.documentCreate && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams } override fun hashCode(): Int = - Objects.hash(documentCreate, additionalHeaders, additionalQueryParams) + Objects.hash(constructPdf, documentCreate, additionalHeaders, additionalQueryParams) override fun toString() = - "DocumentCreateParams{documentCreate=$documentCreate, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "DocumentCreateParams{constructPdf=$constructPdf, documentCreate=$documentCreate, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateParamsTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateParamsTest.kt index fd62996..08476ce 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateParamsTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/models/documents/DocumentCreateParamsTest.kt @@ -2,6 +2,7 @@ package com.e_invoice.api.models.documents +import com.e_invoice.api.core.http.QueryParams import com.e_invoice.api.models.inbox.DocumentState import java.time.LocalDate import org.assertj.core.api.Assertions.assertThat @@ -12,6 +13,7 @@ internal class DocumentCreateParamsTest { @Test fun create() { DocumentCreateParams.builder() + .constructPdf(true) .documentCreate( DocumentCreate.builder() .addAllowance( @@ -137,10 +139,156 @@ internal class DocumentCreateParamsTest { .build() } + @Test + fun queryParams() { + val params = + DocumentCreateParams.builder() + .constructPdf(true) + .documentCreate( + DocumentCreate.builder() + .addAllowance( + DocumentCreate.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .taxCode(DocumentCreate.Allowance.TaxCode.AE) + .taxRate(0.0) + .build() + ) + .amountDue(0.0) + .addAttachment( + DocumentAttachmentCreate.builder() + .fileName("file_name") + .fileData("file_data") + .fileSize(0L) + .fileType("file_type") + .build() + ) + .billingAddress("billing_address") + .billingAddressRecipient("billing_address_recipient") + .addCharge( + DocumentCreate.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .taxCode(DocumentCreate.Charge.TaxCode.AE) + .taxRate("21.00") + .build() + ) + .currency(CurrencyCode.EUR) + .customerAddress("customer_address") + .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") + .customerEmail("customer_email") + .customerId("customer_id") + .customerName("customer_name") + .customerTaxId("BE1018265814") + .direction(DocumentDirection.INBOUND) + .documentType(DocumentType.INVOICE) + .dueDate(LocalDate.parse("2019-12-27")) + .invoiceDate(LocalDate.parse("2019-12-27")) + .invoiceId("invoice_id") + .invoiceTotal(0.0) + .addItem( + DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate(0.0) + .build() + ) + .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("21.00") + .build() + ) + .date(null) + .description("description") + .productCode("product_code") + .quantity(0.0) + .tax(0.0) + .taxRate("21.00") + .unit(UnitOfMeasureCode._10) + .unitPrice(0.0) + .build() + ) + .note("note") + .addPaymentDetail( + PaymentDetailCreate.builder() + .bankAccountNumber("bank_account_number") + .iban("iban") + .paymentReference("payment_reference") + .swift("swift") + .build() + ) + .paymentTerm("payment_term") + .previousUnpaidBalance(0.0) + .purchaseOrder("purchase_order") + .remittanceAddress("remittance_address") + .remittanceAddressRecipient("remittance_address_recipient") + .serviceAddress("service_address") + .serviceAddressRecipient("service_address_recipient") + .serviceEndDate(LocalDate.parse("2019-12-27")) + .serviceStartDate(LocalDate.parse("2019-12-27")) + .shippingAddress("shipping_address") + .shippingAddressRecipient("shipping_address_recipient") + .state(DocumentState.DRAFT) + .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) + .addTaxDetail( + DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() + ) + .totalDiscount(0.0) + .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") + .vendorAddress("vendor_address") + .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") + .vendorEmail("vendor_email") + .vendorName("vendor_name") + .vendorTaxId("BE1018265814") + .build() + ) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo(QueryParams.builder().put("construct_pdf", "true").build()) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + DocumentCreateParams.builder().documentCreate(DocumentCreate.builder().build()).build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } + @Test fun body() { val params = DocumentCreateParams.builder() + .constructPdf(true) .documentCreate( DocumentCreate.builder() .addAllowance( diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ErrorHandlingTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ErrorHandlingTest.kt index 586b80b..a2a4397 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ErrorHandlingTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ErrorHandlingTest.kt @@ -19,6 +19,7 @@ import com.e_invoice.api.errors.UnprocessableEntityException import com.e_invoice.api.models.documents.CurrencyCode import com.e_invoice.api.models.documents.DocumentAttachmentCreate import com.e_invoice.api.models.documents.DocumentCreate +import com.e_invoice.api.models.documents.DocumentCreateParams import com.e_invoice.api.models.documents.DocumentDirection import com.e_invoice.api.models.documents.DocumentType import com.e_invoice.api.models.documents.PaymentDetailCreate @@ -79,125 +80,137 @@ internal class ErrorHandlingTest { val e = assertThrows { documentService.create( - DocumentCreate.builder() - .addAllowance( - DocumentCreate.Allowance.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) - .build() - ) - .amountDue(0.0) - .addAttachment( - DocumentAttachmentCreate.builder() - .fileName("file_name") - .fileData("file_data") - .fileSize(0L) - .fileType("file_type") - .build() - ) - .billingAddress("billing_address") - .billingAddressRecipient("billing_address_recipient") - .addCharge( - DocumentCreate.Charge.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") - .build() - ) - .currency(CurrencyCode.EUR) - .customerAddress("customer_address") - .customerAddressRecipient("customer_address_recipient") - .customerCompanyId("1018265814") - .customerEmail("customer_email") - .customerId("customer_id") - .customerName("customer_name") - .customerTaxId("BE1018265814") - .direction(DocumentDirection.INBOUND) - .documentType(DocumentType.INVOICE) - .dueDate(LocalDate.parse("2019-12-27")) - .invoiceDate(LocalDate.parse("2019-12-27")) - .invoiceId("invoice_id") - .invoiceTotal(0.0) - .addItem( - DocumentCreate.Item.builder() + DocumentCreateParams.builder() + .constructPdf(true) + .documentCreate( + DocumentCreate.builder() .addAllowance( - DocumentCreate.Item.Allowance.builder() + DocumentCreate.Allowance.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .taxCode(DocumentCreate.Allowance.TaxCode.AE) .taxRate(0.0) .build() ) - .amount(0.0) + .amountDue(0.0) + .addAttachment( + DocumentAttachmentCreate.builder() + .fileName("file_name") + .fileData("file_data") + .fileSize(0L) + .fileType("file_type") + .build() + ) + .billingAddress("billing_address") + .billingAddressRecipient("billing_address_recipient") .addCharge( - DocumentCreate.Item.Charge.builder() + DocumentCreate.Charge.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .taxCode(DocumentCreate.Charge.TaxCode.AE) .taxRate("21.00") .build() ) - .date(null) - .description("description") - .productCode("product_code") - .quantity(0.0) - .tax(0.0) - .taxRate("21.00") - .unit(UnitOfMeasureCode._10) - .unitPrice(0.0) - .build() - ) - .note("note") - .addPaymentDetail( - PaymentDetailCreate.builder() - .bankAccountNumber("bank_account_number") - .iban("iban") - .paymentReference("payment_reference") - .swift("swift") + .currency(CurrencyCode.EUR) + .customerAddress("customer_address") + .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") + .customerEmail("customer_email") + .customerId("customer_id") + .customerName("customer_name") + .customerTaxId("BE1018265814") + .direction(DocumentDirection.INBOUND) + .documentType(DocumentType.INVOICE) + .dueDate(LocalDate.parse("2019-12-27")) + .invoiceDate(LocalDate.parse("2019-12-27")) + .invoiceId("invoice_id") + .invoiceTotal(0.0) + .addItem( + DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Allowance.ReasonCode._41 + ) + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate(0.0) + .build() + ) + .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Charge.ReasonCode.AA + ) + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("21.00") + .build() + ) + .date(null) + .description("description") + .productCode("product_code") + .quantity(0.0) + .tax(0.0) + .taxRate("21.00") + .unit(UnitOfMeasureCode._10) + .unitPrice(0.0) + .build() + ) + .note("note") + .addPaymentDetail( + PaymentDetailCreate.builder() + .bankAccountNumber("bank_account_number") + .iban("iban") + .paymentReference("payment_reference") + .swift("swift") + .build() + ) + .paymentTerm("payment_term") + .previousUnpaidBalance(0.0) + .purchaseOrder("purchase_order") + .remittanceAddress("remittance_address") + .remittanceAddressRecipient("remittance_address_recipient") + .serviceAddress("service_address") + .serviceAddressRecipient("service_address_recipient") + .serviceEndDate(LocalDate.parse("2019-12-27")) + .serviceStartDate(LocalDate.parse("2019-12-27")) + .shippingAddress("shipping_address") + .shippingAddressRecipient("shipping_address_recipient") + .state(DocumentState.DRAFT) + .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) + .addTaxDetail( + DocumentCreate.TaxDetail.builder() + .amount(0.0) + .rate("rate") + .build() + ) + .totalDiscount(0.0) + .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") + .vendorAddress("vendor_address") + .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") + .vendorEmail("vendor_email") + .vendorName("vendor_name") + .vendorTaxId("BE1018265814") .build() ) - .paymentTerm("payment_term") - .previousUnpaidBalance(0.0) - .purchaseOrder("purchase_order") - .remittanceAddress("remittance_address") - .remittanceAddressRecipient("remittance_address_recipient") - .serviceAddress("service_address") - .serviceAddressRecipient("service_address_recipient") - .serviceEndDate(LocalDate.parse("2019-12-27")) - .serviceStartDate(LocalDate.parse("2019-12-27")) - .shippingAddress("shipping_address") - .shippingAddressRecipient("shipping_address_recipient") - .state(DocumentState.DRAFT) - .subtotal(0.0) - .taxCode(DocumentCreate.TaxCode.AE) - .addTaxDetail( - DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() - ) - .totalDiscount(0.0) - .totalTax(0.0) - .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) - .vatexNote("vatex_note") - .vendorAddress("vendor_address") - .vendorAddressRecipient("vendor_address_recipient") - .vendorCompanyId("1018265814") - .vendorEmail("vendor_email") - .vendorName("vendor_name") - .vendorTaxId("BE1018265814") .build() ) } @@ -220,125 +233,137 @@ internal class ErrorHandlingTest { val e = assertThrows { documentService.create( - DocumentCreate.builder() - .addAllowance( - DocumentCreate.Allowance.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) - .build() - ) - .amountDue(0.0) - .addAttachment( - DocumentAttachmentCreate.builder() - .fileName("file_name") - .fileData("file_data") - .fileSize(0L) - .fileType("file_type") - .build() - ) - .billingAddress("billing_address") - .billingAddressRecipient("billing_address_recipient") - .addCharge( - DocumentCreate.Charge.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") - .build() - ) - .currency(CurrencyCode.EUR) - .customerAddress("customer_address") - .customerAddressRecipient("customer_address_recipient") - .customerCompanyId("1018265814") - .customerEmail("customer_email") - .customerId("customer_id") - .customerName("customer_name") - .customerTaxId("BE1018265814") - .direction(DocumentDirection.INBOUND) - .documentType(DocumentType.INVOICE) - .dueDate(LocalDate.parse("2019-12-27")) - .invoiceDate(LocalDate.parse("2019-12-27")) - .invoiceId("invoice_id") - .invoiceTotal(0.0) - .addItem( - DocumentCreate.Item.builder() + DocumentCreateParams.builder() + .constructPdf(true) + .documentCreate( + DocumentCreate.builder() .addAllowance( - DocumentCreate.Item.Allowance.builder() + DocumentCreate.Allowance.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .taxCode(DocumentCreate.Allowance.TaxCode.AE) .taxRate(0.0) .build() ) - .amount(0.0) + .amountDue(0.0) + .addAttachment( + DocumentAttachmentCreate.builder() + .fileName("file_name") + .fileData("file_data") + .fileSize(0L) + .fileType("file_type") + .build() + ) + .billingAddress("billing_address") + .billingAddressRecipient("billing_address_recipient") .addCharge( - DocumentCreate.Item.Charge.builder() + DocumentCreate.Charge.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .taxCode(DocumentCreate.Charge.TaxCode.AE) .taxRate("21.00") .build() ) - .date(null) - .description("description") - .productCode("product_code") - .quantity(0.0) - .tax(0.0) - .taxRate("21.00") - .unit(UnitOfMeasureCode._10) - .unitPrice(0.0) - .build() - ) - .note("note") - .addPaymentDetail( - PaymentDetailCreate.builder() - .bankAccountNumber("bank_account_number") - .iban("iban") - .paymentReference("payment_reference") - .swift("swift") + .currency(CurrencyCode.EUR) + .customerAddress("customer_address") + .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") + .customerEmail("customer_email") + .customerId("customer_id") + .customerName("customer_name") + .customerTaxId("BE1018265814") + .direction(DocumentDirection.INBOUND) + .documentType(DocumentType.INVOICE) + .dueDate(LocalDate.parse("2019-12-27")) + .invoiceDate(LocalDate.parse("2019-12-27")) + .invoiceId("invoice_id") + .invoiceTotal(0.0) + .addItem( + DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Allowance.ReasonCode._41 + ) + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate(0.0) + .build() + ) + .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Charge.ReasonCode.AA + ) + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("21.00") + .build() + ) + .date(null) + .description("description") + .productCode("product_code") + .quantity(0.0) + .tax(0.0) + .taxRate("21.00") + .unit(UnitOfMeasureCode._10) + .unitPrice(0.0) + .build() + ) + .note("note") + .addPaymentDetail( + PaymentDetailCreate.builder() + .bankAccountNumber("bank_account_number") + .iban("iban") + .paymentReference("payment_reference") + .swift("swift") + .build() + ) + .paymentTerm("payment_term") + .previousUnpaidBalance(0.0) + .purchaseOrder("purchase_order") + .remittanceAddress("remittance_address") + .remittanceAddressRecipient("remittance_address_recipient") + .serviceAddress("service_address") + .serviceAddressRecipient("service_address_recipient") + .serviceEndDate(LocalDate.parse("2019-12-27")) + .serviceStartDate(LocalDate.parse("2019-12-27")) + .shippingAddress("shipping_address") + .shippingAddressRecipient("shipping_address_recipient") + .state(DocumentState.DRAFT) + .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) + .addTaxDetail( + DocumentCreate.TaxDetail.builder() + .amount(0.0) + .rate("rate") + .build() + ) + .totalDiscount(0.0) + .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") + .vendorAddress("vendor_address") + .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") + .vendorEmail("vendor_email") + .vendorName("vendor_name") + .vendorTaxId("BE1018265814") .build() ) - .paymentTerm("payment_term") - .previousUnpaidBalance(0.0) - .purchaseOrder("purchase_order") - .remittanceAddress("remittance_address") - .remittanceAddressRecipient("remittance_address_recipient") - .serviceAddress("service_address") - .serviceAddressRecipient("service_address_recipient") - .serviceEndDate(LocalDate.parse("2019-12-27")) - .serviceStartDate(LocalDate.parse("2019-12-27")) - .shippingAddress("shipping_address") - .shippingAddressRecipient("shipping_address_recipient") - .state(DocumentState.DRAFT) - .subtotal(0.0) - .taxCode(DocumentCreate.TaxCode.AE) - .addTaxDetail( - DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() - ) - .totalDiscount(0.0) - .totalTax(0.0) - .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) - .vatexNote("vatex_note") - .vendorAddress("vendor_address") - .vendorAddressRecipient("vendor_address_recipient") - .vendorCompanyId("1018265814") - .vendorEmail("vendor_email") - .vendorName("vendor_name") - .vendorTaxId("BE1018265814") .build() ) } @@ -361,125 +386,137 @@ internal class ErrorHandlingTest { val e = assertThrows { documentService.create( - DocumentCreate.builder() - .addAllowance( - DocumentCreate.Allowance.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) - .build() - ) - .amountDue(0.0) - .addAttachment( - DocumentAttachmentCreate.builder() - .fileName("file_name") - .fileData("file_data") - .fileSize(0L) - .fileType("file_type") - .build() - ) - .billingAddress("billing_address") - .billingAddressRecipient("billing_address_recipient") - .addCharge( - DocumentCreate.Charge.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") - .build() - ) - .currency(CurrencyCode.EUR) - .customerAddress("customer_address") - .customerAddressRecipient("customer_address_recipient") - .customerCompanyId("1018265814") - .customerEmail("customer_email") - .customerId("customer_id") - .customerName("customer_name") - .customerTaxId("BE1018265814") - .direction(DocumentDirection.INBOUND) - .documentType(DocumentType.INVOICE) - .dueDate(LocalDate.parse("2019-12-27")) - .invoiceDate(LocalDate.parse("2019-12-27")) - .invoiceId("invoice_id") - .invoiceTotal(0.0) - .addItem( - DocumentCreate.Item.builder() + DocumentCreateParams.builder() + .constructPdf(true) + .documentCreate( + DocumentCreate.builder() .addAllowance( - DocumentCreate.Item.Allowance.builder() + DocumentCreate.Allowance.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .taxCode(DocumentCreate.Allowance.TaxCode.AE) .taxRate(0.0) .build() ) - .amount(0.0) + .amountDue(0.0) + .addAttachment( + DocumentAttachmentCreate.builder() + .fileName("file_name") + .fileData("file_data") + .fileSize(0L) + .fileType("file_type") + .build() + ) + .billingAddress("billing_address") + .billingAddressRecipient("billing_address_recipient") .addCharge( - DocumentCreate.Item.Charge.builder() + DocumentCreate.Charge.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .taxCode(DocumentCreate.Charge.TaxCode.AE) .taxRate("21.00") .build() ) - .date(null) - .description("description") - .productCode("product_code") - .quantity(0.0) - .tax(0.0) - .taxRate("21.00") - .unit(UnitOfMeasureCode._10) - .unitPrice(0.0) - .build() - ) - .note("note") - .addPaymentDetail( - PaymentDetailCreate.builder() - .bankAccountNumber("bank_account_number") - .iban("iban") - .paymentReference("payment_reference") - .swift("swift") + .currency(CurrencyCode.EUR) + .customerAddress("customer_address") + .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") + .customerEmail("customer_email") + .customerId("customer_id") + .customerName("customer_name") + .customerTaxId("BE1018265814") + .direction(DocumentDirection.INBOUND) + .documentType(DocumentType.INVOICE) + .dueDate(LocalDate.parse("2019-12-27")) + .invoiceDate(LocalDate.parse("2019-12-27")) + .invoiceId("invoice_id") + .invoiceTotal(0.0) + .addItem( + DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Allowance.ReasonCode._41 + ) + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate(0.0) + .build() + ) + .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Charge.ReasonCode.AA + ) + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("21.00") + .build() + ) + .date(null) + .description("description") + .productCode("product_code") + .quantity(0.0) + .tax(0.0) + .taxRate("21.00") + .unit(UnitOfMeasureCode._10) + .unitPrice(0.0) + .build() + ) + .note("note") + .addPaymentDetail( + PaymentDetailCreate.builder() + .bankAccountNumber("bank_account_number") + .iban("iban") + .paymentReference("payment_reference") + .swift("swift") + .build() + ) + .paymentTerm("payment_term") + .previousUnpaidBalance(0.0) + .purchaseOrder("purchase_order") + .remittanceAddress("remittance_address") + .remittanceAddressRecipient("remittance_address_recipient") + .serviceAddress("service_address") + .serviceAddressRecipient("service_address_recipient") + .serviceEndDate(LocalDate.parse("2019-12-27")) + .serviceStartDate(LocalDate.parse("2019-12-27")) + .shippingAddress("shipping_address") + .shippingAddressRecipient("shipping_address_recipient") + .state(DocumentState.DRAFT) + .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) + .addTaxDetail( + DocumentCreate.TaxDetail.builder() + .amount(0.0) + .rate("rate") + .build() + ) + .totalDiscount(0.0) + .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") + .vendorAddress("vendor_address") + .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") + .vendorEmail("vendor_email") + .vendorName("vendor_name") + .vendorTaxId("BE1018265814") .build() ) - .paymentTerm("payment_term") - .previousUnpaidBalance(0.0) - .purchaseOrder("purchase_order") - .remittanceAddress("remittance_address") - .remittanceAddressRecipient("remittance_address_recipient") - .serviceAddress("service_address") - .serviceAddressRecipient("service_address_recipient") - .serviceEndDate(LocalDate.parse("2019-12-27")) - .serviceStartDate(LocalDate.parse("2019-12-27")) - .shippingAddress("shipping_address") - .shippingAddressRecipient("shipping_address_recipient") - .state(DocumentState.DRAFT) - .subtotal(0.0) - .taxCode(DocumentCreate.TaxCode.AE) - .addTaxDetail( - DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() - ) - .totalDiscount(0.0) - .totalTax(0.0) - .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) - .vatexNote("vatex_note") - .vendorAddress("vendor_address") - .vendorAddressRecipient("vendor_address_recipient") - .vendorCompanyId("1018265814") - .vendorEmail("vendor_email") - .vendorName("vendor_name") - .vendorTaxId("BE1018265814") .build() ) } @@ -502,125 +539,137 @@ internal class ErrorHandlingTest { val e = assertThrows { documentService.create( - DocumentCreate.builder() - .addAllowance( - DocumentCreate.Allowance.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) - .build() - ) - .amountDue(0.0) - .addAttachment( - DocumentAttachmentCreate.builder() - .fileName("file_name") - .fileData("file_data") - .fileSize(0L) - .fileType("file_type") - .build() - ) - .billingAddress("billing_address") - .billingAddressRecipient("billing_address_recipient") - .addCharge( - DocumentCreate.Charge.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") - .build() - ) - .currency(CurrencyCode.EUR) - .customerAddress("customer_address") - .customerAddressRecipient("customer_address_recipient") - .customerCompanyId("1018265814") - .customerEmail("customer_email") - .customerId("customer_id") - .customerName("customer_name") - .customerTaxId("BE1018265814") - .direction(DocumentDirection.INBOUND) - .documentType(DocumentType.INVOICE) - .dueDate(LocalDate.parse("2019-12-27")) - .invoiceDate(LocalDate.parse("2019-12-27")) - .invoiceId("invoice_id") - .invoiceTotal(0.0) - .addItem( - DocumentCreate.Item.builder() + DocumentCreateParams.builder() + .constructPdf(true) + .documentCreate( + DocumentCreate.builder() .addAllowance( - DocumentCreate.Item.Allowance.builder() + DocumentCreate.Allowance.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .taxCode(DocumentCreate.Allowance.TaxCode.AE) .taxRate(0.0) .build() ) - .amount(0.0) + .amountDue(0.0) + .addAttachment( + DocumentAttachmentCreate.builder() + .fileName("file_name") + .fileData("file_data") + .fileSize(0L) + .fileType("file_type") + .build() + ) + .billingAddress("billing_address") + .billingAddressRecipient("billing_address_recipient") .addCharge( - DocumentCreate.Item.Charge.builder() + DocumentCreate.Charge.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .taxCode(DocumentCreate.Charge.TaxCode.AE) .taxRate("21.00") .build() ) - .date(null) - .description("description") - .productCode("product_code") - .quantity(0.0) - .tax(0.0) - .taxRate("21.00") - .unit(UnitOfMeasureCode._10) - .unitPrice(0.0) - .build() - ) - .note("note") - .addPaymentDetail( - PaymentDetailCreate.builder() - .bankAccountNumber("bank_account_number") - .iban("iban") - .paymentReference("payment_reference") - .swift("swift") + .currency(CurrencyCode.EUR) + .customerAddress("customer_address") + .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") + .customerEmail("customer_email") + .customerId("customer_id") + .customerName("customer_name") + .customerTaxId("BE1018265814") + .direction(DocumentDirection.INBOUND) + .documentType(DocumentType.INVOICE) + .dueDate(LocalDate.parse("2019-12-27")) + .invoiceDate(LocalDate.parse("2019-12-27")) + .invoiceId("invoice_id") + .invoiceTotal(0.0) + .addItem( + DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Allowance.ReasonCode._41 + ) + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate(0.0) + .build() + ) + .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Charge.ReasonCode.AA + ) + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("21.00") + .build() + ) + .date(null) + .description("description") + .productCode("product_code") + .quantity(0.0) + .tax(0.0) + .taxRate("21.00") + .unit(UnitOfMeasureCode._10) + .unitPrice(0.0) + .build() + ) + .note("note") + .addPaymentDetail( + PaymentDetailCreate.builder() + .bankAccountNumber("bank_account_number") + .iban("iban") + .paymentReference("payment_reference") + .swift("swift") + .build() + ) + .paymentTerm("payment_term") + .previousUnpaidBalance(0.0) + .purchaseOrder("purchase_order") + .remittanceAddress("remittance_address") + .remittanceAddressRecipient("remittance_address_recipient") + .serviceAddress("service_address") + .serviceAddressRecipient("service_address_recipient") + .serviceEndDate(LocalDate.parse("2019-12-27")) + .serviceStartDate(LocalDate.parse("2019-12-27")) + .shippingAddress("shipping_address") + .shippingAddressRecipient("shipping_address_recipient") + .state(DocumentState.DRAFT) + .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) + .addTaxDetail( + DocumentCreate.TaxDetail.builder() + .amount(0.0) + .rate("rate") + .build() + ) + .totalDiscount(0.0) + .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") + .vendorAddress("vendor_address") + .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") + .vendorEmail("vendor_email") + .vendorName("vendor_name") + .vendorTaxId("BE1018265814") .build() ) - .paymentTerm("payment_term") - .previousUnpaidBalance(0.0) - .purchaseOrder("purchase_order") - .remittanceAddress("remittance_address") - .remittanceAddressRecipient("remittance_address_recipient") - .serviceAddress("service_address") - .serviceAddressRecipient("service_address_recipient") - .serviceEndDate(LocalDate.parse("2019-12-27")) - .serviceStartDate(LocalDate.parse("2019-12-27")) - .shippingAddress("shipping_address") - .shippingAddressRecipient("shipping_address_recipient") - .state(DocumentState.DRAFT) - .subtotal(0.0) - .taxCode(DocumentCreate.TaxCode.AE) - .addTaxDetail( - DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() - ) - .totalDiscount(0.0) - .totalTax(0.0) - .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) - .vatexNote("vatex_note") - .vendorAddress("vendor_address") - .vendorAddressRecipient("vendor_address_recipient") - .vendorCompanyId("1018265814") - .vendorEmail("vendor_email") - .vendorName("vendor_name") - .vendorTaxId("BE1018265814") .build() ) } @@ -643,125 +692,137 @@ internal class ErrorHandlingTest { val e = assertThrows { documentService.create( - DocumentCreate.builder() - .addAllowance( - DocumentCreate.Allowance.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) - .build() - ) - .amountDue(0.0) - .addAttachment( - DocumentAttachmentCreate.builder() - .fileName("file_name") - .fileData("file_data") - .fileSize(0L) - .fileType("file_type") - .build() - ) - .billingAddress("billing_address") - .billingAddressRecipient("billing_address_recipient") - .addCharge( - DocumentCreate.Charge.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") - .build() - ) - .currency(CurrencyCode.EUR) - .customerAddress("customer_address") - .customerAddressRecipient("customer_address_recipient") - .customerCompanyId("1018265814") - .customerEmail("customer_email") - .customerId("customer_id") - .customerName("customer_name") - .customerTaxId("BE1018265814") - .direction(DocumentDirection.INBOUND) - .documentType(DocumentType.INVOICE) - .dueDate(LocalDate.parse("2019-12-27")) - .invoiceDate(LocalDate.parse("2019-12-27")) - .invoiceId("invoice_id") - .invoiceTotal(0.0) - .addItem( - DocumentCreate.Item.builder() + DocumentCreateParams.builder() + .constructPdf(true) + .documentCreate( + DocumentCreate.builder() .addAllowance( - DocumentCreate.Item.Allowance.builder() + DocumentCreate.Allowance.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .taxCode(DocumentCreate.Allowance.TaxCode.AE) .taxRate(0.0) .build() ) - .amount(0.0) + .amountDue(0.0) + .addAttachment( + DocumentAttachmentCreate.builder() + .fileName("file_name") + .fileData("file_data") + .fileSize(0L) + .fileType("file_type") + .build() + ) + .billingAddress("billing_address") + .billingAddressRecipient("billing_address_recipient") .addCharge( - DocumentCreate.Item.Charge.builder() + DocumentCreate.Charge.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .taxCode(DocumentCreate.Charge.TaxCode.AE) .taxRate("21.00") .build() ) - .date(null) - .description("description") - .productCode("product_code") - .quantity(0.0) - .tax(0.0) - .taxRate("21.00") - .unit(UnitOfMeasureCode._10) - .unitPrice(0.0) - .build() - ) - .note("note") - .addPaymentDetail( - PaymentDetailCreate.builder() - .bankAccountNumber("bank_account_number") - .iban("iban") - .paymentReference("payment_reference") - .swift("swift") + .currency(CurrencyCode.EUR) + .customerAddress("customer_address") + .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") + .customerEmail("customer_email") + .customerId("customer_id") + .customerName("customer_name") + .customerTaxId("BE1018265814") + .direction(DocumentDirection.INBOUND) + .documentType(DocumentType.INVOICE) + .dueDate(LocalDate.parse("2019-12-27")) + .invoiceDate(LocalDate.parse("2019-12-27")) + .invoiceId("invoice_id") + .invoiceTotal(0.0) + .addItem( + DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Allowance.ReasonCode._41 + ) + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate(0.0) + .build() + ) + .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Charge.ReasonCode.AA + ) + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("21.00") + .build() + ) + .date(null) + .description("description") + .productCode("product_code") + .quantity(0.0) + .tax(0.0) + .taxRate("21.00") + .unit(UnitOfMeasureCode._10) + .unitPrice(0.0) + .build() + ) + .note("note") + .addPaymentDetail( + PaymentDetailCreate.builder() + .bankAccountNumber("bank_account_number") + .iban("iban") + .paymentReference("payment_reference") + .swift("swift") + .build() + ) + .paymentTerm("payment_term") + .previousUnpaidBalance(0.0) + .purchaseOrder("purchase_order") + .remittanceAddress("remittance_address") + .remittanceAddressRecipient("remittance_address_recipient") + .serviceAddress("service_address") + .serviceAddressRecipient("service_address_recipient") + .serviceEndDate(LocalDate.parse("2019-12-27")) + .serviceStartDate(LocalDate.parse("2019-12-27")) + .shippingAddress("shipping_address") + .shippingAddressRecipient("shipping_address_recipient") + .state(DocumentState.DRAFT) + .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) + .addTaxDetail( + DocumentCreate.TaxDetail.builder() + .amount(0.0) + .rate("rate") + .build() + ) + .totalDiscount(0.0) + .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") + .vendorAddress("vendor_address") + .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") + .vendorEmail("vendor_email") + .vendorName("vendor_name") + .vendorTaxId("BE1018265814") .build() ) - .paymentTerm("payment_term") - .previousUnpaidBalance(0.0) - .purchaseOrder("purchase_order") - .remittanceAddress("remittance_address") - .remittanceAddressRecipient("remittance_address_recipient") - .serviceAddress("service_address") - .serviceAddressRecipient("service_address_recipient") - .serviceEndDate(LocalDate.parse("2019-12-27")) - .serviceStartDate(LocalDate.parse("2019-12-27")) - .shippingAddress("shipping_address") - .shippingAddressRecipient("shipping_address_recipient") - .state(DocumentState.DRAFT) - .subtotal(0.0) - .taxCode(DocumentCreate.TaxCode.AE) - .addTaxDetail( - DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() - ) - .totalDiscount(0.0) - .totalTax(0.0) - .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) - .vatexNote("vatex_note") - .vendorAddress("vendor_address") - .vendorAddressRecipient("vendor_address_recipient") - .vendorCompanyId("1018265814") - .vendorEmail("vendor_email") - .vendorName("vendor_name") - .vendorTaxId("BE1018265814") .build() ) } @@ -784,125 +845,137 @@ internal class ErrorHandlingTest { val e = assertThrows { documentService.create( - DocumentCreate.builder() - .addAllowance( - DocumentCreate.Allowance.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) - .build() - ) - .amountDue(0.0) - .addAttachment( - DocumentAttachmentCreate.builder() - .fileName("file_name") - .fileData("file_data") - .fileSize(0L) - .fileType("file_type") - .build() - ) - .billingAddress("billing_address") - .billingAddressRecipient("billing_address_recipient") - .addCharge( - DocumentCreate.Charge.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") - .build() - ) - .currency(CurrencyCode.EUR) - .customerAddress("customer_address") - .customerAddressRecipient("customer_address_recipient") - .customerCompanyId("1018265814") - .customerEmail("customer_email") - .customerId("customer_id") - .customerName("customer_name") - .customerTaxId("BE1018265814") - .direction(DocumentDirection.INBOUND) - .documentType(DocumentType.INVOICE) - .dueDate(LocalDate.parse("2019-12-27")) - .invoiceDate(LocalDate.parse("2019-12-27")) - .invoiceId("invoice_id") - .invoiceTotal(0.0) - .addItem( - DocumentCreate.Item.builder() + DocumentCreateParams.builder() + .constructPdf(true) + .documentCreate( + DocumentCreate.builder() .addAllowance( - DocumentCreate.Item.Allowance.builder() + DocumentCreate.Allowance.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .taxCode(DocumentCreate.Allowance.TaxCode.AE) .taxRate(0.0) .build() ) - .amount(0.0) + .amountDue(0.0) + .addAttachment( + DocumentAttachmentCreate.builder() + .fileName("file_name") + .fileData("file_data") + .fileSize(0L) + .fileType("file_type") + .build() + ) + .billingAddress("billing_address") + .billingAddressRecipient("billing_address_recipient") .addCharge( - DocumentCreate.Item.Charge.builder() + DocumentCreate.Charge.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .taxCode(DocumentCreate.Charge.TaxCode.AE) .taxRate("21.00") .build() ) - .date(null) - .description("description") - .productCode("product_code") - .quantity(0.0) - .tax(0.0) - .taxRate("21.00") - .unit(UnitOfMeasureCode._10) - .unitPrice(0.0) - .build() - ) - .note("note") - .addPaymentDetail( - PaymentDetailCreate.builder() - .bankAccountNumber("bank_account_number") - .iban("iban") - .paymentReference("payment_reference") - .swift("swift") + .currency(CurrencyCode.EUR) + .customerAddress("customer_address") + .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") + .customerEmail("customer_email") + .customerId("customer_id") + .customerName("customer_name") + .customerTaxId("BE1018265814") + .direction(DocumentDirection.INBOUND) + .documentType(DocumentType.INVOICE) + .dueDate(LocalDate.parse("2019-12-27")) + .invoiceDate(LocalDate.parse("2019-12-27")) + .invoiceId("invoice_id") + .invoiceTotal(0.0) + .addItem( + DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Allowance.ReasonCode._41 + ) + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate(0.0) + .build() + ) + .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Charge.ReasonCode.AA + ) + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("21.00") + .build() + ) + .date(null) + .description("description") + .productCode("product_code") + .quantity(0.0) + .tax(0.0) + .taxRate("21.00") + .unit(UnitOfMeasureCode._10) + .unitPrice(0.0) + .build() + ) + .note("note") + .addPaymentDetail( + PaymentDetailCreate.builder() + .bankAccountNumber("bank_account_number") + .iban("iban") + .paymentReference("payment_reference") + .swift("swift") + .build() + ) + .paymentTerm("payment_term") + .previousUnpaidBalance(0.0) + .purchaseOrder("purchase_order") + .remittanceAddress("remittance_address") + .remittanceAddressRecipient("remittance_address_recipient") + .serviceAddress("service_address") + .serviceAddressRecipient("service_address_recipient") + .serviceEndDate(LocalDate.parse("2019-12-27")) + .serviceStartDate(LocalDate.parse("2019-12-27")) + .shippingAddress("shipping_address") + .shippingAddressRecipient("shipping_address_recipient") + .state(DocumentState.DRAFT) + .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) + .addTaxDetail( + DocumentCreate.TaxDetail.builder() + .amount(0.0) + .rate("rate") + .build() + ) + .totalDiscount(0.0) + .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") + .vendorAddress("vendor_address") + .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") + .vendorEmail("vendor_email") + .vendorName("vendor_name") + .vendorTaxId("BE1018265814") .build() ) - .paymentTerm("payment_term") - .previousUnpaidBalance(0.0) - .purchaseOrder("purchase_order") - .remittanceAddress("remittance_address") - .remittanceAddressRecipient("remittance_address_recipient") - .serviceAddress("service_address") - .serviceAddressRecipient("service_address_recipient") - .serviceEndDate(LocalDate.parse("2019-12-27")) - .serviceStartDate(LocalDate.parse("2019-12-27")) - .shippingAddress("shipping_address") - .shippingAddressRecipient("shipping_address_recipient") - .state(DocumentState.DRAFT) - .subtotal(0.0) - .taxCode(DocumentCreate.TaxCode.AE) - .addTaxDetail( - DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() - ) - .totalDiscount(0.0) - .totalTax(0.0) - .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) - .vatexNote("vatex_note") - .vendorAddress("vendor_address") - .vendorAddressRecipient("vendor_address_recipient") - .vendorCompanyId("1018265814") - .vendorEmail("vendor_email") - .vendorName("vendor_name") - .vendorTaxId("BE1018265814") .build() ) } @@ -925,125 +998,137 @@ internal class ErrorHandlingTest { val e = assertThrows { documentService.create( - DocumentCreate.builder() - .addAllowance( - DocumentCreate.Allowance.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) - .build() - ) - .amountDue(0.0) - .addAttachment( - DocumentAttachmentCreate.builder() - .fileName("file_name") - .fileData("file_data") - .fileSize(0L) - .fileType("file_type") - .build() - ) - .billingAddress("billing_address") - .billingAddressRecipient("billing_address_recipient") - .addCharge( - DocumentCreate.Charge.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") - .build() - ) - .currency(CurrencyCode.EUR) - .customerAddress("customer_address") - .customerAddressRecipient("customer_address_recipient") - .customerCompanyId("1018265814") - .customerEmail("customer_email") - .customerId("customer_id") - .customerName("customer_name") - .customerTaxId("BE1018265814") - .direction(DocumentDirection.INBOUND) - .documentType(DocumentType.INVOICE) - .dueDate(LocalDate.parse("2019-12-27")) - .invoiceDate(LocalDate.parse("2019-12-27")) - .invoiceId("invoice_id") - .invoiceTotal(0.0) - .addItem( - DocumentCreate.Item.builder() + DocumentCreateParams.builder() + .constructPdf(true) + .documentCreate( + DocumentCreate.builder() .addAllowance( - DocumentCreate.Item.Allowance.builder() + DocumentCreate.Allowance.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .taxCode(DocumentCreate.Allowance.TaxCode.AE) .taxRate(0.0) .build() ) - .amount(0.0) + .amountDue(0.0) + .addAttachment( + DocumentAttachmentCreate.builder() + .fileName("file_name") + .fileData("file_data") + .fileSize(0L) + .fileType("file_type") + .build() + ) + .billingAddress("billing_address") + .billingAddressRecipient("billing_address_recipient") .addCharge( - DocumentCreate.Item.Charge.builder() + DocumentCreate.Charge.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .taxCode(DocumentCreate.Charge.TaxCode.AE) .taxRate("21.00") .build() ) - .date(null) - .description("description") - .productCode("product_code") - .quantity(0.0) - .tax(0.0) - .taxRate("21.00") - .unit(UnitOfMeasureCode._10) - .unitPrice(0.0) - .build() - ) - .note("note") - .addPaymentDetail( - PaymentDetailCreate.builder() - .bankAccountNumber("bank_account_number") - .iban("iban") - .paymentReference("payment_reference") - .swift("swift") + .currency(CurrencyCode.EUR) + .customerAddress("customer_address") + .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") + .customerEmail("customer_email") + .customerId("customer_id") + .customerName("customer_name") + .customerTaxId("BE1018265814") + .direction(DocumentDirection.INBOUND) + .documentType(DocumentType.INVOICE) + .dueDate(LocalDate.parse("2019-12-27")) + .invoiceDate(LocalDate.parse("2019-12-27")) + .invoiceId("invoice_id") + .invoiceTotal(0.0) + .addItem( + DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Allowance.ReasonCode._41 + ) + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate(0.0) + .build() + ) + .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Charge.ReasonCode.AA + ) + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("21.00") + .build() + ) + .date(null) + .description("description") + .productCode("product_code") + .quantity(0.0) + .tax(0.0) + .taxRate("21.00") + .unit(UnitOfMeasureCode._10) + .unitPrice(0.0) + .build() + ) + .note("note") + .addPaymentDetail( + PaymentDetailCreate.builder() + .bankAccountNumber("bank_account_number") + .iban("iban") + .paymentReference("payment_reference") + .swift("swift") + .build() + ) + .paymentTerm("payment_term") + .previousUnpaidBalance(0.0) + .purchaseOrder("purchase_order") + .remittanceAddress("remittance_address") + .remittanceAddressRecipient("remittance_address_recipient") + .serviceAddress("service_address") + .serviceAddressRecipient("service_address_recipient") + .serviceEndDate(LocalDate.parse("2019-12-27")) + .serviceStartDate(LocalDate.parse("2019-12-27")) + .shippingAddress("shipping_address") + .shippingAddressRecipient("shipping_address_recipient") + .state(DocumentState.DRAFT) + .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) + .addTaxDetail( + DocumentCreate.TaxDetail.builder() + .amount(0.0) + .rate("rate") + .build() + ) + .totalDiscount(0.0) + .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") + .vendorAddress("vendor_address") + .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") + .vendorEmail("vendor_email") + .vendorName("vendor_name") + .vendorTaxId("BE1018265814") .build() ) - .paymentTerm("payment_term") - .previousUnpaidBalance(0.0) - .purchaseOrder("purchase_order") - .remittanceAddress("remittance_address") - .remittanceAddressRecipient("remittance_address_recipient") - .serviceAddress("service_address") - .serviceAddressRecipient("service_address_recipient") - .serviceEndDate(LocalDate.parse("2019-12-27")) - .serviceStartDate(LocalDate.parse("2019-12-27")) - .shippingAddress("shipping_address") - .shippingAddressRecipient("shipping_address_recipient") - .state(DocumentState.DRAFT) - .subtotal(0.0) - .taxCode(DocumentCreate.TaxCode.AE) - .addTaxDetail( - DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() - ) - .totalDiscount(0.0) - .totalTax(0.0) - .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) - .vatexNote("vatex_note") - .vendorAddress("vendor_address") - .vendorAddressRecipient("vendor_address_recipient") - .vendorCompanyId("1018265814") - .vendorEmail("vendor_email") - .vendorName("vendor_name") - .vendorTaxId("BE1018265814") .build() ) } @@ -1066,125 +1151,137 @@ internal class ErrorHandlingTest { val e = assertThrows { documentService.create( - DocumentCreate.builder() - .addAllowance( - DocumentCreate.Allowance.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) - .build() - ) - .amountDue(0.0) - .addAttachment( - DocumentAttachmentCreate.builder() - .fileName("file_name") - .fileData("file_data") - .fileSize(0L) - .fileType("file_type") - .build() - ) - .billingAddress("billing_address") - .billingAddressRecipient("billing_address_recipient") - .addCharge( - DocumentCreate.Charge.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") - .build() - ) - .currency(CurrencyCode.EUR) - .customerAddress("customer_address") - .customerAddressRecipient("customer_address_recipient") - .customerCompanyId("1018265814") - .customerEmail("customer_email") - .customerId("customer_id") - .customerName("customer_name") - .customerTaxId("BE1018265814") - .direction(DocumentDirection.INBOUND) - .documentType(DocumentType.INVOICE) - .dueDate(LocalDate.parse("2019-12-27")) - .invoiceDate(LocalDate.parse("2019-12-27")) - .invoiceId("invoice_id") - .invoiceTotal(0.0) - .addItem( - DocumentCreate.Item.builder() + DocumentCreateParams.builder() + .constructPdf(true) + .documentCreate( + DocumentCreate.builder() .addAllowance( - DocumentCreate.Item.Allowance.builder() + DocumentCreate.Allowance.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .taxCode(DocumentCreate.Allowance.TaxCode.AE) .taxRate(0.0) .build() ) - .amount(0.0) + .amountDue(0.0) + .addAttachment( + DocumentAttachmentCreate.builder() + .fileName("file_name") + .fileData("file_data") + .fileSize(0L) + .fileType("file_type") + .build() + ) + .billingAddress("billing_address") + .billingAddressRecipient("billing_address_recipient") .addCharge( - DocumentCreate.Item.Charge.builder() + DocumentCreate.Charge.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .taxCode(DocumentCreate.Charge.TaxCode.AE) .taxRate("21.00") .build() ) - .date(null) - .description("description") - .productCode("product_code") - .quantity(0.0) - .tax(0.0) - .taxRate("21.00") - .unit(UnitOfMeasureCode._10) - .unitPrice(0.0) - .build() - ) - .note("note") - .addPaymentDetail( - PaymentDetailCreate.builder() - .bankAccountNumber("bank_account_number") - .iban("iban") - .paymentReference("payment_reference") - .swift("swift") + .currency(CurrencyCode.EUR) + .customerAddress("customer_address") + .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") + .customerEmail("customer_email") + .customerId("customer_id") + .customerName("customer_name") + .customerTaxId("BE1018265814") + .direction(DocumentDirection.INBOUND) + .documentType(DocumentType.INVOICE) + .dueDate(LocalDate.parse("2019-12-27")) + .invoiceDate(LocalDate.parse("2019-12-27")) + .invoiceId("invoice_id") + .invoiceTotal(0.0) + .addItem( + DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Allowance.ReasonCode._41 + ) + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate(0.0) + .build() + ) + .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Charge.ReasonCode.AA + ) + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("21.00") + .build() + ) + .date(null) + .description("description") + .productCode("product_code") + .quantity(0.0) + .tax(0.0) + .taxRate("21.00") + .unit(UnitOfMeasureCode._10) + .unitPrice(0.0) + .build() + ) + .note("note") + .addPaymentDetail( + PaymentDetailCreate.builder() + .bankAccountNumber("bank_account_number") + .iban("iban") + .paymentReference("payment_reference") + .swift("swift") + .build() + ) + .paymentTerm("payment_term") + .previousUnpaidBalance(0.0) + .purchaseOrder("purchase_order") + .remittanceAddress("remittance_address") + .remittanceAddressRecipient("remittance_address_recipient") + .serviceAddress("service_address") + .serviceAddressRecipient("service_address_recipient") + .serviceEndDate(LocalDate.parse("2019-12-27")) + .serviceStartDate(LocalDate.parse("2019-12-27")) + .shippingAddress("shipping_address") + .shippingAddressRecipient("shipping_address_recipient") + .state(DocumentState.DRAFT) + .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) + .addTaxDetail( + DocumentCreate.TaxDetail.builder() + .amount(0.0) + .rate("rate") + .build() + ) + .totalDiscount(0.0) + .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") + .vendorAddress("vendor_address") + .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") + .vendorEmail("vendor_email") + .vendorName("vendor_name") + .vendorTaxId("BE1018265814") .build() ) - .paymentTerm("payment_term") - .previousUnpaidBalance(0.0) - .purchaseOrder("purchase_order") - .remittanceAddress("remittance_address") - .remittanceAddressRecipient("remittance_address_recipient") - .serviceAddress("service_address") - .serviceAddressRecipient("service_address_recipient") - .serviceEndDate(LocalDate.parse("2019-12-27")) - .serviceStartDate(LocalDate.parse("2019-12-27")) - .shippingAddress("shipping_address") - .shippingAddressRecipient("shipping_address_recipient") - .state(DocumentState.DRAFT) - .subtotal(0.0) - .taxCode(DocumentCreate.TaxCode.AE) - .addTaxDetail( - DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() - ) - .totalDiscount(0.0) - .totalTax(0.0) - .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) - .vatexNote("vatex_note") - .vendorAddress("vendor_address") - .vendorAddressRecipient("vendor_address_recipient") - .vendorCompanyId("1018265814") - .vendorEmail("vendor_email") - .vendorName("vendor_name") - .vendorTaxId("BE1018265814") .build() ) } @@ -1207,125 +1304,137 @@ internal class ErrorHandlingTest { val e = assertThrows { documentService.create( - DocumentCreate.builder() - .addAllowance( - DocumentCreate.Allowance.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) - .build() - ) - .amountDue(0.0) - .addAttachment( - DocumentAttachmentCreate.builder() - .fileName("file_name") - .fileData("file_data") - .fileSize(0L) - .fileType("file_type") - .build() - ) - .billingAddress("billing_address") - .billingAddressRecipient("billing_address_recipient") - .addCharge( - DocumentCreate.Charge.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") - .build() - ) - .currency(CurrencyCode.EUR) - .customerAddress("customer_address") - .customerAddressRecipient("customer_address_recipient") - .customerCompanyId("1018265814") - .customerEmail("customer_email") - .customerId("customer_id") - .customerName("customer_name") - .customerTaxId("BE1018265814") - .direction(DocumentDirection.INBOUND) - .documentType(DocumentType.INVOICE) - .dueDate(LocalDate.parse("2019-12-27")) - .invoiceDate(LocalDate.parse("2019-12-27")) - .invoiceId("invoice_id") - .invoiceTotal(0.0) - .addItem( - DocumentCreate.Item.builder() + DocumentCreateParams.builder() + .constructPdf(true) + .documentCreate( + DocumentCreate.builder() .addAllowance( - DocumentCreate.Item.Allowance.builder() + DocumentCreate.Allowance.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .taxCode(DocumentCreate.Allowance.TaxCode.AE) .taxRate(0.0) .build() ) - .amount(0.0) + .amountDue(0.0) + .addAttachment( + DocumentAttachmentCreate.builder() + .fileName("file_name") + .fileData("file_data") + .fileSize(0L) + .fileType("file_type") + .build() + ) + .billingAddress("billing_address") + .billingAddressRecipient("billing_address_recipient") .addCharge( - DocumentCreate.Item.Charge.builder() + DocumentCreate.Charge.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .taxCode(DocumentCreate.Charge.TaxCode.AE) .taxRate("21.00") .build() ) - .date(null) - .description("description") - .productCode("product_code") - .quantity(0.0) - .tax(0.0) - .taxRate("21.00") - .unit(UnitOfMeasureCode._10) - .unitPrice(0.0) - .build() - ) - .note("note") - .addPaymentDetail( - PaymentDetailCreate.builder() - .bankAccountNumber("bank_account_number") - .iban("iban") - .paymentReference("payment_reference") - .swift("swift") + .currency(CurrencyCode.EUR) + .customerAddress("customer_address") + .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") + .customerEmail("customer_email") + .customerId("customer_id") + .customerName("customer_name") + .customerTaxId("BE1018265814") + .direction(DocumentDirection.INBOUND) + .documentType(DocumentType.INVOICE) + .dueDate(LocalDate.parse("2019-12-27")) + .invoiceDate(LocalDate.parse("2019-12-27")) + .invoiceId("invoice_id") + .invoiceTotal(0.0) + .addItem( + DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Allowance.ReasonCode._41 + ) + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate(0.0) + .build() + ) + .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Charge.ReasonCode.AA + ) + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("21.00") + .build() + ) + .date(null) + .description("description") + .productCode("product_code") + .quantity(0.0) + .tax(0.0) + .taxRate("21.00") + .unit(UnitOfMeasureCode._10) + .unitPrice(0.0) + .build() + ) + .note("note") + .addPaymentDetail( + PaymentDetailCreate.builder() + .bankAccountNumber("bank_account_number") + .iban("iban") + .paymentReference("payment_reference") + .swift("swift") + .build() + ) + .paymentTerm("payment_term") + .previousUnpaidBalance(0.0) + .purchaseOrder("purchase_order") + .remittanceAddress("remittance_address") + .remittanceAddressRecipient("remittance_address_recipient") + .serviceAddress("service_address") + .serviceAddressRecipient("service_address_recipient") + .serviceEndDate(LocalDate.parse("2019-12-27")) + .serviceStartDate(LocalDate.parse("2019-12-27")) + .shippingAddress("shipping_address") + .shippingAddressRecipient("shipping_address_recipient") + .state(DocumentState.DRAFT) + .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) + .addTaxDetail( + DocumentCreate.TaxDetail.builder() + .amount(0.0) + .rate("rate") + .build() + ) + .totalDiscount(0.0) + .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") + .vendorAddress("vendor_address") + .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") + .vendorEmail("vendor_email") + .vendorName("vendor_name") + .vendorTaxId("BE1018265814") .build() ) - .paymentTerm("payment_term") - .previousUnpaidBalance(0.0) - .purchaseOrder("purchase_order") - .remittanceAddress("remittance_address") - .remittanceAddressRecipient("remittance_address_recipient") - .serviceAddress("service_address") - .serviceAddressRecipient("service_address_recipient") - .serviceEndDate(LocalDate.parse("2019-12-27")) - .serviceStartDate(LocalDate.parse("2019-12-27")) - .shippingAddress("shipping_address") - .shippingAddressRecipient("shipping_address_recipient") - .state(DocumentState.DRAFT) - .subtotal(0.0) - .taxCode(DocumentCreate.TaxCode.AE) - .addTaxDetail( - DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() - ) - .totalDiscount(0.0) - .totalTax(0.0) - .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) - .vatexNote("vatex_note") - .vendorAddress("vendor_address") - .vendorAddressRecipient("vendor_address_recipient") - .vendorCompanyId("1018265814") - .vendorEmail("vendor_email") - .vendorName("vendor_name") - .vendorTaxId("BE1018265814") .build() ) } @@ -1348,125 +1457,137 @@ internal class ErrorHandlingTest { val e = assertThrows { documentService.create( - DocumentCreate.builder() - .addAllowance( - DocumentCreate.Allowance.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) - .build() - ) - .amountDue(0.0) - .addAttachment( - DocumentAttachmentCreate.builder() - .fileName("file_name") - .fileData("file_data") - .fileSize(0L) - .fileType("file_type") - .build() - ) - .billingAddress("billing_address") - .billingAddressRecipient("billing_address_recipient") - .addCharge( - DocumentCreate.Charge.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") - .build() - ) - .currency(CurrencyCode.EUR) - .customerAddress("customer_address") - .customerAddressRecipient("customer_address_recipient") - .customerCompanyId("1018265814") - .customerEmail("customer_email") - .customerId("customer_id") - .customerName("customer_name") - .customerTaxId("BE1018265814") - .direction(DocumentDirection.INBOUND) - .documentType(DocumentType.INVOICE) - .dueDate(LocalDate.parse("2019-12-27")) - .invoiceDate(LocalDate.parse("2019-12-27")) - .invoiceId("invoice_id") - .invoiceTotal(0.0) - .addItem( - DocumentCreate.Item.builder() + DocumentCreateParams.builder() + .constructPdf(true) + .documentCreate( + DocumentCreate.builder() .addAllowance( - DocumentCreate.Item.Allowance.builder() + DocumentCreate.Allowance.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .taxCode(DocumentCreate.Allowance.TaxCode.AE) .taxRate(0.0) .build() ) - .amount(0.0) + .amountDue(0.0) + .addAttachment( + DocumentAttachmentCreate.builder() + .fileName("file_name") + .fileData("file_data") + .fileSize(0L) + .fileType("file_type") + .build() + ) + .billingAddress("billing_address") + .billingAddressRecipient("billing_address_recipient") .addCharge( - DocumentCreate.Item.Charge.builder() + DocumentCreate.Charge.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .taxCode(DocumentCreate.Charge.TaxCode.AE) .taxRate("21.00") .build() ) - .date(null) - .description("description") - .productCode("product_code") - .quantity(0.0) - .tax(0.0) - .taxRate("21.00") - .unit(UnitOfMeasureCode._10) - .unitPrice(0.0) - .build() - ) - .note("note") - .addPaymentDetail( - PaymentDetailCreate.builder() - .bankAccountNumber("bank_account_number") - .iban("iban") - .paymentReference("payment_reference") - .swift("swift") + .currency(CurrencyCode.EUR) + .customerAddress("customer_address") + .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") + .customerEmail("customer_email") + .customerId("customer_id") + .customerName("customer_name") + .customerTaxId("BE1018265814") + .direction(DocumentDirection.INBOUND) + .documentType(DocumentType.INVOICE) + .dueDate(LocalDate.parse("2019-12-27")) + .invoiceDate(LocalDate.parse("2019-12-27")) + .invoiceId("invoice_id") + .invoiceTotal(0.0) + .addItem( + DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Allowance.ReasonCode._41 + ) + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate(0.0) + .build() + ) + .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Charge.ReasonCode.AA + ) + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("21.00") + .build() + ) + .date(null) + .description("description") + .productCode("product_code") + .quantity(0.0) + .tax(0.0) + .taxRate("21.00") + .unit(UnitOfMeasureCode._10) + .unitPrice(0.0) + .build() + ) + .note("note") + .addPaymentDetail( + PaymentDetailCreate.builder() + .bankAccountNumber("bank_account_number") + .iban("iban") + .paymentReference("payment_reference") + .swift("swift") + .build() + ) + .paymentTerm("payment_term") + .previousUnpaidBalance(0.0) + .purchaseOrder("purchase_order") + .remittanceAddress("remittance_address") + .remittanceAddressRecipient("remittance_address_recipient") + .serviceAddress("service_address") + .serviceAddressRecipient("service_address_recipient") + .serviceEndDate(LocalDate.parse("2019-12-27")) + .serviceStartDate(LocalDate.parse("2019-12-27")) + .shippingAddress("shipping_address") + .shippingAddressRecipient("shipping_address_recipient") + .state(DocumentState.DRAFT) + .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) + .addTaxDetail( + DocumentCreate.TaxDetail.builder() + .amount(0.0) + .rate("rate") + .build() + ) + .totalDiscount(0.0) + .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") + .vendorAddress("vendor_address") + .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") + .vendorEmail("vendor_email") + .vendorName("vendor_name") + .vendorTaxId("BE1018265814") .build() ) - .paymentTerm("payment_term") - .previousUnpaidBalance(0.0) - .purchaseOrder("purchase_order") - .remittanceAddress("remittance_address") - .remittanceAddressRecipient("remittance_address_recipient") - .serviceAddress("service_address") - .serviceAddressRecipient("service_address_recipient") - .serviceEndDate(LocalDate.parse("2019-12-27")) - .serviceStartDate(LocalDate.parse("2019-12-27")) - .shippingAddress("shipping_address") - .shippingAddressRecipient("shipping_address_recipient") - .state(DocumentState.DRAFT) - .subtotal(0.0) - .taxCode(DocumentCreate.TaxCode.AE) - .addTaxDetail( - DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() - ) - .totalDiscount(0.0) - .totalTax(0.0) - .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) - .vatexNote("vatex_note") - .vendorAddress("vendor_address") - .vendorAddressRecipient("vendor_address_recipient") - .vendorCompanyId("1018265814") - .vendorEmail("vendor_email") - .vendorName("vendor_name") - .vendorTaxId("BE1018265814") .build() ) } @@ -1489,125 +1610,137 @@ internal class ErrorHandlingTest { val e = assertThrows { documentService.create( - DocumentCreate.builder() - .addAllowance( - DocumentCreate.Allowance.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) - .build() - ) - .amountDue(0.0) - .addAttachment( - DocumentAttachmentCreate.builder() - .fileName("file_name") - .fileData("file_data") - .fileSize(0L) - .fileType("file_type") - .build() - ) - .billingAddress("billing_address") - .billingAddressRecipient("billing_address_recipient") - .addCharge( - DocumentCreate.Charge.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") - .build() - ) - .currency(CurrencyCode.EUR) - .customerAddress("customer_address") - .customerAddressRecipient("customer_address_recipient") - .customerCompanyId("1018265814") - .customerEmail("customer_email") - .customerId("customer_id") - .customerName("customer_name") - .customerTaxId("BE1018265814") - .direction(DocumentDirection.INBOUND) - .documentType(DocumentType.INVOICE) - .dueDate(LocalDate.parse("2019-12-27")) - .invoiceDate(LocalDate.parse("2019-12-27")) - .invoiceId("invoice_id") - .invoiceTotal(0.0) - .addItem( - DocumentCreate.Item.builder() + DocumentCreateParams.builder() + .constructPdf(true) + .documentCreate( + DocumentCreate.builder() .addAllowance( - DocumentCreate.Item.Allowance.builder() + DocumentCreate.Allowance.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .taxCode(DocumentCreate.Allowance.TaxCode.AE) .taxRate(0.0) .build() ) - .amount(0.0) + .amountDue(0.0) + .addAttachment( + DocumentAttachmentCreate.builder() + .fileName("file_name") + .fileData("file_data") + .fileSize(0L) + .fileType("file_type") + .build() + ) + .billingAddress("billing_address") + .billingAddressRecipient("billing_address_recipient") .addCharge( - DocumentCreate.Item.Charge.builder() + DocumentCreate.Charge.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .taxCode(DocumentCreate.Charge.TaxCode.AE) .taxRate("21.00") .build() ) - .date(null) - .description("description") - .productCode("product_code") - .quantity(0.0) - .tax(0.0) - .taxRate("21.00") - .unit(UnitOfMeasureCode._10) - .unitPrice(0.0) - .build() - ) - .note("note") - .addPaymentDetail( - PaymentDetailCreate.builder() - .bankAccountNumber("bank_account_number") - .iban("iban") - .paymentReference("payment_reference") - .swift("swift") + .currency(CurrencyCode.EUR) + .customerAddress("customer_address") + .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") + .customerEmail("customer_email") + .customerId("customer_id") + .customerName("customer_name") + .customerTaxId("BE1018265814") + .direction(DocumentDirection.INBOUND) + .documentType(DocumentType.INVOICE) + .dueDate(LocalDate.parse("2019-12-27")) + .invoiceDate(LocalDate.parse("2019-12-27")) + .invoiceId("invoice_id") + .invoiceTotal(0.0) + .addItem( + DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Allowance.ReasonCode._41 + ) + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate(0.0) + .build() + ) + .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Charge.ReasonCode.AA + ) + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("21.00") + .build() + ) + .date(null) + .description("description") + .productCode("product_code") + .quantity(0.0) + .tax(0.0) + .taxRate("21.00") + .unit(UnitOfMeasureCode._10) + .unitPrice(0.0) + .build() + ) + .note("note") + .addPaymentDetail( + PaymentDetailCreate.builder() + .bankAccountNumber("bank_account_number") + .iban("iban") + .paymentReference("payment_reference") + .swift("swift") + .build() + ) + .paymentTerm("payment_term") + .previousUnpaidBalance(0.0) + .purchaseOrder("purchase_order") + .remittanceAddress("remittance_address") + .remittanceAddressRecipient("remittance_address_recipient") + .serviceAddress("service_address") + .serviceAddressRecipient("service_address_recipient") + .serviceEndDate(LocalDate.parse("2019-12-27")) + .serviceStartDate(LocalDate.parse("2019-12-27")) + .shippingAddress("shipping_address") + .shippingAddressRecipient("shipping_address_recipient") + .state(DocumentState.DRAFT) + .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) + .addTaxDetail( + DocumentCreate.TaxDetail.builder() + .amount(0.0) + .rate("rate") + .build() + ) + .totalDiscount(0.0) + .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") + .vendorAddress("vendor_address") + .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") + .vendorEmail("vendor_email") + .vendorName("vendor_name") + .vendorTaxId("BE1018265814") .build() ) - .paymentTerm("payment_term") - .previousUnpaidBalance(0.0) - .purchaseOrder("purchase_order") - .remittanceAddress("remittance_address") - .remittanceAddressRecipient("remittance_address_recipient") - .serviceAddress("service_address") - .serviceAddressRecipient("service_address_recipient") - .serviceEndDate(LocalDate.parse("2019-12-27")) - .serviceStartDate(LocalDate.parse("2019-12-27")) - .shippingAddress("shipping_address") - .shippingAddressRecipient("shipping_address_recipient") - .state(DocumentState.DRAFT) - .subtotal(0.0) - .taxCode(DocumentCreate.TaxCode.AE) - .addTaxDetail( - DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() - ) - .totalDiscount(0.0) - .totalTax(0.0) - .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) - .vatexNote("vatex_note") - .vendorAddress("vendor_address") - .vendorAddressRecipient("vendor_address_recipient") - .vendorCompanyId("1018265814") - .vendorEmail("vendor_email") - .vendorName("vendor_name") - .vendorTaxId("BE1018265814") .build() ) } @@ -1630,125 +1763,137 @@ internal class ErrorHandlingTest { val e = assertThrows { documentService.create( - DocumentCreate.builder() - .addAllowance( - DocumentCreate.Allowance.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) - .build() - ) - .amountDue(0.0) - .addAttachment( - DocumentAttachmentCreate.builder() - .fileName("file_name") - .fileData("file_data") - .fileSize(0L) - .fileType("file_type") - .build() - ) - .billingAddress("billing_address") - .billingAddressRecipient("billing_address_recipient") - .addCharge( - DocumentCreate.Charge.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") - .build() - ) - .currency(CurrencyCode.EUR) - .customerAddress("customer_address") - .customerAddressRecipient("customer_address_recipient") - .customerCompanyId("1018265814") - .customerEmail("customer_email") - .customerId("customer_id") - .customerName("customer_name") - .customerTaxId("BE1018265814") - .direction(DocumentDirection.INBOUND) - .documentType(DocumentType.INVOICE) - .dueDate(LocalDate.parse("2019-12-27")) - .invoiceDate(LocalDate.parse("2019-12-27")) - .invoiceId("invoice_id") - .invoiceTotal(0.0) - .addItem( - DocumentCreate.Item.builder() + DocumentCreateParams.builder() + .constructPdf(true) + .documentCreate( + DocumentCreate.builder() .addAllowance( - DocumentCreate.Item.Allowance.builder() + DocumentCreate.Allowance.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .taxCode(DocumentCreate.Allowance.TaxCode.AE) .taxRate(0.0) .build() ) - .amount(0.0) + .amountDue(0.0) + .addAttachment( + DocumentAttachmentCreate.builder() + .fileName("file_name") + .fileData("file_data") + .fileSize(0L) + .fileType("file_type") + .build() + ) + .billingAddress("billing_address") + .billingAddressRecipient("billing_address_recipient") .addCharge( - DocumentCreate.Item.Charge.builder() + DocumentCreate.Charge.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .taxCode(DocumentCreate.Charge.TaxCode.AE) .taxRate("21.00") .build() ) - .date(null) - .description("description") - .productCode("product_code") - .quantity(0.0) - .tax(0.0) - .taxRate("21.00") - .unit(UnitOfMeasureCode._10) - .unitPrice(0.0) - .build() - ) - .note("note") - .addPaymentDetail( - PaymentDetailCreate.builder() - .bankAccountNumber("bank_account_number") - .iban("iban") - .paymentReference("payment_reference") - .swift("swift") + .currency(CurrencyCode.EUR) + .customerAddress("customer_address") + .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") + .customerEmail("customer_email") + .customerId("customer_id") + .customerName("customer_name") + .customerTaxId("BE1018265814") + .direction(DocumentDirection.INBOUND) + .documentType(DocumentType.INVOICE) + .dueDate(LocalDate.parse("2019-12-27")) + .invoiceDate(LocalDate.parse("2019-12-27")) + .invoiceId("invoice_id") + .invoiceTotal(0.0) + .addItem( + DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Allowance.ReasonCode._41 + ) + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate(0.0) + .build() + ) + .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Charge.ReasonCode.AA + ) + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("21.00") + .build() + ) + .date(null) + .description("description") + .productCode("product_code") + .quantity(0.0) + .tax(0.0) + .taxRate("21.00") + .unit(UnitOfMeasureCode._10) + .unitPrice(0.0) + .build() + ) + .note("note") + .addPaymentDetail( + PaymentDetailCreate.builder() + .bankAccountNumber("bank_account_number") + .iban("iban") + .paymentReference("payment_reference") + .swift("swift") + .build() + ) + .paymentTerm("payment_term") + .previousUnpaidBalance(0.0) + .purchaseOrder("purchase_order") + .remittanceAddress("remittance_address") + .remittanceAddressRecipient("remittance_address_recipient") + .serviceAddress("service_address") + .serviceAddressRecipient("service_address_recipient") + .serviceEndDate(LocalDate.parse("2019-12-27")) + .serviceStartDate(LocalDate.parse("2019-12-27")) + .shippingAddress("shipping_address") + .shippingAddressRecipient("shipping_address_recipient") + .state(DocumentState.DRAFT) + .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) + .addTaxDetail( + DocumentCreate.TaxDetail.builder() + .amount(0.0) + .rate("rate") + .build() + ) + .totalDiscount(0.0) + .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") + .vendorAddress("vendor_address") + .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") + .vendorEmail("vendor_email") + .vendorName("vendor_name") + .vendorTaxId("BE1018265814") .build() ) - .paymentTerm("payment_term") - .previousUnpaidBalance(0.0) - .purchaseOrder("purchase_order") - .remittanceAddress("remittance_address") - .remittanceAddressRecipient("remittance_address_recipient") - .serviceAddress("service_address") - .serviceAddressRecipient("service_address_recipient") - .serviceEndDate(LocalDate.parse("2019-12-27")) - .serviceStartDate(LocalDate.parse("2019-12-27")) - .shippingAddress("shipping_address") - .shippingAddressRecipient("shipping_address_recipient") - .state(DocumentState.DRAFT) - .subtotal(0.0) - .taxCode(DocumentCreate.TaxCode.AE) - .addTaxDetail( - DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() - ) - .totalDiscount(0.0) - .totalTax(0.0) - .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) - .vatexNote("vatex_note") - .vendorAddress("vendor_address") - .vendorAddressRecipient("vendor_address_recipient") - .vendorCompanyId("1018265814") - .vendorEmail("vendor_email") - .vendorName("vendor_name") - .vendorTaxId("BE1018265814") .build() ) } @@ -1771,125 +1916,137 @@ internal class ErrorHandlingTest { val e = assertThrows { documentService.create( - DocumentCreate.builder() - .addAllowance( - DocumentCreate.Allowance.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) - .build() - ) - .amountDue(0.0) - .addAttachment( - DocumentAttachmentCreate.builder() - .fileName("file_name") - .fileData("file_data") - .fileSize(0L) - .fileType("file_type") - .build() - ) - .billingAddress("billing_address") - .billingAddressRecipient("billing_address_recipient") - .addCharge( - DocumentCreate.Charge.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") - .build() - ) - .currency(CurrencyCode.EUR) - .customerAddress("customer_address") - .customerAddressRecipient("customer_address_recipient") - .customerCompanyId("1018265814") - .customerEmail("customer_email") - .customerId("customer_id") - .customerName("customer_name") - .customerTaxId("BE1018265814") - .direction(DocumentDirection.INBOUND) - .documentType(DocumentType.INVOICE) - .dueDate(LocalDate.parse("2019-12-27")) - .invoiceDate(LocalDate.parse("2019-12-27")) - .invoiceId("invoice_id") - .invoiceTotal(0.0) - .addItem( - DocumentCreate.Item.builder() + DocumentCreateParams.builder() + .constructPdf(true) + .documentCreate( + DocumentCreate.builder() .addAllowance( - DocumentCreate.Item.Allowance.builder() + DocumentCreate.Allowance.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .taxCode(DocumentCreate.Allowance.TaxCode.AE) .taxRate(0.0) .build() ) - .amount(0.0) + .amountDue(0.0) + .addAttachment( + DocumentAttachmentCreate.builder() + .fileName("file_name") + .fileData("file_data") + .fileSize(0L) + .fileType("file_type") + .build() + ) + .billingAddress("billing_address") + .billingAddressRecipient("billing_address_recipient") .addCharge( - DocumentCreate.Item.Charge.builder() + DocumentCreate.Charge.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .taxCode(DocumentCreate.Charge.TaxCode.AE) .taxRate("21.00") .build() ) - .date(null) - .description("description") - .productCode("product_code") - .quantity(0.0) - .tax(0.0) - .taxRate("21.00") - .unit(UnitOfMeasureCode._10) - .unitPrice(0.0) - .build() - ) - .note("note") - .addPaymentDetail( - PaymentDetailCreate.builder() - .bankAccountNumber("bank_account_number") - .iban("iban") - .paymentReference("payment_reference") - .swift("swift") + .currency(CurrencyCode.EUR) + .customerAddress("customer_address") + .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") + .customerEmail("customer_email") + .customerId("customer_id") + .customerName("customer_name") + .customerTaxId("BE1018265814") + .direction(DocumentDirection.INBOUND) + .documentType(DocumentType.INVOICE) + .dueDate(LocalDate.parse("2019-12-27")) + .invoiceDate(LocalDate.parse("2019-12-27")) + .invoiceId("invoice_id") + .invoiceTotal(0.0) + .addItem( + DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Allowance.ReasonCode._41 + ) + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate(0.0) + .build() + ) + .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Charge.ReasonCode.AA + ) + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("21.00") + .build() + ) + .date(null) + .description("description") + .productCode("product_code") + .quantity(0.0) + .tax(0.0) + .taxRate("21.00") + .unit(UnitOfMeasureCode._10) + .unitPrice(0.0) + .build() + ) + .note("note") + .addPaymentDetail( + PaymentDetailCreate.builder() + .bankAccountNumber("bank_account_number") + .iban("iban") + .paymentReference("payment_reference") + .swift("swift") + .build() + ) + .paymentTerm("payment_term") + .previousUnpaidBalance(0.0) + .purchaseOrder("purchase_order") + .remittanceAddress("remittance_address") + .remittanceAddressRecipient("remittance_address_recipient") + .serviceAddress("service_address") + .serviceAddressRecipient("service_address_recipient") + .serviceEndDate(LocalDate.parse("2019-12-27")) + .serviceStartDate(LocalDate.parse("2019-12-27")) + .shippingAddress("shipping_address") + .shippingAddressRecipient("shipping_address_recipient") + .state(DocumentState.DRAFT) + .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) + .addTaxDetail( + DocumentCreate.TaxDetail.builder() + .amount(0.0) + .rate("rate") + .build() + ) + .totalDiscount(0.0) + .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") + .vendorAddress("vendor_address") + .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") + .vendorEmail("vendor_email") + .vendorName("vendor_name") + .vendorTaxId("BE1018265814") .build() ) - .paymentTerm("payment_term") - .previousUnpaidBalance(0.0) - .purchaseOrder("purchase_order") - .remittanceAddress("remittance_address") - .remittanceAddressRecipient("remittance_address_recipient") - .serviceAddress("service_address") - .serviceAddressRecipient("service_address_recipient") - .serviceEndDate(LocalDate.parse("2019-12-27")) - .serviceStartDate(LocalDate.parse("2019-12-27")) - .shippingAddress("shipping_address") - .shippingAddressRecipient("shipping_address_recipient") - .state(DocumentState.DRAFT) - .subtotal(0.0) - .taxCode(DocumentCreate.TaxCode.AE) - .addTaxDetail( - DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() - ) - .totalDiscount(0.0) - .totalTax(0.0) - .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) - .vatexNote("vatex_note") - .vendorAddress("vendor_address") - .vendorAddressRecipient("vendor_address_recipient") - .vendorCompanyId("1018265814") - .vendorEmail("vendor_email") - .vendorName("vendor_name") - .vendorTaxId("BE1018265814") .build() ) } @@ -1912,125 +2069,137 @@ internal class ErrorHandlingTest { val e = assertThrows { documentService.create( - DocumentCreate.builder() - .addAllowance( - DocumentCreate.Allowance.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) - .build() - ) - .amountDue(0.0) - .addAttachment( - DocumentAttachmentCreate.builder() - .fileName("file_name") - .fileData("file_data") - .fileSize(0L) - .fileType("file_type") - .build() - ) - .billingAddress("billing_address") - .billingAddressRecipient("billing_address_recipient") - .addCharge( - DocumentCreate.Charge.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") - .build() - ) - .currency(CurrencyCode.EUR) - .customerAddress("customer_address") - .customerAddressRecipient("customer_address_recipient") - .customerCompanyId("1018265814") - .customerEmail("customer_email") - .customerId("customer_id") - .customerName("customer_name") - .customerTaxId("BE1018265814") - .direction(DocumentDirection.INBOUND) - .documentType(DocumentType.INVOICE) - .dueDate(LocalDate.parse("2019-12-27")) - .invoiceDate(LocalDate.parse("2019-12-27")) - .invoiceId("invoice_id") - .invoiceTotal(0.0) - .addItem( - DocumentCreate.Item.builder() + DocumentCreateParams.builder() + .constructPdf(true) + .documentCreate( + DocumentCreate.builder() .addAllowance( - DocumentCreate.Item.Allowance.builder() + DocumentCreate.Allowance.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .taxCode(DocumentCreate.Allowance.TaxCode.AE) .taxRate(0.0) .build() ) - .amount(0.0) + .amountDue(0.0) + .addAttachment( + DocumentAttachmentCreate.builder() + .fileName("file_name") + .fileData("file_data") + .fileSize(0L) + .fileType("file_type") + .build() + ) + .billingAddress("billing_address") + .billingAddressRecipient("billing_address_recipient") .addCharge( - DocumentCreate.Item.Charge.builder() + DocumentCreate.Charge.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .taxCode(DocumentCreate.Charge.TaxCode.AE) .taxRate("21.00") .build() ) - .date(null) - .description("description") - .productCode("product_code") - .quantity(0.0) - .tax(0.0) - .taxRate("21.00") - .unit(UnitOfMeasureCode._10) - .unitPrice(0.0) - .build() - ) - .note("note") - .addPaymentDetail( - PaymentDetailCreate.builder() - .bankAccountNumber("bank_account_number") - .iban("iban") - .paymentReference("payment_reference") - .swift("swift") + .currency(CurrencyCode.EUR) + .customerAddress("customer_address") + .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") + .customerEmail("customer_email") + .customerId("customer_id") + .customerName("customer_name") + .customerTaxId("BE1018265814") + .direction(DocumentDirection.INBOUND) + .documentType(DocumentType.INVOICE) + .dueDate(LocalDate.parse("2019-12-27")) + .invoiceDate(LocalDate.parse("2019-12-27")) + .invoiceId("invoice_id") + .invoiceTotal(0.0) + .addItem( + DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Allowance.ReasonCode._41 + ) + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate(0.0) + .build() + ) + .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Charge.ReasonCode.AA + ) + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("21.00") + .build() + ) + .date(null) + .description("description") + .productCode("product_code") + .quantity(0.0) + .tax(0.0) + .taxRate("21.00") + .unit(UnitOfMeasureCode._10) + .unitPrice(0.0) + .build() + ) + .note("note") + .addPaymentDetail( + PaymentDetailCreate.builder() + .bankAccountNumber("bank_account_number") + .iban("iban") + .paymentReference("payment_reference") + .swift("swift") + .build() + ) + .paymentTerm("payment_term") + .previousUnpaidBalance(0.0) + .purchaseOrder("purchase_order") + .remittanceAddress("remittance_address") + .remittanceAddressRecipient("remittance_address_recipient") + .serviceAddress("service_address") + .serviceAddressRecipient("service_address_recipient") + .serviceEndDate(LocalDate.parse("2019-12-27")) + .serviceStartDate(LocalDate.parse("2019-12-27")) + .shippingAddress("shipping_address") + .shippingAddressRecipient("shipping_address_recipient") + .state(DocumentState.DRAFT) + .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) + .addTaxDetail( + DocumentCreate.TaxDetail.builder() + .amount(0.0) + .rate("rate") + .build() + ) + .totalDiscount(0.0) + .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") + .vendorAddress("vendor_address") + .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") + .vendorEmail("vendor_email") + .vendorName("vendor_name") + .vendorTaxId("BE1018265814") .build() ) - .paymentTerm("payment_term") - .previousUnpaidBalance(0.0) - .purchaseOrder("purchase_order") - .remittanceAddress("remittance_address") - .remittanceAddressRecipient("remittance_address_recipient") - .serviceAddress("service_address") - .serviceAddressRecipient("service_address_recipient") - .serviceEndDate(LocalDate.parse("2019-12-27")) - .serviceStartDate(LocalDate.parse("2019-12-27")) - .shippingAddress("shipping_address") - .shippingAddressRecipient("shipping_address_recipient") - .state(DocumentState.DRAFT) - .subtotal(0.0) - .taxCode(DocumentCreate.TaxCode.AE) - .addTaxDetail( - DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() - ) - .totalDiscount(0.0) - .totalTax(0.0) - .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) - .vatexNote("vatex_note") - .vendorAddress("vendor_address") - .vendorAddressRecipient("vendor_address_recipient") - .vendorCompanyId("1018265814") - .vendorEmail("vendor_email") - .vendorName("vendor_name") - .vendorTaxId("BE1018265814") .build() ) } @@ -2053,125 +2222,137 @@ internal class ErrorHandlingTest { val e = assertThrows { documentService.create( - DocumentCreate.builder() - .addAllowance( - DocumentCreate.Allowance.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) - .build() - ) - .amountDue(0.0) - .addAttachment( - DocumentAttachmentCreate.builder() - .fileName("file_name") - .fileData("file_data") - .fileSize(0L) - .fileType("file_type") - .build() - ) - .billingAddress("billing_address") - .billingAddressRecipient("billing_address_recipient") - .addCharge( - DocumentCreate.Charge.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") - .build() - ) - .currency(CurrencyCode.EUR) - .customerAddress("customer_address") - .customerAddressRecipient("customer_address_recipient") - .customerCompanyId("1018265814") - .customerEmail("customer_email") - .customerId("customer_id") - .customerName("customer_name") - .customerTaxId("BE1018265814") - .direction(DocumentDirection.INBOUND) - .documentType(DocumentType.INVOICE) - .dueDate(LocalDate.parse("2019-12-27")) - .invoiceDate(LocalDate.parse("2019-12-27")) - .invoiceId("invoice_id") - .invoiceTotal(0.0) - .addItem( - DocumentCreate.Item.builder() + DocumentCreateParams.builder() + .constructPdf(true) + .documentCreate( + DocumentCreate.builder() .addAllowance( - DocumentCreate.Item.Allowance.builder() + DocumentCreate.Allowance.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .taxCode(DocumentCreate.Allowance.TaxCode.AE) .taxRate(0.0) .build() ) - .amount(0.0) + .amountDue(0.0) + .addAttachment( + DocumentAttachmentCreate.builder() + .fileName("file_name") + .fileData("file_data") + .fileSize(0L) + .fileType("file_type") + .build() + ) + .billingAddress("billing_address") + .billingAddressRecipient("billing_address_recipient") .addCharge( - DocumentCreate.Item.Charge.builder() + DocumentCreate.Charge.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .taxCode(DocumentCreate.Charge.TaxCode.AE) .taxRate("21.00") .build() ) - .date(null) - .description("description") - .productCode("product_code") - .quantity(0.0) - .tax(0.0) - .taxRate("21.00") - .unit(UnitOfMeasureCode._10) - .unitPrice(0.0) - .build() - ) - .note("note") - .addPaymentDetail( - PaymentDetailCreate.builder() - .bankAccountNumber("bank_account_number") - .iban("iban") - .paymentReference("payment_reference") - .swift("swift") + .currency(CurrencyCode.EUR) + .customerAddress("customer_address") + .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") + .customerEmail("customer_email") + .customerId("customer_id") + .customerName("customer_name") + .customerTaxId("BE1018265814") + .direction(DocumentDirection.INBOUND) + .documentType(DocumentType.INVOICE) + .dueDate(LocalDate.parse("2019-12-27")) + .invoiceDate(LocalDate.parse("2019-12-27")) + .invoiceId("invoice_id") + .invoiceTotal(0.0) + .addItem( + DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Allowance.ReasonCode._41 + ) + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate(0.0) + .build() + ) + .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Charge.ReasonCode.AA + ) + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("21.00") + .build() + ) + .date(null) + .description("description") + .productCode("product_code") + .quantity(0.0) + .tax(0.0) + .taxRate("21.00") + .unit(UnitOfMeasureCode._10) + .unitPrice(0.0) + .build() + ) + .note("note") + .addPaymentDetail( + PaymentDetailCreate.builder() + .bankAccountNumber("bank_account_number") + .iban("iban") + .paymentReference("payment_reference") + .swift("swift") + .build() + ) + .paymentTerm("payment_term") + .previousUnpaidBalance(0.0) + .purchaseOrder("purchase_order") + .remittanceAddress("remittance_address") + .remittanceAddressRecipient("remittance_address_recipient") + .serviceAddress("service_address") + .serviceAddressRecipient("service_address_recipient") + .serviceEndDate(LocalDate.parse("2019-12-27")) + .serviceStartDate(LocalDate.parse("2019-12-27")) + .shippingAddress("shipping_address") + .shippingAddressRecipient("shipping_address_recipient") + .state(DocumentState.DRAFT) + .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) + .addTaxDetail( + DocumentCreate.TaxDetail.builder() + .amount(0.0) + .rate("rate") + .build() + ) + .totalDiscount(0.0) + .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") + .vendorAddress("vendor_address") + .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") + .vendorEmail("vendor_email") + .vendorName("vendor_name") + .vendorTaxId("BE1018265814") .build() ) - .paymentTerm("payment_term") - .previousUnpaidBalance(0.0) - .purchaseOrder("purchase_order") - .remittanceAddress("remittance_address") - .remittanceAddressRecipient("remittance_address_recipient") - .serviceAddress("service_address") - .serviceAddressRecipient("service_address_recipient") - .serviceEndDate(LocalDate.parse("2019-12-27")) - .serviceStartDate(LocalDate.parse("2019-12-27")) - .shippingAddress("shipping_address") - .shippingAddressRecipient("shipping_address_recipient") - .state(DocumentState.DRAFT) - .subtotal(0.0) - .taxCode(DocumentCreate.TaxCode.AE) - .addTaxDetail( - DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() - ) - .totalDiscount(0.0) - .totalTax(0.0) - .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) - .vatexNote("vatex_note") - .vendorAddress("vendor_address") - .vendorAddressRecipient("vendor_address_recipient") - .vendorCompanyId("1018265814") - .vendorEmail("vendor_email") - .vendorName("vendor_name") - .vendorTaxId("BE1018265814") .build() ) } @@ -2194,125 +2375,137 @@ internal class ErrorHandlingTest { val e = assertThrows { documentService.create( - DocumentCreate.builder() - .addAllowance( - DocumentCreate.Allowance.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) - .build() - ) - .amountDue(0.0) - .addAttachment( - DocumentAttachmentCreate.builder() - .fileName("file_name") - .fileData("file_data") - .fileSize(0L) - .fileType("file_type") - .build() - ) - .billingAddress("billing_address") - .billingAddressRecipient("billing_address_recipient") - .addCharge( - DocumentCreate.Charge.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") - .build() - ) - .currency(CurrencyCode.EUR) - .customerAddress("customer_address") - .customerAddressRecipient("customer_address_recipient") - .customerCompanyId("1018265814") - .customerEmail("customer_email") - .customerId("customer_id") - .customerName("customer_name") - .customerTaxId("BE1018265814") - .direction(DocumentDirection.INBOUND) - .documentType(DocumentType.INVOICE) - .dueDate(LocalDate.parse("2019-12-27")) - .invoiceDate(LocalDate.parse("2019-12-27")) - .invoiceId("invoice_id") - .invoiceTotal(0.0) - .addItem( - DocumentCreate.Item.builder() + DocumentCreateParams.builder() + .constructPdf(true) + .documentCreate( + DocumentCreate.builder() .addAllowance( - DocumentCreate.Item.Allowance.builder() + DocumentCreate.Allowance.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .taxCode(DocumentCreate.Allowance.TaxCode.AE) .taxRate(0.0) .build() ) - .amount(0.0) + .amountDue(0.0) + .addAttachment( + DocumentAttachmentCreate.builder() + .fileName("file_name") + .fileData("file_data") + .fileSize(0L) + .fileType("file_type") + .build() + ) + .billingAddress("billing_address") + .billingAddressRecipient("billing_address_recipient") .addCharge( - DocumentCreate.Item.Charge.builder() + DocumentCreate.Charge.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .taxCode(DocumentCreate.Charge.TaxCode.AE) .taxRate("21.00") .build() ) - .date(null) - .description("description") - .productCode("product_code") - .quantity(0.0) - .tax(0.0) - .taxRate("21.00") - .unit(UnitOfMeasureCode._10) - .unitPrice(0.0) - .build() - ) - .note("note") - .addPaymentDetail( - PaymentDetailCreate.builder() - .bankAccountNumber("bank_account_number") - .iban("iban") - .paymentReference("payment_reference") - .swift("swift") + .currency(CurrencyCode.EUR) + .customerAddress("customer_address") + .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") + .customerEmail("customer_email") + .customerId("customer_id") + .customerName("customer_name") + .customerTaxId("BE1018265814") + .direction(DocumentDirection.INBOUND) + .documentType(DocumentType.INVOICE) + .dueDate(LocalDate.parse("2019-12-27")) + .invoiceDate(LocalDate.parse("2019-12-27")) + .invoiceId("invoice_id") + .invoiceTotal(0.0) + .addItem( + DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Allowance.ReasonCode._41 + ) + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate(0.0) + .build() + ) + .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Charge.ReasonCode.AA + ) + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("21.00") + .build() + ) + .date(null) + .description("description") + .productCode("product_code") + .quantity(0.0) + .tax(0.0) + .taxRate("21.00") + .unit(UnitOfMeasureCode._10) + .unitPrice(0.0) + .build() + ) + .note("note") + .addPaymentDetail( + PaymentDetailCreate.builder() + .bankAccountNumber("bank_account_number") + .iban("iban") + .paymentReference("payment_reference") + .swift("swift") + .build() + ) + .paymentTerm("payment_term") + .previousUnpaidBalance(0.0) + .purchaseOrder("purchase_order") + .remittanceAddress("remittance_address") + .remittanceAddressRecipient("remittance_address_recipient") + .serviceAddress("service_address") + .serviceAddressRecipient("service_address_recipient") + .serviceEndDate(LocalDate.parse("2019-12-27")) + .serviceStartDate(LocalDate.parse("2019-12-27")) + .shippingAddress("shipping_address") + .shippingAddressRecipient("shipping_address_recipient") + .state(DocumentState.DRAFT) + .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) + .addTaxDetail( + DocumentCreate.TaxDetail.builder() + .amount(0.0) + .rate("rate") + .build() + ) + .totalDiscount(0.0) + .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") + .vendorAddress("vendor_address") + .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") + .vendorEmail("vendor_email") + .vendorName("vendor_name") + .vendorTaxId("BE1018265814") .build() ) - .paymentTerm("payment_term") - .previousUnpaidBalance(0.0) - .purchaseOrder("purchase_order") - .remittanceAddress("remittance_address") - .remittanceAddressRecipient("remittance_address_recipient") - .serviceAddress("service_address") - .serviceAddressRecipient("service_address_recipient") - .serviceEndDate(LocalDate.parse("2019-12-27")) - .serviceStartDate(LocalDate.parse("2019-12-27")) - .shippingAddress("shipping_address") - .shippingAddressRecipient("shipping_address_recipient") - .state(DocumentState.DRAFT) - .subtotal(0.0) - .taxCode(DocumentCreate.TaxCode.AE) - .addTaxDetail( - DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() - ) - .totalDiscount(0.0) - .totalTax(0.0) - .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) - .vatexNote("vatex_note") - .vendorAddress("vendor_address") - .vendorAddressRecipient("vendor_address_recipient") - .vendorCompanyId("1018265814") - .vendorEmail("vendor_email") - .vendorName("vendor_name") - .vendorTaxId("BE1018265814") .build() ) } @@ -2333,125 +2526,137 @@ internal class ErrorHandlingTest { val e = assertThrows { documentService.create( - DocumentCreate.builder() - .addAllowance( - DocumentCreate.Allowance.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) - .build() - ) - .amountDue(0.0) - .addAttachment( - DocumentAttachmentCreate.builder() - .fileName("file_name") - .fileData("file_data") - .fileSize(0L) - .fileType("file_type") - .build() - ) - .billingAddress("billing_address") - .billingAddressRecipient("billing_address_recipient") - .addCharge( - DocumentCreate.Charge.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") - .build() - ) - .currency(CurrencyCode.EUR) - .customerAddress("customer_address") - .customerAddressRecipient("customer_address_recipient") - .customerCompanyId("1018265814") - .customerEmail("customer_email") - .customerId("customer_id") - .customerName("customer_name") - .customerTaxId("BE1018265814") - .direction(DocumentDirection.INBOUND) - .documentType(DocumentType.INVOICE) - .dueDate(LocalDate.parse("2019-12-27")) - .invoiceDate(LocalDate.parse("2019-12-27")) - .invoiceId("invoice_id") - .invoiceTotal(0.0) - .addItem( - DocumentCreate.Item.builder() + DocumentCreateParams.builder() + .constructPdf(true) + .documentCreate( + DocumentCreate.builder() .addAllowance( - DocumentCreate.Item.Allowance.builder() + DocumentCreate.Allowance.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .taxCode(DocumentCreate.Allowance.TaxCode.AE) .taxRate(0.0) .build() ) - .amount(0.0) + .amountDue(0.0) + .addAttachment( + DocumentAttachmentCreate.builder() + .fileName("file_name") + .fileData("file_data") + .fileSize(0L) + .fileType("file_type") + .build() + ) + .billingAddress("billing_address") + .billingAddressRecipient("billing_address_recipient") .addCharge( - DocumentCreate.Item.Charge.builder() + DocumentCreate.Charge.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .taxCode(DocumentCreate.Charge.TaxCode.AE) .taxRate("21.00") .build() ) - .date(null) - .description("description") - .productCode("product_code") - .quantity(0.0) - .tax(0.0) - .taxRate("21.00") - .unit(UnitOfMeasureCode._10) - .unitPrice(0.0) - .build() - ) - .note("note") - .addPaymentDetail( - PaymentDetailCreate.builder() - .bankAccountNumber("bank_account_number") - .iban("iban") - .paymentReference("payment_reference") - .swift("swift") + .currency(CurrencyCode.EUR) + .customerAddress("customer_address") + .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") + .customerEmail("customer_email") + .customerId("customer_id") + .customerName("customer_name") + .customerTaxId("BE1018265814") + .direction(DocumentDirection.INBOUND) + .documentType(DocumentType.INVOICE) + .dueDate(LocalDate.parse("2019-12-27")) + .invoiceDate(LocalDate.parse("2019-12-27")) + .invoiceId("invoice_id") + .invoiceTotal(0.0) + .addItem( + DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Allowance.ReasonCode._41 + ) + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate(0.0) + .build() + ) + .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Charge.ReasonCode.AA + ) + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("21.00") + .build() + ) + .date(null) + .description("description") + .productCode("product_code") + .quantity(0.0) + .tax(0.0) + .taxRate("21.00") + .unit(UnitOfMeasureCode._10) + .unitPrice(0.0) + .build() + ) + .note("note") + .addPaymentDetail( + PaymentDetailCreate.builder() + .bankAccountNumber("bank_account_number") + .iban("iban") + .paymentReference("payment_reference") + .swift("swift") + .build() + ) + .paymentTerm("payment_term") + .previousUnpaidBalance(0.0) + .purchaseOrder("purchase_order") + .remittanceAddress("remittance_address") + .remittanceAddressRecipient("remittance_address_recipient") + .serviceAddress("service_address") + .serviceAddressRecipient("service_address_recipient") + .serviceEndDate(LocalDate.parse("2019-12-27")) + .serviceStartDate(LocalDate.parse("2019-12-27")) + .shippingAddress("shipping_address") + .shippingAddressRecipient("shipping_address_recipient") + .state(DocumentState.DRAFT) + .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) + .addTaxDetail( + DocumentCreate.TaxDetail.builder() + .amount(0.0) + .rate("rate") + .build() + ) + .totalDiscount(0.0) + .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") + .vendorAddress("vendor_address") + .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") + .vendorEmail("vendor_email") + .vendorName("vendor_name") + .vendorTaxId("BE1018265814") .build() ) - .paymentTerm("payment_term") - .previousUnpaidBalance(0.0) - .purchaseOrder("purchase_order") - .remittanceAddress("remittance_address") - .remittanceAddressRecipient("remittance_address_recipient") - .serviceAddress("service_address") - .serviceAddressRecipient("service_address_recipient") - .serviceEndDate(LocalDate.parse("2019-12-27")) - .serviceStartDate(LocalDate.parse("2019-12-27")) - .shippingAddress("shipping_address") - .shippingAddressRecipient("shipping_address_recipient") - .state(DocumentState.DRAFT) - .subtotal(0.0) - .taxCode(DocumentCreate.TaxCode.AE) - .addTaxDetail( - DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() - ) - .totalDiscount(0.0) - .totalTax(0.0) - .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) - .vatexNote("vatex_note") - .vendorAddress("vendor_address") - .vendorAddressRecipient("vendor_address_recipient") - .vendorCompanyId("1018265814") - .vendorEmail("vendor_email") - .vendorName("vendor_name") - .vendorTaxId("BE1018265814") .build() ) } diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ServiceParamsTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ServiceParamsTest.kt index 7d184da..df07769 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ServiceParamsTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/ServiceParamsTest.kt @@ -51,6 +51,7 @@ internal class ServiceParamsTest { documentService.create( DocumentCreateParams.builder() + .constructPdf(true) .documentCreate( DocumentCreate.builder() .addAllowance( diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncTest.kt index 1186a27..b7ba41d 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/async/DocumentServiceAsyncTest.kt @@ -8,6 +8,7 @@ import com.e_invoice.api.models.documents.CurrencyCode import com.e_invoice.api.models.documents.DocumentAttachmentCreate import com.e_invoice.api.models.documents.DocumentCreate import com.e_invoice.api.models.documents.DocumentCreateFromPdfParams +import com.e_invoice.api.models.documents.DocumentCreateParams import com.e_invoice.api.models.documents.DocumentDirection import com.e_invoice.api.models.documents.DocumentSendParams import com.e_invoice.api.models.documents.DocumentType @@ -34,125 +35,132 @@ internal class DocumentServiceAsyncTest { val documentResponseFuture = documentServiceAsync.create( - DocumentCreate.builder() - .addAllowance( - DocumentCreate.Allowance.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) - .build() - ) - .amountDue(0.0) - .addAttachment( - DocumentAttachmentCreate.builder() - .fileName("file_name") - .fileData("file_data") - .fileSize(0L) - .fileType("file_type") - .build() - ) - .billingAddress("billing_address") - .billingAddressRecipient("billing_address_recipient") - .addCharge( - DocumentCreate.Charge.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") - .build() - ) - .currency(CurrencyCode.EUR) - .customerAddress("customer_address") - .customerAddressRecipient("customer_address_recipient") - .customerCompanyId("1018265814") - .customerEmail("customer_email") - .customerId("customer_id") - .customerName("customer_name") - .customerTaxId("BE1018265814") - .direction(DocumentDirection.INBOUND) - .documentType(DocumentType.INVOICE) - .dueDate(LocalDate.parse("2019-12-27")) - .invoiceDate(LocalDate.parse("2019-12-27")) - .invoiceId("invoice_id") - .invoiceTotal(0.0) - .addItem( - DocumentCreate.Item.builder() + DocumentCreateParams.builder() + .constructPdf(true) + .documentCreate( + DocumentCreate.builder() .addAllowance( - DocumentCreate.Item.Allowance.builder() + DocumentCreate.Allowance.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .taxCode(DocumentCreate.Allowance.TaxCode.AE) .taxRate(0.0) .build() ) - .amount(0.0) + .amountDue(0.0) + .addAttachment( + DocumentAttachmentCreate.builder() + .fileName("file_name") + .fileData("file_data") + .fileSize(0L) + .fileType("file_type") + .build() + ) + .billingAddress("billing_address") + .billingAddressRecipient("billing_address_recipient") .addCharge( - DocumentCreate.Item.Charge.builder() + DocumentCreate.Charge.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .taxCode(DocumentCreate.Charge.TaxCode.AE) .taxRate("21.00") .build() ) - .date(null) - .description("description") - .productCode("product_code") - .quantity(0.0) - .tax(0.0) - .taxRate("21.00") - .unit(UnitOfMeasureCode._10) - .unitPrice(0.0) - .build() - ) - .note("note") - .addPaymentDetail( - PaymentDetailCreate.builder() - .bankAccountNumber("bank_account_number") - .iban("iban") - .paymentReference("payment_reference") - .swift("swift") + .currency(CurrencyCode.EUR) + .customerAddress("customer_address") + .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") + .customerEmail("customer_email") + .customerId("customer_id") + .customerName("customer_name") + .customerTaxId("BE1018265814") + .direction(DocumentDirection.INBOUND) + .documentType(DocumentType.INVOICE) + .dueDate(LocalDate.parse("2019-12-27")) + .invoiceDate(LocalDate.parse("2019-12-27")) + .invoiceId("invoice_id") + .invoiceTotal(0.0) + .addItem( + DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Allowance.ReasonCode._41 + ) + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate(0.0) + .build() + ) + .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("21.00") + .build() + ) + .date(null) + .description("description") + .productCode("product_code") + .quantity(0.0) + .tax(0.0) + .taxRate("21.00") + .unit(UnitOfMeasureCode._10) + .unitPrice(0.0) + .build() + ) + .note("note") + .addPaymentDetail( + PaymentDetailCreate.builder() + .bankAccountNumber("bank_account_number") + .iban("iban") + .paymentReference("payment_reference") + .swift("swift") + .build() + ) + .paymentTerm("payment_term") + .previousUnpaidBalance(0.0) + .purchaseOrder("purchase_order") + .remittanceAddress("remittance_address") + .remittanceAddressRecipient("remittance_address_recipient") + .serviceAddress("service_address") + .serviceAddressRecipient("service_address_recipient") + .serviceEndDate(LocalDate.parse("2019-12-27")) + .serviceStartDate(LocalDate.parse("2019-12-27")) + .shippingAddress("shipping_address") + .shippingAddressRecipient("shipping_address_recipient") + .state(DocumentState.DRAFT) + .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) + .addTaxDetail( + DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() + ) + .totalDiscount(0.0) + .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") + .vendorAddress("vendor_address") + .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") + .vendorEmail("vendor_email") + .vendorName("vendor_name") + .vendorTaxId("BE1018265814") .build() ) - .paymentTerm("payment_term") - .previousUnpaidBalance(0.0) - .purchaseOrder("purchase_order") - .remittanceAddress("remittance_address") - .remittanceAddressRecipient("remittance_address_recipient") - .serviceAddress("service_address") - .serviceAddressRecipient("service_address_recipient") - .serviceEndDate(LocalDate.parse("2019-12-27")) - .serviceStartDate(LocalDate.parse("2019-12-27")) - .shippingAddress("shipping_address") - .shippingAddressRecipient("shipping_address_recipient") - .state(DocumentState.DRAFT) - .subtotal(0.0) - .taxCode(DocumentCreate.TaxCode.AE) - .addTaxDetail( - DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() - ) - .totalDiscount(0.0) - .totalTax(0.0) - .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) - .vatexNote("vatex_note") - .vendorAddress("vendor_address") - .vendorAddressRecipient("vendor_address_recipient") - .vendorCompanyId("1018265814") - .vendorEmail("vendor_email") - .vendorName("vendor_name") - .vendorTaxId("BE1018265814") .build() ) diff --git a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/DocumentServiceTest.kt b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/DocumentServiceTest.kt index 0c1d2fd..0e142d9 100644 --- a/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/DocumentServiceTest.kt +++ b/e-invoice-java-core/src/test/kotlin/com/e_invoice/api/services/blocking/DocumentServiceTest.kt @@ -8,6 +8,7 @@ import com.e_invoice.api.models.documents.CurrencyCode import com.e_invoice.api.models.documents.DocumentAttachmentCreate import com.e_invoice.api.models.documents.DocumentCreate import com.e_invoice.api.models.documents.DocumentCreateFromPdfParams +import com.e_invoice.api.models.documents.DocumentCreateParams import com.e_invoice.api.models.documents.DocumentDirection import com.e_invoice.api.models.documents.DocumentSendParams import com.e_invoice.api.models.documents.DocumentType @@ -34,125 +35,132 @@ internal class DocumentServiceTest { val documentResponse = documentService.create( - DocumentCreate.builder() - .addAllowance( - DocumentCreate.Allowance.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Allowance.TaxCode.AE) - .taxRate(0.0) - .build() - ) - .amountDue(0.0) - .addAttachment( - DocumentAttachmentCreate.builder() - .fileName("file_name") - .fileData("file_data") - .fileSize(0L) - .fileType("file_type") - .build() - ) - .billingAddress("billing_address") - .billingAddressRecipient("billing_address_recipient") - .addCharge( - DocumentCreate.Charge.builder() - .amount(0.0) - .baseAmount(0.0) - .multiplierFactor(0.0) - .reason("reason") - .reasonCode(DocumentCreate.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Charge.TaxCode.AE) - .taxRate("21.00") - .build() - ) - .currency(CurrencyCode.EUR) - .customerAddress("customer_address") - .customerAddressRecipient("customer_address_recipient") - .customerCompanyId("1018265814") - .customerEmail("customer_email") - .customerId("customer_id") - .customerName("customer_name") - .customerTaxId("BE1018265814") - .direction(DocumentDirection.INBOUND) - .documentType(DocumentType.INVOICE) - .dueDate(LocalDate.parse("2019-12-27")) - .invoiceDate(LocalDate.parse("2019-12-27")) - .invoiceId("invoice_id") - .invoiceTotal(0.0) - .addItem( - DocumentCreate.Item.builder() + DocumentCreateParams.builder() + .constructPdf(true) + .documentCreate( + DocumentCreate.builder() .addAllowance( - DocumentCreate.Item.Allowance.builder() + DocumentCreate.Allowance.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Allowance.ReasonCode._41) - .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .reasonCode(DocumentCreate.Allowance.ReasonCode._41) + .taxCode(DocumentCreate.Allowance.TaxCode.AE) .taxRate(0.0) .build() ) - .amount(0.0) + .amountDue(0.0) + .addAttachment( + DocumentAttachmentCreate.builder() + .fileName("file_name") + .fileData("file_data") + .fileSize(0L) + .fileType("file_type") + .build() + ) + .billingAddress("billing_address") + .billingAddressRecipient("billing_address_recipient") .addCharge( - DocumentCreate.Item.Charge.builder() + DocumentCreate.Charge.builder() .amount(0.0) .baseAmount(0.0) .multiplierFactor(0.0) .reason("reason") - .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) - .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .reasonCode(DocumentCreate.Charge.ReasonCode.AA) + .taxCode(DocumentCreate.Charge.TaxCode.AE) .taxRate("21.00") .build() ) - .date(null) - .description("description") - .productCode("product_code") - .quantity(0.0) - .tax(0.0) - .taxRate("21.00") - .unit(UnitOfMeasureCode._10) - .unitPrice(0.0) - .build() - ) - .note("note") - .addPaymentDetail( - PaymentDetailCreate.builder() - .bankAccountNumber("bank_account_number") - .iban("iban") - .paymentReference("payment_reference") - .swift("swift") + .currency(CurrencyCode.EUR) + .customerAddress("customer_address") + .customerAddressRecipient("customer_address_recipient") + .customerCompanyId("1018265814") + .customerEmail("customer_email") + .customerId("customer_id") + .customerName("customer_name") + .customerTaxId("BE1018265814") + .direction(DocumentDirection.INBOUND) + .documentType(DocumentType.INVOICE) + .dueDate(LocalDate.parse("2019-12-27")) + .invoiceDate(LocalDate.parse("2019-12-27")) + .invoiceId("invoice_id") + .invoiceTotal(0.0) + .addItem( + DocumentCreate.Item.builder() + .addAllowance( + DocumentCreate.Item.Allowance.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode( + DocumentCreate.Item.Allowance.ReasonCode._41 + ) + .taxCode(DocumentCreate.Item.Allowance.TaxCode.AE) + .taxRate(0.0) + .build() + ) + .amount(0.0) + .addCharge( + DocumentCreate.Item.Charge.builder() + .amount(0.0) + .baseAmount(0.0) + .multiplierFactor(0.0) + .reason("reason") + .reasonCode(DocumentCreate.Item.Charge.ReasonCode.AA) + .taxCode(DocumentCreate.Item.Charge.TaxCode.AE) + .taxRate("21.00") + .build() + ) + .date(null) + .description("description") + .productCode("product_code") + .quantity(0.0) + .tax(0.0) + .taxRate("21.00") + .unit(UnitOfMeasureCode._10) + .unitPrice(0.0) + .build() + ) + .note("note") + .addPaymentDetail( + PaymentDetailCreate.builder() + .bankAccountNumber("bank_account_number") + .iban("iban") + .paymentReference("payment_reference") + .swift("swift") + .build() + ) + .paymentTerm("payment_term") + .previousUnpaidBalance(0.0) + .purchaseOrder("purchase_order") + .remittanceAddress("remittance_address") + .remittanceAddressRecipient("remittance_address_recipient") + .serviceAddress("service_address") + .serviceAddressRecipient("service_address_recipient") + .serviceEndDate(LocalDate.parse("2019-12-27")) + .serviceStartDate(LocalDate.parse("2019-12-27")) + .shippingAddress("shipping_address") + .shippingAddressRecipient("shipping_address_recipient") + .state(DocumentState.DRAFT) + .subtotal(0.0) + .taxCode(DocumentCreate.TaxCode.AE) + .addTaxDetail( + DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() + ) + .totalDiscount(0.0) + .totalTax(0.0) + .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) + .vatexNote("vatex_note") + .vendorAddress("vendor_address") + .vendorAddressRecipient("vendor_address_recipient") + .vendorCompanyId("1018265814") + .vendorEmail("vendor_email") + .vendorName("vendor_name") + .vendorTaxId("BE1018265814") .build() ) - .paymentTerm("payment_term") - .previousUnpaidBalance(0.0) - .purchaseOrder("purchase_order") - .remittanceAddress("remittance_address") - .remittanceAddressRecipient("remittance_address_recipient") - .serviceAddress("service_address") - .serviceAddressRecipient("service_address_recipient") - .serviceEndDate(LocalDate.parse("2019-12-27")) - .serviceStartDate(LocalDate.parse("2019-12-27")) - .shippingAddress("shipping_address") - .shippingAddressRecipient("shipping_address_recipient") - .state(DocumentState.DRAFT) - .subtotal(0.0) - .taxCode(DocumentCreate.TaxCode.AE) - .addTaxDetail( - DocumentCreate.TaxDetail.builder().amount(0.0).rate("rate").build() - ) - .totalDiscount(0.0) - .totalTax(0.0) - .vatex(DocumentCreate.Vatex.VATEX_EU_79_C) - .vatexNote("vatex_note") - .vendorAddress("vendor_address") - .vendorAddressRecipient("vendor_address_recipient") - .vendorCompanyId("1018265814") - .vendorEmail("vendor_email") - .vendorName("vendor_name") - .vendorTaxId("BE1018265814") .build() ) From 84aef0c44a876e73a4cd03beae355742315b6096 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 9 Feb 2026 10:17:38 +0000 Subject: [PATCH 43/43] release: 0.1.0-alpha.13 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 56 +++++++++++++++++++++++++++++++++++ README.md | 10 +++---- build.gradle.kts | 2 +- 4 files changed, 63 insertions(+), 7 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index fd0ccba..000572e 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.12" + ".": "0.1.0-alpha.13" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 851053c..d948f44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,61 @@ # Changelog +## 0.1.0-alpha.13 (2026-02-09) + +Full Changelog: [v0.1.0-alpha.12...v0.1.0-alpha.13](https://github.com/e-invoice-be/e-invoice-java/compare/v0.1.0-alpha.12...v0.1.0-alpha.13) + +### Features + +* **api:** api update ([60dbcea](https://github.com/e-invoice-be/e-invoice-java/commit/60dbcea186a99adbde90154602023e831daf3632)) +* **api:** api update ([c634578](https://github.com/e-invoice-be/e-invoice-java/commit/c63457882b2760456275e531d05f289c716e5934)) +* **api:** api update ([8af9305](https://github.com/e-invoice-be/e-invoice-java/commit/8af9305dcb70550adbd23bc6b31119eaa5aaf23c)) +* **api:** api update ([2b90fa4](https://github.com/e-invoice-be/e-invoice-java/commit/2b90fa4367258ccc96cdf4fe039efeede2a7048e)) +* **api:** api update ([74c4c9e](https://github.com/e-invoice-be/e-invoice-java/commit/74c4c9e381b260df4545a7180365cf517a65b26f)) +* **api:** api update ([5c08714](https://github.com/e-invoice-be/e-invoice-java/commit/5c0871400561a727de59401802a44d4722e6a09a)) +* **api:** api update ([3ef5ab9](https://github.com/e-invoice-be/e-invoice-java/commit/3ef5ab9f1fd50c8dc83094c6d58212e350e1000e)) +* **api:** api update ([4a468b2](https://github.com/e-invoice-be/e-invoice-java/commit/4a468b27a6b2a2c8e748131b3d4f35176a4e3d98)) +* **api:** api update ([d42fb14](https://github.com/e-invoice-be/e-invoice-java/commit/d42fb14927fcae080a39896743dade19a3f23c81)) +* **api:** api update ([3bc4883](https://github.com/e-invoice-be/e-invoice-java/commit/3bc4883a59e0cc7352dfa41a3c6f67f4efc8ba19)) +* **api:** api update ([010d7f1](https://github.com/e-invoice-be/e-invoice-java/commit/010d7f1fc776ed37da2fb55f96ade8267e184cee)) +* **api:** api update ([02308b8](https://github.com/e-invoice-be/e-invoice-java/commit/02308b86f70414c3008b61e1776f17f1fa8d38f0)) +* **api:** api update ([50eb173](https://github.com/e-invoice-be/e-invoice-java/commit/50eb173e52614313f0474c525571300d31f47003)) +* **api:** api update ([88a2388](https://github.com/e-invoice-be/e-invoice-java/commit/88a2388ce1f68f3ad01ac7ae30aa6fd25c1daa15)) +* **api:** api update ([5b447b4](https://github.com/e-invoice-be/e-invoice-java/commit/5b447b4473189cf6675d79480758e989808dab38)) +* **api:** api update ([7c8d5d6](https://github.com/e-invoice-be/e-invoice-java/commit/7c8d5d6baaf53b8fa24983e413280c44ef6783bb)) +* **api:** api update ([16e58bd](https://github.com/e-invoice-be/e-invoice-java/commit/16e58bd343a028e65724cd766aaea0c96b8a01aa)) +* **api:** manual updates ([4f7dc90](https://github.com/e-invoice-be/e-invoice-java/commit/4f7dc90de5d979ea18f9650a25a4b747e28ce5af)) +* **client:** send `X-Stainless-Kotlin-Version` header ([310f45e](https://github.com/e-invoice-be/e-invoice-java/commit/310f45e949318fdc406d157cebe1525e048e1f7c)) + + +### Bug Fixes + +* **client:** cancel okhttp call when future cancelled ([f34d373](https://github.com/e-invoice-be/e-invoice-java/commit/f34d373cab9477deb15c0c5670166984fe83c850)) +* **client:** multi-value header serialization ([57c75d9](https://github.com/e-invoice-be/e-invoice-java/commit/57c75d98fc1b53bdc1d1544476c6a31cec525601)) +* **client:** preserve time zone in lenient date-time parsing ([2bc9f75](https://github.com/e-invoice-be/e-invoice-java/commit/2bc9f757bcc64596e9db1b2fab3bdeb504e92534)) +* **tests:** add missing query/header params ([a1039c6](https://github.com/e-invoice-be/e-invoice-java/commit/a1039c67421588b13f9a5d522b5baa7c1b150931)) + + +### Chores + +* **internal:** codegen related update ([0bd96de](https://github.com/e-invoice-be/e-invoice-java/commit/0bd96de349c640f0757190242e91a9e315c133e1)) +* **internal:** codegen related update ([20dd5a8](https://github.com/e-invoice-be/e-invoice-java/commit/20dd5a8e841a3649ffe0f76098e1046e1d8f00e9)) +* **internal:** codegen related update ([04ffe93](https://github.com/e-invoice-be/e-invoice-java/commit/04ffe93692ea6714f8825df585864c39b84a2663)) +* **internal:** codegen related update ([eb5c7e5](https://github.com/e-invoice-be/e-invoice-java/commit/eb5c7e54df6ca465861af705907ed654e844d5a5)) +* **internal:** codegen related update ([34d3b25](https://github.com/e-invoice-be/e-invoice-java/commit/34d3b2519e014679f33b0e66e807b13134c12741)) +* **internal:** codegen related update ([6c5b431](https://github.com/e-invoice-be/e-invoice-java/commit/6c5b4313f318f8c7e7a99cade9644bbb2103be72)) +* **internal:** codegen related update ([0059a2f](https://github.com/e-invoice-be/e-invoice-java/commit/0059a2f619a5e17c3bc9f17e7f684e4af983fe60)) +* **internal:** codegen related update ([ee9459a](https://github.com/e-invoice-be/e-invoice-java/commit/ee9459ac80af991d3a9d719f46d28bee16ac1d49)) +* **internal:** codegen related update ([52e1ebb](https://github.com/e-invoice-be/e-invoice-java/commit/52e1ebbb83280db67feb3581a08d3f7241a500f0)) +* **internal:** codegen related update ([b3aad10](https://github.com/e-invoice-be/e-invoice-java/commit/b3aad10fd43571a39c18361ddf3597d68a643531)) +* **internal:** codegen related update ([b5a6a0f](https://github.com/e-invoice-be/e-invoice-java/commit/b5a6a0f7aa5ed8d9a44f27f818da15da3ff30d3f)) +* **internal:** correct cache invalidation for `SKIP_MOCK_TESTS` ([524c037](https://github.com/e-invoice-be/e-invoice-java/commit/524c0373a029f9e0ac7429d05d0e9869dca8a723)) +* **internal:** update maven repo doc to include authentication ([9e69b7f](https://github.com/e-invoice-be/e-invoice-java/commit/9e69b7ff607be2392d5ab6e9796518e129c46fcc)) + + +### Documentation + +* remove `$` for better copy-pasteabality ([4b1c946](https://github.com/e-invoice-be/e-invoice-java/commit/4b1c946cf5e6403194165bf0c92f5160a5e95e32)) + ## 0.1.0-alpha.12 (2025-09-26) Full Changelog: [v0.1.0-alpha.11...v0.1.0-alpha.12](https://github.com/e-invoice-be/e-invoice-java/compare/v0.1.0-alpha.11...v0.1.0-alpha.12) diff --git a/README.md b/README.md index c30f901..3b9ed83 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.e_invoice.api/e-invoice-java)](https://central.sonatype.com/artifact/com.e_invoice.api/e-invoice-java/0.1.0-alpha.12) -[![javadoc](https://javadoc.io/badge2/com.e_invoice.api/e-invoice-java/0.1.0-alpha.12/javadoc.svg)](https://javadoc.io/doc/com.e_invoice.api/e-invoice-java/0.1.0-alpha.12) +[![Maven Central](https://img.shields.io/maven-central/v/com.e_invoice.api/e-invoice-java)](https://central.sonatype.com/artifact/com.e_invoice.api/e-invoice-java/0.1.0-alpha.13) +[![javadoc](https://javadoc.io/badge2/com.e_invoice.api/e-invoice-java/0.1.0-alpha.13/javadoc.svg)](https://javadoc.io/doc/com.e_invoice.api/e-invoice-java/0.1.0-alpha.13) @@ -20,7 +20,7 @@ Use the E Invoice MCP Server to enable AI assistants to interact with this API, -The REST API documentation can be found on [api.e-invoice.be](https://api.e-invoice.be). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.e_invoice.api/e-invoice-java/0.1.0-alpha.12). +The REST API documentation can be found on [api.e-invoice.be](https://api.e-invoice.be). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.e_invoice.api/e-invoice-java/0.1.0-alpha.13). @@ -31,7 +31,7 @@ The REST API documentation can be found on [api.e-invoice.be](https://api.e-invo ### Gradle ```kotlin -implementation("com.e_invoice.api:e-invoice-java:0.1.0-alpha.12") +implementation("com.e_invoice.api:e-invoice-java:0.1.0-alpha.13") ``` ### Maven @@ -40,7 +40,7 @@ implementation("com.e_invoice.api:e-invoice-java:0.1.0-alpha.12") com.e_invoice.api e-invoice-java - 0.1.0-alpha.12 + 0.1.0-alpha.13 ``` diff --git a/build.gradle.kts b/build.gradle.kts index c57fa31..a545472 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ repositories { allprojects { group = "com.e_invoice.api" - version = "0.1.0-alpha.12" // x-release-please-version + version = "0.1.0-alpha.13" // x-release-please-version } subprojects {