Skip to content

Commit

Permalink
Merge pull request #50 from sssonline/master
Browse files Browse the repository at this point in the history
2016-11-23
  • Loading branch information
jonesde authored Nov 24, 2016
2 parents b639409 + 7999cfd commit 7931e4a
Show file tree
Hide file tree
Showing 3 changed files with 177 additions and 1 deletion.
10 changes: 10 additions & 0 deletions entity/AccountingOtherViewEntities.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ along with this software (see the LICENSE.md file). If not, see
<alias-all entity-alias="BDGT"/>
<alias-all entity-alias="TMPD"/>
</view-entity>
<view-entity entity-name="BudgetItemAndDetail" package="mantle.other.budget">
<member-entity entity-alias="BIT" entity-name="mantle.other.budget.BudgetItem"/>
<member-entity entity-alias="BIDET" entity-name="mantle.other.budget.BudgetItemDetail">
<key-map field-name="budgetId"/><key-map field-name="budgetItemSeqId"/></member-entity>
<alias-all entity-alias="BIT"><exclude field="amount"/><exclude field="productId"/><exclude field="quantity"/></alias-all>
<alias-all entity-alias="BIDET"/>
<alias name="itemAmount" entity-alias="BIT" field="amount"/>
<alias name="itemProductId" entity-alias="BIT" field="productId"/>
<alias name="itemQuantity" entity-alias="BIT" field="quantity"/>
</view-entity>

<!-- ========================================================= -->
<!-- mantle.other.tax -->
Expand Down
166 changes: 166 additions & 0 deletions service/mantle/other/BudgetServices.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,75 @@ along with this software (see the LICENSE.md file). If not, see
</else-if></if>
</actions>
</service>
<service verb="store" noun="BudgetItemsSubPeriods">
<in-parameters>
<parameter name="budgetId" required="true"/>
<parameter name="glAccountId" required="true"/>
<parameter name="amountMain" type="BigDecimal"/>
<parameter name="amountPer1" type="BigDecimal"/><parameter name="amountPer2" type="BigDecimal"/><parameter name="amountPer3" type="BigDecimal"/>
<parameter name="amountPer4" type="BigDecimal"/><parameter name="amountPer5" type="BigDecimal"/><parameter name="amountPer6" type="BigDecimal"/>
<parameter name="amountPer7" type="BigDecimal"/><parameter name="amountPer8" type="BigDecimal"/><parameter name="amountPer9" type="BigDecimal"/>
<parameter name="amountPer10" type="BigDecimal"/><parameter name="amountPer11" type="BigDecimal"/><parameter name="amountPer12" type="BigDecimal"/>
</in-parameters>
<actions>
<entity-find-one entity-name="mantle.other.budget.Budget" value-field="budget"/>
<if condition="!budget.timePeriodId || !budget.subTimePeriodTypeId">
<return error="true" message="Budget must have a Time Period and a Sub-Period Type"/></if>

<entity-find entity-name="mantle.other.budget.BudgetItem" list="budgetItemList">
<econdition field-name="budgetId"/><econdition field-name="glAccountId"/></entity-find>

<service-call name="mantle.party.TimeServices.get#DescendantPeriods" out-map="subPeriodOut"
in-map="[parentPeriodId:budget.timePeriodId, timePeriodTypeId:budget.subTimePeriodTypeId, createMissing:true]"/>
<set field="subTimePeriodList" from="subPeriodOut.timePeriodList"/>
<set field="subTimePeriodIds" from="new ArrayList(subTimePeriodList*.timePeriodId)"/>

<set field="subAmountTotal" from="0.0"/>
<iterate list="subTimePeriodIds" entry="subTimePeriodId">
<set field="budgetItems" from="budgetItemList.findAll({ it.subTimePeriodId == subTimePeriodId })"/>
<while condition="budgetItems.size() &gt; 1">
<set field="delBudgetItem" from="budgetItems.remove(0)"/>
<entity-delete value-field="delBudgetItem"/>
</while>
<set field="budgetItem" from="budgetItems ? budgetItems.get(0) : null"/>
<set field="budgetItemSeqId" from="budgetItem?.budgetItemSeqId"/>
<set field="amount" from="context.get('amountPer' + (subTimePeriodId_index + 1))"/>
<if condition="amount != null"><then>
<set field="subAmountTotal" from="subAmountTotal + amount"/>
<if condition="budgetItem != null"><then>
<set field="budgetItem.amount" from="amount"/>
<entity-update value-field="budgetItem"/>
</then><else>
<service-call name="create#mantle.other.budget.BudgetItem" in-map="context"/>
</else></if>
</then><else-if condition="budgetItemSeqId">
<service-call name="delete#mantle.other.budget.BudgetItem" in-map="context"/>
</else-if></if>
</iterate>

<set field="subTimePeriodId" from="null"/>
<set field="budgetItems" from="budgetItemList.findAll({ it.subTimePeriodId == null })"/>
<while condition="budgetItems.size() &gt; 1">
<set field="delBudgetItem" from="budgetItems.remove(0)"/>
<entity-delete value-field="delBudgetItem"/>
</while>
<set field="budgetItem" from="budgetItems ? budgetItems.get(0) : null"/>
<set field="budgetItemSeqId" from="budgetItem?.budgetItemSeqId"/>
<set field="amountMain" from="amountMain ?: subAmountTotal ?: null"/>
<if condition="amountMain != null"><then>
<set field="amount" from="amountMain"/>
<if condition="budgetItem != null"><then>
<set field="budgetItem.amount" from="amount"/>
<entity-update value-field="budgetItem"/>
</then><else>
<service-call name="create#mantle.other.budget.BudgetItem" in-map="context"/>
</else></if>
</then><else-if condition="budgetItemSeqId">
<service-call name="delete#mantle.other.budget.BudgetItem" in-map="context"/>
</else-if></if>
</actions>
</service>

<service verb="store" noun="BudgetItemDetail">
<in-parameters>
<parameter name="budgetItemDetailId"/>
Expand All @@ -155,4 +224,101 @@ along with this software (see the LICENSE.md file). If not, see
</else-if></if>
</actions>
</service>
<service verb="store" noun="BudgetItemDetailsSubPeriods">
<in-parameters>
<parameter name="budgetId" required="true"/>
<parameter name="glAccountId" required="true"/>
<parameter name="assetId"><description>Must pass assetId or facilityId</description></parameter>
<parameter name="facilityId"/>
<parameter name="amountMain" type="BigDecimal"/>
<parameter name="amountPer1" type="BigDecimal"/><parameter name="amountPer2" type="BigDecimal"/><parameter name="amountPer3" type="BigDecimal"/>
<parameter name="amountPer4" type="BigDecimal"/><parameter name="amountPer5" type="BigDecimal"/><parameter name="amountPer6" type="BigDecimal"/>
<parameter name="amountPer7" type="BigDecimal"/><parameter name="amountPer8" type="BigDecimal"/><parameter name="amountPer9" type="BigDecimal"/>
<parameter name="amountPer10" type="BigDecimal"/><parameter name="amountPer11" type="BigDecimal"/><parameter name="amountPer12" type="BigDecimal"/>
</in-parameters>
<actions>
<if condition="!assetId &amp;&amp; !facilityId"><return message="Not storing budget item details, no assetId or facilityId specified"/></if>

<entity-find-one entity-name="mantle.other.budget.Budget" value-field="budget"/>
<if condition="!budget.timePeriodId || !budget.subTimePeriodTypeId">
<return error="true" message="Budget must have a Time Period and a Sub-Period Type"/></if>

<entity-find entity-name="mantle.other.budget.BudgetItem" list="budgetItemList">
<econdition field-name="budgetId"/><econdition field-name="glAccountId"/></entity-find>
<set field="budgetItemSeqIds" from="budgetItemList*.budgetItemSeqId"/>

<entity-find entity-name="mantle.other.budget.BudgetItemDetail" list="budgetItemDetailList">
<econdition field-name="budgetId"/><econdition field-name="budgetItemSeqId" operator="in" from="budgetItemSeqIds"/>
<econdition field-name="assetId" ignore-if-empty="true"/>
<econdition field-name="facilityId" ignore-if-empty="true"/>
</entity-find>

<service-call name="mantle.party.TimeServices.get#DescendantPeriods" out-map="subPeriodOut"
in-map="[parentPeriodId:budget.timePeriodId, timePeriodTypeId:budget.subTimePeriodTypeId, createMissing:true]"/>
<set field="subTimePeriodList" from="subPeriodOut.timePeriodList"/>
<set field="subTimePeriodIds" from="new ArrayList(subTimePeriodList*.timePeriodId)"/>

<set field="subAmountTotal" from="0.0"/>
<iterate list="subTimePeriodIds" entry="subTimePeriodId">
<set field="budgetItem" from="budgetItemList.find({ it.subTimePeriodId == subTimePeriodId })"/>
<set field="budgetItemSeqId" from="budgetItem?.budgetItemSeqId"/>
<set field="amount" from="context.get('amountPer' + (subTimePeriodId_index + 1))"/>

<if condition="budgetItemSeqId"><then>
<set field="budgetItemDetail" from="budgetItemDetailList.find({ it.budgetItemSeqId == budgetItemSeqId })"/>
<set field="budgetItemDetailId" from="budgetItemDetail?.budgetItemDetailId"/>

<if condition="amount != null"><then>
<set field="subAmountTotal" from="subAmountTotal + amount"/>
<if condition="budgetItemDetail != null"><then>
<set field="budgetItemDetail.amount" from="amount"/>
<entity-update value-field="budgetItemDetail"/>
</then><else>
<service-call name="create#mantle.other.budget.BudgetItemDetail" in-map="context"/>
</else></if>
</then><else-if condition="budgetItemDetailId">
<service-call name="delete#mantle.other.budget.BudgetItemDetail" in-map="context"/>
</else-if></if>
</then><else-if condition="amount != null">
<service-call name="create#mantle.other.budget.BudgetItem" out-map="budgetItemOut" out-map-add-to-existing="false"
in-map="[budgetId:budgetId, glAccountId:glAccountId, subTimePeriodId:subTimePeriodId, amount:amount]"/>
<set field="budgetItemSeqId" from="budgetItemOut.budgetItemSeqId"/>
<set field="budgetItemDetailId" from="null"/>
<service-call name="create#mantle.other.budget.BudgetItemDetail" in-map="context"/>
</else-if></if>
</iterate>

<set field="subTimePeriodId" from="null"/>
<set field="budgetItems" from="budgetItemList.findAll({ it.subTimePeriodId == null })"/>
<while condition="budgetItems.size() &gt; 1">
<set field="delBudgetItem" from="budgetItems.remove(0)"/>
<entity-delete value-field="delBudgetItem"/>
</while>
<set field="budgetItem" from="budgetItems ? budgetItems.get(0) : null"/>
<set field="budgetItemSeqId" from="budgetItem?.budgetItemSeqId"/>
<set field="amount" from="amountMain ?: subAmountTotal ?: null"/>

<if condition="budgetItemSeqId"><then>
<set field="budgetItemDetail" from="budgetItemDetailList.find({ it.budgetItemSeqId == budgetItemSeqId })"/>
<set field="budgetItemDetailId" from="budgetItemDetail?.budgetItemDetailId"/>

<if condition="amount != null"><then>
<set field="subAmountTotal" from="subAmountTotal + amount"/>
<if condition="budgetItemDetail != null"><then>
<set field="budgetItemDetail.amount" from="amount"/>
<entity-update value-field="budgetItemDetail"/>
</then><else>
<service-call name="create#mantle.other.budget.BudgetItemDetail" in-map="context"/>
</else></if>
</then><else-if condition="budgetItemDetailId">
<service-call name="delete#mantle.other.budget.BudgetItemDetail" in-map="context"/>
</else-if></if>
</then><else-if condition="amount != null">
<service-call name="create#mantle.other.budget.BudgetItem" out-map="budgetItemOut" out-map-add-to-existing="false"
in-map="[budgetId:budgetId, glAccountId:glAccountId, subTimePeriodId:subTimePeriodId]"/>
<set field="budgetItemSeqId" from="budgetItemOut.budgetItemSeqId"/>
<service-call name="create#mantle.other.budget.BudgetItemDetail" in-map="context"/>
</else-if></if>
</actions>
</service>
</services>
2 changes: 1 addition & 1 deletion service/mantle/party/TimeServices.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ along with this software (see the LICENSE.md file). If not, see
<if condition="createMissing"><entity-find-one entity-name="mantle.party.time.TimePeriod" value-field="parentPeriod">
<field-map field-name="timePeriodId" from="parentPeriodId"/></entity-find-one></if>

<set field="timePeriodList" from="[]"/>
<set field="timePeriodList" from="new ArrayList()"/>
<entity-find entity-name="mantle.party.time.TimePeriod" list="childPeriodList">
<econdition field-name="parentPeriodId"/><order-by field-name="thruDate"/></entity-find>
<if condition="createMissing">
Expand Down

0 comments on commit 7931e4a

Please sign in to comment.