Skip to content

Commit

Permalink
MOL-1299: Correct VAT Promotion Calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Thilo Lindner committed Apr 5, 2024
1 parent abff673 commit 595deac
Showing 1 changed file with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,22 +214,23 @@ export default class RefundItemService {
if (item.refundQuantity > 0 && item.refundQuantity + item.refunded === item.shopware.quantity) {
refundTaxAmount += item.shopware.tax.totalToPerItemRoundingDiff;
}
}

if (item.refundPromotion) {
// we have to calculate the amount of a single item, because
// the promotion discount is the full discount on all of these items.
const discountPerQty = item.shopware.promotion.discount / item.shopware.promotion.quantity;
const discount = (item.refundQuantity * discountPerQty);
const promotionTaxValuePerQty = item.shopware.promotion.taxValue / item.shopware.promotion.quantity;

let promotionTaxValue = 0;
if (item.refundTax) {
promotionTaxValue = promotionTaxValuePerQty * item.refundQuantity;
}

item.refundAmount = newRefundAmount + refundTaxAmount - discount - promotionTaxValue;
refundTaxAmount -= promotionTaxValue;
}

if (item.refundPromotion) {
// we have to calculate the amount of a single item, because
// the promotion discount is the full discount on all of these items.
const discountPerQty = item.shopware.promotion.discount / item.shopware.promotion.quantity;
const discount = (item.refundQuantity * discountPerQty);

item.refundAmount = newRefundAmount + refundTaxAmount - discount;
} else {
item.refundAmount = newRefundAmount + refundTaxAmount;
}
Expand Down

0 comments on commit 595deac

Please sign in to comment.