Reports
This commit is contained in:
parent
fe55e49fd9
commit
bb87adab60
|
|
@ -535,6 +535,7 @@ abstract class ClientEntity extends Object
|
|||
}
|
||||
|
||||
class ContactFields {
|
||||
static const String fullName = 'fullName';
|
||||
static const String firstName = 'firstName';
|
||||
static const String lastName = 'lastName';
|
||||
static const String email = 'email';
|
||||
|
|
@ -602,6 +603,9 @@ abstract class ContactEntity extends Object
|
|||
@BuiltValueField(wireName: 'custom_value4')
|
||||
String get customValue4;
|
||||
|
||||
@BuiltValueField(wireName: 'last_login')
|
||||
int get lastLogin;
|
||||
|
||||
String get fullName {
|
||||
return (firstName + ' ' + lastName).trim();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -526,6 +526,9 @@ class _$ContactEntitySerializer implements StructuredSerializer<ContactEntity> {
|
|||
'custom_value4',
|
||||
serializers.serialize(object.customValue4,
|
||||
specifiedType: const FullType(String)),
|
||||
'last_login',
|
||||
serializers.serialize(object.lastLogin,
|
||||
specifiedType: const FullType(int)),
|
||||
];
|
||||
if (object.password != null) {
|
||||
result
|
||||
|
|
@ -644,6 +647,10 @@ class _$ContactEntitySerializer implements StructuredSerializer<ContactEntity> {
|
|||
result.customValue4 = serializers.deserialize(value,
|
||||
specifiedType: const FullType(String)) as String;
|
||||
break;
|
||||
case 'last_login':
|
||||
result.lastLogin = serializers.deserialize(value,
|
||||
specifiedType: const FullType(int)) as int;
|
||||
break;
|
||||
case 'isChanged':
|
||||
result.isChanged = serializers.deserialize(value,
|
||||
specifiedType: const FullType(bool)) as bool;
|
||||
|
|
@ -1579,6 +1586,8 @@ class _$ContactEntity extends ContactEntity {
|
|||
@override
|
||||
final String customValue4;
|
||||
@override
|
||||
final int lastLogin;
|
||||
@override
|
||||
final bool isChanged;
|
||||
@override
|
||||
final int createdAt;
|
||||
|
|
@ -1611,6 +1620,7 @@ class _$ContactEntity extends ContactEntity {
|
|||
this.customValue2,
|
||||
this.customValue3,
|
||||
this.customValue4,
|
||||
this.lastLogin,
|
||||
this.isChanged,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
|
|
@ -1653,6 +1663,9 @@ class _$ContactEntity extends ContactEntity {
|
|||
if (customValue4 == null) {
|
||||
throw new BuiltValueNullFieldError('ContactEntity', 'customValue4');
|
||||
}
|
||||
if (lastLogin == null) {
|
||||
throw new BuiltValueNullFieldError('ContactEntity', 'lastLogin');
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
@ -1678,6 +1691,7 @@ class _$ContactEntity extends ContactEntity {
|
|||
customValue2 == other.customValue2 &&
|
||||
customValue3 == other.customValue3 &&
|
||||
customValue4 == other.customValue4 &&
|
||||
lastLogin == other.lastLogin &&
|
||||
isChanged == other.isChanged &&
|
||||
createdAt == other.createdAt &&
|
||||
updatedAt == other.updatedAt &&
|
||||
|
|
@ -1708,18 +1722,18 @@ class _$ContactEntity extends ContactEntity {
|
|||
$jc(
|
||||
$jc(
|
||||
$jc(
|
||||
$jc($jc(0, firstName.hashCode),
|
||||
lastName.hashCode),
|
||||
email.hashCode),
|
||||
password.hashCode),
|
||||
phone.hashCode),
|
||||
contactKey.hashCode),
|
||||
isPrimary.hashCode),
|
||||
sendInvoice.hashCode),
|
||||
customValue1.hashCode),
|
||||
customValue2.hashCode),
|
||||
customValue3.hashCode),
|
||||
customValue4.hashCode),
|
||||
$jc($jc($jc(0, firstName.hashCode), lastName.hashCode),
|
||||
email.hashCode),
|
||||
password.hashCode),
|
||||
phone.hashCode),
|
||||
contactKey.hashCode),
|
||||
isPrimary.hashCode),
|
||||
sendInvoice.hashCode),
|
||||
customValue1.hashCode),
|
||||
customValue2.hashCode),
|
||||
customValue3.hashCode),
|
||||
customValue4.hashCode),
|
||||
lastLogin.hashCode),
|
||||
isChanged.hashCode),
|
||||
createdAt.hashCode),
|
||||
updatedAt.hashCode),
|
||||
|
|
@ -1745,6 +1759,7 @@ class _$ContactEntity extends ContactEntity {
|
|||
..add('customValue2', customValue2)
|
||||
..add('customValue3', customValue3)
|
||||
..add('customValue4', customValue4)
|
||||
..add('lastLogin', lastLogin)
|
||||
..add('isChanged', isChanged)
|
||||
..add('createdAt', createdAt)
|
||||
..add('updatedAt', updatedAt)
|
||||
|
|
@ -1809,6 +1824,10 @@ class ContactEntityBuilder
|
|||
String get customValue4 => _$this._customValue4;
|
||||
set customValue4(String customValue4) => _$this._customValue4 = customValue4;
|
||||
|
||||
int _lastLogin;
|
||||
int get lastLogin => _$this._lastLogin;
|
||||
set lastLogin(int lastLogin) => _$this._lastLogin = lastLogin;
|
||||
|
||||
bool _isChanged;
|
||||
bool get isChanged => _$this._isChanged;
|
||||
set isChanged(bool isChanged) => _$this._isChanged = isChanged;
|
||||
|
|
@ -1859,6 +1878,7 @@ class ContactEntityBuilder
|
|||
_customValue2 = _$v.customValue2;
|
||||
_customValue3 = _$v.customValue3;
|
||||
_customValue4 = _$v.customValue4;
|
||||
_lastLogin = _$v.lastLogin;
|
||||
_isChanged = _$v.isChanged;
|
||||
_createdAt = _$v.createdAt;
|
||||
_updatedAt = _$v.updatedAt;
|
||||
|
|
@ -1901,6 +1921,7 @@ class ContactEntityBuilder
|
|||
customValue2: customValue2,
|
||||
customValue3: customValue3,
|
||||
customValue4: customValue4,
|
||||
lastLogin: lastLogin,
|
||||
isChanged: isChanged,
|
||||
createdAt: createdAt,
|
||||
updatedAt: updatedAt,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class ClientPresenter extends EntityPresenter {
|
|||
ClientFields.contactEmail,
|
||||
ClientFields.idNumber,
|
||||
EntityFields.createdAt,
|
||||
//ClientFields.lastLogin, // TODO implement
|
||||
//ClientFields.contactLastLogin,
|
||||
ClientFields.balance,
|
||||
EntityFields.state,
|
||||
];
|
||||
|
|
|
|||
|
|
@ -9,6 +9,51 @@ import 'package:invoiceninja_flutter/utils/dates.dart';
|
|||
import 'package:invoiceninja_flutter/utils/formatting.dart';
|
||||
import 'package:memoize/memoize.dart';
|
||||
|
||||
class ClientReportFields {
|
||||
static const String clientId = 'client_id';
|
||||
static const String name = 'name';
|
||||
static const String website = 'website';
|
||||
static const String privateNotes = 'private_notes';
|
||||
static const String industry = 'industry';
|
||||
static const String size = 'size';
|
||||
static const String address1 = 'address1';
|
||||
static const String address2 = 'address2';
|
||||
static const String city = 'city';
|
||||
static const String state = 'state';
|
||||
static const String postCode = 'postal_code';
|
||||
static const String phone = 'phone';
|
||||
static const String country = 'country';
|
||||
static const String shippingAddress1 = 'shipping_address1';
|
||||
static const String shippingAddress2 = 'shipping_address2';
|
||||
static const String shippingCity = 'shipping_city';
|
||||
static const String shippingState = 'shipping_state';
|
||||
static const String shippingPostalCode = 'shipping_postal_code';
|
||||
static const String shippingCountry = 'shipping_country';
|
||||
static const String customValue1 = 'custom_value1';
|
||||
static const String customValue2 = 'custom_value2';
|
||||
static const String customValue3 = 'custom_value3';
|
||||
static const String customValue4 = 'custom_value4';
|
||||
static const String createdBy = 'created_by';
|
||||
static const String assignedTo = 'assigned_to';
|
||||
static const String balance = 'balance';
|
||||
static const String creditBalance = 'credit_balance';
|
||||
static const String paidToDate = 'paid_to_date';
|
||||
static const String idNumber = 'id_number';
|
||||
static const String vatNumber = 'vat_number';
|
||||
static const String createdAt = 'created_at';
|
||||
static const String updatedAt = 'updated_at';
|
||||
static const String contactId = 'contact_id';
|
||||
static const String contactFirstName = 'contact_first_name';
|
||||
static const String contactLastName = 'contact_last_name';
|
||||
static const String contactEmail = 'contact_email';
|
||||
static const String contactPhone = 'contact_phone';
|
||||
static const String contactCustomValue1 = 'contact_custom_value1';
|
||||
static const String contactCustomValue2 = 'contact_custom_value2';
|
||||
static const String contactCustomValue3 = 'contact_custom_value3';
|
||||
static const String contactCustomValue4 = 'contact_custom_value4';
|
||||
static const String contactLastLogin = 'contact_last_login';
|
||||
}
|
||||
|
||||
var memoizedClientReport = memo3((UserCompanyEntity userCompany,
|
||||
ReportsUIState reportsUIState,
|
||||
BuiltMap<String, ClientEntity> clientMap) =>
|
||||
|
|
@ -29,12 +74,14 @@ ReportResult clientReport(UserCompanyEntity userCompany,
|
|||
columns = clientReportSettings.columns;
|
||||
} else {
|
||||
columns = BuiltList(<String>[
|
||||
ClientFields.name,
|
||||
ClientReportFields.name,
|
||||
ClientReportFields.idNumber,
|
||||
]);
|
||||
}
|
||||
|
||||
for (var clientId in clientMap.keys) {
|
||||
final client = clientMap[clientId];
|
||||
final contact = client.primaryContact;
|
||||
if (client.isDeleted) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -47,44 +94,41 @@ ReportResult clientReport(UserCompanyEntity userCompany,
|
|||
double amount;
|
||||
|
||||
switch (column) {
|
||||
case ClientFields.name:
|
||||
case ClientReportFields.name:
|
||||
value = client.name;
|
||||
break;
|
||||
case ClientFields.idNumber:
|
||||
case ClientReportFields.idNumber:
|
||||
value = client.idNumber;
|
||||
break;
|
||||
case ClientFields.vatNumber:
|
||||
case ClientReportFields.vatNumber:
|
||||
value = client.vatNumber;
|
||||
break;
|
||||
case ClientFields.state:
|
||||
case ClientReportFields.state:
|
||||
value = client.state;
|
||||
break;
|
||||
case ClientFields.createdAt:
|
||||
case ClientReportFields.createdAt:
|
||||
value = convertTimestampToDateString(client.createdAt);
|
||||
break;
|
||||
case ClientFields.assignedTo:
|
||||
case ClientReportFields.assignedTo:
|
||||
value = userCompany
|
||||
.company.userMap[client.assignedUserId]?.listDisplayName ??
|
||||
'';
|
||||
break;
|
||||
case ClientFields.assignedToId:
|
||||
value = client.assignedUserId;
|
||||
break;
|
||||
case ClientFields.createdBy:
|
||||
case ClientReportFields.createdBy:
|
||||
value = userCompany
|
||||
.company.userMap[client.createdUserId]?.listDisplayName ??
|
||||
'';
|
||||
break;
|
||||
case ClientFields.createdById:
|
||||
value = client.createdUserId;
|
||||
break;
|
||||
case ClientFields.updatedAt:
|
||||
case ClientReportFields.updatedAt:
|
||||
value = convertTimestampToDateString(client.updatedAt);
|
||||
break;
|
||||
case ClientFields.balance:
|
||||
case ClientReportFields.contactLastLogin:
|
||||
value = convertTimestampToDateString(contact.lastLogin);
|
||||
break;
|
||||
case ClientReportFields.balance:
|
||||
amount = client.balance;
|
||||
break;
|
||||
case ClientFields.paidToDate:
|
||||
case ClientReportFields.paidToDate:
|
||||
amount = client.paidToDate;
|
||||
break;
|
||||
}
|
||||
|
|
@ -163,19 +207,26 @@ ReportResult clientReport(UserCompanyEntity userCompany,
|
|||
|
||||
return ReportResult(
|
||||
allColumns: [
|
||||
ClientFields.name,
|
||||
ClientFields.createdBy,
|
||||
ClientFields.assignedTo,
|
||||
ClientFields.balance,
|
||||
ClientFields.paidToDate,
|
||||
ClientFields.idNumber,
|
||||
ClientFields.vatNumber,
|
||||
ClientFields.state,
|
||||
ClientFields.createdAt,
|
||||
ClientFields.updatedAt,
|
||||
ClientFields.clientId,
|
||||
ClientFields.assignedToId,
|
||||
ClientFields.createdById,
|
||||
ClientReportFields.clientId,
|
||||
ClientReportFields.name,
|
||||
ClientReportFields.createdBy,
|
||||
ClientReportFields.assignedTo,
|
||||
ClientReportFields.balance,
|
||||
ClientReportFields.paidToDate,
|
||||
ClientReportFields.idNumber,
|
||||
ClientReportFields.vatNumber,
|
||||
ClientReportFields.state,
|
||||
ClientReportFields.createdAt,
|
||||
ClientReportFields.updatedAt,
|
||||
ClientReportFields.contactId,
|
||||
ClientReportFields.contactFirstName,
|
||||
ClientReportFields.contactLastName,
|
||||
ClientReportFields.contactEmail,
|
||||
ClientReportFields.contactPhone,
|
||||
ClientReportFields.contactCustomValue1,
|
||||
ClientReportFields.contactCustomValue2,
|
||||
ClientReportFields.contactCustomValue3,
|
||||
ClientReportFields.contactCustomValue4,
|
||||
],
|
||||
columns: columns.toList(),
|
||||
data: data,
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ abstract class LocaleCodeAware {
|
|||
mixin LocalizationsProvider on LocaleCodeAware {
|
||||
static final Map<String, Map<String, String>> _localizedValues = {
|
||||
'en': {
|
||||
'client_id': 'Client Id',
|
||||
'assigned_to': 'Assigned To',
|
||||
'created_by': 'Created By',
|
||||
'assigned_to_id': 'Assigned To Id',
|
||||
|
|
@ -692,8 +693,8 @@ mixin LocalizationsProvider on LocaleCodeAware {
|
|||
'settings': 'Settings',
|
||||
'language': 'Language',
|
||||
'currency': 'Currency',
|
||||
'created_at': 'Created',
|
||||
'updated_at': 'Updated',
|
||||
'created_at': 'Created At',
|
||||
'updated_at': 'Updated At',
|
||||
'tax': 'Tax',
|
||||
'please_enter_an_invoice_number': 'Please enter an invoice number',
|
||||
'please_enter_a_quote_number': 'Please enter a quote number',
|
||||
|
|
@ -16012,6 +16013,8 @@ mixin LocalizationsProvider on LocaleCodeAware {
|
|||
|
||||
String get createdById => _localizedValues[localeCode]['created_by_id'];
|
||||
|
||||
String get clientId => _localizedValues[localeCode]['client_id'];
|
||||
|
||||
String lookup(String key) {
|
||||
final lookupKey = toSnakeCase(key);
|
||||
return _localizedValues[localeCode][lookupKey] ??
|
||||
|
|
|
|||
Loading…
Reference in New Issue