Fixed double entry issue

This commit is contained in:
2026-08-30 21:06:46 +05:30
parent eb39d5ff90
commit a0e7a898fa
7 changed files with 198 additions and 53 deletions

View File

@@ -240,12 +240,16 @@ class _ProductListScreenState extends ConsumerState<ProductListScreen> {
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
(p.currentStock != null)
? 'Stock: ${p.currentStock ?? 0}'
p.currentStock != null
? (p.currentStock! > 0
? 'Stock: ${p.currentStock! % 1 == 0 ? p.currentStock!.toInt() : p.currentStock}'
: 'Out of Stock')
: 'Untracked',
style: TextStyle(
color: (p.currentStock != null)
? Colors.orange
color: p.currentStock != null
? (p.currentStock! > 0
? const Color(0xFF10B981)
: Colors.red)
: Colors.grey,
fontSize: 12,
fontWeight: FontWeight.bold,

View File

@@ -421,7 +421,10 @@ class _InvoiceBuilderScreenState extends ConsumerState<InvoiceBuilderScreen> {
totalAmount: grandTotal,
amountPaid: validAmountPaid,
paymentMethod: validAmountPaid > 0 ? _paymentMethod : null,
paymentWalletId: validAmountPaid > 0 ? (_selectedWalletId ?? ref.read(walletProvider).value?.firstOrNull?.id) : null,
paymentWalletId: validAmountPaid > 0
? (_selectedWalletId ??
ref.read(walletProvider).value?.where((w) => w.nature == 'CASH' || w.nature == 'SAVINGS').firstOrNull?.id)
: null,
nextPaymentDate: balanceDue > 0.01 ? (_nextPaymentDate ?? DateTime.now().add(const Duration(days: 30))) : null,
status: widget.existingInvoice != null
? (isFullyPaid ? 'PAID' : (validAmountPaid > 0.01 ? 'PARTIAL' : widget.existingInvoice!.status))