mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 22:00:31 +00:00
fix: Trial balance sheet adjusted balance (#273)
This commit is contained in:
@@ -1,88 +1,10 @@
|
||||
// @ts-nocheck
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import { Button } from '@blueprintjs/core';
|
||||
|
||||
import { Align } from '@/constants';
|
||||
import { getColumnWidth } from '@/utils';
|
||||
import { CellTextSpan } from '@/components/Datatable/Cells';
|
||||
import { If, Icon, FormattedMessage as T } from '@/components';
|
||||
import { useTrialBalanceSheetContext } from './TrialBalanceProvider';
|
||||
import { FinancialComputeAlert } from '../FinancialReportPage';
|
||||
import FinancialLoadingBar from '../FinancialLoadingBar';
|
||||
|
||||
/**
|
||||
* Retrieves the credit column.
|
||||
*/
|
||||
const getCreditColumn = (data) => {
|
||||
const width = getColumnWidth(data, `credit`, { minWidth: 140 });
|
||||
|
||||
return {
|
||||
Header: intl.get('credit'),
|
||||
Cell: CellTextSpan,
|
||||
accessor: 'formatted_credit',
|
||||
className: 'credit',
|
||||
width,
|
||||
textOverview: true,
|
||||
align: Align.Right,
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the debit column.
|
||||
*/
|
||||
const getDebitColumn = (data) => {
|
||||
return {
|
||||
Header: intl.get('debit'),
|
||||
Cell: CellTextSpan,
|
||||
accessor: 'formatted_debit',
|
||||
width: getColumnWidth(data, `debit`, { minWidth: 140 }),
|
||||
textOverview: true,
|
||||
align: Align.Right,
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the balance column.
|
||||
*/
|
||||
const getBalanceColumn = (data) => {
|
||||
return {
|
||||
Header: intl.get('balance'),
|
||||
Cell: CellTextSpan,
|
||||
accessor: 'formatted_balance',
|
||||
className: 'balance',
|
||||
width: getColumnWidth(data, `balance`, { minWidth: 140 }),
|
||||
textOverview: true,
|
||||
align: Align.Right,
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieve trial balance sheet table columns.
|
||||
*/
|
||||
export const useTrialBalanceTableColumns = () => {
|
||||
// Trial balance sheet context.
|
||||
const {
|
||||
trialBalanceSheet: { tableRows },
|
||||
} = useTrialBalanceSheetContext();
|
||||
|
||||
return React.useMemo(
|
||||
() => [
|
||||
{
|
||||
Header: intl.get('account_name'),
|
||||
accessor: (row) => (row.code ? `${row.name} - ${row.code}` : row.name),
|
||||
className: 'name',
|
||||
width: 350,
|
||||
textOverview: true,
|
||||
},
|
||||
getCreditColumn(tableRows),
|
||||
getDebitColumn(tableRows),
|
||||
getBalanceColumn(tableRows),
|
||||
],
|
||||
[tableRows],
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Trial balance sheet progress loading bar.
|
||||
*/
|
||||
@@ -101,7 +23,7 @@ export function TrialBalanceSheetLoadingBar() {
|
||||
*/
|
||||
export function TrialBalanceSheetAlerts() {
|
||||
const {
|
||||
trialBalanceSheet: { meta },
|
||||
trialBalanceSheet,
|
||||
isLoading,
|
||||
refetchSheet,
|
||||
} = useTrialBalanceSheetContext();
|
||||
@@ -115,7 +37,7 @@ export function TrialBalanceSheetAlerts() {
|
||||
return null;
|
||||
}
|
||||
// Can't continue if the cost compute job is not running.
|
||||
if (!meta.is_cost_compute_running) {
|
||||
if (!trialBalanceSheet?.meta.is_cost_compute_running) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user