payout
This commit is contained in:
parent
9f3b22200f
commit
02e73e3543
@ -60,7 +60,7 @@ class _DateFilterRowState extends ConsumerState<DateFilterRowPayout> {
|
|||||||
dropDownKeyPartner = GlobalKey<DropdownSearchState<Map<String, dynamic>>>();
|
dropDownKeyPartner = GlobalKey<DropdownSearchState<Map<String, dynamic>>>();
|
||||||
|
|
||||||
late ApiService apiService;
|
late ApiService apiService;
|
||||||
List<dynamic>? selectedPartnerIds = [];
|
// List<dynamic>? selectedPartnerIds = [];
|
||||||
List<Map<String, dynamic>> getPartnerData = [];
|
List<Map<String, dynamic>> getPartnerData = [];
|
||||||
List<Map<String, dynamic>> filteredPartnerData = [];
|
List<Map<String, dynamic>> filteredPartnerData = [];
|
||||||
|
|
||||||
@ -88,10 +88,10 @@ class _DateFilterRowState extends ConsumerState<DateFilterRowPayout> {
|
|||||||
final userID = ref.watch(userIdProvider);
|
final userID = ref.watch(userIdProvider);
|
||||||
role = ref.watch(userRoleProvider);
|
role = ref.watch(userRoleProvider);
|
||||||
print("managerId - $managerId");
|
print("managerId - $managerId");
|
||||||
if (userID != null && role != null) {
|
// if (userID != null && role != null) {
|
||||||
print('hansles');
|
// print('hansles');
|
||||||
getPartnerDetails(userID);
|
// getPartnerDetails(userID);
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (managerId != null) {
|
if (managerId != null) {
|
||||||
print('managerId - $managerId');
|
print('managerId - $managerId');
|
||||||
@ -165,40 +165,40 @@ class _DateFilterRowState extends ConsumerState<DateFilterRowPayout> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getPartnerDetails(int id) async {
|
// Future<void> getPartnerDetails(int id) async {
|
||||||
print('getPartnerDetails called By handler');
|
// print('getPartnerDetails called By handler');
|
||||||
setState(() {
|
// setState(() {
|
||||||
isLoading = true;
|
// isLoading = true;
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
// final response = await apiService.fetchStaffUserList(id, role);
|
// // final response = await apiService.fetchStaffUserList(id, role);
|
||||||
final response = await apiService.fetchStaffListForEnquiryAssignDropDown(
|
// final response = await apiService.fetchStaffListForEnquiryAssignDropDown(
|
||||||
managerId,
|
// managerId,
|
||||||
id,
|
// id,
|
||||||
role,
|
// role,
|
||||||
);
|
// );
|
||||||
if (response['status'] == 'success') {
|
// if (response['status'] == 'success') {
|
||||||
print('getStaffDetails - ${response['data']}');
|
// print('getStaffDetails - ${response['data']}');
|
||||||
setState(() {
|
// setState(() {
|
||||||
getPartnerData = List<Map<String, dynamic>>.from(response['data']);
|
// getPartnerData = List<Map<String, dynamic>>.from(response['data']);
|
||||||
print('API Data - $getPartnerData');
|
// print('API Data - $getPartnerData');
|
||||||
|
//
|
||||||
filteredPartnerData = List.from(getPartnerData);
|
// filteredPartnerData = List.from(getPartnerData);
|
||||||
print('originalData - $filteredPartnerData');
|
// print('originalData - $filteredPartnerData');
|
||||||
});
|
// });
|
||||||
} else {
|
// } else {
|
||||||
getPartnerData = [];
|
// getPartnerData = [];
|
||||||
filteredPartnerData = [];
|
// filteredPartnerData = [];
|
||||||
}
|
// }
|
||||||
} catch (e) {
|
// } catch (e) {
|
||||||
print('Exception occurred: $e');
|
// print('Exception occurred: $e');
|
||||||
} finally {
|
// } finally {
|
||||||
setState(() {
|
// setState(() {
|
||||||
isLoading = false;
|
// isLoading = false;
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -350,7 +350,7 @@ class _DateFilterRowState extends ConsumerState<DateFilterRowPayout> {
|
|||||||
return null; // ✅ no error
|
return null; // ✅ no error
|
||||||
},
|
},
|
||||||
controller: widget.endController,
|
controller: widget.endController,
|
||||||
lastDate: DateTime.now(),
|
// lastDate: DateTime.now(),
|
||||||
onDateSelected: (date) {
|
onDateSelected: (date) {
|
||||||
print("Picked Date: $date");
|
print("Picked Date: $date");
|
||||||
widget.endController.text = DateFormat('dd-MM-yyyy').format(date);
|
widget.endController.text = DateFormat('dd-MM-yyyy').format(date);
|
||||||
@ -536,9 +536,15 @@ class _DateFilterRowState extends ConsumerState<DateFilterRowPayout> {
|
|||||||
// : null,
|
// : null,
|
||||||
selectedItems: filteredPartnerData
|
selectedItems: filteredPartnerData
|
||||||
.where(
|
.where(
|
||||||
(item) => (selectedPartnerIds ?? []).contains(item['id']),
|
(item) => (widget.selectedParnter ?? []).contains(item['id']),
|
||||||
)
|
)
|
||||||
.toList(),
|
.toList(),
|
||||||
|
|
||||||
|
// selectedItems: filteredPartnerData
|
||||||
|
// .where(
|
||||||
|
// (item) => (selectedPartnerIds ?? []).contains(item['id']),
|
||||||
|
// )
|
||||||
|
// .toList(),
|
||||||
items: (filter, infiniteScrollProps) {
|
items: (filter, infiniteScrollProps) {
|
||||||
return filteredPartnerData;
|
return filteredPartnerData;
|
||||||
},
|
},
|
||||||
@ -647,7 +653,7 @@ class _DateFilterRowState extends ConsumerState<DateFilterRowPayout> {
|
|||||||
// .map((v) => v['id'].toString())
|
// .map((v) => v['id'].toString())
|
||||||
// .toList();
|
// .toList();
|
||||||
final ids = selectedVals.map((v) => v['id'].toString()).toList();
|
final ids = selectedVals.map((v) => v['id'].toString()).toList();
|
||||||
print("Selected PArnter IDs: $selectedPartnerIds");
|
print("Selected PArnter IDs: $widget.selectedPartnerIds");
|
||||||
widget.onPartnerChanges?.call(ids);
|
widget.onPartnerChanges?.call(ids);
|
||||||
// widget.onPartnerChanges!(v['id']);
|
// widget.onPartnerChanges!(v['id']);
|
||||||
},
|
},
|
||||||
@ -657,153 +663,153 @@ class _DateFilterRowState extends ConsumerState<DateFilterRowPayout> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildSelectStaffMem(BuildContext context) {
|
// Widget buildSelectStaffMem(BuildContext context) {
|
||||||
Map<String, dynamic>? selectedVehicle;
|
// Map<String, dynamic>? selectedVehicle;
|
||||||
if (widget.selectedStaffId == null) {
|
// if (widget.selectedStaffId == null) {
|
||||||
selectedVehicle = null;
|
// selectedVehicle = null;
|
||||||
} else if (widget.selectedStaffId != null) {
|
// } else if (widget.selectedStaffId != null) {
|
||||||
selectedVehicle = filteredPartnerData.firstWhere(
|
// selectedVehicle = filteredPartnerData.firstWhere(
|
||||||
(item) => item['id'] == widget.selectedStaffId,
|
// (item) => item['id'] == widget.selectedStaffId,
|
||||||
orElse: () => {}, // empty map
|
// orElse: () => {}, // empty map
|
||||||
);
|
// );
|
||||||
if (selectedVehicle.isEmpty) selectedVehicle = null;
|
// if (selectedVehicle.isEmpty) selectedVehicle = null;
|
||||||
} else if (selectedStaff != null) {
|
// } else if (selectedStaff != null) {
|
||||||
selectedVehicle = filteredPartnerData.firstWhere(
|
// selectedVehicle = filteredPartnerData.firstWhere(
|
||||||
(item) => item['id'] == selectedStaff,
|
// (item) => item['id'] == selectedStaff,
|
||||||
orElse: () => {}, // empty map
|
// orElse: () => {}, // empty map
|
||||||
);
|
// );
|
||||||
if (selectedVehicle.isEmpty) selectedVehicle = null;
|
// if (selectedVehicle.isEmpty) selectedVehicle = null;
|
||||||
} else {
|
// } else {
|
||||||
selectedVehicle = null;
|
// selectedVehicle = null;
|
||||||
}
|
// }
|
||||||
return Column(
|
// return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
// children: [
|
||||||
// Text("Staff Name", style: _textStyle),
|
// // Text("Staff Name", style: _textStyle),
|
||||||
// SizedBox(height: 10),
|
// // SizedBox(height: 10),
|
||||||
SizedBox(
|
// SizedBox(
|
||||||
height: 35,
|
// height: 35,
|
||||||
child: Container(
|
// child: Container(
|
||||||
decoration: BoxDecoration(
|
// decoration: BoxDecoration(
|
||||||
borderRadius: BorderRadius.circular(5.0),
|
// borderRadius: BorderRadius.circular(5.0),
|
||||||
border: Border.all(color: Color(0xFFE2E8F0)),
|
// border: Border.all(color: Color(0xFFE2E8F0)),
|
||||||
// color: Colors.black,
|
// // color: Colors.black,
|
||||||
),
|
// ),
|
||||||
|
//
|
||||||
width: ResponsiveLayout.isMobile(context)
|
// width: ResponsiveLayout.isMobile(context)
|
||||||
? null
|
// ? null
|
||||||
: MediaQuery.of(context).size.width * 0.13,
|
// : MediaQuery.of(context).size.width * 0.13,
|
||||||
// height: 45,
|
// // height: 45,
|
||||||
child: DropdownSearch<Map<String, dynamic>>(
|
// child: DropdownSearch<Map<String, dynamic>>(
|
||||||
// key: dropDownKey,
|
// // key: dropDownKey,
|
||||||
key: ValueKey(selectedStaff),
|
// key: ValueKey(selectedStaff),
|
||||||
// selectedItem: selectedVehicle.isNotEmpty ? selectedVehicle : null,
|
// // selectedItem: selectedVehicle.isNotEmpty ? selectedVehicle : null,
|
||||||
selectedItem: selectedVehicle,
|
// selectedItem: selectedVehicle,
|
||||||
|
//
|
||||||
items: (filter, infiniteScrollProps) {
|
// items: (filter, infiniteScrollProps) {
|
||||||
return filteredPartnerData;
|
// return filteredPartnerData;
|
||||||
},
|
// },
|
||||||
|
//
|
||||||
itemAsString: (val) => val['name'].toString(),
|
// itemAsString: (val) => val['name'].toString(),
|
||||||
compareFn: (item, selectedItem) =>
|
// compareFn: (item, selectedItem) =>
|
||||||
item['id'] == selectedItem['id'], // ✅ compare by id
|
// item['id'] == selectedItem['id'], // ✅ compare by id
|
||||||
dropdownBuilder: (context, selectedItem) => Align(
|
// dropdownBuilder: (context, selectedItem) => Align(
|
||||||
alignment: Alignment.centerLeft,
|
// alignment: Alignment.centerLeft,
|
||||||
child: Text(
|
// child: Text(
|
||||||
selectedItem != null ? selectedItem['name'].toString() : "",
|
// selectedItem != null ? selectedItem['name'].toString() : "",
|
||||||
style: GoogleFonts.poppins(fontSize: 11, color: Colors.black),
|
// style: GoogleFonts.poppins(fontSize: 11, color: Colors.black),
|
||||||
overflow: TextOverflow.ellipsis,
|
// overflow: TextOverflow.ellipsis,
|
||||||
maxLines: 1,
|
// maxLines: 1,
|
||||||
softWrap: false,
|
// softWrap: false,
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
decoratorProps: DropDownDecoratorProps(
|
// decoratorProps: DropDownDecoratorProps(
|
||||||
decoration:
|
// decoration:
|
||||||
AppInputDecorations.dropdownDecoration(
|
// AppInputDecorations.dropdownDecoration(
|
||||||
label: "Select Staff ",
|
// label: "Select Staff ",
|
||||||
).copyWith(
|
// ).copyWith(
|
||||||
filled: true,
|
// filled: true,
|
||||||
fillColor:
|
// fillColor:
|
||||||
Colors.white, // 👈 makes the dropdown input white
|
// Colors.white, // 👈 makes the dropdown input white
|
||||||
contentPadding: const EdgeInsets.symmetric(
|
// contentPadding: const EdgeInsets.symmetric(
|
||||||
horizontal: 6,
|
// horizontal: 6,
|
||||||
vertical: 1, // 👈 adjust this to make the field shorter
|
// vertical: 1, // 👈 adjust this to make the field shorter
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
|
//
|
||||||
popupProps: PopupProps.menu(
|
// popupProps: PopupProps.menu(
|
||||||
fit: FlexFit.loose,
|
// fit: FlexFit.loose,
|
||||||
constraints: BoxConstraints(maxHeight: 250),
|
// constraints: BoxConstraints(maxHeight: 250),
|
||||||
menuProps: MenuProps(
|
// menuProps: MenuProps(
|
||||||
backgroundColor:
|
// backgroundColor:
|
||||||
Colors.white, // 👈 sets dropdown background to white
|
// Colors.white, // 👈 sets dropdown background to white
|
||||||
),
|
// ),
|
||||||
showSearchBox: true,
|
// showSearchBox: true,
|
||||||
searchFieldProps: TextFieldProps(
|
// searchFieldProps: TextFieldProps(
|
||||||
decoration: InputDecoration(
|
// decoration: InputDecoration(
|
||||||
filled: true,
|
// filled: true,
|
||||||
fillColor: Colors.white,
|
// fillColor: Colors.white,
|
||||||
hintText: "Search Staff ...",
|
// hintText: "Search Staff ...",
|
||||||
hintStyle: GoogleFonts.inter(
|
// hintStyle: GoogleFonts.inter(
|
||||||
fontSize: 12,
|
// fontSize: 12,
|
||||||
color: Colors.black,
|
// color: Colors.black,
|
||||||
),
|
// ),
|
||||||
enabledBorder: OutlineInputBorder(
|
// enabledBorder: OutlineInputBorder(
|
||||||
borderSide: BorderSide(
|
// borderSide: BorderSide(
|
||||||
color: Colors.white,
|
// color: Colors.white,
|
||||||
), // 👈 Normal border
|
// ), // 👈 Normal border
|
||||||
),
|
// ),
|
||||||
focusedBorder: OutlineInputBorder(
|
// focusedBorder: OutlineInputBorder(
|
||||||
borderSide: BorderSide(
|
// borderSide: BorderSide(
|
||||||
color: Colors.white,
|
// color: Colors.white,
|
||||||
width: 1.5,
|
// width: 1.5,
|
||||||
), // 👈 Focused border
|
// ), // 👈 Focused border
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
|
//
|
||||||
itemBuilder: (context, item, isDisabled, isSelected) {
|
// itemBuilder: (context, item, isDisabled, isSelected) {
|
||||||
return Container(
|
// return Container(
|
||||||
// color: isSelected ? Colors.blue.withOpacity(0.1) : null,
|
// // color: isSelected ? Colors.blue.withOpacity(0.1) : null,
|
||||||
padding: const EdgeInsets.symmetric(
|
// padding: const EdgeInsets.symmetric(
|
||||||
horizontal: 8,
|
// horizontal: 8,
|
||||||
vertical: 3,
|
// vertical: 3,
|
||||||
),
|
// ),
|
||||||
child: Text(
|
// child: Text(
|
||||||
item['name'].toString(),
|
// item['name'].toString(),
|
||||||
style: GoogleFonts.inter(
|
// style: GoogleFonts.inter(
|
||||||
fontSize: 13,
|
// fontSize: 13,
|
||||||
color: Colors.black,
|
// color: Colors.black,
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
);
|
// );
|
||||||
},
|
// },
|
||||||
|
//
|
||||||
// constraints: BoxConstraints(),
|
// // constraints: BoxConstraints(),
|
||||||
),
|
// ),
|
||||||
|
//
|
||||||
onChanged: (val) {
|
// onChanged: (val) {
|
||||||
if (val != null) {
|
// if (val != null) {
|
||||||
print("Selected Staff : ${val['name']}");
|
// print("Selected Staff : ${val['name']}");
|
||||||
print("Id: ${val['id']}");
|
// print("Id: ${val['id']}");
|
||||||
// selectedStaffName = val['name'];
|
// // selectedStaffName = val['name'];
|
||||||
// selectedStaff = val['id'];
|
// // selectedStaff = val['id'];
|
||||||
widget.onBrokerChanged!(val['id']);
|
// widget.onBrokerChanged!(val['id']);
|
||||||
// if (widget.onFilterStaff != null)
|
// // if (widget.onFilterStaff != null)
|
||||||
// widget.onFilterStaff!(val['id']);
|
// // widget.onFilterStaff!(val['id']);
|
||||||
|
//
|
||||||
// Future.microtask(() => widget.onFilter());
|
// // Future.microtask(() => widget.onFilter());
|
||||||
// controllers['agentId']?.text = val['agent_code'];
|
// // controllers['agentId']?.text = val['agent_code'];
|
||||||
// agentId = agent['id'];
|
// // agentId = agent['id'];
|
||||||
}
|
// }
|
||||||
},
|
// },
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
),
|
// ),
|
||||||
],
|
// ],
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
|
|
||||||
static final _textStyle = GoogleFonts.poppins(
|
static final _textStyle = GoogleFonts.poppins(
|
||||||
fontSize: 11,
|
fontSize: 11,
|
||||||
|
|||||||
@ -226,6 +226,7 @@ class _PayOutScreenState extends ConsumerState<PayOutScreen> {
|
|||||||
selectedPolicies = {};
|
selectedPolicies = {};
|
||||||
totalPolicies = '';
|
totalPolicies = '';
|
||||||
totalCommission = '';
|
totalCommission = '';
|
||||||
|
// dropDownKeyPartner.currentState?.clear();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -542,6 +542,18 @@ class _policyValidationState extends ConsumerState<policyValidation> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final commissionAmount =
|
||||||
|
controllers["commission_amount"]?.text.trim() ?? '';
|
||||||
|
|
||||||
|
if (widget.item?['is_data_accuracy_checked']?.toString() == '0' &&
|
||||||
|
commissionAmount.isEmpty) {
|
||||||
|
ToastHelper.showWarningToast(
|
||||||
|
context,
|
||||||
|
"Please calculate commission amount",
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (widget.item?['is_data_accuracy_checked'] == "1") {
|
if (widget.item?['is_data_accuracy_checked'] == "1") {
|
||||||
ToastHelper.showWarningToast(context, "Data already confirmed");
|
ToastHelper.showWarningToast(context, "Data already confirmed");
|
||||||
return;
|
return;
|
||||||
@ -607,7 +619,7 @@ class _policyValidationState extends ConsumerState<policyValidation> {
|
|||||||
final endDate = parseDate(controllers["endDate"]?.text);
|
final endDate = parseDate(controllers["endDate"]?.text);
|
||||||
|
|
||||||
if (startDate != null && endDate != null && startDate.isAfter(endDate)) {
|
if (startDate != null && endDate != null && startDate.isAfter(endDate)) {
|
||||||
ToastHelper.showWarningToast(
|
ToastHelper.showErrorToast(
|
||||||
context,
|
context,
|
||||||
'Start Date cannot be greater than End Date',
|
'Start Date cannot be greater than End Date',
|
||||||
);
|
);
|
||||||
@ -895,7 +907,7 @@ class _policyValidationState extends ConsumerState<policyValidation> {
|
|||||||
"Fuel Type ",
|
"Fuel Type ",
|
||||||
style: GoogleFonts.poppins(fontWeight: FontWeight.w500, fontSize: 11),
|
style: GoogleFonts.poppins(fontWeight: FontWeight.w500, fontSize: 11),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 6),
|
const SizedBox(height: 6),
|
||||||
DropdownSearch<String>(
|
DropdownSearch<String>(
|
||||||
key: dropDownKeyFuel,
|
key: dropDownKeyFuel,
|
||||||
|
|
||||||
@ -1043,8 +1055,16 @@ class _policyValidationState extends ConsumerState<policyValidation> {
|
|||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
inputFormatters: inputFormatters, // 👈 USE HERE
|
inputFormatters: inputFormatters, // 👈 USE HERE
|
||||||
validator: (val) {
|
validator: (val) {
|
||||||
|
// if (val == null || val.isEmpty) {
|
||||||
|
// return ""; // 👈 triggers error border, no text
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (!required) {
|
||||||
|
return null; // ✅ skip validation entirely
|
||||||
|
}
|
||||||
|
|
||||||
if (val == null || val.isEmpty) {
|
if (val == null || val.isEmpty) {
|
||||||
return ""; // 👈 triggers error border, no text
|
return ''; // show red border only when required
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
@ -1618,6 +1638,8 @@ class _policyValidationState extends ConsumerState<policyValidation> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: buildFuelType(context),
|
child: buildFuelType(context),
|
||||||
@ -1689,6 +1711,8 @@ class _policyValidationState extends ConsumerState<policyValidation> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
Row(
|
Row(
|
||||||
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: _buildInput(
|
child: _buildInput(
|
||||||
@ -1762,7 +1786,7 @@ class _policyValidationState extends ConsumerState<policyValidation> {
|
|||||||
child: _buildInput(
|
child: _buildInput(
|
||||||
'Commission Amount *',
|
'Commission Amount *',
|
||||||
controllers['commission_amount']!,
|
controllers['commission_amount']!,
|
||||||
// required: true,
|
required: false,
|
||||||
keyboardType:
|
keyboardType:
|
||||||
TextInputType.numberWithOptions(
|
TextInputType.numberWithOptions(
|
||||||
decimal: true,
|
decimal: true,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user