Skip to content
This repository has been archived by the owner on Jun 16, 2023. It is now read-only.

Commit

Permalink
V 0.9.1: merge of development branch: separate user and company
Browse files Browse the repository at this point in the history
  • Loading branch information
hansbak committed Mar 22, 2023
1 parent f77099d commit 2365bbf
Show file tree
Hide file tree
Showing 8 changed files with 472 additions and 360 deletions.
189 changes: 42 additions & 147 deletions entity/GrowerpViewEntities.xml

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions service/growerp.rest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ along with this software (see the LICENSE.md file). If not, see
<method type="post"><service name="growerp.100.WebsiteServices100.upload#WebsiteContent"/></method></resource>
<resource name="Obsidian">
<method type="post"><service name="growerp.100.WebsiteServices100.upload#Obsidian"/></method></resource>
<!-- import JSON -->
<resource name="Entities">
<method type="post"><service name="growerp.100.ImportExportServices100.import#Entities"/></method></resource>
<!-- export via email -->
<resource name="ImportExport">
<resource name="Categories">
Expand Down
124 changes: 83 additions & 41 deletions service/growerp/100/CatgProdServices100.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ along with this software (see the LICENSE.md file). If not, see
<entity-find entity-name="mantle.party.Organization" list="parties" limit="1">
<order-by field-name="partyId"/></entity-find>
<set field="companyPartyId" from="parties[0].partyId"/>
<log message="Using first allocated companyPartyId"/></if>
</if>
<if condition="categoryId == '###first one###'">
<!-- for ecommerce startup we only need products in the first alphabetical category
but do not know which one that is -->
Expand Down Expand Up @@ -241,12 +241,16 @@ along with this software (see the LICENSE.md file). If not, see
<parameter name="categories" type="List">
<parameter name="category" type="Map">
<parameter name="categoryId"/>
<parameter name="categoryName"/>
<parameter name="description"/>
<parameter name="image"/>
</parameter>
</parameter>
<parameter name="useWarehouse" type="Boolean"/>
<parameter name="assetCount"/>
<parameter name="image"/>
</parameter>
<parameter name="classificationId" required="true"/>
</in-parameters>
<out-parameters>
<parameter name="product" type="Map">
Expand All @@ -266,7 +270,6 @@ along with this software (see the LICENSE.md file). If not, see
<parameter name="useWarehouse" type="Boolean"/>
<parameter name="assetCount"/>
<parameter name="image"/>

</parameter>
</out-parameters>
<actions>
Expand Down Expand Up @@ -309,37 +312,31 @@ along with this software (see the LICENSE.md file). If not, see
]"/>
<!-- related categories -->
<if condition="product.categories">
<set field="productCategories" from="product.categories"/>
<else><!-- empty -->
<set field="productCategories" from="[]"/>
</else>
<iterate list="product.categories" entry="productCategory">
<!-- add if no id's but have name-->
<if condition="!productCategory.categoryId &amp;&amp; productCategory.categoryName">
<service-call name="growerp.100.CatgProdServices100.create#ProductCategory"
in-map="[category: productCategory, classificationId: classificationId]"
out-map="categoryResult"/>
<set field="productCategory.categoryId" from="categoryResult.category.categoryId"/>
</if>
<!-- add to category member -->
<service-call name="create#mantle.product.category.ProductCategoryMember"
in-map="[ productId: productId,
productCategoryId: productCategory.categoryId,
fromDate: ec.user.nowTimestamp]"/>
</iterate>
</if>
<!-- always connect product to category allProducts -->
<entity-find entity-name="mantle.product.category.ProductCategory" list="catgs">
<econdition field-name="ownerPartyId" from="companyPartyId"/>
<econdition field-name="productCategoryTypeEnumId" value="PctRoot"/>
</entity-find>
<script>productCategories.add([categoryId: catgs[0].productCategoryId])</script>
<!-- add as members -->
<iterate list="productCategories" entry="productCategory">
<!-- if no id present, get it via the name -->
<if condition="!productCategory.categoryId">
<entity-find entity-name="mantle.product.category.ProductCategory" list="catgNames">
<econdition field-name="ownerPartyId" from="companyPartyId"/>
<econdition field-name="categoryName" from="productCategory.categoryName"/>
</entity-find>
<if condition="catgNames">
<set field="productCategory.categoryId" from="catgNames[0].productCategoryId"/>
<else>
<continue/><!-- ignore when not found -->
</else>
</if>
</if>
<service-call name="create#mantle.product.category.ProductCategoryMember"
in-map="[productCategoryId: productCategory.categoryId,
productId: productId,
fromDate: ec.user.nowTimestamp]"/>
</iterate>
<!-- add allProducts to category member -->
<service-call name="create#mantle.product.category.ProductCategoryMember"
in-map="[ productId: productId,
productCategoryId: catgs[0].productCategoryId,
fromDate: ec.user.nowTimestamp]"/>
<!-- asset count -->
<if condition="product.assetCount != null &amp;&amp; Integer.parseInt(product.assetCount) > 0">
<set field="newProduct" from="[productId: productId]"/>
Expand Down Expand Up @@ -429,24 +426,41 @@ along with this software (see the LICENSE.md file). If not, see
<set field="oldProduct.productTypeEnumId" from="prodConvert.convertedStatusId"/>
<set field="oldProduct.requireInventory" from="requireInventory"/>
<entity-update value-field="oldProduct"/></if>
<!-- price -->
<!-- prices -->
<entity-find-one value-field="pref"
entity-name="mantle.ledger.config.PartyAcctgPreference">
<field-map field-name="organizationPartyId" from="companyPartyId"/>
</entity-find-one>
<set field="priceMap" from="[productId: product.productId,
priceTypeEnumId: 'PptCurrent',
priceUomId: pref.baseCurrencyUomId,
price: product.price,
quantityUomId: 'OTH_ea',
fromDate: ec.user.nowTimestamp,
pricePurposeEnumId: 'PppPurchase']"/>
<entity-find entity-name="growerp.mobile.product.ProductAndPrices"
list="productPrices">
<econdition field-name="productId" from="product.productId"/>
<econdition field-name="ownerPartyId" from="companyPartyId"/>
</entity-find>
<if condition="productPrices[0].price != product.price">
<if condition="productPrices &amp;&amp; productPrices[0].price != product.price">
<!-- existing current price -->
<entity-find-one value-field="productPrice"
entity-name="mantle.product.ProductPrice" for-update="true">
<field-map field-name="productPriceId"
from="productPrices[0].productPriceId"/></entity-find-one>
<set field="productPrice.thruDate" from="ec.user.nowTimestamp"/>
<entity-update value-field="productPrice"/>
<service-call name="create#mantle.product.ProductPrice"
in-map=" productPrice + [ productPriceId: null,
price: product.price,
thruDate: null]"/></if>
<if condition="productPrices[0].listPrice != product.listPrice">
entity-name="mantle.product.ProductPrice" for-update="true">
<field-map field-name="productPriceId"
from="productPrices[0].productPriceId"/></entity-find-one>
<set field="productPrice.thruDate" from="ec.user.nowTimestamp"/>
<entity-update value-field="productPrice"/>
<service-call name="create#mantle.product.ProductPrice"
in-map=" productPrice + [ productPriceId: null,
price: product.price,
thruDate: null]"/>
</if>
<if condition="!productPrices &amp;&amp; product.price">
<service-call name="create#mantle.product.ProductPrice"
in-map="priceMap"/></if>
<if condition="productPrices &amp;&amp; productPrices[0].listPrice != product.listPrice">
<!-- existing list price -->
<entity-find-one value-field="listProductPrice"
entity-name="mantle.product.ProductPrice" for-update="true">
<field-map field-name="productPriceId"
Expand All @@ -457,6 +471,11 @@ along with this software (see the LICENSE.md file). If not, see
in-map=" listProductPrice + [ productPriceId: null,
price: product.listPrice,
thruDate: null]"/></if>
<if condition="!productPrices &amp;&amp; product.listPrice">
<service-call name="create#mantle.product.ProductPrice"
in-map="priceMap + [priceTypeEnumId: 'PptList',
price: product.listPrice,
]"/></if>
<!-- get root catg -->
<entity-find entity-name="mantle.product.category.ProductCategory" list="catgs">
<econdition field-name="ownerPartyId" from="companyPartyId"/>
Expand Down Expand Up @@ -687,6 +706,23 @@ along with this software (see the LICENSE.md file). If not, see
<parameter name="expectedEndOfLifeDate"/>
<parameter name="product" type="Map">
<parameter name="productId"/>
<parameter name="productTypeId"/>
<parameter name="assetClassId" default-value="Hotel Room"/>
<parameter name="productName"/>
<parameter name="description"/>
<parameter name="price"/>
<parameter name="listPrice"/>
<parameter name="categories" type="List">
<parameter name="category" type="Map">
<parameter name="categoryId"/>
<parameter name="categoryName"/>
<parameter name="description"/>
<parameter name="image"/>
</parameter>
</parameter>
<parameter name="useWarehouse" type="Boolean"/>
<parameter name="assetCount"/>
<parameter name="image"/>
</parameter>
</parameter>
</in-parameters>
Expand Down Expand Up @@ -719,6 +755,12 @@ along with this software (see the LICENSE.md file). If not, see
<econdition field-name="organizationPartyId" from="companyPartyId"/>
<econdition field-name="storeDomain" from="classificationId"/>
</entity-find>
<if condition="!asset.product?.productId &amp;&amp; asset.product?.productName">
<service-call name="growerp.100.CatgProdServices100.create#Product"
in-map="[classificationId: classificationId, product: asset.product]"
out-map="productResult"/>
<set field="asset.product.productId" from="productResult.product.productId"/>
</if>
<service-call name="create#mantle.product.asset.Asset"
in-map="[
classEnumId: assetClass.convertedStatusId,
Expand Down Expand Up @@ -884,7 +926,7 @@ along with this software (see the LICENSE.md file). If not, see
<entity-find entity-name="mantle.party.Organization" list="parties" limit="1">
<order-by field-name="partyId"/></entity-find>
<set field="companyPartyId" from="parties[0].partyId"/>
<log message="Using first allocated companyPartyId"/></if>
</if>
<!-- root category -->
<entity-find entity-name="mantle.product.category.ProductCategory" list="rootList">
<econdition field-name="productCategoryTypeEnumId" value="PctRoot"/>
Expand Down Expand Up @@ -1030,7 +1072,7 @@ along with this software (see the LICENSE.md file). If not, see
productCategoryId: productCategoryId]"/>
</if>
<!-- image -->
<if condition="category.image">
<if condition="category.image != null">
<service-call name="growerp.100.ImageServices100.upload#Image"
in-map="[type: 'category',
id: productCategoryId, base64: category.image]"/>
Expand Down
18 changes: 12 additions & 6 deletions service/growerp/100/GeneralServices100.xml
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,10 @@ along with this software (see the LICENSE.md file). If not, see
<parameter name="name"/>
<parameter name="role"/>
<parameter name="email"/>
<parameter name="currencyId"/>
<parameter name="currencyName"/>
<parameter name="currency" type="Map">
<parameter name="currencyId"/>
<parameter name="description"/>
</parameter>
<parameter name="vatPerc">
<description>Percentage used for VAT if applicable</description></parameter>
<parameter name="salesPerc">
Expand Down Expand Up @@ -453,8 +455,10 @@ along with this software (see the LICENSE.md file). If not, see
<parameter name="name"/>
<parameter name="role"/>
<parameter name="email"/>
<parameter name="currencyId"/>
<parameter name="currencyName"/>
<parameter name="currency" type="Map">
<parameter name="currencyId"/>
<parameter name="description"/>
</parameter>
<parameter name="vatPerc">
<description>Percentage used for VAT if applicable</description></parameter>
<parameter name="salesPerc">
Expand Down Expand Up @@ -596,8 +600,10 @@ along with this software (see the LICENSE.md file). If not, see
<parameter name="name"/>
<parameter name="role"/>
<parameter name="email"/>
<parameter name="currencyId"/>
<parameter name="currencyName"/>
<parameter name="currency" type="Map">
<parameter name="currencyId"/>
<parameter name="description"/>
</parameter>
<parameter name="vatPerc">
<description>Percentage used for VAT if applicable</description></parameter>
<parameter name="salesPerc">
Expand Down
50 changes: 50 additions & 0 deletions service/growerp/100/ImportExportServices100.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,56 @@ along with this software (see the LICENSE.md file). If not, see
-->
<services xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/service-definition-2.1.xsd">

<service verb="import" noun="Entities">
<description> Import general entities</description>
<in-parameters>
<parameter name="entities" required="true" type="Map"/>
<parameter name="classificationId" required="true"/>
</in-parameters>
<actions>
<service-call name="growerp.100.GeneralServices100.get#RelatedCompanyAndOwner"
out-map="relComp"/>
<if condition="entities.companies">
<iterate list="entities.companies" entry="company">
<if condition="company.partyId == '_MOD_'">
<entity-find entity-name="growerp.party.OwnerCompanyDetailAndEmployee" list="parties">
<econdition field-name="ownerPartyId" from="relComp.ownerPartyId"/>
<econdition field-name="companyName" operator="like" value="${company.name}%"/>
</entity-find>
<if condition="parties">
<set field="company.partyId" from="parties[0].companyPartyId"/>
<service-call name="growerp.100.PartyServices100.update#Company"
in-map="[company: company]"/>
</if>
<else>
<service-call name="growerp.100.PartyServices100.create#Company"
in-map="[company: company]"/>
</else>
</if>
</iterate></if>
<if condition="entities.users">
<iterate list="entities.users" entry="user">
<service-call name="growerp.100.PartyServices100.create#User"
in-map="[user: user]"/>
</iterate></if>
<if condition="entities.categories">
<iterate list="entities.categories" entry="category">
<service-call name="growerp.100.CatgProdServices100.create#ProductCategory"
in-map="[category: category, classificationId: classificationId]"/>
</iterate></if>
<if condition="entities.products">
<iterate list="entities.products" entry="product">
<service-call name="growerp.100.CatgProdServices100.create#Product"
in-map="[product: product, classificationId: classificationId]"/>
</iterate></if>
<if condition="entities.assets">
<iterate list="entities.assets" entry="asset">
<service-call name="growerp.100.CatgProdServices100.create#Asset"
in-map="[asset: asset, classificationId: classificationId]"/>
</iterate></if>
</actions>
</service>

<service verb="export" noun="Categories">
<description>
send categories csv file
Expand Down
Loading

0 comments on commit 2365bbf

Please sign in to comment.