-
Notifications
You must be signed in to change notification settings - Fork 10
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
Implemented: schema for shipment, defined action to fetch the shipments, and added transformation rule(#2vd6xty) #14
Open
ymaheshwari1
wants to merge
14
commits into
hotwax:main
Choose a base branch
from
ymaheshwari1:#2vd6xty
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
4e58a57
Implemented: schema for shipments referring moqui shipment schema(#2v…
ymaheshwari1 c1e4000
Implemented: support to fetch shipments and added the transformation …
ymaheshwari1 22f62b3
Removed: unwanted commented code(#2vd6xty)
ymaheshwari1 83fb85a
Removed: entry for lib directory from gitignore and added the build i…
ymaheshwari1 82e941d
Improved: code to export the fetchShipments method and updated the bu…
ymaheshwari1 c7d036f
Improved: code to prepare the paylod for fetching shipments(#2vd6xty)
ymaheshwari1 ebba787
Updated: the build for the app(#2vd6xty)
ymaheshwari1 34d1837
Improved: the type for fields and improved logic to prepare payload(#…
ymaheshwari1 7df2760
Improved: schema for shipment to use shipmentItemSource for defining …
ymaheshwari1 77a0266
Updated: the build for the package(#2vd6xty)
ymaheshwari1 b2a2546
Merge branch 'main' of https://github.com/hotwax/oms-api into #2vd6xty
ymaheshwari1 55aea6b
Removed: app build from the PR(#2vd6xty)
ymaheshwari1 ccc4e7c
Improved: code to make properties in shipment schema optional and mad…
ymaheshwari1 44d6a08
Merge branch 'main' into #2vd6xty
ymaheshwari1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const shipmentTransformRule = { | ||
item: { | ||
shipmentId: "shipmentId", | ||
estimatedArrivalDate: "estimatedArrivalDate", | ||
fromPartyId: "partyIdFrom", | ||
toPartyId: "partyIdTo", | ||
statusId: "statusId", | ||
shipmentItemCount: "shipmentItemCount", | ||
destinationFacilityId: "destinationFacilityId" | ||
} | ||
} | ||
|
||
export { shipmentTransformRule } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import api from "@/api"; | ||
import { hasError } from "@/util"; | ||
import { Response, Shipment } from "@/types"; | ||
import { shipmentTransformRule } from "@/mappings/shipment"; | ||
import { transform } from "node-json-transform"; | ||
|
||
async function fetchShipments(payload: any): Promise <Shipment[] | Response> { | ||
let response = {} as Shipment[] | Response | ||
|
||
const query = { | ||
"inputFields": { | ||
"destinationFacilityId": payload.facilityId, | ||
"statusId": "PURCH_SHIP_SHIPPED", | ||
"shipmentTypeId_fld0_value": "INCOMING_SHIPMENT", | ||
"shipmentTypeId_fld0_op": "equals", | ||
"shipmentTypeId_fld0_grp": "1", | ||
"parentTypeId_fld0_value": "INCOMING_SHIPMENT", | ||
"parentTypeId_fld0_op": "equals", | ||
"parentTypeId_fld0_grp": "2", | ||
}, | ||
"entityName": "ShipmentAndTypeAndItemCount", | ||
"fieldList" : ["shipmentId", "primaryShipGroupSeqId", "partyIdFrom", "partyIdTo", "estimatedArrivalDate", "destinationFacilityId", "statusId", "shipmentItemCount"], | ||
"noConditionFind": "Y", | ||
"viewSize": payload.viewSize, | ||
"viewIndex": payload.viewIndex, | ||
} as any | ||
|
||
if(payload.queryString) { | ||
query.inputFields["shipmentId"] = payload.queryString; | ||
query.inputFields["shipmentId_op"] = "contains"; | ||
query.inputFields["shipmentId_ic"] = "Y"; | ||
} | ||
|
||
try { | ||
const resp = await api({ | ||
url: '/performFind', | ||
method: 'post', | ||
data: query, | ||
cache: true | ||
}) as any | ||
|
||
if (resp.status === 200 && resp.data.docs?.length > 0 && !hasError(resp)) { | ||
const shipments: Array<Shipment> = transform(resp.data.docs, shipmentTransformRule) | ||
response = shipments; | ||
} else { | ||
response = []; | ||
} | ||
} catch(err) { | ||
response = { | ||
code: 'error', | ||
message: 'Something went wrong', | ||
serverResponse: err | ||
} | ||
} | ||
|
||
return response; | ||
} | ||
|
||
export { fetchShipments } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { Enumeration, Party, Status, Uom } from "./index" | ||
|
||
export interface ShipmentItemSource { | ||
shipmentItemSourceId?: string; | ||
orderId?: string; | ||
orderItemSeqId?: string; | ||
returnId?: string; | ||
returnItemSeqId?: string; | ||
statusId?: string; | ||
invoiceId?: string; | ||
invoiceItemSeqId?: string; | ||
} | ||
|
||
export interface Shipment { | ||
shipmentId: string; | ||
shipmentTypeEnumId?: string; | ||
statusId?: string; | ||
fromPartyId?: string; | ||
toPartyId?: string; | ||
binLocationNumber?: number; | ||
productStoreId?: string; | ||
priority?: number; | ||
entryDate?: number; | ||
shipAfterDate?: number; | ||
shipBeforeDate?: number; | ||
estimatedReadyDate?: number; | ||
estimatedShipDate?: number; | ||
estimatedArrivalDate?: number; | ||
latestCancelDate?: number; | ||
packedDate?: number; | ||
pickContainerId?: string; | ||
estimatedShipCost?: number; | ||
costUomId?: string; | ||
addtlShippingCharge?: number; | ||
addtlShippingChargeDesc?: string; | ||
signatureRequiredEnumId?: string; | ||
handlingInstructions?: string; | ||
otherPartyOrderId?: string; | ||
systemMessageRemoteId?: string; | ||
externalId?: string; | ||
originId?: string; | ||
type?: Enumeration; | ||
status?: Status; | ||
fromParty?: Party; | ||
toParty?: Party; | ||
costUom?: Uom; | ||
contents?: Array<{ | ||
shipmentContentId?: string; | ||
shipmentContentTypeEnumId?: string; | ||
shipmentId?: string; | ||
productId?: string; | ||
shipmentPackageSeqId?: string; | ||
shipmentRouteSegmentSeqId?: string; | ||
contentLocation?: string; | ||
description?: string; | ||
contentDate?: number; | ||
userId?: string; | ||
}>; | ||
items?: Array<{ | ||
shipmentId?: string; | ||
productId?: string; | ||
quantity?: number; | ||
itemSource?: ShipmentItemSource; | ||
}>; | ||
packages?: Array<{ | ||
shipmentId?: string; | ||
shipmentPackageSeqId?: string; | ||
shipmentBoxTypeId?: string; | ||
weight?: number; | ||
weightUomId?: string; | ||
gatewayPackageId?: string; | ||
}>; | ||
shipmentItemCount?: number; // Item count in shipment | ||
destinationFacilityId?: string; // Destination facility Id for shipment | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We are allowing to fetch only shipped and incoming shipments here. I would suggest making it configurable along with the following improvements:
We should define shipment status enumerations for apps (created, shipped...) and perform mapping in the package. This way package could easily take care of the different status values of different backend servers. The app query will be static for different backends having a defined status and the package does the magic.
For incoming/outgoing shipment conditions, I would suggest 2 possible solutions:
For example, we identify a field shipmentType with values incoming/outgoing. If we do not receive any value we fetch all shipments else add
This way we are abstracting applications from server details. The app needs incoming shipments, different backends may have different data models. If we define these conditions in apps, we may diverge from the bodiless approach and have to perform workarounds when switching between backends.
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.
As discussed with @adityasharma7 Sir and @dt2patel Sir, we will define two separate methods for incoming and outgoing shipments.
Also will create enums for shipment type and shipment status in oms package.