Inventory Management | Customer Management | Invoice Management Done | Commodity Rate Sync Done

This commit is contained in:
2026-08-20 20:35:41 +05:30
parent ba9a9fd8a4
commit 5f620022f3
101 changed files with 9091 additions and 240 deletions

View File

@@ -25,6 +25,13 @@ class _BusinessSettingsScreenState extends ConsumerState<BusinessSettingsScreen>
_taxIncludedInPrice = profile.taxIncludedInPrice ?? false;
});
}
final feature = ref.read(businessFeatureProvider).value;
if (feature != null) {
setState(() {
_inventoryEnabled = feature.inventoryManagement;
_salesEnabled = feature.salesManagement;
});
}
});
}
@@ -45,17 +52,76 @@ class _BusinessSettingsScreenState extends ConsumerState<BusinessSettingsScreen>
title: const Text('Inventory Management'),
subtitle: const Text('Track stock levels, multiple locations, and products'),
value: _inventoryEnabled,
onChanged: (val) => setState(() => _inventoryEnabled = val),
onChanged: (val) {
setState(() => _inventoryEnabled = val);
_saveFeatures();
},
secondary: const Icon(LucideIcons.package),
),
SwitchListTile(
title: const Text('Sales & POS'),
subtitle: const Text('Enable point of sale, invoicing, and receivables'),
value: _salesEnabled,
onChanged: (val) => setState(() => _salesEnabled = val),
onChanged: (val) {
setState(() => _salesEnabled = val);
_saveFeatures();
},
secondary: const Icon(LucideIcons.shoppingCart),
),
const SizedBox(height: 32),
const Text('Inventory Strategy', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold, color: Colors.grey)),
const SizedBox(height: 16),
Consumer(
builder: (context, ref, child) {
final featureState = ref.watch(businessFeatureProvider);
final currentStrategy = featureState.value?.bomReductionStrategy ?? 'COMPONENTS_ONLY';
final deductParentStock = currentStrategy == 'PARENT_AND_COMPONENTS';
final stockDeductionOnInvoice = featureState.value?.stockDeductionOnInvoice ?? true;
return Column(
children: [
SwitchListTile(
title: const Text('Deduct Parent Stock on BOM Sale'),
subtitle: const Text('If enabled, selling an assembled product reduces both parent and component stock.'),
value: deductParentStock,
secondary: const Icon(LucideIcons.gitMerge),
onChanged: (val) {
if (featureState.value != null) {
final newStrategy = val ? 'PARENT_AND_COMPONENTS' : 'COMPONENTS_ONLY';
final updated = featureState.value!.copyWith(bomReductionStrategy: newStrategy);
ref.read(businessFeatureProvider.notifier).updateFeatures(updated);
}
},
),
SwitchListTile(
title: const Text('Stock Deduction on Invoice'),
subtitle: const Text('If enabled, finalizing an invoice automatically deducts product stock. Turn off for a two-step fulfillment process.'),
value: stockDeductionOnInvoice,
secondary: const Icon(LucideIcons.boxes),
onChanged: (val) {
if (featureState.value != null) {
final updated = featureState.value!.copyWith(stockDeductionOnInvoice: val);
ref.read(businessFeatureProvider.notifier).updateFeatures(updated);
}
},
),
SwitchListTile(
title: const Text('Use EAN/Barcode for Scanner'),
subtitle: const Text('If disabled, the barcode scanner will search using the SKU field instead.'),
value: (featureState.value?.barcodeSource ?? 'SKU') == 'BARCODE',
secondary: const Icon(LucideIcons.scanLine),
onChanged: (val) {
if (featureState.value != null) {
final updated = featureState.value!.copyWith(barcodeSource: val ? 'BARCODE' : 'SKU');
ref.read(businessFeatureProvider.notifier).updateFeatures(updated);
}
},
),
],
);
}
),
const SizedBox(height: 32),
const Text('Pricing & Taxation', style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold, color: Colors.grey)),
const SizedBox(height: 16),
SwitchListTile(
@@ -80,4 +146,15 @@ class _BusinessSettingsScreenState extends ConsumerState<BusinessSettingsScreen>
ref.read(businessProfileProvider.notifier).updateProfile(updated);
}
}
void _saveFeatures() {
final featureState = ref.read(businessFeatureProvider).value;
if (featureState != null) {
final updated = featureState.copyWith(
inventoryManagement: _inventoryEnabled,
salesManagement: _salesEnabled,
);
ref.read(businessFeatureProvider.notifier).updateFeatures(updated);
}
}
}