Push After Pull from dev_priya and resolve merge conflicts

feature_dev_ankit
Ankit Sharma 2025-02-07 01:53:29 +05:30
commit 2382a8eaa9
11 changed files with 485 additions and 450 deletions

View File

@ -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";

View File

@ -9,95 +9,124 @@ ViewFreightBillResModel viewFreightBillResModelFromJson(String str) => ViewFreig
String viewFreightBillResModelToJson(ViewFreightBillResModel data) => json.encode(data.toJson()); String viewFreightBillResModelToJson(ViewFreightBillResModel data) => json.encode(data.toJson());
class ViewFreightBillResModel { class ViewFreightBillResModel {
final List<List<FreightBill>>? content; List<List<FreightBill>>? content;
final Pageable? pageable; Pageable? pageable;
final bool? last; int? totalPages;
final int? totalElements; int? totalElements;
final int? totalPages; bool? last;
final int? size; int? size;
final int? number; int? number;
final Sort? sort; Sort? sort;
final bool? first; int? numberOfElements;
final int? numberOfElements; bool? first;
final bool? empty; bool? empty;
ViewFreightBillResModel({ ViewFreightBillResModel({
this.content, this.content,
this.pageable, this.pageable,
this.last,
this.totalElements,
this.totalPages, this.totalPages,
this.totalElements,
this.last,
this.size, this.size,
this.number, this.number,
this.sort, this.sort,
this.first,
this.numberOfElements, this.numberOfElements,
this.first,
this.empty, this.empty,
}); });
ViewFreightBillResModel copyWith({
List<List<FreightBill>>? content,
Pageable? pageable,
int? totalPages,
int? totalElements,
bool? last,
int? size,
int? number,
Sort? sort,
int? numberOfElements,
bool? first,
bool? empty,
}) =>
ViewFreightBillResModel(
content: content ?? this.content,
pageable: pageable ?? this.pageable,
totalPages: totalPages ?? this.totalPages,
totalElements: totalElements ?? this.totalElements,
last: last ?? this.last,
size: size ?? this.size,
number: number ?? this.number,
sort: sort ?? this.sort,
numberOfElements: numberOfElements ?? this.numberOfElements,
first: first ?? this.first,
empty: empty ?? this.empty,
);
factory ViewFreightBillResModel.fromJson(Map<String, dynamic> json) => ViewFreightBillResModel( factory ViewFreightBillResModel.fromJson(Map<String, dynamic> json) => ViewFreightBillResModel(
content: json["content"] == null ? [] : List<List<FreightBill>>.from(json["content"]!.map((x) => List<FreightBill>.from(x.map((x) => FreightBill.fromJson(x))))), content: json["content"] == null ? [] : List<List<FreightBill>>.from(json["content"]!.map((x) => List<FreightBill>.from(x.map((x) => FreightBill.fromJson(x))))),
pageable: json["pageable"] == null ? null : Pageable.fromJson(json["pageable"]), pageable: json["pageable"] == null ? null : Pageable.fromJson(json["pageable"]),
last: json["last"],
totalElements: json["totalElements"],
totalPages: json["totalPages"], totalPages: json["totalPages"],
totalElements: json["totalElements"],
last: json["last"],
size: json["size"], size: json["size"],
number: json["number"], number: json["number"],
sort: json["sort"] == null ? null : Sort.fromJson(json["sort"]), sort: json["sort"] == null ? null : Sort.fromJson(json["sort"]),
first: json["first"],
numberOfElements: json["numberOfElements"], numberOfElements: json["numberOfElements"],
first: json["first"],
empty: json["empty"], empty: json["empty"],
); );
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
"content": content == null ? [] : List<dynamic>.from(content!.map((x) => List<dynamic>.from(x.map((x) => x.toJson())))), "content": content == null ? [] : List<dynamic>.from(content!.map((x) => List<dynamic>.from(x.map((x) => x.toJson())))),
"pageable": pageable?.toJson(), "pageable": pageable?.toJson(),
"last": last,
"totalElements": totalElements,
"totalPages": totalPages, "totalPages": totalPages,
"totalElements": totalElements,
"last": last,
"size": size, "size": size,
"number": number, "number": number,
"sort": sort?.toJson(), "sort": sort?.toJson(),
"first": first,
"numberOfElements": numberOfElements, "numberOfElements": numberOfElements,
"first": first,
"empty": empty, "empty": empty,
}; };
} }
class FreightBill { class FreightBill {
final int? freightbillId; int? freightbillId;
final String? freightbillCode; String? freightbillCode;
final String? status; String? status;
final DateTime? statusDate; DateTime? statusDate;
final String? plantCode; String? plantCode;
final String? materialCode; String? plantDesc;
final String? fromLocation; String? materialCode;
final int? billingQty; String? materialDescription;
final dynamic uom; String? fromLocation;
final double? freightAmount; dynamic billingNetQty;
final double? cgst; dynamic uom;
final double? sgst; double? shipmentGrossCost;
final int? igst; double? cgst;
final double? totalGst; double? sgst;
final double? shipmentNetAmount; int? igst;
final DateTime? createdOn; double? totalGst;
final dynamic trasnporterInvoiceNo; double? shipmentNetCost;
final dynamic trasnporterInvoiceNoDate; DateTime? createdOn;
final dynamic utr1No; dynamic transporterInvoiceNo;
final dynamic utr2No; dynamic transporterInvoiceNoDate;
final dynamic utr3No; dynamic utr1No;
final dynamic utr4No; dynamic utr2No;
final dynamic utr5No; dynamic utr3No;
final dynamic utr1PaymentAmount; dynamic utr4No;
final dynamic utr2PaymentAmount; dynamic utr5No;
final dynamic utr3PaymentAmount; dynamic utr1PaymentAmount;
final dynamic utr4PaymentAmount; dynamic utr2PaymentAmount;
final dynamic utr5PaymentAmount; dynamic utr3PaymentAmount;
final dynamic utr1Date; dynamic utr4PaymentAmount;
final dynamic utr2Date; dynamic utr5PaymentAmount;
final dynamic utr3Date; dynamic utr1Date;
final dynamic utr4Date; dynamic utr2Date;
final dynamic utr5Date; dynamic utr3Date;
dynamic utr4Date;
dynamic utr5Date;
FreightBill({ FreightBill({
this.freightbillId, this.freightbillId,
@ -105,19 +134,21 @@ class FreightBill {
this.status, this.status,
this.statusDate, this.statusDate,
this.plantCode, this.plantCode,
this.plantDesc,
this.materialCode, this.materialCode,
this.materialDescription,
this.fromLocation, this.fromLocation,
this.billingQty, this.billingNetQty,
this.uom, this.uom,
this.freightAmount, this.shipmentGrossCost,
this.cgst, this.cgst,
this.sgst, this.sgst,
this.igst, this.igst,
this.totalGst, this.totalGst,
this.shipmentNetAmount, this.shipmentNetCost,
this.createdOn, this.createdOn,
this.trasnporterInvoiceNo, this.transporterInvoiceNo,
this.trasnporterInvoiceNoDate, this.transporterInvoiceNoDate,
this.utr1No, this.utr1No,
this.utr2No, this.utr2No,
this.utr3No, this.utr3No,
@ -135,25 +166,102 @@ class FreightBill {
this.utr5Date, this.utr5Date,
}); });
FreightBill copyWith({
int? freightbillId,
String? freightbillCode,
String? status,
DateTime? statusDate,
String? plantCode,
String? plantDesc,
String? materialCode,
String? materialDescription,
String? fromLocation,
dynamic billingNetQty,
dynamic uom,
double? shipmentGrossCost,
double? cgst,
double? sgst,
int? igst,
double? totalGst,
double? shipmentNetCost,
DateTime? createdOn,
dynamic transporterInvoiceNo,
dynamic transporterInvoiceNoDate,
dynamic utr1No,
dynamic utr2No,
dynamic utr3No,
dynamic utr4No,
dynamic utr5No,
dynamic utr1PaymentAmount,
dynamic utr2PaymentAmount,
dynamic utr3PaymentAmount,
dynamic utr4PaymentAmount,
dynamic utr5PaymentAmount,
dynamic utr1Date,
dynamic utr2Date,
dynamic utr3Date,
dynamic utr4Date,
dynamic utr5Date,
}) =>
FreightBill(
freightbillId: freightbillId ?? this.freightbillId,
freightbillCode: freightbillCode ?? this.freightbillCode,
status: status ?? this.status,
statusDate: statusDate ?? this.statusDate,
plantCode: plantCode ?? this.plantCode,
plantDesc: plantDesc ?? this.plantDesc,
materialCode: materialCode ?? this.materialCode,
materialDescription: materialDescription ?? this.materialDescription,
fromLocation: fromLocation ?? this.fromLocation,
billingNetQty: billingNetQty ?? this.billingNetQty,
uom: uom ?? this.uom,
shipmentGrossCost: shipmentGrossCost ?? this.shipmentGrossCost,
cgst: cgst ?? this.cgst,
sgst: sgst ?? this.sgst,
igst: igst ?? this.igst,
totalGst: totalGst ?? this.totalGst,
shipmentNetCost: shipmentNetCost ?? this.shipmentNetCost,
createdOn: createdOn ?? this.createdOn,
transporterInvoiceNo: transporterInvoiceNo ?? this.transporterInvoiceNo,
transporterInvoiceNoDate: transporterInvoiceNoDate ?? this.transporterInvoiceNoDate,
utr1No: utr1No ?? this.utr1No,
utr2No: utr2No ?? this.utr2No,
utr3No: utr3No ?? this.utr3No,
utr4No: utr4No ?? this.utr4No,
utr5No: utr5No ?? this.utr5No,
utr1PaymentAmount: utr1PaymentAmount ?? this.utr1PaymentAmount,
utr2PaymentAmount: utr2PaymentAmount ?? this.utr2PaymentAmount,
utr3PaymentAmount: utr3PaymentAmount ?? this.utr3PaymentAmount,
utr4PaymentAmount: utr4PaymentAmount ?? this.utr4PaymentAmount,
utr5PaymentAmount: utr5PaymentAmount ?? this.utr5PaymentAmount,
utr1Date: utr1Date ?? this.utr1Date,
utr2Date: utr2Date ?? this.utr2Date,
utr3Date: utr3Date ?? this.utr3Date,
utr4Date: utr4Date ?? this.utr4Date,
utr5Date: utr5Date ?? this.utr5Date,
);
factory FreightBill.fromJson(Map<String, dynamic> json) => FreightBill( factory FreightBill.fromJson(Map<String, dynamic> json) => FreightBill(
freightbillId: json["freightbill_id"], freightbillId: json["freightbill_id"],
freightbillCode: json["freightbill_code"], freightbillCode: json["freightbill_code"],
status: json["status"], status: json["status"],
statusDate: json["status_date"] == null ? null : DateTime.parse(json["status_date"]), statusDate: json["status_date"] == null ? null : DateTime.parse(json["status_date"]),
plantCode: json["plant_code"], plantCode: json["plant_code"],
plantDesc: json["plant_desc"],
materialCode: json["material_code"], materialCode: json["material_code"],
materialDescription: json["material_description"],
fromLocation: json["from_location"], fromLocation: json["from_location"],
billingQty: json["billing_qty"], billingNetQty: json["billing_net_qty"],
uom: json["uom"], uom: json["uom"],
freightAmount: json["freight_amount"]?.toDouble(), shipmentGrossCost: json["shipment_gross_cost"]?.toDouble(),
cgst: json["cgst"]?.toDouble(), cgst: json["cgst"]?.toDouble(),
sgst: json["sgst"]?.toDouble(), sgst: json["sgst"]?.toDouble(),
igst: json["igst"], igst: json["igst"],
totalGst: json["total_gst"]?.toDouble(), totalGst: json["total_gst"]?.toDouble(),
shipmentNetAmount: json["shipment_net_amount"]?.toDouble(), shipmentNetCost: json["shipment_net_cost"]?.toDouble(),
createdOn: json["created_on"] == null ? null : DateTime.parse(json["created_on"]), createdOn: json["created_on"] == null ? null : DateTime.parse(json["created_on"]),
trasnporterInvoiceNo: json["trasnporter_invoice_no"], transporterInvoiceNo: json["transporter_invoice_no"],
trasnporterInvoiceNoDate: json["trasnporter_invoice_no_date"], transporterInvoiceNoDate: json["transporter_invoice_no_date"],
utr1No: json["utr1_no"], utr1No: json["utr1_no"],
utr2No: json["utr2_no"], utr2No: json["utr2_no"],
utr3No: json["utr3_no"], utr3No: json["utr3_no"],
@ -177,19 +285,21 @@ class FreightBill {
"status": status, "status": status,
"status_date": "${statusDate!.year.toString().padLeft(4, '0')}-${statusDate!.month.toString().padLeft(2, '0')}-${statusDate!.day.toString().padLeft(2, '0')}", "status_date": "${statusDate!.year.toString().padLeft(4, '0')}-${statusDate!.month.toString().padLeft(2, '0')}-${statusDate!.day.toString().padLeft(2, '0')}",
"plant_code": plantCode, "plant_code": plantCode,
"plant_desc": plantDesc,
"material_code": materialCode, "material_code": materialCode,
"material_description": materialDescription,
"from_location": fromLocation, "from_location": fromLocation,
"billing_qty": billingQty, "billing_net_qty": billingNetQty,
"uom": uom, "uom": uom,
"freight_amount": freightAmount, "shipment_gross_cost": shipmentGrossCost,
"cgst": cgst, "cgst": cgst,
"sgst": sgst, "sgst": sgst,
"igst": igst, "igst": igst,
"total_gst": totalGst, "total_gst": totalGst,
"shipment_net_amount": shipmentNetAmount, "shipment_net_cost": shipmentNetCost,
"created_on": createdOn?.toIso8601String(), "created_on": createdOn?.toIso8601String(),
"trasnporter_invoice_no": trasnporterInvoiceNo, "transporter_invoice_no": transporterInvoiceNo,
"trasnporter_invoice_no_date": trasnporterInvoiceNoDate, "transporter_invoice_no_date": transporterInvoiceNoDate,
"utr1_no": utr1No, "utr1_no": utr1No,
"utr2_no": utr2No, "utr2_no": utr2No,
"utr3_no": utr3No, "utr3_no": utr3No,
@ -209,61 +319,89 @@ class FreightBill {
} }
class Pageable { class Pageable {
final Sort? sort; Sort? sort;
final int? offset; int? pageNumber;
final int? pageSize; int? pageSize;
final int? pageNumber; int? offset;
final bool? unpaged; bool? paged;
final bool? paged; bool? unpaged;
Pageable({ Pageable({
this.sort, this.sort,
this.offset,
this.pageSize,
this.pageNumber, this.pageNumber,
this.unpaged, this.pageSize,
this.offset,
this.paged, this.paged,
this.unpaged,
}); });
Pageable copyWith({
Sort? sort,
int? pageNumber,
int? pageSize,
int? offset,
bool? paged,
bool? unpaged,
}) =>
Pageable(
sort: sort ?? this.sort,
pageNumber: pageNumber ?? this.pageNumber,
pageSize: pageSize ?? this.pageSize,
offset: offset ?? this.offset,
paged: paged ?? this.paged,
unpaged: unpaged ?? this.unpaged,
);
factory Pageable.fromJson(Map<String, dynamic> json) => Pageable( factory Pageable.fromJson(Map<String, dynamic> json) => Pageable(
sort: json["sort"] == null ? null : Sort.fromJson(json["sort"]), sort: json["sort"] == null ? null : Sort.fromJson(json["sort"]),
offset: json["offset"],
pageSize: json["pageSize"],
pageNumber: json["pageNumber"], pageNumber: json["pageNumber"],
unpaged: json["unpaged"], pageSize: json["pageSize"],
offset: json["offset"],
paged: json["paged"], paged: json["paged"],
unpaged: json["unpaged"],
); );
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
"sort": sort?.toJson(), "sort": sort?.toJson(),
"offset": offset,
"pageSize": pageSize,
"pageNumber": pageNumber, "pageNumber": pageNumber,
"unpaged": unpaged, "pageSize": pageSize,
"offset": offset,
"paged": paged, "paged": paged,
"unpaged": unpaged,
}; };
} }
class Sort { class Sort {
final bool? empty; bool? sorted;
final bool? sorted; bool? empty;
final bool? unsorted; bool? unsorted;
Sort({ Sort({
this.empty,
this.sorted, this.sorted,
this.empty,
this.unsorted, this.unsorted,
}); });
Sort copyWith({
bool? sorted,
bool? empty,
bool? unsorted,
}) =>
Sort(
sorted: sorted ?? this.sorted,
empty: empty ?? this.empty,
unsorted: unsorted ?? this.unsorted,
);
factory Sort.fromJson(Map<String, dynamic> json) => Sort( factory Sort.fromJson(Map<String, dynamic> json) => Sort(
empty: json["empty"],
sorted: json["sorted"], sorted: json["sorted"],
empty: json["empty"],
unsorted: json["unsorted"], unsorted: json["unsorted"],
); );
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
"empty": empty,
"sorted": sorted, "sorted": sorted,
"empty": empty,
"unsorted": unsorted, "unsorted": unsorted,
}; };
} }

View File

@ -12,6 +12,7 @@ import '../../../../../../../components/common/common_btn.dart';
import '../../../../../../../components/common/custom_drop_down.dart'; import '../../../../../../../components/common/custom_drop_down.dart';
import '../../../../../../../components/common/data_cell.dart'; import '../../../../../../../components/common/data_cell.dart';
import '../../../../../../../components/styles/app_strings.dart'; import '../../../../../../../components/styles/app_strings.dart';
import '../../../../widgets/custom_pagination.dart';
import '../../view_model/transport_controller.dart'; import '../../view_model/transport_controller.dart';
import '../../widgets/common_card.dart'; import '../../widgets/common_card.dart';
import '../../widgets/freightbill_dialog.dart'; import '../../widgets/freightbill_dialog.dart';
@ -298,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();
// }
// },
// ),
], ],
), ),
), ),
@ -348,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
@ -368,6 +344,8 @@ class GenerateFrightBill extends StatelessWidget {
); );
} }
return Column( return Column(
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.end,
children: [ children: [
Container( Container(
padding: EdgeInsets.symmetric(horizontal: 10), padding: EdgeInsets.symmetric(horizontal: 10),
@ -416,9 +394,10 @@ class GenerateFrightBill extends StatelessWidget {
), ),
Container( Container(
margin: EdgeInsets.only(bottom: 16, top: 16), margin: EdgeInsets.only(bottom: 16, top: 16),
height: controller.isFilterVisibleGenerateFreight.value == true height:
? MediaQuery.of(context).size.height * 0.3 controller.isFilterVisibleGenerateFreight.value == true
: MediaQuery.of(context).size.height * 0.64, ? MediaQuery.of(context).size.height * 0.3
: MediaQuery.of(context).size.height * 0.64,
child: RawScrollbar( child: RawScrollbar(
thumbColor: AppColors.clrD9, thumbColor: AppColors.clrD9,
radius: Radius.circular(2), radius: Radius.circular(2),
@ -439,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,
@ -465,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,
), ),
), ),
), ),
@ -498,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: [
@ -520,16 +496,19 @@ class GenerateFrightBill extends StatelessWidget {
), ),
// editableCell(index, "0${index + 1}"), // editableCell(index, "0${index + 1}"),
editableCell(index, stoppage.grnNo ?? ""), editableCell(index, stoppage.grnNo ?? ""),
editableCell(index, stoppage.plantCode ?? ""), editableCell(
index, stoppage.plantCode ?? ""),
editableCell( editableCell(
index, stoppage.materialCode ?? ""), index, stoppage.materialCode ?? ""),
editableCell( editableCell(
index, index,
DateFormat('yyyy-MM-dd').format( DateFormat('yyyy-MM-dd').format(
stoppage.grnDate ?? DateTime.now())), stoppage.grnDate ??
DateTime.now())),
editableCell( editableCell(
index, stoppage.fromLocation ?? ""), index, stoppage.fromLocation ?? ""),
editableCell(index, stoppage.vehicleNo ?? ""), editableCell(
index, stoppage.vehicleNo ?? ""),
editableCell(index, stoppage.lrNo ?? ""), editableCell(index, stoppage.lrNo ?? ""),
editableCell( editableCell(
index, index,
@ -537,15 +516,17 @@ class GenerateFrightBill extends StatelessWidget {
stoppage.lrDate ?? DateTime.now())), stoppage.lrDate ?? DateTime.now())),
editableCell(index, editableCell(index,
stoppage.dispQty?.toString() ?? ""), stoppage.dispQty?.toString() ?? ""),
editableCell( editableCell(index,
index, stoppage.netQty?.toString() ?? ""), stoppage.netQty?.toString() ?? ""),
editableCell(index, editableCell(index,
stoppage.billingQty?.toString() ?? ""), stoppage.billingQty?.toString() ?? ""),
editableCell(index, "-"), editableCell(index, "-"),
editableCell(index, editableCell(index,
stoppage.freightRate?.toString() ?? ""), stoppage.freightRate?.toString() ?? ""),
editableCell(index, editableCell(
stoppage.shipmentCost?.toString() ?? ""), index,
stoppage.shipmentCost?.toString() ??
""),
], ],
); );
}), }),
@ -556,6 +537,13 @@ class GenerateFrightBill extends StatelessWidget {
), ),
), ),
), ),
CustomPagination(
currentPage: controller.currentPageViewFreight.value + 1,
totalPages: controller.totalPagesViewFreight.value,
onPageChanged: (page) {
controller.viewFreightView(page: page - 1);
},
),
], ],
); );
}), }),

View File

@ -3,6 +3,7 @@ import 'package:get/get.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:shayog/components/styles/textStyles.dart'; import 'package:shayog/components/styles/textStyles.dart';
import 'package:shayog/feature/presentation/screens/transporter/view_model/transport_controller.dart'; import 'package:shayog/feature/presentation/screens/transporter/view_model/transport_controller.dart';
import 'package:shayog/feature/presentation/widgets/custom_pagination.dart';
import 'package:sizer/sizer.dart'; import 'package:sizer/sizer.dart';
import 'package:vph_web_date_picker/vph_web_date_picker.dart'; import 'package:vph_web_date_picker/vph_web_date_picker.dart';
import '../../../../../../../components/common/data_cell.dart'; import '../../../../../../../components/common/data_cell.dart';
@ -519,9 +520,17 @@ class PendingGeneration extends StatelessWidget {
), ),
), ),
), ),
], ],
); );
}), }),
// CustomPagination(
// currentPage: controller.currentPage.value,
// totalPages: controller.totalPages.value,
// onPageChanged: (int page) {
// // controller.onPageChanged(page);
// },
// ),
], ],
); );
} }

View File

@ -1,9 +1,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:shayog/components/common/common_btn.dart'; import 'package:shayog/components/common/common_btn.dart';
import 'package:shayog/components/styles/textStyles.dart'; import 'package:shayog/feature/presentation/widgets/custom_pagination.dart';
import 'package:shayog/feature/presentation/screens/transporter/model/sub_freight_view_dialog_model.dart';
import 'package:shayog/feature/presentation/screens/transporter/model/view_freight_bill_res_model.dart';
import 'package:sizer/sizer.dart'; import 'package:sizer/sizer.dart';
import 'package:vph_web_date_picker/vph_web_date_picker.dart'; import 'package:vph_web_date_picker/vph_web_date_picker.dart';
import '../../../../../../../components/common/data_cell.dart'; import '../../../../../../../components/common/data_cell.dart';
@ -11,11 +9,8 @@ import '../../../../../../../components/styles/app_colors.dart';
import '../../../../../../../components/styles/app_strings.dart'; import '../../../../../../../components/styles/app_strings.dart';
import '../../../../../../components/common/common_button.dart'; import '../../../../../../components/common/common_button.dart';
import '../../../../../../components/common/custom_drop_down.dart'; import '../../../../../../components/common/custom_drop_down.dart';
import '../../../../widgets/custom_pagination.dart';
import '../../../../widgets/text_view.dart'; import '../../../../widgets/text_view.dart';
import '../../view_model/transport_controller.dart'; import '../../view_model/transport_controller.dart';
import '../../widgets/common_card.dart';
import '../../widgets/freightbill_dialog.dart';
class ViewFreightBill extends StatelessWidget { class ViewFreightBill extends StatelessWidget {
ViewFreightBill({super.key}); ViewFreightBill({super.key});
@ -27,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,
@ -57,8 +54,6 @@ class ViewFreightBill extends StatelessWidget {
selected.plantCode ?? ""; selected.plantCode ?? "";
controller.showPlantErrorViewFreight.value = controller.showPlantErrorViewFreight.value =
false; false;
print(
"selectPlant${controller.selectPlant.value}");
} }
}, },
hintText: "Select Plant", hintText: "Select Plant",
@ -151,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(
@ -294,19 +289,6 @@ class ViewFreightBill extends StatelessWidget {
width: 100, width: 100,
text: AppStrings.submit, text: AppStrings.submit,
clickAction: () { clickAction: () {
// if (controller.showPlantErrorFreight
// .value ||
// controller.showProductErrorFreight
// .value ||
// controller.showTransactionErrorFreight
// .value
// ) {
// print(
// 'controller.showProductError.value ${controller
// .showProductError.value}');
// } else {
// controller.postData();
// }
controller controller
.handleFilterSubmitViewFreightBill(); .handleFilterSubmitViewFreightBill();
}, },
@ -323,11 +305,10 @@ class ViewFreightBill extends StatelessWidget {
), ),
) )
: SizedBox.shrink()), : SizedBox.shrink()),
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(
@ -339,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)));
} }
@ -347,10 +328,9 @@ class ViewFreightBill extends StatelessWidget {
if (controller.freightBillData.isEmpty || if (controller.freightBillData.isEmpty ||
controller.freightBillData == []) { controller.freightBillData == []) {
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(
@ -366,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,
@ -388,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,
@ -460,14 +440,12 @@ class ViewFreightBill extends StatelessWidget {
controller.freightBillCode.value = controller.freightBillCode.value =
freightBill.freightbillCode ?? ""; freightBill.freightbillCode ?? "";
print(
'freightBill.trasnporterInvoiceNo ${freightBill.trasnporterInvoiceNo}');
return DataRow( return DataRow(
cells: [ cells: [
editableCell( editableCell(index,
index, "${freightBill.plantCode}"), "${freightBill.plantCode}-${freightBill.plantDesc}"),
editableCell( editableCell(index,
index, "${freightBill.materialCode}"), "${freightBill.materialCode}-${freightBill.materialDescription}"),
editableCell( editableCell(
index, index,
freightBill.freightbillCode ?? "-", freightBill.freightbillCode ?? "-",
@ -484,15 +462,15 @@ class ViewFreightBill extends StatelessWidget {
editableCell( editableCell(
index, "${freightBill.createdOn ?? "-"}"), index, "${freightBill.createdOn ?? "-"}"),
editableCell(index, editableCell(index,
"${freightBill.trasnporterInvoiceNo ?? "-"}"), "${freightBill.transporterInvoiceNo ?? "-"}"),
editableCell(index, editableCell(index,
"${freightBill.trasnporterInvoiceNoDate ?? "-"}"), "${freightBill.transporterInvoiceNoDate ?? "-"}"),
editableCell(index, editableCell(index,
"${freightBill.billingQty ?? "-"}"), "${freightBill.billingNetQty ?? "-"}"),
editableCell( editableCell(
index, "${freightBill.uom ?? "-"}"), index, "${freightBill.uom ?? "-"}"),
editableCell(index, editableCell(index,
"${freightBill.freightAmount ?? "-"}"), "${freightBill.shipmentGrossCost ?? "-"}"),
editableCell( editableCell(
index, "${freightBill.cgst ?? "-"}"), index, "${freightBill.cgst ?? "-"}"),
editableCell( editableCell(
@ -504,21 +482,21 @@ class ViewFreightBill extends StatelessWidget {
editableCell( editableCell(
index, "${freightBill.totalGst ?? "-"}"), index, "${freightBill.totalGst ?? "-"}"),
editableCell(index, editableCell(index,
"${freightBill.freightAmount ?? "-"}"), "${freightBill.shipmentNetCost ?? "-"}"),
editableCell(index, editableCell(index,
"${freightBill.trasnporterInvoiceNoDate ?? "-"}"), "${freightBill.transporterInvoiceNoDate ?? "-"}"),
editableCell( editableCell(
index, "${freightBill.status ?? "-"}"), index, freightBill.status ?? "-"),
editableCell( editableCell(
index, "${freightBill.totalGst ?? "-"}"), index, "${freightBill.totalGst ?? "-"}"),
editableCell(index, editableCell(index,
"${freightBill.trasnporterInvoiceNoDate ?? "-"}"), "${freightBill.transporterInvoiceNoDate ?? "-"}"),
editableCell( editableCell(
index, "${freightBill.utr5No ?? "-"}"), index, "${freightBill.utr5No ?? "-"}"),
editableCell( editableCell(
index, "${freightBill.utr1Date ?? "-"}"), index, "${freightBill.utr1Date ?? "-"}"),
editableCell(index, editableCell(index,
"${freightBill.freightAmount ?? "-"}"), "${freightBill.shipmentNetCost ?? "-"}"),
editableCell( editableCell(
index, "${freightBill.utr1No ?? "-"}"), index, "${freightBill.utr1No ?? "-"}"),
editableCell( editableCell(
@ -558,24 +536,17 @@ class ViewFreightBill extends StatelessWidget {
), ),
), ),
), ),
// CustomPagination( ),
// currentPage: controller.currentPage.value, CustomPagination(
// totalPages: controller.totalPages.value, currentPage: controller.currentPageViewFreight.value + 1,
// onPageChanged: (int page) { totalPages: controller.totalPagesViewFreight.value,
// controller.onPageChanged(page); onPageChanged: (page) {
// }, controller.viewFreightView(page: page - 1);
// ), },
), ),
], ],
); );
}), }),
CustomPagination(
currentPage: controller.currentPage.value,
totalPages: controller.totalPages.value,
onPageChanged: (int page) {
controller.onPageChanged(page);
},
),
], ],
); );
} }
@ -612,8 +583,7 @@ class ViewFreightBill extends StatelessWidget {
), ),
), ),
Expanded( Expanded(
child: contr.grnListDialog == null || child: contr.grnListDialog.isEmpty
contr.grnListDialog.isEmpty
? Center(child: Text('No data available.')) ? Center(child: Text('No data available.'))
: Column( : Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
@ -706,12 +676,20 @@ class ViewFreightBill extends StatelessWidget {
), ),
editableCell(index, editableCell(index,
"${freightBill.grnDate ?? "-"}"), "${freightBill.grnDate ?? "-"}"),
editableCell(index, editableCell(
"${freightBill.fromLocation ?? "-"}"), index,
editableCell(index, freightBill
"${freightBill.vehicleNo ?? "-"}"), .fromLocation ??
editableCell(index, "-"),
"${freightBill.transporterCode ?? "-"}"), editableCell(
index,
freightBill.vehicleNo ??
"-"),
editableCell(
index,
freightBill
.transporterCode ??
"-"),
editableCell(index, editableCell(index,
"${freightBill.lrDate ?? "-"}"), "${freightBill.lrDate ?? "-"}"),
editableCell(index, editableCell(index,

View File

@ -22,6 +22,7 @@ import 'sub_views/view_freight_bill.dart';
import 'package:file_picker/file_picker.dart'; import 'package:file_picker/file_picker.dart';
import 'package:path_provider/path_provider.dart'; import 'package:path_provider/path_provider.dart';
class TransportView extends StatefulWidget { class TransportView extends StatefulWidget {
const TransportView({super.key}); const TransportView({super.key});
@ -57,7 +58,7 @@ class _TransportViewState extends State<TransportView> {
() => InkWell( () => InkWell(
onTap: () { onTap: () {
ctrl.selectedIndex.value = index; ctrl.selectedIndex.value = index;
ctrl.selectedUser.value =0; ctrl.selectedUser.value = 0;
}, },
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
@ -164,97 +165,99 @@ class _TransportViewState extends State<TransportView> {
dataColumn("Add Signature"), dataColumn("Add Signature"),
], ],
rows: List<DataRow>.generate(ctrl.getInvoiceData.length, rows: List<DataRow>.generate(ctrl.getInvoiceData.length,
(index) { (index) {
final getInvoice = ctrl.getInvoiceData[index]; final getInvoice = ctrl.getInvoiceData[index];
return DataRow( return DataRow(
cells: [ cells: [
editableCell(index, "${getInvoice.invoiceId}"), editableCell(index, "${getInvoice.invoiceId}"),
editableCell(index, getInvoice.freightbillCode), editableCell(index, getInvoice.freightbillCode),
editableCell( editableCell(
index, index,
DateFormat("dd MMMM yyyy").format( DateFormat("dd MMMM yyyy").format(
DateTime.parse('${getInvoice.createdOn}'))), DateTime.parse('${getInvoice.createdOn}'))),
editableCell( editableCell(
index, "${getInvoice.sapReferenceno ?? "-"}"), index, "${getInvoice.sapReferenceno ?? "-"}"),
editableCell( editableCell(
index, index,
DateFormat("d MMMM yyyy").format(DateTime.parse( DateFormat("d MMMM yyyy").format(DateTime.parse(
'${getInvoice.shipmentCostDate}'))), '${getInvoice.shipmentCostDate}'))),
editableCell( editableCell(
index, "${getInvoice.shipmentCost ?? "-"}"), index, "${getInvoice.shipmentCost ?? "-"}"),
editableCell(index,"${getInvoice.statusId?? "-"}"), editableCell(index, "${getInvoice.statusId ?? "-"}"),
editableCell(index, getInvoice.materialCode?? "-"), editableCell(index, getInvoice.materialCode ?? "-"),
editableCell(index, getInvoice.materialDescription, isLink: true), editableCell(index, getInvoice.materialDescription,
editableCell(index,getInvoice. status?? "-"), isLink: true),
editableCell(index, getInvoice.plantCode?? "-", isLink: true), editableCell(index, getInvoice.status ?? "-"),
DataCell( editableCell(index, getInvoice.plantCode ?? "-",
Row( isLink: true),
mainAxisSize: MainAxisSize.min, DataCell(
children: [ Row(
Container( mainAxisSize: MainAxisSize.min,
padding: EdgeInsets.all(4), children: [
decoration: BoxDecoration( Container(
border: Border.all(color: Colors.blue), padding: EdgeInsets.all(4),
borderRadius: BorderRadius.circular(4), decoration: BoxDecoration(
), border: Border.all(color: Colors.blue),
child: InkWell( borderRadius: BorderRadius.circular(4),
onTap: () { }, ),
child: Row( child: InkWell(
mainAxisSize: MainAxisSize.min, onTap: () {},
children: [ child: Row(
Icon(Icons.download, mainAxisSize: MainAxisSize.min,
size: 16, color: Colors.blue), children: [
SizedBox(width: 4), Icon(Icons.download,
Text('Download', size: 16, color: Colors.blue),
style: TextStyle( SizedBox(width: 4),
color: Colors.blue, Text('Download',
fontSize: 12)), style: TextStyle(
], color: Colors.blue,
), fontSize: 12)),
), ],
), ),
SizedBox(width: 8), ),
Container( ),
padding: EdgeInsets.all(4), SizedBox(width: 8),
decoration: BoxDecoration( Container(
border: Border.all(color: Colors.blue), padding: EdgeInsets.all(4),
borderRadius: BorderRadius.circular(4), decoration: BoxDecoration(
), border: Border.all(color: Colors.blue),
child: InkWell( borderRadius: BorderRadius.circular(4),
onTap: () => handleFileUpload(index), ),
child: Row( child: InkWell(
mainAxisSize: MainAxisSize.min, onTap: () => handleFileUpload(index),
children: [ child: Row(
Icon(Icons.upload, mainAxisSize: MainAxisSize.min,
size: 16, color: Colors.blue), children: [
SizedBox(width: 4), Icon(Icons.upload,
Text('Upload', size: 16, color: Colors.blue),
style: TextStyle( SizedBox(width: 4),
color: Colors.blue, Text('Upload',
fontSize: 12)), style: TextStyle(
], color: Colors.blue,
), fontSize: 12)),
), ],
), ),
),
),
//###################### This Function is used to close or cut uploaded File in Local ####################### //###################### This Function is used to close or cut uploaded File in Local #######################
// if (uploadedFiles.containsKey(index)) // if (uploadedFiles.containsKey(index))
// IconButton( // IconButton(
// icon: Icon(Icons.close, size: 16, color: Colors.red), // icon: Icon(Icons.close, size: 16, color: Colors.red),
// onPressed: () { // onPressed: () {
// setState(() { // setState(() {
// uploadedFiles.remove(index); // uploadedFiles.remove(index);
// }); // });
// }, // },
// ), // ),
//########################################################################################################### //###########################################################################################################
], ],
), ),
), ),
], ],
); );
}), }),
), ),
), ),
), ),
@ -284,7 +287,8 @@ class _TransportViewState extends State<TransportView> {
PlatformFile file = result.files.first; PlatformFile file = result.files.first;
// Validate file size (optional) // Validate file size (optional)
if (file.size > 10 * 1024 * 1024) { // 10MB limit if (file.size > 10 * 1024 * 1024) {
// 10MB limit
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
SnackBar( SnackBar(
content: Text('File size must be less than 10MB'), content: Text('File size must be less than 10MB'),
@ -316,14 +320,6 @@ class _TransportViewState extends State<TransportView> {
} }
} }
_commonText(String title) {
return Text(
title,
style: TextStyle(
fontSize: 13, color: Colors.black, fontWeight: FontWeight.w900),
);
}
_dashboardView() { _dashboardView() {
return RawScrollbar( return RawScrollbar(
child: Column( child: Column(
@ -350,8 +346,10 @@ class _TransportViewState extends State<TransportView> {
ctrl.selectedUser.value = index; ctrl.selectedUser.value = index;
ctrl.refreshApis(); ctrl.refreshApis();
ctrl.isFilterVisibleViewFreight.value = false; ctrl.isFilterVisibleViewFreight.value = false;
ctrl.isFilterVisiblePendingGeneration.value = false; ctrl.isFilterVisiblePendingGeneration.value =
ctrl.isFilterVisibleGenerateFreight.value = false; false;
ctrl.isFilterVisibleGenerateFreight.value =
false;
}, },
child: Container( child: Container(
margin: EdgeInsets.only(bottom: 10, top: 10), margin: EdgeInsets.only(bottom: 10, top: 10),

View File

@ -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;
} }

View File

@ -4,7 +4,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;
@ -19,7 +20,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,

View File

@ -24,3 +24,4 @@ class MyApp extends StatelessWidget {
}); });
} }
} }

View File

@ -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";
// }

View File

@ -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 {