filter with view freight bill

dev_branch
Priya Chetiwal 2025-02-06 13:36:00 +05:30
parent 712a309ee4
commit f3e918b2bd
5 changed files with 308 additions and 252 deletions

View File

@ -402,12 +402,13 @@ class GenerateFrightBill extends StatelessWidget {
negativeText: "Cancel",
positiveBtCallback: () {
Get.back();
// controller.addFreightBill();
// showFreightBill(context);
//
// controller.postData();
controller.addFreightBill();
showFreightBill(context);
},
negativeBtCallback: () {});
negativeBtCallback: () {
Get.back();
});
}
}),
],
@ -416,9 +417,10 @@ class GenerateFrightBill extends StatelessWidget {
Container(
margin: EdgeInsets.only(bottom: 16, top: 16),
height: controller.isFilterVisibleGenerateFreight.value == true
? MediaQuery.of(context).size.height * 0.4
? MediaQuery.of(context).size.height * 0.3
: MediaQuery.of(context).size.height * 0.7,
child: RawScrollbar(
thumbColor: AppColors.clrD9,
radius: Radius.circular(2),
trackVisibility: true,
@ -496,13 +498,7 @@ class GenerateFrightBill extends StatelessWidget {
],
rows: List<DataRow>.generate(
controller.grnDetails.length, (index) {
final stoppage = controller
.grnDetails[index].codeValue ==
"Active" ||
controller.grnDetails[index].codeValue ==
"Reversed"
? controller.grnDetails[index]
: controller.grnDetails[-1];
final stoppage = controller.grnDetails[index];
return DataRow(
selected: stoppage.isSelected,
@ -517,11 +513,9 @@ class GenerateFrightBill extends StatelessWidget {
index, value ?? false);
},
activeColor: AppColors.primaryClr,
// Custom color when selected
checkColor: Colors.white,
// Custom color for check mark
materialTapTargetSize: MaterialTapTargetSize
.shrinkWrap, // Avoids large tap area
materialTapTargetSize:
MaterialTapTargetSize.shrinkWrap,
),
),
),
@ -548,12 +542,11 @@ class GenerateFrightBill extends StatelessWidget {
index, stoppage.netQty?.toString() ?? ""),
editableCell(index,
stoppage.billingQty?.toString() ?? ""),
editableCell(index, "-"),
editableCell(index,
stoppage.freightRate?.toString() ?? ""),
editableCell(index,
stoppage.shipmentCost?.toString() ?? ""),
editableCell(index,
stoppage.statusId?.toString() ?? ""),
],
);
}),

View File

@ -256,29 +256,30 @@ class PendingGeneration extends StatelessWidget {
),
),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(text: "From Location"),
SizedBox(height: 8),
CustomDropdown<dynamic>(
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: controller.fromLocation,
itemLabel: (item) => item,
onSelected: (selected) {
if (selected != null) {
controller.selectLocation.value =
selected;
}
},
hintText: "Select From Location",
),
],
),
),
// Expanded(
// child: Column(
// mainAxisAlignment: MainAxisAlignment.start,
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// TextView(text: "From Location"),
// SizedBox(height: 8),
// CustomDropdown<dynamic>(
// backClr: AppColors.clrD9,
// borderClr: AppColors.clrGrey,
// items: controller.fromLocation,
// itemLabel: (item) => item,
// onSelected: (selected) {
// if (selected != null) {
// controller.selectLocation.value =
// selected;
// }
// },
// hintText: "Select From Location",
// ),
// ],
// ),
// ),
Expanded(child: SizedBox.shrink()),
SizedBox(
width: 16,
),
@ -373,7 +374,7 @@ class PendingGeneration extends StatelessWidget {
margin: EdgeInsets.only(bottom: 16, top: 16),
height:
controller.isFilterVisiblePendingGeneration.value == true
? MediaQuery.of(context).size.height * 0.4
? MediaQuery.of(context).size.height * 0.3
: MediaQuery.of(context).size.height * 0.7,
child: RawScrollbar(
thumbColor: AppColors.clrD9,

View File

@ -75,6 +75,41 @@ class ViewFreightBill extends StatelessWidget {
),
),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: "Freight Bill No.", isRequired: true),
SizedBox(height: 8),
CustomDropdown<String>(
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: controller.freightBill,
itemLabel: (item) => item,
onSelected: (selected) {
if (selected != null) {
controller.selectFreightBillValidate.value =
selected;
controller.showTransactionErrorViewFreight
.value = false;
}
},
hintText: "Select Freight Bill No.",
),
Obx(() => controller
.showTransactionErrorViewFreight.value
? Text(
'Required',
style: TextStyle(
color: Colors.red, fontSize: 12),
)
: Text('')),
],
),
),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
@ -112,43 +147,6 @@ class ViewFreightBill extends StatelessWidget {
],
),
),
SizedBox(width: 16),
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TextView(
text: "Transaction Type", isRequired: true),
SizedBox(height: 8),
CustomDropdown<String>(
backClr: AppColors.clrD9,
borderClr: AppColors.clrGrey,
items: controller.transactionType,
itemLabel: (item) => item,
onSelected: (selected) {
if (selected != null) {
controller.selectTransactionTypeViewFreight
.value = selected;
controller.showTransactionErrorViewFreight
.value = false;
print(
"selectTransactionType${controller.selectTransactionType.value}");
}
},
hintText: "Select Transaction Type",
),
Obx(() => controller
.showTransactionErrorViewFreight.value
? Text(
'Required',
style: TextStyle(
color: Colors.red, fontSize: 12),
)
: Text('')),
],
),
),
],
),
Padding(
@ -407,8 +405,9 @@ class ViewFreightBill extends StatelessWidget {
children: [
Container(
margin: EdgeInsets.only(bottom: 16, top: 16),
height: controller.isFilterVisibleViewFreight.value == true ? MediaQuery.of(context).size.height * 0.4:
MediaQuery.of(context).size.height * 0.7,
height: controller.isFilterVisibleViewFreight.value == true
? MediaQuery.of(context).size.height * 0.4
: MediaQuery.of(context).size.height * 0.7,
child: RawScrollbar(
thumbColor: AppColors.clrD9,
radius: Radius.circular(2),
@ -430,7 +429,6 @@ class ViewFreightBill extends StatelessWidget {
controller: controller.horizontalScrollController,
child: Container(
margin: EdgeInsets.only(bottom: 24, right: 24),
decoration: BoxDecoration(
border: Border.all(
color: Colors.grey.shade400,
@ -502,9 +500,8 @@ class ViewFreightBill extends StatelessWidget {
controller.freightBillCode.value =
freightBill.freightbillCode ?? "";
print(
'freightBill.freightbillCode ${controller.freightBillCode.value} and ${freightBill.freightbillCode.toString()}');
'freightBill.trasnporterInvoiceNo ${freightBill.trasnporterInvoiceNo}');
return DataRow(
cells: [
editableCell(
@ -515,14 +512,6 @@ class ViewFreightBill extends StatelessWidget {
index,
freightBill.freightbillCode ?? "-",
isLink: true,
// onTap: () {
// showFreightBillDetailsDialog(
// context, controller.grnListDialog.value);
// print('on tap');
// controller.getSubFreightBillsView();
//
//
// },
onTap: () async {
print(
'Freight Bill Code: ${freightBill.freightbillCode}');
@ -729,7 +718,7 @@ class ViewFreightBill extends StatelessWidget {
dataColumn(AppStrings.netQty),
dataColumn(AppStrings.billingQty),
dataColumn(AppStrings.uom),
dataColumn(AppStrings.freightBill),
dataColumn(AppStrings.freightRate),
dataColumn(
AppStrings.freightAmount),
],
@ -764,12 +753,11 @@ class ViewFreightBill extends StatelessWidget {
"${freightBill.netQty ?? "-"}"),
editableCell(index,
"${freightBill.billingQty ?? "-"}"),
editableCell(index,
"${freightBill.billingQty ?? "-"}"),
editableCell(index, "-"),
editableCell(index,
"${freightBill.freightRate ?? "-"}"),
editableCell(index,
"${freightBill.freightRate ?? "-"}"),
"${freightBill.shipmentCost ?? "-"}"),
],
);
},

View File

@ -46,12 +46,12 @@ class TransportController extends GetxController {
RxString selectPlantViewFreight = ''.obs;
var selectProductViewFreight = ''.obs;
var selectLocationViewFreight = ''.obs;
var selectTransactionTypeViewFreight = ''.obs;
var selectedItem = false.obs;
var grnDetails = <Content>[].obs;
var product = <Prodect>[].obs;
var plant = <Plant>[].obs;
var freightBill = [].obs;
var freightBill = <String>[].obs;
var selectFreightBillValidate = ''.obs;
var fromLocation = [].obs;
var grnList = [].obs;
RxBool showE = false.obs;
@ -134,8 +134,8 @@ class TransportController extends GetxController {
void validateFieldsViewFreightBill() {
showPlantErrorViewFreight.value = selectPlantViewFreight.value.isEmpty;
// showTransactionErrorViewFreight.value =
// selectTransactionTypeViewFreight.value.isEmpty;
showTransactionErrorViewFreight.value =
selectFreightBillValidate.value.isEmpty;
showProductErrorViewFreight.value = selectProductViewFreight.value.isEmpty;
}
@ -311,7 +311,7 @@ class TransportController extends GetxController {
showPlantError.value = false;
showProductError.value = false;
showTransactionError.value = false;
postData();
}
void clearFiltersPendingGeneration() {
@ -322,18 +322,18 @@ class TransportController extends GetxController {
showPlantErrorPending.value = false;
showProductErrorPending.value = false;
showTransactionErrorPending.value = false;
postData();
}
void clearFiltersViewFreight() {
selectPlantViewFreight.value = '';
selectProductViewFreight.value = '';
// selectTransactionTypeViewFreight.value = '';
selectFreightBillValidate.value = '';
fromController.clear();
showPlantErrorViewFreight.value = false;
showProductErrorViewFreight.value = false;
showTransactionErrorViewFreight.value = false;
postData();
}
getFreightBills() async {
@ -342,7 +342,7 @@ class TransportController extends GetxController {
var response = await GetRequests.getFreightBill();
if (response != null) {
print("gtyfhg");
plant.assignAll(response.plant ?? []);
product.assignAll(response.prodect ?? []);
freightBill.assignAll(response.freightBill ?? []);
@ -547,59 +547,139 @@ class TransportController extends GetxController {
}
// void displayFilteredDataFromViewFreight() async {
// try {
// freightViewLoader.value = true;
// Map<String, String> requestBody = {
// "plant": selectPlantViewFreight.value,
// "productNane": selectProductViewFreight.value,
// "freightBillNo": selectFreightBillValidate.value,
// "transactionType": "",
// "fromLocation": "",
// "grnFromDate": "",
// "grnToDate": "",
// };
// print(
// "Filter request with Plant: ${selectPlantViewFreight.value}, Product: ${selectProductViewFreight.value} and ${ selectFreightBillValidate.value}");
// var response = await PostRequests.viewFreightBill(requestBody);
// if (response != null) {
// List<FreightBill> flattenedContent =
// response.content!.expand((list) => list).toList();
//
// print("Total records before filtering: ${flattenedContent.length}");
//
// // If first item exists, log its types for debugging
// if (flattenedContent.isNotEmpty) {
// print(
// "Sample data types - Plant: ${flattenedContent[0].plantCode.runtimeType}, "
// "Material: ${flattenedContent[0].materialCode.runtimeType}");
// }
//
// List<FreightBill> filteredData = flattenedContent.where((item) {
// bool plantMatch = selectPlantViewFreight.value.isEmpty ||
// item.plantCode == selectPlantViewFreight.value;
// bool productMatch = selectProductViewFreight.value.isEmpty ||
// item.materialCode == selectProductViewFreight.value;
// selectFreightBillValidate.value
//
// // Debug log for matching
// print("Checking - Plant: ${item.plantCode} matches: $plantMatch, "
// "Product: ${item.materialCode} matches: $productMatch");
//
// return plantMatch && productMatch;
// }).toList();
//
// print("Filtered records count: ${filteredData.length}");
//
// freightBillData.assignAll(filteredData);
//
// // Update pagination if available
// totalPages.value = response.totalPages ?? 0;
// totalElements.value = response.totalElements ?? 0;
//
// print(
// "✅ Freight bill data filtered: ${filteredData.length} items displayed");
// } else {
// print("❌ No response from API.");
// freightBillData.clear();
// }
// } catch (e) {
// print("❌ Error in displayFilteredDataFromViewFreight: $e");
// freightBillData.clear();
// } finally {
// freightViewLoader.value = false;
// print('data');
// }
// }
void displayFilteredDataFromViewFreight() async {
try {
freightViewLoader.value = true;
Map<String, String> requestBody = {
"plant": selectPlantViewFreight.value,
"productNane": selectProductViewFreight.value,
"freightBillNo": "",
"freightBillNo": selectFreightBillValidate.value,
"transactionType": "",
"fromLocation": "",
"grnFromDate": "",
"grnToDate": "",
};
print(
"Filter request with Plant: ${selectPlantViewFreight.value}, Product: ${selectProductViewFreight.value}");
print("Filter request - Plant: ${selectPlantViewFreight.value}, "
"Product: ${selectProductViewFreight.value}, "
"Freight Bill: ${selectFreightBillValidate.value}");
var response = await PostRequests.viewFreightBill(requestBody);
if (response != null) {
List<FreightBill> flattenedContent =
response.content!.expand((list) => list).toList();
response.content!.expand((list) => list).toList();
print("Total records before filtering: ${flattenedContent.length}");
// If first item exists, log its types for debugging
// Log sample data for debugging if available
if (flattenedContent.isNotEmpty) {
print(
"Sample data types - Plant: ${flattenedContent[0].plantCode.runtimeType}, "
"Material: ${flattenedContent[0].materialCode.runtimeType}");
"Sample data - Plant: ${flattenedContent[0].plantCode}, "
"Material: ${flattenedContent[0].materialCode}, "
"Freight Bill: ${flattenedContent[0].freightbillCode}");
}
List<FreightBill> filteredData = flattenedContent.where((item) {
// Plant filter
bool plantMatch = selectPlantViewFreight.value.isEmpty ||
item.plantCode == selectPlantViewFreight.value;
item.plantCode.toString().toLowerCase() ==
selectPlantViewFreight.value.toLowerCase();
// Product filter
bool productMatch = selectProductViewFreight.value.isEmpty ||
item.materialCode == selectProductViewFreight.value;
item.materialCode.toString().toLowerCase() ==
selectProductViewFreight.value.toLowerCase();
// Debug log for matching
print("Checking - Plant: ${item.plantCode} matches: $plantMatch, "
"Product: ${item.materialCode} matches: $productMatch");
// Freight bill filter
bool freightBillMatch = selectFreightBillValidate.value.isEmpty ||
item.freightbillCode.toString().toLowerCase() ==
selectFreightBillValidate.value.toLowerCase();
return plantMatch && productMatch;
// Debug logging for filter matches
print("Filter matches for item ${item.freightbillCode}:"
"\nPlant Match: $plantMatch (${item.plantCode} vs ${selectPlantViewFreight.value})"
"\nProduct Match: $productMatch (${item.materialCode} vs ${selectProductViewFreight.value})"
"\nFreight Bill Match: $freightBillMatch (${item.freightbillCode} vs ${selectFreightBillValidate.value})");
return plantMatch && productMatch && freightBillMatch;
}).toList();
print("Filtered records count: ${filteredData.length}");
freightBillData.assignAll(filteredData);
// Update pagination if available
// Update pagination values
totalPages.value = response.totalPages ?? 0;
totalElements.value = response.totalElements ?? 0;
print(
"✅ Freight bill data filtered: ${filteredData.length} items displayed");
print("✅ Freight bill data filtered successfully");
} else {
print("❌ No response from API.");
print("❌ No response received from API");
freightBillData.clear();
}
} catch (e) {
@ -607,10 +687,8 @@ class TransportController extends GetxController {
freightBillData.clear();
} finally {
freightViewLoader.value = false;
print('data');
}
}
void displayFilteredDataFromPending() async {
try {
isLoading.value = true;

View File

@ -151,136 +151,132 @@ void showFreightBill(BuildContext context) {
)),
),
),
controller.grnList.isEmpty
? Center(child: Text('No data available.'))
: Container(
padding: EdgeInsets.only(
top: 24, left: 16, right: 16, bottom: 16),
color: Colors.white,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Container(
margin: EdgeInsets.only(right: 13),
height: 20,
width: 20,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.white,
border: Border.all(color: AppColors.green)),
child: Center(
child: Icon(
Icons.done_rounded,
color: AppColors.green,
size: 16,
),
)),
Text(
"Freight Bill Generate Successfully",
style: TextStyle(
fontSize: 12,
color: AppColors.green,
fontWeight: FontWeight.bold),
Container(
padding:
EdgeInsets.only(top: 24, left: 16, right: 16, bottom: 16),
color: Colors.white,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: [
Container(
margin: EdgeInsets.only(right: 13),
height: 20,
width: 20,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.white,
border: Border.all(color: AppColors.green)),
child: Center(
child: Icon(
Icons.done_rounded,
color: AppColors.green,
size: 16,
),
],
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: Obx(
() => Text(
"Freight Bill No: ${controller.freightBillNo.value}",
style: TextStyle(
fontSize: 12,
color: AppColors.black,
fontWeight: FontWeight.bold),
),
),
),
Obx(() {
if (controller.grnListLoader.value) {
return Center(
child: CircularProgressIndicator(
color: AppColors.primaryClr,
));
}
if (controller.errorMessage.isNotEmpty) {
return Center(
child: Text(controller.errorMessage.value));
}
if (controller.grnList.isEmpty) {
return Center(child: Text('No data available.'));
}
return Scrollbar(
thumbVisibility: true,
controller: controller.horizontalScrollController,
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
controller: controller.horizontalScrollController,
child: Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.grey.shade400,
width: 1.0,
),
),
child: DataTable(
dataRowHeight: 28,
headingRowHeight: 38,
headingRowColor:
WidgetStateProperty.all(AppColors.clrF2),
border: TableBorder(
horizontalInside:
BorderSide(color: AppColors.clrGrey),
verticalInside:
BorderSide(color: AppColors.clrGrey),
bottom:
BorderSide(color: AppColors.clrGrey),
left: BorderSide(color: AppColors.clrGrey),
right: BorderSide(color: AppColors.clrGrey),
top: BorderSide(color: AppColors.clrGrey),
),
columns: [
dataColumn(AppStrings.srNo),
dataColumn(AppStrings.mrnNo),
],
rows: List<DataRow>.generate(
controller.grnList.length, (index) {
final stoppage = controller.grnList[index];
return DataRow(
cells: [
editableCell(index, "0$index"),
editableCell(index, stoppage),
],
);
}),
),
),
),
);
}),
Align(
alignment: Alignment.bottomRight,
child: CommonBtn(
style: 14.txtBoldBlue,
borderClr: AppColors.primaryClr,
bkClr: Colors.white,
margin: EdgeInsets.only(top: 24),
text: "Done",
clickAction: () {
controller.navigateToInvoiceTab();
}),
)
],
)),
Text(
"Freight Bill Generate Successfully",
style: TextStyle(
fontSize: 12,
color: AppColors.green,
fontWeight: FontWeight.bold),
),
],
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: Obx(
() => Text(
"Freight Bill No: ${controller.freightBillNo.value}",
style: TextStyle(
fontSize: 12,
color: AppColors.black,
fontWeight: FontWeight.bold),
),
),
),
Obx(() {
if (controller.grnListLoader.value) {
return Center(
child: CircularProgressIndicator(
color: AppColors.primaryClr,
));
}
if (controller.errorMessage.isNotEmpty) {
return Center(child: Text(controller.errorMessage.value));
}
if (controller.grnList.isEmpty) {
return Center(child: Text('No data available.'));
}
return Scrollbar(
thumbVisibility: true,
controller: controller.horizontalScrollController,
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
controller: controller.horizontalScrollController,
child: Container(
decoration: BoxDecoration(
border: Border.all(
color: Colors.grey.shade400,
width: 1.0,
),
),
child: DataTable(
dataRowHeight: 28,
headingRowHeight: 38,
headingRowColor:
WidgetStateProperty.all(AppColors.clrF2),
border: TableBorder(
horizontalInside:
BorderSide(color: AppColors.clrGrey),
verticalInside:
BorderSide(color: AppColors.clrGrey),
bottom: BorderSide(color: AppColors.clrGrey),
left: BorderSide(color: AppColors.clrGrey),
right: BorderSide(color: AppColors.clrGrey),
top: BorderSide(color: AppColors.clrGrey),
),
columns: [
dataColumn(AppStrings.srNo),
dataColumn(AppStrings.mrnNo),
],
rows: List<DataRow>.generate(
controller.grnList.length, (index) {
final stoppage = controller.grnList[index];
return DataRow(
cells: [
editableCell(index, "0$index"),
editableCell(index, stoppage),
],
);
}),
),
),
),
);
}),
Align(
alignment: Alignment.bottomRight,
child: CommonBtn(
style: 14.txtBoldBlue,
borderClr: AppColors.primaryClr,
bkClr: Colors.white,
margin: EdgeInsets.only(top: 24),
text: "Done",
clickAction: () {
Get.back();
}),
)
],
),
),
],
),
);