update carton and fcs shipment

This commit is contained in:
tzw
2025-02-17 20:13:30 +06:30
parent ffaa715333
commit 0295a29c44
33 changed files with 171 additions and 2383 deletions

View File

@@ -22,7 +22,6 @@ import 'package:fcs/pages/main/util.dart';
import 'package:fcs/pages/payment_methods/model/payment_method_model.dart';
import 'package:fcs/pages/rates/custom_list.dart';
import 'package:fcs/pages/rates/model/shipment_rate_model.dart';
import 'package:fcs/pages/shipment/model/shipment_model.dart';
import 'package:fcs/pages/widgets/display_text.dart';
import 'package:fcs/pages/widgets/fcs_icons.dart';
import 'package:fcs/pages/widgets/local_app_bar.dart';
@@ -104,8 +103,8 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
}
_loadShipments() async {
ShipmentModel shipmentModel =
Provider.of<ShipmentModel>(context, listen: false);
InvoiceModel shipmentModel =
Provider.of<InvoiceModel>(context, listen: false);
List<Shipment?>? shipments = await shipmentModel.getShipmentWithHandlingFee(
widget.fcsShipment!.id!, widget.customer!.id!);
shipments!.forEach((s) {
@@ -361,14 +360,6 @@ class _InvoiceEditorState extends State<InvoiceEditor> {
);
}
_addCustom(CustomDuty customDuty) {
if (customDuty == null) return;
setState(() {
_invoice!.customDuties.remove(customDuty);
_invoice!.customDuties.add(customDuty);
});
}
_addShipment(Shipment shipment) {
if (shipment == null) return;
shipment.isSelected = true;

View File

@@ -11,6 +11,7 @@ import 'package:fcs/pages/main/model/base_model.dart';
import 'package:logging/logging.dart';
import 'package:path/path.dart' as Path;
import '../../../domain/entities/shipment.dart';
import '../../../pagination/paginator_listener.dart';
class InvoiceModel extends BaseModel {
@@ -105,4 +106,28 @@ class InvoiceModel extends BaseModel {
Future<void> cancelInvoice(Invoice invoice) {
return Services.instance.invoiceService.cancelInvoice(invoice);
}
Future<List<Shipment?>?> getShipmentWithHandlingFee(
String fcsShipmentID, String userID) async {
String path = "/$shipments_collection";
try {
var q = FirebaseFirestore.instance
.collection(path)
.where("user_id", isEqualTo: userID)
.where("is_deleted", isEqualTo: false)
.where("handling_fee", isGreaterThan: 0)
.where("fcs_shipment_id", isEqualTo: fcsShipmentID);
var snaps = await q.get(const GetOptions(source: Source.server));
List<Shipment?> shipments = snaps.docs.map((snap) {
if (snap.exists) {
var s = Shipment.fromMap(snap.data as Map<String, dynamic>, snap.id);
return s;
}
}).toList();
return shipments;
} catch (e) {
log.warning("Error!! $e");
}
return null;
}
}