In this section, various fields used to hold information and make calculations are described, along with the default formulas used.
The pricing fields of an order can be catagorised as
- Information fields: fields that merely contains information, such as price and vat percentage.
- Calculated fields: Fields that are calculated using the information fields. These fields are calculated in the pricing rules plugin. Since they are calculated, any value entered manually will be overwritten.
Order row
The order row is used to record a single type of item purchased, and the quantity purchased. Orders may have one or more order rows. There can be different order rows with similar items, but a single order row will have only one type of item, and can only use an order row level campaign once.
Information fields
UnitCampaignPrice: Special campaign price of an article, this special price is calculated by an Order Row Level Campaign. This price is for a single unit of item, such as "one mobile phone", or "one litre of oil".
UnitListPrice: Price of an article.This price is for a single unit of item, such as "one mobile phone", or "one litre of oil".
DiscountPercentage: Percentage of discount applicable for the order row.
VATPercentage: Percentage of VAT applicable for this article.
Calculated fields
TotalDiscountAmount = UnitListPrice x Quantity x DiscountPercentage IF THERE IS NO order row level campaign.
TotalDiscountAmount = UnitCampaignPrice x Quantity x DiscountPercentage IF an order level campaign is applied.
TotalPrice = UnitListPrice x Quantity - OrderRow TotalDiscountAmount IF THERE IS NO order row level campaign.
TotalPrice = UnitCampaignPrice x Quantity - OrderRow TotalDiscountAmount, IF an order row level campaign is applied.
TotalVATAmount = TotalPrice x VATPercentage
TotalPriceWithVAT = TotalPrice + TotalVATAmount
Notes
1) TotalVATAmount is based on TotalPrice and TotalPrice is based on UnitCampaignPrice and TotalDiscountAmount where applicable. What this means is, VAT is automatically reduced to any discounts or special prices given. You should take note of this when developing campaigns, the campaign special price should be without taking VAT into account.
2) TotalDiscountAmount is applied on top of UnitCampaignPrice if campaigns are applied. This means, you will be giving a cumulative discount if a discount percentage is specified for the order row, if, at the same time, the order row becomes eligible for a campaign.
3) TotalPrice does not include VAT, it's the TotalPriceWithVAT that contains the price with vat.
Deliveries
Records information about deliveries. There can be multiple deliveries for a order.
Information fields
- DeliveryCost: Cost to deliver goods. This can be the amount paid to delivering company, postage or frieght charges. Value should be without VAT.
- CampaignDiscountAmount: Campaign discount if applicable to this delivery. The value should be without VAT.
Calculated fields
- VATPercentage = Weight average VAT percentage based on VAT amounts in the order rows.
- TotalDeliveryCost = DeliveryCost - CampaignDiscountAmount
- TotalVATAmount = TotalDeliveryCost x VATPercentage
- TotalDeliveryCostWithVat = TotalDeliveryCost + TotalVATAmount
You can set the TotalDeliveryCostWithVat and then set KeepDeliveryCostWithVatConstant property to true, in which case TotalDeliveryCostWithVat will be the information field, and VAT calculator will calculate the correct DeliveryCost which will be the calculated field.
Fees
Fees applicable for processing the order, such as special order handling fees, administration fees, etc. There can be multiple fee rows.
Information fields
- Amount: Fee amount. The value should be without VAT.
- CampaignDiscountAmount: Campaign discount if applicable to this fee. The value should be without VAT.
Calculated fields
- TotalAmount = Amount - CampaignDiscountAmount.
- VATPercentage = Weight average VAT percentage based on VAT amounts in the order rows.
- TotalVATAmount = TotalFee x VATPercentage.
- TotalAmountWithVAT = TotalFee x TotalVATAmount.
You can set the TotalFeeWithVat and then set KeepAmountWithVATConstant property to true, in which case TotalAmountWithVAT will be the information field, and VAT calculator will calculate the correct TotalAmount which will be the calculated field.
Order discount
Represents a discount applicable for the whole order. This discount should include reduction of VAT that will happen because of the descount. That means, for example, if a discount of say 100 SEK is given to a end customer, some amount out of this 100 SEK will actually be VAT. Please see the Calculating Order Grand Total and Calculating VAT topics for more details.
Information fields
- DiscountAmountWithVAT: The amount of the discount, including VAT reduction.
- DiscountPercentage: The percentage of discount. Note: this field is not used in the default calculations implementation.
Calculated fields
- VATPercentage = Weight average VAT percentage based on VAT amounts on the order rows.
- DiscountAmount = DiscountAmountWithVAT / (1+ VATPercentage).
- VATAmount = DiscountAmount x VATPercentage.
Order
When it comes to pricing, an order only has calculated fields. All the information for the calculated fields are present in field of the component parts of the order: order rows, deliveries, fees, order discounts, order campaign discounts.
Calculated fields
- Total = Sum of TotalPrice of the order rows (VAT not included).
- TotalOrderRowVAT = Sum of TotalVATAmount of the order rows.
- TotalWithVAT = Total + TotalOrderRowVAT.
- TotalDeliveryCost = Sum of TotalDeliveryCost of the deliveries (VAT not included).
- TotalDeliveryCostVAT = Sum of TotalVATAmount of the deliveries.
- TotalDeliveryCostWithVAT = TotalDeliveryCost + TotalDeliveryCostVAT.
- TotalFee = Sum of TotalFee in fees (VAT not included).
- TotalFeeVAT = Sum of TotalVATAmount in fees.
- TotalFeeWithVAT = TotalFee + TotalFeeVAT.
- TotalDiscount = Sum of DiscountAmount of order discounts (VAT not included).
- TotalDiscountVAT = Sum of VATAmount of order discounts.
- TotalDiscountWithVAT = TotalDiscount + TotalDiscountVAT.
- TotalVat = TotalOrderRowVAT + TotalDeliveryCostVAT + TotalFeeVAT - TotalDiscountVAT.
- GrandTotal = Total + TotalDeliveryCost + TotalFee + TotalVAT - TotalDiscount
Payment info
Payment info is used to represent a payment made for the order. Payment info is used by the payment providers to find out how much amount should be charged from the end customer.
Information fields
- Amount: The amount to be charged from customer. This information is set to Order GrandTotal. Therefore, this includes VAT.
- VATAmount: The amount of VAT. This information is set to Order TotalVat.
- TotalAmountWithVAT: The Amount with VAT. This is not a calculated field, but set by the IPaymentInfoCalculator.CalculateFromCarrier method.
Calculated fields
- VATPercentage: VATAmount / (Amount - VATAmount).