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

@@ -450,6 +450,34 @@ class _InvoiceBuilderScreenState extends ConsumerState<InvoiceBuilderScreen> {
const Text('Line Items', style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16)),
Row(
children: [
Consumer(
builder: (context, ref, child) {
final feature = ref.watch(businessFeatureProvider).value;
final isBarcode = feature?.barcodeSource == 'BARCODE';
return Row(
children: [
Text('Scan by:', style: TextStyle(fontSize: 12, color: Colors.grey.shade600)),
const SizedBox(width: 4),
Text('SKU', style: TextStyle(fontSize: 10, fontWeight: !isBarcode ? FontWeight.bold : FontWeight.normal, color: !isBarcode ? Colors.blue : Colors.grey)),
Transform.scale(
scale: 0.7,
child: Switch(
value: isBarcode,
activeColor: Colors.blue,
onChanged: (val) {
if (feature != null) {
ref.read(businessFeatureProvider.notifier).updateFeatures(
feature.copyWith(barcodeSource: val ? 'BARCODE' : 'SKU')
);
}
},
),
),
Text('EAN', style: TextStyle(fontSize: 10, fontWeight: isBarcode ? FontWeight.bold : FontWeight.normal, color: isBarcode ? Colors.blue : Colors.grey)),
],
);
},
),
IconButton(
icon: const Icon(LucideIcons.scanLine, color: Colors.blue),
onPressed: _scanAndAddBarcode,
@@ -595,10 +623,25 @@ class _InvoiceBuilderScreenState extends ConsumerState<InvoiceBuilderScreen> {
child: Consumer(
builder: (context, consumerRef, _) {
final walletsState = consumerRef.watch(walletProvider);
final wallets = walletsState.value ?? [];
final allWallets = walletsState.value ?? [];
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))) {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) setState(() => _selectedWalletId = wallets.first.id);
});
}
return DropdownButtonHideUnderline(
child: DropdownButton<int>(
value: _selectedWalletId ?? wallets.firstOrNull?.id,
value: _selectedWalletId,
isDense: true,
hint: const Text('Wallet'),
items: wallets
@@ -626,7 +669,14 @@ class _InvoiceBuilderScreenState extends ConsumerState<InvoiceBuilderScreen> {
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;
});
}
},
),
),
),