feat: Refactor code structure and optimize performance across multiple modules
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
import 'package:krow/features/invoice/data/models/invoice_model.dart';
|
||||
|
||||
class InvoiceListEntity {
|
||||
final String id;
|
||||
final InvoiceStatus status;
|
||||
String? cursor;
|
||||
final String invoiceNumber;
|
||||
final String eventName;
|
||||
final int count;
|
||||
final double value;
|
||||
final DateTime date;
|
||||
final DateTime dueAt;
|
||||
final String? poNumber;
|
||||
|
||||
final InvoiceModel? invoiceModel;
|
||||
|
||||
InvoiceListEntity({
|
||||
required this.id,
|
||||
required this.status,
|
||||
required this.invoiceNumber,
|
||||
required this.eventName,
|
||||
required this.count,
|
||||
required this.value,
|
||||
required this.date,
|
||||
required this.dueAt,
|
||||
this.poNumber,
|
||||
this.cursor,
|
||||
this.invoiceModel,
|
||||
});
|
||||
|
||||
InvoiceListEntity copyWith({
|
||||
String? id,
|
||||
String? cursor,
|
||||
InvoiceStatus? status,
|
||||
String? invoiceNumber,
|
||||
String? eventName,
|
||||
int? count,
|
||||
double? value,
|
||||
DateTime? date,
|
||||
DateTime? dueAt,
|
||||
String? poNumber,
|
||||
}) {
|
||||
return InvoiceListEntity(
|
||||
id: id ?? this.id,
|
||||
cursor: cursor ?? this.cursor,
|
||||
status: status ?? this.status,
|
||||
invoiceNumber: invoiceNumber ?? this.invoiceNumber,
|
||||
eventName: eventName ?? this.eventName,
|
||||
count: count ?? this.count,
|
||||
value: value ?? this.value,
|
||||
date: date ?? this.date,
|
||||
dueAt: date ?? this.dueAt,
|
||||
);
|
||||
}
|
||||
|
||||
InvoiceListEntity.fromModel(InvoiceModel model, {this.cursor})
|
||||
: id = model.id,
|
||||
poNumber = model.event?.purchaseOrder,
|
||||
status = model.status,
|
||||
invoiceNumber = model.event?.id ?? '',
|
||||
eventName = model.event!.name,
|
||||
count = model.items?.length?? 0,
|
||||
value = (model.total ?? 0.0),
|
||||
date = DateTime.parse(model.event?.date ?? ''),
|
||||
dueAt = DateTime.parse(model.dueAt ?? ''),
|
||||
invoiceModel = model;
|
||||
|
||||
InvoiceListEntity.empty()
|
||||
: id = 'INV-20250113-12345',
|
||||
status = InvoiceStatus.open,
|
||||
invoiceNumber = 'INV-20250113-12345',
|
||||
eventName = 'Event Name',
|
||||
count = 16,
|
||||
value = 1230,
|
||||
poNumber = 'PO-123456',
|
||||
date = DateTime.now(),
|
||||
dueAt = DateTime.now(),
|
||||
invoiceModel = null;
|
||||
}
|
||||
Reference in New Issue
Block a user