uabh perhitungan tax

This commit is contained in:
2026-02-08 14:58:52 +07:00
parent 0bebe34f19
commit d144d24596
7 changed files with 289 additions and 221 deletions

View File

@@ -132,11 +132,26 @@ class CartNotifier extends ChangeNotifier {
totalPayableAmount -= discountAmount;
}
// Apply VAT
if (selectedVat?.rate != null) {
vatAmount = (totalPayableAmount * selectedVat!.rate!) / 100;
vatAmountController.text = vatAmount.toStringAsFixed(2);
// Apply Item-wise VAT
vatAmount = 0;
for (var element in cartItemList) {
num unitPrice = element.unitPrice ?? 0;
num quantity = element.quantity;
num taxRate = element.perItemTaxPercentage ?? 0;
// VAT Formula: (Price * Qty * Rate%)
// Note: We are calculating VAT on the base price, not discounted price if that's the requirement.
// But usually VAT is on the final price.
// The user request "QTY x Harga x % dari vat_id" implies Base Price.
// If it should be on discounted price, we would subtract productDiscount.
// Assuming "Harga" refers to the selling price.
num itemVat = (unitPrice * quantity * taxRate) / 100;
vatAmount += itemVat;
}
vatAmountController.text = vatAmount.toStringAsFixed(2);
// Add Total VAT to Payable
totalPayableAmount += vatAmount;
// Apply Shipping