diff --git a/client/src/containers/Drawers/AccountDrawer/AccountDrawerActionBar.js b/client/src/containers/Drawers/AccountDrawer/AccountDrawerActionBar.js
index 7df7f3ade..50b2f9b1e 100644
--- a/client/src/containers/Drawers/AccountDrawer/AccountDrawerActionBar.js
+++ b/client/src/containers/Drawers/AccountDrawer/AccountDrawerActionBar.js
@@ -28,8 +28,6 @@ function AccountDrawerActionBar({
// #ownProps
account,
}) {
-
-
// Handle new child button click.
const onNewChildAccount = () => {
openDialog('account-form', {
@@ -69,9 +67,9 @@ function AccountDrawerActionBar({
/>
}
+ icon={}
text={}
- // intent={Intent.DANGER}
+ intent={Intent.DANGER}
onClick={safeCallback(onDeleteAccount)}
/>
diff --git a/client/src/containers/Drawers/AccountDrawer/AccountDrawerContent.js b/client/src/containers/Drawers/AccountDrawer/AccountDrawerContent.js
index adea3f343..aa4bcc436 100644
--- a/client/src/containers/Drawers/AccountDrawer/AccountDrawerContent.js
+++ b/client/src/containers/Drawers/AccountDrawer/AccountDrawerContent.js
@@ -8,10 +8,11 @@ import AccountDrawerDetails from './AccountDrawerDetails';
export default function AccountDrawerContent({
// #ownProp
accountId,
+ name
}) {
return (
-
+
);
-}
+}
\ No newline at end of file
diff --git a/client/src/containers/Drawers/AccountDrawer/AccountDrawerHeader.js b/client/src/containers/Drawers/AccountDrawer/AccountDrawerHeader.js
index 06305c208..e24b84246 100644
--- a/client/src/containers/Drawers/AccountDrawer/AccountDrawerHeader.js
+++ b/client/src/containers/Drawers/AccountDrawer/AccountDrawerHeader.js
@@ -1,6 +1,6 @@
import React from 'react';
import { FormattedMessage as T } from 'react-intl';
-import { If, Money } from 'components';
+import { Icon, Money } from 'components';
/**
* Account drawer header.
@@ -23,17 +23,24 @@ export default function AccountDrawerHeader({
{}
-
+
-
+
-
{account_normal}
+
+ {' '}
+ {account_normal}{' '}
+
+
@@ -49,12 +56,10 @@ export default function AccountDrawerHeader({
-
-
-
-
- : {description}
-
+
+
+
+ : {description ? description : '--'}
);
diff --git a/client/src/containers/Drawers/AccountDrawer/AccountDrawerProvider.js b/client/src/containers/Drawers/AccountDrawer/AccountDrawerProvider.js
index 94c649ef8..7d6ec6242 100644
--- a/client/src/containers/Drawers/AccountDrawer/AccountDrawerProvider.js
+++ b/client/src/containers/Drawers/AccountDrawer/AccountDrawerProvider.js
@@ -7,7 +7,7 @@ const AccountDrawerContext = React.createContext();
/**
* Account drawer provider.
*/
-function AccountDrawerProvider({ accountId, ...props }) {
+function AccountDrawerProvider({ accountId, name, ...props }) {
// Fetches the specific account details.
const { data: account, isLoading: isAccountLoading } = useAccount(accountId, {
enabled: !!accountId,
@@ -20,18 +20,19 @@ function AccountDrawerProvider({ accountId, ...props }) {
} = useAccountTransactions(accountId, {
enabled: !!accountId,
});
- const name = `${account.name} ${account.code}`;
+ const drawerTitle = `${account.name} ${account.code}`;
// provider.
const provider = {
accountId,
account,
accounts,
+ drawerName: name,
};
return (
-
+
);
diff --git a/client/src/containers/Drawers/AccountDrawer/AccountDrawerTable.js b/client/src/containers/Drawers/AccountDrawer/AccountDrawerTable.js
index bdaf1a041..b97c1d7d4 100644
--- a/client/src/containers/Drawers/AccountDrawer/AccountDrawerTable.js
+++ b/client/src/containers/Drawers/AccountDrawer/AccountDrawerTable.js
@@ -1,18 +1,23 @@
import React from 'react';
import moment from 'moment';
+import { Link } from 'react-router-dom';
import { useAccountDrawerContext } from './AccountDrawerProvider';
import { formatMessage } from 'services/intl';
import { DataTable, Money } from 'components';
-import { isBlank } from 'utils';
+import { isBlank, compose } from 'utils';
+import withDrawerActions from 'containers/Drawer/withDrawerActions';
/**
* account drawer table.
*/
-export default function AccountDrawerTable() {
+function AccountDrawerTable({
+ closeDrawer
+}) {
const {
account: { currency_code },
accounts,
+ drawerName
} = useAccountDrawerContext();
const columns = React.useMemo(
@@ -45,16 +50,33 @@ export default function AccountDrawerTable() {
},
{
Header: formatMessage({ id: 'running_balance' }),
- accessor: 'balance',
+ accessor: ({ running_balance }) => (
+
+ ),
width: 110,
},
],
[],
);
+ // Handle view more link click.
+ const handleLinkClick = () => {
+ closeDrawer(drawerName);
+ };
+
return (
+
+
);
}
+
+export default compose(
+ withDrawerActions
+)(AccountDrawerTable);
\ No newline at end of file
diff --git a/client/src/containers/Drawers/AccountDrawer/index.js b/client/src/containers/Drawers/AccountDrawer/index.js
index c9b933cc5..f621ffe81 100644
--- a/client/src/containers/Drawers/AccountDrawer/index.js
+++ b/client/src/containers/Drawers/AccountDrawer/index.js
@@ -11,15 +11,15 @@ const AccountDrawerContent = lazy(() => import('./AccountDrawerContent'));
*/
function AccountDrawer({
name,
- //#withDrawer
+ // #withDrawer
isOpen,
payload: { accountId },
}) {
return (
-
+
-
+
);
diff --git a/client/src/containers/Drawers/ManualJournalDrawer/index.js b/client/src/containers/Drawers/ManualJournalDrawer/index.js
index 817011f70..28649bd6f 100644
--- a/client/src/containers/Drawers/ManualJournalDrawer/index.js
+++ b/client/src/containers/Drawers/ManualJournalDrawer/index.js
@@ -19,7 +19,7 @@ function ManualJournalDrawer({
payload: { manualJournalId },
}) {
return (
-
+
diff --git a/client/src/style/App.scss b/client/src/style/App.scss
index ec41a98f3..18d88ff4f 100644
--- a/client/src/style/App.scss
+++ b/client/src/style/App.scss
@@ -176,3 +176,8 @@ body.hide-scrollbar .Pane2 {
.ReactVirtualized__List {
}
+
+
+.bp3-drawer{
+ box-shadow: 0 0 0;
+}
\ No newline at end of file
diff --git a/client/src/style/components/Drawer/AccountDrawer.scss b/client/src/style/components/Drawer/AccountDrawer.scss
index d94fbbc0f..318c66a44 100644
--- a/client/src/style/components/Drawer/AccountDrawer.scss
+++ b/client/src/style/components/Drawer/AccountDrawer.scss
@@ -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 {
background-color: #fbfbfb;
@@ -9,30 +21,47 @@
padding: 15px;
background: white;
border: 1px solid #d2dce2;
- color: #666666;
- > div {
+ > div{
flex-grow: 1;
font-size: 14px;
margin: 15px 0;
+ > span {
+ color: #666666;
+ font-weight: 500;
+ }
+
.balance,
p {
text-transform: capitalize;
margin: 5px 0;
}
+
.balance {
- font-size: 26px;
- font-weight: 500;
- color: #000;
- margin: 10px 0;
+ font-size: 28px;
+ color: #c06361;
+ margin: 6px 0;
+ font-weight: 600;
+ margin-bottom: 0;
+ }
+
+ &.account-normal{
+
+ .bp3-icon{
+ position: relative;
+ top: -2px;
+ margin-left: 2px;
+
+ svg{
+ fill: #6a7994;
+ }
+ }
}
}
+
&--desc {
flex-basis: 100%;
- b {
- color: #000;
- }
}
}
@@ -42,15 +71,26 @@
border: 1px solid #d2dce2;
.table {
- .thead .tr .th .resizer {
- display: none;
+ .thead {
+ .tr .th {
+ padding: 0.7rem 0.8rem;
+ font-weight: 500;
+ }
}
- .thead .th,
+
.tbody .tr .td {
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,16 +104,19 @@
height: 100%;
scrollbar-width: none;
+
&::-webkit-scrollbar {
display: none;
}
+
.bp3-drawer-header {
margin-bottom: 2px;
box-shadow: (0, 0, 0);
background-color: #6a7993;
+
.bp3-heading,
.bp3-icon {
color: white;
}
}
-}
+}
\ No newline at end of file
diff --git a/server/src/api/controllers/Accounts.ts b/server/src/api/controllers/Accounts.ts
index c5e3c428e..b4e378434 100644
--- a/server/src/api/controllers/Accounts.ts
+++ b/server/src/api/controllers/Accounts.ts
@@ -353,7 +353,9 @@ export default class AccountsController extends BaseController {
tenantId,
transactionsFilter
);
- return res.status(200).send({ transactions });
+ return res.status(200).send({
+ transactions: this.transfromToResponse(transactions),
+ });
} catch (error) {
next(error);
}
diff --git a/server/src/services/Accounts/AccountsService.ts b/server/src/services/Accounts/AccountsService.ts
index 2aef28d9f..1fa20f645 100644
--- a/server/src/services/Accounts/AccountsService.ts
+++ b/server/src/services/Accounts/AccountsService.ts
@@ -20,6 +20,7 @@ import DynamicListingService from 'services/DynamicListing/DynamicListService';
import events from 'subscribers/events';
import AccountTypesUtils from 'lib/AccountTypes';
import { ERRORS } from './constants';
+import { transaction } from 'objection';
@Service()
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.
* @param {number} tenantId -
@@ -642,6 +667,9 @@ export default class AccountsService {
): Promise<{ transactions: IAccountTransaction }> {
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.');
const transactions = await AccountTransaction.query().onBuild((query) => {
query.orderBy('date', 'DESC');
@@ -652,7 +680,14 @@ export default class AccountsService {
query.withGraphFetched('account');
query.withGraphFetched('contact');
});
- return { transactions };
+
+ return {
+ transactions: this.runningBalanceFromClosing(
+ transactions,
+ account.amount,
+ account.accountNormal,
+ )
+ };
}
/**