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

Commit

Permalink
improved opoortunity view, fix opportunity test error
Browse files Browse the repository at this point in the history
  • Loading branch information
hansbak committed Dec 16, 2022
1 parent 7b19569 commit 366e7e9
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 21 deletions.
49 changes: 41 additions & 8 deletions entity/GrowerpViewEntities.xml
Original file line number Diff line number Diff line change
Expand Up @@ -877,26 +877,59 @@ along with this software (see the LICENSE.md file). If not, see
<view-entity entity-name="OpportunityAndParties" package="growerp.crm">
<member-entity entity-alias="OPPOR"
entity-name="mantle.sales.opportunity.SalesOpportunity"/>
<member-entity entity-alias="ACCNTPERSON" entity-name="mantle.party.Person"
join-from-alias="OPPOR" join-optional="true">
<key-map field-name="accountPartyId" related="partyId"/></member-entity>
<member-entity entity-alias="TOACCNTCOMPANY" entity-name="mantle.party.PartyRelationship"
join-from-alias="ACCNTPERSON" join-optional="true">
<key-map field-name="partyId" related="fromPartyId"/>
<entity-condition>
<econdition field-name="relationshipTypeEnumId" value="PrtEmployee"/>
<date-filter/></entity-condition></member-entity>
<member-entity entity-alias="ACCNTCOMPANY" entity-name="mantle.party.Organization"
join-from-alias="TOACCNTCOMPANY" join-optional="true">
<key-map field-name="toPartyId" related="partyId"/>
</member-entity>
<member-entity entity-alias="SOPPARTY"
entity-name="mantle.sales.opportunity.SalesOpportunityParty"
join-from-alias="OPPOR" join-optional="true">
<key-map field-name="salesOpportunityId"/>
</member-entity>
<alias name="opportunityId" field="salesOpportunityId"
entity-alias="OPPOR"/>
<member-entity entity-alias="LEADPERSON" entity-name="mantle.party.Person"
join-from-alias="SOPPARTY" join-optional="true">
<key-map field-name="partyId"/></member-entity>
<member-entity entity-alias="TOLEADCOMPANY" entity-name="mantle.party.PartyRelationship"
join-from-alias="LEADPERSON" join-optional="true">
<key-map field-name="partyId" related="fromPartyId"/>
<entity-condition>
<econdition field-name="relationshipTypeEnumId" value="PrtEmployee"/>
<date-filter/></entity-condition></member-entity>
<member-entity entity-alias="LEADCOMPANY" entity-name="mantle.party.Organization"
join-from-alias="TOLEADCOMPANY" join-optional="true">
<key-map field-name="toPartyId" related="partyId"/>
</member-entity>

<alias name="opportunityId" field="salesOpportunityId" entity-alias="OPPOR"/>
<alias name="ownerPartyId" entity-alias="OPPOR"/>
<alias name="opportunityName" entity-alias="OPPOR"/>
<alias name="description" entity-alias="OPPOR"/>
<alias name="nextStep" entity-alias="OPPOR"/>
<alias name="lastUpdatedStamp" entity-alias="OPPOR"/>
<alias name="estAmount" field="estimatedAmount" entity-alias="OPPOR"/>
<alias name="estProbability" field="estimatedProbability"
entity-alias="OPPOR"/>
<alias name="estProbability" field="estimatedProbability" entity-alias="OPPOR"/>
<alias name="stageId" field="opportunityStageId" entity-alias="OPPOR"/>
<alias name="accountPartyId" entity-alias="OPPOR"/>
<alias name="fromDate" entity-alias="SOPPARTY"></alias>
<alias name="thruDate" entity-alias="SOPPARTY"></alias>
<alias name="leadPartyId" field="partyId" entity-alias="SOPPARTY"/>
<alias name="accntUserPartyId" field="accountPartyId" entity-alias="OPPOR"/>
<alias name="accntFirstName" field="firstName" entity-alias="ACCNTPERSON"/>
<alias name="accntLastName" field="lastName" entity-alias="ACCNTPERSON"/>
<alias name="accntCompanyPartyId" field="partyId" entity-alias="ACCNTCOMPANY"/>
<alias name="accntCompanyName" field="organizationName" entity-alias="ACCNTCOMPANY"/>
<alias name="fromDate" entity-alias="SOPPARTY"/>
<alias name="thruDate" entity-alias="SOPPARTY"/>
<alias name="leadUserPartyId" field="partyId" entity-alias="LEADPERSON"/>
<alias name="leadFirstName" field="firstName" entity-alias="LEADPERSON"/>
<alias name="leadLastName" field="lastName" entity-alias="LEADPERSON"/>
<alias name="leadCompanyPartyId" field="partyId" entity-alias="LEADCOMPANY"/>
<alias name="leadCompanyName" field="organizationName" entity-alias="LEADCOMPANY"/>
<entity-condition><date-filter/></entity-condition>
</view-entity>

Expand Down
1 change: 0 additions & 1 deletion service/growerp/100/CatgProdServices100.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ along with this software (see the LICENSE.md file). If not, see
<econdition field-name="ownerPartyId" from="companyPartyId"/>
<econdition field-name="productCategoryTypeEnumId" value="PctRoot"/>
</entity-find>
<log message="===looking for product"/>
<entity-find offset="start" limit="limit*5"
entity-name="growerp.mobile.product.ProductAndCategoryAndPrices"
list="productList">
Expand Down
24 changes: 15 additions & 9 deletions service/growerp/100/CrmServices100.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ along with this software (see the LICENSE.md file). If not, see
<set field="notDisplayStatus" from="['Deleted']"/></if>
<entity-find list="opps" offset="start" limit="limit"
entity-name="growerp.crm.OpportunityAndParties">
<econdition field-name="ownerPartyId" ignore-if-empty="true"/>
<econdition field-name="ownerPartyId" from="companyPartyId"/>
<econdition field-name="opportunityId" ignore-if-empty="true"/>
<econdition field-name="accountPartyId" ignore-if-empty="true"/>
<econdition field-name="stageId" operator="not-in"
Expand All @@ -107,10 +107,16 @@ along with this software (see the LICENSE.md file). If not, see
<if condition="!opportunityId">
<set field="opportunities" from="[]"/></if>
<iterate list="opps" entry="opp">
<service-call name="growerp.100.PartyServices100.get#User"
in-map="[userPartyId: opp.accountPartyId]" out-map="employee"/>
<service-call name="growerp.100.PartyServices100.get#User"
in-map="[userPartyId: opp.leadPartyId]" out-map="lead"/>
<set field="employeeUser" from="[partyId: opp.accntUserPartyId,
firstName: opp.accntFirstName,
lastName: opp.accntLastName,
companyPartyId: opp.accntCompanyPartyId,
companyName: opp.accntCompanyName]"/>
<set field="leadUser" from="[partyId: opp.leadUserPartyId,
firstName: opp.leadFirstName,
lastName: opp.leadLastName,
companyPartyId: opp.leadCompanyPartyId,
companyName: opp.leadCompanyName]"/>
<set field="opOut" from="[
opportunityId: opp.opportunityId,
lastUpdated: opp.lastUpdatedStamp
Expand All @@ -121,9 +127,9 @@ along with this software (see the LICENSE.md file). If not, see
description: opp.description,
nextStep: opp.nextStep,
estAmount: opp.estAmount?.toString(),
estProbability: opp.estProbability,
employeeUser: employee.user,
leadUser: lead.user]"/>
estProbability: opp.estProbability.toString(),
employeeUser: employeeUser,
leadUser: leadUser]"/>
<if condition="!opportunityId">
<script>opportunities.add(opOut)</script>
<else>
Expand Down Expand Up @@ -305,7 +311,7 @@ along with this software (see the LICENSE.md file). If not, see
<if condition="!oldValues &amp;&amp; opportunity.leadUser">
<service-call name="create#mantle.sales.opportunity.SalesOpportunityParty"
in-map="[salesOpportunityId: opportunity.opportunityId,
partyId: opportunity.leadUser?.partyId,
partyId: opportunity.leadUser?.companyPartyId,
roleTypeId: 'Customer',
fromDate: ec.user.nowTimestamp]" out-map="context"/>
</if>
Expand Down
17 changes: 14 additions & 3 deletions service/growerp/100/PartyServices100.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2294,6 +2294,8 @@ along with this software (see the LICENSE.md file). If not, see
</if>

<!-- users -->
<set field="dbLeads" from="[]"/>
<set field="dbEmployees" from="[]"/>
<iterate list="users" entry="us">
<set field="userIn" from="[
firstName: us.firstName,
Expand All @@ -2304,12 +2306,21 @@ along with this software (see the LICENSE.md file). If not, see
userGroupId: us.userGroupId, companyName: us.companyName,
]"/>
<service-call name="growerp.100.PartyServices100.create#User"
in-map="[user: userIn]" out-map="context"/>
in-map="[user: userIn]" out-map="outMap"/>
<script>
if(us.userGroupId == 'GROWERP_M_EMPLOYEE') dbEmployees.add(outMap)
if(us.userGroupId == 'GROWERP_M_LEAD') dbLeads.add(outMap)
</script>
</iterate>


<!-- opportunities -->
<set field="index" value="0" type="Integer"/>
<iterate list="opportunities" entry="opp">
<set field="employeeUser" from="[partyId: index%2 == 0
? dbEmployees[0].user.partyId : dbEmployees[1].user.partyId]"/>
<set field="leadUser" from="[partyId: index%2 == 0
? dbLeads[0].user.partyId : dbLeads[1].user.partyId]"/>
<set field="oppIn" from="[
opportunityName: opp.opportunityName,
description: opp.description,
Expand All @@ -2318,8 +2329,8 @@ along with this software (see the LICENSE.md file). If not, see
estProbability: opp.estProbability,
opportunityStageId: opp.opportunityStageId,
ownerPartyId: companyPartyId,
accountPartyId: index%2 == 0? userPartyId: employeeUser1,
leadPartyId: index%2 == 0 ? leadUser1 : leadUser2
employeeUser: employeeUser,
leadUser: leadUser
]"/>
<service-call name="growerp.100.CrmServices100.create#Opportunity"
in-map="[opportunity: oppIn]" out-map="context"/>
Expand Down

0 comments on commit 366e7e9

Please sign in to comment.