latest code here
parent
87e0f7608f
commit
7951d16f87
|
@ -57,8 +57,7 @@ class AppStrings {
|
||||||
static const String cCNDate = "CCN Date";
|
static const String cCNDate = "CCN Date";
|
||||||
static const String miroStatus = "Micro Status";
|
static const String miroStatus = "Micro Status";
|
||||||
static const String gstHold = "GST Hold";
|
static const String gstHold = "GST Hold";
|
||||||
static const String gstRelease = "If GST release this invoice"
|
static const String gstRelease = "If GST release this invoice\nthan required GST Payment Due & UTN Number";
|
||||||
" than required GST Payment Due & UTN Number";
|
|
||||||
static const String utrNo = "UTR No.";
|
static const String utrNo = "UTR No.";
|
||||||
static const String utrDate = "UTR Date";
|
static const String utrDate = "UTR Date";
|
||||||
static const String amount = "Amount";
|
static const String amount = "Amount";
|
||||||
|
|
|
@ -299,32 +299,9 @@ class GenerateFrightBill extends StatelessWidget {
|
||||||
height: 30,
|
height: 30,
|
||||||
width: 100,
|
width: 100,
|
||||||
text: AppStrings.submit,
|
text: AppStrings.submit,
|
||||||
// clickAction: () {
|
|
||||||
// // controller.postData();
|
|
||||||
// controller.handleFilterSubmit();
|
|
||||||
// },
|
|
||||||
clickAction: () => controller
|
clickAction: () => controller
|
||||||
.handleFilterSubmitGenerateFreight(),
|
.handleFilterSubmitGenerateFreight(),
|
||||||
),
|
),
|
||||||
// CommonButton(
|
|
||||||
// borderRadius: 4,
|
|
||||||
// height: 30,
|
|
||||||
// width: 100,
|
|
||||||
// text: AppStrings.submit,
|
|
||||||
// clickAction: () {
|
|
||||||
// controller.validateFields();
|
|
||||||
//
|
|
||||||
// if (controller.showPlantError.value ||
|
|
||||||
// controller.showProductError.value ||
|
|
||||||
// controller.showTransactionError.value
|
|
||||||
// ) {
|
|
||||||
// print('controller.showProductError.value ${controller.showProductError.value}');
|
|
||||||
//
|
|
||||||
// } else {
|
|
||||||
// controller.postData();
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
// ),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -349,14 +326,12 @@ class GenerateFrightBill extends StatelessWidget {
|
||||||
color: AppColors.primaryClr,
|
color: AppColors.primaryClr,
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (controller.errorMessage.isNotEmpty) {
|
if (controller.errorMessage.isNotEmpty) {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: MediaQuery.sizeOf(context).height * 0.6,
|
height: MediaQuery.sizeOf(context).height * 0.6,
|
||||||
width: MediaQuery.sizeOf(context).width,
|
width: MediaQuery.sizeOf(context).width,
|
||||||
child: Center(child: Text(controller.errorMessage.value)));
|
child: Center(child: Text(controller.errorMessage.value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (controller.grnDetails.isEmpty) {
|
if (controller.grnDetails.isEmpty) {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: controller.isFilterVisibleGenerateFreight.value
|
height: controller.isFilterVisibleGenerateFreight.value
|
||||||
|
@ -443,7 +418,7 @@ class GenerateFrightBill extends StatelessWidget {
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
controller: controller.horizontalScrollController,
|
controller: controller.horizontalScrollController,
|
||||||
child: Container(
|
child: Container(
|
||||||
margin: EdgeInsets.only(bottom: 24, right: 24),
|
margin: EdgeInsets.only(bottom: 24),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: Colors.grey.shade400,
|
color: Colors.grey.shade400,
|
||||||
|
@ -469,17 +444,15 @@ class GenerateFrightBill extends StatelessWidget {
|
||||||
DataColumn(
|
DataColumn(
|
||||||
label: Transform.scale(
|
label: Transform.scale(
|
||||||
scale: 0.80,
|
scale: 0.80,
|
||||||
// Adjust this scale to make the checkbox bigger or smaller
|
|
||||||
child: Checkbox(
|
child: Checkbox(
|
||||||
value: controller.selectAllField.value,
|
value: controller.selectAllField.value,
|
||||||
|
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
controller.selectAll(value ?? false);
|
controller.selectAll(value ?? false);
|
||||||
},
|
},
|
||||||
activeColor: AppColors.primaryClr,
|
activeColor: AppColors.primaryClr,
|
||||||
checkColor: Colors.white,
|
checkColor: Colors.white,
|
||||||
materialTapTargetSize: MaterialTapTargetSize
|
materialTapTargetSize: MaterialTapTargetSize
|
||||||
.shrinkWrap, // Avoids large tap area
|
.shrinkWrap,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -502,7 +475,6 @@ class GenerateFrightBill extends StatelessWidget {
|
||||||
rows: List<DataRow>.generate(
|
rows: List<DataRow>.generate(
|
||||||
controller.grnDetails.length, (index) {
|
controller.grnDetails.length, (index) {
|
||||||
final stoppage = controller.grnDetails[index];
|
final stoppage = controller.grnDetails[index];
|
||||||
|
|
||||||
return DataRow(
|
return DataRow(
|
||||||
selected: stoppage.isSelected,
|
selected: stoppage.isSelected,
|
||||||
cells: [
|
cells: [
|
||||||
|
@ -565,16 +537,16 @@ class GenerateFrightBill extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
CustomPagination(
|
||||||
|
currentPage: controller.currentPageViewFreight.value + 1,
|
||||||
|
totalPages: controller.totalPagesViewFreight.value,
|
||||||
|
onPageChanged: (page) {
|
||||||
|
controller.viewFreightView(page: page - 1);
|
||||||
|
},
|
||||||
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
CustomPagination(
|
|
||||||
currentPage: controller.currentPage.value,
|
|
||||||
totalPages: controller.totalPages.value,
|
|
||||||
onPageChanged: (int page) {
|
|
||||||
controller.onPageChanged(page);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -524,13 +524,13 @@ class PendingGeneration extends StatelessWidget {
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
CustomPagination(
|
// CustomPagination(
|
||||||
currentPage: controller.currentPage.value,
|
// currentPage: controller.currentPage.value,
|
||||||
totalPages: controller.totalPages.value,
|
// totalPages: controller.totalPages.value,
|
||||||
onPageChanged: (int page) {
|
// onPageChanged: (int page) {
|
||||||
controller.onPageChanged(page);
|
// // controller.onPageChanged(page);
|
||||||
},
|
// },
|
||||||
),
|
// ),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,10 +22,12 @@ class ViewFreightBill extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Column(
|
return Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.end,
|
||||||
children: [
|
children: [
|
||||||
Obx(() => controller.isFilterVisibleViewFreight.value
|
Obx(() => controller.isFilterVisibleViewFreight.value
|
||||||
? Container(
|
? Container(
|
||||||
padding: EdgeInsets.all(16),
|
padding: EdgeInsets.symmetric(vertical: 10,horizontal: 16),
|
||||||
color: AppColors.clrF2,
|
color: AppColors.clrF2,
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
@ -144,7 +146,7 @@ class ViewFreightBill extends StatelessWidget {
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding:
|
padding:
|
||||||
const EdgeInsets.only(top: 16.0, left: 0, right: 8),
|
const EdgeInsets.only(top: 0.0, left: 0, right: 8),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
|
@ -306,7 +308,7 @@ class ViewFreightBill extends StatelessWidget {
|
||||||
Obx(() {
|
Obx(() {
|
||||||
if (controller.freightViewLoader.value) {
|
if (controller.freightViewLoader.value) {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: MediaQuery.sizeOf(context).height * 0.6,
|
height: MediaQuery.sizeOf(context).height * 0.64,
|
||||||
width: MediaQuery.sizeOf(context).width,
|
width: MediaQuery.sizeOf(context).width,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: CircularProgressIndicator(
|
child: CircularProgressIndicator(
|
||||||
|
@ -318,7 +320,7 @@ class ViewFreightBill extends StatelessWidget {
|
||||||
|
|
||||||
if (controller.errorMessage.isNotEmpty) {
|
if (controller.errorMessage.isNotEmpty) {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: MediaQuery.sizeOf(context).height * 0.6,
|
height: MediaQuery.sizeOf(context).height * 0.64,
|
||||||
width: MediaQuery.sizeOf(context).width,
|
width: MediaQuery.sizeOf(context).width,
|
||||||
child: Center(child: Text(controller.errorMessage.value)));
|
child: Center(child: Text(controller.errorMessage.value)));
|
||||||
}
|
}
|
||||||
|
@ -328,7 +330,7 @@ class ViewFreightBill extends StatelessWidget {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
height: controller.isFilterVisibleViewFreight.value
|
height: controller.isFilterVisibleViewFreight.value
|
||||||
? MediaQuery.sizeOf(context).height * 0.4
|
? MediaQuery.sizeOf(context).height * 0.4
|
||||||
: MediaQuery.sizeOf(context).height * 0.6,
|
: MediaQuery.sizeOf(context).height * 0.64,
|
||||||
width: MediaQuery.sizeOf(context).width,
|
width: MediaQuery.sizeOf(context).width,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Text(
|
child: Text(
|
||||||
|
@ -344,7 +346,7 @@ class ViewFreightBill extends StatelessWidget {
|
||||||
Container(
|
Container(
|
||||||
margin: EdgeInsets.only(bottom: 16, top: 16),
|
margin: EdgeInsets.only(bottom: 16, top: 16),
|
||||||
height: controller.isFilterVisibleViewFreight.value == true
|
height: controller.isFilterVisibleViewFreight.value == true
|
||||||
? MediaQuery.of(context).size.height * 0.4
|
? MediaQuery.of(context).size.height * 0.36
|
||||||
: MediaQuery.of(context).size.height * 0.64,
|
: MediaQuery.of(context).size.height * 0.64,
|
||||||
child: RawScrollbar(
|
child: RawScrollbar(
|
||||||
thumbColor: AppColors.clrD9,
|
thumbColor: AppColors.clrD9,
|
||||||
|
@ -366,7 +368,7 @@ class ViewFreightBill extends StatelessWidget {
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
controller: controller.horizontalScrollController,
|
controller: controller.horizontalScrollController,
|
||||||
child: Container(
|
child: Container(
|
||||||
margin: EdgeInsets.only(bottom: 24, right: 24),
|
margin: EdgeInsets.only(bottom: 24),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
color: Colors.grey.shade400,
|
color: Colors.grey.shade400,
|
||||||
|
@ -440,10 +442,10 @@ class ViewFreightBill extends StatelessWidget {
|
||||||
freightBill.freightbillCode ?? "";
|
freightBill.freightbillCode ?? "";
|
||||||
return DataRow(
|
return DataRow(
|
||||||
cells: [
|
cells: [
|
||||||
editableCell(
|
editableCell(index,
|
||||||
index, "${freightBill.plantCode}-${freightBill.plantDesc}"),
|
"${freightBill.plantCode}-${freightBill.plantDesc}"),
|
||||||
editableCell(
|
editableCell(index,
|
||||||
index, "${freightBill.materialCode}-${freightBill.materialDescription}"),
|
"${freightBill.materialCode}-${freightBill.materialDescription}"),
|
||||||
editableCell(
|
editableCell(
|
||||||
index,
|
index,
|
||||||
freightBill.freightbillCode ?? "-",
|
freightBill.freightbillCode ?? "-",
|
||||||
|
@ -535,16 +537,16 @@ class ViewFreightBill extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
CustomPagination(
|
||||||
|
currentPage: controller.currentPageViewFreight.value + 1,
|
||||||
|
totalPages: controller.totalPagesViewFreight.value,
|
||||||
|
onPageChanged: (page) {
|
||||||
|
controller.viewFreightView(page: page - 1);
|
||||||
|
},
|
||||||
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
CustomPagination(
|
|
||||||
currentPage: controller.currentPage.value,
|
|
||||||
totalPages: controller.totalPages.value,
|
|
||||||
onPageChanged: (int page) {
|
|
||||||
controller.onPageChanged(page);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -739,5 +741,3 @@ class ViewFreightBill extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:shayog/components/styles/app_images.dart';
|
import 'package:shayog/components/styles/app_images.dart';
|
||||||
|
@ -7,7 +5,6 @@ import 'package:shayog/feature/presentation/screens/transporter/model/sub_freigh
|
||||||
import 'package:shayog/services/network/get_requests.dart';
|
import 'package:shayog/services/network/get_requests.dart';
|
||||||
import '../../../../../../components/common/common_model.dart';
|
import '../../../../../../components/common/common_model.dart';
|
||||||
import '../../../../../../components/styles/app_strings.dart';
|
import '../../../../../../components/styles/app_strings.dart';
|
||||||
|
|
||||||
import '../../../../../../services/model/generate_freight_model.dart';
|
import '../../../../../../services/model/generate_freight_model.dart';
|
||||||
import '../../../../../../services/network/post_request.dart';
|
import '../../../../../../services/network/post_request.dart';
|
||||||
import '../model/freightbill_res_model.dart';
|
import '../model/freightbill_res_model.dart';
|
||||||
|
@ -45,7 +42,6 @@ class TransportController extends GetxController {
|
||||||
var selectTransactionTypePending = ''.obs;
|
var selectTransactionTypePending = ''.obs;
|
||||||
|
|
||||||
// for view FreightBill
|
// for view FreightBill
|
||||||
|
|
||||||
RxString selectPlantViewFreight = ''.obs;
|
RxString selectPlantViewFreight = ''.obs;
|
||||||
var selectProductViewFreight = ''.obs;
|
var selectProductViewFreight = ''.obs;
|
||||||
var selectLocationViewFreight = ''.obs;
|
var selectLocationViewFreight = ''.obs;
|
||||||
|
@ -165,28 +161,24 @@ class TransportController extends GetxController {
|
||||||
postData();
|
postData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
getInvoiceView() async {
|
getInvoiceView() async {
|
||||||
try {
|
try {
|
||||||
invoiceViewLoader.value = true;
|
invoiceViewLoader.value = true;
|
||||||
|
|
||||||
Map<String, String> requestBody = {
|
Map<String, String> requestBody = {
|
||||||
"invoice_id":"",
|
"invoice_id": "",
|
||||||
"freightBillNo":"",
|
"freightBillNo": "",
|
||||||
"invFromDate":"",
|
"invFromDate": "",
|
||||||
"invToDate":"",
|
"invToDate": "",
|
||||||
"freightFromDate":"",
|
"freightFromDate": "",
|
||||||
"freightToDate":""
|
"freightToDate": ""
|
||||||
};
|
};
|
||||||
|
|
||||||
var response = await PostRequests.getInvoice(requestBody);
|
var response = await PostRequests.getInvoice(requestBody);
|
||||||
if (response != null) {
|
if (response != null) {
|
||||||
List<GetInvoiceContent> flattenedContent =
|
List<GetInvoiceContent> flattenedContent =
|
||||||
response.content!.expand((list) => list).toList();
|
response.content.expand((list) => list).toList();
|
||||||
getInvoiceData.assignAll(flattenedContent);
|
getInvoiceData.assignAll(flattenedContent);
|
||||||
// print("response from${getInvoiceData[0].freightbillCode.runtimeType} view freight bill ${freightBillData[0].plantCode.runtimeType} and ${freightBillData[0].materialCode.runtimeType} and}");
|
|
||||||
totalPages.value = response.totalPages ?? 0;
|
|
||||||
totalElements.value = response.totalElements ?? 0;
|
|
||||||
print('res from invoice ${response.toString()}');
|
print('res from invoice ${response.toString()}');
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -226,7 +218,6 @@ class TransportController extends GetxController {
|
||||||
postData() async {
|
postData() async {
|
||||||
try {
|
try {
|
||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
|
|
||||||
Map<String, String> requestBody = {
|
Map<String, String> requestBody = {
|
||||||
"plant": "",
|
"plant": "",
|
||||||
"productNane": "",
|
"productNane": "",
|
||||||
|
@ -235,7 +226,6 @@ class TransportController extends GetxController {
|
||||||
"grnFromDate": "",
|
"grnFromDate": "",
|
||||||
"grnToDate": ""
|
"grnToDate": ""
|
||||||
};
|
};
|
||||||
|
|
||||||
var response = await PostRequests.addFreightBill(requestBody);
|
var response = await PostRequests.addFreightBill(requestBody);
|
||||||
if (response != null) {
|
if (response != null) {
|
||||||
List<Content> flattenedContent =
|
List<Content> flattenedContent =
|
||||||
|
@ -291,17 +281,6 @@ class TransportController extends GetxController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// void handleFilterSubmit() {
|
|
||||||
// validateFieldsGenerateFreight();
|
|
||||||
//
|
|
||||||
// if (showPlantError.value ||
|
|
||||||
// showProductError.value ||
|
|
||||||
// showTransactionError.value) {
|
|
||||||
// print('show errr');
|
|
||||||
// } else {
|
|
||||||
// postData();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
void handleFilterSubmitGenerateFreight() {
|
void handleFilterSubmitGenerateFreight() {
|
||||||
validateFieldsGenerateFreight();
|
validateFieldsGenerateFreight();
|
||||||
if (selectPlantFreight.value.isEmpty ||
|
if (selectPlantFreight.value.isEmpty ||
|
||||||
|
@ -387,8 +366,6 @@ class TransportController extends GetxController {
|
||||||
getSubFreightBillsView() async {
|
getSubFreightBillsView() async {
|
||||||
try {
|
try {
|
||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
print('Getting details for freight bill: ${freightBillCode.value}');
|
|
||||||
|
|
||||||
var response =
|
var response =
|
||||||
await GetRequests.subViewFreightDialog(freightBillCode.value);
|
await GetRequests.subViewFreightDialog(freightBillCode.value);
|
||||||
if (response != null) {
|
if (response != null) {
|
||||||
|
@ -462,12 +439,7 @@ class TransportController extends GetxController {
|
||||||
"status_id": grn.statusId
|
"status_id": grn.statusId
|
||||||
})
|
})
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
// Only send the selected data in the request body
|
|
||||||
var response = await PostRequests.freightBill(selectedGrns);
|
var response = await PostRequests.freightBill(selectedGrns);
|
||||||
|
|
||||||
print("Selected GRNs>>>$selectedGrns");
|
|
||||||
|
|
||||||
if (response != null) {
|
if (response != null) {
|
||||||
freightBillNo.value = response.freightBillNo ?? "";
|
freightBillNo.value = response.freightBillNo ?? "";
|
||||||
grnList.assignAll(response.grn ?? []);
|
grnList.assignAll(response.grn ?? []);
|
||||||
|
@ -480,16 +452,17 @@ class TransportController extends GetxController {
|
||||||
////////////////////////////////////////// PRIYA ///////////////////////////////////////////////
|
////////////////////////////////////////// PRIYA ///////////////////////////////////////////////
|
||||||
var freightBillData = <FreightBill>[].obs;
|
var freightBillData = <FreightBill>[].obs;
|
||||||
|
|
||||||
var totalElements = 0.obs;
|
var totalElementsViewFreight = 0.obs;
|
||||||
var pageSize = 2.obs;
|
var pageSize = 2.obs;
|
||||||
var sortField = "grn_date".obs;
|
var sortField = "grn_date".obs;
|
||||||
var sortDirection = "desc".obs;
|
var sortDirection = "desc".obs;
|
||||||
|
|
||||||
RxInt currentPage = 1.obs;
|
RxInt currentPageViewFreight = 1.obs;
|
||||||
RxInt totalPages = 3.obs;
|
RxInt totalPagesViewFreight = 3.obs;
|
||||||
final int limit = 10;
|
final int limit = 10;
|
||||||
|
|
||||||
viewFreightView() async {
|
|
||||||
|
viewFreightView({int page = 0}) async {
|
||||||
try {
|
try {
|
||||||
freightViewLoader.value = true;
|
freightViewLoader.value = true;
|
||||||
|
|
||||||
|
@ -503,40 +476,22 @@ class TransportController extends GetxController {
|
||||||
"grnToDate": "",
|
"grnToDate": "",
|
||||||
};
|
};
|
||||||
|
|
||||||
var response = await PostRequests.viewFreightBill(requestBody);
|
var response = await PostRequests.viewFreightBill(
|
||||||
|
page: page, size: 4, requestBody: requestBody);
|
||||||
|
|
||||||
if (response != null) {
|
if (response != null) {
|
||||||
List<FreightBill> flattenedContent =
|
List<FreightBill> flattenedContent =
|
||||||
response.content!.expand((list) => list).toList();
|
response.content!.expand((list) => list).toList();
|
||||||
freightBillData.assignAll(flattenedContent);
|
freightBillData.assignAll(flattenedContent);
|
||||||
print(
|
totalPagesViewFreight.value = response.totalPages ?? 0;
|
||||||
"response from${freightBillData[0].freightbillCode.runtimeType} view freight bill ${freightBillData[0].plantCode.runtimeType} and ${freightBillData[0].materialCode.runtimeType} and}");
|
totalElementsViewFreight.value = response.totalElements ?? 0;
|
||||||
totalPages.value = response.totalPages ?? 0;
|
currentPageViewFreight.value = page;
|
||||||
totalElements.value = response.totalElements ?? 0;
|
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
freightViewLoader.value = false;
|
freightViewLoader.value = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void nextPage() {
|
|
||||||
if (currentPage.value < totalPages.value) {
|
|
||||||
currentPage.value++;
|
|
||||||
viewFreightView(); // Fetch data for the next page
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void previousPage() {
|
|
||||||
if (currentPage.value > 1) {
|
|
||||||
currentPage.value--;
|
|
||||||
viewFreightView(); // Fetch data for the previous page
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void onPageChanged(int page) {
|
|
||||||
currentPage.value = page;
|
|
||||||
viewFreightView(); // Fetch data for the selected page
|
|
||||||
}
|
|
||||||
|
|
||||||
void changeSort(String field) {
|
void changeSort(String field) {
|
||||||
if (field == sortField.value) {
|
if (field == sortField.value) {
|
||||||
sortDirection.value = sortDirection.value == "asc" ? "desc" : "asc";
|
sortDirection.value = sortDirection.value == "asc" ? "desc" : "asc";
|
||||||
|
@ -544,7 +499,6 @@ class TransportController extends GetxController {
|
||||||
sortField.value = field;
|
sortField.value = field;
|
||||||
sortDirection.value = "desc";
|
sortDirection.value = "desc";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var grnPendingData = <GrnPending>[].obs;
|
var grnPendingData = <GrnPending>[].obs;
|
||||||
|
@ -577,9 +531,10 @@ class TransportController extends GetxController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void displayFilteredDataFromViewFreight() async {
|
void displayFilteredDataFromViewFreight({int page = 0, int size = 4}) async {
|
||||||
try {
|
try {
|
||||||
freightViewLoader.value = true;
|
freightViewLoader.value = true;
|
||||||
|
|
||||||
Map<String, String> requestBody = {
|
Map<String, String> requestBody = {
|
||||||
"plant": selectPlantViewFreight.value,
|
"plant": selectPlantViewFreight.value,
|
||||||
"productNane": selectProductViewFreight.value,
|
"productNane": selectProductViewFreight.value,
|
||||||
|
@ -590,66 +545,37 @@ class TransportController extends GetxController {
|
||||||
"grnToDate": "",
|
"grnToDate": "",
|
||||||
};
|
};
|
||||||
|
|
||||||
print("Filter request - Plant: ${selectPlantViewFreight.value}, "
|
print("🔎 Filter Request - Page: $page, Size: $size, Plant: ${selectPlantViewFreight.value}, "
|
||||||
"Product: ${selectProductViewFreight.value}, "
|
"Product: ${selectProductViewFreight.value}, Freight Bill: ${selectFreightBillValidate.value}");
|
||||||
"Freight Bill: ${selectFreightBillValidate.value}");
|
|
||||||
|
|
||||||
var response = await PostRequests.viewFreightBill(requestBody);
|
var response = await PostRequests.viewFreightBill(
|
||||||
|
page: page, size: size, requestBody: requestBody); // Pass pagination
|
||||||
|
|
||||||
if (response != null) {
|
if (response != null && response.content != null) {
|
||||||
List<FreightBill> flattenedContent =
|
List<FreightBill> flattenedContent =
|
||||||
response.content!.expand((list) => list).toList();
|
response.content!.expand((list) => list).toList();
|
||||||
|
|
||||||
print("Total records before filtering: ${flattenedContent.length}");
|
print("📌 Total records received: ${flattenedContent.length}");
|
||||||
|
|
||||||
// Log sample data for debugging if available
|
if (page == 0) {
|
||||||
if (flattenedContent.isNotEmpty) {
|
freightBillData.assignAll(flattenedContent); // First page: Replace data
|
||||||
print("Sample data - Plant: ${flattenedContent[0].plantCode}, "
|
} else {
|
||||||
"Material: ${flattenedContent[0].materialCode}, "
|
freightBillData.addAll(flattenedContent); // Next pages: Append data
|
||||||
"Freight Bill: ${flattenedContent[0].freightbillCode}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
List<FreightBill> filteredData = flattenedContent.where((item) {
|
// Update pagination details
|
||||||
// Plant filter
|
totalPagesViewFreight.value = response.totalPages ?? 0;
|
||||||
bool plantMatch = selectPlantViewFreight.value.isEmpty ||
|
totalElementsViewFreight.value = response.totalElements ?? 0;
|
||||||
item.plantCode.toString().toLowerCase() ==
|
currentPageViewFreight.value = page;
|
||||||
selectPlantViewFreight.value.toLowerCase();
|
|
||||||
|
|
||||||
// Product filter
|
print("✅ Freight bill data filtered & paginated successfully");
|
||||||
bool productMatch = selectProductViewFreight.value.isEmpty ||
|
|
||||||
item.materialCode.toString().toLowerCase() ==
|
|
||||||
selectProductViewFreight.value.toLowerCase();
|
|
||||||
|
|
||||||
// Freight bill filter
|
|
||||||
bool freightBillMatch = selectFreightBillValidate.value.isEmpty ||
|
|
||||||
item.freightbillCode.toString().toLowerCase() ==
|
|
||||||
selectFreightBillValidate.value.toLowerCase();
|
|
||||||
|
|
||||||
// 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 values
|
|
||||||
totalPages.value = response.totalPages ?? 0;
|
|
||||||
totalElements.value = response.totalElements ?? 0;
|
|
||||||
|
|
||||||
print("✅ Freight bill data filtered successfully");
|
|
||||||
} else {
|
} else {
|
||||||
print("❌ No response received from API");
|
print("❌ No response received from API");
|
||||||
freightBillData.clear();
|
if (page == 0) freightBillData.clear();
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("❌ Error in displayFilteredDataFromViewFreight: $e");
|
print("❌ Error in displayFilteredDataFromViewFreight: $e");
|
||||||
freightBillData.clear();
|
if (page == 0) freightBillData.clear();
|
||||||
} finally {
|
} finally {
|
||||||
freightViewLoader.value = false;
|
freightViewLoader.value = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,8 @@ import 'package:shayog/components/styles/textStyles.dart';
|
||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
import '../../../components/styles/app_colors.dart';
|
import '../../../components/styles/app_colors.dart';
|
||||||
|
|
||||||
class CustomPagination extends StatelessWidget {
|
class
|
||||||
|
CustomPagination extends StatelessWidget {
|
||||||
final int currentPage;
|
final int currentPage;
|
||||||
final int totalPages;
|
final int totalPages;
|
||||||
final Function(int) onPageChanged;
|
final Function(int) onPageChanged;
|
||||||
|
@ -18,7 +19,6 @@ class CustomPagination extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return Container(
|
||||||
|
|
||||||
padding: const EdgeInsets.symmetric(vertical: 2.0),
|
padding: const EdgeInsets.symmetric(vertical: 2.0),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: AppColors.clrF2,
|
color: AppColors.clrF2,
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
class ApiUrls {
|
class ApiUrls {
|
||||||
ApiUrls._();
|
ApiUrls._();
|
||||||
|
|
||||||
static const String baseUrl = "http://46.28.44.130:9092/";
|
static const String baseUrl = "http://46.28.44.130:9092/";
|
||||||
|
|
||||||
static const addFreightBill =
|
static const addFreightBill =
|
||||||
'bill/grndetails?page=0&size=20&sort=grn_date,desc';
|
'bill/grndetails?page=0&size=20&sort=grn_date,desc';
|
||||||
static const getFreightBills = 'bill/dropdown';
|
static const getFreightBills = 'bill/dropdown';
|
||||||
|
@ -15,7 +13,7 @@ class ApiUrls {
|
||||||
static const getAllUser =
|
static const getAllUser =
|
||||||
'http://46.28.44.130:9093/api/users/userdetails?page=';
|
'http://46.28.44.130:9093/api/users/userdetails?page=';
|
||||||
static const viewFreightBill =
|
static const viewFreightBill =
|
||||||
'http://46.28.44.130:9092/bill/freightbill?page=0&size=15&sort=last_updated_on,desc';
|
'http://46.28.44.130:9092/bill/freightbill?page=';
|
||||||
static const addUserType =
|
static const addUserType =
|
||||||
'http://46.28.44.130:9093/api/user-types/createUserType';
|
'http://46.28.44.130:9093/api/user-types/createUserType';
|
||||||
static const dropDownList =
|
static const dropDownList =
|
||||||
|
@ -38,40 +36,4 @@ class ApiUrls {
|
||||||
static const viewSubDetailsOfViewFreightBill = "http://46.28.44.130:9092/bill/grndetailsByFreightBill?freightBillCode=";
|
static const viewSubDetailsOfViewFreightBill = "http://46.28.44.130:9092/bill/grndetailsByFreightBill?freightBillCode=";
|
||||||
static const getInvoiceDetails = "http://46.28.44.130:9092/invoice/getInvoice";
|
static const getInvoiceDetails = "http://46.28.44.130:9092/invoice/getInvoice";
|
||||||
}
|
}
|
||||||
// class ApiUrls {
|
|
||||||
// ApiUrls._();
|
|
||||||
//
|
|
||||||
// static const String baseUrl = "http://localhost:9092/";
|
|
||||||
//
|
|
||||||
// static const addFreightBill =
|
|
||||||
// 'bill/grndetails?page=0&size=20&sort=grn_date,desc';
|
|
||||||
// static const getFreightBills = 'bill/dropdown';
|
|
||||||
// static const generateFreightBill =
|
|
||||||
// 'http://localhost:9092/bill/addFreightBill';
|
|
||||||
// static const createUser = 'http://localhost:9093/api/users/createUser';
|
|
||||||
// static const editUser =
|
|
||||||
// 'http://localhost:9093/api/users/update?userEmpTransCode=';
|
|
||||||
// static const getAllUser =
|
|
||||||
// 'http://localhost:9093/api/users/userdetails?page=';
|
|
||||||
// static const viewFreightBill =
|
|
||||||
// 'http://localhost:9092/bill/freightbill?page';
|
|
||||||
// static const addUserType =
|
|
||||||
// 'http://localhost:9093/api/user-types/createUserType';
|
|
||||||
// static const dropDownList =
|
|
||||||
// 'http://localhost:9093/api/user-roles/userrole_dropdown';
|
|
||||||
// static const plantMapping = 'http://localhost:9093/userplant/fetchPlants';
|
|
||||||
// static const checkStatus =
|
|
||||||
// 'http://localhost:9093/api/user-types/update-status/';
|
|
||||||
// static const getInternalUserDropdown =
|
|
||||||
// 'http://localhost:9093/api/user-roles/userrole_dropdown';
|
|
||||||
// static const fetchEmailsAndEmpCode =
|
|
||||||
// 'http://localhost:9093/api/user-roles/fetchRoles';
|
|
||||||
// static const selectAndAssignRole =
|
|
||||||
// "http://localhost:9093/api/user-roles/assignRoles";
|
|
||||||
// static const assignPlantRole =
|
|
||||||
// "http://localhost:9093/userplant/assignPlants";
|
|
||||||
// static const userTypeDetails =
|
|
||||||
// "http://localhost:9093/api/user-types/usertypedetails?page=0&size=15&sort=last_updated_on,desc";
|
|
||||||
// static const grnPendingDetails =
|
|
||||||
// "http://localhost:9092/bill/grndetailsPanding?page=0&size=20&sort=grn_date,desc";
|
|
||||||
// }
|
|
||||||
|
|
|
@ -20,6 +20,8 @@ class PostRequests {
|
||||||
PostRequests._();
|
PostRequests._();
|
||||||
|
|
||||||
static Future<GenerateFreightBills?> addFreightBill(
|
static Future<GenerateFreightBills?> addFreightBill(
|
||||||
|
|
||||||
|
|
||||||
Map<String, String> requestBody) async {
|
Map<String, String> requestBody) async {
|
||||||
var apiResponse =
|
var apiResponse =
|
||||||
await RemoteService.simplePost(requestBody, ApiUrls.addFreightBill);
|
await RemoteService.simplePost(requestBody, ApiUrls.addFreightBill);
|
||||||
|
@ -103,7 +105,7 @@ class PostRequests {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<ViewFreightBillResModel?> viewFreightBill(
|
static Future<ViewFreightBillResModel?> viewFreightBillF(
|
||||||
Map<String, String> requestBody,
|
Map<String, String> requestBody,
|
||||||
) async {
|
) async {
|
||||||
var apiResponse = await RemoteService.postUser(requestBody,
|
var apiResponse = await RemoteService.postUser(requestBody,
|
||||||
|
@ -115,6 +117,40 @@ class PostRequests {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
static Future<ViewFreightBillResModel?> viewFreightBill({
|
||||||
|
int page = 0,
|
||||||
|
int size = 15,
|
||||||
|
String sort = 'last_updated_on,desc',
|
||||||
|
Map<String, String>? requestBody,
|
||||||
|
}) async {
|
||||||
|
// Construct dynamic URL with query parameters
|
||||||
|
String url = 'http://46.28.44.130:9092/bill/freightbill'
|
||||||
|
'?page=$page&size=$size&sort=$sort';
|
||||||
|
|
||||||
|
try {
|
||||||
|
var apiResponse = await RemoteService.postUser(
|
||||||
|
requestBody ?? {}, // Use empty map if no request body
|
||||||
|
url
|
||||||
|
);
|
||||||
|
|
||||||
|
if (apiResponse == null) return null;
|
||||||
|
if (apiResponse.response == null || apiResponse.response!.isEmpty) {
|
||||||
|
print('Empty response received');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return viewFreightBillResModelFromJson(apiResponse.response!);
|
||||||
|
} catch (e) {
|
||||||
|
print('JSON Parsing Error: $e');
|
||||||
|
print('Problematic JSON: ${apiResponse.response}');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print('API Call Error: $e');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static Future<UserTypeResModel?> addUserType(
|
static Future<UserTypeResModel?> addUserType(
|
||||||
Map<String, String> requestBody) async {
|
Map<String, String> requestBody) async {
|
||||||
|
|
Loading…
Reference in New Issue