Client/product documents
This commit is contained in:
parent
7c3004c107
commit
7603f3b58d
|
|
@ -275,6 +275,9 @@ abstract class BaseEntity implements SelectableEntity {
|
|||
ReportStringValue getReportString({String value}) =>
|
||||
ReportStringValue(entityId: id, entityType: entityType, value: value);
|
||||
|
||||
ReportEntityTypeValue getReportEntityType() =>
|
||||
ReportEntityTypeValue(entityId: id, entityType: entityType, value: entityType);
|
||||
|
||||
ReportBoolValue getReportBool({bool value}) =>
|
||||
ReportBoolValue(entityId: id, entityType: entityType, value: value);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,20 +6,27 @@ import 'package:invoiceninja_flutter/data/models/company_model.dart';
|
|||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||
import 'package:invoiceninja_flutter/redux/reports/reports_state.dart';
|
||||
import 'package:invoiceninja_flutter/ui/reports/reports_screen.dart';
|
||||
import 'package:invoiceninja_flutter/utils/formatting.dart';
|
||||
import 'package:memoize/memoize.dart';
|
||||
|
||||
enum DocumentReportFields {
|
||||
name,
|
||||
type,
|
||||
file_type,
|
||||
record_type,
|
||||
record_name,
|
||||
created_at,
|
||||
created_by,
|
||||
updated_at,
|
||||
}
|
||||
|
||||
var memoizedDocumentReport = memo6((
|
||||
var memoizedDocumentReport = memo7((
|
||||
UserCompanyEntity userCompany,
|
||||
ReportsUIState reportsUIState,
|
||||
BuiltMap<String, InvoiceEntity> invoiceMap,
|
||||
BuiltMap<String, ExpenseEntity> expenseMap,
|
||||
BuiltMap<String, ProjectEntity> projectMap,
|
||||
BuiltMap<String, VendorEntity> vendorMap,
|
||||
BuiltMap<String, UserEntity> userMap,
|
||||
) =>
|
||||
documentReport(
|
||||
userCompany,
|
||||
|
|
@ -28,6 +35,7 @@ var memoizedDocumentReport = memo6((
|
|||
expenseMap,
|
||||
projectMap,
|
||||
vendorMap,
|
||||
userMap,
|
||||
));
|
||||
|
||||
ReportResult documentReport(
|
||||
|
|
@ -37,6 +45,7 @@ ReportResult documentReport(
|
|||
BuiltMap<String, ExpenseEntity> expenseMap,
|
||||
BuiltMap<String, ProjectEntity> projectMap,
|
||||
BuiltMap<String, VendorEntity> vendorMap,
|
||||
BuiltMap<String, UserEntity> userMap,
|
||||
) {
|
||||
final List<List<ReportElement>> data = [];
|
||||
BuiltList<DocumentReportFields> columns;
|
||||
|
|
@ -48,8 +57,10 @@ ReportResult documentReport(
|
|||
: ReportSettingsEntity();
|
||||
|
||||
final defaultColumns = [
|
||||
DocumentReportFields.record_type,
|
||||
DocumentReportFields.record_name,
|
||||
DocumentReportFields.name,
|
||||
DocumentReportFields.type,
|
||||
DocumentReportFields.file_type,
|
||||
];
|
||||
|
||||
if (documentReportSettings.columns.isNotEmpty) {
|
||||
|
|
@ -60,7 +71,7 @@ ReportResult documentReport(
|
|||
columns = BuiltList(defaultColumns);
|
||||
}
|
||||
|
||||
List<ReportElement> _getRow(DocumentEntity document) {
|
||||
List<ReportElement> _getRow(BaseEntity entity, DocumentEntity document) {
|
||||
if (document.isDeleted ?? false) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -74,9 +85,24 @@ ReportResult documentReport(
|
|||
case DocumentReportFields.name:
|
||||
value = document.name;
|
||||
break;
|
||||
case DocumentReportFields.type:
|
||||
case DocumentReportFields.file_type:
|
||||
value = document.type;
|
||||
break;
|
||||
case DocumentReportFields.created_at:
|
||||
value = convertTimestampToDateString(document.createdAt);
|
||||
break;
|
||||
case DocumentReportFields.created_by:
|
||||
value = userMap[document.createdUserId]?.listDisplayName ?? '';
|
||||
break;
|
||||
case DocumentReportFields.record_name:
|
||||
value = entity.listDisplayName;
|
||||
break;
|
||||
case DocumentReportFields.record_type:
|
||||
value = entity.entityType;
|
||||
break;
|
||||
case DocumentReportFields.updated_at:
|
||||
value = convertTimestampToDateString(document.updatedAt);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!ReportResult.matchField(
|
||||
|
|
@ -89,11 +115,13 @@ ReportResult documentReport(
|
|||
}
|
||||
|
||||
if (value.runtimeType == bool) {
|
||||
row.add(document.getReportBool(value: value));
|
||||
row.add(entity.getReportBool(value: value));
|
||||
} else if (value.runtimeType == double || value.runtimeType == int) {
|
||||
row.add(document.getReportNumber(value: value));
|
||||
row.add(entity.getReportNumber(value: value));
|
||||
} else if (value.runtimeType == EntityType) {
|
||||
row.add(entity.getReportEntityType());
|
||||
} else {
|
||||
row.add(document.getReportString(value: value));
|
||||
row.add(entity.getReportString(value: value));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -102,7 +130,7 @@ ReportResult documentReport(
|
|||
|
||||
invoiceMap.forEach((invoiceId, invoice) {
|
||||
invoice.documents.forEach((document) {
|
||||
final row = _getRow(document);
|
||||
final row = _getRow(invoice, document);
|
||||
if (row != null) {
|
||||
data.add(row);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1278,6 +1278,24 @@ class ReportStringValue extends ReportElement {
|
|||
}
|
||||
}
|
||||
|
||||
class ReportEntityTypeValue extends ReportElement {
|
||||
ReportEntityTypeValue({
|
||||
dynamic value,
|
||||
EntityType entityType,
|
||||
String entityId,
|
||||
}) : super(value: value, entityType: entityType, entityId: entityId);
|
||||
|
||||
@override
|
||||
Widget renderWidget(BuildContext context, String column) {
|
||||
return Text(renderText(context, column));
|
||||
}
|
||||
|
||||
@override
|
||||
String renderText(BuildContext context, String column) {
|
||||
return AppLocalization.of(context).lookup('$value');
|
||||
}
|
||||
}
|
||||
|
||||
class ReportAgeValue extends ReportElement {
|
||||
ReportAgeValue({
|
||||
@required dynamic value,
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ class ReportsScreenVM {
|
|||
state.expenseState.map,
|
||||
state.projectState.map,
|
||||
state.vendorState.map,
|
||||
state.userState.map,
|
||||
);
|
||||
break;
|
||||
case kReportExpense:
|
||||
|
|
|
|||
Loading…
Reference in New Issue