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

191 lines
5.5 KiB
Dart

class GetRdCancelledModel {
final String id;
final String paymentMode;
final String shipTo;
final String billTo;
final List<OrderItem> orderItems;
final double subtotal;
final double gstTotal;
final double grandTotal;
final String status;
final List<String> invoices;
final String addedBy;
final String pd;
final bool isCancelled;
final bool isDelivered;
final String deliveredDate;
final String statusUpdatedAt;
final String uniqueId;
final String createdAt;
final String updatedAt;
final int version;
final String orderCancelledReason;
GetRdCancelledModel({
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.version,
required this.orderCancelledReason,
});
factory GetRdCancelledModel.fromJson(Map<String, dynamic> json) {
return GetRdCancelledModel(
id: json['_id'],
paymentMode: json['paymentMode'],
shipTo: json['shipTo'],
billTo: json['billTo'],
orderItems: (json['orderItem'] as List<dynamic>)
.map((item) => OrderItem.fromJson(item))
.toList(),
subtotal: json['subtotal'].toDouble(),
gstTotal: json['gstTotal'].toDouble(),
grandTotal: json['grandTotal'].toDouble(),
status: json['status'],
invoices: List<String>.from(json['invoices']),
addedBy: 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'],
version: json['__v'],
orderCancelledReason: json['order_Cancelled_Reason'],
);
}
Map<String, dynamic> toJson() {
return {
'_id': id,
'paymentMode': paymentMode,
'shipTo': shipTo,
'billTo': billTo,
'orderItem': orderItems.map((item) => item.toJson()).toList(),
'subtotal': subtotal,
'gstTotal': gstTotal,
'grandTotal': grandTotal,
'status': status,
'invoices': invoices,
'addedBy': addedBy,
'pd': pd,
'iscancelled': isCancelled,
'isDelivered': isDelivered,
'DeliveredDate': deliveredDate,
'statusUpdatedAt': statusUpdatedAt,
'uniqueId': uniqueId,
'createdAt': createdAt,
'updatedAt': updatedAt,
'__v': version,
'order_Cancelled_Reason': orderCancelledReason,
};
}
@override
String toString() {
return 'PlacedOrder(id: $id, paymentMode: $paymentMode, shipTo: $shipTo, '
'billTo: $billTo, orderItems: $orderItems, subtotal: $subtotal, '
'gstTotal: $gstTotal, grandTotal: $grandTotal, status: $status, '
'invoices: $invoices, addedBy: $addedBy, pd: $pd, isCancelled: $isCancelled, '
'isDelivered: $isDelivered, deliveredDate: $deliveredDate, '
'statusUpdatedAt: $statusUpdatedAt, uniqueId: $uniqueId, '
'createdAt: $createdAt, updatedAt: $updatedAt, version: $version, '
'orderCancelledReason: $orderCancelledReason)';
}
}
class OrderItem {
final String productId;
final String sku;
final String name;
final String categoryName;
final String brandName;
final double price;
final double gst;
final int hsnCode;
final String description;
final List<String> images;
final int quantity;
final int remainingQuantity;
final 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.images,
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'].toDouble(),
gst: json['GST'].toDouble(),
hsnCode: json['HSN_Code'],
description: json['description'] ?? '',
images: List<String>.from(json['image']),
quantity: json['quantity'],
remainingQuantity: json['remainingQuantity'],
id: json['_id'],
);
}
Map<String, dynamic> toJson() {
return {
'productId': productId,
'SKU': sku,
'name': name,
'categoryName': categoryName,
'brandName': brandName,
'price': price,
'GST': gst,
'HSN_Code': hsnCode,
'description': description,
'image': images,
'quantity': quantity,
'remainingQuantity': remainingQuantity,
'_id': id,
};
}
@override
String toString() {
return 'OrderItem(productId: $productId, sku: $sku, name: $name, '
'categoryName: $categoryName, brandName: $brandName, price: $price, '
'gst: $gst, hsnCode: $hsnCode, description: $description, '
'images: $images, quantity: $quantity, remainingQuantity: $remainingQuantity, '
'id: $id)';
}
}