Author: jacopoc
Date: Fri Dec 14 02:50:26 2007 New Revision: 604156 URL: http://svn.apache.org/viewvc?rev=604156&view=rev Log: First experimental implementation of the closeFinancialTimePeriod service. OFBIZ-1522 Several misc improvements. Modified: ofbiz/trunk/applications/accounting/data/DemoGlSetupData.xml ofbiz/trunk/applications/accounting/data/DemoOrganizationData.xml ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml ofbiz/trunk/applications/accounting/widget/GlForms.xml ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryForms.xml Modified: ofbiz/trunk/applications/accounting/data/DemoGlSetupData.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/data/DemoGlSetupData.xml?rev=604156&r1=604155&r2=604156&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/data/DemoGlSetupData.xml (original) +++ ofbiz/trunk/applications/accounting/data/DemoGlSetupData.xml Fri Dec 14 02:50:26 2007 @@ -283,4 +283,16 @@ <VarianceReasonGlAccount organizationPartyId="Company" varianceReasonId="VAR_INTEGR" glAccountId="514000"/> <VarianceReasonGlAccount organizationPartyId="Company" varianceReasonId="VAR_SAMPLE" glAccountId="625000"/> + <!-- Some Sample Time Periods, two Years with Quarters --> + <CustomTimePeriod organizationPartyId="Company" customTimePeriodId="6000" periodTypeId="FISCAL_YEAR" fromDate="2007-01-01" thruDate="2008-01-01" isClosed="N" periodNum="5" periodName="2007"/> + <CustomTimePeriod organizationPartyId="Company" customTimePeriodId="6001" periodTypeId="FISCAL_QUARTER" fromDate="2007-01-01" thruDate="2007-04-01" isClosed="N" periodNum="1" periodName="2007/Q1" parentPeriodId="6000"/> + <CustomTimePeriod organizationPartyId="Company" customTimePeriodId="6002" periodTypeId="FISCAL_QUARTER" fromDate="2007-04-01" thruDate="2007-07-01" isClosed="N" periodNum="2" periodName="2007/Q2" parentPeriodId="6000"/> + <CustomTimePeriod organizationPartyId="Company" customTimePeriodId="6003" periodTypeId="FISCAL_QUARTER" fromDate="2007-07-01" thruDate="2007-10-01" isClosed="N" periodNum="3" periodName="2007/Q3" parentPeriodId="6000"/> + <CustomTimePeriod organizationPartyId="Company" customTimePeriodId="6004" periodTypeId="FISCAL_QUARTER" fromDate="2007-10-01" thruDate="2008-01-01" isClosed="N" periodNum="4" periodName="2007/Q4" parentPeriodId="6000"/> + <CustomTimePeriod organizationPartyId="Company" customTimePeriodId="6005" periodTypeId="FISCAL_YEAR" fromDate="2008-01-01" thruDate="2009-01-01" isClosed="N" periodNum="5" periodName="2008"/> + <CustomTimePeriod organizationPartyId="Company" customTimePeriodId="6006" periodTypeId="FISCAL_QUARTER" fromDate="2008-01-01" thruDate="2008-04-01" isClosed="N" periodNum="1" periodName="2008/Q1" parentPeriodId="6005"/> + <CustomTimePeriod organizationPartyId="Company" customTimePeriodId="6007" periodTypeId="FISCAL_QUARTER" fromDate="2008-04-01" thruDate="2008-07-01" isClosed="N" periodNum="2" periodName="2008/Q2" parentPeriodId="6005"/> + <CustomTimePeriod organizationPartyId="Company" customTimePeriodId="6008" periodTypeId="FISCAL_QUARTER" fromDate="2008-07-01" thruDate="2008-10-01" isClosed="N" periodNum="3" periodName="2008/Q3" parentPeriodId="6005"/> + <CustomTimePeriod organizationPartyId="Company" customTimePeriodId="6009" periodTypeId="FISCAL_QUARTER" fromDate="2008-10-01" thruDate="2009-01-01" isClosed="N" periodNum="4" periodName="2008/Q4" parentPeriodId="6005"/> + </entity-engine-xml> Modified: ofbiz/trunk/applications/accounting/data/DemoOrganizationData.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/data/DemoOrganizationData.xml?rev=604156&r1=604155&r2=604156&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/data/DemoOrganizationData.xml (original) +++ ofbiz/trunk/applications/accounting/data/DemoOrganizationData.xml Fri Dec 14 02:50:26 2007 @@ -53,23 +53,4 @@ <PartyGroup partyId="TESTING" groupName="Testing department"/> <PartyRole partyId="TESTING" roleTypeId="INTERNAL_ORGANIZATIO" lastUpdatedStamp="2004-03-27 09:37:41.142" lastUpdatedTxStamp="2004-03-27 09:37:41.142" createdStamp="2004-03-27 09:37:41.142" createdTxStamp="2004-03-27 09:37:41.142"/> - <!-- Some Sample Time Periods, a Year with Quarters and Months --> - <CustomTimePeriod organizationPartyId="Company" periodTypeId="FISCAL_YEAR" fromDate="2007-01-01" thruDate="2008-01-01" isClosed="N" periodNum="2007" periodName="Fiscal Year"/> - <CustomTimePeriod organizationPartyId="Company" periodTypeId="FISCAL_QUARTER" fromDate="2007-01-01" thruDate="2007-04-01" isClosed="N" periodNum="1" periodName="Quarter"/> - <CustomTimePeriod organizationPartyId="Company" periodTypeId="FISCAL_QUARTER" fromDate="2007-04-01" thruDate="2007-07-01" isClosed="N" periodNum="2" periodName="Quarter"/> - <CustomTimePeriod organizationPartyId="Company" periodTypeId="FISCAL_QUARTER" fromDate="2007-07-01" thruDate="2007-10-01" isClosed="N" periodNum="3" periodName="Quarter"/> - <CustomTimePeriod organizationPartyId="Company" periodTypeId="FISCAL_QUARTER" fromDate="2007-10-01" thruDate="2008-01-01" isClosed="N" periodNum="4" periodName="Quarter"/> - <CustomTimePeriod organizationPartyId="Company" periodTypeId="FISCAL_MONTH" fromDate="2007-01-01" thruDate="2007-02-01" isClosed="N" periodNum="1" periodName="Month"/> - <CustomTimePeriod organizationPartyId="Company" periodTypeId="FISCAL_MONTH" fromDate="2007-02-01" thruDate="2007-03-01" isClosed="N" periodNum="2" periodName="Month"/> - <CustomTimePeriod organizationPartyId="Company" periodTypeId="FISCAL_MONTH" fromDate="2007-03-01" thruDate="2007-04-01" isClosed="N" periodNum="3" periodName="Month"/> - <CustomTimePeriod organizationPartyId="Company" periodTypeId="FISCAL_MONTH" fromDate="2007-04-01" thruDate="2007-05-01" isClosed="N" periodNum="4" periodName="Month"/> - <CustomTimePeriod organizationPartyId="Company" periodTypeId="FISCAL_MONTH" fromDate="2007-05-01" thruDate="2007-06-01" isClosed="N" periodNum="5" periodName="Month"/> - <CustomTimePeriod organizationPartyId="Company" periodTypeId="FISCAL_MONTH" fromDate="2007-06-01" thruDate="2007-07-01" isClosed="N" periodNum="6" periodName="Month"/> - <CustomTimePeriod organizationPartyId="Company" periodTypeId="FISCAL_MONTH" fromDate="2007-07-01" thruDate="2007-08-01" isClosed="N" periodNum="7" periodName="Month"/> - <CustomTimePeriod organizationPartyId="Company" periodTypeId="FISCAL_MONTH" fromDate="2007-08-01" thruDate="2007-09-01" isClosed="N" periodNum="8" periodName="Month"/> - <CustomTimePeriod organizationPartyId="Company" periodTypeId="FISCAL_MONTH" fromDate="2007-09-01" thruDate="2007-10-01" isClosed="N" periodNum="9" periodName="Month"/> - <CustomTimePeriod organizationPartyId="Company" periodTypeId="FISCAL_MONTH" fromDate="2007-10-01" thruDate="2007-11-01" isClosed="N" periodNum="10" periodName="Month"/> - <CustomTimePeriod organizationPartyId="Company" periodTypeId="FISCAL_MONTH" fromDate="2007-11-01" thruDate="2007-12-01" isClosed="N" periodNum="11" periodName="Month"/> - <CustomTimePeriod organizationPartyId="Company" periodTypeId="FISCAL_MONTH" fromDate="2007-12-01" thruDate="2008-01-01" isClosed="N" periodNum="12" periodName="Month"/> - </entity-engine-xml> Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml?rev=604156&r1=604155&r2=604156&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml (original) +++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/AcctgTransServices.xml Fri Dec 14 02:50:26 2007 @@ -240,7 +240,10 @@ <!-- DONE with initial tests/checks, see if we are good to go or not... --> <if-compare field-name="parameters.verifyOnly" operator="equals" value="Y"> - <check-errors/> + <if-not-empty field-name="error_list"> + <field-to-result field-name="error_list" result-name="successMessageList"/> + </if-not-empty> + <return/> <else> <!-- if there are errors and we have an error journal assign to the journal and return --> <if-not-empty field-name="error_list"> @@ -254,8 +257,9 @@ <else> <!-- assign the transaction to the error journal --> <set field="acctgTrans.glJournalId" from-field="partyAcctgPreference.errorGlJournalId"/> - <!-- FIXME: we should probably store the journal id in each one of the AcctgTransEntry records--> <store-value value-name="acctgTrans"/> + <set field="warningMessage[]" value="The accounting transaction [${acctgTrans.acctgTransId}] has been posted to the Error Journal [${partyAcctgPreference.errorGlJournalId}]."/> + <field-to-result field-name="warningMessage" result-name="successMessageList"/> <return/> </else> </if-empty> Modified: ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml?rev=604156&r1=604155&r2=604156&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml (original) +++ ofbiz/trunk/applications/accounting/script/org/ofbiz/accounting/ledger/GeneralLedgerServices.xml Fri Dec 14 02:50:26 2007 @@ -532,6 +532,300 @@ </if-empty> </simple-method> + <simple-method method-name="closeFinancialTimePeriod" short-description="Close a financial CustomTimePeriod"> + <entity-one entity-name="CustomTimePeriod" value-name="customTimePeriod"/> + <set field="openTimePeriodCondition.isClosed" value="N"/> + <get-related value-name="customTimePeriod" relation-name="ChildCustomTimePeriod" list-name="openChildTimePeriods" map-name="openTimePeriodCondition"/> + <iterate list-name="openChildTimePeriods" entry-name="openChildTimePeriod"> + <add-error><fail-message message="Cannot close time period [${customTimePeriod.customTimePeriodId}] because the child time period ${openChildTimePeriod.periodName} [${openChildTimePeriod.customTimePeriodId}] is not closed."/></add-error> + </iterate> + <check-errors/> + <!-- retrieve the last closed date for the same type of time period --> + <set field="findLastClosedDateInMap.organizationPartyId" from-field="customTimePeriod.organizationPartyId"/> + <set field="findLastClosedDateInMap.periodTypeId" from-field="customTimePeriod.periodTypeId"/> + <call-service service-name="findLastClosedDate" in-map-name="findLastClosedDateInMap"> + <result-to-field result-name="lastClosedDate"/> + <result-to-field result-name="lastClosedTimePeriod"/> + </call-service> + <if-empty field-name="lastClosedDate"> + <add-error><fail-message message="Unable to find a last closed date for time period [${customTimePeriod.customTimePeriodId}] of type [${customTimePeriod.customTimePeriodId}] for organization [${customTimePeriod.organizationPartyId}]"/></add-error> + </if-empty> + <check-errors/> + <entity-one entity-name="GlAccountClass" value-name="expenseGlAccountClass"> + <field-map field-name="glAccountClassId" value="EXPENSE"/> + </entity-one> + <call-class-method class-name="org.ofbiz.accounting.util.UtilAccounting" method-name="getDescendantGlAccountClassIds" ret-field-name="expenseAccountClassIds"> + <field field-name="expenseGlAccountClass" type="GenericValue"/> + </call-class-method> + <entity-one entity-name="GlAccountClass" value-name="revenueGlAccountClass"> + <field-map field-name="glAccountClassId" value="REVENUE"/> + </entity-one> + <call-class-method class-name="org.ofbiz.accounting.util.UtilAccounting" method-name="getDescendantGlAccountClassIds" ret-field-name="revenueAccountClassIds"> + <field field-name="revenueGlAccountClass" type="GenericValue"/> + </call-class-method> + <entity-one entity-name="GlAccountClass" value-name="incomeGlAccountClass"> + <field-map field-name="glAccountClassId" value="INCOME"/> + </entity-one> + <call-class-method class-name="org.ofbiz.accounting.util.UtilAccounting" method-name="getDescendantGlAccountClassIds" ret-field-name="incomeAccountClassIds"> + <field field-name="incomeGlAccountClass" type="GenericValue"/> + </call-class-method> + <entity-one entity-name="GlAccountClass" value-name="assetGlAccountClass"> + <field-map field-name="glAccountClassId" value="ASSET"/> + </entity-one> + <call-class-method class-name="org.ofbiz.accounting.util.UtilAccounting" method-name="getDescendantGlAccountClassIds" ret-field-name="assetAccountClassIds"> + <field field-name="assetGlAccountClass" type="GenericValue"/> + </call-class-method> + <entity-one entity-name="GlAccountClass" value-name="liabilityGlAccountClass"> + <field-map field-name="glAccountClassId" value="LIABILITY"/> + </entity-one> + <call-class-method class-name="org.ofbiz.accounting.util.UtilAccounting" method-name="getDescendantGlAccountClassIds" ret-field-name="liabilityAccountClassIds"> + <field field-name="liabilityGlAccountClass" type="GenericValue"/> + </call-class-method> + <entity-one entity-name="GlAccountClass" value-name="equityGlAccountClass"> + <field-map field-name="glAccountClassId" value="EQUITY"/> + </entity-one> + <call-class-method class-name="org.ofbiz.accounting.util.UtilAccounting" method-name="getDescendantGlAccountClassIds" ret-field-name="equityAccountClassIds"> + <field field-name="equityGlAccountClass" type="GenericValue"/> + </call-class-method> + + <!-- Compute the total posted amount of the period --> + <entity-condition entity-name="AcctgTransAndEntries" list-name="acctgTransAndEntries"> + <condition-list combine="and"> + <condition-expr field-name="organizationPartyId" operator="equals" env-name="customTimePeriod.organizationPartyId"/> + <condition-expr field-name="isPosted" operator="equals" value="Y"/> + <condition-expr field-name="glFiscalTypeId" operator="equals" value="ACTUAL"/> + <condition-expr field-name="transactionDate" operator="greater-equals" env-name="lastClosedDate"/> + <condition-expr field-name="transactionDate" operator="less" env-name="customTimePeriod.thruDate"/> <!-- FIXME: Date to Timestamp --> + <condition-expr field-name="acctgTransTypeId" operator="not-equals" value="PERIOD_CLOSING"/> + <condition-list combine="or"> + <condition-expr field-name="glAccountClassId" operator="in" env-name="expenseAccountClassIds"/> + <condition-expr field-name="glAccountClassId" operator="in" env-name="revenueAccountClassIds"/> + <condition-expr field-name="glAccountClassId" operator="in" env-name="incomeAccountClassIds"/> + </condition-list> + </condition-list> + <order-by field-name="acctgTransId"/> + <order-by field-name="acctgTransEntrySeqId"/> + </entity-condition> + <set field="totalAmount" value="0.0" type="Double"/> + <iterate list-name="acctgTransAndEntries" entry-name="acctgTransAndEntry"> + <get-related-one value-name="acctgTransAndEntry" relation-name="GlAccount" to-value-name="glAccount"/> + <call-class-method class-name="org.ofbiz.accounting.util.UtilAccounting" method-name="isCreditAccount" ret-field-name="isCreditAccount"> + <field field-name="glAccount" type="GenericValue"/> + </call-class-method> + <call-class-method class-name="org.ofbiz.accounting.util.UtilAccounting" method-name="isDebitAccount" ret-field-name="isDebitAccount"> + <field field-name="glAccount" type="GenericValue"/> + </call-class-method> + <call-class-method class-name="org.ofbiz.accounting.util.UtilAccounting" method-name="isExpenseAccount" ret-field-name="isExpenseAccount"> + <field field-name="glAccount" type="GenericValue"/> + </call-class-method> + <set field="amount" from-field="acctgTransAndEntry.amount" type="Double"/> + <if> + <condition> + <or> + <and> + <if-compare field-name="acctgTransAndEntry.debitCreditFlag" operator="equals" value="D"/> + <if-compare field-name="isCreditAccount" operator="equals" value="true" type="Boolean"/> + </and> + <and> + <if-compare field-name="acctgTransAndEntry.debitCreditFlag" operator="equals" value="C"/> + <if-compare field-name="isDebitAccount" operator="equals" value="true" type="Boolean"/> + </and> + </or> + </condition> + <then> + <calculate field-name="amount"> + <calcop field-name="amount" operator="negative"/> + </calculate> + </then> + </if> + <if-compare field-name="isExpenseAccount" operator="equals" value="true" type="Boolean"> + <calculate field-name="amount"> + <calcop field-name="amount" operator="negative"/> + </calculate> + </if-compare> + <calculate field-name="totalAmount" type="Double"> + <calcop field-name="totalAmount" operator="add"><calcop field-name="amount" operator="get"/></calcop> + </calculate> + </iterate> + <entity-one entity-name="PartyAcctgPreference" value-name="partyAcctgPreference" use-cache="true" auto-field-map="false"> + <field-map field-name="partyId" env-name="customTimePeriod.organizationPartyId"/> + </entity-one> + <!-- get the profit and loss gl account id --> + <entity-one entity-name="GlAccountTypeDefault" value-name="profitLossAccount" use-cache="true"> + <field-map field-name="organizationPartyId" env-name="customTimePeriod.organizationPartyId"/> + <field-map field-name="glAccountTypeId" value="PROFIT_LOSS_ACCOUNT"/> + </entity-one> + <entity-one entity-name="GlAccountHistory" value-name="profitLossAccountHistory"> + <field-map field-name="organizationPartyId" env-name="customTimePeriod.organizationPartyId"/> + <field-map field-name="customTimePeriodId" env-name="customTimePeriod.customTimePeriodId"/> + <field-map field-name="glAccountId" env-name="profitLossAccount.glAccountId"/> + </entity-one> + <if-not-empty field-name="profitLossAccountHistory"> + <!-- already posted: verify if numbers match --> + <call-class-method class-name="org.ofbiz.accounting.util.UtilAccounting" method-name="getNetBalance" ret-field-name="postedBalance"> + <field field-name="profitLossAccountHistory" type="GenericValue"/> + </call-class-method> + <if-compare-field field-name="postedBalance" operator="not-equals" to-field-name="totalAmount" type="Double"> + <add-error><fail-message message="There is already a posted balance [${postedBalance}] that doesn't match with the current one [${totalAmount}]."/></add-error> + </if-compare-field> + <check-errors/> + <else> + <make-value entity-name="AcctgTransEntry" value-name="creditEntry"/> + <set field="creditEntry.debitCreditFlag" value="C"/> + <set field="creditEntry.glAccountTypeId" value="RETAINED_EARNINGS"/> + <set field="creditEntry.organizationPartyId" from-field="customTimePeriod.organizationPartyId"/> + <set field="creditEntry.origAmount" from-field="totalAmount"/> + <set field="creditEntry.origCurrencyUomId" from-field="partyAcctgPreference.baseCurrencyUomId"/> + <set field="acctgTransEntries[]" from-field="creditEntry" type="Object"/> + <make-value entity-name="AcctgTransEntry" value-name="debitEntry"/> + <set field="debitEntry.debitCreditFlag" value="D"/> + <set field="debitEntry.glAccountTypeId" value="PROFIT_LOSS_ACCOUNT"/> + <set field="debitEntry.organizationPartyId" from-field="customTimePeriod.organizationPartyId"/> + <set field="debitEntry.origAmount" from-field="totalAmount"/> + <set field="debitEntry.origCurrencyUomId" from-field="partyAcctgPreference.baseCurrencyUomId"/> + <set field="acctgTransEntries[]" from-field="debitEntry" type="Object"/> + + <set field="createAcctgTransAndEntriesInMap.glFiscalTypeId" value="ACTUAL"/> + <set field="createAcctgTransAndEntriesInMap.acctgTransTypeId" value="PERIOD_CLOSING"/> + <set field="createAcctgTransAndEntriesInMap.transactionDate" from-field="customTimePeriod.thruDate"/> <!-- FIXME --> + <set field="createAcctgTransAndEntriesInMap.acctgTransEntries" from-field="acctgTransEntries"/> + <call-service service-name="createAcctgTransAndEntries" in-map-name="createAcctgTransAndEntriesInMap"> + <result-to-field result-name="acctgTransId"/> + </call-service> + </else> + </if-not-empty> + <entity-and entity-name="GlAccountHistory" list-name="glAccountHistories"> + <field-map field-name="organizationPartyId" env-name="customTimePeriod.organizationPartyId"/> + <field-map field-name="customTimePeriodId" env-name="customTimePeriod.customTimePeriodId"/> + </entity-and> + <iterate list-name="glAccountHistories" entry-name="glAccountHistory"> + <call-class-method class-name="org.ofbiz.accounting.util.UtilAccounting" method-name="getNetBalance" ret-field-name="endingBalance"> + <field field-name="glAccountHistory" type="GenericValue"/> + </call-class-method> + <set field="glAccountHistory.endingBalance" from-field="endingBalance" type="Double"/> + <store-value value-name="glAccountHistory"/> + </iterate> + <if-not-empty field-name="lastClosedTimePeriod"> + <entity-condition entity-name="GlAccountAndHistory" list-name="lastPeriodGlAccountAndHistories"> + <condition-list combine="and"> + <condition-expr field-name="organizationPartyId" operator="equals" env-name="customTimePeriod.organizationPartyId"/> + <condition-expr field-name="customTimePeriodId" operator="equals" env-name="lastClosedTimePeriod.customTimePeriodId"/> + <condition-list combine="or"> + <condition-expr field-name="glAccountClassId" operator="in" env-name="assetAccountClassIds"/> + <condition-expr field-name="glAccountClassId" operator="in" env-name="liabilityAccountClassIds"/> + <condition-expr field-name="glAccountClassId" operator="in" env-name="equityAccountClassIds"/> + </condition-list> + </condition-list> + <order-by field-name="glAccountId"/> + </entity-condition> + <iterate list-name="lastPeriodGlAccountAndHistories" entry-name="lastPeriodGlAccountAndHistory"> + <get-related-one value-name="lastPeriodGlAccountAndHistory" relation-name="GlAccountHistory" to-value-name="lastPeriodGlAccountHistory"/> + <entity-one entity-name="GlAccountHistory" value-name="thisPeriodGlAccountHistory" auto-field-map="false"> + <field-map field-name="organizationPartyId" env-name="customTimePeriod.organizationPartyId"/> + <field-map field-name="customTimePeriodId" env-name="customTimePeriod.customTimePeriodId"/> + <field-map field-name="glAccountId" env-name="lastPeriodGlAccountHistory.glAccountId"/> + </entity-one> + <if-empty field-name="thisPeriodGlAccountHistory"> + <make-value entity-name="GlAccountHistory" value-name="thisPeriodGlAccountHistory"/> + <set field="thisPeriodGlAccountHistory.customTimePeriodId" from-field="customTimePeriod.customTimePeriodId"/> + <set field="thisPeriodGlAccountHistory.organizationPartyId" from-field="customTimePeriod.organizationPartyId"/> + <set field="thisPeriodGlAccountHistory.glAccountId" from-field="lastPeriodGlAccountHistory.glAccountId"/> + <set field="thisPeriodGlAccountHistory.postedDebits" value="0.0" type="Double"/> + <set field="thisPeriodGlAccountHistory.postedCredits" value="0.0" type="Double"/> + <set field="thisPeriodGlAccountHistory.endingBalance" from-field="lastPeriodGlAccountHistory.endingBalance" type="Double"/> + <create-value value-name="thisPeriodGlAccountHistory"/> + <else> + <calculate field-name="thisPeriodGlAccountHistory.endingBalance" type="Double"> + <calcop field-name="thisPeriodGlAccountHistory.endingBalance" operator="add"><calcop field-name="lastPeriodGlAccountHistory.endingBalance" operator="get"/></calcop> + </calculate> + <store-value value-name="thisPeriodGlAccountHistory"/> + </else> + </if-empty> + </iterate> + </if-not-empty> + + <!-- Initialize the accounts for the new fiscal period --> + <entity-condition entity-name="GlAccountOrganizationAndClass" list-name="glAccountOrganizationAndClassList"> + <condition-list combine="and"> + <condition-expr field-name="organizationPartyId" operator="equals" env-name="customTimePeriod.organizationPartyId"/> + <condition-expr field-name="postedBalance" operator="not-equals" value="0.0"/> + <condition-list combine="or"> + <condition-expr field-name="glAccountClassId" operator="in" env-name="expenseAccountClassIds"/> + <condition-expr field-name="glAccountClassId" operator="in" env-name="revenueAccountClassIds"/> + <condition-expr field-name="glAccountClassId" operator="in" env-name="incomeAccountClassIds"/> + </condition-list> + </condition-list> + </entity-condition> + <now-timestamp-to-env env-name="nowTimestamp"/> + <iterate list-name="glAccountOrganizationAndClassList" entry-name="glAccountOrganizationAndClass"> + <entity-condition entity-name="AcctgTransAndEntries" list-name="acctgTransAndEntries"> + <condition-list combine="and"> + <condition-expr field-name="organizationPartyId" operator="equals" env-name="customTimePeriod.organizationPartyId"/> + <condition-expr field-name="glAccountId" operator="equals" env-name="glAccountOrganizationAndClass.glAccountId"/> + <condition-expr field-name="isPosted" operator="equals" value="Y"/> + <condition-expr field-name="glFiscalTypeId" operator="equals" value="ACTUAL"/> + <condition-expr field-name="transactionDate" operator="greater-equals" env-name="customTimePeriod.thruDate"/> <!-- FIXME: Date to Timestamp --> + <condition-expr field-name="transactionDate" operator="less" env-name="nowTimestamp"/> + <condition-expr field-name="acctgTransTypeId" operator="not-equals" value="PERIOD_CLOSING"/> + </condition-list> + <order-by field-name="acctgTransId"/> + <order-by field-name="acctgTransEntrySeqId"/> + </entity-condition> + + <set field="newPostedBalance" value="0.0" type="Double"/> + <iterate list-name="acctgTransAndEntries" entry-name="acctgTransAndEntry"> + <get-related-one value-name="acctgTransAndEntry" relation-name="GlAccount" to-value-name="glAccount"/> + <call-class-method class-name="org.ofbiz.accounting.util.UtilAccounting" method-name="isCreditAccount" ret-field-name="isCreditAccount"> + <field field-name="glAccount" type="GenericValue"/> + </call-class-method> + <call-class-method class-name="org.ofbiz.accounting.util.UtilAccounting" method-name="isDebitAccount" ret-field-name="isDebitAccount"> + <field field-name="glAccount" type="GenericValue"/> + </call-class-method> + <call-class-method class-name="org.ofbiz.accounting.util.UtilAccounting" method-name="isExpenseAccount" ret-field-name="isExpenseAccount"> + <field field-name="glAccount" type="GenericValue"/> + </call-class-method> + <set field="amount" from-field="acctgTransAndEntry.amount" type="Double"/> + <if> + <condition> + <or> + <and> + <if-compare field-name="acctgTransAndEntry.debitCreditFlag" operator="equals" value="D"/> + <if-compare field-name="isCreditAccount" operator="equals" value="true" type="Boolean"/> + </and> + <and> + <if-compare field-name="acctgTransAndEntry.debitCreditFlag" operator="equals" value="C"/> + <if-compare field-name="isDebitAccount" operator="equals" value="true" type="Boolean"/> + </and> + </or> + </condition> + <then> + <calculate field-name="amount"> + <calcop field-name="amount" operator="negative"/> + </calculate> + </then> + </if> + <if-compare field-name="isExpenseAccount" operator="equals" value="true" type="Boolean"> + <calculate field-name="amount"> + <calcop field-name="amount" operator="negative"/> + </calculate> + </if-compare> + <calculate field-name="newPostedBalance" type="Double"> + <calcop field-name="newPostedBalance" operator="add"><calcop field-name="amount" operator="get"/></calcop> + </calculate> + </iterate> + + <set field="updateGlAccountOrganizationInMap.organizationPartyId" from-field="customTimePeriod.organizationPartyId"/> + <set field="updateGlAccountOrganizationInMap.glAccountId" from-field="glAccountOrganizationAndClass.glAccountId"/> + <set field="updateGlAccountOrganizationInMap.postedBalance" from-field="newPostedBalance" type="Double"/> + <call-service service-name="updateGlAccountOrganization" in-map-name="updateGlAccountOrganizationInMap"/> + </iterate> + + <set field="updateCustomTimePeriodInMap.customTimePeriodId" from-field="customTimePeriod.customTimePeriodId"/> + <set field="updateCustomTimePeriodInMap.organizationPartyId" from-field="customTimePeriod.organizationPartyId"/> + <set field="updateCustomTimePeriodInMap.isClosed" value="Y"/> + <call-service service-name="updateCustomTimePeriod" in-map-name="updateCustomTimePeriodInMap"/> + </simple-method> + <!-- Services for the automatic creation of accounting transactions based on business transactions Typically, these services are triggered by SECAs --> Modified: ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml?rev=604156&r1=604155&r2=604156&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml (original) +++ ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml Fri Dec 14 02:50:26 2007 @@ -280,6 +280,12 @@ <attribute name="verifyOnly" type="String" mode="IN" optional="true"/> </service> + <service name="closeFinancialTimePeriod" default-entity-name="CustomTimePeriod" engine="simple" + location="org/ofbiz/accounting/ledger/GeneralLedgerServices.xml" invoke="closeFinancialTimePeriod" auth="true"> + <description>Close a financial time period</description> + <auto-attributes include="pk" mode="IN" optional="false"/> + </service> + <!-- Miscellaneous Ledger-related services --> <service name="getGlAccountFromAccountType" engine="simple" location="org/ofbiz/accounting/ledger/GeneralLedgerServices.xml" invoke="getGlAccountFromAccountType" auth="true"> @@ -378,7 +384,7 @@ <attribute name="inventoryItemId" type="String" mode="IN" optional="false"/> <attribute name="acctgTransId" type="String" mode="OUT" optional="true"/> </service> -<!-- Service for the automatic creation of AcctgTransForPhysicalInventoryVariance, triggered by SECAs --> + <!-- Service for the automatic creation of AcctgTransForPhysicalInventoryVariance, triggered by SECAs --> <service name="createAcctgTransForPhysicalInventoryVariance" engine="simple" location="org/ofbiz/accounting/ledger/GeneralLedgerServices.xml" invoke="createAcctgTransForPhysicalInventoryVariance"> <description>Create an AcctgEntry for Physical Inventory variance</description> Modified: ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml?rev=604156&r1=604155&r2=604156&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml (original) +++ ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml Fri Dec 14 02:50:26 2007 @@ -1149,6 +1149,12 @@ <response name="success" type="view" value="TimePeriods"/> <response name="error" type="view" value="TimePeriods"/> </request-map> + <request-map uri="closeFinancialTimePeriod"> + <security https="true" auth="true"/> + <event type="service" invoke="closeFinancialTimePeriod"/> + <response name="success" type="view" value="TimePeriods"/> + <response name="error" type="view" value="TimePeriods"/> + </request-map> <request-map uri="PartyAcctgPreference"> <security https="true" auth="true"/> <response name="success" type="view" value="PartyAcctgPreference"/> Modified: ofbiz/trunk/applications/accounting/widget/GlForms.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/GlForms.xml?rev=604156&r1=604155&r2=604156&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/widget/GlForms.xml (original) +++ ofbiz/trunk/applications/accounting/widget/GlForms.xml Fri Dec 14 02:50:26 2007 @@ -465,7 +465,7 @@ <field name="acctgTransId"><hidden/></field> <field name="acctgTransEntrySeqId"><display/></field> <field name="glAccountId"> - <drop-down> + <drop-down allow-empty="true"> <entity-options entity-name="GlAccountOrganizationAndClass" key-field-name="glAccountId" description="${accountName} [${glAccountId}]"> <entity-constraint name="organizationPartyId" operator="equals" env-name="parameters.organizationPartyId"/> <entity-order-by field-name="description"/> @@ -473,7 +473,7 @@ </drop-down> </field> <field name="acctgTransEntryTypeId" title="${uiLabelMap.AccountingTransactionEntryType}"> - <drop-down> + <drop-down allow-empty="true"> <entity-options entity-name="AcctgTransEntryType" description="${description}"> <entity-order-by field-name="acctgTransEntryTypeId"/> </entity-options> Modified: ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryForms.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryForms.xml?rev=604156&r1=604155&r2=604156&view=diff ============================================================================== --- ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryForms.xml (original) +++ ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryForms.xml Fri Dec 14 02:50:26 2007 @@ -73,9 +73,9 @@ <entity-one entity-name="GlAccount" value-name="glAccount"> <field-map field-name="glAccountId"/> </entity-one> - <set field="showDebit" value="${bsh:(postedBalance > 0 && org.ofbiz.accounting.util.UtilAccounting.isDebitAccount(glAccount)) || (postedBalance < 0 && org.ofbiz.accounting.util.UtilAccounting.isCreditAccount(glAccount))}" type="Boolean"/> - <set field="showCredit" value="${bsh:(postedBalance > 0 && org.ofbiz.accounting.util.UtilAccounting.isCreditAccount(glAccount)) || (postedBalance < 0 && org.ofbiz.accounting.util.UtilAccounting.isDebitAccount(glAccount))}" type="Boolean"/> - <set field="absolutePostedBalance" value="${bsh:(postedBalance > 0? postedBalance: (-1)*postedBalance)}" type="Double"/> + <set field="showDebit" value="${bsh:(postedBalance >= 0 && org.ofbiz.accounting.util.UtilAccounting.isDebitAccount(glAccount)) || (postedBalance < 0 && org.ofbiz.accounting.util.UtilAccounting.isCreditAccount(glAccount))}" type="Boolean"/> + <set field="showCredit" value="${bsh:(postedBalance >= 0 && org.ofbiz.accounting.util.UtilAccounting.isCreditAccount(glAccount)) || (postedBalance < 0 && org.ofbiz.accounting.util.UtilAccounting.isDebitAccount(glAccount))}" type="Boolean"/> + <set field="absolutePostedBalance" value="${bsh:(postedBalance >= 0? postedBalance: (-1)*postedBalance)}" type="Double"/> <set field="showTotals" value="${bsh:(isLastRow != null && isLastRow==true)}" type="Boolean"/> <set field="debitTotal" from-field="parameters.debitTotal" type="Double"/> <set field="creditTotal" from-field="parameters.creditTotal" type="Double"/> |
Free forum by Nabble | Edit this page |