Complex shopping cart logic and tax calculation, discount voucher, bundles

I’m in the process of creating a checkout / shopping cart process for a relatively scenario and would like to check if someone has done this before and what the best or rather financially (tax) correct method is to calculate the VAT and discounts to be tax compliant.

It’s not about the actual programming code but more about the correct sequence or logic that should be followed to be financially correct.

To start with we have ‘Passes’ that allow clients to attend sessions based on the pass ‘credits’ Clients can buy this passes in as standalone items or in ‘packs’. Packs are purely a ‘collection’ or Product / Pass combinations and ONLY has a sales value. VAT for packs is based on the items within the pack. They can also have Promotion Codes that can be applied to a specific product or to the cart value.

There’s also ‘Products’ that can be purchased.

NOTE: All the prices are inclusive of VAT

**So Passes:** 
1 - Pass 1 - has 1 credit and price is $25 - vat is 9%
2 - Pass 2 - has 5 credits and price is $100 - vat is 9%
3 - Pass 3 - has 10 credits and price is $180 - vat is 9%
4 - Pass 4 - has 20 credits and price is $340 - vat is 9%


**Products**
1 - Product 1 - price $15 - vat 15%
2 - Product 2 - price $70 - vat 15%
3 - Product 3 - price $11 - vat 9%

**Packs**
1 - Pack 1 - consist of **Pass 1 and Product 1** - price $110 
2 - Pack 2 - consist of **Pass 2 and Product 2** - price $165

**Promo Codes**
1 - Promo 1 - ONLY valid on Pass 2 - value 5% of item value
2 - Promo 2 - valid on cart total - value 5% of cart value


Here's 2 sample carts:

**Cart 1**
1 x Pass 3 @ 180 (this is @ 9% VAT inclusive)
1 x Pack 2 @ 165 (this has 2 items with 9% and 15% VAT)
Client added Promo Code 1 (promo is only valid for Pass 2 which is part of the Pack)


**Cart 2** 
1 x Product 2 @ $8 (this is @ 15% VAT inclusive)
1 x Pack 1 @ $110 (this has 2 items with 9% and 15% VAT)
1 x Pass 2 @ $100 (this is @ 9% inclusive)
1 x Product 3 @ $11 (this is @ 9% inclusive)
Client added Promo Code 2 (promo code is valid for the total cart value)

So the question is how to 1) apply the discounts for the promo codes entered, 2) calculate the discounts.

As you can see from the data above, a Pack is essentially 1 or more products and has a combined selling value for the items in that pack – ie. a discounted value for the items but at a pack level, and the VAT is inclusive so in order to calculate the VAT in a pack you have to pro-rate the actual selling price of the item within the pack then apply the tax/vat. Add to that the promo coupon and the question is what calculation comes first and do you pro-rate @ the inclusive price level or at the exclusive price level? And for the promo at cart level do you now pro-rate ALL the items in the cart or can you apply the discount of subtotal level which will mean your tax breakdown will be incorrect??

I’m sure there must be a specific sequence this needs to be done at in order to be VAT / TAX compliant but I don’t seem to find anything online that describes the sequence or process of how this should be done.

Will be interesting to see as I have discussed with multiple people and I seem to be getting conflicting approached to do this 🙂

Thanks in advance for your views and comments.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật