add auth, format
This commit is contained in:
@@ -7,24 +7,57 @@ part 'quote_model.g.dart';
|
||||
|
||||
@HiveType(typeId: HiveTypeIds.quoteModel)
|
||||
class QuoteModel extends HiveObject {
|
||||
QuoteModel({required this.quoteId, required this.quoteNumber, required this.userId, required this.status, required this.totalAmount, required this.discountAmount, required this.finalAmount, this.projectName, this.deliveryAddress, this.paymentTerms, this.notes, this.validUntil, this.convertedOrderId, this.erpnextQuotation, required this.createdAt, this.updatedAt});
|
||||
|
||||
@HiveField(0) final String quoteId;
|
||||
@HiveField(1) final String quoteNumber;
|
||||
@HiveField(2) final String userId;
|
||||
@HiveField(3) final QuoteStatus status;
|
||||
@HiveField(4) final double totalAmount;
|
||||
@HiveField(5) final double discountAmount;
|
||||
@HiveField(6) final double finalAmount;
|
||||
@HiveField(7) final String? projectName;
|
||||
@HiveField(8) final String? deliveryAddress;
|
||||
@HiveField(9) final String? paymentTerms;
|
||||
@HiveField(10) final String? notes;
|
||||
@HiveField(11) final DateTime? validUntil;
|
||||
@HiveField(12) final String? convertedOrderId;
|
||||
@HiveField(13) final String? erpnextQuotation;
|
||||
@HiveField(14) final DateTime createdAt;
|
||||
@HiveField(15) final DateTime? updatedAt;
|
||||
QuoteModel({
|
||||
required this.quoteId,
|
||||
required this.quoteNumber,
|
||||
required this.userId,
|
||||
required this.status,
|
||||
required this.totalAmount,
|
||||
required this.discountAmount,
|
||||
required this.finalAmount,
|
||||
this.projectName,
|
||||
this.deliveryAddress,
|
||||
this.paymentTerms,
|
||||
this.notes,
|
||||
this.validUntil,
|
||||
this.convertedOrderId,
|
||||
this.erpnextQuotation,
|
||||
required this.createdAt,
|
||||
this.updatedAt,
|
||||
});
|
||||
|
||||
@HiveField(0)
|
||||
final String quoteId;
|
||||
@HiveField(1)
|
||||
final String quoteNumber;
|
||||
@HiveField(2)
|
||||
final String userId;
|
||||
@HiveField(3)
|
||||
final QuoteStatus status;
|
||||
@HiveField(4)
|
||||
final double totalAmount;
|
||||
@HiveField(5)
|
||||
final double discountAmount;
|
||||
@HiveField(6)
|
||||
final double finalAmount;
|
||||
@HiveField(7)
|
||||
final String? projectName;
|
||||
@HiveField(8)
|
||||
final String? deliveryAddress;
|
||||
@HiveField(9)
|
||||
final String? paymentTerms;
|
||||
@HiveField(10)
|
||||
final String? notes;
|
||||
@HiveField(11)
|
||||
final DateTime? validUntil;
|
||||
@HiveField(12)
|
||||
final String? convertedOrderId;
|
||||
@HiveField(13)
|
||||
final String? erpnextQuotation;
|
||||
@HiveField(14)
|
||||
final DateTime createdAt;
|
||||
@HiveField(15)
|
||||
final DateTime? updatedAt;
|
||||
|
||||
factory QuoteModel.fromJson(Map<String, dynamic> json) => QuoteModel(
|
||||
quoteId: json['quote_id'] as String,
|
||||
@@ -35,14 +68,20 @@ class QuoteModel extends HiveObject {
|
||||
discountAmount: (json['discount_amount'] as num).toDouble(),
|
||||
finalAmount: (json['final_amount'] as num).toDouble(),
|
||||
projectName: json['project_name'] as String?,
|
||||
deliveryAddress: json['delivery_address'] != null ? jsonEncode(json['delivery_address']) : null,
|
||||
deliveryAddress: json['delivery_address'] != null
|
||||
? jsonEncode(json['delivery_address'])
|
||||
: null,
|
||||
paymentTerms: json['payment_terms'] as String?,
|
||||
notes: json['notes'] as String?,
|
||||
validUntil: json['valid_until'] != null ? DateTime.parse(json['valid_until']?.toString() ?? '') : null,
|
||||
validUntil: json['valid_until'] != null
|
||||
? DateTime.parse(json['valid_until']?.toString() ?? '')
|
||||
: null,
|
||||
convertedOrderId: json['converted_order_id'] as String?,
|
||||
erpnextQuotation: json['erpnext_quotation'] as String?,
|
||||
createdAt: DateTime.parse(json['created_at']?.toString() ?? ''),
|
||||
updatedAt: json['updated_at'] != null ? DateTime.parse(json['updated_at']?.toString() ?? '') : null,
|
||||
updatedAt: json['updated_at'] != null
|
||||
? DateTime.parse(json['updated_at']?.toString() ?? '')
|
||||
: null,
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
@@ -54,7 +93,9 @@ class QuoteModel extends HiveObject {
|
||||
'discount_amount': discountAmount,
|
||||
'final_amount': finalAmount,
|
||||
'project_name': projectName,
|
||||
'delivery_address': deliveryAddress != null ? jsonDecode(deliveryAddress!) : null,
|
||||
'delivery_address': deliveryAddress != null
|
||||
? jsonDecode(deliveryAddress!)
|
||||
: null,
|
||||
'payment_terms': paymentTerms,
|
||||
'notes': notes,
|
||||
'valid_until': validUntil?.toIso8601String(),
|
||||
@@ -64,6 +105,7 @@ class QuoteModel extends HiveObject {
|
||||
'updated_at': updatedAt?.toIso8601String(),
|
||||
};
|
||||
|
||||
bool get isExpired => validUntil != null && DateTime.now().isAfter(validUntil!);
|
||||
bool get isExpired =>
|
||||
validUntil != null && DateTime.now().isAfter(validUntil!);
|
||||
bool get isConverted => convertedOrderId != null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user