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 getReportString({String value}) =>
|
||||||
ReportStringValue(entityId: id, entityType: entityType, value: value);
|
ReportStringValue(entityId: id, entityType: entityType, value: value);
|
||||||
|
|
||||||
|
ReportEntityTypeValue getReportEntityType() =>
|
||||||
|
ReportEntityTypeValue(entityId: id, entityType: entityType, value: entityType);
|
||||||
|
|
||||||
ReportBoolValue getReportBool({bool value}) =>
|
ReportBoolValue getReportBool({bool value}) =>
|
||||||
ReportBoolValue(entityId: id, entityType: entityType, value: 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/data/models/models.dart';
|
||||||
import 'package:invoiceninja_flutter/redux/reports/reports_state.dart';
|
import 'package:invoiceninja_flutter/redux/reports/reports_state.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/reports/reports_screen.dart';
|
import 'package:invoiceninja_flutter/ui/reports/reports_screen.dart';
|
||||||
|
import 'package:invoiceninja_flutter/utils/formatting.dart';
|
||||||
import 'package:memoize/memoize.dart';
|
import 'package:memoize/memoize.dart';
|
||||||
|
|
||||||
enum DocumentReportFields {
|
enum DocumentReportFields {
|
||||||
name,
|
name,
|
||||||
type,
|
file_type,
|
||||||
|
record_type,
|
||||||
|
record_name,
|
||||||
|
created_at,
|
||||||
|
created_by,
|
||||||
|
updated_at,
|
||||||
}
|
}
|
||||||
|
|
||||||
var memoizedDocumentReport = memo6((
|
var memoizedDocumentReport = memo7((
|
||||||
UserCompanyEntity userCompany,
|
UserCompanyEntity userCompany,
|
||||||
ReportsUIState reportsUIState,
|
ReportsUIState reportsUIState,
|
||||||
BuiltMap<String, InvoiceEntity> invoiceMap,
|
BuiltMap<String, InvoiceEntity> invoiceMap,
|
||||||
BuiltMap<String, ExpenseEntity> expenseMap,
|
BuiltMap<String, ExpenseEntity> expenseMap,
|
||||||
BuiltMap<String, ProjectEntity> projectMap,
|
BuiltMap<String, ProjectEntity> projectMap,
|
||||||
BuiltMap<String, VendorEntity> vendorMap,
|
BuiltMap<String, VendorEntity> vendorMap,
|
||||||
|
BuiltMap<String, UserEntity> userMap,
|
||||||
) =>
|
) =>
|
||||||
documentReport(
|
documentReport(
|
||||||
userCompany,
|
userCompany,
|
||||||
|
|
@ -28,6 +35,7 @@ var memoizedDocumentReport = memo6((
|
||||||
expenseMap,
|
expenseMap,
|
||||||
projectMap,
|
projectMap,
|
||||||
vendorMap,
|
vendorMap,
|
||||||
|
userMap,
|
||||||
));
|
));
|
||||||
|
|
||||||
ReportResult documentReport(
|
ReportResult documentReport(
|
||||||
|
|
@ -37,6 +45,7 @@ ReportResult documentReport(
|
||||||
BuiltMap<String, ExpenseEntity> expenseMap,
|
BuiltMap<String, ExpenseEntity> expenseMap,
|
||||||
BuiltMap<String, ProjectEntity> projectMap,
|
BuiltMap<String, ProjectEntity> projectMap,
|
||||||
BuiltMap<String, VendorEntity> vendorMap,
|
BuiltMap<String, VendorEntity> vendorMap,
|
||||||
|
BuiltMap<String, UserEntity> userMap,
|
||||||
) {
|
) {
|
||||||
final List<List<ReportElement>> data = [];
|
final List<List<ReportElement>> data = [];
|
||||||
BuiltList<DocumentReportFields> columns;
|
BuiltList<DocumentReportFields> columns;
|
||||||
|
|
@ -48,8 +57,10 @@ ReportResult documentReport(
|
||||||
: ReportSettingsEntity();
|
: ReportSettingsEntity();
|
||||||
|
|
||||||
final defaultColumns = [
|
final defaultColumns = [
|
||||||
|
DocumentReportFields.record_type,
|
||||||
|
DocumentReportFields.record_name,
|
||||||
DocumentReportFields.name,
|
DocumentReportFields.name,
|
||||||
DocumentReportFields.type,
|
DocumentReportFields.file_type,
|
||||||
];
|
];
|
||||||
|
|
||||||
if (documentReportSettings.columns.isNotEmpty) {
|
if (documentReportSettings.columns.isNotEmpty) {
|
||||||
|
|
@ -60,7 +71,7 @@ ReportResult documentReport(
|
||||||
columns = BuiltList(defaultColumns);
|
columns = BuiltList(defaultColumns);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ReportElement> _getRow(DocumentEntity document) {
|
List<ReportElement> _getRow(BaseEntity entity, DocumentEntity document) {
|
||||||
if (document.isDeleted ?? false) {
|
if (document.isDeleted ?? false) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
@ -74,9 +85,24 @@ ReportResult documentReport(
|
||||||
case DocumentReportFields.name:
|
case DocumentReportFields.name:
|
||||||
value = document.name;
|
value = document.name;
|
||||||
break;
|
break;
|
||||||
case DocumentReportFields.type:
|
case DocumentReportFields.file_type:
|
||||||
value = document.type;
|
value = document.type;
|
||||||
break;
|
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(
|
if (!ReportResult.matchField(
|
||||||
|
|
@ -89,11 +115,13 @@ ReportResult documentReport(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value.runtimeType == bool) {
|
if (value.runtimeType == bool) {
|
||||||
row.add(document.getReportBool(value: value));
|
row.add(entity.getReportBool(value: value));
|
||||||
} else if (value.runtimeType == double || value.runtimeType == int) {
|
} 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 {
|
} else {
|
||||||
row.add(document.getReportString(value: value));
|
row.add(entity.getReportString(value: value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -102,7 +130,7 @@ ReportResult documentReport(
|
||||||
|
|
||||||
invoiceMap.forEach((invoiceId, invoice) {
|
invoiceMap.forEach((invoiceId, invoice) {
|
||||||
invoice.documents.forEach((document) {
|
invoice.documents.forEach((document) {
|
||||||
final row = _getRow(document);
|
final row = _getRow(invoice, document);
|
||||||
if (row != null) {
|
if (row != null) {
|
||||||
data.add(row);
|
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 {
|
class ReportAgeValue extends ReportElement {
|
||||||
ReportAgeValue({
|
ReportAgeValue({
|
||||||
@required dynamic value,
|
@required dynamic value,
|
||||||
|
|
|
||||||
|
|
@ -114,6 +114,7 @@ class ReportsScreenVM {
|
||||||
state.expenseState.map,
|
state.expenseState.map,
|
||||||
state.projectState.map,
|
state.projectState.map,
|
||||||
state.vendorState.map,
|
state.vendorState.map,
|
||||||
|
state.userState.map,
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case kReportExpense:
|
case kReportExpense:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue