diff --git a/client/src/common/currencies.js b/client/src/common/currencies.js index 8e9ffd911..8ab6d7f86 100644 --- a/client/src/common/currencies.js +++ b/client/src/common/currencies.js @@ -1,5 +1,7 @@ +import { formatMessage } from 'services/intl'; + export default [ - { name: 'US Dollar', code: 'USD' }, - { name: 'Euro', code: 'EUR' }, - { name: 'Libyan Dinar ', code: 'LYD' }, -] \ No newline at end of file + { name: formatMessage({ id: 'us_dollar' }), code: 'USD' }, + { name: formatMessage({ id: 'euro' }), code: 'EUR' }, + { name: formatMessage({ id: 'libyan_diner' }), code: 'LYD' }, +]; diff --git a/client/src/common/languagesOptions.js b/client/src/common/languagesOptions.js index b331d32ec..42c2d787a 100644 --- a/client/src/common/languagesOptions.js +++ b/client/src/common/languagesOptions.js @@ -1,6 +1,6 @@ - +import { formatMessage } from 'services/intl'; export default [ - { name: 'English', value: 'en' }, - { name: 'Arabic', value: 'ar' }, -]; \ No newline at end of file + { name: formatMessage({ id: 'english' }), value: 'en' }, + { name: formatMessage({ id: 'arabic' }), value: 'ar' }, +]; diff --git a/client/src/common/numberFormatsOptions.js b/client/src/common/numberFormatsOptions.js index 0315eae93..a6bd2c26e 100644 --- a/client/src/common/numberFormatsOptions.js +++ b/client/src/common/numberFormatsOptions.js @@ -1,7 +1,9 @@ +import { formatMessage } from 'services/intl'; + export const moneyFormat = [ - { key: 'total', text: 'Total rows' }, - { key: 'always', text: 'Always' }, - { key: 'none', text: 'None' }, + { key: 'total', text: formatMessage({ id: 'total_rows' }) }, + { key: 'always', text: formatMessage({ id: 'always' }) }, + { key: 'none', text: formatMessage({ id: 'none' }) }, ]; export const negativeFormat = [ diff --git a/client/src/containers/FinancialStatements/APAgingSummary/components.js b/client/src/containers/FinancialStatements/APAgingSummary/components.js index 89b054997..5c9e21771 100644 --- a/client/src/containers/FinancialStatements/APAgingSummary/components.js +++ b/client/src/containers/FinancialStatements/APAgingSummary/components.js @@ -2,6 +2,8 @@ import React, { useMemo } from 'react'; import { useAPAgingSummaryContext } from './APAgingSummaryProvider'; import { getColumnWidth } from 'utils'; import { FormattedMessage as T } from 'react-intl'; +import { formatMessage } from 'services/intl'; + import { If } from 'components'; import FinancialLoadingBar from '../FinancialLoadingBar'; @@ -16,7 +18,9 @@ export const useAPAgingSummaryColumns = () => { const agingColumns = React.useMemo(() => { return columns.map( (agingColumn) => - `${agingColumn.before_days} - ${agingColumn.to_days || 'And Over'}`, + `${agingColumn.before_days} - ${ + agingColumn.to_days || formatMessage({ id: 'and_over' }) + }`, ); }, [columns]); @@ -60,14 +64,12 @@ export const useAPAgingSummaryColumns = () => { /** * A/P aging summary sheet loading bar. */ - export function APAgingSummarySheetLoadingBar() { - const { - isAPAgingFetching - } = useAPAgingSummaryContext(); +export function APAgingSummarySheetLoadingBar() { + const { isAPAgingFetching } = useAPAgingSummaryContext(); return ( - ) -} \ No newline at end of file + ); +} diff --git a/client/src/containers/FinancialStatements/ARAgingSummary/components.js b/client/src/containers/FinancialStatements/ARAgingSummary/components.js index b78f92ee9..2a2c6e997 100644 --- a/client/src/containers/FinancialStatements/ARAgingSummary/components.js +++ b/client/src/containers/FinancialStatements/ARAgingSummary/components.js @@ -2,6 +2,7 @@ import React from 'react'; import { useARAgingSummaryContext } from './ARAgingSummaryProvider'; import { getColumnWidth } from 'utils'; import { FormattedMessage as T } from 'react-intl'; +import { formatMessage } from 'services/intl'; import { If } from 'components'; import FinancialLoadingBar from '../FinancialLoadingBar'; @@ -16,7 +17,9 @@ export const useARAgingSummaryColumns = () => { const agingColumns = React.useMemo(() => { return columns.map( (agingColumn) => - `${agingColumn.before_days} - ${agingColumn.to_days || 'And Over'}`, + `${agingColumn.before_days} - ${ + agingColumn.to_days || formatMessage({ id: 'and_over' }) + }`, ); }, [columns]); @@ -62,14 +65,12 @@ export const useARAgingSummaryColumns = () => { /** * A/R aging summary sheet loading bar. */ - export function ARAgingSummarySheetLoadingBar() { - const { - isARAgingFetching, - } = useARAgingSummaryContext(); +export function ARAgingSummarySheetLoadingBar() { + const { isARAgingFetching } = useARAgingSummaryContext(); return ( - ) -} \ No newline at end of file + ); +} diff --git a/client/src/containers/FinancialStatements/BalanceSheet/components.js b/client/src/containers/FinancialStatements/BalanceSheet/components.js index ad0992fb9..f8d90e2d4 100644 --- a/client/src/containers/FinancialStatements/BalanceSheet/components.js +++ b/client/src/containers/FinancialStatements/BalanceSheet/components.js @@ -2,34 +2,32 @@ import React from 'react'; import { Button } from '@blueprintjs/core'; import { Icon, If } from 'components'; import { useBalanceSheetContext } from './BalanceSheetProvider'; +import { FormattedMessage as T } from 'react-intl'; import FinancialLoadingBar from '../FinancialLoadingBar'; /** * Balance sheet alerts. */ export function BalanceSheetAlerts() { - const { - isLoading, - refetchBalanceSheet, - balanceSheet, - } = useBalanceSheetContext(); + const { isLoading, refetchBalanceSheet, balanceSheet } = + useBalanceSheetContext(); // Handle refetch the report sheet. const handleRecalcReport = () => { refetchBalanceSheet(); }; // Can't display any error if the report is loading. - if (isLoading) { return null; } + if (isLoading) { + return null; + } return (
- Just a moment! We're - calculating your cost transactions and this doesn't take much time. - Please check after sometime.{' '} - + {' '} +
@@ -40,13 +38,11 @@ export function BalanceSheetAlerts() { * Balance sheet loading bar. */ export function BalanceSheetLoadingBar() { - const { - isFetching - } = useBalanceSheetContext(); + const { isFetching } = useBalanceSheetContext(); return ( - ) -} \ No newline at end of file + ); +} diff --git a/client/src/containers/FinancialStatements/CashFlowStatement/components.js b/client/src/containers/FinancialStatements/CashFlowStatement/components.js index 5097af88f..37c8dcb8d 100644 --- a/client/src/containers/FinancialStatements/CashFlowStatement/components.js +++ b/client/src/containers/FinancialStatements/CashFlowStatement/components.js @@ -1,6 +1,7 @@ import React from 'react'; import { Button } from '@blueprintjs/core'; import { Icon, If } from 'components'; +import { FormattedMessage as T } from 'react-intl'; import { dynamicColumns } from './utils'; import { useCashFlowStatementContext } from './CashFlowStatementProvider'; @@ -52,11 +53,10 @@ export function CashFlowStatementAlerts() { return (
- Just a moment! We're - calculating your cost transactions and this doesn't take much time. - Please check after sometime. + +
diff --git a/client/src/containers/FinancialStatements/GeneralLedger/components.js b/client/src/containers/FinancialStatements/GeneralLedger/components.js index 270d0f1e2..d180e7253 100644 --- a/client/src/containers/FinancialStatements/GeneralLedger/components.js +++ b/client/src/containers/FinancialStatements/GeneralLedger/components.js @@ -2,6 +2,8 @@ import React from 'react'; import { useIntl } from 'react-intl'; import { Button } from '@blueprintjs/core'; import { Icon, If } from 'components'; +import { FormattedMessage as T } from 'react-intl'; + import { getForceWidth, getColumnWidth } from 'utils'; import { useGeneralLedgerContext } from './GeneralLedgerProvider'; import FinancialLoadingBar from '../FinancialLoadingBar'; @@ -68,7 +70,6 @@ export function useGeneralLedgerTableColumns() { accessor: 'formatted_credit', className: 'credit', width: getColumnWidth(tableRows, 'formatted_credit', { - minWidth: 100, magicSpacing: 10, }), @@ -105,33 +106,28 @@ export function useGeneralLedgerTableColumns() { ); } - /** * General ledger sheet alerts. */ - export function GeneralLedgerSheetAlerts() { - const { - generalLedger, - isLoading, - sheetRefresh - } = useGeneralLedgerContext(); +export function GeneralLedgerSheetAlerts() { + const { generalLedger, isLoading, sheetRefresh } = useGeneralLedgerContext(); // Handle refetch the report sheet. const handleRecalcReport = () => { sheetRefresh(); }; // Can't display any error if the report is loading. - if (isLoading) { return null; } + if (isLoading) { + return null; + } return (
- Just a moment! We're - calculating your cost transactions and this doesn't take much time. - Please check after sometime.{' '} - + +
@@ -142,13 +138,11 @@ export function useGeneralLedgerTableColumns() { * General ledger sheet loading bar. */ export function GeneralLedgerSheetLoadingBar() { - const { - isFetching, - } = useGeneralLedgerContext(); + const { isFetching } = useGeneralLedgerContext(); return ( - ) + ); } diff --git a/client/src/containers/FinancialStatements/InventoryItemDetails/components.js b/client/src/containers/FinancialStatements/InventoryItemDetails/components.js index 58e44e528..915cd7ee2 100644 --- a/client/src/containers/FinancialStatements/InventoryItemDetails/components.js +++ b/client/src/containers/FinancialStatements/InventoryItemDetails/components.js @@ -1,6 +1,7 @@ import React from 'react'; import { Button } from '@blueprintjs/core'; import { Icon, If } from 'components'; +import { FormattedMessage as T } from 'react-intl'; import { dynamicColumns } from './utils'; import FinancialLoadingBar from '../FinancialLoadingBar'; @@ -51,15 +52,15 @@ export function InventoryItemDetailsAlerts() { if (isInventoryItemDetailsLoading) { return null; } - + return (
- Just a moment! We're - calculating your cost transactions and this doesn't take much time. - Please check after sometime. + + +
diff --git a/client/src/containers/FinancialStatements/Journal/components.js b/client/src/containers/FinancialStatements/Journal/components.js index a658be52a..133641785 100644 --- a/client/src/containers/FinancialStatements/Journal/components.js +++ b/client/src/containers/FinancialStatements/Journal/components.js @@ -1,5 +1,6 @@ import React from 'react'; -import { useIntl } from 'react-intl'; +import { FormattedMessage as T, useIntl } from 'react-intl'; + import moment from 'moment'; import { Button } from '@blueprintjs/core'; import { Icon, If } from 'components'; @@ -69,45 +70,40 @@ export const useJournalTableColumns = () => { * Journal sheet loading bar. */ export function JournalSheetLoadingBar() { - const { - isFetching - } = useJournalSheetContext(); + const { isFetching } = useJournalSheetContext(); return ( - ) + ); } /** * Journal sheet alerts. */ - export function JournalSheetAlerts() { - const { - isLoading, - refetchSheet, - journalSheet, - } = useJournalSheetContext(); +export function JournalSheetAlerts() { + const { isLoading, refetchSheet, journalSheet } = useJournalSheetContext(); // Handle refetch the report sheet. const handleRecalcReport = () => { refetchSheet(); }; // Can't display any error if the report is loading. - if (isLoading) { return null; } + if (isLoading) { + return null; + } return (
- Just a moment! We're - calculating your cost transactions and this doesn't take much time. - Please check after sometime.{' '} + +
); -} \ No newline at end of file +} diff --git a/client/src/containers/FinancialStatements/ProfitLossSheet/components.js b/client/src/containers/FinancialStatements/ProfitLossSheet/components.js index 6e69b4438..46a8f7ac1 100644 --- a/client/src/containers/FinancialStatements/ProfitLossSheet/components.js +++ b/client/src/containers/FinancialStatements/ProfitLossSheet/components.js @@ -1,6 +1,8 @@ import React from 'react'; import { Button } from '@blueprintjs/core'; import { Icon, If } from 'components'; +import { FormattedMessage as T } from 'react-intl'; + import { useProfitLossSheetContext } from './ProfitLossProvider'; import FinancialLoadingBar from '../FinancialLoadingBar'; @@ -21,11 +23,8 @@ export function ProfitLossSheetLoadingBar() { * Balance sheet alerts. */ export function ProfitLossSheetAlerts() { - const { - isLoading, - sheetRefetch, - profitLossSheet, - } = useProfitLossSheetContext(); + const { isLoading, sheetRefetch, profitLossSheet } = + useProfitLossSheetContext(); // Handle refetch the report sheet. const handleRecalcReport = () => { @@ -39,11 +38,11 @@ export function ProfitLossSheetAlerts() { return (
- Just a moment! We're - calculating your cost transactions and this doesn't take much time. - Please check after sometime.{' '} + + +
diff --git a/client/src/containers/FinancialStatements/TrialBalanceSheet/components.js b/client/src/containers/FinancialStatements/TrialBalanceSheet/components.js index 21756d0ee..facf51cb2 100644 --- a/client/src/containers/FinancialStatements/TrialBalanceSheet/components.js +++ b/client/src/containers/FinancialStatements/TrialBalanceSheet/components.js @@ -1,5 +1,6 @@ import React from 'react'; -import { useIntl } from 'react-intl'; +import { FormattedMessage as T, useIntl } from 'react-intl'; + import { Button } from '@blueprintjs/core'; import { getColumnWidth } from 'utils'; import { If, Icon } from 'components'; @@ -60,15 +61,13 @@ export const useTrialBalanceTableColumns = () => { * Trial balance sheet progress loading bar. */ export function TrialBalanceSheetLoadingBar() { - const { - isFetching - } = useTrialBalanceSheetContext(); + const { isFetching } = useTrialBalanceSheetContext(); return ( - ) + ); } /** @@ -78,7 +77,7 @@ export function TrialBalanceSheetAlerts() { const { trialBalanceSheet: { meta }, isLoading, - refetchSheet + refetchSheet, } = useTrialBalanceSheetContext(); // Handle refetch the sheet. @@ -86,19 +85,20 @@ export function TrialBalanceSheetAlerts() { refetchSheet(); }; // Can't display any error if the report is loading. - if (isLoading) { return null; } + if (isLoading) { + return null; + } return (
- Just a moment! We're - calculating your cost transactions and this doesn't take much time. - Please check after sometime.{' '} + +
- ) -} \ No newline at end of file + ); +} diff --git a/client/src/containers/FinancialStatements/common.js b/client/src/containers/FinancialStatements/common.js index 73c7a3537..5f9ab501f 100644 --- a/client/src/containers/FinancialStatements/common.js +++ b/client/src/containers/FinancialStatements/common.js @@ -3,21 +3,46 @@ import { transfromToSnakeCase, flatObject } from 'utils'; import { formatMessage } from 'services/intl'; export const displayColumnsByOptions = [ - { key: 'total', name: 'Total', type: 'total', by: '' }, - { key: 'year', name: 'Date/Year', type: 'date_periods', by: 'year' }, - { key: 'month', name: 'Date/Month', type: 'date_periods', by: 'month' }, - { key: 'week', name: 'Date/Week', type: 'date_periods', by: 'month' }, - { key: 'day', name: 'Date/Day', type: 'date_periods', by: 'day' }, - { key: 'quarter', name: 'Date/Quarter', type: 'date_periods', by: 'quarter' }, + { key: 'total', name: formatMessage({ id: 'total' }), type: 'total', by: '' }, + { + key: 'year', + name: formatMessage({ id: 'date_year' }), + type: 'date_periods', + by: 'year', + }, + { + key: 'month', + name: formatMessage({ id: 'date_month' }), + type: 'date_periods', + by: 'month', + }, + { + key: 'week', + name: formatMessage({ id: 'date_week' }), + type: 'date_periods', + by: 'month', + }, + { + key: 'day', + name: formatMessage({ id: 'date_day' }), + type: 'date_periods', + by: 'day', + }, + { + key: 'quarter', + name: formatMessage({ id: 'date_quarter' }), + type: 'date_periods', + by: 'quarter', + }, ]; export const dateRangeOptions = [ - { value: 'today', label: 'Today' }, - { value: 'this_week', label: 'This Week' }, - { value: 'this_month', label: 'This Month' }, - { value: 'this_quarter', label: 'This Quarter' }, - { value: 'this_year', label: 'This Year' }, - { value: 'custom', label: 'Custom Range' }, + { value: 'today', label: formatMessage({ id: 'today' }) }, + { value: 'this_week', label: formatMessage({ id: 'this_week' }) }, + { value: 'this_month', label: formatMessage({ id: 'this_month' }) }, + { value: 'this_quarter', label: formatMessage({ id: 'this_quarter' }) }, + { value: 'this_year', label: formatMessage({ id: 'this_year' }) }, + { value: 'custom', label: formatMessage({ id: 'custom_range' }) }, ]; export const filterAccountsOptions = [ diff --git a/client/src/containers/FinancialStatements/reducers.js b/client/src/containers/FinancialStatements/reducers.js index add2c4f49..d74cb844e 100644 --- a/client/src/containers/FinancialStatements/reducers.js +++ b/client/src/containers/FinancialStatements/reducers.js @@ -1,5 +1,7 @@ +import React from 'react'; import { chain } from 'lodash'; import moment from 'moment'; +import { FormattedMessage as T } from 'react-intl'; export const balanceSheetRowsReducer = (accounts) => { return accounts.map((account) => { @@ -10,7 +12,7 @@ export const balanceSheetRowsReducer = (accounts) => { ...(account.total && account.children && account.children.length > 0 ? [ { - name: `Total ${account.name}`, + name: , row_types: ['total-row', account.section_type], total: { ...account.total }, ...(account.total_periods && { @@ -46,12 +48,12 @@ export const profitLossSheetReducer = (profitLoss) => { if (profitLoss.income) { results.push({ - name: 'Income', + name: , total: profitLoss.income.total, children: [ ...profitLoss.income.accounts, { - name: 'Total Income', + name: , total: profitLoss.income.total, total_periods: profitLoss.income.total_periods, rowTypes: ['income_total', 'section_total', 'total'], @@ -62,12 +64,12 @@ export const profitLossSheetReducer = (profitLoss) => { } if (profitLoss.cost_of_sales) { results.push({ - name: 'Cost of sales', + name: , total: profitLoss.cost_of_sales.total, children: [ ...profitLoss.cost_of_sales.accounts, { - name: 'Total cost of sales', + name: , total: profitLoss.cost_of_sales.total, total_periods: profitLoss.cost_of_sales.total_periods, rowTypes: ['cogs_total', 'section_total', 'total'], @@ -78,7 +80,7 @@ export const profitLossSheetReducer = (profitLoss) => { } if (profitLoss.gross_profit) { results.push({ - name: 'Gross profit', + name: , total: profitLoss.gross_profit.total, total_periods: profitLoss.gross_profit.total_periods, rowTypes: ['gross_total', 'section_total', 'total'], @@ -86,12 +88,12 @@ export const profitLossSheetReducer = (profitLoss) => { } if (profitLoss.expenses) { results.push({ - name: 'Expenses', + name: , total: profitLoss.expenses.total, children: [ ...profitLoss.expenses.accounts, { - name: 'Total Expenses', + name: , total: profitLoss.expenses.total, total_periods: profitLoss.expenses.total_periods, rowTypes: ['expenses_total', 'section_total', 'total'], @@ -102,7 +104,7 @@ export const profitLossSheetReducer = (profitLoss) => { } if (profitLoss.operating_profit) { results.push({ - name: 'Net Operating income', + name: , total: profitLoss.operating_profit.total, total_periods: profitLoss.income.total_periods, rowTypes: ['net_operating_total', 'section_total', 'total'], @@ -110,13 +112,13 @@ export const profitLossSheetReducer = (profitLoss) => { } if (profitLoss.other_income) { results.push({ - name: 'Other Income', + name: 'other_income', total: profitLoss.other_income.total, total_periods: profitLoss.other_income.total_periods, children: [ ...profitLoss.other_income.accounts, { - name: 'Total other income', + name: , total: profitLoss.other_income.total, total_periods: profitLoss.other_income.total_periods, rowTypes: ['expenses_total', 'section_total', 'total'], @@ -126,13 +128,13 @@ export const profitLossSheetReducer = (profitLoss) => { } if (profitLoss.other_expenses) { results.push({ - name: 'Other expenses', + name: , total: profitLoss.other_expenses.total, total_periods: profitLoss.other_expenses.total_periods, children: [ ...profitLoss.other_expenses.accounts, { - name: 'Total other expenses', + name: , total: profitLoss.other_expenses.total, total_periods: profitLoss.other_expenses.total_periods, rowTypes: ['expenses_total', 'section_total', 'total'], @@ -142,7 +144,7 @@ export const profitLossSheetReducer = (profitLoss) => { } if (profitLoss.net_other_income) { results.push({ - name: 'Net other income', + name: , total: profitLoss.net_other_income.total, total_periods: profitLoss.net_other_income.total_periods, rowTypes: ['net_other_income', 'section_total', 'total'], @@ -150,7 +152,7 @@ export const profitLossSheetReducer = (profitLoss) => { } if (profitLoss.net_income) { results.push({ - name: 'Net Income', + name: , total: profitLoss.net_income.total, total_periods: profitLoss.net_income.total_periods, rowTypes: ['net_income_total', 'section_total', 'total'], @@ -215,7 +217,7 @@ export const generalLedgerTableRowsReducer = (accounts) => { children: [ { ...account.opening_balance, - name: 'Opening balance', + name: , rowType: 'OPENING_BALANCE', date: moment(account.opening_balance.date).format('DD MMM YYYY'), }, @@ -227,7 +229,7 @@ export const generalLedgerTableRowsReducer = (accounts) => { })), { ...account.closing_balance, - name: 'Closing balance', + name: , rowType: 'CLOSING_BALANCE', date: moment(account.closing_balance.date).format('DD MMM YYYY'), }, @@ -357,4 +359,4 @@ export const salesByItemsReducer = (sheet) => { }); } return results; -}; \ No newline at end of file +}; diff --git a/client/src/lang/en/index.json b/client/src/lang/en/index.json index cf99bf452..7af683d9e 100644 --- a/client/src/lang/en/index.json +++ b/client/src/lang/en/index.json @@ -1030,5 +1030,41 @@ "create_a_new_bill": "Create a new bill.", "create_a_new_make_journal": "Create a new Make Journal.", "create_a_new_item": "Create a new item.", - "close_and_open_sidebar": "Close and open sidebar." + "close_and_open_sidebar": "Close and open sidebar.", + "and_over": "And Over", + "date_year": "Date/Year", + "date_month": "Date/Month", + "date_week": "Date/Week", + "date_day": "Date/Day", + "date_quarter": "Date/Quarter", + "today": "Today", + "this_week": "This Week", + "this_month": "This Month", + "this_quarter": "This Quarter", + "this_year": "This Year", + "custom_range": "Custom Range", + "total_rows": "Total rows", + "always": "Always", + "none": "None", + "us_dollar": "US Dollar", + "euro": "Euro", + "libyan_diner": "Libyan Diner", + "english": "English", + "arabic": "Arabic", + "just_a_moment_we_re_calculating_your_cost_transactions": "Just a moment! We're calculating your cost transactions and this doesn't take much time.Please check after sometime.", + "refresh": "Refresh", + "total_name": "Total {name}", + "income": "Income", + "total_income": "Total Income", + "cost_of_sales": "Cost of sales", + "total_cost_of_sales": "Total cost of sales", + "gross_profit": "Gross profit", + "total_expenses": "Total Expenses", + "net_operating_income": "Net Operating income", + "other_income": "Other Income", + "total_other_income": "Total other income", + "other_expenses": "Other expenses", + "total_other_expenses": "Total other expenses", + "net_other_income": "Net other income", + "net_income": "Net Income" } \ No newline at end of file