Document improvments
This commit is contained in:
parent
4fa67cc0aa
commit
f57ded2d10
|
|
@ -19,47 +19,28 @@ enum DocumentReportFields {
|
||||||
height,
|
height,
|
||||||
file_type,
|
file_type,
|
||||||
record_type,
|
record_type,
|
||||||
record_name,
|
|
||||||
created_at,
|
created_at,
|
||||||
created_by,
|
created_by,
|
||||||
updated_at,
|
updated_at,
|
||||||
}
|
}
|
||||||
|
|
||||||
var memoizedDocumentReport = memo10((
|
var memoizedDocumentReport = memo4((
|
||||||
UserCompanyEntity userCompany,
|
UserCompanyEntity userCompany,
|
||||||
ReportsUIState reportsUIState,
|
ReportsUIState reportsUIState,
|
||||||
BuiltMap<String, ClientEntity> clientMap,
|
BuiltMap<String, DocumentEntity> documentMap,
|
||||||
BuiltMap<String, ProductEntity> productMap,
|
|
||||||
BuiltMap<String, InvoiceEntity> invoiceMap,
|
|
||||||
BuiltMap<String, InvoiceEntity> quoteMap,
|
|
||||||
BuiltMap<String, ExpenseEntity> expenseMap,
|
|
||||||
BuiltMap<String, ProjectEntity> projectMap,
|
|
||||||
BuiltMap<String, VendorEntity> vendorMap,
|
|
||||||
BuiltMap<String, UserEntity> userMap,
|
BuiltMap<String, UserEntity> userMap,
|
||||||
) =>
|
) =>
|
||||||
documentReport(
|
documentReport(
|
||||||
userCompany,
|
userCompany,
|
||||||
reportsUIState,
|
reportsUIState,
|
||||||
clientMap,
|
documentMap,
|
||||||
productMap,
|
|
||||||
invoiceMap,
|
|
||||||
quoteMap,
|
|
||||||
expenseMap,
|
|
||||||
projectMap,
|
|
||||||
vendorMap,
|
|
||||||
userMap,
|
userMap,
|
||||||
));
|
));
|
||||||
|
|
||||||
ReportResult documentReport(
|
ReportResult documentReport(
|
||||||
UserCompanyEntity userCompany,
|
UserCompanyEntity userCompany,
|
||||||
ReportsUIState reportsUIState,
|
ReportsUIState reportsUIState,
|
||||||
BuiltMap<String, ClientEntity> clientMap,
|
BuiltMap<String, DocumentEntity> documentMap,
|
||||||
BuiltMap<String, ProductEntity> productMap,
|
|
||||||
BuiltMap<String, InvoiceEntity> invoiceMap,
|
|
||||||
BuiltMap<String, InvoiceEntity> quoteMap,
|
|
||||||
BuiltMap<String, ExpenseEntity> expenseMap,
|
|
||||||
BuiltMap<String, ProjectEntity> projectMap,
|
|
||||||
BuiltMap<String, VendorEntity> vendorMap,
|
|
||||||
BuiltMap<String, UserEntity> userMap,
|
BuiltMap<String, UserEntity> userMap,
|
||||||
) {
|
) {
|
||||||
final List<List<ReportElement>> data = [];
|
final List<List<ReportElement>> data = [];
|
||||||
|
|
@ -76,9 +57,11 @@ ReportResult documentReport(
|
||||||
|
|
||||||
final defaultColumns = [
|
final defaultColumns = [
|
||||||
DocumentReportFields.record_type,
|
DocumentReportFields.record_type,
|
||||||
DocumentReportFields.record_name,
|
|
||||||
DocumentReportFields.name,
|
DocumentReportFields.name,
|
||||||
DocumentReportFields.file_type,
|
DocumentReportFields.file_type,
|
||||||
|
DocumentReportFields.size,
|
||||||
|
DocumentReportFields.width,
|
||||||
|
DocumentReportFields.height,
|
||||||
];
|
];
|
||||||
|
|
||||||
if (documentReportSettings.columns.isNotEmpty) {
|
if (documentReportSettings.columns.isNotEmpty) {
|
||||||
|
|
@ -90,7 +73,7 @@ ReportResult documentReport(
|
||||||
columns = BuiltList(defaultColumns);
|
columns = BuiltList(defaultColumns);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ReportElement> _getRow(BaseEntity entity, DocumentEntity document) {
|
documentMap.values.forEach((document) {
|
||||||
bool skip = false;
|
bool skip = false;
|
||||||
final List<ReportElement> row = [];
|
final List<ReportElement> row = [];
|
||||||
|
|
||||||
|
|
@ -110,11 +93,8 @@ ReportResult documentReport(
|
||||||
case DocumentReportFields.created_by:
|
case DocumentReportFields.created_by:
|
||||||
value = userMap[document.createdUserId]?.listDisplayName ?? '';
|
value = userMap[document.createdUserId]?.listDisplayName ?? '';
|
||||||
break;
|
break;
|
||||||
case DocumentReportFields.record_name:
|
|
||||||
value = entity.listDisplayName;
|
|
||||||
break;
|
|
||||||
case DocumentReportFields.record_type:
|
case DocumentReportFields.record_type:
|
||||||
value = entity.entityType;
|
value = document.parentType;
|
||||||
break;
|
break;
|
||||||
case DocumentReportFields.updated_at:
|
case DocumentReportFields.updated_at:
|
||||||
value = convertTimestampToDateString(document.updatedAt);
|
value = convertTimestampToDateString(document.updatedAt);
|
||||||
|
|
@ -141,59 +121,25 @@ ReportResult documentReport(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value.runtimeType == bool) {
|
if (value.runtimeType == bool) {
|
||||||
row.add(entity.getReportBool(value: value));
|
row.add(document.getReportBool(value: value));
|
||||||
} else if (value.runtimeType == int) {
|
} else if (value.runtimeType == int) {
|
||||||
row.add(entity.getReportInt(value: value));
|
row.add(document.getReportInt(value: value));
|
||||||
} else if (value.runtimeType == double) {
|
} else if (value.runtimeType == double) {
|
||||||
row.add(entity.getReportDouble(value: value));
|
row.add(document.getReportDouble(value: value));
|
||||||
} else if (value.runtimeType == EntityType) {
|
} else if (value.runtimeType == EntityType) {
|
||||||
row.add(entity.getReportEntityType());
|
row.add(ReportEntityTypeValue(
|
||||||
|
entityId: document.parentId,
|
||||||
|
entityType: document.parentType,
|
||||||
|
value: document.parentType));
|
||||||
} else {
|
} else {
|
||||||
row.add(entity.getReportString(value: value));
|
row.add(document.getReportString(value: value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return skip ? null : row;
|
if (!skip) {
|
||||||
}
|
data.add(row);
|
||||||
|
entities.add(document);
|
||||||
clientMap.forEach((clientId, client) {
|
}
|
||||||
client.documents.forEach((document) {
|
|
||||||
final row = _getRow(client, document);
|
|
||||||
if (row != null) {
|
|
||||||
data.add(row);
|
|
||||||
entities.add(document);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
productMap.forEach((productId, product) {
|
|
||||||
product.documents.forEach((document) {
|
|
||||||
final row = _getRow(product, document);
|
|
||||||
if (row != null) {
|
|
||||||
data.add(row);
|
|
||||||
entities.add(document);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
invoiceMap.forEach((invoiceId, invoice) {
|
|
||||||
invoice.documents.forEach((document) {
|
|
||||||
final row = _getRow(invoice, document);
|
|
||||||
if (row != null) {
|
|
||||||
data.add(row);
|
|
||||||
entities.add(document);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
quoteMap.forEach((quoteId, quote) {
|
|
||||||
quote.documents.forEach((document) {
|
|
||||||
final row = _getRow(quote, document);
|
|
||||||
if (row != null) {
|
|
||||||
data.add(row);
|
|
||||||
entities.add(document);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
final selectedColumns = columns.map((item) => EnumUtils.parse(item)).toList();
|
final selectedColumns = columns.map((item) => EnumUtils.parse(item)).toList();
|
||||||
|
|
|
||||||
|
|
@ -147,13 +147,7 @@ class ReportsScreenVM {
|
||||||
reportResult = memoizedDocumentReport(
|
reportResult = memoizedDocumentReport(
|
||||||
state.userCompany,
|
state.userCompany,
|
||||||
state.uiState.reportsUIState,
|
state.uiState.reportsUIState,
|
||||||
state.clientState.map,
|
state.documentState.map,
|
||||||
state.productState.map,
|
|
||||||
state.invoiceState.map,
|
|
||||||
state.quoteState.map,
|
|
||||||
state.expenseState.map,
|
|
||||||
state.projectState.map,
|
|
||||||
state.vendorState.map,
|
|
||||||
state.userState.map,
|
state.userState.map,
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue