52 lines
1.2 KiB
Dart
52 lines
1.2 KiB
Dart
import 'package.dart';
|
|
import 'receipt.dart';
|
|
|
|
class Invoice {
|
|
String id;
|
|
String invoiceNumber;
|
|
DateTime invoiceDate;
|
|
String customerName;
|
|
String customerPhoneNumber;
|
|
double amount;
|
|
String discount;
|
|
String status;
|
|
String paymentAttachment;
|
|
|
|
List<Package> packages;
|
|
List<Receipt> receipts;
|
|
List<String> receiptPhotos;
|
|
|
|
Invoice(
|
|
{this.id,
|
|
this.invoiceNumber,
|
|
this.invoiceDate,
|
|
this.customerName,
|
|
this.customerPhoneNumber,
|
|
this.amount,
|
|
this.discount,
|
|
this.status,
|
|
this.paymentAttachment,
|
|
this.packages,
|
|
this.receiptPhotos,
|
|
this.receipts});
|
|
|
|
double get getAmount => packages.fold(0, (p, e) => (e.rate * e.weight) + p);
|
|
|
|
factory Invoice.fromMap(Map<String, dynamic> map, String docID) {
|
|
return Invoice(
|
|
id: docID,
|
|
invoiceNumber: map['invoice_number'],
|
|
invoiceDate: map['invoice_date'],
|
|
customerName: map['customer_name'],
|
|
customerPhoneNumber: map['phone_number'],
|
|
amount: map['amount'],
|
|
status: map['status'],
|
|
discount: map['discount'],
|
|
paymentAttachment: map['payment_attachment'],
|
|
packages: map['packages'],
|
|
receiptPhotos: map['receiptPhotos'],
|
|
receipts: map['receipts'],
|
|
);
|
|
}
|
|
}
|