Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add sample sheet to accounts and bank transactions #389

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/server/resources/locales/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@
"account.field.normal.credit": "دائن",
"account.field.normal.debit": "مدين",
"account.field.type": "نوع الحساب",
"account.field.active": "Activity",
"account.field.active": "Active",
"account.field.balance": "الرصيد",
"account.field.created_at": "أنشئت في",
"item.field.type": "نوع الصنف",
Expand Down
3 changes: 2 additions & 1 deletion packages/server/resources/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@
"account.field.normal.credit": "Credit",
"account.field.normal.debit": "Debit",
"account.field.type": "Type",
"account.field.active": "Activity",
"account.field.active": "Active",
"account.field.currency": "Currency",
"account.field.balance": "Balance",
"account.field.created_at": "Created at",
"item.field.type": "Item type",
Expand Down
Original file line number Diff line number Diff line change
@@ -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': '',
},
];
12 changes: 6 additions & 6 deletions packages/server/src/services/Accounts/AccountsImportable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Knex } from 'knex';
import { IAccountCreateDTO } from '@/interfaces';
import { CreateAccount } from './CreateAccount';
import { Importable } from '../Import/Importable';
import { AccountsSampleData } from './AccountsImportable.SampleData';

@Service()
export class AccountsImportable extends Importable {
Expand Down Expand Up @@ -35,11 +36,10 @@ export class AccountsImportable extends Importable {
return 1;
}

public public sampleData(): any[] {
return [
{

}
]
/**
* Retrieves the sample data that used to download accounts sample sheet.
*/
public sampleData(): any[] {
return AccountsSampleData;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { CreateUncategorizedTransaction } from './CreateUncategorizedTransaction
import { CreateUncategorizedTransactionDTO } from '@/interfaces';
import { ImportableContext } from '../Import/interfaces';
import HasTenancyService from '../Tenancy/TenancyService';
import { ImportSampleData } from './constants';
import { BankTransactionsSampleData } from './constants';

@Service()
export class UncategorizedTransactionsImportable extends Importable {
Expand All @@ -32,8 +32,8 @@ export class UncategorizedTransactionsImportable extends Importable {

/**
* Transformes the DTO before validating and importing.
* @param {CreateUncategorizedTransactionDTO} createDTO
* @param {ImportableContext} context
* @param {CreateUncategorizedTransactionDTO} createDTO
* @param {ImportableContext} context
* @returns {CreateUncategorizedTransactionDTO}
*/
public transform(
Expand All @@ -51,7 +51,7 @@ export class UncategorizedTransactionsImportable extends Importable {
* @returns {Record<string, any>[]}
*/
public sampleData(): Record<string, any>[] {
return ImportSampleData;
return BankTransactionsSampleData;
}

/**
Expand All @@ -76,9 +76,7 @@ export class UncategorizedTransactionsImportable extends Importable {
const { Account } = this.tenancy.models(tenantId);

if (params.accountId) {
await Account.query()
.findById(params.accountId)
.throwIfNotFound({});
await Account.query().findById(params.accountId).throwIfNotFound({});
}
}
}
}
52 changes: 29 additions & 23 deletions packages/server/src/services/Cashflow/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ export const ERRORS = {
ACCOUNT_HAS_ASSOCIATED_TRANSACTIONS: 'account_has_associated_transactions',
TRANSACTION_ALREADY_CATEGORIZED: 'TRANSACTION_ALREADY_CATEGORIZED',
TRANSACTION_ALREADY_UNCATEGORIZED: 'TRANSACTION_ALREADY_UNCATEGORIZED',
UNCATEGORIZED_TRANSACTION_TYPE_INVALID: 'UNCATEGORIZED_TRANSACTION_TYPE_INVALID',
CANNOT_DELETE_TRANSACTION_CONVERTED_FROM_UNCATEGORIZED: 'CANNOT_DELETE_TRANSACTION_CONVERTED_FROM_UNCATEGORIZED'
UNCATEGORIZED_TRANSACTION_TYPE_INVALID:
'UNCATEGORIZED_TRANSACTION_TYPE_INVALID',
CANNOT_DELETE_TRANSACTION_CONVERTED_FROM_UNCATEGORIZED:
'CANNOT_DELETE_TRANSACTION_CONVERTED_FROM_UNCATEGORIZED',
};

export enum CASHFLOW_DIRECTION {
Expand Down Expand Up @@ -76,24 +78,28 @@ export interface ICashflowTransactionTypeMeta {
creditType: string[];
}


export const ImportSampleData = [
{
Amount: 5000,
Date: '2024-01-01',
Payee: 'John Roberts',
Description: 'Cheque deposit',
},
{
Amount: 5000,
Date: '2024-01-01',
Payee: 'John Roberts',
Description: 'Cheque deposit',
},
{
Amount: 5000,
Date: '2024-01-01',
Payee: 'John Roberts',
Description: 'Cheque deposit',
},
]
export const BankTransactionsSampleData = [
[
{
Amount: '6,410.19',
Date: '2024-03-26',
Payee: 'MacGyver and Sons',
'Reference No.': 'REF-1',
Description: 'Commodi quo labore.',
},
{
Amount: '8,914.17',
Date: '2024-01-05',
Payee: 'Eichmann - Bergnaum',
'Reference No.': 'REF-1',
Description: 'Quia enim et.',
},
{
Amount: '6,200.88',
Date: '2024-02-17',
Payee: 'Luettgen, Mraz and Legros',
'Reference No.': 'REF-1',
Description: 'Occaecati consequuntur cum impedit illo.',
},
],
];
Loading