Skip to content

Commit

Permalink
Changes related to create#PostalAddress service.
Browse files Browse the repository at this point in the history
  • Loading branch information
mridulpathak committed Jan 6, 2025
1 parent d6b8971 commit c1953ab
Show file tree
Hide file tree
Showing 4 changed files with 224 additions and 19 deletions.
37 changes: 26 additions & 11 deletions project-ideas/oms/createPostalAddress.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
### create#PostalAddress

1. Parameters
* Input
* toName
* address1
* address2
* city
* postalCode
* stateProvinceGeoId
* countryGeoId
* latitude
* longitude
* Output
* contactMechId
2. Call create#ContactMech for [contactMechTypeId:"POSTAL_ADDRESS"].
3. Set contactMechId = createContactMechOutput.contactMechId.
4. Call create#PostalAddress for context

```json
{
"toName": "Demo Customer Company",
"address1": "2004 Factory Blvd",
"city": "Orem",
"stateProvinceGeoId": "UT",
"postalCode": "84057",
"countryGeoId": "USA",
"toName": "Demo Customer Company",
"address1": "2004 Factory Blvd",
"address2": "",
"city": "Orem",
"stateProvinceGeoId": "UT",
"postalCode": "84057",
"countryGeoId": "USA",
"latitude": "40.7650225",
"longitude": "40.7650225"
}

```
This would be the oms api the uses entity crud.
Workflow
1. create ContactMech
2. create PostalAddress

190 changes: 190 additions & 0 deletions project-ideas/order-ledger/ShopifyOrderSyncDesign.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,200 @@ Following would be the flow to sync products,
> - Support to create OrderPaymentPreference(s) for Shopify order transactions
> - Support to create OrderPaymentPreference for Shopify order payment term
> - Support to create OrderItemAssociation(s) for exchange orders
> - Support to create OrderNote for shopifyOrder.note
> - Handle shopifyOrder.tags
## Shopify Connector
Shopify connector would produce a periodic created orders feed since last run time with following fields,

```
Order {
id
name
displayFulfillmentStatus
createdAt
cancelledAt
channelInformation {
channelDefinition {
handle
}
}
customAttributes {
key
value
}
customer {
id
firstName
lastName
email
}
phone
email
tags
note
currencyCode
presentmentCurrencyCode
totalPriceSet {
presentmentMoney {
amount
currencyCode
}
}
currentTotalPriceSet {
presentmentMoney {
amount
currencyCode
}
}
shippingAddress {
name
address1
address2
city
zip
provinceCode
countryCodeV2
latitude
longitude
phone
}
billingAddress {
name
address1
address2
city
zip
provinceCode
countryCodeV2
latitude
longitude
phone
}
shippingLines (first: 5) {
edges {
node {
title
originalPriceSet {
presentmentMoney {
amount
currencyCode
}
}
discountAllocations {
allocatedAmountSet {
presentmentMoney {
amount
currencyCode
}
}
discountApplication {
... on DiscountCodeApplication {
code
targetType
value {
... on PricingPercentageValue {
percentage
}
}
}
}
}
taxLines {
title
priceSet {
presentmentMoney {
amount
currencyCode
}
}
}
}
}
}
totalTipReceivedSet {
presentmentMoney {
amount
currencyCode
}
}
fulfillmentOrders (first: 5) {
edges {
node {
id
status
assignedLocation {
location {
id
}
}
deliveryMethod {
methodType
serviceCode
}
lineItems (first: 5) {
edges {
node {
id
lineItem {
id
sku
variant {
id
barcode
title
}
originalUnitPriceSet {
presentmentMoney {
amount
}
}
quantity
nonFulfillableQuantity
customAttributes {
key
value
}
taxLines {
title
ratePercentage
priceSet {
presentmentMoney {
amount
currencyCode
}
}
}
discountAllocations {
allocatedAmountSet {
presentmentMoney {
amount
currencyCode
}
}
discountApplication {
... on DiscountCodeApplication {
code
value {
... on PricingPercentageValue {
percentage
}
}
}
}
}
}
totalQuantity
remainingQuantity
}
}
}
}
}
}
}
```

## Shopify OMS Bridge

Periodically receive and consume ShopifyNewOrdersFeed and transform to generated OMSNewOrdersFeed.
Expand Down
8 changes: 4 additions & 4 deletions project-ideas/order-ledger/createSalesOrder.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ This service will take in the order JSON in OMSNewOrdersFeed and set up a comple
* Get ProductStore for orderJson.productStoreId
* Add [partyId:ProductStore.payToPartyId, roleTypeId:"SHIP_FROM_VENDOR"] to orderContext.roles
5. Initialize orderContext.contactMechs list
* For orderJson.shipToAddress map call create#ContactMech with input as [contactMechTypeId:"POSTAL_ADDRESS", postalAddress:orderJson.shipToAddress]
* Set shipToAddressContactMechId = createContactMechOutput.contactMechId
* For orderJson.shipToAddress map call create#PostalAddress with input as orderJson.shipToAddress
* Set shipToAddressContactMechId = createPostalAddressOutput.contactMechId
* Add [contatctMechId:shipToAddressContactMechId, contactMechPurposeTypeId:"SHIPPING_LOCATION"] to orderContext.contactMechs
* Call create#ContactMech for [contactMechTypeId:"TELECOM_NUMBER", infoString:orderJson.shipToPhone]
* Set shipToPhoneContactMechId = createContactMechOutput.contactMechId
* Add [contatctMechId:shipToPhoneContactMechId, contactMechPurposeTypeId:"PHONE_SHIPPING"] to orderContext.contactMechs
* Call create#ContactMech for [contactMechTypeId:"EMAIL_ADDRESS", infoString:orderJson.email]
* Add [contatctMechId:createContactMechOutput.contactMechId, contactMechPurposeTypeId:"ORDER_EMAIL"] to orderContext.contactMechs
* If orderJson.billToAddress
* For orderJson.billToAddress map call create#ContactMech with input as [contactMechTypeId:"POSTAL_ADDRESS", postalAddress:orderJson.billToAddress]
* Add [contatctMechId:createContactMechOutput.contactMechId, contactMechPurposeTypeId:"BILLING_LOCATION"] to orderContext.contactMechs
* For orderJson.billToAddress map call create#PostalAddress with input as orderJson.billToAddress
* Add [contatctMechId:createPostalAddressOutput.contactMechId, contactMechPurposeTypeId:"BILLING_LOCATION"] to orderContext.contactMechs
* If orderJson.billToPhone
* Call create#ContactMech for [contactMechTypeId:"TELECOM_NUMBER", infoString:orderJson.billToPhone]
* Add [contatctMechId:createContactMechOutput.contactMechId, contactMechPurposeTypeId:"PHONE_BILLING"] to orderContext.contactMechs
Expand Down
8 changes: 4 additions & 4 deletions project-ideas/order-ledger/mapSalesOrder.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
* If shopifyOrder.displayFulfillmentStatus="FULFILLED", set as "ORDER_COMPLETED"
* If shopifyOrder.cancelledAt is not null, set as "ORDER_CANCELLED"
* order.attributes = Iterate through shopifyOrder.customAttributes if not null and add to list [attrName:shopifyOrder.customAttributes.key, attrValue:shopifyOrder.customAttributes.value]
* order.shipToAddress = [toName:shopifyOrder.shippingAddress.name, address1:shopifyOrder.shippingAddress.address1, address2:shopifyOrder.shippingAddress.address2, city:shopifyOrder.shippingAddress.city, postalCode:shopifyOrder.shippingAddress.zip, stateProvineGeoId:geoId where shopifyOrder.shippingAddress.provinceCode=Geo.geoCode, countryGeoId:geoId where shopifyOrder.shippingAddress.countryCodeV2=Geo.geoCode, latitude:shopifyOrder.shippingAddress.latitude, longitude:shopifyOrder.shippingAddress.longitude]
* order.shipToAddress = [toName:shopifyOrder.shippingAddress.name, address1:shopifyOrder.shippingAddress.address1, address2:shopifyOrder.shippingAddress.address2, city:shopifyOrder.shippingAddress.city, postalCode:shopifyOrder.shippingAddress.zip, stateProvinceGeoId:geoId where shopifyOrder.shippingAddress.provinceCode=Geo.geoCode, countryGeoId:geoId where shopifyOrder.shippingAddress.countryCodeV2=Geo.geoCode, latitude:shopifyOrder.shippingAddress.latitude, longitude:shopifyOrder.shippingAddress.longitude]
* order.shipToPhone = shopifyOrder.shippingAddress.phone
* If "SAVE_BILL_TO_INF" setting in ProductStoreSetting is "Y"
* order.billToAddress = [toName:shopifyOrder.billingAddress.name, address1:shopifyOrder.billingAddress.address1, address2:shopifyOrder.billingAddress.address2, city:shopifyOrder.billingAddress.city, postalCode:shopifyOrder.billingAddress.zip, stateProvineGeoId:geoId where shopifyOrder.billingAddress.provinceCode=Geo.geoCode, countryGeoId:geoId where shopifyOrder.billingAddress.countryCodeV2=Geo.geoCode, latitude:shopifyOrder.billingAddress.latitude, longitude:shopifyOrder.billingAddress.longitude]
* order.billToAddress = [toName:shopifyOrder.billingAddress.name, address1:shopifyOrder.billingAddress.address1, address2:shopifyOrder.billingAddress.address2, city:shopifyOrder.billingAddress.city, postalCode:shopifyOrder.billingAddress.zip, stateProvinceGeoId:geoId where shopifyOrder.billingAddress.provinceCode=Geo.geoCode, countryGeoId:geoId where shopifyOrder.billingAddress.countryCodeV2=Geo.geoCode, latitude:shopifyOrder.billingAddress.latitude, longitude:shopifyOrder.billingAddress.longitude]
* order.billToPhone = shopifyOrder.billingAddress.phone
* order.customer = [externalId:shopifyOrder.customer.id, firstName:shopifyOrder.customer.firstName, lastName:shopifyOrder.customer.lastName, dataSourceId:"SHOPIFY", email:shopifyOrder.customer.email]
* order.productStoreId = ProductStore.productStoreId
Expand All @@ -39,7 +39,7 @@
* If shopifyOrder.shippingLines.taxLines.priceSet.presentmentMoney.amount > 0
* Add to order.adjustments list [orderAdjustmentTypeId:"SHIPPING_SALES_TAX", amount:taxAmount, sourcePercentage:shopifyOrder.shippingLines.taxLines.ratePercentage, comments:shopifyOrder.shippingLines.taxLines.title]
* Iterate through shopifyOrder.shippingLines.discountAllocations
* Set shippingDiscountAdjustment = [orderAdjustmentTypeId:"EXT_PROMO_ADJUSTMENT", amount:(shopifyOrder.shippingLines.discountAllocations.allocatedAmountSet.presentmentMoney.amount).negate(), comments:"ExternalDiscount"]
* Set shippingDiscountAdjustment = [orderAdjustmentTypeId:"EXT_PROMO_ADJUSTMENT", amount:(shopifyOrder.shippingLines.discountAllocations.allocatedAmountSet.presentmentMoney.amount).negate(), comments:"External Discount"]
* If shopifyOrder.shippingLines.discountAllocations.discountCodeApplication exists
* Set shippingDiscountAdjustment.attributes (List) = [[attrName:"DISCOUNT_CODE", attrValue:shopifyOrder.shippingLines.discountAllocations.discountCodeApplication.discountCodeApplication.code]]
* If shopifyOrder.shippingLines.discountAllocations.discountCodeApplication.pricingPercentageValue exists
Expand Down Expand Up @@ -67,7 +67,7 @@
* Add following map to orderAdjustments list - [orderAdjustmentTypeId:"SALES_TAX", amount:taxAmount, sourcePercentage:shopifyOrder.fulfillmentOrders.lineItems.taxLines.ratePercentage, comments:shopifyOrder.fulfillmentOrders.lineItems.taxLines.title]
* Iterate through shopifyOrder.fulfillmentOrders.lineItems.linetItem.discountAllocations
* Calculate discount amount for exploded order items, discountAmount = shopifyOrder.fulfillmentOrders.lineItems.linetItem.discountAllocations.allocatedAmountSet.presentmentMoney.amount / shopifyOrder.fulfillmentOrders.lineItems.lineItem.quantity
* Set discountAdjustment = [orderAdjustmentTypeId:"EXT_PROMO_ADJUSTMENT", amount:discountAmount.negate(), comments:"ExternalDiscount"]
* Set discountAdjustment = [orderAdjustmentTypeId:"EXT_PROMO_ADJUSTMENT", amount:discountAmount.negate(), comments:"External Discount"]
* If shopifyOrder.fulfillmentOrders.lineItems.linetItem.discountAllocations.discountCodeApplication
* Set discountAdjustment.attributes (List) = [[attrName:"DISCOUNT_CODE", attrValue:shopifyOrder.fulfillmentOrders.lineItems.linetItem.discountAllocations.discountCodeApplication.code]]
* If shopifyOrder.fulfillmentOrders.lineItems.linetItem.discountAllocations.discountCodeApplication.pricingPercentageValue
Expand Down

0 comments on commit c1953ab

Please sign in to comment.