diff --git a/client/src/common/drawers.js b/client/src/common/drawers.js
index 987215b9f..af7978a77 100644
--- a/client/src/common/drawers.js
+++ b/client/src/common/drawers.js
@@ -1,5 +1,3 @@
-
-
export const DRAWERS = {
ESTIMATE_DRAWER: 'estimate-drawer',
MANUAL_JOURNAL_DRAWER: 'journal-drawer',
@@ -8,5 +6,6 @@ export const DRAWERS = {
PAYMENT_RECEIVE_DRAWER: 'payment-receive-drawer',
ACCOUNT_DRAWER: 'account-drawer',
JOURNAL_DRAWER: 'journal-drawer',
- EXPENSE_DRAWER: 'expense-drawer'
-};
\ No newline at end of file
+ EXPENSE_DRAWER: 'expense-drawer',
+ INVENTORY_ADJUSTMENT_DRAWER: 'inventory-adjustment-drawer',
+};
diff --git a/client/src/components/DrawersContainer.js b/client/src/components/DrawersContainer.js
index ea5010e6b..d37ccb8f6 100644
--- a/client/src/components/DrawersContainer.js
+++ b/client/src/components/DrawersContainer.js
@@ -14,6 +14,7 @@ import PaymentMadeDetailDrawer from 'containers/Drawers/PaymentMadeDetailDrawer'
import EstimateDetailDrawer from '../containers/Drawers/EstimateDetailDrawer';
import ItemDetailDrawer from '../containers/Drawers/ItemDetailDrawer';
import ContactDetailDrawer from '../containers/Drawers/ContactDetailDrawer';
+import InventoryAdjustmentDetailDrawer from '../containers/Drawers/InventoryAdjustmentDetailDrawer';
import { DRAWERS } from 'common/drawers';
@@ -34,6 +35,9 @@ export default function DrawersContainer() {
+
);
}
diff --git a/client/src/containers/Drawers/InventoryAdjustmentDetailDrawer/InventoryAdjustmentDetail.js b/client/src/containers/Drawers/InventoryAdjustmentDetailDrawer/InventoryAdjustmentDetail.js
new file mode 100644
index 000000000..3e6476f07
--- /dev/null
+++ b/client/src/containers/Drawers/InventoryAdjustmentDetailDrawer/InventoryAdjustmentDetail.js
@@ -0,0 +1,25 @@
+import React from 'react';
+import clsx from 'classnames';
+
+import { Card } from 'components';
+
+import InventoryAdjustmentDetailActionsBar from './InventoryAdjustmentDetailActionsBar';
+import InventoryAdjustmentDetailHeader from './InventoryAdjustmentDetailHeader';
+import InventoryAdjustmentDetailTable from './InventoryAdjustmentDetailTable';
+
+import InventoryAdjustmentDrawerCls from 'style/components/Drawers/InventoryAdjustmentDrawer.module.scss';
+
+/**
+ * Inventory adjustment detail
+ */
+export default function InventoryAdjustmentDetail() {
+ return (
+
+
+
+
+
+
+
+ );
+}
diff --git a/client/src/containers/Drawers/InventoryAdjustmentDetailDrawer/InventoryAdjustmentDetailActionsBar.js b/client/src/containers/Drawers/InventoryAdjustmentDetailDrawer/InventoryAdjustmentDetailActionsBar.js
new file mode 100644
index 000000000..f054fb2ec
--- /dev/null
+++ b/client/src/containers/Drawers/InventoryAdjustmentDetailDrawer/InventoryAdjustmentDetailActionsBar.js
@@ -0,0 +1,53 @@
+import React from 'react';
+
+import { Button, NavbarGroup, Classes, Intent } from '@blueprintjs/core';
+import DashboardActionsBar from 'components/Dashboard/DashboardActionsBar';
+
+import { useInventoryAdjustmentDrawerContext } from './InventoryAdjustmentDrawerProvider';
+
+import withAlertsActions from 'containers/Alert/withAlertActions';
+import withDrawerActions from 'containers/Drawer/withDrawerActions';
+
+import { Icon, FormattedMessage as T } from 'components';
+
+import { compose } from 'utils';
+
+/**
+ * Inventory adjustment detail actions bar.
+ */
+function InventoryAdjustmentDetailActionsBar({
+ // #withAlertsActions
+ openAlert,
+
+ // #withDrawerActions
+ closeDrawer,
+}) {
+ const { inventoryId } = useInventoryAdjustmentDrawerContext();
+
+ // Handle delete inventory adjustment.
+ const handleDeleteInventoryAdjustment = () => {
+ openAlert('inventory-adjustment-delete', {
+ inventoryId,
+ });
+ closeDrawer('inventory-adjustment-drawer');
+ };
+
+ return (
+
+
+ }
+ text={}
+ intent={Intent.DANGER}
+ onClick={handleDeleteInventoryAdjustment}
+ />
+
+
+ );
+}
+
+export default compose(
+ withDrawerActions,
+ withAlertsActions,
+)(InventoryAdjustmentDetailActionsBar);
diff --git a/client/src/containers/Drawers/InventoryAdjustmentDetailDrawer/InventoryAdjustmentDetailHeader.js b/client/src/containers/Drawers/InventoryAdjustmentDetailDrawer/InventoryAdjustmentDetailHeader.js
new file mode 100644
index 000000000..ee36e7a6c
--- /dev/null
+++ b/client/src/containers/Drawers/InventoryAdjustmentDetailDrawer/InventoryAdjustmentDetailHeader.js
@@ -0,0 +1,61 @@
+import React from 'react';
+import moment from 'moment';
+
+import intl from 'react-intl-universal';
+import { defaultTo } from 'lodash';
+import clsx from 'classnames';
+
+import { DetailsMenu, DetailItem } from 'components';
+import { useInventoryAdjustmentDrawerContext } from './InventoryAdjustmentDrawerProvider';
+
+import InventoryAdjustmentDrawerCls from 'style/components/Drawers/InventoryAdjustmentDrawer.module.scss';
+
+/**
+ * Inventory detail header.
+ */
+export default function InventoryAdjustmentDetailHeader() {
+ const {
+ inventoryAdjustment: {
+ date,
+ type,
+ adjustment_account,
+ inventory_direction,
+ description,
+ reference_no,
+ reason,
+ published_at,
+ created_at,
+ },
+ } = useInventoryAdjustmentDrawerContext();
+
+ return (
+
+
+
+ {moment(date).format('YYYY MMM DD')}
+
+ {type}
+
+ {adjustment_account.name}
+
+
+ {defaultTo(reference_no, '-')}
+
+
+ {moment(published_at).format('YYYY MMM DD')}
+
+
+
+
+ {defaultTo(reason, '—')}
+
+
+ {defaultTo(description, '—')}
+
+
+ {moment(created_at).format('YYYY MMM DD')}
+
+
+
+ );
+}
diff --git a/client/src/containers/Drawers/InventoryAdjustmentDetailDrawer/InventoryAdjustmentDetailTable.js b/client/src/containers/Drawers/InventoryAdjustmentDetailDrawer/InventoryAdjustmentDetailTable.js
new file mode 100644
index 000000000..45b72d638
--- /dev/null
+++ b/client/src/containers/Drawers/InventoryAdjustmentDetailDrawer/InventoryAdjustmentDetailTable.js
@@ -0,0 +1,30 @@
+import React from 'react';
+import clsx from 'classnames';
+
+import { DataTable } from 'components';
+
+import { useInventoryAdjustmentEntriesColumns } from './utils';
+import { useInventoryAdjustmentDrawerContext } from './InventoryAdjustmentDrawerProvider';
+
+import InventoryAdjustmentDrawerCls from 'style/components/Drawers/InventoryAdjustmentDrawer.module.scss';
+
+/**
+ * Inventory adjustment detail entries table.
+ */
+export default function InventoryAdjustmentDetailTable() {
+ const columns = useInventoryAdjustmentEntriesColumns();
+
+ const {
+ inventoryAdjustment: { entries },
+ } = useInventoryAdjustmentDrawerContext();
+
+ return (
+
+
+
+ );
+}
diff --git a/client/src/containers/Drawers/InventoryAdjustmentDetailDrawer/InventoryAdjustmentDrawerContent.js b/client/src/containers/Drawers/InventoryAdjustmentDetailDrawer/InventoryAdjustmentDrawerContent.js
new file mode 100644
index 000000000..c6555fafc
--- /dev/null
+++ b/client/src/containers/Drawers/InventoryAdjustmentDetailDrawer/InventoryAdjustmentDrawerContent.js
@@ -0,0 +1,15 @@
+import React from 'react';
+
+import InventoryAdjustmentDetail from './InventoryAdjustmentDetail';
+import { InventoryAdjustmentDrawerProvider } from './InventoryAdjustmentDrawerProvider';
+
+/**
+ * Inventory adjustment drawer content.
+ */
+export default function InventoryAdjustmentDrawerContent({ inventoryId }) {
+ return (
+
+
+
+ );
+}
diff --git a/client/src/containers/Drawers/InventoryAdjustmentDetailDrawer/InventoryAdjustmentDrawerProvider.js b/client/src/containers/Drawers/InventoryAdjustmentDetailDrawer/InventoryAdjustmentDrawerProvider.js
new file mode 100644
index 000000000..de07d0882
--- /dev/null
+++ b/client/src/containers/Drawers/InventoryAdjustmentDetailDrawer/InventoryAdjustmentDrawerProvider.js
@@ -0,0 +1,42 @@
+import React from 'react';
+import intl from 'react-intl-universal';
+import { DrawerHeaderContent, DashboardInsider } from 'components';
+import { useInventoryAdjustment } from 'hooks/query';
+
+const InventoryAdjustmentDrawerContext = React.createContext();
+
+/**
+ * Inventory adjustment drawer provider.
+ */
+function InventoryAdjustmentDrawerProvider({ inventoryId, ...props }) {
+ // Handle fetch inventory adjustment .
+ const { data: inventoryAdjustment, isLoading: isAdjustmentsLoading } =
+ useInventoryAdjustment(inventoryId, {
+ enabled: !!inventoryId,
+ });
+
+ //provider.
+ const provider = {
+ inventoryAdjustment,
+ inventoryId,
+ };
+
+ return (
+
+
+
+
+
+ );
+}
+
+const useInventoryAdjustmentDrawerContext = () =>
+ React.useContext(InventoryAdjustmentDrawerContext);
+
+export {
+ InventoryAdjustmentDrawerProvider,
+ useInventoryAdjustmentDrawerContext,
+};
diff --git a/client/src/containers/Drawers/InventoryAdjustmentDetailDrawer/index.js b/client/src/containers/Drawers/InventoryAdjustmentDetailDrawer/index.js
new file mode 100644
index 000000000..f614bc782
--- /dev/null
+++ b/client/src/containers/Drawers/InventoryAdjustmentDetailDrawer/index.js
@@ -0,0 +1,35 @@
+import React from 'react';
+
+import { Drawer, DrawerSuspense } from 'components';
+import withDrawers from 'containers/Drawer/withDrawers';
+
+import { compose } from 'utils';
+
+const InventoryAdjustmentDrawerContent = React.lazy(() =>
+ import('./InventoryAdjustmentDrawerContent'),
+);
+
+/**
+ * Inventory adjustment detail drawer.
+ */
+function InventoryAdjustmentDetailDrawer({
+ name,
+ // #withDrawer
+ isOpen,
+ payload: { inventoryId },
+}) {
+ return (
+
+
+
+
+
+ );
+}
+
+export default compose(withDrawers())(InventoryAdjustmentDetailDrawer);
diff --git a/client/src/containers/Drawers/InventoryAdjustmentDetailDrawer/utils.js b/client/src/containers/Drawers/InventoryAdjustmentDetailDrawer/utils.js
new file mode 100644
index 000000000..e279c5cf6
--- /dev/null
+++ b/client/src/containers/Drawers/InventoryAdjustmentDetailDrawer/utils.js
@@ -0,0 +1,37 @@
+import React from 'react';
+import intl from 'react-intl-universal';
+
+export const useInventoryAdjustmentEntriesColumns = () =>
+ React.useMemo(
+ () => [
+ {
+ Header: intl.get('product_and_service'),
+ accessor: 'item.name',
+ width: 150,
+ className: 'name',
+ disableSortBy: true,
+ },
+ {
+ Header: intl.get('quantity'),
+ accessor: 'quantity',
+ width: 100,
+ className: 'quantity',
+ disableSortBy: true,
+ },
+ {
+ Header: intl.get('cost'),
+ accessor: 'cost',
+ width: 100,
+ className: 'cost',
+ disableSortBy: true,
+ },
+ {
+ Header: intl.get('value'),
+ accessor: 'value',
+ width: 100,
+ className: 'value',
+ disableSortBy: true,
+ },
+ ],
+ [],
+ );
diff --git a/client/src/containers/InventoryAdjustments/InventoryAdjustmentTable.js b/client/src/containers/InventoryAdjustments/InventoryAdjustmentTable.js
index 29662c98a..07bde3169 100644
--- a/client/src/containers/InventoryAdjustments/InventoryAdjustmentTable.js
+++ b/client/src/containers/InventoryAdjustments/InventoryAdjustmentTable.js
@@ -4,6 +4,7 @@ import { useInventoryAdjustmentsColumns, ActionsMenu } from './components';
import intl from 'react-intl-universal';
import withAlertsActions from 'containers/Alert/withAlertActions';
+import withDrawerActions from 'containers/Drawer/withDrawerActions';
import withInventoryAdjustmentActions from './withInventoryAdjustmentActions';
import { useInventoryAdjustmentsContext } from './InventoryAdjustmentsProvider';
@@ -23,6 +24,9 @@ function InventoryAdjustmentDataTable({
// #withAlertsActions
openAlert,
+ // #withDrawerActions
+ openDrawer,
+
// #ownProps
tableProps,
}) {
@@ -43,6 +47,10 @@ function InventoryAdjustmentDataTable({
const handlePublishInventoryAdjustment = ({ id }) => {
openAlert('inventory-adjustment-publish', { inventoryId: id });
};
+ // Handle view detail inventory adjustment.
+ const handleViewDetailInventoryAdjustment = ({ id }) => {
+ openDrawer('inventory-adjustment-drawer', { inventoryId: id });
+ };
// Inventory adjustments columns.
const columns = useInventoryAdjustmentsColumns();
@@ -78,6 +86,7 @@ function InventoryAdjustmentDataTable({
payload={{
onDelete: handleDeleteAdjustment,
onPublish: handlePublishInventoryAdjustment,
+ onViewDetails: handleViewDetailInventoryAdjustment,
}}
ContextMenu={ActionsMenu}
noResults={intl.get('there_is_no_inventory_adjustments_transactions_yet')}
@@ -89,6 +98,7 @@ function InventoryAdjustmentDataTable({
export default compose(
withAlertsActions,
withInventoryAdjustmentActions,
+ withDrawerActions,
withInventoryAdjustments(({ inventoryAdjustmentTableState }) => ({
inventoryAdjustmentTableState,
})),
diff --git a/client/src/containers/InventoryAdjustments/components.js b/client/src/containers/InventoryAdjustments/components.js
index 812371a7e..9d4302442 100644
--- a/client/src/containers/InventoryAdjustments/components.js
+++ b/client/src/containers/InventoryAdjustments/components.js
@@ -93,13 +93,14 @@ export const ItemTypeAccessor = (row) => {
export const ActionsMenu = ({
row: { original },
- payload: { onDelete, onPublish },
+ payload: { onDelete, onPublish, onViewDetails },
}) => {
return (