BIG-344: add branch to manual journal & expense.

This commit is contained in:
elforjani13
2022-03-31 13:39:15 +02:00
parent 756af3c4d3
commit b849bfaa95
5 changed files with 41 additions and 9 deletions

View File

@@ -1,6 +1,9 @@
import React from 'react';
import intl from 'react-intl-universal';
import { useExpense } from 'hooks/query';
import { DrawerLoading } from 'components';
import { DrawerHeaderContent, DrawerLoading } from 'components';
import { Features } from 'common';
import { useFeatureCan } from 'hooks/state';
const ExpenseDrawerDrawerContext = React.createContext();
@@ -8,6 +11,9 @@ const ExpenseDrawerDrawerContext = React.createContext();
* Expense drawer provider.
*/
function ExpenseDrawerProvider({ expenseId, ...props }) {
// Features guard.
const { featureCan } = useFeatureCan();
// Fetch the expense details.
const {
data: expense,
@@ -28,6 +34,17 @@ function ExpenseDrawerProvider({ expenseId, ...props }) {
return (
<DrawerLoading loading={isExpenseLoading}>
<DrawerHeaderContent
name="expense-drawer"
title={intl.get('expense.drawer.title')}
subTitle={
featureCan(Features.Branches)
? intl.get('expense.drawer.subtitle', {
value: expense.branch?.name,
})
: null
}
/>
<ExpenseDrawerDrawerContext.Provider value={provider} {...props} />
</DrawerLoading>
);

View File

@@ -1,6 +1,4 @@
import React, { lazy } from 'react';
import intl from 'react-intl-universal';
import { Drawer, DrawerSuspense } from 'components';
import withDrawers from 'containers/Drawer/withDrawers';
@@ -22,7 +20,6 @@ function ExpenseDrawer({
<Drawer
isOpen={isOpen}
name={name}
title={intl.get('expense.drawer.title')}
size={'65%'}
style={{ minWidth: '700px', maxWidth: '900px' }}
>

View File

@@ -3,6 +3,8 @@ import React from 'react';
import { Tag, Intent, Classes, Tooltip, Position } from '@blueprintjs/core';
import { T, Choose, FormatNumberCell, If, Icon } from '../../../components';
import { Features } from 'common';
import { useFeatureCan } from 'hooks/state';
/**
* Note column accessor.
@@ -46,8 +48,9 @@ export function ManualJournalDetailsStatus({ manualJournal }) {
/**
* Retrieve read-only manual journal entries columns.
*/
export const useManualJournalEntriesColumns = () =>
React.useMemo(
export const useManualJournalEntriesColumns = () => {
const { featureCan } = useFeatureCan();
return React.useMemo(
() => [
{
Header: intl.get('account_name'),
@@ -70,6 +73,17 @@ export const useManualJournalEntriesColumns = () =>
disableSortBy: true,
className: 'note',
},
...(featureCan(Features.Branches)
? [
{
Header: intl.get('branch'),
width: 130,
accessor: 'branch.name',
disableSortBy: true,
className: 'branch',
},
]
: []),
{
Header: intl.get('credit'),
accessor: 'credit',
@@ -93,5 +107,6 @@ export const useManualJournalEntriesColumns = () =>
align: 'right',
},
],
[],
[featureCan],
);
};

View File

@@ -2005,8 +2005,10 @@
"estimate.warehouse_button.label": "المخزن: {label}",
"receipt.branch_button.label": "الفرع: {label}",
"receipt.warehouse_button.label": "المخزن: {label}",
"warehouse_transfer.empty_status.title": "إدارة عمليات النقل بين المستودعات",
"warehouse_transfer.empty_status.description": "غالبًا ماتحتاج الاعمال ذات مستودعات متعددة لطلبات نقل البضائع من مستودع إلى آخر عندما تكون في حاجة ماسة إلى البائعين.",
"warehouse_transfer.empty_status.title": "إدارة عمليات النقل بين المخازن",
"warehouse_transfer.empty_status.description": "غالبًا ماتحتاج الاعمال ذات مخازن متعددة لطلبات نقل البضائع من مخزن إلى آخر عندما تكون في حاجة ماسة إلى البائعين.",
"warehouse_transfer.form.reason.label": "أسباب النقل",
"warehouse_transfer.form.reason.placeholder": "Enter the reason behind the transfer order.",
"item.error.you_could_not_delete_item_has_associated": "لا يمكنك حذف العنصر لديه معاملات مرتبطة به ",
"warehouse_transfer.quantity_cannot_be_zero_or_empty": "لا يمكن أن تكون الكمية صفراً أو فارغة.",
"invoice.validation.due_date": "يجب أن يكون حقل {path} في وقت لاحق من {min}",

View File

@@ -1756,6 +1756,7 @@
"payment_made.drawer.subtitle": "Branch: {value}",
"manual_journal.drawer.title": "Manual journal details ({number})",
"expense.drawer.title": "Expense details",
"expense.drawer.subtitle": "Branch: {value}",
"global_error.you_dont_have_permissions": "You do not have permissions to access this page.",
"global_error.transactions_locked": "Transactions before {lockedToDate} has been locked. Hence action cannot be performed.",
"global_error.authorized_user_inactive": "The authorized user is inactive.",