feat: Inventory item details report.

feat: Cash flow statement report.
This commit is contained in:
a.bouhuolia
2021-05-31 13:17:02 +02:00
parent 256d915f06
commit d47633b8ea
80 changed files with 5474 additions and 376 deletions

View File

@@ -33,7 +33,13 @@ export interface IAccountsTransactionsFilter {
}
export interface IAccountTransaction {
credit: number;
debit: number;
accountId: number;
contactId: number;
date: string|Date;
referenceNumber: string;
account: IAccount;
}
export interface IAccountResponse extends IAccount {

View File

@@ -0,0 +1,190 @@
import { INumberFormatQuery } from './FinancialStatements';
import { IAccount } from './Account';
import { ILedger } from './Ledger';
import { ITableRow } from './Table';
export interface ICashFlowStatementQuery {
fromDate: Date|string;
toDate: Date|string;
displayColumnsBy: string;
displayColumnsType: string;
noneZero: boolean;
noneTransactions: boolean;
numberFormat: INumberFormatQuery;
basis: string;
}
export interface ICashFlowStatementTotal {
amount: number;
formattedAmount: string;
currencyCode: string;
}
export interface ICashFlowStatementTotalPeriod {
fromDate: Date;
toDate: Date;
total: ICashFlowStatementTotal;
}
export interface ICashFlowStatementCommonSection {
id: string;
label: string;
total: ICashFlowStatementTotal;
footerLabel?: string;
}
export interface ICashFlowStatementAccountMeta {
id: number;
label: string;
code: string;
total: ICashFlowStatementTotal;
accountType: string;
adjusmentType: string;
sectionType: ICashFlowStatementSectionType.ACCOUNT;
}
export enum ICashFlowStatementSectionType {
REGULAR = 'REGULAR',
AGGREGATE = 'AGGREGATE',
NET_INCOME = 'NET_INCOME',
ACCOUNT = 'ACCOUNT',
ACCOUNTS = 'ACCOUNTS',
TOTAL = 'TOTAL',
CASH_AT_BEGINNING = 'CASH_AT_BEGINNING',
}
export interface ICashFlowStatementAccountSection
extends ICashFlowStatementCommonSection {
sectionType: ICashFlowStatementSectionType.ACCOUNTS;
children: ICashFlowStatementAccountMeta[];
total: ICashFlowStatementTotal;
}
export interface ICashFlowStatementNetIncomeSection
extends ICashFlowStatementCommonSection {
sectionType: ICashFlowStatementSectionType.NET_INCOME;
}
export interface ICashFlowStatementTotalSection
extends ICashFlowStatementCommonSection {
sectionType: ICashFlowStatementSectionType.TOTAL;
}
export type ICashFlowStatementSection =
| ICashFlowStatementAccountSection
| ICashFlowStatementNetIncomeSection
| ICashFlowStatementTotalSection
| ICashFlowStatementCommonSection;
export interface ICashFlowStatementColumn {}
export interface ICashFlowStatementMeta {}
export interface ICashFlowStatementService {
cashFlow(
tenantId: number,
query: ICashFlowStatementQuery
): Promise<ICashFlowStatement>;
}
// CASH FLOW SCHEMA TYPES.
// -----------------------------
export interface ICashFlowSchemaCommonSection {
id: string;
label: string;
children: ICashFlowSchemaSection[];
footerLabel?: string;
}
export enum CASH_FLOW_ACCOUNT_RELATION {
MINES = 'mines',
PLUS = 'plus',
}
export enum CASH_FLOW_SECTION_ID {
NET_INCOME = 'NET_INCOME',
OPERATING = 'OPERATING',
OPERATING_ACCOUNTS = 'OPERATING_ACCOUNTS',
INVESTMENT = 'INVESTMENT',
FINANCIAL = 'FINANCIAL',
NET_OPERATING = 'NET_OPERATING',
NET_INVESTMENT = 'NET_INVESTMENT',
NET_FINANCIAL = 'NET_FINANCIAL',
CASH_BEGINNING_PERIOD = 'CASH_BEGINNING_PERIOD',
CASH_END_PERIOD = 'CASH_END_PERIOD',
NET_CASH_INCREASE = 'NET_CASH_INCREASE',
}
export interface ICashFlowSchemaAccountsSection
extends ICashFlowSchemaCommonSection {
sectionType: ICashFlowStatementSectionType.ACCOUNT;
accountsRelations: ICashFlowSchemaAccountRelation[];
}
export interface ICashFlowSchemaTotalSection
extends ICashFlowStatementCommonSection {
sectionType: ICashFlowStatementSectionType.TOTAL;
equation: string;
}
export type ICashFlowSchemaSection =
| ICashFlowSchemaAccountsSection
| ICashFlowSchemaTotalSection
| ICashFlowSchemaCommonSection;
export type ICashFlowStatementData = ICashFlowSchemaSection[];
export interface ICashFlowSchemaAccountRelation {
type: string;
direction: CASH_FLOW_ACCOUNT_RELATION.PLUS;
}
export interface ICashFlowSchemaSectionAccounts
extends ICashFlowStatementCommonSection {
type: ICashFlowStatementSectionType.ACCOUNT;
accountsRelations: ICashFlowSchemaAccountRelation[];
}
export interface ICashFlowSchemaSectionTotal {
type: ICashFlowStatementSectionType.TOTAL;
totalEquation: string;
}
export interface ICashFlowDatePeriod {
fromDate: ICashFlowDate;
toDate: ICashFlowDate;
total: ICashFlowStatementTotal;
}
export interface ICashFlowDate {
formattedDate: string;
date: Date;
}
export interface ICashFlowStatement {
/**
* Constructor method.
* @constructor
*/
constructor(
accounts: IAccount[],
ledger: ILedger,
cashLedger: ILedger,
netIncomeLedger: ILedger,
query: ICashFlowStatementQuery,
baseCurrency: string
): void;
reportData(): ICashFlowStatementData;
}
export interface ICashFlowTable {
constructor(reportStatement: ICashFlowStatement): void;
tableRows(): ITableRow[];
}
export interface IDateRange {
fromDate: Date,
toDate: Date,
}

View File

@@ -0,0 +1,76 @@
import {
INumberFormatQuery,
} from './FinancialStatements';
export interface IInventoryDetailsQuery {
fromDate: Date | string;
toDate: Date | string;
numberFormat: INumberFormatQuery;
noneTransactions: boolean;
}
export interface IInventoryDetailsNumber {
number: number;
formattedNumber: string;
}
export interface IInventoryDetailsMoney {
amount: number;
formattedAmount: string;
currencyCode: string;
}
export interface IInventoryDetailsDate {
date: Date;
formattedDate: string;
}
export interface IInventoryDetailsOpening {
nodeType: 'OPENING_ENTRY';
date: IInventoryDetailsDate;
quantity: IInventoryDetailsNumber;
value: IInventoryDetailsNumber;
}
export interface IInventoryDetailsClosing extends IInventoryDetailsOpening {
nodeType: 'CLOSING_ENTRY';
}
export interface IInventoryDetailsItem {
id: number;
nodeType: string;
name: string;
code: string;
children: (
| IInventoryDetailsItemTransaction
| IInventoryDetailsOpening
| IInventoryDetailsClosing
)[];
}
export interface IInventoryDetailsItemTransaction {
nodeType: string;
date: IInventoryDetailsDate;
transactionType: string;
transactionNumber: string;
quantityMovement: IInventoryDetailsNumber;
valueMovement: IInventoryDetailsNumber;
quantity: IInventoryDetailsNumber;
value: IInventoryDetailsNumber;
cost: IInventoryDetailsNumber;
profitMargin: IInventoryDetailsNumber;
rate: IInventoryDetailsNumber;
runningQuantity: IInventoryDetailsNumber;
runningValuation: IInventoryDetailsNumber;
direction: string;
}
export type IInventoryDetailsNode =
| IInventoryDetailsItem
| IInventoryDetailsItemTransaction;
export type IInventoryDetailsData = IInventoryDetailsItem[];

View File

@@ -1,38 +1,51 @@
export type TInventoryTransactionDirection = 'IN' | 'OUT';
export interface IInventoryTransaction {
id?: number,
date: Date|string,
direction: TInventoryTransactionDirection,
itemId: number,
id?: number;
date: Date | string;
direction: TInventoryTransactionDirection;
itemId: number;
quantity: number;
rate: number;
transactionType: string;
transcationTypeFormatted: string;
transactionId: number;
entryId: number;
costAccountId: number;
meta?: IInventoryTransactionMeta;
costLotAggregated?: IInventoryCostLotAggregated;
createdAt?: Date;
updatedAt?: Date;
}
export interface IInventoryTransactionMeta {
id?: number;
transactionNumber: string;
description: string;
}
export interface IInventoryCostLotAggregated {
cost: number,
quantity: number,
rate: number,
transactionType: string,
transactionId: number,
entryId: number,
costAccountId: number,
createdAt?: Date,
updatedAt?: Date,
};
export interface IInventoryLotCost {
id?: number,
date: Date,
direction: string,
itemId: number,
quantity: number,
rate: number,
remaining: number,
cost: number,
transactionType: string,
transactionId: number,
costAccountId: number,
entryId: number,
createdAt: Date,
};
id?: number;
date: Date;
direction: string;
itemId: number;
quantity: number;
rate: number;
remaining: number;
cost: number;
transactionType: string;
transactionId: number;
costAccountId: number;
entryId: number;
createdAt: Date;
}
export interface IItemsQuantityChanges {
itemId: number,
balanceChange: number,
};
itemId: number;
balanceChange: number;
}

View File

@@ -2,6 +2,7 @@ export interface ILedger {
entries: ILedgerEntry[];
getEntries(): ILedgerEntry[];
whereAccountId(accountId: number): ILedger;
whereContactId(contactId: number): ILedger;
whereFromDate(fromDate: Date | string): ILedger;
whereToDate(toDate: Date | string): ILedger;
@@ -15,6 +16,6 @@ export interface ILedgerEntry {
accountNormal: string;
contactId?: number;
date: Date | string;
transactionType: string,
transactionNumber: string,
transactionType?: string,
transactionNumber?: string,
}

View File

@@ -12,4 +12,14 @@ export interface ITableCell {
export type ITableRow = {
rows: ITableCell[];
};
};
export interface ITableColumn {
key: string,
label: string,
}
export interface ITable {
columns: ITableColumn[],
data: ITableRow[],
}

View File

@@ -25,8 +25,8 @@ export interface ITransactionsByContactsContact {
}
export interface ITransactionsByContactsFilter {
fromDate: Date;
toDate: Date;
fromDate: Date|string;
toDate: Date|string;
numberFormat: INumberFormatQuery;
noneTransactions: boolean;
noneZero: boolean;

View File

@@ -50,4 +50,6 @@ export * from './TransactionsByCustomers';
export * from './TransactionsByContacts';
export * from './TransactionsByVendors';
export * from './Table';
export * from './Ledger';
export * from './Ledger';
export * from './CashFlow';
export * from './InventoryDetails';