uabh perhitungan tax
This commit is contained in:
@@ -588,6 +588,8 @@ class _PosSaleScreenState extends ConsumerState<PosSaleScreen> {
|
||||
productType: variantProduct!.productType,
|
||||
productId: variantProduct!.id ?? 0,
|
||||
quantity: 1,
|
||||
perItemTaxPercentage: variantProduct!.vat?.rate ?? 0,
|
||||
productVatId: variantProduct!.vatId,
|
||||
);
|
||||
|
||||
providerData.addToCartRiverPod(cartItem: cartItem);
|
||||
@@ -738,6 +740,8 @@ class _PosSaleScreenState extends ConsumerState<PosSaleScreen> {
|
||||
productType: product.productType,
|
||||
productId: product.id ?? 0,
|
||||
quantity: 1,
|
||||
perItemTaxPercentage: product.vat?.rate ?? 0,
|
||||
productVatId: product.vatId,
|
||||
);
|
||||
|
||||
providerData.addToCartRiverPod(cartItem: cartItem);
|
||||
@@ -924,91 +928,117 @@ class _PosSaleScreenState extends ConsumerState<PosSaleScreen> {
|
||||
Divider(color: kBorderColorTextField),
|
||||
itemBuilder: (context, index) {
|
||||
final item = providerData.cartItemList[index];
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
item.productName ?? '',
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 14,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'$currency${item.unitPrice}',
|
||||
style: TextStyle(
|
||||
color: kSubPeraColor,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Row(
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
providerData.quantityDecrease(index);
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(4),
|
||||
decoration: BoxDecoration(
|
||||
color: kMainColor.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: const Icon(Icons.remove, size: 16, color: kMainColor),
|
||||
final double quantity = (item.quantity ?? 0).toDouble();
|
||||
final double unitPrice = (item.unitPrice ?? 0).toDouble();
|
||||
final double itemVAT = (unitPrice * quantity * (item.perItemTaxPercentage ?? 0)) / 100;
|
||||
final double originalTotal = unitPrice * quantity;
|
||||
final double finalTotal = originalTotal + itemVAT;
|
||||
|
||||
return SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
// 1. Product Name
|
||||
SizedBox(
|
||||
width: 140, // Fixed width to allow scrolling and wrapping
|
||||
child: Text(
|
||||
item.productName ?? '',
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.w600,
|
||||
fontSize: 14,
|
||||
),
|
||||
maxLines: 2,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
|
||||
// 2. Decrease Icon
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
providerData.quantityDecrease(index);
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(4),
|
||||
decoration: BoxDecoration(
|
||||
color: kMainColor.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: const Icon(Icons.remove, size: 16, color: kMainColor),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
|
||||
// 3. Qty Order
|
||||
Text(
|
||||
'${item.quantity}',
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
|
||||
// 4. Increase Icon
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
providerData.quantityIncrease(index);
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(4),
|
||||
decoration: BoxDecoration(
|
||||
color: kMainColor.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: const Icon(Icons.add, size: 16, color: kMainColor),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
|
||||
// 5. Value Original
|
||||
Text(
|
||||
'$currency${originalTotal.toStringAsFixed(2)}',
|
||||
style: TextStyle(
|
||||
color: kSubPeraColor,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
|
||||
// 6. Value VAT/Tax
|
||||
if (itemVAT > 0) ...[
|
||||
Text(
|
||||
'${item.quantity}',
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
providerData.quantityIncrease(index);
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(4),
|
||||
decoration: BoxDecoration(
|
||||
color: kMainColor.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: const Icon(Icons.add, size: 16, color: kMainColor),
|
||||
'VAT: $currency${itemVAT.toStringAsFixed(2)}',
|
||||
style: TextStyle(
|
||||
color: kSubPeraColor,
|
||||
fontSize: 10,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Text(
|
||||
'$currency${(item.unitPrice ?? 0) * (item.quantity ?? 0)}',
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: kMainColor,
|
||||
fontSize: 14,
|
||||
|
||||
// 7. Sum (Value Original + VAT/Tax)
|
||||
Text(
|
||||
'$currency${finalTotal.toStringAsFixed(2)}',
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: kMainColor,
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
providerData.deleteToCart(index);
|
||||
},
|
||||
child: const Icon(
|
||||
Icons.delete_outline,
|
||||
color: Colors.red,
|
||||
size: 20,
|
||||
const SizedBox(width: 12),
|
||||
|
||||
// Delete Icon (Keeping it for usability)
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
providerData.deleteToCart(index);
|
||||
},
|
||||
child: const Icon(
|
||||
Icons.delete_outline,
|
||||
color: Colors.red,
|
||||
size: 20,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user