pd-android-app/lib/models/get_invoice_model.dart

244 lines
5.7 KiB
Dart

class GetInvoiceModel {
CourierStatusTimeline courierStatusTimeline;
String id;
String invoiceId;
OrderId orderId;
List<Item> items;
int subtotal;
double gstTotal;
double invoiceAmount;
String courierStatus;
int v;
GetInvoiceModel({
required this.courierStatusTimeline,
required this.id,
required this.invoiceId,
required this.orderId,
required this.items,
required this.subtotal,
required this.gstTotal,
required this.invoiceAmount,
required this.courierStatus,
required this.v,
});
factory GetInvoiceModel.fromJson(Map<String, dynamic> json) {
return GetInvoiceModel(
courierStatusTimeline: CourierStatusTimeline.fromJson(
json['courierstatus_timeline']),
id: json['_id'],
invoiceId: json['invoiceId'],
orderId: OrderId.fromJson(json['orderId']),
items: List<Item>.from(json['items'].map((item) => Item.fromJson(item))),
subtotal: json['subtotal'],
gstTotal: json['gstTotal'].toDouble(),
invoiceAmount: json['invoiceAmount'].toDouble(),
courierStatus: json['courierStatus'],
v: json['__v'],
);
}
}
class CourierStatusTimeline {
String processing;
CourierStatusTimeline({
required this.processing,
});
factory CourierStatusTimeline.fromJson(Map<String, dynamic> json) {
return CourierStatusTimeline(
processing: json['processing'],
);
}
}
class OrderId {
String id;
String paymentMode;
String shipTo;
String billTo;
List<OrderItem> orderItems;
int subtotal;
double gstTotal;
double grandTotal;
String status;
List<String> invoices;
AddedBy addedBy;
String pd;
bool isCancelled;
bool isDelivered;
String deliveredDate;
String statusUpdatedAt;
String uniqueId;
String createdAt;
String updatedAt;
int v;
OrderId({
required this.id,
required this.paymentMode,
required this.shipTo,
required this.billTo,
required this.orderItems,
required this.subtotal,
required this.gstTotal,
required this.grandTotal,
required this.status,
required this.invoices,
required this.addedBy,
required this.pd,
required this.isCancelled,
required this.isDelivered,
required this.deliveredDate,
required this.statusUpdatedAt,
required this.uniqueId,
required this.createdAt,
required this.updatedAt,
required this.v,
});
factory OrderId.fromJson(Map<String, dynamic> json) {
return OrderId(
id: json['_id'],
paymentMode: json['paymentMode'],
shipTo: json['shipTo'],
billTo: json['billTo'],
orderItems: List<OrderItem>.from(json['orderItem'].map((item) => OrderItem.fromJson(item))),
subtotal: json['subtotal'],
gstTotal: json['gstTotal'].toDouble(),
grandTotal: json['grandTotal'].toDouble(),
status: json['status'],
invoices: List<String>.from(json['invoices']),
addedBy: AddedBy.fromJson(json['addedBy']),
pd: json['pd'],
isCancelled: json['iscancelled'],
isDelivered: json['isDelivered'],
deliveredDate: json['DeliveredDate'] ?? '',
statusUpdatedAt: json['statusUpdatedAt'],
uniqueId: json['uniqueId'],
createdAt: json['createdAt'],
updatedAt: json['updatedAt'],
v: json['__v'],
);
}
}
class OrderItem {
String productId;
String sku;
String name;
String categoryName;
String brandName;
int price;
int gst;
int hsnCode;
String description;
List<dynamic> image;
int quantity;
int remainingQuantity;
String id;
OrderItem({
required this.productId,
required this.sku,
required this.name,
required this.categoryName,
required this.brandName,
required this.price,
required this.gst,
required this.hsnCode,
required this.description,
required this.image,
required this.quantity,
required this.remainingQuantity,
required this.id,
});
factory OrderItem.fromJson(Map<String, dynamic> json) {
return OrderItem(
productId: json['productId'],
sku: json['SKU'],
name: json['name'],
categoryName: json['categoryName'],
brandName: json['brandName'],
price: json['price'],
gst: json['GST'],
hsnCode: json['HSN_Code'],
description: json['description'] ?? '',
image: List<dynamic>.from(json['image']),
quantity: json['quantity'],
remainingQuantity: json['remainingQuantity'],
id: json['_id'],
);
}
}
class Item {
String productId;
String sku;
String name;
String categoryName;
String brandName;
int price;
int gst;
int hsnCode;
int processQuantity;
String id;
Item({
required this.productId,
required this.sku,
required this.name,
required this.categoryName,
required this.brandName,
required this.price,
required this.gst,
required this.hsnCode,
required this.processQuantity,
required this.id,
});
factory Item.fromJson(Map<String, dynamic> json) {
return Item(
productId: json['productId'],
sku: json['SKU'],
name: json['name'],
categoryName: json['categoryName'],
brandName: json['brandName'],
price: json['price'],
gst: json['GST'],
hsnCode: json['HSN_Code'],
processQuantity: json['processquantity'],
id: json['_id'],
);
}
}
class AddedBy {
String id;
String name;
String email;
String mobileNumber;
dynamic fcmToken;
AddedBy({
required this.id,
required this.name,
required this.email,
required this.mobileNumber,
this.fcmToken,
});
factory AddedBy.fromJson(Map<String, dynamic> json) {
return AddedBy(
id: json['_id'],
name: json['name'],
email: json['email'],
mobileNumber: json['mobile_number'],
fcmToken: json['fcm_token'],
);
}
}