Project management related changes
This commit is contained in:
46
scratch/patch_builder.py
Normal file
46
scratch/patch_builder.py
Normal file
@@ -0,0 +1,46 @@
|
||||
import re
|
||||
|
||||
with open('kifi-app/lib/features/sales/presentation/invoice_builder_screen.dart', 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
# Add initialItems to constructor
|
||||
content = content.replace(
|
||||
'const InvoiceBuilderScreen({super.key});',
|
||||
'final List<InvoiceItem>? initialItems;\n final int? initialCustomerId;\n\n const InvoiceBuilderScreen({super.key, this.initialItems, this.initialCustomerId});'
|
||||
)
|
||||
|
||||
# Populate initial items
|
||||
init_state = """
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (widget.initialItems != null) {
|
||||
_items.addAll(widget.initialItems!);
|
||||
}
|
||||
}
|
||||
|
||||
void _loadInitialCustomer() {
|
||||
if (widget.initialCustomerId != null && _selectedCustomer == null) {
|
||||
final customers = ref.read(customersProvider).value;
|
||||
if (customers != null) {
|
||||
final cust = customers.where((c) => c.id == widget.initialCustomerId).firstOrNull;
|
||||
if (cust != null) {
|
||||
setState(() {
|
||||
_selectedCustomer = cust;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
content = content.replace(' bool _isEmi = false;', ' bool _isEmi = false;\n' + init_state)
|
||||
|
||||
# Call _loadInitialCustomer in build
|
||||
content = content.replace(
|
||||
'Widget build(BuildContext context) {',
|
||||
'Widget build(BuildContext context) {\n _loadInitialCustomer();'
|
||||
)
|
||||
|
||||
with open('kifi-app/lib/features/sales/presentation/invoice_builder_screen.dart', 'w') as f:
|
||||
f.write(content)
|
||||
Reference in New Issue
Block a user