fix: add explicit types to all callback parameters in permissions.ts and update inventory detail stored procedure names
This commit is contained in:
parent
e6e3afac56
commit
a8d53eef82
2 changed files with 59 additions and 27 deletions
|
|
@ -258,10 +258,12 @@ export async function getUserCompanies() {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
type CompanyRelation = NonNullable<typeof questUser>['companies'][0];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
questUser?.companies
|
questUser?.companies
|
||||||
.filter((c) => c.company.is_active)
|
.filter((c: CompanyRelation) => c.company.is_active)
|
||||||
.map((c) => c.company) || []
|
.map((c: CompanyRelation) => c.company) || []
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -185,41 +185,71 @@ export async function getInventoryDetails(
|
||||||
warehouse?: string;
|
warehouse?: string;
|
||||||
}
|
}
|
||||||
): Promise<InventoryDetailRow[]> {
|
): Promise<InventoryDetailRow[]> {
|
||||||
// Map category to stored procedure name
|
const hasFilters = filters?.partNum || filters?.plant || filters?.warehouse;
|
||||||
const procMap: Record<InventoryCategory, string> = {
|
|
||||||
wip: 'portal_WorkInProgressInventoryDetailV6',
|
// Map category to stored procedure names (filtered and ALL variants)
|
||||||
'finished-goods': 'portal_FinishedGoodsInventoryDetailV6',
|
const procMap: Record<
|
||||||
'processed-other': 'portal_ProcessedOtherInventoryDetailV6',
|
InventoryCategory,
|
||||||
unprocessed: 'portal_UnprocessedInventoryDetail',
|
{ filtered: string; all: string; isV6: boolean }
|
||||||
'unprocessed-rr': 'portal_UnprocessedRRInventoryDetail',
|
> = {
|
||||||
'processed-rr': 'portal_ProcessedRRInventoryDetail',
|
wip: {
|
||||||
|
filtered: 'PortalWorkInProgressInventoryDetailsV6',
|
||||||
|
all: 'PortalWorkInProgressInventoryDetailsALLV6',
|
||||||
|
isV6: true,
|
||||||
|
},
|
||||||
|
'finished-goods': {
|
||||||
|
filtered: 'PortalFinishedGoodsInventoryDetailsV6',
|
||||||
|
all: 'PortalFinishedGoodsInventoryDetailsALLV6',
|
||||||
|
isV6: true,
|
||||||
|
},
|
||||||
|
'processed-other': {
|
||||||
|
filtered: 'PortalProcessedOtherInventoryDetailsV6',
|
||||||
|
all: 'PortalProcessedOtherInventoryDetailsALLV6',
|
||||||
|
isV6: true,
|
||||||
|
},
|
||||||
|
unprocessed: {
|
||||||
|
filtered: 'PortalUnprocessedInventoryDetails',
|
||||||
|
all: 'PortalUnprocessedInventoryDetailsALL',
|
||||||
|
isV6: false,
|
||||||
|
},
|
||||||
|
'unprocessed-rr': {
|
||||||
|
filtered: 'PortalUnprocessedInventoryRejectsAndReturnsDetails',
|
||||||
|
all: 'PortalUnprocessedInventoryRejectsAndReturnsDetailsALL',
|
||||||
|
isV6: false,
|
||||||
|
},
|
||||||
|
'processed-rr': {
|
||||||
|
filtered: 'PortalProcessedInventoryRejectsAndReturnsDetails',
|
||||||
|
all: 'PortalProcessedInventoryRejectsAndReturnsDetailsALL',
|
||||||
|
isV6: false,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const procName = procMap[category];
|
const procConfig = procMap[category];
|
||||||
|
const procName = hasFilters ? procConfig.filtered : procConfig.all;
|
||||||
|
|
||||||
const params: Record<string, unknown> = {
|
const params: Record<string, unknown> = {
|
||||||
CustID: custId,
|
|
||||||
DBNAME: dbName,
|
DBNAME: dbName,
|
||||||
};
|
};
|
||||||
|
|
||||||
// V6 procedures use 'sub' parameter
|
// V6 procedures use CUSTID (uppercase), non-V6 use custID
|
||||||
if (
|
if (procConfig.isV6) {
|
||||||
category === 'wip' ||
|
params.CUSTID = custId;
|
||||||
category === 'finished-goods' ||
|
|
||||||
category === 'processed-other'
|
|
||||||
) {
|
|
||||||
params.sub = sub;
|
params.sub = sub;
|
||||||
|
} else {
|
||||||
|
params.custID = custId;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add filters if provided
|
// Add filters if provided (only for filtered variant)
|
||||||
if (filters?.partNum) {
|
if (hasFilters) {
|
||||||
params.PartNum = filters.partNum;
|
if (procConfig.isV6) {
|
||||||
}
|
params.PART = filters?.partNum || '';
|
||||||
if (filters?.plant) {
|
params.PLANT = filters?.plant || '';
|
||||||
params.Plant = filters.plant;
|
params.WAREHOUSE = filters?.warehouse || '';
|
||||||
}
|
} else {
|
||||||
if (filters?.warehouse) {
|
params.part = filters?.partNum || '';
|
||||||
params.Warehouse = filters.warehouse;
|
params.plant = filters?.plant || '';
|
||||||
|
params.warehouse = filters?.warehouse || '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = await execStoredProc<InventoryDetailRow[]>(procName, params);
|
const result = await execStoredProc<InventoryDetailRow[]>(procName, params);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue