mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-22 07:40:32 +00:00
feat: optimize style of account drawer.
This commit is contained in:
@@ -28,8 +28,6 @@ function AccountDrawerActionBar({
|
|||||||
// #ownProps
|
// #ownProps
|
||||||
account,
|
account,
|
||||||
}) {
|
}) {
|
||||||
|
|
||||||
|
|
||||||
// Handle new child button click.
|
// Handle new child button click.
|
||||||
const onNewChildAccount = () => {
|
const onNewChildAccount = () => {
|
||||||
openDialog('account-form', {
|
openDialog('account-form', {
|
||||||
@@ -69,9 +67,9 @@ function AccountDrawerActionBar({
|
|||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
className={Classes.MINIMAL}
|
className={Classes.MINIMAL}
|
||||||
icon={<Icon style={{ color: 'red' }} icon="trash-18" iconSize={18} />}
|
icon={<Icon icon="trash-18" iconSize={18} />}
|
||||||
text={<T id={'delete'} />}
|
text={<T id={'delete'} />}
|
||||||
// intent={Intent.DANGER}
|
intent={Intent.DANGER}
|
||||||
onClick={safeCallback(onDeleteAccount)}
|
onClick={safeCallback(onDeleteAccount)}
|
||||||
/>
|
/>
|
||||||
</NavbarGroup>
|
</NavbarGroup>
|
||||||
|
|||||||
@@ -8,9 +8,10 @@ import AccountDrawerDetails from './AccountDrawerDetails';
|
|||||||
export default function AccountDrawerContent({
|
export default function AccountDrawerContent({
|
||||||
// #ownProp
|
// #ownProp
|
||||||
accountId,
|
accountId,
|
||||||
|
name
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<AccountDrawerProvider accountId={accountId}>
|
<AccountDrawerProvider name={name} accountId={accountId}>
|
||||||
<AccountDrawerDetails />
|
<AccountDrawerDetails />
|
||||||
</AccountDrawerProvider>
|
</AccountDrawerProvider>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { FormattedMessage as T } from 'react-intl';
|
import { FormattedMessage as T } from 'react-intl';
|
||||||
import { If, Money } from 'components';
|
import { Icon, Money } from 'components';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Account drawer header.
|
* Account drawer header.
|
||||||
@@ -23,17 +23,24 @@ export default function AccountDrawerHeader({
|
|||||||
{<Money amount={amount} currency={currency_code} />}
|
{<Money amount={amount} currency={currency_code} />}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class={'account-type'}>
|
||||||
<span>
|
<span>
|
||||||
<T id={'account_type'} />
|
<T id={'account_type'} />
|
||||||
</span>
|
</span>
|
||||||
<p>{account_type_label}</p>
|
<p>{account_type_label}</p>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div class={'account-normal'}>
|
||||||
<span>
|
<span>
|
||||||
<T id={'account_normal'} />
|
<T id={'account_normal'} />
|
||||||
</span>
|
</span>
|
||||||
<p> {account_normal}</p>
|
<p>
|
||||||
|
{' '}
|
||||||
|
{account_normal}{' '}
|
||||||
|
<Icon
|
||||||
|
iconSize={14}
|
||||||
|
icon={`arrow-${account_normal === 'credit' ? 'down' : 'up'}`}
|
||||||
|
/>
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<span>
|
<span>
|
||||||
@@ -49,12 +56,10 @@ export default function AccountDrawerHeader({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p className={'account-drawer__content--desc'}>
|
<p className={'account-drawer__content--desc'}>
|
||||||
<If condition={description}>
|
|
||||||
<b>
|
<b>
|
||||||
<T id={'description'} />
|
<T id={'description'} />
|
||||||
</b>
|
</b>
|
||||||
: {description}
|
: {description ? description : '--'}
|
||||||
</If>
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ const AccountDrawerContext = React.createContext();
|
|||||||
/**
|
/**
|
||||||
* Account drawer provider.
|
* Account drawer provider.
|
||||||
*/
|
*/
|
||||||
function AccountDrawerProvider({ accountId, ...props }) {
|
function AccountDrawerProvider({ accountId, name, ...props }) {
|
||||||
// Fetches the specific account details.
|
// Fetches the specific account details.
|
||||||
const { data: account, isLoading: isAccountLoading } = useAccount(accountId, {
|
const { data: account, isLoading: isAccountLoading } = useAccount(accountId, {
|
||||||
enabled: !!accountId,
|
enabled: !!accountId,
|
||||||
@@ -20,18 +20,19 @@ function AccountDrawerProvider({ accountId, ...props }) {
|
|||||||
} = useAccountTransactions(accountId, {
|
} = useAccountTransactions(accountId, {
|
||||||
enabled: !!accountId,
|
enabled: !!accountId,
|
||||||
});
|
});
|
||||||
const name = `${account.name} ${account.code}`;
|
const drawerTitle = `${account.name} ${account.code}`;
|
||||||
|
|
||||||
// provider.
|
// provider.
|
||||||
const provider = {
|
const provider = {
|
||||||
accountId,
|
accountId,
|
||||||
account,
|
account,
|
||||||
accounts,
|
accounts,
|
||||||
|
drawerName: name,
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DashboardInsider loading={isAccountLoading || isAccountsLoading}>
|
<DashboardInsider loading={isAccountLoading || isAccountsLoading}>
|
||||||
<DrawerHeaderContent name={'account-drawer'} title={name} />
|
<DrawerHeaderContent name={'account-drawer'} title={drawerTitle} />
|
||||||
<AccountDrawerContext.Provider value={provider} {...props} />
|
<AccountDrawerContext.Provider value={provider} {...props} />
|
||||||
</DashboardInsider>
|
</DashboardInsider>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,18 +1,23 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
import { useAccountDrawerContext } from './AccountDrawerProvider';
|
import { useAccountDrawerContext } from './AccountDrawerProvider';
|
||||||
|
|
||||||
import { formatMessage } from 'services/intl';
|
import { formatMessage } from 'services/intl';
|
||||||
import { DataTable, Money } from 'components';
|
import { DataTable, Money } from 'components';
|
||||||
import { isBlank } from 'utils';
|
import { isBlank, compose } from 'utils';
|
||||||
|
import withDrawerActions from 'containers/Drawer/withDrawerActions';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* account drawer table.
|
* account drawer table.
|
||||||
*/
|
*/
|
||||||
export default function AccountDrawerTable() {
|
function AccountDrawerTable({
|
||||||
|
closeDrawer
|
||||||
|
}) {
|
||||||
const {
|
const {
|
||||||
account: { currency_code },
|
account: { currency_code },
|
||||||
accounts,
|
accounts,
|
||||||
|
drawerName
|
||||||
} = useAccountDrawerContext();
|
} = useAccountDrawerContext();
|
||||||
|
|
||||||
const columns = React.useMemo(
|
const columns = React.useMemo(
|
||||||
@@ -45,16 +50,33 @@ export default function AccountDrawerTable() {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
Header: formatMessage({ id: 'running_balance' }),
|
Header: formatMessage({ id: 'running_balance' }),
|
||||||
accessor: 'balance',
|
accessor: ({ running_balance }) => (
|
||||||
|
<Money amount={running_balance} currency={currency_code} />
|
||||||
|
),
|
||||||
width: 110,
|
width: 110,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Handle view more link click.
|
||||||
|
const handleLinkClick = () => {
|
||||||
|
closeDrawer(drawerName);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={'account-drawer__table'}>
|
<div className={'account-drawer__table'}>
|
||||||
<DataTable columns={columns} data={accounts} />
|
<DataTable columns={columns} data={accounts} />
|
||||||
|
|
||||||
|
<div class="account-drawer__table-footer">
|
||||||
|
<Link to={`/financial-reports/general-ledger`} onClick={handleLinkClick}>
|
||||||
|
← View more transactions.
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default compose(
|
||||||
|
withDrawerActions
|
||||||
|
)(AccountDrawerTable);
|
||||||
@@ -11,15 +11,15 @@ const AccountDrawerContent = lazy(() => import('./AccountDrawerContent'));
|
|||||||
*/
|
*/
|
||||||
function AccountDrawer({
|
function AccountDrawer({
|
||||||
name,
|
name,
|
||||||
//#withDrawer
|
// #withDrawer
|
||||||
isOpen,
|
isOpen,
|
||||||
payload: { accountId },
|
payload: { accountId },
|
||||||
}) {
|
}) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Drawer isOpen={isOpen} name={name}>
|
<Drawer isOpen={isOpen} name={name} size={'900px'}>
|
||||||
<DrawerSuspense>
|
<DrawerSuspense>
|
||||||
<AccountDrawerContent accountId={accountId} />
|
<AccountDrawerContent name={name} accountId={accountId} />
|
||||||
</DrawerSuspense>
|
</DrawerSuspense>
|
||||||
</Drawer>
|
</Drawer>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ function ManualJournalDrawer({
|
|||||||
payload: { manualJournalId },
|
payload: { manualJournalId },
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<Drawer isOpen={isOpen} name={name}>
|
<Drawer isOpen={isOpen} name={name} size={'900px'}>
|
||||||
<DrawerSuspense>
|
<DrawerSuspense>
|
||||||
<ManualJournalDrawerContent manualJournalId={manualJournalId} />
|
<ManualJournalDrawerContent manualJournalId={manualJournalId} />
|
||||||
</DrawerSuspense>
|
</DrawerSuspense>
|
||||||
|
|||||||
@@ -176,3 +176,8 @@ body.hide-scrollbar .Pane2 {
|
|||||||
|
|
||||||
.ReactVirtualized__List {
|
.ReactVirtualized__List {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.bp3-drawer{
|
||||||
|
box-shadow: 0 0 0;
|
||||||
|
}
|
||||||
@@ -1,3 +1,15 @@
|
|||||||
|
.bp3-drawer-header {
|
||||||
|
box-shadow: 0 0 0;
|
||||||
|
|
||||||
|
.bp3-heading{
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
.bp3-button{
|
||||||
|
min-height: 28px;
|
||||||
|
min-width: 28px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.account-drawer {
|
.account-drawer {
|
||||||
background-color: #fbfbfb;
|
background-color: #fbfbfb;
|
||||||
|
|
||||||
@@ -9,30 +21,47 @@
|
|||||||
padding: 15px;
|
padding: 15px;
|
||||||
background: white;
|
background: white;
|
||||||
border: 1px solid #d2dce2;
|
border: 1px solid #d2dce2;
|
||||||
color: #666666;
|
|
||||||
|
|
||||||
> div {
|
> div{
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
margin: 15px 0;
|
margin: 15px 0;
|
||||||
|
|
||||||
|
> span {
|
||||||
|
color: #666666;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
.balance,
|
.balance,
|
||||||
p {
|
p {
|
||||||
text-transform: capitalize;
|
text-transform: capitalize;
|
||||||
margin: 5px 0;
|
margin: 5px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.balance {
|
.balance {
|
||||||
font-size: 26px;
|
font-size: 28px;
|
||||||
font-weight: 500;
|
color: #c06361;
|
||||||
color: #000;
|
margin: 6px 0;
|
||||||
margin: 10px 0;
|
font-weight: 600;
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.account-normal{
|
||||||
|
|
||||||
|
.bp3-icon{
|
||||||
|
position: relative;
|
||||||
|
top: -2px;
|
||||||
|
margin-left: 2px;
|
||||||
|
|
||||||
|
svg{
|
||||||
|
fill: #6a7994;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&--desc {
|
&--desc {
|
||||||
flex-basis: 100%;
|
flex-basis: 100%;
|
||||||
b {
|
|
||||||
color: #000;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -42,15 +71,26 @@
|
|||||||
border: 1px solid #d2dce2;
|
border: 1px solid #d2dce2;
|
||||||
|
|
||||||
.table {
|
.table {
|
||||||
.thead .tr .th .resizer {
|
.thead {
|
||||||
display: none;
|
.tr .th {
|
||||||
|
padding: 0.7rem 0.8rem;
|
||||||
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
.thead .th,
|
}
|
||||||
|
|
||||||
.tbody .tr .td {
|
.tbody .tr .td {
|
||||||
padding: 0.8rem;
|
padding: 0.8rem;
|
||||||
font-size: 14px;
|
}
|
||||||
font-weight: 400;
|
}
|
||||||
color: #666666;
|
|
||||||
|
&-footer{
|
||||||
|
padding: 12px 14px;
|
||||||
|
display: inline-block;
|
||||||
|
|
||||||
|
a{
|
||||||
|
text-decoration: underline;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #37639c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -64,13 +104,16 @@
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
|
|
||||||
scrollbar-width: none;
|
scrollbar-width: none;
|
||||||
|
|
||||||
&::-webkit-scrollbar {
|
&::-webkit-scrollbar {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.bp3-drawer-header {
|
.bp3-drawer-header {
|
||||||
margin-bottom: 2px;
|
margin-bottom: 2px;
|
||||||
box-shadow: (0, 0, 0);
|
box-shadow: (0, 0, 0);
|
||||||
background-color: #6a7993;
|
background-color: #6a7993;
|
||||||
|
|
||||||
.bp3-heading,
|
.bp3-heading,
|
||||||
.bp3-icon {
|
.bp3-icon {
|
||||||
color: white;
|
color: white;
|
||||||
|
|||||||
@@ -353,7 +353,9 @@ export default class AccountsController extends BaseController {
|
|||||||
tenantId,
|
tenantId,
|
||||||
transactionsFilter
|
transactionsFilter
|
||||||
);
|
);
|
||||||
return res.status(200).send({ transactions });
|
return res.status(200).send({
|
||||||
|
transactions: this.transfromToResponse(transactions),
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
next(error);
|
next(error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import DynamicListingService from 'services/DynamicListing/DynamicListService';
|
|||||||
import events from 'subscribers/events';
|
import events from 'subscribers/events';
|
||||||
import AccountTypesUtils from 'lib/AccountTypes';
|
import AccountTypesUtils from 'lib/AccountTypes';
|
||||||
import { ERRORS } from './constants';
|
import { ERRORS } from './constants';
|
||||||
|
import { transaction } from 'objection';
|
||||||
|
|
||||||
@Service()
|
@Service()
|
||||||
export default class AccountsService {
|
export default class AccountsService {
|
||||||
@@ -631,6 +632,30 @@ export default class AccountsService {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
runningBalanceFromClosing(
|
||||||
|
transactions: IAccountTransaction[],
|
||||||
|
closingBalance: number,
|
||||||
|
accountNormal: string,
|
||||||
|
) {
|
||||||
|
let remain = closingBalance;
|
||||||
|
|
||||||
|
return transactions.map((entry, index) => {
|
||||||
|
const { credit, debit } = entry;
|
||||||
|
const amount = accountNormal === 'credit' ?
|
||||||
|
credit - debit : debit - credit;
|
||||||
|
|
||||||
|
const runningBalance = Math.min(amount, remain);
|
||||||
|
const output = {
|
||||||
|
...entry.toJSON(),
|
||||||
|
runningBalance: remain,
|
||||||
|
runningBalanceFormatted: remain,
|
||||||
|
};
|
||||||
|
remain -= Math.max(runningBalance, 0);
|
||||||
|
return output;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the accounts transactions.
|
* Retrieve the accounts transactions.
|
||||||
* @param {number} tenantId -
|
* @param {number} tenantId -
|
||||||
@@ -642,6 +667,9 @@ export default class AccountsService {
|
|||||||
): Promise<{ transactions: IAccountTransaction }> {
|
): Promise<{ transactions: IAccountTransaction }> {
|
||||||
const { AccountTransaction } = this.tenancy.models(tenantId);
|
const { AccountTransaction } = this.tenancy.models(tenantId);
|
||||||
|
|
||||||
|
// Retrieve the given account or throw not found error.
|
||||||
|
const account = await this.getAccountOrThrowError(tenantId, filter.accountId);
|
||||||
|
|
||||||
this.logger.info('[accounts] trying to get accounts transactions list.');
|
this.logger.info('[accounts] trying to get accounts transactions list.');
|
||||||
const transactions = await AccountTransaction.query().onBuild((query) => {
|
const transactions = await AccountTransaction.query().onBuild((query) => {
|
||||||
query.orderBy('date', 'DESC');
|
query.orderBy('date', 'DESC');
|
||||||
@@ -652,7 +680,14 @@ export default class AccountsService {
|
|||||||
query.withGraphFetched('account');
|
query.withGraphFetched('account');
|
||||||
query.withGraphFetched('contact');
|
query.withGraphFetched('contact');
|
||||||
});
|
});
|
||||||
return { transactions };
|
|
||||||
|
return {
|
||||||
|
transactions: this.runningBalanceFromClosing(
|
||||||
|
transactions,
|
||||||
|
account.amount,
|
||||||
|
account.accountNormal,
|
||||||
|
)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user