mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-15 20:30:33 +00:00
feat(item): add item warehouse locations.
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import React from 'react';
|
||||
import intl from 'react-intl-universal';
|
||||
import { FormatNumberCell, FormattedMessage as T } from '../../../../components';
|
||||
|
||||
import clsx from 'classnames';
|
||||
import { CLASSES } from '../../../../common/classes';
|
||||
|
||||
/**
|
||||
* Warehouse locations columns
|
||||
@@ -12,12 +11,21 @@ export const useWarehouseLocationsColumns = () => {
|
||||
() => [
|
||||
{
|
||||
id: 'warehouse_name',
|
||||
accessor: 'warehouse_name',
|
||||
Header: intl.get('warehouse_locations.column.warehouse_name'),
|
||||
width: 120,
|
||||
},
|
||||
{
|
||||
id: 'warehouse_code',
|
||||
accessor: 'warehouse_code',
|
||||
Header: intl.get('warehouse_locations.column.warehouse_code'),
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
id: 'quantity',
|
||||
accessor: 'quantity_on_hand_formatted',
|
||||
Header: intl.get('warehouse_locations.column.quantity'),
|
||||
Cell: FormatNumberCell,
|
||||
align: 'right',
|
||||
width: 100,
|
||||
},
|
||||
|
||||
@@ -2,10 +2,12 @@ import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
|
||||
import { DataTable, CommercialDocEntriesTable, Card } from 'components';
|
||||
|
||||
import { useWarehouseLocationsColumns } from './components';
|
||||
|
||||
import { TableStyle } from '../../../../common';
|
||||
import TableSkeletonRows from 'components/Datatable/TableSkeletonRows';
|
||||
|
||||
import { useItemDetailDrawerContext } from '../ItemDetailDrawerProvider';
|
||||
import { useWarehouseLocationsColumns } from './components';
|
||||
import { useItemWarehouseLocation } from 'hooks/query';
|
||||
|
||||
/**
|
||||
* Warehouses locations table columns.
|
||||
@@ -14,9 +16,25 @@ export default function WarehouseLocationsTable() {
|
||||
// Warehouses locations table columns.
|
||||
const columns = useWarehouseLocationsColumns();
|
||||
|
||||
const { itemId } = useItemDetailDrawerContext();
|
||||
|
||||
// Handle fetch Estimate associated transactions.
|
||||
const {
|
||||
isLoading: isItemWarehousesLoading,
|
||||
isFetching: isItemWarehousesFetching,
|
||||
data: itemWarehouses,
|
||||
} = useItemWarehouseLocation(itemId, { enabled: !!itemId });
|
||||
console.log(itemWarehouses, 'XXX');
|
||||
return (
|
||||
<WarehouseLocationsGLEntriesRoot>
|
||||
<DataTable columns={columns} data={[]} styleName={TableStyle.Constrant} />
|
||||
<DataTable
|
||||
columns={columns}
|
||||
data={itemWarehouses}
|
||||
headerLoading={isItemWarehousesLoading}
|
||||
progressBarLoading={isItemWarehousesFetching}
|
||||
TableLoadingRenderer={TableSkeletonRows}
|
||||
styleName={TableStyle.Constrant}
|
||||
/>
|
||||
</WarehouseLocationsGLEntriesRoot>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -231,3 +231,18 @@ export function useItemAssociatedBillTransactions(id, props) {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export function useItemWarehouseLocation(id, props) {
|
||||
return useRequestQuery(
|
||||
[t.ITEM_WAREHOUSES_LOCATION, id],
|
||||
{
|
||||
method: 'get',
|
||||
url: `items/${id}/warehouses`,
|
||||
},
|
||||
{
|
||||
select: (res) => res.data.item_warehouses,
|
||||
defaultData: [],
|
||||
...props,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ const ITEMS = {
|
||||
ITEM_ASSOCIATED_WITH_ESTIMATES: 'ITEM_ASSOCIATED_WITH_ESTIMATES',
|
||||
ITEM_ASSOCIATED_WITH_RECEIPTS: 'ITEM_ASSOCIATED_WITH_RECEIPTS',
|
||||
ITEMS_ASSOCIATED_WITH_BILLS: 'ITEMS_ASSOCIATED_WITH_BILLS',
|
||||
ITEM_WAREHOUSES_LOCATION: 'ITEM_WAREHOUSES_LOCATION',
|
||||
};
|
||||
|
||||
const SALE_ESTIMATES = {
|
||||
|
||||
@@ -1782,5 +1782,10 @@
|
||||
"profit_loss_sheet.percentage_of_column": "% التغير العمودي",
|
||||
"profit_loss_sheet.percentage_of_row": "% التغير الأفقي",
|
||||
"profit_loss_sheet.percentage_of_expense": "% التغير في المصاريف",
|
||||
"profit_loss_sheet.percentage_of_income": "% التغير الإيرادات"
|
||||
"profit_loss_sheet.percentage_of_income": "% التغير الإيرادات",
|
||||
"warehouse_locations.label": "Warehouses Locations",
|
||||
"warehouse_locations.column.warehouse_name": "Warehouse name",
|
||||
"warehouse_locations.column.quantity": "Quantity",
|
||||
"warehouse_locations.column.available_for_sale": "Available for sale",
|
||||
"warehouse_locations.column.warehouse_code": "Warehouse code"
|
||||
}
|
||||
@@ -1739,7 +1739,6 @@
|
||||
"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.",
|
||||
|
||||
"balance_sheet.comparisons": "Comparisons",
|
||||
"balance_sheet.percentage_of_column": "% of Columns",
|
||||
"balance_sheet.percentage_of_row": "% of Rows",
|
||||
@@ -1756,18 +1755,15 @@
|
||||
"profit_loss_sheet.percentage_of_row": "% of Row",
|
||||
"profit_loss_sheet.percentage_of_expense": "% of Expense",
|
||||
"profit_loss_sheet.percentage_of_income": "% of Income",
|
||||
|
||||
"the_vendor_has_been_inactivated_successfully": "The contact has been inactivated successfully.",
|
||||
"vendor.alert.activated_message": "The vendor has been activated successfully.",
|
||||
"vendor.alert.are_you_sure_want_to_inactivate_this_vendor": "Are you sure want to inactivate this vendor? You will to able to activate it later.",
|
||||
"vendor.alert.inactivated_message": "The vendor has been inactivated successfully.",
|
||||
"vendor.alert.are_you_sure_want_to_activate_this_vendor": "Are you sure want to activate this vendor? You will to able to inactivate it later.",
|
||||
|
||||
"customer.alert.activated_message": "The customer has been activated successfully.",
|
||||
"customer.alert.are_you_sure_want_to_activate_this_customer": "Are you sure want to activate this customer? You will to able to inactivate it later.",
|
||||
"customer.alert.inactivated_message": "The customer has been inactivated successfully.",
|
||||
"customer.alert.are_you_sure_want_to_inactivate_this_customer": "Are you sure want to inactivate this customer? You will to able to activate it later.",
|
||||
|
||||
"credit_note_preview.dialog.title": "Credit Note PDF Preview",
|
||||
"payment_receive_preview.dialog.title": "Payment Receive PDF Preview",
|
||||
"warehouses.label": "Warehouses",
|
||||
@@ -1789,12 +1785,12 @@
|
||||
"warehouse_locations.column.warehouse_name": "Warehouse name",
|
||||
"warehouse_locations.column.quantity": "Quantity",
|
||||
"warehouse_locations.column.available_for_sale": "Available for sale",
|
||||
"warehouse_locations.column.warehouse_code": "Warehouse code",
|
||||
"warehouses.action.edit_warehouse": "Edit Warehouse",
|
||||
"warehouses.action.delete_warehouse": "Delete Warehouse",
|
||||
"warehouses.action.make_as_parimary": "Mark as Primary",
|
||||
"warehouse.alert.delete_message": "The warehouse has been deleted successfully",
|
||||
"warehouse.once_delete_this_warehouse": "Once you delete this warehouse, you won't be able to restore it later. Are you sure you want to delete this warehouse?",
|
||||
|
||||
"sidebar_warehouse_transfer": "Warehouse Transfers",
|
||||
"warehouse_transfer.label.transfer_no": "Transfer No",
|
||||
"warehouse_transfer.label.form_warehouse": "Form Warehouse",
|
||||
@@ -1824,7 +1820,6 @@
|
||||
"warehouse_transfer.alert.delete_message": "The warehouse transfer transaction has been deleted successfully",
|
||||
"warehouse_transfer.once_delete_this_warehouse_transfer": "Once you delete this warehouse transfer, you won't be able to restore it later. Are you sure you want to delete this warehouse transfer?",
|
||||
"warehouse_transfer.error.could_not_transfer_item_from_source_to_destination": "Could not transfer item from source to destination on the same warehouse",
|
||||
|
||||
"branches.label": "Branches",
|
||||
"branches.label.new_branch": "New Branch",
|
||||
"branches.action.edit_branch": "Edit Branch",
|
||||
@@ -1852,7 +1847,6 @@
|
||||
"unrealized_gain_or_loss.label": "Unrealized Gain or Loss",
|
||||
"branch_activate.dialog_success_message": "Multi-branches feature has been activated successfully.",
|
||||
"branch.alert.mark_primary_message": "The branch has been marked as primary.",
|
||||
|
||||
"branch.alert.are_you_sure_you_want_to_make": "Are you sure you want to make a primary branch?",
|
||||
"warehouse_activate.dialog_success_message": "Multi-branches feature has been activated successfully.",
|
||||
"warehouse.alert.mark_primary_message": "The given warehouse has been marked as primary.",
|
||||
|
||||
Reference in New Issue
Block a user