fix: base currency from organization metadata.

This commit is contained in:
a.bouhuolia
2021-09-11 14:01:52 +02:00
parent 6d79fe3498
commit ccd30cb2bd
16 changed files with 98 additions and 124 deletions

View File

@@ -3,6 +3,7 @@ import { Inject, Service } from 'typedi';
import { IAPAgingSummaryQuery, IARAgingSummaryMeta } from 'interfaces'; import { IAPAgingSummaryQuery, IARAgingSummaryMeta } from 'interfaces';
import TenancyService from 'services/Tenancy/TenancyService'; import TenancyService from 'services/Tenancy/TenancyService';
import APAgingSummarySheet from './APAgingSummarySheet'; import APAgingSummarySheet from './APAgingSummarySheet';
import { Tenant } from 'system/models';
@Service() @Service()
export default class PayableAgingSummaryService { export default class PayableAgingSummaryService {
@@ -74,11 +75,10 @@ export default class PayableAgingSummaryService {
filter, filter,
}); });
// Settings tenant service. // Settings tenant service.
const settings = this.tenancy.settings(tenantId); const tenant = await Tenant.query()
const baseCurrency = settings.get({ .findById(tenantId)
group: 'organization', .withGraphFetched('metadata');
key: 'base_currency',
});
// Retrieve all vendors from the storage. // Retrieve all vendors from the storage.
const vendors = const vendors =
filter.vendorsIds.length > 0 filter.vendorsIds.length > 0
@@ -98,7 +98,7 @@ export default class PayableAgingSummaryService {
vendors, vendors,
overdueBills, overdueBills,
dueBills, dueBills,
baseCurrency tenant.metadata.baseCurrency
); );
// A/P aging summary report data and columns. // A/P aging summary report data and columns.
const data = APAgingSummaryReport.reportData(); const data = APAgingSummaryReport.reportData();

View File

@@ -3,6 +3,7 @@ import { Inject, Service } from 'typedi';
import { IARAgingSummaryQuery, IARAgingSummaryMeta } from 'interfaces'; import { IARAgingSummaryQuery, IARAgingSummaryMeta } from 'interfaces';
import TenancyService from 'services/Tenancy/TenancyService'; import TenancyService from 'services/Tenancy/TenancyService';
import ARAgingSummarySheet from './ARAgingSummarySheet'; import ARAgingSummarySheet from './ARAgingSummarySheet';
import { Tenant } from 'system/models';
@Service() @Service()
export default class ARAgingSummaryService { export default class ARAgingSummaryService {
@@ -74,13 +75,10 @@ export default class ARAgingSummaryService {
tenantId, tenantId,
filter, filter,
}); });
// Settings tenant service. const tenant = await Tenant.query()
const settings = this.tenancy.settings(tenantId); .findById(tenantId)
.withGraphFetched('metadata');
const baseCurrency = settings.get({
group: 'organization',
key: 'base_currency',
});
// Retrieve all customers from the storage. // Retrieve all customers from the storage.
const customers = const customers =
(filter.customersIds.length > 0) (filter.customersIds.length > 0)
@@ -102,7 +100,7 @@ export default class ARAgingSummaryService {
customers, customers,
overdueSaleInvoices, overdueSaleInvoices,
currentInvoices, currentInvoices,
baseCurrency tenant.metadata.baseCurrency
); );
// AR aging summary report data and columns. // AR aging summary report data and columns.
const data = ARAgingSummaryReport.reportData(); const data = ARAgingSummaryReport.reportData();

View File

@@ -11,10 +11,12 @@ import Journal from 'services/Accounting/JournalPoster';
import BalanceSheetStatement from './BalanceSheet'; import BalanceSheetStatement from './BalanceSheet';
import InventoryService from 'services/Inventory/Inventory'; import InventoryService from 'services/Inventory/Inventory';
import { parseBoolean } from 'utils'; import { parseBoolean } from 'utils';
import { Tenant } from 'system/models';
@Service() @Service()
export default class BalanceSheetStatementService export default class BalanceSheetStatementService
implements IBalanceSheetStatementService { implements IBalanceSheetStatementService
{
@Inject() @Inject()
tenancy: TenancyService; tenancy: TenancyService;
@@ -50,14 +52,14 @@ export default class BalanceSheetStatementService
/** /**
* Retrieve the balance sheet meta. * Retrieve the balance sheet meta.
* @param {number} tenantId - * @param {number} tenantId -
* @returns {IBalanceSheetMeta} * @returns {IBalanceSheetMeta}
*/ */
private reportMetadata(tenantId: number): IBalanceSheetMeta { private reportMetadata(tenantId: number): IBalanceSheetMeta {
const settings = this.tenancy.settings(tenantId); const settings = this.tenancy.settings(tenantId);
const isCostComputeRunning = this.inventoryService const isCostComputeRunning =
.isItemsCostComputeRunning(tenantId); this.inventoryService.isItemsCostComputeRunning(tenantId);
const organizationName = settings.get({ const organizationName = settings.get({
group: 'organization', group: 'organization',
@@ -71,7 +73,7 @@ export default class BalanceSheetStatementService
return { return {
isCostComputeRunning: parseBoolean(isCostComputeRunning, false), isCostComputeRunning: parseBoolean(isCostComputeRunning, false),
organizationName, organizationName,
baseCurrency baseCurrency,
}; };
} }
@@ -87,18 +89,14 @@ export default class BalanceSheetStatementService
tenantId: number, tenantId: number,
query: IBalanceSheetQuery query: IBalanceSheetQuery
): Promise<IBalanceSheetStatement> { ): Promise<IBalanceSheetStatement> {
const { const { accountRepository, transactionsRepository } =
accountRepository, this.tenancy.repositories(tenantId);
transactionsRepository,
} = this.tenancy.repositories(tenantId);
const i18n = this.tenancy.i18n(tenantId); const i18n = this.tenancy.i18n(tenantId);
// Settings tenant service. const tenant = await Tenant.query()
const settings = this.tenancy.settings(tenantId); .findById(tenantId)
const baseCurrency = settings.get({ .withGraphFetched('metadata');
group: 'organization', key: 'base_currency',
});
const filter = { const filter = {
...this.defaultQuery, ...this.defaultQuery,
@@ -115,7 +113,7 @@ export default class BalanceSheetStatementService
// Retrieve all journal transactions based on the given query. // Retrieve all journal transactions based on the given query.
const transactions = await transactionsRepository.journal({ const transactions = await transactionsRepository.journal({
fromDate: query.fromDate, fromDate: query.fromDate,
toDate: query.toDate, toDate: query.toDate,
}); });
// Transform transactions to journal collection. // Transform transactions to journal collection.
const transactionsJournal = Journal.fromTransactions( const transactionsJournal = Journal.fromTransactions(
@@ -129,7 +127,7 @@ export default class BalanceSheetStatementService
filter, filter,
accounts, accounts,
transactionsJournal, transactionsJournal,
baseCurrency, tenant.metadata.baseCurrency,
i18n i18n
); );
// Balance sheet data. // Balance sheet data.

View File

@@ -15,6 +15,7 @@ import Ledger from 'services/Accounting/Ledger';
import CashFlowRepository from './CashFlowRepository'; import CashFlowRepository from './CashFlowRepository';
import InventoryService from 'services/Inventory/Inventory'; import InventoryService from 'services/Inventory/Inventory';
import { parseBoolean } from 'utils'; import { parseBoolean } from 'utils';
import { Tenant } from 'system/models';
@Service() @Service()
export default class CashFlowStatementService export default class CashFlowStatementService
@@ -99,12 +100,9 @@ export default class CashFlowStatementService
// Retrieve all accounts on the storage. // Retrieve all accounts on the storage.
const accounts = await this.cashFlowRepo.cashFlowAccounts(tenantId); const accounts = await this.cashFlowRepo.cashFlowAccounts(tenantId);
// Settings tenant service. const tenant = await Tenant.query()
const settings = this.tenancy.settings(tenantId); .findById(tenantId)
const baseCurrency = settings.get({ .withGraphFetched('metadata');
group: 'organization',
key: 'base_currency',
});
const filter = { const filter = {
...this.defaultQuery, ...this.defaultQuery,
@@ -137,7 +135,7 @@ export default class CashFlowStatementService
cashLedger, cashLedger,
netIncomeLedger, netIncomeLedger,
filter, filter,
baseCurrency, tenant.metadata.baseCurrency,
i18n i18n
); );

View File

@@ -14,6 +14,7 @@ import { CustomerBalanceSummaryReport } from './CustomerBalanceSummary';
import Ledger from 'services/Accounting/Ledger'; import Ledger from 'services/Accounting/Ledger';
import CustomerBalanceSummaryRepository from './CustomerBalanceSummaryRepository'; import CustomerBalanceSummaryRepository from './CustomerBalanceSummaryRepository';
import { Tenant } from 'system/models';
export default class CustomerBalanceSummaryService export default class CustomerBalanceSummaryService
implements ICustomerBalanceSummaryService implements ICustomerBalanceSummaryService
@@ -79,12 +80,10 @@ export default class CustomerBalanceSummaryService
tenantId: number, tenantId: number,
query: ICustomerBalanceSummaryQuery query: ICustomerBalanceSummaryQuery
): Promise<ICustomerBalanceSummaryStatement> { ): Promise<ICustomerBalanceSummaryStatement> {
// Settings tenant service. const tenant = await Tenant.query()
const settings = this.tenancy.settings(tenantId); .findById(tenantId)
const baseCurrency = settings.get({ .withGraphFetched('metadata');
group: 'organization',
key: 'base_currency',
});
// Merges the default query and request query. // Merges the default query and request query.
const filter = { ...this.defaultQuery, ...query }; const filter = { ...this.defaultQuery, ...query };
@@ -113,7 +112,7 @@ export default class CustomerBalanceSummaryService
ledger, ledger,
customers, customers,
filter, filter,
baseCurrency tenant.metadata.baseCurrency,
); );
return { return {

View File

@@ -8,6 +8,7 @@ import Journal from 'services/Accounting/JournalPoster';
import GeneralLedgerSheet from 'services/FinancialStatements/GeneralLedger/GeneralLedger'; import GeneralLedgerSheet from 'services/FinancialStatements/GeneralLedger/GeneralLedger';
import InventoryService from 'services/Inventory/Inventory'; import InventoryService from 'services/Inventory/Inventory';
import { transformToMap, parseBoolean } from 'utils'; import { transformToMap, parseBoolean } from 'utils';
import { Tenant } from 'system/models';
const ERRORS = { const ERRORS = {
ACCOUNTS_NOT_FOUND: 'ACCOUNTS_NOT_FOUND', ACCOUNTS_NOT_FOUND: 'ACCOUNTS_NOT_FOUND',
@@ -105,21 +106,17 @@ export default class GeneralLedgerService {
transactionsRepository, transactionsRepository,
contactRepository contactRepository
} = this.tenancy.repositories(tenantId); } = this.tenancy.repositories(tenantId);
const settings = this.tenancy.settings(tenantId);
const i18n = this.tenancy.i18n(tenantId); const i18n = this.tenancy.i18n(tenantId);
const tenant = await Tenant.query()
.findById(tenantId)
.withGraphFetched('metadata');
const filter = { const filter = {
...this.defaultQuery, ...this.defaultQuery,
...query, ...query,
}; };
this.logger.info('[general_ledger] trying to calculate the report.', {
tenantId,
filter,
});
const baseCurrency = settings.get({
group: 'organization',
key: 'base_currency',
});
// Retrieve all accounts with associated type from the storage. // Retrieve all accounts with associated type from the storage.
const accounts = await accountRepository.all(); const accounts = await accountRepository.all();
const accountsGraph = await accountRepository.getDependencyGraph(); const accountsGraph = await accountRepository.getDependencyGraph();
@@ -158,7 +155,7 @@ export default class GeneralLedgerService {
contactsByIdMap, contactsByIdMap,
transactionsJournal, transactionsJournal,
openingTransJournal, openingTransJournal,
baseCurrency, tenant.metadata.baseCurrency,
i18n i18n
); );
// Retrieve general ledger report data. // Retrieve general ledger report data.

View File

@@ -11,6 +11,7 @@ import FinancialSheet from '../FinancialSheet';
import InventoryDetailsRepository from './InventoryDetailsRepository'; import InventoryDetailsRepository from './InventoryDetailsRepository';
import InventoryService from 'services/Inventory/Inventory'; import InventoryService from 'services/Inventory/Inventory';
import { parseBoolean } from 'utils'; import { parseBoolean } from 'utils';
import { Tenant } from 'system/models';
@Service() @Service()
export default class InventoryDetailsService extends FinancialSheet { export default class InventoryDetailsService extends FinancialSheet {
@@ -80,14 +81,11 @@ export default class InventoryDetailsService extends FinancialSheet {
tenantId: number, tenantId: number,
query: IInventoryDetailsQuery query: IInventoryDetailsQuery
): Promise<IInvetoryItemDetailDOO> { ): Promise<IInvetoryItemDetailDOO> {
// Settings tenant service.
const settings = this.tenancy.settings(tenantId);
const i18n = this.tenancy.i18n(tenantId); const i18n = this.tenancy.i18n(tenantId);
const baseCurrency = settings.get({ const tenant = await Tenant.query()
group: 'organization', .findById(tenantId)
key: 'base_currency', .withGraphFetched('metadata');
});
const filter = { const filter = {
...this.defaultQuery, ...this.defaultQuery,
@@ -112,7 +110,7 @@ export default class InventoryDetailsService extends FinancialSheet {
openingBalanceTransactions, openingBalanceTransactions,
inventoryTransactions, inventoryTransactions,
filter, filter,
baseCurrency, tenant.metadata.baseCurrency,
i18n i18n
); );

View File

@@ -7,6 +7,7 @@ import {
import TenancyService from 'services/Tenancy/TenancyService'; import TenancyService from 'services/Tenancy/TenancyService';
import InventoryValuationSheet from './InventoryValuationSheet'; import InventoryValuationSheet from './InventoryValuationSheet';
import InventoryService from 'services/Inventory/Inventory'; import InventoryService from 'services/Inventory/Inventory';
import { Tenant } from 'system/models';
@Service() @Service()
export default class InventoryValuationSheetService { export default class InventoryValuationSheetService {
@@ -76,12 +77,9 @@ export default class InventoryValuationSheetService {
) { ) {
const { Item, InventoryCostLotTracker } = this.tenancy.models(tenantId); const { Item, InventoryCostLotTracker } = this.tenancy.models(tenantId);
// Settings tenant service. const tenant = await Tenant.query()
const settings = this.tenancy.settings(tenantId); .findById(tenantId)
const baseCurrency = settings.get({ .withGraphFetched('metadata');
group: 'organization',
key: 'base_currency',
});
const filter = { const filter = {
...this.defaultQuery, ...this.defaultQuery,
@@ -119,7 +117,7 @@ export default class InventoryValuationSheetService {
inventoryItems, inventoryItems,
INTransactions, INTransactions,
OUTTransactions, OUTTransactions,
baseCurrency, tenant.metadata.baseCurrency,
); );
// Retrieve the inventory valuation report data. // Retrieve the inventory valuation report data.
const inventoryValuationData = inventoryValuationInstance.reportData(); const inventoryValuationData = inventoryValuationInstance.reportData();

View File

@@ -7,6 +7,7 @@ import TenancyService from 'services/Tenancy/TenancyService';
import Journal from 'services/Accounting/JournalPoster'; import Journal from 'services/Accounting/JournalPoster';
import InventoryService from 'services/Inventory/Inventory'; import InventoryService from 'services/Inventory/Inventory';
import { parseBoolean, transformToMap } from 'utils'; import { parseBoolean, transformToMap } from 'utils';
import { Tenant } from 'system/models';
@Service() @Service()
export default class JournalSheetService { export default class JournalSheetService {
@@ -86,12 +87,11 @@ export default class JournalSheetService {
tenantId, tenantId,
filter, filter,
}); });
// Settings service.
const settings = this.tenancy.settings(tenantId); const tenant = await Tenant.query()
const baseCurrency = settings.get({ .findById(tenantId)
group: 'organization', .withGraphFetched('metadata');
key: 'base_currency',
});
// Retrieve all accounts on the storage. // Retrieve all accounts on the storage.
const accountsGraph = await accountRepository.getDependencyGraph(); const accountsGraph = await accountRepository.getDependencyGraph();
@@ -127,7 +127,7 @@ export default class JournalSheetService {
transactionsJournal, transactionsJournal,
accountsGraph, accountsGraph,
contactsByIdMap, contactsByIdMap,
baseCurrency, tenant.metadata.baseCurrency,
i18n i18n
); );
// Retrieve journal report columns. // Retrieve journal report columns.

View File

@@ -7,6 +7,7 @@ import TenancyService from 'services/Tenancy/TenancyService';
import AccountsService from 'services/Accounts/AccountsService'; import AccountsService from 'services/Accounts/AccountsService';
import InventoryService from 'services/Inventory/Inventory'; import InventoryService from 'services/Inventory/Inventory';
import { parseBoolean } from 'utils'; import { parseBoolean } from 'utils';
import { Tenant } from 'system/models';
// Profit/Loss sheet service. // Profit/Loss sheet service.
@Service() @Service()
@@ -103,12 +104,10 @@ export default class ProfitLossSheetService {
filter.accountsIds filter.accountsIds
); );
} }
// Settings tenant service. const tenant = await Tenant.query()
const settings = this.tenancy.settings(tenantId); .findById(tenantId)
const baseCurrency = settings.get({ .withGraphFetched('metadata');
group: 'organization',
key: 'base_currency',
});
// Retrieve all accounts on the storage. // Retrieve all accounts on the storage.
const accounts = await accountRepository.all(); const accounts = await accountRepository.all();
const accountsGraph = await accountRepository.getDependencyGraph(); const accountsGraph = await accountRepository.getDependencyGraph();
@@ -130,7 +129,7 @@ export default class ProfitLossSheetService {
filter, filter,
accounts, accounts,
transactionsJournal, transactionsJournal,
baseCurrency tenant.metadata.baseCurrency,
); );
// Profit/loss report data and collumns. // Profit/loss report data and collumns.
const profitLossData = profitLossInstance.reportData(); const profitLossData = profitLossInstance.reportData();

View File

@@ -7,6 +7,7 @@ import {
} from 'interfaces'; } from 'interfaces';
import TenancyService from 'services/Tenancy/TenancyService'; import TenancyService from 'services/Tenancy/TenancyService';
import PurchasesByItems from './PurchasesByItems'; import PurchasesByItems from './PurchasesByItems';
import { Tenant } from 'system/models';
@Service() @Service()
export default class InventoryValuationReportService { export default class InventoryValuationReportService {
@@ -77,12 +78,9 @@ export default class InventoryValuationReportService {
}> { }> {
const { Item, InventoryTransaction } = this.tenancy.models(tenantId); const { Item, InventoryTransaction } = this.tenancy.models(tenantId);
// Settings tenant service. const tenant = await Tenant.query()
const settings = this.tenancy.settings(tenantId); .findById(tenantId)
const baseCurrency = settings.get({ .withGraphFetched('metadata');
group: 'organization',
key: 'base_currency',
});
const filter = { const filter = {
...this.defaultQuery, ...this.defaultQuery,
@@ -119,7 +117,7 @@ export default class InventoryValuationReportService {
filter, filter,
inventoryItems, inventoryItems,
inventoryTransactions, inventoryTransactions,
baseCurrency tenant.metadata.baseCurrency
); );
const purchasesByItemsData = purchasesByItemsInstance.reportData(); const purchasesByItemsData = purchasesByItemsInstance.reportData();

View File

@@ -7,6 +7,7 @@ import {
} from 'interfaces'; } from 'interfaces';
import TenancyService from 'services/Tenancy/TenancyService'; import TenancyService from 'services/Tenancy/TenancyService';
import SalesByItems from './SalesByItems'; import SalesByItems from './SalesByItems';
import { Tenant } from 'system/models';
@Service() @Service()
export default class SalesByItemsReportService { export default class SalesByItemsReportService {
@@ -77,12 +78,9 @@ export default class SalesByItemsReportService {
}> { }> {
const { Item, InventoryTransaction } = this.tenancy.models(tenantId); const { Item, InventoryTransaction } = this.tenancy.models(tenantId);
// Settings tenant service. const tenant = await Tenant.query()
const settings = this.tenancy.settings(tenantId); .findById(tenantId)
const baseCurrency = settings.get({ .withGraphFetched('metadata');
group: 'organization',
key: 'base_currency',
});
const filter = { const filter = {
...this.defaultQuery, ...this.defaultQuery,
@@ -120,7 +118,7 @@ export default class SalesByItemsReportService {
filter, filter,
inventoryItems, inventoryItems,
inventoryTransactions, inventoryTransactions,
baseCurrency tenant.metadata.baseCurrency,
); );
const purchasesByItemsData = purchasesByItemsInstance.reportData(); const purchasesByItemsData = purchasesByItemsInstance.reportData();

View File

@@ -11,6 +11,7 @@ import {
import TransactionsByCustomers from './TransactionsByCustomers'; import TransactionsByCustomers from './TransactionsByCustomers';
import Ledger from 'services/Accounting/Ledger'; import Ledger from 'services/Accounting/Ledger';
import TransactionsByCustomersRepository from './TransactionsByCustomersRepository'; import TransactionsByCustomersRepository from './TransactionsByCustomersRepository';
import { Tenant } from 'system/models';
export default class TransactionsByCustomersService export default class TransactionsByCustomersService
implements ITransactionsByCustomersService implements ITransactionsByCustomersService
@@ -112,15 +113,12 @@ export default class TransactionsByCustomersService
query: ITransactionsByCustomersFilter query: ITransactionsByCustomersFilter
): Promise<ITransactionsByCustomersStatement> { ): Promise<ITransactionsByCustomersStatement> {
const { accountRepository } = this.tenancy.repositories(tenantId); const { accountRepository } = this.tenancy.repositories(tenantId);
// Settings tenant service.
const settings = this.tenancy.settings(tenantId);
const i18n = this.tenancy.i18n(tenantId); const i18n = this.tenancy.i18n(tenantId);
const baseCurrency = settings.get({ // Retrieve tenant information.
group: 'organization', const tenant = await Tenant.query()
key: 'base_currency', .findById(tenantId)
}); .withGraphFetched('metadata');
const filter = { const filter = {
...this.defaultQuery, ...this.defaultQuery,
@@ -162,7 +160,7 @@ export default class TransactionsByCustomersService
accountsGraph, accountsGraph,
journal, journal,
filter, filter,
baseCurrency, tenant.metadata.baseCurrency,
i18n i18n
); );

View File

@@ -12,6 +12,7 @@ import {
import TransactionsByVendor from './TransactionsByVendor'; import TransactionsByVendor from './TransactionsByVendor';
import Ledger from 'services/Accounting/Ledger'; import Ledger from 'services/Accounting/Ledger';
import TransactionsByVendorRepository from './TransactionsByVendorRepository'; import TransactionsByVendorRepository from './TransactionsByVendorRepository';
import { Tenant } from 'system/models';
export default class TransactionsByVendorsService export default class TransactionsByVendorsService
implements ITransactionsByVendorsService implements ITransactionsByVendorsService
@@ -135,14 +136,12 @@ export default class TransactionsByVendorsService
): Promise<ITransactionsByVendorsStatement> { ): Promise<ITransactionsByVendorsStatement> {
const { accountRepository } = this.tenancy.repositories(tenantId); const { accountRepository } = this.tenancy.repositories(tenantId);
// Settings tenant service.
const settings = this.tenancy.settings(tenantId);
const i18n = this.tenancy.i18n(tenantId); const i18n = this.tenancy.i18n(tenantId);
const tenant = await Tenant.query()
.findById(tenantId)
.withGraphFetched('metadata');
const baseCurrency = settings.get({
group: 'organization',
key: 'base_currency',
});
const filter = { ...this.defaultQuery, ...query }; const filter = { ...this.defaultQuery, ...query };
// Retrieve the report vendors. // Retrieve the report vendors.
@@ -168,7 +167,7 @@ export default class TransactionsByVendorsService
accountsGraph, accountsGraph,
journal, journal,
filter, filter,
baseCurrency, tenant.metadata.baseCurrency,
i18n i18n
); );
return { return {

View File

@@ -7,6 +7,7 @@ import TrialBalanceSheet from './TrialBalanceSheet';
import FinancialSheet from '../FinancialSheet'; import FinancialSheet from '../FinancialSheet';
import InventoryService from 'services/Inventory/Inventory'; import InventoryService from 'services/Inventory/Inventory';
import { parseBoolean } from 'utils'; import { parseBoolean } from 'utils';
import { Tenant } from 'system/models';
@Service() @Service()
export default class TrialBalanceSheetService extends FinancialSheet { export default class TrialBalanceSheetService extends FinancialSheet {
@@ -89,12 +90,9 @@ export default class TrialBalanceSheetService extends FinancialSheet {
transactionsRepository, transactionsRepository,
} = this.tenancy.repositories(tenantId); } = this.tenancy.repositories(tenantId);
// Settings tenant service. const tenant = await Tenant.query()
const settings = this.tenancy.settings(tenantId); .findById(tenantId)
const baseCurrency = settings.get({ .withGraphFetched('metadata');
group: 'organization',
key: 'base_currency',
});
this.logger.info('[trial_balance_sheet] trying to calcualte the report.', { this.logger.info('[trial_balance_sheet] trying to calcualte the report.', {
tenantId, tenantId,
@@ -122,7 +120,7 @@ export default class TrialBalanceSheetService extends FinancialSheet {
filter, filter,
accounts, accounts,
transactionsJournal, transactionsJournal,
baseCurrency tenant.metadata.baseCurrency,
); );
// Trial balance sheet data. // Trial balance sheet data.
const trialBalanceSheetData = trialBalanceInstance.reportData(); const trialBalanceSheetData = trialBalanceInstance.reportData();

View File

@@ -13,6 +13,7 @@ import {
import { VendorBalanceSummaryReport } from './VendorBalanceSummary'; import { VendorBalanceSummaryReport } from './VendorBalanceSummary';
import Ledger from 'services/Accounting/Ledger'; import Ledger from 'services/Accounting/Ledger';
import VendorBalanceSummaryRepository from './VendorBalanceSummaryRepository'; import VendorBalanceSummaryRepository from './VendorBalanceSummaryRepository';
import { Tenant } from 'system/models';
export default class VendorBalanceSummaryService export default class VendorBalanceSummaryService
implements IVendorBalanceSummaryService implements IVendorBalanceSummaryService
@@ -77,12 +78,9 @@ export default class VendorBalanceSummaryService
tenantId: number, tenantId: number,
query: IVendorBalanceSummaryQuery query: IVendorBalanceSummaryQuery
): Promise<IVendorBalanceSummaryStatement> { ): Promise<IVendorBalanceSummaryStatement> {
// Settings tenant service. const tenant = await Tenant.query()
const settings = this.tenancy.settings(tenantId); .findById(tenantId)
const baseCurrency = settings.get({ .withGraphFetched('metadata');
group: 'organization',
key: 'base_currency',
});
const filter = { ...this.defaultQuery, ...query }; const filter = { ...this.defaultQuery, ...query };
this.logger.info( this.logger.info(
@@ -110,7 +108,7 @@ export default class VendorBalanceSummaryService
vendorsLedger, vendorsLedger,
vendors, vendors,
filter, filter,
baseCurrency tenant.metadata.baseCurrency
); );
return { return {