Additions and modifications
Business
- The
ibanproperty is now checked prior to adding theibanelement to the XML. This solves some validation issues when theibanproperty is not set. - The
registrationNumberproperty is now checked prior to adding theregistrationNumberelement to the XML. This solves some validation issues when theregistrationNumberproperty is not set.
Envelope
- Updated the
issuerandrecipientproperties from the$invoicepassed in the Envelope class, due to changes to the Invoice class. The correct values are nowsellerandbuyerrespectively.
Invoice
- Added the
addDocumentAllowancefunction that takes a class ofInvoiceDiscountas a parameter. The logic is similar to the existingTaxSummary. - Removed the
globalDiscountAmountandglobalDiscountPercentageproperties along with their setters, since the discounts on a document can be multiple not just one. - Added the
sellerproperty along with its settersetSellerto better follow document rules. This has replaced theissuerproperty and the respective setter. - Added the
buyerproperty along with its settersetBuyerto better follow document rules. This has replaced therecipientproperty and the respective setter. - Added the
setSumOfAllowancesfunction that stores the sum of all document allowances. - Added a new
paidAmountproperty along with its settersetPaidAmountto store the amount already paid for the document. This property is optional. - Added a new
roundingAmountproperty along with its settersetRoundingAmountto store a rounding amount value for the document if applicable. This property is optional. - Added a new
amountDueForPaymentproperty along with its settersetAmountDueForPaymentto store the amount due for payment for the document if applicable. This property is optional. If it is not set thetotalWithTaxproperty will be used instead.
InvoiceItem
- Added a new line item unit constant
UNIT_THOUSANDfor theunitproperty. This is used when theunitis measured in items of 1000. - Added the
addItemAllowancefunction that takes a class ofInvoiceItemDiscountas a parameter. The logic is similar to the existingTaxSummary. - Removed the
discountAmountanddiscountPercentageproperties along with their setters, since the discounts on a line item can be multiple not just one. - Removed the
quantityTypeproperty along with its setter, since it is not used anywhere in the code - the type is always fixed to47. - Added a new property
priceWithoutTaxBeforeDiscountsalong with its settersetPriceWithoutTaxBeforeDiscountsto store the price of the line item before any discounts are applied. - Added a new property
itemPriceDiscountalong with its settersetItemPriceDiscountto store the discount amount for the line item. This property is optional.
TaxSummary
- Added a bunch of code constants for all possible vat categories. These are used in the
setCategoryCodefunction. - Renamed the
baseproperty tobaseAmountalong with its settersetBaseAmount.
Segments
- Added segment helper classes to generate commonly used segments from the eSlog2.0 document.
- Current segments are:
- Allowance
- AllowanceInformation
- DateTimePeriod
- Identifier
- MonetaryAmount
- PercentageDetail
Breaking changes
Invoice
issuerrenamed tosellerto better follow document rules. Setters have been updated accordingly fromsetIssuertosetSeller.recipientrenamed tobuyerto better follow document rules. Setters have been updated accordingly fromsetRecipienttosetBuyer.- Removed the
$globalDiscountAmountand$globalDiscountPercentagevariables along with their setters, since the discounts on a document can be multiple not just one. - Replaced the removed variables with a new function
addDocumentAllowancethat takes a class ofInvoiceDiscountas a parameter. The logic is similar to the existingTaxSummary.
An example of the new way to add a discount to the document:
$eInvoice->addDocumentAllowance(
(new \Media24si\eSlog2\InvoiceDiscount())
->setReason('Loyal customer discount')
->setReasonCode(95)
->setAmount(100)
->setPercentage(10)
->setBaseAmount(1000)
->setVatRate(22)
->setVatCategoryCode(\Media24si\eSlog2\TaxSummary::CODE_STANDARD_RATE)
);InvoiceItem
- Removed the
$discountAmountand$discountPercentagevariables along with their setters, since the discounts on a line item can be multiple not just one. - Replaced the removed variables with a new function
addItemAllowancethat takes a class ofInvoiceItemDiscountas a parameter. The logic is similar to the existingTaxSummary.
An example of the new way to add a discount to a line item:
$invoiceItem->addItemAllowance(
(new \Media24si\eSlog2\InvoiceItemDiscount())
->setReason('Loyal customer item discount')
->setReasonCode(95)
->setPercentage(10)
->setAmount(250)
->setBaseAmount(2500)
);TaxSummary
- Renamed the
$basevariable with$baseAmount. Setter has been updated accordingly fromsetBasetosetBaseAmount. - Renamed the
$typevariable to$categoryCode. Setter has been updated accordingly fromsetTypetosetCategoryCode.