Files
fcs/lib/domain/entities/payment.dart
2021-09-10 14:27:38 +06:30

51 lines
1.1 KiB
Dart

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