diff --git a/client/packages/requisitions/src/RequestRequisition/ListView/ProgramRequisitionOptions.tsx b/client/packages/requisitions/src/RequestRequisition/ListView/ProgramRequisitionOptions.tsx index 4467a3ca69..adab15715c 100644 --- a/client/packages/requisitions/src/RequestRequisition/ListView/ProgramRequisitionOptions.tsx +++ b/client/packages/requisitions/src/RequestRequisition/ListView/ProgramRequisitionOptions.tsx @@ -133,7 +133,7 @@ const LabelAndOptions = ({ {noOptionsDisplay || ( )} - update({ incomingUnits: value })} - onBlur={save} + {isProgram && ( + <> + update({ incomingUnits: value })} + onBlur={save} + /> + } + labelWidth={LABEL_WIDTH} + label={t('label.incoming-stock')} + sx={{ marginBottom: 1 }} /> - } - labelWidth={LABEL_WIDTH} - label={t('label.incoming-stock')} - sx={{ marginBottom: 1 }} - /> - update({ outgoingUnits: value })} - onBlur={save} + update({ outgoingUnits: value })} + onBlur={save} + /> + } + labelWidth={LABEL_WIDTH} + label={t('label.outgoing')} + sx={{ marginBottom: 1 }} /> - } - labelWidth={LABEL_WIDTH} - label={t('label.outgoing')} - sx={{ marginBottom: 1 }} - /> - update({ lossInUnits: value })} - onBlur={save} + update({ lossInUnits: value })} + onBlur={save} + /> + } + labelWidth={LABEL_WIDTH} + label={t('label.losses')} + sx={{ marginBottom: 1 }} /> - } - labelWidth={LABEL_WIDTH} - label={t('label.losses')} - sx={{ marginBottom: 1 }} - /> - update({ additionInUnits: value })} - onBlur={save} + update({ additionInUnits: value })} + onBlur={save} + /> + } + labelWidth={LABEL_WIDTH} + label={t('label.additions')} + sx={{ marginBottom: 1 }} /> - } - labelWidth={LABEL_WIDTH} - label={t('label.additions')} - sx={{ marginBottom: 1 }} - /> - update({ expiringUnits: value })} - onBlur={save} + update({ expiringUnits: value })} + onBlur={save} + /> + } + labelWidth={LABEL_WIDTH} + label={t('label.short-expiry')} + sx={{ marginBottom: 1 }} /> - } - labelWidth={LABEL_WIDTH} - label={t('label.short-expiry')} - sx={{ marginBottom: 1 }} - /> - update({ daysOutOfStock: value })} - onBlur={save} + update({ daysOutOfStock: value })} + onBlur={save} + /> + } + labelWidth={LABEL_WIDTH} + label={t('label.days-out-of-stock')} + sx={{ marginBottom: 1 }} /> - } - labelWidth={LABEL_WIDTH} - label={t('label.days-out-of-stock')} - sx={{ marginBottom: 1 }} - /> + + )} - - } - labelWidth={LABEL_WIDTH} - label={t('label.months-of-stock')} - /> + {isProgram && ( + + } + labelWidth={LABEL_WIDTH} + label={t('label.months-of-stock')} + /> + )} {/* Right column content */} @@ -275,18 +281,20 @@ export const ResponseLineEdit = ({ )} - - } - labelWidth={LABEL_WIDTH} - label={t('label.available')} - sx={{ marginBottom: 1 }} - /> + {isProgram && ( + + } + labelWidth={LABEL_WIDTH} + label={t('label.available')} + sx={{ marginBottom: 1 }} + /> + )} - { - update({ reason: value }); - }} - width={200} - type={ReasonOptionNodeType.RequisitionLineVariance} - isDisabled={ - draft?.requestedQuantity === draft?.suggestedQuantity || - !!hasLinkedRequisition - } - onBlur={save} - /> - } - labelWidth={'66px'} - label={t('label.reason')} - sx={{ marginBottom: 1 }} - /> + {isProgram && ( + { + update({ reason: value }); + }} + width={200} + type={ReasonOptionNodeType.RequisitionLineVariance} + isDisabled={ + draft?.requestedQuantity === draft?.suggestedQuantity || + !!hasLinkedRequisition + } + onBlur={save} + /> + } + labelWidth={'66px'} + label={t('label.reason')} + sx={{ marginBottom: 1 }} + /> + )} = ({ : 100; return ( - + diff --git a/client/packages/requisitions/src/ResponseRequisition/DetailView/columns.ts b/client/packages/requisitions/src/ResponseRequisition/DetailView/columns.ts index 4f279dadd0..05b20eb789 100644 --- a/client/packages/requisitions/src/ResponseRequisition/DetailView/columns.ts +++ b/client/packages/requisitions/src/ResponseRequisition/DetailView/columns.ts @@ -71,119 +71,124 @@ export const useResponseColumns = () => { accessor: ({ rowData }) => rowData.availableStockOnHand, }); } - columnDefinitions.push( - // TODO: Global pref to show/hide the next columns - { - 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; + if (programName) { + columnDefinitions.push( + // TODO: Global pref to show/hide the next columns + { + 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; + const incomingStock = rowData.incomingUnits + rowData.additionInUnits; + const outgoingStock = rowData.lossInUnits + rowData.outgoingUnits; - return stockOnHand + incomingStock - outgoingStock; + return stockOnHand + incomingStock - outgoingStock; + }, }, - }, - { - 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; + { + 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 available = stockOnHand + incomingStock - outgoingStock; - const averageMonthlyConsumption = rowData.averageMonthlyConsumption; + const averageMonthlyConsumption = rowData.averageMonthlyConsumption; - return averageMonthlyConsumption !== 0 - ? available / averageMonthlyConsumption - : 0; - }, - }, + return averageMonthlyConsumption !== 0 + ? available / averageMonthlyConsumption + : 0; + }, + } + ); + } + + columnDefinitions.push( { key: 'suggestedQuantity', label: 'label.suggested-quantity', @@ -229,12 +234,14 @@ export const useResponseColumns = () => { ]); // TODO: Global pref to show/hide column - columnDefinitions.push({ - key: 'reason', - label: 'label.reason', - sortable: false, - accessor: ({ rowData }) => rowData.reason?.reason, - }); + if (programName) { + columnDefinitions.push({ + key: 'reason', + label: 'label.reason', + sortable: false, + accessor: ({ rowData }) => rowData.reason?.reason, + }); + } columnDefinitions.push({ label: 'label.already-issued',