fixed ledger account listing + quotation listing
This commit is contained in:
@@ -14,8 +14,10 @@ class LedgerAccountDTO {
|
||||
final String organizationRef;
|
||||
final String? ownerRef;
|
||||
final String accountCode;
|
||||
@JsonKey(fromJson: ledgerAccountTypeFromJson, toJson: ledgerAccountTypeToJson)
|
||||
final LedgerAccountTypeDTO accountType;
|
||||
final String currency;
|
||||
@JsonKey(fromJson: ledgerAccountStatusFromJson, toJson: ledgerAccountStatusToJson)
|
||||
final LedgerAccountStatusDTO status;
|
||||
final bool allowNegative;
|
||||
final bool isSettlement;
|
||||
@@ -23,7 +25,7 @@ class LedgerAccountDTO {
|
||||
final DateTime? createdAt;
|
||||
final DateTime? updatedAt;
|
||||
|
||||
final DescribableDTO describable;
|
||||
final DescribableDTO? describable;
|
||||
|
||||
final LedgerBalanceDTO? balance;
|
||||
|
||||
@@ -40,7 +42,7 @@ class LedgerAccountDTO {
|
||||
this.metadata,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
required this.describable,
|
||||
this.describable,
|
||||
this.balance,
|
||||
});
|
||||
|
||||
|
||||
@@ -11,3 +11,34 @@ enum LedgerAccountStatusDTO {
|
||||
@JsonValue('frozen')
|
||||
frozen,
|
||||
}
|
||||
|
||||
LedgerAccountStatusDTO ledgerAccountStatusFromJson(Object? value) {
|
||||
final raw = value?.toString() ?? '';
|
||||
var normalized = raw.trim().toLowerCase();
|
||||
const prefix = 'account_status_';
|
||||
if (normalized.startsWith(prefix)) {
|
||||
normalized = normalized.substring(prefix.length);
|
||||
}
|
||||
switch (normalized) {
|
||||
case 'active':
|
||||
return LedgerAccountStatusDTO.active;
|
||||
case 'frozen':
|
||||
return LedgerAccountStatusDTO.frozen;
|
||||
case 'unspecified':
|
||||
case '':
|
||||
return LedgerAccountStatusDTO.unspecified;
|
||||
default:
|
||||
return LedgerAccountStatusDTO.unspecified;
|
||||
}
|
||||
}
|
||||
|
||||
String ledgerAccountStatusToJson(LedgerAccountStatusDTO value) {
|
||||
switch (value) {
|
||||
case LedgerAccountStatusDTO.active:
|
||||
return 'active';
|
||||
case LedgerAccountStatusDTO.frozen:
|
||||
return 'frozen';
|
||||
case LedgerAccountStatusDTO.unspecified:
|
||||
return 'unspecified';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,3 +17,42 @@ enum LedgerAccountTypeDTO {
|
||||
@JsonValue('expense')
|
||||
expense,
|
||||
}
|
||||
|
||||
LedgerAccountTypeDTO ledgerAccountTypeFromJson(Object? value) {
|
||||
final raw = value?.toString() ?? '';
|
||||
var normalized = raw.trim().toLowerCase();
|
||||
const prefix = 'account_type_';
|
||||
if (normalized.startsWith(prefix)) {
|
||||
normalized = normalized.substring(prefix.length);
|
||||
}
|
||||
switch (normalized) {
|
||||
case 'asset':
|
||||
return LedgerAccountTypeDTO.asset;
|
||||
case 'liability':
|
||||
return LedgerAccountTypeDTO.liability;
|
||||
case 'revenue':
|
||||
return LedgerAccountTypeDTO.revenue;
|
||||
case 'expense':
|
||||
return LedgerAccountTypeDTO.expense;
|
||||
case 'unspecified':
|
||||
case '':
|
||||
return LedgerAccountTypeDTO.unspecified;
|
||||
default:
|
||||
return LedgerAccountTypeDTO.unspecified;
|
||||
}
|
||||
}
|
||||
|
||||
String ledgerAccountTypeToJson(LedgerAccountTypeDTO value) {
|
||||
switch (value) {
|
||||
case LedgerAccountTypeDTO.asset:
|
||||
return 'asset';
|
||||
case LedgerAccountTypeDTO.liability:
|
||||
return 'liability';
|
||||
case LedgerAccountTypeDTO.revenue:
|
||||
return 'revenue';
|
||||
case LedgerAccountTypeDTO.expense:
|
||||
return 'expense';
|
||||
case LedgerAccountTypeDTO.unspecified:
|
||||
return 'unspecified';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user