Files
fcs/lib/domain/entities/payment.dart

51 lines
1.1 KiB
Dart
Raw Normal View History

2020-10-28 05:11:06 +06:30
import 'package:cloud_firestore/cloud_firestore.dart';
class Payment {
2021-09-10 14:27:38 +06:30
String? id;
String? invoiceID;
DateTime? paymentDate;
String? paymentReceiptURL;
String? status;
2020-10-28 05:11:06 +06:30
double amount;
Payment(
{this.id,
this.invoiceID,
this.paymentDate,
this.paymentReceiptURL,
this.status,
2021-09-10 14:27:38 +06:30
this.amount = 0});
2020-10-28 05:11:06 +06:30
factory Payment.fromMap(Map<String, dynamic> map, String id) {
var _paymentDate = (map['payment_date'] as Timestamp);
return Payment(
id: id,
2021-09-10 14:27:38 +06:30
paymentDate: _paymentDate.toDate(),
2020-10-28 05:11:06 +06:30
paymentReceiptURL: map['payment_receipt_url'],
status: map['status'],
amount: map['amount']?.toDouble() ?? 0,
);
}
Map<String, dynamic> toMap() {
return {
"id": id,
"invoice_id": invoiceID,
2021-09-10 14:27:38 +06:30
'payment_date': paymentDate?.toUtc().toIso8601String(),
2020-10-28 05:11:06 +06:30
'payment_receipt_url': paymentReceiptURL,
'status': status,
'amount': amount,
};
}
Payment clone() {
2021-09-10 14:27:38 +06:30
return Payment.fromMap(toMap(), this.id!);
2020-10-28 05:11:06 +06:30
}
@override
bool operator ==(Object other) => other is Payment && other.id == id;
@override
int get hashCode => id.hashCode;
}