Skip to content
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

OBPIH-6813 shipped in po column when edits to shipped quantities in receiving #4941

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@ class ShipmentItem implements Comparable, Serializable {
return orderItem?.unitOfMeasure
}

BigDecimal getPackSize() {
return orderItem?.quantityPerUom
}

/**
* Sorts shipping items by associated product name, then lot number, then quantity,
* and finally by id.
Expand Down
2 changes: 1 addition & 1 deletion grails-app/i18n/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3663,7 +3663,7 @@ react.partialReceiving.lotSerialNo.label=Lot/Serial No.
react.partialReceiving.expirationDate.label=Expiration date
react.partialReceiving.binLocation.label=Bin Location
react.partialReceiving.recipient.label=Recipient
react.partialReceiving.shippedInPo.label=Shipped (in PO)
react.partialReceiving.shippedInPo.label=Shipped (in PO UoM)
react.partialReceiving.shippedEach.label=Shipped (each)
react.partialReceiving.shipped.label=Shipped
react.partialReceiving.received.label=Received
Expand Down
8 changes: 6 additions & 2 deletions src/js/components/form-elements/TextField.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ import React from 'react';
import BaseField from 'components/form-elements/BaseField';
import Input from 'utils/Input';


const TextField = (props) => {
const renderInput = attributes => (
const renderInput = ({
inputClassName,
className,
...attributes
}) => (
<Input
isFormElement
className={inputClassName || className}
{...attributes}
/>
);
Expand Down
37 changes: 33 additions & 4 deletions src/js/components/receiving/PartialReceivingPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,15 +261,38 @@ const TABLE_FIELDS = {
unitOfMeasure: {
type: (params) => <LabelField {...params} />,
label: 'react.partialReceiving.shippedInPo.label',
defaultMessage: 'Shipped (in PO)',
defaultMessage: 'Shipped (in PO UoM)',
multilineHeader: true,
flexWidth: '1',
attributes: {
cellClassName: 'text-right',
showValueTooltip: true,
},
getDynamicAttr: (props) => ({
hide: !props.values?.isShipmentFromPurchaseOrder,
}),
getDynamicAttr: ({ values, parentIndex, rowIndex }) => {
const shipmentItem = _.get(
values,
`containers[${parentIndex}].shipmentItems[${rowIndex}]`,
{},
);
Comment on lines +272 to +276
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use nullsafe here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had some issues when using

 const shipmentItem = values?.containers[parentIndex]?.shipmentItems[rowIndex] ?? {};

I guess the values are very deeply nested and nulish operator does not handle it very well

const packsRequested = _.round(shipmentItem?.packsRequested, 2);
const unitOfMeasure = shipmentItem?.unitOfMeasure;

return {
tooltipValue: unitOfMeasure ? `${packsRequested} ${unitOfMeasure}` : undefined,
formatValue: () => {
if (!unitOfMeasure) {
return null;
}
return (
<span>
{packsRequested}
<small className="text-muted ml-1">{unitOfMeasure}</small>
</span>
);
},
hide: !values?.isShipmentFromPurchaseOrder,
};
},
},
quantityShipped: {
type: (params) => (params.subfield ? <LabelField {...params} /> : null),
Expand All @@ -278,6 +301,7 @@ const TABLE_FIELDS = {
multilineHeader: true,
flexWidth: '1',
attributes: {
cellClassName: 'text-right',
formatValue: (value) => (value ? (value.toLocaleString('en-US')) : value),
},
getDynamicAttr: ({ values }) => ({
Expand Down Expand Up @@ -333,6 +357,7 @@ const TABLE_FIELDS = {
flexWidth: '1',
attributes: {
autoComplete: 'off',
inputClassName: 'text-right',
},
getDynamicAttr: ({ shipmentReceived, fieldValue, values }) => ({
disabled: shipmentReceived || isReceived(true, fieldValue),
Expand Down Expand Up @@ -805,6 +830,10 @@ class PartialReceivingPage extends Component {
unitOfMeasure: shipmentItemsGrouped.originalItem?.unitOfMeasure,
// This helper id is needed for mismatching quantity shipped indicator in edit modal
rowId: _.uniqueId(),
packSize: shipmentItemsGrouped.originalItem?.packSize,
packsRequested: shipmentItemsGrouped.originalItem?.packSize
? item.quantityShipped / shipmentItemsGrouped.originalItem?.packSize
: null,
}));

/**
Expand Down
2 changes: 2 additions & 0 deletions src/js/components/receiving/ReceivingCheckScreen.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ const TABLE_FIELDS = {
defaultMessage: 'Receiving now',
flexWidth: '1',
attributes: {
cellClassName: 'text-right',
formatValue: value => (value ? (value.toLocaleString('en-US')) : value),
},
},
Expand All @@ -174,6 +175,7 @@ const TABLE_FIELDS = {
fieldKey: '',
flexWidth: '1',
attributes: {
cellClassName: 'text-right',
formatValue: fieldValue => (fieldValue && fieldValue.quantityRemaining ? fieldValue.quantityRemaining.toLocaleString('en-US') : fieldValue.quantityRemaining),
},
getDynamicAttr: ({ fieldValue }) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package org.pih.warehouse.api
import org.pih.warehouse.core.Location
import org.pih.warehouse.core.Person
import org.pih.warehouse.inventory.InventoryItem
import org.pih.warehouse.order.OrderItem
import org.pih.warehouse.product.Product
import org.pih.warehouse.receiving.ReceiptItem
import org.pih.warehouse.receiving.ReceiptStatusCode
Expand Down Expand Up @@ -74,10 +73,6 @@ class PartialReceiptItem {
return quantityShipped / shipmentItem?.quantityPerUom
}

String getDisplayUnitOfMeasure() {
return "${packsRequested?.toPlainString()} ${shipmentItem?.unitOfMeasure}"
}

Map toJson() {
return [

Expand Down Expand Up @@ -109,7 +104,9 @@ class PartialReceiptItem {
cancelRemaining : cancelRemaining,
quantityOnHand : quantityOnHand,
comment : comment,
unitOfMeasure : displayUnitOfMeasure,
unitOfMeasure : shipmentItem?.unitOfMeasure,
packSize : shipmentItem?.packSize,
packsRequested : packsRequested,
]
}

Expand Down
Loading