add payment
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:fcs/domain/entities/carton.dart';
|
||||
import 'package:fcs/domain/entities/custom_duty.dart';
|
||||
import 'package:fcs/domain/entities/discount.dart';
|
||||
import 'package:fcs/domain/entities/discount_by_weight.dart';
|
||||
import 'package:fcs/domain/entities/payment.dart';
|
||||
import 'package:fcs/domain/entities/payment_method.dart';
|
||||
import 'package:fcs/domain/entities/rate.dart';
|
||||
import 'package:fcs/domain/entities/shipment.dart';
|
||||
@@ -28,6 +29,7 @@ class Invoice {
|
||||
List<Carton> cartons;
|
||||
List<CargoType> cargoTypes;
|
||||
List<Shipment> shipments;
|
||||
List<Payment> payments;
|
||||
Discount discount;
|
||||
PaymentMethod paymentMethod;
|
||||
String invoiceURL;
|
||||
@@ -70,6 +72,8 @@ class Invoice {
|
||||
return total;
|
||||
}
|
||||
|
||||
double get balance => (amount ?? 0) - (paidAmount ?? 0);
|
||||
|
||||
double getNetAmount(Rate rate) {
|
||||
List<CargoType> cargoTypes = getCargoTypes(rate);
|
||||
var total = cargoTypes.fold(0.0, (p, c) => c.calAmount + p);
|
||||
@@ -108,6 +112,7 @@ class Invoice {
|
||||
this.userName,
|
||||
this.phoneNumber,
|
||||
this.amount,
|
||||
this.paidAmount,
|
||||
this.discount,
|
||||
this.status,
|
||||
this.customDuties,
|
||||
@@ -118,6 +123,7 @@ class Invoice {
|
||||
this.fcsShipmentID,
|
||||
this.shipments,
|
||||
this.invoiceURL,
|
||||
this.payments,
|
||||
this.paymentMethod});
|
||||
|
||||
factory Invoice.fromMap(Map<String, dynamic> map, String docID) {
|
||||
@@ -142,6 +148,8 @@ class Invoice {
|
||||
: null;
|
||||
var discountMap = map['discount'];
|
||||
var discount = Discount.fromMap(discountMap, discountMap['id']);
|
||||
var paymentMaps = List<Map<String, dynamic>>.from(map['payments'] ?? []);
|
||||
var payments = paymentMaps.map((e) => Payment.fromMap(e, e["id"])).toList();
|
||||
return Invoice(
|
||||
id: docID,
|
||||
invoiceNumber: map['invoice_number'],
|
||||
@@ -150,6 +158,7 @@ class Invoice {
|
||||
fcsID: map['fcs_id'],
|
||||
phoneNumber: map['phone_number'],
|
||||
amount: map['amount'],
|
||||
paidAmount: double.tryParse(map['paid_amount'].toString()) ?? 0,
|
||||
status: map['status'],
|
||||
cartons: cartons,
|
||||
cargoTypes: cargoTypes,
|
||||
@@ -159,6 +168,7 @@ class Invoice {
|
||||
invoiceURL: map['invoice_url'],
|
||||
paymentMethod: paymentMethod,
|
||||
discount: discount,
|
||||
payments: payments,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user