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 (
|
||||
questUser?.companies
|
||||
.filter((c) => c.company.is_active)
|
||||
.map((c) => c.company) || []
|
||||
.filter((c: CompanyRelation) => c.company.is_active)
|
||||
.map((c: CompanyRelation) => c.company) || []
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -185,41 +185,71 @@ export async function getInventoryDetails(
|
|||
warehouse?: string;
|
||||
}
|
||||
): Promise<InventoryDetailRow[]> {
|
||||
// Map category to stored procedure name
|
||||
const procMap: Record<InventoryCategory, string> = {
|
||||
wip: 'portal_WorkInProgressInventoryDetailV6',
|
||||
'finished-goods': 'portal_FinishedGoodsInventoryDetailV6',
|
||||
'processed-other': 'portal_ProcessedOtherInventoryDetailV6',
|
||||
unprocessed: 'portal_UnprocessedInventoryDetail',
|
||||
'unprocessed-rr': 'portal_UnprocessedRRInventoryDetail',
|
||||
'processed-rr': 'portal_ProcessedRRInventoryDetail',
|
||||
const hasFilters = filters?.partNum || filters?.plant || filters?.warehouse;
|
||||
|
||||
// Map category to stored procedure names (filtered and ALL variants)
|
||||
const procMap: Record<
|
||||
InventoryCategory,
|
||||
{ filtered: string; all: string; isV6: boolean }
|
||||
> = {
|
||||
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> = {
|
||||
CustID: custId,
|
||||
DBNAME: dbName,
|
||||
};
|
||||
|
||||
// V6 procedures use 'sub' parameter
|
||||
if (
|
||||
category === 'wip' ||
|
||||
category === 'finished-goods' ||
|
||||
category === 'processed-other'
|
||||
) {
|
||||
// V6 procedures use CUSTID (uppercase), non-V6 use custID
|
||||
if (procConfig.isV6) {
|
||||
params.CUSTID = custId;
|
||||
params.sub = sub;
|
||||
} else {
|
||||
params.custID = custId;
|
||||
}
|
||||
|
||||
// Add filters if provided
|
||||
if (filters?.partNum) {
|
||||
params.PartNum = filters.partNum;
|
||||
}
|
||||
if (filters?.plant) {
|
||||
params.Plant = filters.plant;
|
||||
}
|
||||
if (filters?.warehouse) {
|
||||
params.Warehouse = filters.warehouse;
|
||||
// Add filters if provided (only for filtered variant)
|
||||
if (hasFilters) {
|
||||
if (procConfig.isV6) {
|
||||
params.PART = filters?.partNum || '';
|
||||
params.PLANT = filters?.plant || '';
|
||||
params.WAREHOUSE = filters?.warehouse || '';
|
||||
} else {
|
||||
params.part = filters?.partNum || '';
|
||||
params.plant = filters?.plant || '';
|
||||
params.warehouse = filters?.warehouse || '';
|
||||
}
|
||||
}
|
||||
|
||||
const result = await execStoredProc<InventoryDetailRow[]>(procName, params);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue