From ccd30cb2bdc823ddc37dc7a02c5af83a8c57174f Mon Sep 17 00:00:00 2001 From: "a.bouhuolia" Date: Sat, 11 Sep 2021 14:01:52 +0200 Subject: [PATCH] fix: base currency from organization metadata. --- .../AgingSummary/APAgingSummaryService.ts | 12 ++++---- .../AgingSummary/ARAgingSummaryService.ts | 12 ++++---- .../BalanceSheet/BalanceSheetService.ts | 30 +++++++++---------- .../CashFlow/CashFlowService.ts | 12 ++++---- .../CustomerBalanceSummaryService.ts | 13 ++++---- .../GeneralLedger/GeneralLedgerService.ts | 17 +++++------ .../InventoryDetailsService.ts | 12 ++++---- .../InventoryValuationSheetService.ts | 12 ++++---- .../JournalSheet/JournalSheetService.ts | 14 ++++----- .../ProfitLossSheet/ProfitLossSheetService.ts | 13 ++++---- .../PurchasesByItemsService.ts | 12 ++++---- .../SalesByItems/SalesByItemsService.ts | 12 ++++---- .../TransactionsByCustomersService.ts | 14 ++++----- .../TransactionsByVendorService.ts | 13 ++++---- .../TrialBalanceSheetService.ts | 12 ++++---- .../VendorBalanceSummaryService.ts | 12 ++++---- 16 files changed, 98 insertions(+), 124 deletions(-) diff --git a/server/src/services/FinancialStatements/AgingSummary/APAgingSummaryService.ts b/server/src/services/FinancialStatements/AgingSummary/APAgingSummaryService.ts index 930ee66f8..55565352f 100644 --- a/server/src/services/FinancialStatements/AgingSummary/APAgingSummaryService.ts +++ b/server/src/services/FinancialStatements/AgingSummary/APAgingSummaryService.ts @@ -3,6 +3,7 @@ import { Inject, Service } from 'typedi'; import { IAPAgingSummaryQuery, IARAgingSummaryMeta } from 'interfaces'; import TenancyService from 'services/Tenancy/TenancyService'; import APAgingSummarySheet from './APAgingSummarySheet'; +import { Tenant } from 'system/models'; @Service() export default class PayableAgingSummaryService { @@ -74,11 +75,10 @@ export default class PayableAgingSummaryService { filter, }); // Settings tenant service. - const settings = this.tenancy.settings(tenantId); - const baseCurrency = settings.get({ - group: 'organization', - key: 'base_currency', - }); + const tenant = await Tenant.query() + .findById(tenantId) + .withGraphFetched('metadata'); + // Retrieve all vendors from the storage. const vendors = filter.vendorsIds.length > 0 @@ -98,7 +98,7 @@ export default class PayableAgingSummaryService { vendors, overdueBills, dueBills, - baseCurrency + tenant.metadata.baseCurrency ); // A/P aging summary report data and columns. const data = APAgingSummaryReport.reportData(); diff --git a/server/src/services/FinancialStatements/AgingSummary/ARAgingSummaryService.ts b/server/src/services/FinancialStatements/AgingSummary/ARAgingSummaryService.ts index 21b60064b..cd727e3c1 100644 --- a/server/src/services/FinancialStatements/AgingSummary/ARAgingSummaryService.ts +++ b/server/src/services/FinancialStatements/AgingSummary/ARAgingSummaryService.ts @@ -3,6 +3,7 @@ import { Inject, Service } from 'typedi'; import { IARAgingSummaryQuery, IARAgingSummaryMeta } from 'interfaces'; import TenancyService from 'services/Tenancy/TenancyService'; import ARAgingSummarySheet from './ARAgingSummarySheet'; +import { Tenant } from 'system/models'; @Service() export default class ARAgingSummaryService { @@ -74,13 +75,10 @@ export default class ARAgingSummaryService { tenantId, filter, }); - // Settings tenant service. - const settings = this.tenancy.settings(tenantId); + const tenant = await Tenant.query() + .findById(tenantId) + .withGraphFetched('metadata'); - const baseCurrency = settings.get({ - group: 'organization', - key: 'base_currency', - }); // Retrieve all customers from the storage. const customers = (filter.customersIds.length > 0) @@ -102,7 +100,7 @@ export default class ARAgingSummaryService { customers, overdueSaleInvoices, currentInvoices, - baseCurrency + tenant.metadata.baseCurrency ); // AR aging summary report data and columns. const data = ARAgingSummaryReport.reportData(); diff --git a/server/src/services/FinancialStatements/BalanceSheet/BalanceSheetService.ts b/server/src/services/FinancialStatements/BalanceSheet/BalanceSheetService.ts index 3b98b4983..13a9d564e 100644 --- a/server/src/services/FinancialStatements/BalanceSheet/BalanceSheetService.ts +++ b/server/src/services/FinancialStatements/BalanceSheet/BalanceSheetService.ts @@ -11,10 +11,12 @@ import Journal from 'services/Accounting/JournalPoster'; import BalanceSheetStatement from './BalanceSheet'; import InventoryService from 'services/Inventory/Inventory'; import { parseBoolean } from 'utils'; +import { Tenant } from 'system/models'; @Service() export default class BalanceSheetStatementService - implements IBalanceSheetStatementService { + implements IBalanceSheetStatementService +{ @Inject() tenancy: TenancyService; @@ -50,14 +52,14 @@ export default class BalanceSheetStatementService /** * Retrieve the balance sheet meta. - * @param {number} tenantId - + * @param {number} tenantId - * @returns {IBalanceSheetMeta} */ private reportMetadata(tenantId: number): IBalanceSheetMeta { const settings = this.tenancy.settings(tenantId); - const isCostComputeRunning = this.inventoryService - .isItemsCostComputeRunning(tenantId); + const isCostComputeRunning = + this.inventoryService.isItemsCostComputeRunning(tenantId); const organizationName = settings.get({ group: 'organization', @@ -71,7 +73,7 @@ export default class BalanceSheetStatementService return { isCostComputeRunning: parseBoolean(isCostComputeRunning, false), organizationName, - baseCurrency + baseCurrency, }; } @@ -87,18 +89,14 @@ export default class BalanceSheetStatementService tenantId: number, query: IBalanceSheetQuery ): Promise { - const { - accountRepository, - transactionsRepository, - } = this.tenancy.repositories(tenantId); + const { accountRepository, transactionsRepository } = + this.tenancy.repositories(tenantId); const i18n = this.tenancy.i18n(tenantId); - // Settings tenant service. - const settings = this.tenancy.settings(tenantId); - const baseCurrency = settings.get({ - group: 'organization', key: 'base_currency', - }); + const tenant = await Tenant.query() + .findById(tenantId) + .withGraphFetched('metadata'); const filter = { ...this.defaultQuery, @@ -115,7 +113,7 @@ export default class BalanceSheetStatementService // Retrieve all journal transactions based on the given query. const transactions = await transactionsRepository.journal({ fromDate: query.fromDate, - toDate: query.toDate, + toDate: query.toDate, }); // Transform transactions to journal collection. const transactionsJournal = Journal.fromTransactions( @@ -129,7 +127,7 @@ export default class BalanceSheetStatementService filter, accounts, transactionsJournal, - baseCurrency, + tenant.metadata.baseCurrency, i18n ); // Balance sheet data. diff --git a/server/src/services/FinancialStatements/CashFlow/CashFlowService.ts b/server/src/services/FinancialStatements/CashFlow/CashFlowService.ts index 378182613..e619f634f 100644 --- a/server/src/services/FinancialStatements/CashFlow/CashFlowService.ts +++ b/server/src/services/FinancialStatements/CashFlow/CashFlowService.ts @@ -15,6 +15,7 @@ import Ledger from 'services/Accounting/Ledger'; import CashFlowRepository from './CashFlowRepository'; import InventoryService from 'services/Inventory/Inventory'; import { parseBoolean } from 'utils'; +import { Tenant } from 'system/models'; @Service() export default class CashFlowStatementService @@ -99,12 +100,9 @@ export default class CashFlowStatementService // Retrieve all accounts on the storage. const accounts = await this.cashFlowRepo.cashFlowAccounts(tenantId); - // Settings tenant service. - const settings = this.tenancy.settings(tenantId); - const baseCurrency = settings.get({ - group: 'organization', - key: 'base_currency', - }); + const tenant = await Tenant.query() + .findById(tenantId) + .withGraphFetched('metadata'); const filter = { ...this.defaultQuery, @@ -137,7 +135,7 @@ export default class CashFlowStatementService cashLedger, netIncomeLedger, filter, - baseCurrency, + tenant.metadata.baseCurrency, i18n ); diff --git a/server/src/services/FinancialStatements/CustomerBalanceSummary/CustomerBalanceSummaryService.ts b/server/src/services/FinancialStatements/CustomerBalanceSummary/CustomerBalanceSummaryService.ts index e3ad79584..441a47db6 100644 --- a/server/src/services/FinancialStatements/CustomerBalanceSummary/CustomerBalanceSummaryService.ts +++ b/server/src/services/FinancialStatements/CustomerBalanceSummary/CustomerBalanceSummaryService.ts @@ -14,6 +14,7 @@ import { CustomerBalanceSummaryReport } from './CustomerBalanceSummary'; import Ledger from 'services/Accounting/Ledger'; import CustomerBalanceSummaryRepository from './CustomerBalanceSummaryRepository'; +import { Tenant } from 'system/models'; export default class CustomerBalanceSummaryService implements ICustomerBalanceSummaryService @@ -79,12 +80,10 @@ export default class CustomerBalanceSummaryService tenantId: number, query: ICustomerBalanceSummaryQuery ): Promise { - // Settings tenant service. - const settings = this.tenancy.settings(tenantId); - const baseCurrency = settings.get({ - group: 'organization', - key: 'base_currency', - }); + const tenant = await Tenant.query() + .findById(tenantId) + .withGraphFetched('metadata'); + // Merges the default query and request query. const filter = { ...this.defaultQuery, ...query }; @@ -113,7 +112,7 @@ export default class CustomerBalanceSummaryService ledger, customers, filter, - baseCurrency + tenant.metadata.baseCurrency, ); return { diff --git a/server/src/services/FinancialStatements/GeneralLedger/GeneralLedgerService.ts b/server/src/services/FinancialStatements/GeneralLedger/GeneralLedgerService.ts index 58aaf8f0d..7cbf2d9dc 100644 --- a/server/src/services/FinancialStatements/GeneralLedger/GeneralLedgerService.ts +++ b/server/src/services/FinancialStatements/GeneralLedger/GeneralLedgerService.ts @@ -8,6 +8,7 @@ import Journal from 'services/Accounting/JournalPoster'; import GeneralLedgerSheet from 'services/FinancialStatements/GeneralLedger/GeneralLedger'; import InventoryService from 'services/Inventory/Inventory'; import { transformToMap, parseBoolean } from 'utils'; +import { Tenant } from 'system/models'; const ERRORS = { ACCOUNTS_NOT_FOUND: 'ACCOUNTS_NOT_FOUND', @@ -105,21 +106,17 @@ export default class GeneralLedgerService { transactionsRepository, contactRepository } = this.tenancy.repositories(tenantId); - const settings = this.tenancy.settings(tenantId); + const i18n = this.tenancy.i18n(tenantId); + const tenant = await Tenant.query() + .findById(tenantId) + .withGraphFetched('metadata'); + const filter = { ...this.defaultQuery, ...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. const accounts = await accountRepository.all(); const accountsGraph = await accountRepository.getDependencyGraph(); @@ -158,7 +155,7 @@ export default class GeneralLedgerService { contactsByIdMap, transactionsJournal, openingTransJournal, - baseCurrency, + tenant.metadata.baseCurrency, i18n ); // Retrieve general ledger report data. diff --git a/server/src/services/FinancialStatements/InventoryDetails/InventoryDetailsService.ts b/server/src/services/FinancialStatements/InventoryDetails/InventoryDetailsService.ts index 4fcf7f9f7..755b0ab29 100644 --- a/server/src/services/FinancialStatements/InventoryDetails/InventoryDetailsService.ts +++ b/server/src/services/FinancialStatements/InventoryDetails/InventoryDetailsService.ts @@ -11,6 +11,7 @@ import FinancialSheet from '../FinancialSheet'; import InventoryDetailsRepository from './InventoryDetailsRepository'; import InventoryService from 'services/Inventory/Inventory'; import { parseBoolean } from 'utils'; +import { Tenant } from 'system/models'; @Service() export default class InventoryDetailsService extends FinancialSheet { @@ -80,14 +81,11 @@ export default class InventoryDetailsService extends FinancialSheet { tenantId: number, query: IInventoryDetailsQuery ): Promise { - // Settings tenant service. - const settings = this.tenancy.settings(tenantId); const i18n = this.tenancy.i18n(tenantId); - const baseCurrency = settings.get({ - group: 'organization', - key: 'base_currency', - }); + const tenant = await Tenant.query() + .findById(tenantId) + .withGraphFetched('metadata'); const filter = { ...this.defaultQuery, @@ -112,7 +110,7 @@ export default class InventoryDetailsService extends FinancialSheet { openingBalanceTransactions, inventoryTransactions, filter, - baseCurrency, + tenant.metadata.baseCurrency, i18n ); diff --git a/server/src/services/FinancialStatements/InventoryValuationSheet/InventoryValuationSheetService.ts b/server/src/services/FinancialStatements/InventoryValuationSheet/InventoryValuationSheetService.ts index f34d12eb6..db6cd030f 100644 --- a/server/src/services/FinancialStatements/InventoryValuationSheet/InventoryValuationSheetService.ts +++ b/server/src/services/FinancialStatements/InventoryValuationSheet/InventoryValuationSheetService.ts @@ -7,6 +7,7 @@ import { import TenancyService from 'services/Tenancy/TenancyService'; import InventoryValuationSheet from './InventoryValuationSheet'; import InventoryService from 'services/Inventory/Inventory'; +import { Tenant } from 'system/models'; @Service() export default class InventoryValuationSheetService { @@ -76,12 +77,9 @@ export default class InventoryValuationSheetService { ) { const { Item, InventoryCostLotTracker } = this.tenancy.models(tenantId); - // Settings tenant service. - const settings = this.tenancy.settings(tenantId); - const baseCurrency = settings.get({ - group: 'organization', - key: 'base_currency', - }); + const tenant = await Tenant.query() + .findById(tenantId) + .withGraphFetched('metadata'); const filter = { ...this.defaultQuery, @@ -119,7 +117,7 @@ export default class InventoryValuationSheetService { inventoryItems, INTransactions, OUTTransactions, - baseCurrency, + tenant.metadata.baseCurrency, ); // Retrieve the inventory valuation report data. const inventoryValuationData = inventoryValuationInstance.reportData(); diff --git a/server/src/services/FinancialStatements/JournalSheet/JournalSheetService.ts b/server/src/services/FinancialStatements/JournalSheet/JournalSheetService.ts index 71f320256..868c37e47 100644 --- a/server/src/services/FinancialStatements/JournalSheet/JournalSheetService.ts +++ b/server/src/services/FinancialStatements/JournalSheet/JournalSheetService.ts @@ -7,6 +7,7 @@ import TenancyService from 'services/Tenancy/TenancyService'; import Journal from 'services/Accounting/JournalPoster'; import InventoryService from 'services/Inventory/Inventory'; import { parseBoolean, transformToMap } from 'utils'; +import { Tenant } from 'system/models'; @Service() export default class JournalSheetService { @@ -86,12 +87,11 @@ export default class JournalSheetService { tenantId, filter, }); - // Settings service. - const settings = this.tenancy.settings(tenantId); - const baseCurrency = settings.get({ - group: 'organization', - key: 'base_currency', - }); + + const tenant = await Tenant.query() + .findById(tenantId) + .withGraphFetched('metadata'); + // Retrieve all accounts on the storage. const accountsGraph = await accountRepository.getDependencyGraph(); @@ -127,7 +127,7 @@ export default class JournalSheetService { transactionsJournal, accountsGraph, contactsByIdMap, - baseCurrency, + tenant.metadata.baseCurrency, i18n ); // Retrieve journal report columns. diff --git a/server/src/services/FinancialStatements/ProfitLossSheet/ProfitLossSheetService.ts b/server/src/services/FinancialStatements/ProfitLossSheet/ProfitLossSheetService.ts index 3ca848d38..f6dd57aec 100644 --- a/server/src/services/FinancialStatements/ProfitLossSheet/ProfitLossSheetService.ts +++ b/server/src/services/FinancialStatements/ProfitLossSheet/ProfitLossSheetService.ts @@ -7,6 +7,7 @@ import TenancyService from 'services/Tenancy/TenancyService'; import AccountsService from 'services/Accounts/AccountsService'; import InventoryService from 'services/Inventory/Inventory'; import { parseBoolean } from 'utils'; +import { Tenant } from 'system/models'; // Profit/Loss sheet service. @Service() @@ -103,12 +104,10 @@ export default class ProfitLossSheetService { filter.accountsIds ); } - // Settings tenant service. - const settings = this.tenancy.settings(tenantId); - const baseCurrency = settings.get({ - group: 'organization', - key: 'base_currency', - }); + const tenant = await Tenant.query() + .findById(tenantId) + .withGraphFetched('metadata'); + // Retrieve all accounts on the storage. const accounts = await accountRepository.all(); const accountsGraph = await accountRepository.getDependencyGraph(); @@ -130,7 +129,7 @@ export default class ProfitLossSheetService { filter, accounts, transactionsJournal, - baseCurrency + tenant.metadata.baseCurrency, ); // Profit/loss report data and collumns. const profitLossData = profitLossInstance.reportData(); diff --git a/server/src/services/FinancialStatements/PurchasesByItems/PurchasesByItemsService.ts b/server/src/services/FinancialStatements/PurchasesByItems/PurchasesByItemsService.ts index 80455f585..a50741f93 100644 --- a/server/src/services/FinancialStatements/PurchasesByItems/PurchasesByItemsService.ts +++ b/server/src/services/FinancialStatements/PurchasesByItems/PurchasesByItemsService.ts @@ -7,6 +7,7 @@ import { } from 'interfaces'; import TenancyService from 'services/Tenancy/TenancyService'; import PurchasesByItems from './PurchasesByItems'; +import { Tenant } from 'system/models'; @Service() export default class InventoryValuationReportService { @@ -77,12 +78,9 @@ export default class InventoryValuationReportService { }> { const { Item, InventoryTransaction } = this.tenancy.models(tenantId); - // Settings tenant service. - const settings = this.tenancy.settings(tenantId); - const baseCurrency = settings.get({ - group: 'organization', - key: 'base_currency', - }); + const tenant = await Tenant.query() + .findById(tenantId) + .withGraphFetched('metadata'); const filter = { ...this.defaultQuery, @@ -119,7 +117,7 @@ export default class InventoryValuationReportService { filter, inventoryItems, inventoryTransactions, - baseCurrency + tenant.metadata.baseCurrency ); const purchasesByItemsData = purchasesByItemsInstance.reportData(); diff --git a/server/src/services/FinancialStatements/SalesByItems/SalesByItemsService.ts b/server/src/services/FinancialStatements/SalesByItems/SalesByItemsService.ts index 093027fa2..fbef4e845 100644 --- a/server/src/services/FinancialStatements/SalesByItems/SalesByItemsService.ts +++ b/server/src/services/FinancialStatements/SalesByItems/SalesByItemsService.ts @@ -7,6 +7,7 @@ import { } from 'interfaces'; import TenancyService from 'services/Tenancy/TenancyService'; import SalesByItems from './SalesByItems'; +import { Tenant } from 'system/models'; @Service() export default class SalesByItemsReportService { @@ -77,12 +78,9 @@ export default class SalesByItemsReportService { }> { const { Item, InventoryTransaction } = this.tenancy.models(tenantId); - // Settings tenant service. - const settings = this.tenancy.settings(tenantId); - const baseCurrency = settings.get({ - group: 'organization', - key: 'base_currency', - }); + const tenant = await Tenant.query() + .findById(tenantId) + .withGraphFetched('metadata'); const filter = { ...this.defaultQuery, @@ -120,7 +118,7 @@ export default class SalesByItemsReportService { filter, inventoryItems, inventoryTransactions, - baseCurrency + tenant.metadata.baseCurrency, ); const purchasesByItemsData = purchasesByItemsInstance.reportData(); diff --git a/server/src/services/FinancialStatements/TransactionsByCustomer/TransactionsByCustomersService.ts b/server/src/services/FinancialStatements/TransactionsByCustomer/TransactionsByCustomersService.ts index 89c2128c7..b93c540d9 100644 --- a/server/src/services/FinancialStatements/TransactionsByCustomer/TransactionsByCustomersService.ts +++ b/server/src/services/FinancialStatements/TransactionsByCustomer/TransactionsByCustomersService.ts @@ -11,6 +11,7 @@ import { import TransactionsByCustomers from './TransactionsByCustomers'; import Ledger from 'services/Accounting/Ledger'; import TransactionsByCustomersRepository from './TransactionsByCustomersRepository'; +import { Tenant } from 'system/models'; export default class TransactionsByCustomersService implements ITransactionsByCustomersService @@ -112,15 +113,12 @@ export default class TransactionsByCustomersService query: ITransactionsByCustomersFilter ): Promise { const { accountRepository } = this.tenancy.repositories(tenantId); - - // Settings tenant service. - const settings = this.tenancy.settings(tenantId); const i18n = this.tenancy.i18n(tenantId); - const baseCurrency = settings.get({ - group: 'organization', - key: 'base_currency', - }); + // Retrieve tenant information. + const tenant = await Tenant.query() + .findById(tenantId) + .withGraphFetched('metadata'); const filter = { ...this.defaultQuery, @@ -162,7 +160,7 @@ export default class TransactionsByCustomersService accountsGraph, journal, filter, - baseCurrency, + tenant.metadata.baseCurrency, i18n ); diff --git a/server/src/services/FinancialStatements/TransactionsByVendor/TransactionsByVendorService.ts b/server/src/services/FinancialStatements/TransactionsByVendor/TransactionsByVendorService.ts index d8f16136c..ef75b84a1 100644 --- a/server/src/services/FinancialStatements/TransactionsByVendor/TransactionsByVendorService.ts +++ b/server/src/services/FinancialStatements/TransactionsByVendor/TransactionsByVendorService.ts @@ -12,6 +12,7 @@ import { import TransactionsByVendor from './TransactionsByVendor'; import Ledger from 'services/Accounting/Ledger'; import TransactionsByVendorRepository from './TransactionsByVendorRepository'; +import { Tenant } from 'system/models'; export default class TransactionsByVendorsService implements ITransactionsByVendorsService @@ -135,14 +136,12 @@ export default class TransactionsByVendorsService ): Promise { const { accountRepository } = this.tenancy.repositories(tenantId); - // Settings tenant service. - const settings = this.tenancy.settings(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 }; // Retrieve the report vendors. @@ -168,7 +167,7 @@ export default class TransactionsByVendorsService accountsGraph, journal, filter, - baseCurrency, + tenant.metadata.baseCurrency, i18n ); return { diff --git a/server/src/services/FinancialStatements/TrialBalanceSheet/TrialBalanceSheetService.ts b/server/src/services/FinancialStatements/TrialBalanceSheet/TrialBalanceSheetService.ts index 48abaa44a..4d693c9f9 100644 --- a/server/src/services/FinancialStatements/TrialBalanceSheet/TrialBalanceSheetService.ts +++ b/server/src/services/FinancialStatements/TrialBalanceSheet/TrialBalanceSheetService.ts @@ -7,6 +7,7 @@ import TrialBalanceSheet from './TrialBalanceSheet'; import FinancialSheet from '../FinancialSheet'; import InventoryService from 'services/Inventory/Inventory'; import { parseBoolean } from 'utils'; +import { Tenant } from 'system/models'; @Service() export default class TrialBalanceSheetService extends FinancialSheet { @@ -89,12 +90,9 @@ export default class TrialBalanceSheetService extends FinancialSheet { transactionsRepository, } = this.tenancy.repositories(tenantId); - // Settings tenant service. - const settings = this.tenancy.settings(tenantId); - const baseCurrency = settings.get({ - group: 'organization', - key: 'base_currency', - }); + const tenant = await Tenant.query() + .findById(tenantId) + .withGraphFetched('metadata'); this.logger.info('[trial_balance_sheet] trying to calcualte the report.', { tenantId, @@ -122,7 +120,7 @@ export default class TrialBalanceSheetService extends FinancialSheet { filter, accounts, transactionsJournal, - baseCurrency + tenant.metadata.baseCurrency, ); // Trial balance sheet data. const trialBalanceSheetData = trialBalanceInstance.reportData(); diff --git a/server/src/services/FinancialStatements/VendorBalanceSummary/VendorBalanceSummaryService.ts b/server/src/services/FinancialStatements/VendorBalanceSummary/VendorBalanceSummaryService.ts index 19065abb3..7586dc11a 100644 --- a/server/src/services/FinancialStatements/VendorBalanceSummary/VendorBalanceSummaryService.ts +++ b/server/src/services/FinancialStatements/VendorBalanceSummary/VendorBalanceSummaryService.ts @@ -13,6 +13,7 @@ import { import { VendorBalanceSummaryReport } from './VendorBalanceSummary'; import Ledger from 'services/Accounting/Ledger'; import VendorBalanceSummaryRepository from './VendorBalanceSummaryRepository'; +import { Tenant } from 'system/models'; export default class VendorBalanceSummaryService implements IVendorBalanceSummaryService @@ -77,12 +78,9 @@ export default class VendorBalanceSummaryService tenantId: number, query: IVendorBalanceSummaryQuery ): Promise { - // Settings tenant service. - const settings = this.tenancy.settings(tenantId); - const baseCurrency = settings.get({ - group: 'organization', - key: 'base_currency', - }); + const tenant = await Tenant.query() + .findById(tenantId) + .withGraphFetched('metadata'); const filter = { ...this.defaultQuery, ...query }; this.logger.info( @@ -110,7 +108,7 @@ export default class VendorBalanceSummaryService vendorsLedger, vendors, filter, - baseCurrency + tenant.metadata.baseCurrency ); return {