Fixed bugs

This commit is contained in:
2026-08-20 22:02:38 +05:30
parent 5f620022f3
commit fc0faafa18
7 changed files with 198 additions and 22 deletions

View File

@@ -31,9 +31,17 @@ class _ReceivePaymentSheetState extends ConsumerState<ReceivePaymentSheet> {
@override
Widget build(BuildContext context) {
final walletsState = ref.watch(walletProvider);
final wallets = walletsState.value ?? [];
final allWallets = walletsState.value ?? [];
if (wallets.isNotEmpty && _selectedWalletId == null) {
final wallets = allWallets.where((w) {
if (_paymentMethod == 'Cash') {
return w.nature == 'CASH';
} else {
return w.nature == 'INCOME' || w.nature == 'SAVINGS';
}
}).toList();
if (wallets.isNotEmpty && (_selectedWalletId == null || !wallets.any((w) => w.id == _selectedWalletId))) {
_selectedWalletId = wallets.first.id;
}
@@ -102,7 +110,14 @@ class _ReceivePaymentSheetState extends ConsumerState<ReceivePaymentSheet> {
items: ['Cash', 'UPI', 'Bank Transfer', 'Card']
.map((m) => DropdownMenuItem(value: m, child: Text(m)))
.toList(),
onChanged: (val) => setState(() => _paymentMethod = val!),
onChanged: (val) {
if (val != null) {
setState(() {
_paymentMethod = val;
_selectedWalletId = null;
});
}
},
),
),
),