Update Receiving Page to Include Inventory Unit Field

- Modified the receiving controller to include the `inventory_unit` field in the item selection query.
- Updated the frontend components across multiple company pages to reference the new `inventory_unit` field instead of the previous `unit` field, ensuring consistency in data handling.
- Removed hardcoded company code from API calls to allow for dynamic fetching of item information.

(TASK: ERP-030)
This commit is contained in:
kjs
2026-05-08 11:19:34 +09:00
parent b4346b5617
commit 80148a0593
9 changed files with 16 additions and 15 deletions

View File

@@ -1262,7 +1262,7 @@ export async function getItems(req: AuthenticatedRequest, res: Response) {
const dataResult = await pool.query(
`SELECT
id, item_number, item_name, size AS spec, material, unit,
id, item_number, item_name, size AS spec, material, unit, inventory_unit,
COALESCE(width::text, '') AS width,
COALESCE(height::text, '') AS height,
COALESCE(thickness::text, '') AS thickness,

View File

@@ -329,7 +329,7 @@ export default function ReceivingPage() {
Promise.all(
["material", "inventory_unit"].map(async (col) => {
try {
const res = await apiClient.get(`/table-categories/item_info/${col}/values?filterCompanyCode=COMPANY_16`);
const res = await apiClient.get(`/table-categories/item_info/${col}/values`);
const items = flatten(res.data?.data || []);
map[col] = {};
for (const item of items) map[col][item.code] = item.label;
@@ -1770,7 +1770,7 @@ function SourceItemTable({
</TableCell>
<TableCell className="max-w-[100px] truncate p-2" title={item.spec || "-"}>{item.spec || "-"}</TableCell>
<TableCell className="max-w-[100px] truncate p-2" title={resolveCat("material", item.material) || "-"}>{resolveCat("material", item.material) || "-"}</TableCell>
<TableCell className="p-2">{resolveCat("inventory_unit", item.unit) || "-"}</TableCell>
<TableCell className="p-2">{resolveCat("inventory_unit", item.inventory_unit) || "-"}</TableCell>
<TableCell className="p-2 text-right">
{Number(item.standard_price).toLocaleString()}
</TableCell>

View File

@@ -329,7 +329,7 @@ export default function ReceivingPage() {
Promise.all(
["material", "inventory_unit"].map(async (col) => {
try {
const res = await apiClient.get(`/table-categories/item_info/${col}/values?filterCompanyCode=COMPANY_16`);
const res = await apiClient.get(`/table-categories/item_info/${col}/values`);
const items = flatten(res.data?.data || []);
map[col] = {};
for (const item of items) map[col][item.code] = item.label;
@@ -1770,7 +1770,7 @@ function SourceItemTable({
</TableCell>
<TableCell className="max-w-[100px] truncate p-2" title={item.spec || "-"}>{item.spec || "-"}</TableCell>
<TableCell className="max-w-[100px] truncate p-2" title={resolveCat("material", item.material) || "-"}>{resolveCat("material", item.material) || "-"}</TableCell>
<TableCell className="p-2">{resolveCat("inventory_unit", item.unit) || "-"}</TableCell>
<TableCell className="p-2">{resolveCat("inventory_unit", item.inventory_unit) || "-"}</TableCell>
<TableCell className="p-2 text-right">
{Number(item.standard_price).toLocaleString()}
</TableCell>

View File

@@ -328,7 +328,7 @@ export default function ReceivingPage() {
Promise.all(
["material", "inventory_unit"].map(async (col) => {
try {
const res = await apiClient.get(`/table-categories/item_info/${col}/values?filterCompanyCode=COMPANY_16`);
const res = await apiClient.get(`/table-categories/item_info/${col}/values`);
const items = flatten(res.data?.data || []);
map[col] = {};
for (const item of items) map[col][item.code] = item.label;
@@ -1765,7 +1765,7 @@ function SourceItemTable({
</TableCell>
<TableCell className="max-w-[100px] truncate p-2" title={item.spec || "-"}>{item.spec || "-"}</TableCell>
<TableCell className="max-w-[100px] truncate p-2" title={resolveCat("material", item.material) || "-"}>{resolveCat("material", item.material) || "-"}</TableCell>
<TableCell className="p-2">{resolveCat("inventory_unit", item.unit) || "-"}</TableCell>
<TableCell className="p-2">{resolveCat("inventory_unit", item.inventory_unit) || "-"}</TableCell>
<TableCell className="p-2 text-right">
{Number(item.standard_price).toLocaleString()}
</TableCell>

View File

@@ -329,7 +329,7 @@ export default function ReceivingPage() {
Promise.all(
["material", "inventory_unit"].map(async (col) => {
try {
const res = await apiClient.get(`/table-categories/item_info/${col}/values?filterCompanyCode=COMPANY_16`);
const res = await apiClient.get(`/table-categories/item_info/${col}/values`);
const items = flatten(res.data?.data || []);
map[col] = {};
for (const item of items) map[col][item.code] = item.label;
@@ -1770,7 +1770,7 @@ function SourceItemTable({
</TableCell>
<TableCell className="max-w-[100px] truncate p-2" title={item.spec || "-"}>{item.spec || "-"}</TableCell>
<TableCell className="max-w-[100px] truncate p-2" title={resolveCat("material", item.material) || "-"}>{resolveCat("material", item.material) || "-"}</TableCell>
<TableCell className="p-2">{resolveCat("inventory_unit", item.unit) || "-"}</TableCell>
<TableCell className="p-2">{resolveCat("inventory_unit", item.inventory_unit) || "-"}</TableCell>
<TableCell className="p-2 text-right">
{Number(item.standard_price).toLocaleString()}
</TableCell>

View File

@@ -329,7 +329,7 @@ export default function ReceivingPage() {
Promise.all(
["material", "inventory_unit"].map(async (col) => {
try {
const res = await apiClient.get(`/table-categories/item_info/${col}/values?filterCompanyCode=COMPANY_16`);
const res = await apiClient.get(`/table-categories/item_info/${col}/values`);
const items = flatten(res.data?.data || []);
map[col] = {};
for (const item of items) map[col][item.code] = item.label;
@@ -1770,7 +1770,7 @@ function SourceItemTable({
</TableCell>
<TableCell className="max-w-[100px] truncate p-2" title={item.spec || "-"}>{item.spec || "-"}</TableCell>
<TableCell className="max-w-[100px] truncate p-2" title={resolveCat("material", item.material) || "-"}>{resolveCat("material", item.material) || "-"}</TableCell>
<TableCell className="p-2">{resolveCat("inventory_unit", item.unit) || "-"}</TableCell>
<TableCell className="p-2">{resolveCat("inventory_unit", item.inventory_unit) || "-"}</TableCell>
<TableCell className="p-2 text-right">
{Number(item.standard_price).toLocaleString()}
</TableCell>

View File

@@ -329,7 +329,7 @@ export default function ReceivingPage() {
Promise.all(
["material", "inventory_unit"].map(async (col) => {
try {
const res = await apiClient.get(`/table-categories/item_info/${col}/values?filterCompanyCode=COMPANY_16`);
const res = await apiClient.get(`/table-categories/item_info/${col}/values`);
const items = flatten(res.data?.data || []);
map[col] = {};
for (const item of items) map[col][item.code] = item.label;
@@ -1765,7 +1765,7 @@ function SourceItemTable({
</TableCell>
<TableCell className="max-w-[100px] truncate p-2" title={item.spec || "-"}>{item.spec || "-"}</TableCell>
<TableCell className="max-w-[100px] truncate p-2" title={resolveCat("material", item.material) || "-"}>{resolveCat("material", item.material) || "-"}</TableCell>
<TableCell className="p-2">{resolveCat("inventory_unit", item.unit) || "-"}</TableCell>
<TableCell className="p-2">{resolveCat("inventory_unit", item.inventory_unit) || "-"}</TableCell>
<TableCell className="p-2 text-right">
{Number(item.standard_price).toLocaleString()}
</TableCell>

View File

@@ -329,7 +329,7 @@ export default function ReceivingPage() {
Promise.all(
["material", "inventory_unit"].map(async (col) => {
try {
const res = await apiClient.get(`/table-categories/item_info/${col}/values?filterCompanyCode=COMPANY_16`);
const res = await apiClient.get(`/table-categories/item_info/${col}/values`);
const items = flatten(res.data?.data || []);
map[col] = {};
for (const item of items) map[col][item.code] = item.label;
@@ -1770,7 +1770,7 @@ function SourceItemTable({
</TableCell>
<TableCell className="max-w-[100px] truncate p-2" title={item.spec || "-"}>{item.spec || "-"}</TableCell>
<TableCell className="max-w-[100px] truncate p-2" title={resolveCat("material", item.material) || "-"}>{resolveCat("material", item.material) || "-"}</TableCell>
<TableCell className="p-2">{resolveCat("inventory_unit", item.unit) || "-"}</TableCell>
<TableCell className="p-2">{resolveCat("inventory_unit", item.inventory_unit) || "-"}</TableCell>
<TableCell className="p-2 text-right">
{Number(item.standard_price).toLocaleString()}
</TableCell>

View File

@@ -76,6 +76,7 @@ export interface ItemSource {
spec: string | null;
material: string | null;
unit: string | null;
inventory_unit: string | null;
standard_price: number;
}