uabh perhitungan tax
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user