-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
5137.1 requisition line edit + UI updates to line columns #5254
Changes from all commits
888c82b
208ad3c
dfe3d12
ed4ad8b
97a94b2
d5ee226
9e95fab
f1a0bf7
cb59d69
782602c
6396af9
4208187
316a92c
1be65da
1e77115
b21f7cc
f04d14f
84b2eed
e11f861
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ export const useResponseColumns = () => { | |
queryParams: { sortBy }, | ||
} = useUrlQueryParams({ initialSort: { key: 'itemName', dir: 'asc' } }); | ||
const { isRemoteAuthorisation } = useResponse.utils.isRemoteAuthorisation(); | ||
const { programName } = useResponse.document.fields(['programName']); | ||
|
||
const columnDefinitions: ColumnDescription<ResponseLineFragment>[] = [ | ||
getCommentPopoverColumn(), | ||
|
@@ -56,36 +57,160 @@ export const useResponseColumns = () => { | |
accessor: ({ rowData }) => rowData.itemStats.availableStockOnHand, | ||
}, | ||
], | ||
{ | ||
]; | ||
|
||
if (!programName) { | ||
columnDefinitions.push({ | ||
key: 'customerStockOnHand', | ||
label: 'label.customer-soh', | ||
description: 'description.customer-soh', | ||
width: 100, | ||
align: ColumnAlign.Right, | ||
getSortValue: rowData => | ||
rowData.linkedRequisitionLine?.itemStats?.availableStockOnHand ?? '', | ||
Cell: PackQuantityCell, | ||
accessor: ({ rowData }) => | ||
rowData.linkedRequisitionLine?.itemStats.availableStockOnHand ?? 0, | ||
getSortValue: rowData => rowData.availableStockOnHand, | ||
accessor: ({ rowData }) => rowData.availableStockOnHand, | ||
}); | ||
} | ||
columnDefinitions.push( | ||
// TODO: Global pref to show/hide the next columns | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Putting a TODO reminder for global prefs |
||
{ | ||
key: 'initialStockOnHand', | ||
label: 'label.initial-stock-on-hand', | ||
width: 100, | ||
align: ColumnAlign.Right, | ||
sortable: false, | ||
description: 'description.initial-stock-on-hand', | ||
Cell: PackQuantityCell, | ||
accessor: ({ rowData }) => rowData.initialStockOnHandUnits, | ||
}, | ||
{ | ||
key: 'incomingStock', | ||
label: 'label.incoming', | ||
width: 100, | ||
align: ColumnAlign.Right, | ||
sortable: false, | ||
Cell: PackQuantityCell, | ||
accessor: ({ rowData }) => rowData.incomingUnits, | ||
}, | ||
{ | ||
key: 'outgoingUnits', | ||
label: 'label.outgoing', | ||
width: 100, | ||
align: ColumnAlign.Right, | ||
sortable: false, | ||
Cell: PackQuantityCell, | ||
accessor: ({ rowData }) => rowData.outgoingUnits, | ||
}, | ||
{ | ||
key: 'losses', | ||
label: 'label.losses', | ||
width: 100, | ||
align: ColumnAlign.Right, | ||
sortable: false, | ||
Cell: PackQuantityCell, | ||
accessor: ({ rowData }) => rowData.lossInUnits, | ||
}, | ||
{ | ||
key: 'additions', | ||
label: 'label.additions', | ||
width: 100, | ||
align: ColumnAlign.Right, | ||
sortable: false, | ||
Cell: PackQuantityCell, | ||
accessor: ({ rowData }) => rowData.additionInUnits, | ||
}, | ||
{ | ||
key: 'availableUnits', | ||
label: 'label.available', | ||
width: 100, | ||
align: ColumnAlign.Right, | ||
sortable: false, | ||
description: 'description.available-stock', | ||
Cell: PackQuantityCell, | ||
accessor: ({ rowData }) => { | ||
const stockOnHand = rowData.initialStockOnHandUnits; | ||
|
||
const incomingStock = rowData.incomingUnits + rowData.additionInUnits; | ||
const outgoingStock = rowData.lossInUnits + rowData.outgoingUnits; | ||
|
||
return stockOnHand + incomingStock - outgoingStock; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the previous commment on using itemStats, I think this will break their available units? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm still confused by adding the movements to the not:
|
||
}, | ||
}, | ||
{ | ||
key: 'expiringUnits', | ||
label: 'label.short-expiry', | ||
width: 100, | ||
align: ColumnAlign.Right, | ||
sortable: false, | ||
Cell: PackQuantityCell, | ||
accessor: ({ rowData }) => rowData.expiringUnits, | ||
}, | ||
{ | ||
key: 'daysOutOfStock', | ||
label: 'label.days-out-of-stock', | ||
width: 100, | ||
align: ColumnAlign.Right, | ||
sortable: false, | ||
Cell: PackQuantityCell, | ||
accessor: ({ rowData }) => rowData.daysOutOfStock, | ||
}, | ||
{ | ||
key: 'amc', | ||
label: 'label.amc', | ||
width: 100, | ||
align: ColumnAlign.Right, | ||
sortable: false, | ||
Cell: PackQuantityCell, | ||
accessor: ({ rowData }) => rowData.averageMonthlyConsumption, | ||
}, | ||
{ | ||
key: 'mos', | ||
label: 'label.months-of-stock', | ||
width: 100, | ||
align: ColumnAlign.Right, | ||
sortable: false, | ||
Cell: PackQuantityCell, | ||
accessor: ({ rowData }) => { | ||
const stockOnHand = rowData.initialStockOnHandUnits; | ||
const incomingStock = rowData.incomingUnits + rowData.additionInUnits; | ||
const outgoingStock = rowData.lossInUnits + rowData.outgoingUnits; | ||
|
||
const available = stockOnHand + incomingStock - outgoingStock; | ||
|
||
const averageMonthlyConsumption = rowData.averageMonthlyConsumption; | ||
|
||
return averageMonthlyConsumption !== 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice no divide by 0. Tangentially... if a site has 0 AMC then maybe their MOS should be infinity lol |
||
? available / averageMonthlyConsumption | ||
: 0; | ||
}, | ||
}, | ||
{ | ||
key: 'suggestedQuantity', | ||
label: 'label.suggested-quantity', | ||
width: 150, | ||
align: ColumnAlign.Right, | ||
sortable: false, | ||
Cell: PackQuantityCell, | ||
accessor: ({ rowData }) => rowData.suggestedQuantity, | ||
}, | ||
[ | ||
'requestedQuantity', | ||
{ | ||
getSortValue: rowData => rowData.requestedQuantity, | ||
Cell: PackQuantityCell, | ||
accessor: ({rowData}) => rowData.requestedQuantity, | ||
accessor: ({ rowData }) => rowData.requestedQuantity, | ||
width: 150, | ||
}, | ||
], | ||
]; | ||
] | ||
); | ||
|
||
if (isRemoteAuthorisation) { | ||
columnDefinitions.push({ | ||
key: 'approvedQuantity', | ||
label: 'label.approved-quantity', | ||
sortable: false, | ||
Cell: PackQuantityCell, | ||
accessor: ({rowData}) => rowData.approvedQuantity, | ||
accessor: ({ rowData }) => rowData.approvedQuantity, | ||
}); | ||
columnDefinitions.push({ | ||
key: 'approvalComment', | ||
|
@@ -99,18 +224,26 @@ export const useResponseColumns = () => { | |
{ | ||
getSortValue: rowData => rowData.supplyQuantity, | ||
Cell: PackQuantityCell, | ||
accessor: ({rowData}) => rowData.requestedQuantity, | ||
accessor: ({ rowData }) => rowData.requestedQuantity, | ||
}, | ||
]); | ||
|
||
// TODO: Global pref to show/hide column | ||
columnDefinitions.push({ | ||
key: 'reason', | ||
label: 'label.reason', | ||
sortable: false, | ||
accessor: ({ rowData }) => rowData.reason?.reason, | ||
}); | ||
|
||
columnDefinitions.push({ | ||
label: 'label.already-issued', | ||
description: 'description.already-issued', | ||
key: 'alreadyIssued', | ||
align: ColumnAlign.Right, | ||
getSortValue: rowData => rowData.alreadyIssued, | ||
Cell: PackQuantityCell, | ||
accessor: ({rowData}) => rowData.alreadyIssued, | ||
accessor: ({ rowData }) => rowData.alreadyIssued, | ||
width: 100, | ||
}); | ||
|
||
|
@@ -121,7 +254,7 @@ export const useResponseColumns = () => { | |
align: ColumnAlign.Right, | ||
getSortValue: rowData => rowData.remainingQuantityToSupply, | ||
Cell: PackQuantityCell, | ||
accessor: ({rowData}) => rowData.remainingQuantityToSupply, | ||
accessor: ({ rowData }) => rowData.remainingQuantityToSupply, | ||
}); | ||
columnDefinitions.push(GenericColumnKey.Selection); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Their SOH only shows up for requisitions which aren't programs