Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sai Srinivas
GEN_ERP_2025
Commits
c1b1af92
Commit
c1b1af92
authored
Aug 12, 2025
by
Sai Srinivas
Browse files
12-08-2025 By Sai Srinivas
Order Module - Add
parent
ad026e51
Changes
5
Hide whitespace changes
Inline
Side-by-side
lib/Notifiers/ordersProvider/addOrderProvider.dart
View file @
c1b1af92
import
'dart:async'
;
import
'dart:async'
;
import
'dart:convert'
;
import
'dart:io'
;
import
'dart:io'
;
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/cupertino.dart'
;
...
@@ -54,6 +55,21 @@ class Addorderprovider extends ChangeNotifier {
...
@@ -54,6 +55,21 @@ class Addorderprovider extends ChangeNotifier {
List
<
TextEditingController
>
TotalPriceControllers
=
[];
List
<
TextEditingController
>
TotalPriceControllers
=
[];
List
<
TextEditingController
>
TaxableValueControllers
=
[];
List
<
TextEditingController
>
TaxableValueControllers
=
[];
TextEditingController
ProductController
=
TextEditingController
();
TextEditingController
PriceController
=
TextEditingController
();
TextEditingController
QuantityController
=
TextEditingController
(
text:
"1"
);
TextEditingController
CGSTController
=
TextEditingController
(
text:
"9"
);
TextEditingController
SGSTController
=
TextEditingController
(
text:
"9"
);
TextEditingController
IGSTController
=
TextEditingController
(
text:
"0"
);
TextEditingController
TotalPriceController
=
TextEditingController
();
TextEditingController
TaxableValueController
=
TextEditingController
();
List
<
Map
<
String
,
dynamic
>>
_productRows
=
[];
// For backend
List
<
Map
<
String
,
dynamic
>>
get
productRows
=>
_productRows
;
TextEditingController
basicAmountReadOnlyController
=
TextEditingController
();
TextEditingController
basicAmountReadOnlyController
=
TextEditingController
();
TextEditingController
cgstReadOnlyController
=
TextEditingController
();
TextEditingController
cgstReadOnlyController
=
TextEditingController
();
TextEditingController
sgstReadOnlyController
=
TextEditingController
();
TextEditingController
sgstReadOnlyController
=
TextEditingController
();
...
@@ -79,21 +95,26 @@ class Addorderprovider extends ChangeNotifier {
...
@@ -79,21 +95,26 @@ class Addorderprovider extends ChangeNotifier {
AccountDetails
_accountDetails
=
AccountDetails
();
AccountDetails
_accountDetails
=
AccountDetails
();
String
selectAccountError
=
""
;
String
?
selectAccountError
;
String
orderDateError
=
""
;
String
?
orderDateError
;
String
billingNameError
=
""
;
String
?
billingNameError
;
String
billingAddressError
=
""
;
String
?
billingAddressError
;
String
billingPincodeError
=
""
;
String
?
billingPincodeError
;
String
dispatchAddressError
=
""
;
String
?
dispatchAddressError
;
String
dispatchPincodeError
=
""
;
String
?
dispatchPincodeError
;
String
tpcAmountError
=
""
;
String
?
tpcAmountError
;
String
gstError
=
""
;
String
?
gstError
;
String
selectedBillingStateError
=
""
;
String
?
selectedBillingStateError
;
String
selectedBillingDistrictError
=
""
;
String
?
selectedBillingDistrictError
;
String
selectedBillingSubLocError
=
""
;
String
?
selectedBillingSubLocError
;
String
selectedDispatchStateError
=
""
;
String
?
selectedDispatchStateError
;
String
selectedDispatchDistrictError
=
""
;
String
?
selectedDispatchDistrictError
;
String
selectedDispatchSubLocError
=
""
;
String
?
selectedDispatchSubLocError
;
String
?
selectedTPCApplicableError
;
String
?
selectedUnloadingScopeError
;
String
?
selectedFreightScopeError
;
String
?
selectedErectionScopeError
;
String
?
selectedTPCAgentError
;
AccountList
?
_selectedAccountList
;
AccountList
?
_selectedAccountList
;
String
?
_selectedAccountID
;
String
?
_selectedAccountID
;
...
@@ -131,6 +152,7 @@ class Addorderprovider extends ChangeNotifier {
...
@@ -131,6 +152,7 @@ class Addorderprovider extends ChangeNotifier {
List
<
String
?>
_selectedSaleProductID
=
[];
List
<
String
?>
_selectedSaleProductID
=
[];
String
?
_selectedSaleProductName
;
String
?
_selectedSaleProductName
;
String
?
_selectedSingleSaleProductID
;
String
?
_selectedUnloadingScope
;
String
?
_selectedUnloadingScope
;
String
?
_selectedFreightScope
;
String
?
_selectedFreightScope
;
...
@@ -149,7 +171,6 @@ class Addorderprovider extends ChangeNotifier {
...
@@ -149,7 +171,6 @@ class Addorderprovider extends ChangeNotifier {
bool
hasLocationPermission
=
false
;
bool
hasLocationPermission
=
false
;
String
?
FileError
;
String
?
FileError
;
String
?
dateError
;
bool
_isLoading
=
false
;
bool
_isLoading
=
false
;
int
_imagePicked
=
0
;
int
_imagePicked
=
0
;
File
?
_image
;
File
?
_image
;
...
@@ -159,7 +180,7 @@ class Addorderprovider extends ChangeNotifier {
...
@@ -159,7 +180,7 @@ class Addorderprovider extends ChangeNotifier {
String
?
_formattedDate
;
String
?
_formattedDate
;
Timer
?
_debounce
;
Timer
?
_debounce
;
List
<
Map
<
String
,
String
>>
_selectedOrders
=
[];
List
<
Map
<
String
,
String
>>
_selectedOrders
=
[];
String
?
productsEmptyError
;
List
<
Map
<
String
,
String
>>
get
selectedOrders
=>
_selectedOrders
;
List
<
Map
<
String
,
String
>>
get
selectedOrders
=>
_selectedOrders
;
bool
_submitClicked
=
false
;
bool
_submitClicked
=
false
;
...
@@ -175,7 +196,11 @@ class Addorderprovider extends ChangeNotifier {
...
@@ -175,7 +196,11 @@ class Addorderprovider extends ChangeNotifier {
_selectedOrders
=
selectedOrders
;
_selectedOrders
=
selectedOrders
;
notifyListeners
();
notifyListeners
();
}
}
set
productRows
(
value
)
{
_productRows
=
value
;
productsEmptyError
=
""
;
notifyListeners
();
}
bool
get
isLoading
=>
_isLoading
;
bool
get
isLoading
=>
_isLoading
;
String
?
get
formattedDate
=>
_formattedDate
;
String
?
get
formattedDate
=>
_formattedDate
;
...
@@ -270,6 +295,7 @@ class Addorderprovider extends ChangeNotifier {
...
@@ -270,6 +295,7 @@ class Addorderprovider extends ChangeNotifier {
List
<
String
?>
get
selectedSaleProductID
=>
_selectedSaleProductID
;
List
<
String
?>
get
selectedSaleProductID
=>
_selectedSaleProductID
;
String
?
get
selectedSaleProductName
=>
_selectedSaleProductName
;
String
?
get
selectedSaleProductName
=>
_selectedSaleProductName
;
String
?
get
selectedSingleSaleProductID
=>
_selectedSingleSaleProductID
;
String
?
get
selectedUnloadingScope
=>
_selectedUnloadingScope
;
String
?
get
selectedUnloadingScope
=>
_selectedUnloadingScope
;
...
@@ -442,6 +468,7 @@ class Addorderprovider extends ChangeNotifier {
...
@@ -442,6 +468,7 @@ class Addorderprovider extends ChangeNotifier {
set
selectedSaleProducts
(
SaleProducts
?
value
)
{
set
selectedSaleProducts
(
SaleProducts
?
value
)
{
_selectedSaleProducts
=
value
;
_selectedSaleProducts
=
value
;
_selectedSingleSaleProductID
=
value
!.
id
!;
// _selectedSaleProductID = value!.id!;
// _selectedSaleProductID = value!.id!;
// _selectedSaleProductName = value!.prodName;
// _selectedSaleProductName = value!.prodName;
notifyListeners
();
notifyListeners
();
...
@@ -451,6 +478,10 @@ class Addorderprovider extends ChangeNotifier {
...
@@ -451,6 +478,10 @@ class Addorderprovider extends ChangeNotifier {
_selectedSaleProductID
=
value
;
_selectedSaleProductID
=
value
;
notifyListeners
();
notifyListeners
();
}
}
set
selectedSingleSaleProductID
(
String
?
value
){
_selectedSingleSaleProductID
=
value
;
notifyListeners
();
}
set
selectedSaleProductName
(
String
?
value
)
{
set
selectedSaleProductName
(
String
?
value
)
{
_selectedSaleProductName
=
value
;
_selectedSaleProductName
=
value
;
...
@@ -459,21 +490,25 @@ class Addorderprovider extends ChangeNotifier {
...
@@ -459,21 +490,25 @@ class Addorderprovider extends ChangeNotifier {
set
selectedUnloadingScope
(
String
?
value
)
{
set
selectedUnloadingScope
(
String
?
value
)
{
_selectedUnloadingScope
=
value
;
_selectedUnloadingScope
=
value
;
selectedUnloadingScopeError
=
""
;
notifyListeners
();
notifyListeners
();
}
}
set
selectedFreightScope
(
String
?
value
)
{
set
selectedFreightScope
(
String
?
value
)
{
_selectedFreightScope
=
value
;
_selectedFreightScope
=
value
;
selectedFreightScopeError
=
""
;
notifyListeners
();
notifyListeners
();
}
}
set
selectedErectionScope
(
String
?
value
)
{
set
selectedErectionScope
(
String
?
value
)
{
_selectedErectionScope
=
value
;
_selectedErectionScope
=
value
;
selectedErectionScopeError
=
""
;
notifyListeners
();
notifyListeners
();
}
}
set
selectedTpcStatus
(
String
?
value
)
{
set
selectedTpcStatus
(
String
?
value
)
{
_selectedTpcStatus
=
value
;
_selectedTpcStatus
=
value
;
selectedTPCApplicableError
=
""
;
notifyListeners
();
notifyListeners
();
}
}
...
@@ -481,6 +516,7 @@ class Addorderprovider extends ChangeNotifier {
...
@@ -481,6 +516,7 @@ class Addorderprovider extends ChangeNotifier {
_selectedTpcAgent
=
value
;
_selectedTpcAgent
=
value
;
_selectedTpcAgentID
=
value
!.
id
;
_selectedTpcAgentID
=
value
!.
id
;
_selectedTpcAgentValue
=
value
!.
text
;
_selectedTpcAgentValue
=
value
!.
text
;
selectedTPCAgentError
=
""
;
notifyListeners
();
notifyListeners
();
}
}
...
@@ -501,6 +537,7 @@ class Addorderprovider extends ChangeNotifier {
...
@@ -501,6 +537,7 @@ class Addorderprovider extends ChangeNotifier {
set
imagePath
(
File
?
value
)
{
set
imagePath
(
File
?
value
)
{
_imageName
=
value
;
_imageName
=
value
;
FileError
=
null
;
notifyListeners
();
notifyListeners
();
}
}
...
@@ -517,7 +554,7 @@ class Addorderprovider extends ChangeNotifier {
...
@@ -517,7 +554,7 @@ class Addorderprovider extends ChangeNotifier {
set
formattedDate
(
String
?
value
)
{
set
formattedDate
(
String
?
value
)
{
_formattedDate
=
value
;
_formattedDate
=
value
;
orderReceivedDateController
.
text
=
_formattedDate
!;
orderReceivedDateController
.
text
=
_formattedDate
!;
d
ateError
=
null
;
orderD
ateError
=
null
;
notifyListeners
();
notifyListeners
();
}
}
...
@@ -525,7 +562,7 @@ class Addorderprovider extends ChangeNotifier {
...
@@ -525,7 +562,7 @@ class Addorderprovider extends ChangeNotifier {
_date
=
newDate
;
_date
=
newDate
;
_formattedDate
=
DateFormat
(
'yyyy-MM-dd'
).
format
(
newDate
);
_formattedDate
=
DateFormat
(
'yyyy-MM-dd'
).
format
(
newDate
);
orderReceivedDateController
.
text
=
_formattedDate
!;
orderReceivedDateController
.
text
=
_formattedDate
!;
d
ateError
=
null
;
orderD
ateError
=
null
;
notifyListeners
();
notifyListeners
();
}
}
...
@@ -580,6 +617,67 @@ class Addorderprovider extends ChangeNotifier {
...
@@ -580,6 +617,67 @@ class Addorderprovider extends ChangeNotifier {
return
total
!;
return
total
!;
}
}
void
addProduct
(
Map
<
String
,
dynamic
>
product
)
{
productRows
.
add
(
product
);
notifyListeners
();
}
void
updateProduct
(
int
index
,
Map
<
String
,
dynamic
>
updatedProduct
)
{
productRows
[
index
]
=
updatedProduct
;
notifyListeners
();
}
void
updateProductCalculations
()
{
final
inclusivePrice
=
double
.
tryParse
(
PriceController
.
text
)
??
0.0
;
final
quantity
=
double
.
tryParse
(
QuantityController
.
text
)
??
1.0
;
final
cgst
=
double
.
tryParse
(
CGSTController
.
text
)
??
0.0
;
final
sgst
=
double
.
tryParse
(
SGSTController
.
text
)
??
0.0
;
final
igst
=
double
.
tryParse
(
IGSTController
.
text
)
??
0.0
;
final
totalTaxRate
=
(
cgst
+
sgst
+
igst
)
/
100
;
// Calculate taxable value per unit
final
taxableValuePerUnit
=
inclusivePrice
/
(
1
+
totalTaxRate
);
// Total taxable value = taxable value per unit * quantity
final
totalTaxableValue
=
taxableValuePerUnit
*
quantity
;
TaxableValueController
.
text
=
totalTaxableValue
.
toStringAsFixed
(
0
,
);
notifyListeners
();
}
void
updateSelectedSingleProduct
(
SaleProducts
?
product
)
{
_selectedSaleProducts
=
product
;
_selectedSingleSaleProductID
=
product
!.
id
;
PriceController
.
text
=
product
!.
price
!;
updateProductCalculations
();
notifyListeners
();
}
void
prefillProductForEdit
(
int
index
)
{
final
product
=
productRows
[
index
];
selectedSaleProducts
=
saleProducts
.
firstWhere
(
(
p
)
=>
p
.
id
==
product
[
'product_id'
],
orElse:
()
=>
SaleProducts
(
id:
''
,
prodName:
'Unknown'
),
);
selectedSingleSaleProductID
=
product
[
'product_id'
];
selectedSaleProductName
=
selectedSaleProducts
?.
prodName
;
QuantityController
.
text
=
product
[
'qty'
]
??
''
;
PriceController
.
text
=
product
[
'price'
]
??
''
;
CGSTController
.
text
=
product
[
'cgst_p'
]
??
''
;
SGSTController
.
text
=
product
[
'sgst_p'
]
??
''
;
IGSTController
.
text
=
product
[
'igst_p'
]
??
''
;
TaxableValueController
.
text
=
product
[
'total_price'
]
??
''
;
notifyListeners
();
}
String
getJsonEncodedProducts
()
{
return
jsonEncode
(
productRows
);
}
void
addNewRow
()
{
void
addNewRow
()
{
ProductControllers
.
add
(
TextEditingController
());
ProductControllers
.
add
(
TextEditingController
());
PriceControllers
.
add
(
TextEditingController
());
PriceControllers
.
add
(
TextEditingController
());
...
@@ -646,8 +744,7 @@ class Addorderprovider extends ChangeNotifier {
...
@@ -646,8 +744,7 @@ class Addorderprovider extends ChangeNotifier {
notifyListeners
();
notifyListeners
();
}
}
}
}
///[{"product_id":"1","qty":"1","price":"500","cgst_p":"9","sgst_p":"9","igst_p":"0","total_price":"500"},
///{"product_id":"2","qty":"1","price":"1000","cgst_p":"9","sgst_p":"9","igst_p":"0","total_price":"1000"}]
Map
<
String
,
dynamic
>
getFormData
()
{
Map
<
String
,
dynamic
>
getFormData
()
{
final
List
<
Map
<
String
,
dynamic
>>
orders
=
[];
final
List
<
Map
<
String
,
dynamic
>>
orders
=
[];
for
(
int
i
=
0
;
i
<
ProductControllers
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
ProductControllers
.
length
;
i
++)
{
...
@@ -672,150 +769,6 @@ class Addorderprovider extends ChangeNotifier {
...
@@ -672,150 +769,6 @@ class Addorderprovider extends ChangeNotifier {
};
};
}
}
//
//
// void updateSelectedOrderId(int index, SaleProducts? value) {
// if (index >= 0 && index < _selectedSaleProductID.length) {
// _selectedSaleProductID[index] = value!.id;
// ProductControllers[index].text = value!.prodName!;
// PriceControllers[index].text = value.price!;
// notifyListeners();
// } else {
// print("Invalid index: $index");
// }
// }
// void addNewRow() {
// // Create a unique TextEditingController for each field
// ProductControllers.add(TextEditingController());
// PriceControllers.add(TextEditingController());
// QuantityControllers.add(TextEditingController());
// CGSTControllers.add(TextEditingController(text: "9"));
// SGSTControllers.add(TextEditingController(text: "9"));
// IGSTControllers.add(TextEditingController());
// TotalPriceControllers.add(TextEditingController());
// _selectedSaleProductID.add(null); // Safe to add null since List<String?> allows nullable strings
// notifyListeners();
// }
//
// void removeRow(int index) {
// if (index >= 0 && index < ProductControllers.length) {
// ProductControllers[index].dispose();
// ProductControllers.removeAt(index);
// PriceControllers[index].dispose();
// PriceControllers.removeAt(index);
// QuantityControllers[index].dispose();
// QuantityControllers.removeAt(index);
// CGSTControllers[index].dispose();
// CGSTControllers.removeAt(index);
// SGSTControllers[index].dispose();
// SGSTControllers.removeAt(index);
// IGSTControllers[index].dispose();
// IGSTControllers.removeAt(index);
// TotalPriceControllers[index].dispose();
// TotalPriceControllers.removeAt(index);
// _selectedSaleProductID.removeAt(index);
// notifyListeners();
// } else {
// print("Invalid index: $index");
// }
// }
// double get basicAmount {
// double total = 0;
// for (int i = 0; i < TotalPriceControllers.length; i++) {
// total += double.tryParse(TotalPriceControllers[i].text) ?? 0.0;
// }
// return total;
// }
//
// double get cgstAmount {
// double total = 0;
// for (int i = 0; i < ProductControllers.length; i++) {
// final price = double.tryParse(PriceControllers[i].text) ?? 0.0;
// final quantity = double.tryParse(QuantityControllers[i].text) ?? 0.0;
// final cgst = double.tryParse(CGSTControllers[i].text) ?? 0.0;
// total += (price * quantity * cgst) / 100;
// }
// return total;
// }
//
// double get sgstAmount {
// double total = 0;
// for (int i = 0; i < ProductControllers.length; i++) {
// final price = double.tryParse(PriceControllers[i].text) ?? 0.0;
// final quantity = double.tryParse(QuantityControllers[i].text) ?? 0.0;
// final sgst = double.tryParse(SGSTControllers[i].text) ?? 0.0;
// total += (price * quantity * sgst) / 100;
// }
// return total;
// }
//
// double get igstAmount {
// double total = 0;
// for (int i = 0; i < ProductControllers.length; i++) {
// final price = double.tryParse(PriceControllers[i].text) ?? 0.0;
// final quantity = double.tryParse(QuantityControllers[i].text) ?? 0.0;
// final igst = double.tryParse(IGSTControllers[i].text) ?? 0.0;
// total += (price * quantity * igst) / 100;
// }
// return total;
// }
//
// double get totalAmount => basicAmount + cgstAmount + sgstAmount + igstAmount;
//
//
// // List<Map<String, String>> getFormData() {
// // _selectedOrders = [];
// //
// // // Iterate over rows
// // for (int i = 0; i < ProductControllers.length; i++) {
// // // Only include rows with a valid product ID
// // if (_selectedSaleProductID[i] != null &&
// // ProductControllers[i].text.isNotEmpty) {
// // // Create a map for the current row's data
// // final rowData = {
// // "product_id": _selectedSaleProductID[i]!,
// // "product_name": ProductControllers[i].text,
// // "price": PriceControllers[i].text.isNotEmpty ? PriceControllers[i].text : "0",
// // "qty": QuantityControllers[i].text.isNotEmpty ? QuantityControllers[i].text : "0",
// // "cgst_p": CGSTControllers[i].text.isNotEmpty ? CGSTControllers[i].text : "0",
// // "sgst_p": SGSTControllers[i].text.isNotEmpty ? SGSTControllers[i].text : "0",
// // "igst_p": IGSTControllers[i].text.isNotEmpty ? IGSTControllers[i].text : "0",
// // "total_price": TotalPriceControllers[i].text.isNotEmpty ? TotalPriceControllers[i].text : "0",
// // };
// // _selectedOrders.add(rowData);
// // }
// // }
// //
// // print("Form Data: $_selectedOrders");
// // notifyListeners();
// // return _selectedOrders;
// // }
//
// Map<String, dynamic> getFormData() {
// final List<Map<String, dynamic>> orders = [];
// for (int i = 0; i < ProductControllers.length; i++) {
// orders.add({
// 'product_id': selectedSaleProductID[i],
// 'product_name': ProductControllers[i].text,
// 'price': PriceControllers[i].text,
// 'quantity': QuantityControllers[i].text,
// 'cgst': CGSTControllers[i].text,
// 'sgst': SGSTControllers[i].text,
// 'igst': IGSTControllers[i].text,
// 'total_price': TotalPriceControllers[i].text,
// });
// }
// return {
// 'orders': orders,
// 'basic_amount': basicAmount.toStringAsFixed(2),
// 'cgst_amount': cgstAmount.toStringAsFixed(2),
// 'sgst_amount': sgstAmount.toStringAsFixed(2),
// 'igst_amount': igstAmount.toStringAsFixed(2),
// 'total_amount': totalAmount.toStringAsFixed(2),
// 'note': noteController.text,
// };
// }
Future
<
void
>
ordersAddOrderAPIViewFunction
(
context
,
mode
)
async
{
Future
<
void
>
ordersAddOrderAPIViewFunction
(
context
,
mode
)
async
{
try
{
try
{
final
provider
=
Provider
.
of
<
HomescreenNotifier
>(
context
,
listen:
false
);
final
provider
=
Provider
.
of
<
HomescreenNotifier
>(
context
,
listen:
false
);
...
@@ -925,14 +878,27 @@ class Addorderprovider extends ChangeNotifier {
...
@@ -925,14 +878,27 @@ class Addorderprovider extends ChangeNotifier {
_accountDetails
=
data
.
accountDetails
!;
_accountDetails
=
data
.
accountDetails
!;
data
.
accountDetails
!.
accManagerId
!;
data
.
accountDetails
!.
accManagerId
!;
billingNameController
.
text
=
data
.
accountDetails
!.
name
!;
billingNameController
.
text
=
data
.
accountDetails
!.
name
!;
_selectedBillingSubLocID
=
data
.
accountDetails
!.
subLocality
!;
_selectedBillingDistrictID
=
data
.
accountDetails
!.
district
!;
_selectedBillingStateID
=
data
.
accountDetails
!.
state
!;
_selectedBillingStateID
=
data
.
accountDetails
!.
state
!;
if
(
_selectedBillingStateID
!=
null
){
getDistrictAPI
(
context
,
_selectedBillingStateID
);
}
_selectedBillingDistrictID
=
data
.
accountDetails
!.
district
!;
if
(
_selectedBillingDistrictID
!=
null
){
getSubLocationAPI
(
context
,
_selectedBillingDistrictID
);
}
_selectedBillingSubLocID
=
data
.
accountDetails
!.
subLocality
!;
billingPincodeController
.
text
=
data
.
accountDetails
!.
pincode
!;
billingPincodeController
.
text
=
data
.
accountDetails
!.
pincode
!;
billingAddressController
.
text
=
data
.
accountDetails
!.
address
!;
billingAddressController
.
text
=
data
.
accountDetails
!.
address
!;
orderReceivedDateController
.
text
=
data
.
accountDetails
!.
date
!;
orderReceivedDateController
.
text
=
data
.
accountDetails
!.
date
!;
gstController
.
text
=
data
.
accountDetails
!.
gstNumber
!;
gstController
.
text
=
data
.
accountDetails
!.
gstNumber
!;
orderDateError
=
null
;
billingNameError
=
null
;
billingPincodeError
=
null
;
billingAddressError
=
null
;
selectedBillingStateError
=
null
;
selectedBillingDistrictError
=
null
;
selectedBillingSubLocError
=
null
;
notifyListeners
();
notifyListeners
();
}
else
{}
}
else
{}
}
else
{}
}
else
{}
...
@@ -1268,6 +1234,9 @@ class Addorderprovider extends ChangeNotifier {
...
@@ -1268,6 +1234,9 @@ class Addorderprovider extends ChangeNotifier {
_image
=
File
(
galleryImage
!.
path
);
_image
=
File
(
galleryImage
!.
path
);
_imageName
=
File
(
galleryImage
!.
name
);
_imageName
=
File
(
galleryImage
!.
name
);
_imagePicked
=
1
;
_imagePicked
=
1
;
if
(
_imagePicked
==
0
){
FileError
=
"Please Select Attachment"
;
}
FileError
=
null
;
FileError
=
null
;
notifyListeners
();
notifyListeners
();
}
catch
(
e
)
{
}
catch
(
e
)
{
...
@@ -1290,6 +1259,9 @@ class Addorderprovider extends ChangeNotifier {
...
@@ -1290,6 +1259,9 @@ class Addorderprovider extends ChangeNotifier {
_image
=
File
(
galleryImage
!.
path
);
_image
=
File
(
galleryImage
!.
path
);
_imageName
=
File
(
galleryImage
!.
name
);
_imageName
=
File
(
galleryImage
!.
name
);
_imagePicked
=
1
;
_imagePicked
=
1
;
if
(
_imagePicked
==
0
){
FileError
=
"Please Select Attachment"
;
}
FileError
=
null
;
FileError
=
null
;
notifyListeners
();
notifyListeners
();
// var file = FlutterImageCompress.compressWithFile(galleryImage!.path);
// var file = FlutterImageCompress.compressWithFile(galleryImage!.path);
...
@@ -1299,58 +1271,67 @@ class Addorderprovider extends ChangeNotifier {
...
@@ -1299,58 +1271,67 @@ class Addorderprovider extends ChangeNotifier {
}
}
void
onChangedBillingName
(
value
)
{
void
onChangedBillingName
(
value
)
{
billingNameError
=
""
;
billingNameError
=
null
;
notifyListeners
();
}
void
onChangeOrderDate
(
value
)
{
orderDateError
=
null
;
notifyListeners
();
notifyListeners
();
}
}
void
onChangedBillingAddress
(
value
)
{
void
onChangedBillingAddress
(
value
)
{
billingAddressError
=
""
;
billingAddressError
=
null
;
notifyListeners
();
notifyListeners
();
}
}
void
onChangedBillingPincode
(
value
)
{
void
onChangedBillingPincode
(
value
)
{
billingPincodeError
=
""
;
billingPincodeError
=
null
;
notifyListeners
();
notifyListeners
();
}
}
void
onChangedDispatchAddress
(
value
)
{
void
onChangedDispatchAddress
(
value
)
{
dispatchAddressError
=
""
;
dispatchAddressError
=
null
;
notifyListeners
();
notifyListeners
();
}
}
void
onChangedDispatchPincode
(
value
)
{
void
onChangedDispatchPincode
(
value
)
{
dispatchPincodeError
=
""
;
dispatchPincodeError
=
null
;
notifyListeners
();
notifyListeners
();
}
}
void
onChangedGst
(
value
)
{
void
onChangedGst
(
value
)
{
gstError
=
""
;
gstError
=
null
;
notifyListeners
();
notifyListeners
();
}
}
void
onChangeTpcAmount
(
value
)
{
void
onChangeTpcAmount
(
value
)
{
tpcAmountError
=
""
;
tpcAmountError
=
null
;
notifyListeners
();
notifyListeners
();
}
}
bool
validateAddOrder
()
{
bool
validateAddOrder
()
{
bool
isValid
=
true
;
bool
isValid
=
true
;
selectAccountError
=
""
;
selectAccountError
=
null
;
billingNameError
=
""
;
billingNameError
=
null
;
orderDateError
=
""
;
orderDateError
=
null
;
billingAddressError
=
""
;
billingAddressError
=
null
;
billingPincodeError
=
""
;
billingPincodeError
=
null
;
dispatchAddressError
=
""
;
dispatchAddressError
=
null
;
dispatchPincodeError
=
""
;
dispatchPincodeError
=
null
;
gstError
=
""
;
gstError
=
null
;
tpcAmountError
=
""
;
tpcAmountError
=
null
;
selectedBillingStateError
=
""
;
selectedBillingStateError
=
null
;
selectedBillingDistrictError
=
""
;
selectedBillingDistrictError
=
null
;
selectedBillingSubLocError
=
""
;
selectedBillingSubLocError
=
null
;
selectedDispatchStateError
=
""
;
selectedDispatchStateError
=
null
;
selectedDispatchDistrictError
=
""
;
selectedDispatchDistrictError
=
null
;
selectedDispatchSubLocError
=
""
;
selectedDispatchSubLocError
=
null
;
selectedUnloadingScopeError
=
null
;
selectedFreightScopeError
=
null
;
selectedErectionScopeError
=
null
;
selectedTPCApplicableError
=
null
;
selectedTPCAgentError
=
null
;
if
(
_selectedAccountList
==
null
||
_selectedAccountID
==
null
)
{
if
(
_selectedAccountList
==
null
||
_selectedAccountID
==
null
)
{
selectAccountError
=
"Please select an Account"
;
selectAccountError
=
"Please select an Account"
;
...
@@ -1394,53 +1375,230 @@ class Addorderprovider extends ChangeNotifier {
...
@@ -1394,53 +1375,230 @@ class Addorderprovider extends ChangeNotifier {
if
(
orderReceivedDateController
.
text
.
trim
().
isEmpty
)
{
if
(
orderReceivedDateController
.
text
.
trim
().
isEmpty
)
{
orderDateError
=
"Please Enter Date"
;
orderDateError
=
"Please Enter
Received
Date"
;
isValid
=
false
;
isValid
=
false
;
notifyListeners
();
}
}
if
(
billingNameController
.
text
.
trim
().
isEmpty
)
{
if
(
billingNameController
.
text
.
trim
().
isEmpty
)
{
isValid
=
false
;
isValid
=
false
;
billingNameError
=
"Please Enter Your Name"
;
billingNameError
=
"Please Enter Your Name"
;
notifyListeners
();
}
}
if
(
billingAddressController
.
text
.
trim
().
isEmpty
)
{
if
(
billingAddressController
.
text
.
trim
().
isEmpty
)
{
isValid
=
false
;
isValid
=
false
;
billingAddressError
=
"Please Enter Address"
;
billingAddressError
=
"Please Enter Address"
;
notifyListeners
();
}
}
if
(
billingPincodeController
.
text
.
trim
().
isEmpty
)
{
if
(
billingPincodeController
.
text
.
trim
().
isEmpty
)
{
isValid
=
false
;
isValid
=
false
;
billingPincodeError
=
"Please Enter Pin Code"
;
billingPincodeError
=
"Please Enter Pin Code"
;
notifyListeners
();
}
}
if
(
dispatchAddressController
.
text
.
trim
().
isEmpty
)
{
if
(
dispatchAddressController
.
text
.
trim
().
isEmpty
)
{
dispatchAddressError
=
"Please Enter Dispatch Address"
;
dispatchAddressError
=
"Please Enter Dispatch Address"
;
isValid
=
false
;
isValid
=
false
;
notifyListeners
();
}
}
if
(
dispatchPincodeController
.
text
.
trim
().
isEmpty
)
{
if
(
dispatchPincodeController
.
text
.
trim
().
isEmpty
)
{
dispatchPincodeError
=
"Please Enter Dispatch Pin Code"
;
dispatchPincodeError
=
"Please Enter Dispatch Pin Code"
;
isValid
=
false
;
isValid
=
false
;
notifyListeners
();
}
}
if
(
gstController
.
text
.
trim
().
isEmpty
)
{
if
(
gstController
.
text
.
trim
().
isEmpty
)
{
gstError
=
"Please Enter GST Number"
;
gstError
=
"Please Enter GST Number"
;
isValid
=
false
;
isValid
=
false
;
notifyListeners
();
}
if
(
_selectedUnloadingScope
==
null
)
{
selectedUnloadingScopeError
=
"Please select a Scope"
;
isValid
=
false
;
}
if
(
_selectedFreightScope
==
null
)
{
selectedFreightScopeError
=
"Please select a Scope"
;
isValid
=
false
;
}
if
(
_selectedErectionScope
==
null
)
{
selectedErectionScopeError
=
"Please select a Scope"
;
isValid
=
false
;
}
if
(
_selectedTpcStatus
==
null
)
{
selectedTPCApplicableError
=
"Please select TPC status"
;
isValid
=
false
;
}
}
if
(
_selectedTpcStatus
==
"Yes"
)
{
if
(
_selectedTpcStatus
==
"Yes"
)
{
if
(
_selectedTpcAgent
==
null
||
_selectedTpcAgentID
==
null
)
{
selectedTPCAgentError
=
"Please select an Agent"
;
isValid
=
false
;
}
if
(
tpcAmountController
.
text
.
trim
().
isEmpty
)
{
if
(
tpcAmountController
.
text
.
trim
().
isEmpty
)
{
isValid
=
false
;
isValid
=
false
;
tpcAmountError
=
"Please Enter Amount"
;
tpcAmountError
=
"Please Enter Amount"
;
notifyListeners
();
}
}
}
}
_submitClicked
=
false
;
notifyListeners
();
return
isValid
;
}
bool
validateForm1
()
{
bool
isValid
=
true
;
selectAccountError
=
null
;
billingNameError
=
null
;
orderDateError
=
null
;
billingAddressError
=
null
;
billingPincodeError
=
null
;
selectedBillingStateError
=
null
;
selectedBillingDistrictError
=
null
;
selectedBillingSubLocError
=
null
;
if
(
_selectedAccountList
==
null
||
_selectedAccountID
==
null
)
{
selectAccountError
=
"Please select an Account"
;
isValid
=
false
;
}
if
(
_selectedBillingStates
==
null
||
_selectedBillingStateID
==
null
)
{
selectedBillingStateError
=
"Please select a State"
;
isValid
=
false
;
}
if
(
_selectedBillingDistricts
==
null
||
_selectedBillingDistrictID
==
null
)
{
selectedBillingDistrictError
=
"Please select a District"
;
isValid
=
false
;
}
if
(
_selectedBillingSubLocations
==
null
||
_selectedBillingSubLocID
==
null
)
{
selectedBillingSubLocError
=
"Please select a Location"
;
isValid
=
false
;
}
if
(
orderReceivedDateController
.
text
.
trim
().
isEmpty
)
{
isValid
=
false
;
orderDateError
=
"Please Enter Received Date"
;
}
if
(
billingNameController
.
text
.
trim
().
isEmpty
)
{
isValid
=
false
;
billingNameError
=
"Please Enter Your Name"
;
}
if
(
billingAddressController
.
text
.
trim
().
isEmpty
)
{
isValid
=
false
;
billingAddressError
=
"Please Enter Address"
;
}
if
(
billingPincodeController
.
text
.
trim
().
isEmpty
)
{
isValid
=
false
;
billingPincodeError
=
"Please Enter Pin Code"
;
}
if
(
billingPincodeController
.
text
.
length
<
6
){
isValid
=
false
;
billingPincodeError
=
"Please Enter a valid Pin Code"
;
}
_submitClicked
=
false
;
notifyListeners
();
return
isValid
;
}
bool
validateForm2
()
{
bool
isValid
=
true
;
dispatchAddressError
=
null
;
dispatchPincodeError
=
null
;
gstError
=
null
;
selectedDispatchStateError
=
null
;
selectedDispatchDistrictError
=
null
;
selectedDispatchSubLocError
=
null
;
FileError
=
null
;
if
(
_selectedDispatchStates
==
null
||
_selectedDispatchStateID
==
null
)
{
selectedDispatchStateError
=
"Please select a State"
;
isValid
=
false
;
}
if
(
_selectedDispatchDistricts
==
null
||
_selectedDispatchDistrictID
==
null
)
{
selectedDispatchDistrictError
=
"Please select a District"
;
isValid
=
false
;
}
if
(
_selectedDispatchSubLocations
==
null
||
_selectedDispatchSubLocID
==
null
)
{
selectedDispatchSubLocError
=
"Please select a Location"
;
isValid
=
false
;
}
if
(
dispatchAddressController
.
text
.
trim
().
isEmpty
)
{
dispatchAddressError
=
"Please Enter Dispatch Address"
;
isValid
=
false
;
}
if
(
dispatchPincodeController
.
text
.
trim
().
isEmpty
)
{
dispatchPincodeError
=
"Please Enter Dispatch Pin Code"
;
isValid
=
false
;
}
if
(
dispatchPincodeController
.
text
.
length
<
6
){
isValid
=
false
;
dispatchPincodeError
=
"Please Enter a valid Pin Code"
;
}
if
(
gstController
.
text
.
trim
().
isEmpty
)
{
gstError
=
"Please Enter GST Number"
;
isValid
=
false
;
}
if
(
_imagePicked
==
0
){
FileError
=
"Please provide an Attachment"
;
isValid
=
false
;
}
_submitClicked
=
false
;
notifyListeners
();
return
isValid
;
}
bool
validateForm3
()
{
bool
isValid
=
true
;
tpcAmountError
=
null
;
selectedUnloadingScopeError
=
null
;
selectedFreightScopeError
=
null
;
selectedErectionScopeError
=
null
;
selectedTPCApplicableError
=
null
;
selectedTPCAgentError
=
null
;
if
(
_selectedUnloadingScope
==
null
)
{
selectedUnloadingScopeError
=
"Please select a Scope"
;
isValid
=
false
;
}
if
(
_selectedFreightScope
==
null
)
{
selectedFreightScopeError
=
"Please select a Scope"
;
isValid
=
false
;
}
if
(
_selectedErectionScope
==
null
)
{
selectedErectionScopeError
=
"Please select a Scope"
;
isValid
=
false
;
}
if
(
_selectedTpcStatus
==
null
)
{
selectedTPCApplicableError
=
"Please select TPC status"
;
isValid
=
false
;
}
if
(
_selectedTpcStatus
==
"Yes"
)
{
if
(
_selectedTpcAgent
==
null
||
_selectedTpcAgentID
==
null
)
{
selectedTPCAgentError
=
"Please select an Agent"
;
isValid
=
false
;
}
if
(
tpcAmountController
.
text
.
trim
().
isEmpty
)
{
tpcAmountError
=
"Please Enter Amount"
;
isValid
=
false
;
}
}
_submitClicked
=
false
;
notifyListeners
();
return
isValid
;
}
bool
validateForm4
()
{
bool
isValid
=
true
;
if
(
productRows
.
isEmpty
||
_productRows
.
isEmpty
){
productsEmptyError
=
"Please Add min. one Product"
;
isValid
=
false
;
}
_submitClicked
=
false
;
notifyListeners
();
notifyListeners
();
return
isValid
;
return
isValid
;
}
}
void
resetForm
()
{
void
resetForm
()
{
_submitClicked
=
false
;
_submitClicked
=
false
;
_productRows
.
clear
();
dropDownSearchController
.
clear
();
dropDownSearchController
.
clear
();
dropDownTpcSearchController
.
clear
();
dropDownTpcSearchController
.
clear
();
billingNameController
.
clear
();
billingNameController
.
clear
();
...
@@ -1448,20 +1606,31 @@ class Addorderprovider extends ChangeNotifier {
...
@@ -1448,20 +1606,31 @@ class Addorderprovider extends ChangeNotifier {
billingPincodeController
.
clear
();
billingPincodeController
.
clear
();
dispatchAddressController
.
clear
();
dispatchAddressController
.
clear
();
dispatchPincodeController
.
clear
();
dispatchPincodeController
.
clear
();
ProductController
.
clear
();
PriceController
.
clear
();
QuantityController
.
clear
();
CGSTController
.
clear
();
SGSTController
.
clear
();
IGSTController
.
clear
();
QuantityController
.
text
=
"1"
;
CGSTController
.
text
=
"9"
;
SGSTController
.
text
=
"9"
;
IGSTController
.
text
=
"0"
;
TotalPriceController
.
clear
();
TaxableValueController
.
clear
();
billingStateSearchController
.
clear
();
billingStateSearchController
.
clear
();
billingDistrictSearchController
.
clear
();
billingDistrictSearchController
.
clear
();
billingSubLocSearchController
.
clear
();
billingSubLocSearchController
.
clear
();
dispatchStateSearchController
.
clear
();
dispatchStateSearchController
.
clear
();
dispatchDistrictSearchController
.
clear
();
dispatchDistrictSearchController
.
clear
();
dispatchSubLocSearchController
.
clear
();
dispatchSubLocSearchController
.
clear
();
_productRows
=
[];
gstController
.
clear
();
gstController
.
clear
();
orderReceivedDateController
.
clear
();
orderReceivedDateController
.
clear
();
tpcAmountController
.
clear
();
tpcAmountController
.
clear
();
orderReceivedDateController
.
clear
();
orderReceivedDateController
.
clear
();
noteController
.
clear
();
noteController
.
clear
();
selectedSingleSaleProductID
=
null
;
ProductControllers
.
forEach
((
action
)
=>
action
.
dispose
());
ProductControllers
.
forEach
((
action
)
=>
action
.
dispose
());
ProductControllers
.
clear
();
ProductControllers
.
clear
();
PriceControllers
.
forEach
((
action
)
=>
action
.
dispose
());
PriceControllers
.
forEach
((
action
)
=>
action
.
dispose
());
...
@@ -1488,18 +1657,19 @@ class Addorderprovider extends ChangeNotifier {
...
@@ -1488,18 +1657,19 @@ class Addorderprovider extends ChangeNotifier {
_imageName
=
null
;
_imageName
=
null
;
_imagePicked
=
0
;
_imagePicked
=
0
;
selectAccountError
=
""
;
selectAccountError
=
null
;
billingNameError
=
""
;
orderDateError
=
null
;
billingAddressError
=
""
;
billingNameError
=
null
;
billingPincodeError
=
""
;
billingAddressError
=
null
;
dispatchAddressError
=
""
;
billingPincodeError
=
null
;
dispatchPincodeError
=
""
;
dispatchAddressError
=
null
;
selectedBillingStateError
=
""
;
dispatchPincodeError
=
null
;
selectedBillingDistrictError
=
""
;
selectedBillingStateError
=
null
;
selectedBillingSubLocError
=
""
;
selectedBillingDistrictError
=
null
;
selectedDispatchStateError
=
""
;
selectedBillingSubLocError
=
null
;
selectedDispatchDistrictError
=
""
;
selectedDispatchStateError
=
null
;
selectedDispatchSubLocError
=
""
;
selectedDispatchDistrictError
=
null
;
selectedDispatchSubLocError
=
null
;
_selectedAccountList
=
null
;
_selectedAccountList
=
null
;
_selectedEmployees
=
null
;
_selectedEmployees
=
null
;
_selectedBillingStates
=
null
;
_selectedBillingStates
=
null
;
...
@@ -1537,9 +1707,9 @@ class Addorderprovider extends ChangeNotifier {
...
@@ -1537,9 +1707,9 @@ class Addorderprovider extends ChangeNotifier {
_selectedTpcAgentID
=
""
;
_selectedTpcAgentID
=
""
;
_selectedTpcAgentValue
=
""
;
_selectedTpcAgentValue
=
""
;
gstError
=
""
;
gstError
=
null
;
FileError
=
null
;
FileError
=
null
;
d
ateError
=
null
;
orderD
ateError
=
null
;
checkDropdownselected
();
checkDropdownselected
();
notifyListeners
();
notifyListeners
();
}
}
...
@@ -1587,6 +1757,7 @@ class Addorderprovider extends ChangeNotifier {
...
@@ -1587,6 +1757,7 @@ class Addorderprovider extends ChangeNotifier {
),
),
onPressed:
()
{
onPressed:
()
{
setDate
(
_date
??
DateTime
.
now
()
);
setDate
(
_date
??
DateTime
.
now
()
);
Navigator
.
pop
(
context
);
Navigator
.
pop
(
context
);
},
},
),
),
...
...
lib/screens/order/addOrder.dart
View file @
c1b1af92
This source diff could not be displayed because it is too large. You can
view the blob
instead.
lib/screens/order/addOrderAddProduct.dart
0 → 100644
View file @
c1b1af92
import
'dart:io'
;
import
'package:connectivity_plus/connectivity_plus.dart'
;
import
'package:dropdown_button2/dropdown_button2.dart'
;
import
'package:flutter/material.dart'
;
import
'package:generp/Models/ordersModels/AddOrderViewResponse.dart'
;
import
'package:provider/provider.dart'
;
import
'../../Notifiers/ordersProvider/addOrderProvider.dart'
;
import
'../../Utils/app_colors.dart'
;
import
'../../Utils/commonServices.dart'
;
import
'../../Utils/commonWidgets.dart'
;
import
'../../Utils/dropdownTheme.dart'
;
class
Addorderaddproduct
extends
StatefulWidget
{
final
type
;
final
editIndex
;
const
Addorderaddproduct
({
super
.
key
,
this
.
type
,
this
.
editIndex
});
@override
State
<
Addorderaddproduct
>
createState
()
=>
_AddorderaddproductState
();
}
class
_AddorderaddproductState
extends
State
<
Addorderaddproduct
>
{
Map
_source
=
{
ConnectivityResult
.
mobile
:
true
};
final
MyConnectivity
_connectivity
=
MyConnectivity
.
instance
;
Dropdowntheme
ddtheme
=
Dropdowntheme
();
@override
void
initState
()
{
// TODO: implement initState
super
.
initState
();
_connectivity
.
initialise
();
_connectivity
.
myStream
.
listen
((
source
)
{
setState
(()
=>
_source
=
source
);
});
WidgetsBinding
.
instance
.
addPostFrameCallback
((
timeStamp
)
{
final
provider
=
Provider
.
of
<
Addorderprovider
>(
context
,
listen:
false
,
);
if
(
widget
.
type
==
"Add"
){
provider
.
selectedSaleProducts
=
null
;
provider
.
selectedSingleSaleProductID
=
null
;
provider
.
selectedSaleProductName
=
null
;
provider
.
ProductController
.
clear
();
provider
.
PriceController
.
clear
();
provider
.
QuantityController
.
clear
();
provider
.
CGSTController
.
clear
();
provider
.
SGSTController
.
clear
();
provider
.
IGSTController
.
clear
();
provider
.
TotalPriceController
.
clear
();
provider
.
TaxableValueController
.
clear
();
provider
.
QuantityController
.
text
=
"1"
;
provider
.
CGSTController
.
text
=
"9"
;
provider
.
SGSTController
.
text
=
"9"
;
provider
.
IGSTController
.
text
=
"0"
;
}
else
{
provider
.
prefillProductForEdit
(
widget
.
editIndex
!);
}
// provider.addEditInitializeForm(context);
});
}
@override
void
dispose
()
{
// TODO: implement dispose
super
.
dispose
();
_connectivity
.
disposeStream
();
}
@override
Widget
build
(
BuildContext
context
)
{
switch
(
_source
.
keys
.
toList
()[
0
])
{
case
ConnectivityResult
.
mobile
:
connection
=
'Online'
;
break
;
case
ConnectivityResult
.
wifi
:
connection
=
'Online'
;
break
;
case
ConnectivityResult
.
none
:
default
:
connection
=
'Offline'
;
}
return
(
connection
==
"Online"
)
?
Platform
.
isAndroid
?
WillPopScope
(
onWillPop:
()
=>
onBackPressed
(
context
),
child:
SafeArea
(
top:
false
,
bottom:
true
,
child:
_scaffold
(
context
),
),
)
:
_scaffold
(
context
)
:
NoNetwork
(
context
);
}
Widget
_scaffold
(
BuildContext
context
)
{
return
Consumer
<
Addorderprovider
>(
builder:
(
context
,
provider
,
child
)
{
return
Scaffold
(
resizeToAvoidBottomInset:
true
,
appBar:
appbarNew
(
context
,
"Generate Quotation"
,
0xFFFFFFFF
),
backgroundColor:
AppColors
.
scaffold_bg_color
,
body:
SingleChildScrollView
(
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
// Product Rows (Horizontal ListView)
Container
(
width:
MediaQuery
.
of
(
context
).
size
.
width
,
padding:
const
EdgeInsets
.
all
(
5.0
),
decoration:
BoxDecoration
(
color:
const
Color
(
0xFFF5F5F5
),
borderRadius:
BorderRadius
.
circular
(
12
),
),
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
const
SizedBox
(
height:
8.0
),
Container
(
padding:
const
EdgeInsets
.
all
(
3.0
),
decoration:
BoxDecoration
(
color:
Colors
.
white
,
borderRadius:
BorderRadius
.
circular
(
12
),
),
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
// Product Dropdown
Row
(
children:
[
Expanded
(
child:
DropdownButtonHideUnderline
(
child:
DropdownButton2
<
SaleProducts
>(
isExpanded:
true
,
hint:
Text
(
'Select Product'
,
style:
TextStyle
(
fontSize:
14
),
overflow:
TextOverflow
.
ellipsis
,
),
items:
provider
.
saleProducts
.
map
(
(
ord
)
=>
DropdownMenuItem
<
SaleProducts
>(
value:
ord
,
child:
Text
(
"
${ord.prodName}
"
??
''
,
style:
const
TextStyle
(
fontSize:
14
,
),
overflow:
TextOverflow
.
ellipsis
,
),
),
)
.
toList
(),
value:
provider
.
selectedSingleSaleProductID
!=
null
?
provider
.
saleProducts
.
firstWhere
(
(
product
)
=>
product
.
id
==
provider
.
selectedSingleSaleProductID
,
)
:
null
,
onChanged:
(
SaleProducts
?
value
)
{
if
(
value
!=
null
)
{
if
(
provider
.
saleProducts
.
isNotEmpty
)
{
provider
.
selectedSaleProducts
=
value
;
provider
.
PriceController
.
text
=
value
.
price
!;
provider
.
notifyListeners
();
provider
.
updateProductCalculations
();
// provider.updateSelectedSingleProduct(
//
// provider.selectedSaleProducts,
// );
// provider.selectedOrderIds = value!.orderId!;
// provider.selectedOrderNumbers = value!.orderNumber!;
}
}
},
buttonStyleData:
ddtheme
.
buttonStyleData
,
iconStyleData:
ddtheme
.
iconStyleData
,
menuItemStyleData:
ddtheme
.
menuItemStyleData
,
dropdownStyleData:
ddtheme
.
dropdownStyleData
,
),
),
),
],
),
const
SizedBox
(
height:
8.0
),
Row
(
children:
[
// Price TextField (Read-only)
Expanded
(
child:
textControllerWidget
(
context
,
provider
.
PriceController
,
"Price"
,
"Enter Price"
,
(
p0
)
{},
TextInputType
.
number
,
false
,
null
,
null
,
null
,
TextInputAction
.
next
,
),
),
const
SizedBox
(
width:
8.0
),
Expanded
(
child:
textControllerWidget
(
context
,
provider
.
QuantityController
,
"Quantity"
,
"Enter Quantity"
,
(
p0
)
{
provider
.
updateProductCalculations
();
},
TextInputType
.
number
,
false
,
null
,
null
,
null
,
TextInputAction
.
next
,
),
),
],
),
const
SizedBox
(
height:
8.0
),
Row
(
children:
[
// CGST TextField
// Expanded(
// child: TextField(
// controller: provider.CGSTControllers[index],
// decoration: const InputDecoration(
// labelText: 'CGST %',
// border: OutlineInputBorder(),
// isDense: true,
// ),
// keyboardType: TextInputType.number,
// inputFormatters: [
// FilteringTextInputFormatter.digitsOnly
// ],
// onChanged: (value) {
// provider.updateRowCalculations(index);
// },
// ),
// ),
Expanded
(
child:
textControllerWidget
(
context
,
provider
.
CGSTController
,
"CGST %"
,
"Enter CGST %"
,
(
p0
)
{
provider
.
updateProductCalculations
();
},
TextInputType
.
number
,
false
,
null
,
null
,
null
,
TextInputAction
.
next
,
),
),
const
SizedBox
(
width:
8.0
),
Expanded
(
child:
textControllerWidget
(
context
,
provider
.
SGSTController
,
"SGST %"
,
"Enter SGST %"
,
(
p0
)
{
provider
.
updateProductCalculations
();
},
TextInputType
.
number
,
false
,
null
,
null
,
null
,
TextInputAction
.
next
,
),
),
const
SizedBox
(
width:
8.0
),
Expanded
(
child:
textControllerWidget
(
context
,
provider
.
IGSTController
,
"IGST %"
,
"Enter IGST %"
,
(
p0
)
{
provider
.
updateProductCalculations
();
},
TextInputType
.
number
,
false
,
null
,
null
,
null
,
TextInputAction
.
next
,
),
),
],
),
const
SizedBox
(
height:
8.0
),
Row
(
children:
[
Expanded
(
child:
textControllerWidget
(
context
,
provider
.
TaxableValueController
,
"Total Price"
,
"Enter Total Price"
,
(
p0
)
{
provider
.
updateProductCalculations
();
},
TextInputType
.
number
,
true
,
null
,
null
,
null
,
TextInputAction
.
next
,
),
),
],
),
],
),
),
],
),
),
const
SizedBox
(
height:
20
),
// Submit Button
],
),
),
floatingActionButtonLocation:
FloatingActionButtonLocation
.
centerFloat
,
floatingActionButton:
InkWell
(
onTap:
()
{
if
(
provider
.
selectedSaleProducts
!=
null
)
{
final
productData
=
{
'product_id'
:
provider
.
selectedSingleSaleProductID
,
'qty'
:
provider
.
QuantityController
.
text
,
'price'
:
provider
.
PriceController
.
text
,
'cgst_p'
:
provider
.
CGSTController
.
text
,
'sgst_p'
:
provider
.
SGSTController
.
text
,
'igst_p'
:
provider
.
IGSTController
.
text
,
'total_price'
:
provider
.
TaxableValueController
.
text
,
};
if
(
widget
.
editIndex
!=
null
)
{
provider
.
updateProduct
(
widget
.
editIndex
!,
productData
);
}
else
{
provider
.
addProduct
(
productData
);
}
print
(
provider
.
getJsonEncodedProducts
());
Navigator
.
pop
(
context
,
provider
.
getJsonEncodedProducts
());
}
},
child:
Container
(
alignment:
Alignment
.
center
,
height:
45
,
decoration:
BoxDecoration
(
color:
AppColors
.
app_blue
,
//1487C9
borderRadius:
BorderRadius
.
circular
(
14.0
),
),
margin:
EdgeInsets
.
symmetric
(
horizontal:
10
),
child:
Center
(
child:
Text
(
"Submit"
,
textAlign:
TextAlign
.
center
,
style:
TextStyle
(
color:
Colors
.
white
),
),
),
),
),
);
},
);
}
}
lib/screens/order/addPayment.dart
View file @
c1b1af92
...
@@ -94,11 +94,12 @@ class _AddpaymentScreenState extends State<AddpaymentScreen> {
...
@@ -94,11 +94,12 @@ class _AddpaymentScreenState extends State<AddpaymentScreen> {
child:
Scaffold
(
child:
Scaffold
(
resizeToAvoidBottomInset:
true
,
resizeToAvoidBottomInset:
true
,
backgroundColor:
AppColors
.
white
,
backgroundColor:
AppColors
.
white
,
appBar:
appbar2
(
appBar:
appbar2
New
(
context
,
context
,
"
${widget.pageTitleName}
"
,
"
${widget.pageTitleName}
"
,
provider
.
resetForm
,
provider
.
resetForm
,
SizedBox
(
width:
0
),
SizedBox
(
width:
0
),
0xFFFFFFFF
),
),
body:
Container
(
body:
Container
(
padding:
EdgeInsets
.
symmetric
(
horizontal:
10
),
padding:
EdgeInsets
.
symmetric
(
horizontal:
10
),
...
...
lib/screens/order/addTpcAgent.dart
View file @
c1b1af92
...
@@ -67,11 +67,12 @@ class _AddtpcagentScreenState extends State<AddtpcagentScreen> {
...
@@ -67,11 +67,12 @@ class _AddtpcagentScreenState extends State<AddtpcagentScreen> {
bottom:
Platform
.
isIOS
?
false
:
true
,
bottom:
Platform
.
isIOS
?
false
:
true
,
child:
Scaffold
(
child:
Scaffold
(
resizeToAvoidBottomInset:
true
,
resizeToAvoidBottomInset:
true
,
appBar:
appbar2
(
appBar:
appbar2
New
(
context
,
context
,
"Add TPC Agent"
,
"Add TPC Agent"
,
provider
.
resetAll
,
provider
.
resetAll
,
SizedBox
(
width:
0
),
SizedBox
(
width:
0
),
0xFFFFFFFF
),
),
backgroundColor:
AppColors
.
scaffold_bg_color
,
backgroundColor:
AppColors
.
scaffold_bg_color
,
body:
Container
(
body:
Container
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment