update order detail
This commit is contained in:
@@ -24,8 +24,8 @@ class OrderDetailModel {
|
||||
final List<OrderItemDetailModel> items;
|
||||
final PaymentTermsInfoModel paymentTerms;
|
||||
final List<TimelineItemModel> timeline;
|
||||
final List<dynamic> payments;
|
||||
final List<dynamic> invoices;
|
||||
final List<PaymentInfoModel> payments;
|
||||
final List<InvoiceInfoModel> invoices;
|
||||
|
||||
/// Create from JSON
|
||||
factory OrderDetailModel.fromJson(Map<String, dynamic> json) {
|
||||
@@ -50,8 +50,14 @@ class OrderDetailModel {
|
||||
.map((item) =>
|
||||
TimelineItemModel.fromJson(item as Map<String, dynamic>))
|
||||
.toList(),
|
||||
payments: json['payments'] as List<dynamic>? ?? [],
|
||||
invoices: json['invoices'] as List<dynamic>? ?? [],
|
||||
payments: (json['payments'] as List<dynamic>? ?? [])
|
||||
.map((item) =>
|
||||
PaymentInfoModel.fromJson(item as Map<String, dynamic>))
|
||||
.toList(),
|
||||
invoices: (json['invoices'] as List<dynamic>? ?? [])
|
||||
.map((item) =>
|
||||
InvoiceInfoModel.fromJson(item as Map<String, dynamic>))
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -64,8 +70,8 @@ class OrderDetailModel {
|
||||
'items': items.map((item) => item.toJson()).toList(),
|
||||
'payment_terms': paymentTerms.toJson(),
|
||||
'timeline': timeline.map((item) => item.toJson()).toList(),
|
||||
'payments': payments,
|
||||
'invoices': invoices,
|
||||
'payments': payments.map((item) => item.toJson()).toList(),
|
||||
'invoices': invoices.map((item) => item.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -78,8 +84,8 @@ class OrderDetailModel {
|
||||
items: items.map((item) => item.toEntity()).toList(),
|
||||
paymentTerms: paymentTerms.toEntity(),
|
||||
timeline: timeline.map((item) => item.toEntity()).toList(),
|
||||
payments: payments,
|
||||
invoices: invoices,
|
||||
payments: payments.map((item) => item.toEntity()).toList(),
|
||||
invoices: invoices.map((item) => item.toEntity()).toList(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -96,8 +102,12 @@ class OrderDetailModel {
|
||||
timeline: entity.timeline
|
||||
.map((item) => TimelineItemModel.fromEntity(item))
|
||||
.toList(),
|
||||
payments: entity.payments,
|
||||
invoices: entity.invoices,
|
||||
payments: entity.payments
|
||||
.map((item) => PaymentInfoModel.fromEntity(item))
|
||||
.toList(),
|
||||
invoices: entity.invoices
|
||||
.map((item) => InvoiceInfoModel.fromEntity(item))
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -500,3 +510,93 @@ class TimelineItemModel {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Payment Info Model
|
||||
class PaymentInfoModel {
|
||||
const PaymentInfoModel({
|
||||
required this.name,
|
||||
required this.creationDate,
|
||||
required this.amount,
|
||||
});
|
||||
|
||||
final String name;
|
||||
final String creationDate;
|
||||
final double amount;
|
||||
|
||||
factory PaymentInfoModel.fromJson(Map<String, dynamic> json) {
|
||||
return PaymentInfoModel(
|
||||
name: json['name'] as String,
|
||||
creationDate: json['creation_date'] as String,
|
||||
amount: (json['amount'] as num).toDouble(),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'name': name,
|
||||
'creation_date': creationDate,
|
||||
'amount': amount,
|
||||
};
|
||||
}
|
||||
|
||||
PaymentInfo toEntity() {
|
||||
return PaymentInfo(
|
||||
name: name,
|
||||
creationDate: creationDate,
|
||||
amount: amount,
|
||||
);
|
||||
}
|
||||
|
||||
factory PaymentInfoModel.fromEntity(PaymentInfo entity) {
|
||||
return PaymentInfoModel(
|
||||
name: entity.name,
|
||||
creationDate: entity.creationDate,
|
||||
amount: entity.amount,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Invoice Info Model
|
||||
class InvoiceInfoModel {
|
||||
const InvoiceInfoModel({
|
||||
required this.name,
|
||||
required this.postingDate,
|
||||
required this.grandTotal,
|
||||
});
|
||||
|
||||
final String name;
|
||||
final String postingDate;
|
||||
final double grandTotal;
|
||||
|
||||
factory InvoiceInfoModel.fromJson(Map<String, dynamic> json) {
|
||||
return InvoiceInfoModel(
|
||||
name: json['name'] as String,
|
||||
postingDate: json['posting_date'] as String,
|
||||
grandTotal: (json['grand_total'] as num).toDouble(),
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'name': name,
|
||||
'posting_date': postingDate,
|
||||
'grand_total': grandTotal,
|
||||
};
|
||||
}
|
||||
|
||||
InvoiceInfo toEntity() {
|
||||
return InvoiceInfo(
|
||||
name: name,
|
||||
postingDate: postingDate,
|
||||
grandTotal: grandTotal,
|
||||
);
|
||||
}
|
||||
|
||||
factory InvoiceInfoModel.fromEntity(InvoiceInfo entity) {
|
||||
return InvoiceInfoModel(
|
||||
name: entity.name,
|
||||
postingDate: entity.postingDate,
|
||||
grandTotal: entity.grandTotal,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user