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

View entity to fetch eligible records #2

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
5b01be8
Added a view to fetch the order level details of orders eligible for NS
Dec 3, 2024
eb61100
Merge branch 'hotwax:main' into view-entity-to-fetch-eligible-records
Shinde-nutan Dec 3, 2024
32a8a8b
Added the OPP in the view entity
Dec 3, 2024
2c31601
Merge branch 'view-entity-to-fetch-eligible-records' of https://githu…
Dec 3, 2024
d46e953
Added a view to fetch the item level detail
Dec 3, 2024
ab82460
Remove the join of OPP from EligibleOrdersForNetSuiteView and join of…
Dec 4, 2024
2e5bb05
Merge branch 'hotwax:main' into view-entity-to-fetch-eligible-records
Shinde-nutan Dec 4, 2024
998d0cc
Remove the alies-all for OH and OI from the respective views
Dec 4, 2024
ef2d195
Merge branch 'view-entity-to-fetch-eligible-records' of https://githu…
Dec 4, 2024
fa146ae
Added a view IntegrationTypeMappingAndEnum
Dec 4, 2024
210d9a2
Added a view to fetch the eligible order ids and remove the eligiblit…
Dec 5, 2024
3b699cf
added the communicationeventandorder view.
Shinde-nutan Dec 11, 2024
c26d7d2
Added comments in the viewEntity.
Shinde-nutan Dec 13, 2024
8589b1a
shift the view entity into new file.
Shinde-nutan Dec 14, 2024
42b511f
updated the component name
Shinde-nutan Dec 14, 2024
68a40ea
Added the subselect in the EligibleOrdersForNetSuiteView to add a che…
Shinde-nutan Dec 17, 2024
237bd92
added comment in subselect
Shinde-nutan Dec 17, 2024
0b677aa
added the enum code in the view
Shinde-nutan Dec 20, 2024
7e56cf5
Added a view entity (InvalidOrdersForNetsuite) to exculde the invalid…
Shinde-nutan Dec 24, 2024
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# mantle-net-suite-connector
# mantle-netsuite-connector
NetSuite Connector in Moqui
121 changes: 121 additions & 0 deletions entity/OrderViewEntities.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<?xml version="1.0" encoding="UTF-8"?>

<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/entity-definition-3.xsd">
<view-entity entity-name="EligibleOrdersForNetSuiteView" package="co.hotwax.order" group="ofbiz_transactional">
<member-entity entity-alias="OH" entity-name="org.apache.ofbiz.order.order.OrderHeader"/>
<member-entity entity-alias="SCENM" entity-name="org.apache.ofbiz.common.enum.Enumeration" join-from-alias="OH" join-optional="true">
<key-map field-name="salesChannelEnumId" related="enumId"/>
</member-entity>
<member-entity entity-alias="OID" entity-name="co.hotwax.order.OrderIdentification" join-from-alias="OH" join-optional="true">
<key-map field-name="orderId"/>
<entity-condition>
<econdition entity-alias="OID" field-name="orderIdentificationTypeId" value="NETSUITE_ORDER_ID"/>
<date-filter/>
</entity-condition>
</member-entity>
<member-entity entity-alias="ODR" entity-name="org.apache.ofbiz.order.order.OrderRole" join-from-alias="OH" join-optional="true">
<key-map field-name="orderId"/>
<entity-condition>
<econdition entity-alias="ODR" field-name="roleTypeId" operator="equals" value="BILL_TO_CUSTOMER"/>
</entity-condition>
</member-entity>
<member-entity entity-alias="PID" entity-name="org.apache.ofbiz.party.party.PartyIdentification" join-from-alias="ODR">
<key-map field-name="partyId"/>
<entity-condition>
<econdition entity-alias="PID" field-name="partyIdentificationTypeId" value="NETSUITE_CUSTOMER_ID"/>
</entity-condition>
Copy link
Contributor

Choose a reason for hiding this comment

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

@Shinde-nutan,
Add one more entity condition to include "SHOPIFY_CUST_ID"

Copy link
Author

Choose a reason for hiding this comment

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

Hello sir,
In this view we are fetching the details which is required for an order to sync at Netsuite.
the shopify customer id is not required field. if needed we can add that in the custom groovy file which we are preparing specific to client.

Copy link
Contributor

Choose a reason for hiding this comment

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

While we will have Shopify as a constant in our integrations, fetching the field in this view will make this specific to Shopify only and create need for refactoring should orders enter HotWax from another source. For now I agree with @Shinde-nutan here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hello @dt2patel

I agreed.

During the KR Production rollout, someone enabled the "Import Customer Job," which resulted in duplicate customers being created in NetSuite. When we create customers through the "Import Customer Job," we store the Shopify Customer ID in the External ID field of the Party entity.

However, when syncing historical customers from NetSuite or importing a new order from Shopify, we create a PartyIdentification record with the Shopify Customer ID and the corresponding partyIdentificationTypeID defined in OMS.

To avoid duplication issues, we need to add a condition to filter valid customer records appropriately during the fetch process. So we can add the condition in the Groovy file.

CC: @Shinde-nutan

</member-entity>
<member-entity entity-alias="OCMBL" entity-name="org.apache.ofbiz.order.order.OrderContactMech" join-from-alias="OH" join-optional="true">
<key-map field-name="orderId"/>
<entity-condition>
<econdition entity-alias="OCMBL" field-name="contactMechPurposeTypeId" operator="equals" value="BILLING_LOCATION"/>
</entity-condition>
</member-entity>
<member-entity entity-alias="PAB" entity-name="org.apache.ofbiz.party.contact.PostalAddress" join-from-alias="OCMBL" join-optional="true">
<key-map field-name="contactMechId"/>
</member-entity>
<member-entity entity-alias="COUNTRYGEOBL" entity-name="org.apache.ofbiz.common.geo.Geo" join-from-alias="PAB" join-optional="true">
<key-map field-name="countryGeoId" related="geoId"/>
</member-entity>
<member-entity entity-alias="OCMSL" entity-name="org.apache.ofbiz.order.order.OrderContactMech" join-from-alias="OH" join-optional="true">
<key-map field-name="orderId"/>
<entity-condition>
<econdition entity-alias="OCMSL" field-name="contactMechPurposeTypeId" operator="equals" value="SHIPPING_LOCATION"/>
</entity-condition>
</member-entity>
<member-entity entity-alias="PAS" entity-name="org.apache.ofbiz.party.contact.PostalAddress" join-from-alias="OCMSL" join-optional="true">
<key-map field-name="contactMechId"/>
</member-entity>
<member-entity entity-alias="COUNTRYGEOSL" entity-name="org.apache.ofbiz.common.geo.Geo" join-from-alias="PAS" join-optional="true">
<key-map field-name="countryGeoId" related="geoId"/>
</member-entity>
<member-entity entity-alias="OCMBP" entity-name="org.apache.ofbiz.order.order.OrderContactMech" join-from-alias="OH" join-optional="true">
<key-map field-name="orderId"/>
<entity-condition>
<econdition entity-alias="OCMBP" field-name="contactMechPurposeTypeId" operator="equals" value="PHONE_BILLING"/>
</entity-condition>
</member-entity>
<member-entity entity-alias="TN" entity-name="org.apache.ofbiz.party.contact.TelecomNumber" join-from-alias="OCMBP" join-optional="true">
<key-map field-name="contactMechId"/>
</member-entity>
<member-entity entity-alias="OADJ" entity-name="org.apache.ofbiz.order.order.OrderAdjustment" join-from-alias="OH" join-optional="true">
<key-map field-name="orderId"/>
<entity-condition>
<econdition field-name="orderAdjustmentTypeId" value="SHIPPING_CHARGES"/>
</entity-condition>
</member-entity>
<member-entity entity-alias="OPP" entity-name="org.apache.ofbiz.order.order.OrderPaymentPreference" join-from-alias="OH" join-optional="true">
dt2patel marked this conversation as resolved.
Show resolved Hide resolved
<key-map field-name="orderId"/>
<entity-condition>
<econdition field-name="paymentMethodTypeId" value="EXT_GIFT_CARD"/>
</entity-condition>
</member-entity>
<entity-condition>
<econdition entity-alias="OH" field-name="orderTypeId" operator="equals" value="SALES_ORDER"/>
<econdition entity-alias="OID" field-name="orderId" operator="equals" value=""/>
</entity-condition>
<alias-all entity-alias="OH"/>
<alias name="shippingAddress1" field="address1" entity-alias="PAS"/>
<alias name="shippingAddress2" field="address2" entity-alias="PAS"/>
<alias name="shippingCity" field="city" entity-alias="PAS"/>
<alias name="shippingState" field="stateProvinceGeoId" entity-alias="PAS"/>
<alias name="shippingPostalCode" field="postalCode" entity-alias="PAS"/>
<alias name="shippingCountry" field="geoCode" entity-alias="COUNTRYGEOSL"/>
<alias name="billingAddress1" field="address2" entity-alias="PAB"/>
<alias name="billingAddress2" field="address2" entity-alias="PAB"/>
<alias name="billingCity" field="city" entity-alias="PAB"/>
<alias name="billingState" field="stateProvinceGeoId" entity-alias="PAB"/>
<alias name="billingPostalCode" field="postalCode" entity-alias="PAB"/>
<alias name="billingCountry" field="geoCode" entity-alias="COUNTRYGEOBL"/>
<alias name="NetsuiteCustomerId" field="idValue" entity-alias="PID"/>
<alias name="salesChannel" field="description" entity-alias="SCENM"/>
<alias-all entity-alias="TN"/>
<alias name="ShippingCharge" field="amount" entity-alias="OADJ"/>
<alias name="giftCardAmountSum" field="maxAmount" entity-alias="OPP"/>
</view-entity>

<view-entity entity-name="OrderItemsForNetSuiteView" package="co.hotwax.order" group="ofbiz_transactional">
<member-entity entity-alias="OI" entity-name="org.apache.ofbiz.order.order.OrderItem"/>
<member-entity entity-alias="P" entity-name="org.apache.ofbiz.product.product.Product" join-from-alias="OI">
<key-map field-name="productId"/>
</member-entity>
<member-entity entity-alias="GID" entity-name="org.apache.ofbiz.product.product.GoodIdentification" join-from-alias="P">
<key-map field-name="productId"/>
<entity-condition>
<econdition field-name="goodIdentificationTypeId" value="NETSUITE_PRODUCT_ID"/>
<date-filter/>
</entity-condition>
</member-entity>
<member-entity entity-alias="OADJ" entity-name="org.apache.ofbiz.order.order.OrderAdjustment" join-from-alias="OI" join-optional="true">
<key-map field-name="orderId"/>
<key-map field-name="orderItemSeqId"/>
<entity-condition>
<econdition field-name="orderAdjustmentTypeId" value="EXT_PROMO_ADJUSTMENT"/>
</entity-condition>
</member-entity>
<alias-all entity-alias="OI"/>
<alias name="NetSuiteProductId" field="idValue" entity-alias="GID"/>
<alias name="DiscountSum" field="amount" entity-alias="OADJ" function="sum"/>
</view-entity>
</entities>