Skip to content

Releases: Media24si/eslog2

Refactor of the work in progress with some breaking changes

24 Oct 05:31
Compare
Choose a tag to compare

Additions and modifications

Business

  • The iban property is now checked prior to adding the iban element to the XML. This solves some validation issues when the iban property is not set.
  • The registrationNumber property is now checked prior to adding the registrationNumber element to the XML. This solves some validation issues when the registrationNumber property is not set.

Envelope

  • Updated the issuer and recipient properties from the $invoice passed in the Envelope class, due to changes to the Invoice class. The correct values are now seller and buyer respectively.

Invoice

  • Added the addDocumentAllowance function that takes a class of InvoiceDiscount as a parameter. The logic is similar to the existing TaxSummary.
  • Removed the globalDiscountAmount and globalDiscountPercentage properties along with their setters, since the discounts on a document can be multiple not just one.
  • Added the seller property along with its setter setSeller to better follow document rules. This has replaced the issuer property and the respective setter.
  • Added the buyer property along with its setter setBuyer to better follow document rules. This has replaced the recipient property and the respective setter.
  • Added the setSumOfAllowances function that stores the sum of all document allowances.
  • Added a new paidAmount property along with its setter setPaidAmount to store the amount already paid for the document. This property is optional.
  • Added a new roundingAmount property along with its setter setRoundingAmount to store a rounding amount value for the document if applicable. This property is optional.
  • Added a new amountDueForPayment property along with its setter setAmountDueForPayment to store the amount due for payment for the document if applicable. This property is optional. If it is not set the totalWithTax property will be used instead.

InvoiceItem

  • Added a new line item unit constant UNIT_THOUSAND for the unit property. This is used when the unit is measured in items of 1000.
  • Added the addItemAllowance function that takes a class of InvoiceItemDiscount as a parameter. The logic is similar to the existing TaxSummary.
  • Removed the discountAmount and discountPercentage properties along with their setters, since the discounts on a line item can be multiple not just one.
  • Removed the quantityType property along with its setter, since it is not used anywhere in the code - the type is always fixed to 47.
  • Added a new property priceWithoutTaxBeforeDiscounts along with its setter setPriceWithoutTaxBeforeDiscounts to store the price of the line item before any discounts are applied.
  • Added a new property itemPriceDiscount along with its setter setItemPriceDiscount to 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 setCategoryCode function.
  • Renamed the base property to baseAmount along with its setter setBaseAmount.

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

  • issuer renamed to seller to better follow document rules. Setters have been updated accordingly from setIssuer to setSeller.
  • recipient renamed to buyer to better follow document rules. Setters have been updated accordingly from setRecipient to setBuyer.
  • Removed the $globalDiscountAmount and $globalDiscountPercentage variables along with their setters, since the discounts on a document can be multiple not just one.
  • Replaced the removed variables with a new function addDocumentAllowance that takes a class of InvoiceDiscount as a parameter. The logic is similar to the existing TaxSummary.
    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 $discountAmount and $discountPercentage variables 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 addItemAllowance that takes a class of InvoiceItemDiscount as a parameter. The logic is similar to the existing TaxSummary.
    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 $base variable with $baseAmount. Setter has been updated accordingly from setBase to setBaseAmount.
  • Renamed the $type variable to $categoryCode. Setter has been updated accordingly from setType to setCategoryCode.

Initial work in progress version

20 Oct 07:13
Compare
Choose a tag to compare

Initial work in progress version.

Tagged since v0.2.0 will have significant breaking changes.