Merge pull request #389 from bigcapitalhq/accounts-bank-transactions-demo-sheet

feat: add sample sheet to accounts and bank transactions
This commit is contained in:
Ahmed Bouhuolia
2024-03-28 00:57:58 +02:00
committed by GitHub
6 changed files with 94 additions and 39 deletions

View File

@@ -242,7 +242,7 @@
"account.field.normal.credit": "دائن", "account.field.normal.credit": "دائن",
"account.field.normal.debit": "مدين", "account.field.normal.debit": "مدين",
"account.field.type": "نوع الحساب", "account.field.type": "نوع الحساب",
"account.field.active": "Activity", "account.field.active": "Active",
"account.field.balance": "الرصيد", "account.field.balance": "الرصيد",
"account.field.created_at": "أنشئت في", "account.field.created_at": "أنشئت في",
"item.field.type": "نوع الصنف", "item.field.type": "نوع الصنف",

View File

@@ -241,7 +241,8 @@
"account.field.normal.credit": "Credit", "account.field.normal.credit": "Credit",
"account.field.normal.debit": "Debit", "account.field.normal.debit": "Debit",
"account.field.type": "Type", "account.field.type": "Type",
"account.field.active": "Activity", "account.field.active": "Active",
"account.field.currency": "Currency",
"account.field.balance": "Balance", "account.field.balance": "Balance",
"account.field.created_at": "Created at", "account.field.created_at": "Created at",
"item.field.type": "Item type", "item.field.type": "Item type",

View File

@@ -0,0 +1,50 @@
export const AccountsSampleData = [
{
'Account Name': 'Utilities Expense',
'Account Code': 9000,
Type: 'Expense',
Description: 'Omnis voluptatum consequatur.',
Active: 'T',
'Currency Code': '',
},
{
'Account Name': 'Unearned Revenue',
'Account Code': 9010,
Type: 'Long Term Liability',
Description: 'Autem odit voluptas nihil unde.',
Active: 'T',
'Currency Code': '',
},
{
'Account Name': 'Long-Term Debt',
'Account Code': 9020,
Type: 'Long Term Liability',
Description: 'In voluptas cumque exercitationem.',
Active: 'T',
'Currency Code': '',
},
{
'Account Name': 'Salaries and Wages Expense',
'Account Code': 9030,
Type: 'Expense',
Description: 'Assumenda aspernatur soluta aliquid perspiciatis quasi.',
Active: 'T',
'Currency Code': '',
},
{
'Account Name': 'Rental Income',
'Account Code': 9040,
Type: 'Income',
Description: 'Omnis possimus amet occaecati inventore.',
Active: 'T',
'Currency Code': '',
},
{
'Account Name': 'Paypal',
'Account Code': 9050,
Type: 'Bank',
Description: 'In voluptas cumque exercitationem.',
Active: 'T',
'Currency Code': '',
},
];

View File

@@ -3,6 +3,7 @@ import { Knex } from 'knex';
import { IAccountCreateDTO } from '@/interfaces'; import { IAccountCreateDTO } from '@/interfaces';
import { CreateAccount } from './CreateAccount'; import { CreateAccount } from './CreateAccount';
import { Importable } from '../Import/Importable'; import { Importable } from '../Import/Importable';
import { AccountsSampleData } from './AccountsImportable.SampleData';
@Service() @Service()
export class AccountsImportable extends Importable { export class AccountsImportable extends Importable {
@@ -35,11 +36,10 @@ export class AccountsImportable extends Importable {
return 1; return 1;
} }
public public sampleData(): any[] { /**
return [ * Retrieves the sample data that used to download accounts sample sheet.
{ */
public sampleData(): any[] {
} return AccountsSampleData;
]
} }
} }

View File

@@ -6,7 +6,7 @@ import { CreateUncategorizedTransaction } from './CreateUncategorizedTransaction
import { CreateUncategorizedTransactionDTO } from '@/interfaces'; import { CreateUncategorizedTransactionDTO } from '@/interfaces';
import { ImportableContext } from '../Import/interfaces'; import { ImportableContext } from '../Import/interfaces';
import HasTenancyService from '../Tenancy/TenancyService'; import HasTenancyService from '../Tenancy/TenancyService';
import { ImportSampleData } from './constants'; import { BankTransactionsSampleData } from './constants';
@Service() @Service()
export class UncategorizedTransactionsImportable extends Importable { export class UncategorizedTransactionsImportable extends Importable {
@@ -32,8 +32,8 @@ export class UncategorizedTransactionsImportable extends Importable {
/** /**
* Transformes the DTO before validating and importing. * Transformes the DTO before validating and importing.
* @param {CreateUncategorizedTransactionDTO} createDTO * @param {CreateUncategorizedTransactionDTO} createDTO
* @param {ImportableContext} context * @param {ImportableContext} context
* @returns {CreateUncategorizedTransactionDTO} * @returns {CreateUncategorizedTransactionDTO}
*/ */
public transform( public transform(
@@ -51,7 +51,7 @@ export class UncategorizedTransactionsImportable extends Importable {
* @returns {Record<string, any>[]} * @returns {Record<string, any>[]}
*/ */
public sampleData(): Record<string, any>[] { public sampleData(): Record<string, any>[] {
return ImportSampleData; return BankTransactionsSampleData;
} }
/** /**
@@ -76,9 +76,7 @@ export class UncategorizedTransactionsImportable extends Importable {
const { Account } = this.tenancy.models(tenantId); const { Account } = this.tenancy.models(tenantId);
if (params.accountId) { if (params.accountId) {
await Account.query() await Account.query().findById(params.accountId).throwIfNotFound({});
.findById(params.accountId)
.throwIfNotFound({});
} }
} }
} }

View File

@@ -11,8 +11,10 @@ export const ERRORS = {
ACCOUNT_HAS_ASSOCIATED_TRANSACTIONS: 'account_has_associated_transactions', ACCOUNT_HAS_ASSOCIATED_TRANSACTIONS: 'account_has_associated_transactions',
TRANSACTION_ALREADY_CATEGORIZED: 'TRANSACTION_ALREADY_CATEGORIZED', TRANSACTION_ALREADY_CATEGORIZED: 'TRANSACTION_ALREADY_CATEGORIZED',
TRANSACTION_ALREADY_UNCATEGORIZED: 'TRANSACTION_ALREADY_UNCATEGORIZED', TRANSACTION_ALREADY_UNCATEGORIZED: 'TRANSACTION_ALREADY_UNCATEGORIZED',
UNCATEGORIZED_TRANSACTION_TYPE_INVALID: 'UNCATEGORIZED_TRANSACTION_TYPE_INVALID', UNCATEGORIZED_TRANSACTION_TYPE_INVALID:
CANNOT_DELETE_TRANSACTION_CONVERTED_FROM_UNCATEGORIZED: 'CANNOT_DELETE_TRANSACTION_CONVERTED_FROM_UNCATEGORIZED' 'UNCATEGORIZED_TRANSACTION_TYPE_INVALID',
CANNOT_DELETE_TRANSACTION_CONVERTED_FROM_UNCATEGORIZED:
'CANNOT_DELETE_TRANSACTION_CONVERTED_FROM_UNCATEGORIZED',
}; };
export enum CASHFLOW_DIRECTION { export enum CASHFLOW_DIRECTION {
@@ -76,24 +78,28 @@ export interface ICashflowTransactionTypeMeta {
creditType: string[]; creditType: string[];
} }
export const BankTransactionsSampleData = [
export const ImportSampleData = [ [
{ {
Amount: 5000, Amount: '6,410.19',
Date: '2024-01-01', Date: '2024-03-26',
Payee: 'John Roberts', Payee: 'MacGyver and Sons',
Description: 'Cheque deposit', 'Reference No.': 'REF-1',
}, Description: 'Commodi quo labore.',
{ },
Amount: 5000, {
Date: '2024-01-01', Amount: '8,914.17',
Payee: 'John Roberts', Date: '2024-01-05',
Description: 'Cheque deposit', Payee: 'Eichmann - Bergnaum',
}, 'Reference No.': 'REF-1',
{ Description: 'Quia enim et.',
Amount: 5000, },
Date: '2024-01-01', {
Payee: 'John Roberts', Amount: '6,200.88',
Description: 'Cheque deposit', Date: '2024-02-17',
}, Payee: 'Luettgen, Mraz and Legros',
] 'Reference No.': 'REF-1',
Description: 'Occaecati consequuntur cum impedit illo.',
},
],
];