svn commit: r605973 - in /ofbiz/trunk/applications/accounting: data/ script/org/ofbiz/accounting/ledger/ servicedef/ webapp/accounting/WEB-INF/ widget/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r605973 - in /ofbiz/trunk/applications/accounting: data/ script/org/ofbiz/accounting/ledger/ servicedef/ webapp/accounting/WEB-INF/ widget/

jacopoc
Author: jacopoc
Date: Thu Dec 20 08:30:30 2007
New Revision: 605973

URL: http://svn.apache.org/viewvc?rev=605973&view=rev
Log:
Very simple (and beta) version of the Income Statement.
OFBIZ-1501

Modified:
    ofbiz/trunk/applications/accounting/data/DemoGlSetupData.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/Menus.xml
    ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryForms.xml
    ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryScreens.xml

Modified: ofbiz/trunk/applications/accounting/data/DemoGlSetupData.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/data/DemoGlSetupData.xml?rev=605973&r1=605972&r2=605973&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/data/DemoGlSetupData.xml (original)
+++ ofbiz/trunk/applications/accounting/data/DemoGlSetupData.xml Thu Dec 20 08:30:30 2007
@@ -261,6 +261,12 @@
     <CreditCardTypeGlAccount organizationPartyId="Company" cardType="CCT_AMERICANEXPRESS" glAccountId="122100"/>
     <CreditCardTypeGlAccount organizationPartyId="Company" cardType="CCT_DINERSCLUB" glAccountId="122100"/>
     <CreditCardTypeGlAccount organizationPartyId="Company" cardType="CCT_DISCOVER" glAccountId="122200"/>
+    <!-- The following ones are required until the issue OFBIZ-1524 is resolved -->
+    <CreditCardTypeGlAccount organizationPartyId="Company" cardType="Visa" glAccountId="122300"/>
+    <CreditCardTypeGlAccount organizationPartyId="Company" cardType="MasterCard" glAccountId="122300"/>
+    <CreditCardTypeGlAccount organizationPartyId="Company" cardType="AmericanExpress" glAccountId="122100"/>
+    <CreditCardTypeGlAccount organizationPartyId="Company" cardType="DinersClub" glAccountId="122100"/>
+    <CreditCardTypeGlAccount organizationPartyId="Company" cardType="Discover" glAccountId="122200"/>
     <!--
     No need to load these if they are set with the 122000 account (the default for the CREDIT_CARD payment method type)
     <CreditCardTypeGlAccount organizationPartyId="Company" cardType="CCT_ENROUTE" glAccountId="122000"/>

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=605973&r1=605972&r2=605973&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 Thu Dec 20 08:30:30 2007
@@ -826,6 +826,103 @@
         <call-service service-name="updateCustomTimePeriod" in-map-name="updateCustomTimePeriodInMap"/>
     </simple-method>
 
+    <simple-method method-name="prepareIncomeStatement" short-description="Close a financial CustomTimePeriod">
+        <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-condition entity-name="AcctgTransAndEntries" list-name="acctgTransAndEntries">
+            <condition-list combine="and">
+                <condition-expr field-name="organizationPartyId" operator="equals" env-name="parameters.organizationPartyId"/>
+                <condition-expr field-name="isPosted" operator="equals" value="Y"/>
+                <condition-expr field-name="glFiscalTypeId" operator="equals" env-name="parameters.glFiscalTypeId"/>
+                <condition-expr field-name="transactionDate" operator="greater-equals" env-name="parameters.fromDate"/>
+                <condition-expr field-name="transactionDate" operator="less" env-name="parameters.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="totalNetIncome" 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="totalNetIncome" type="Double">
+                <calcop field-name="totalNetIncome" operator="add"><calcop field-name="amount" operator="get"/></calcop>
+            </calculate>
+            <if-empty field-name="glAccountTotalsMap.${glAccount.glAccountId}">
+                <set field="glAccountTotalsMap.${glAccount.glAccountId}" value="0.0" type="Double"/>
+            </if-empty>
+            <calculate field-name="glAccountTotalsMap.${glAccount.glAccountId}" type="Double">
+                <calcop field-name="glAccountTotalsMap.${glAccount.glAccountId}" operator="add"><calcop field-name="amount" operator="get"/></calcop>
+            </calculate>
+        </iterate>
+        <iterate-map map-name="glAccountTotalsMap" key-name="glAccountId" value-name="totalAmount">
+            <clear-field field-name="glAccountTotalMap"/>
+            <set field="glAccountTotalMap.glAccountId" from-field="glAccountId"/>
+            <set field="glAccountTotalMap.totalAmount" from-field="totalAmount"/>
+            <set field="glAccountTotalsList[]" from-field="glAccountTotalMap"/>
+        </iterate-map>
+        <set field="orderByList[]" value="glAccountId"/>
+        <order-value-list list-name="glAccountTotalsList" order-by-list-name="orderByList"/>
+
+        <field-to-result field-name="totalNetIncome" result-name="totalNetIncome"/>
+        <field-to-result field-name="glAccountTotalsMap" result-name="glAccountTotalsMap"/>
+        <field-to-result field-name="glAccountTotalsList" result-name="glAccountTotalsList"/>
+    </simple-method>
+
     <!-- Services for the automatic creation of accounting transactions based on business transactions
          Typically, these services are triggered by SECAs -->
 
@@ -884,7 +981,7 @@
         <call-service service-name="createAcctgTransAndEntries" in-map-name="createAcctgTransAndEntriesInMap">
             <result-to-field result-name="acctgTransId"/>
         </call-service>
-        <field-to-result field-name="acctgTransId" result-name="acctgTransId"/>        
+        <field-to-result field-name="acctgTransId" result-name="acctgTransId"/>
     </simple-method>
 
     <simple-method method-name="createAcctgTransForShipmentReceipt" short-description="Create an accounting transactions for a shipment receipt (D: INVENTORY_ACCOUNT, C: UNINVOICED_SHIP_RCPT or COGS_ACCOUNT for returns)">

Modified: ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml?rev=605973&r1=605972&r2=605973&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml (original)
+++ ofbiz/trunk/applications/accounting/servicedef/services_ledger.xml Thu Dec 20 08:30:30 2007
@@ -287,6 +287,18 @@
         <auto-attributes include="pk" mode="IN" optional="false"/>
     </service>
 
+    <service name="prepareIncomeStatement" engine="simple"
+        location="org/ofbiz/accounting/ledger/GeneralLedgerServices.xml" invoke="prepareIncomeStatement" auth="true">
+        <description>Prepare the data for the income statement</description>
+        <attribute name="organizationPartyId" type="String" mode="IN" optional="false"/>
+        <attribute name="fromDate" type="Timestamp" mode="IN" optional="false"/>
+        <attribute name="thruDate" type="Timestamp" mode="IN" optional="false"/>
+        <attribute name="glFiscalTypeId" type="String" mode="IN" optional="false"/>
+        <attribute name="totalNetIncome" type="Double" mode="OUT" optional="false"/>
+        <attribute name="glAccountTotalsMap" type="Map" mode="OUT" optional="true"/>
+        <attribute name="glAccountTotalsList" type="List" mode="OUT" optional="true"/>
+    </service>
+
     <!-- Miscellaneous Ledger-related services -->
     <service name="getGlAccountFromAccountType" engine="simple"
             location="org/ofbiz/accounting/ledger/GeneralLedgerServices.xml" invoke="getGlAccountFromAccountType" auth="true">

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=605973&r1=605972&r2=605973&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/applications/accounting/webapp/accounting/WEB-INF/controller.xml Thu Dec 20 08:30:30 2007
@@ -1673,6 +1673,13 @@
     <request-map uri="FinancialSummaryReportOptions"><security https="true" auth="true"/><response name="success" type="view" value="FinancialSummaryReportOptions"/></request-map>
     <request-map uri="SalesInvoiceByProductCategorySummary"><security https="true" auth="true"/><response name="success" type="view" value="SalesInvoiceByProductCategorySummary"/></request-map>
     <request-map uri="TrialBalance"><security https="true" auth="true"/><response name="success" type="view" value="TrialBalance"/></request-map>
+    <request-map uri="IncomeStatement"><security https="true" auth="true"/><response name="success" type="view" value="IncomeStatement"/></request-map>
+    <request-map uri="prepareIncomeStatement">
+        <security https="true" auth="true"/>
+        <event type="service" invoke="prepareIncomeStatement"/>
+        <response name="success" type="view" value="IncomeStatement"/>
+        <response name="error" type="view" value="IncomeStatement"/>        
+    </request-map>
     <request-map uri="TransactionTotals"><security https="true" auth="true"/><response name="success" type="view" value="TransactionTotals"/></request-map>
     <!-- end of request mappings -->
 
@@ -1859,6 +1866,7 @@
     <view-map name="FinancialSummaryReportOptions" type="screen" page="component://accounting/widget/ReportFinancialSummaryScreens.xml#FinancialSummaryReportOptions"/>
     <view-map name="SalesInvoiceByProductCategorySummary" type="screen" page="component://accounting/widget/ReportFinancialSummaryScreens.xml#SalesInvoiceByProductCategorySummary"/>
     <view-map name="TrialBalance" type="screen" page="component://accounting/widget/ReportFinancialSummaryScreens.xml#TrialBalance"/>
+    <view-map name="IncomeStatement" type="screen" page="component://accounting/widget/ReportFinancialSummaryScreens.xml#IncomeStatement"/>
     <view-map name="TransactionTotals" type="screen" page="component://accounting/widget/ReportFinancialSummaryScreens.xml#TransactionTotals"/>
     
     <!-- Assignment Mappings -->

Modified: ofbiz/trunk/applications/accounting/widget/Menus.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/Menus.xml?rev=605973&r1=605972&r2=605973&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/widget/Menus.xml (original)
+++ ofbiz/trunk/applications/accounting/widget/Menus.xml Thu Dec 20 08:30:30 2007
@@ -442,6 +442,9 @@
         <menu-item name="TrialBalance" title="${uiLabelMap.AccountingTrialBalance}">
             <link target="TrialBalance?organizationPartyId=${organizationPartyId}"/>
         </menu-item>
+        <menu-item name="IncomeStatement" title="${uiLabelMap.AccountingIncomeStatement}">
+            <link target="IncomeStatement?organizationPartyId=${organizationPartyId}"/>
+        </menu-item>
         <menu-item name="TransactionTotals" title="${uiLabelMap.AccountingTransactionTotals}">
             <link target="TransactionTotals?organizationPartyId=${organizationPartyId}"/>
         </menu-item>

Modified: ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryForms.xml?rev=605973&r1=605972&r2=605973&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryForms.xml (original)
+++ ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryForms.xml Thu Dec 20 08:30:30 2007
@@ -93,4 +93,30 @@
         <field name="debit" entry-name="parameters.debitTotal" use-when="showTotals" widget-area-style="viewManyTR1"><display type="currency" currency="${currencyUomId}"/></field>
         <field name="credit" entry-name="creditTotal" use-when="showTotals" widget-area-style="viewManyTR1"><display type="currency" currency="${currencyUomId}"/></field>
     </form>
+
+    <form name="IncomeStatementParameters" type="single" target="prepareIncomeStatement">
+        <field name="organizationPartyId"><hidden/></field>
+        <field name="fromDate"><date-time/></field>
+        <field name="thruDate"><date-time/></field>
+        <field name="glFiscalTypeId">
+            <drop-down>
+                <entity-options entity-name="GlFiscalType" description="${description}">
+                    <entity-order-by field-name="glFiscalTypeId"/>
+                </entity-options>
+            </drop-down>
+        </field>
+        <field name="submitButton" widget-style="smallSubmit"><submit button-type="button"/></field>
+    </form>
+
+    <form name="IncomeStatementList" type="list" list-name="glAccountTotalsList">
+        <row-actions>
+            <entity-one entity-name="GlAccount" value-name="glAccount">
+                <field-map field-name="glAccountId"/>
+            </entity-one>
+        </row-actions>
+        <field name="glAccountId">
+            <hyperlink target="FindAcctgTransEntries?glAccountId=${glAccountId}&amp;organizationPartyId=${organizationPartyId}" description="[${glAccountId}] [${glAccount.accountCode}] ${glAccount.accountName}"/>
+        </field>
+        <field name="totalAmount"><display type="currency" currency="${currencyUomId}"/></field>
+    </form>
 </forms>

Modified: ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryScreens.xml?rev=605973&r1=605972&r2=605973&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryScreens.xml (original)
+++ ofbiz/trunk/applications/accounting/widget/ReportFinancialSummaryScreens.xml Thu Dec 20 08:30:30 2007
@@ -230,6 +230,43 @@
         </section>
     </screen>
 
+    <screen name="IncomeStatement">
+        <section>
+            <actions>
+                <set field="tabButtonItem" value="OrganizationAccountingReports"/>
+                <set field="tabButtonItem2" value="IncomeStatement"/>
+                <set field="organizationPartyId" from-field="parameters.organizationPartyId"/>
+                <set field="organizationPartyId" from-field="parameters.organizationPartyId"/>
+                <entity-one entity-name="PartyAcctgPreference" value-name="partyAcctgPreference" auto-field-map="false">
+                    <field-map field-name="partyId" env-name="organizationPartyId"/>
+                </entity-one>
+                <set field="currencyUomId" from-field="partyAcctgPreference.baseCurrencyUomId"/>
+                <set field="glAccountTotalsList" from-field="parameters.glAccountTotalsList"/>
+            </actions>
+            <widgets>
+                <decorator-screen name="CommonOrganizationAccountingReportsDecorator" location="${parameters.mainDecoratorLocation}">
+                    <decorator-section name="body">
+                        <container>
+                            <label style="head2" text="${uiLabelMap.AccountingIncomeStatement}"/>
+                        </container>
+                        <include-form name="IncomeStatementParameters" location="component://accounting/widget/ReportFinancialSummaryForms.xml"/>
+                        <section>
+                            <condition>
+                                <not><if-empty field-name="parameters.totalNetIncome"/></not>
+                            </condition>
+                            <widgets>
+                                <include-form name="IncomeStatementList" location="component://accounting/widget/ReportFinancialSummaryForms.xml"/>
+                                <container>
+                                    <label style="head3" text="${uiLabelMap.AccountingNetIncome}: ${parameters.totalNetIncome}"/>
+                                </container>
+                            </widgets>
+                        </section>
+                    </decorator-section>
+                </decorator-screen>
+            </widgets>
+        </section>
+    </screen>
+
     <!-- TODO: this is just a placeholder: the report is not still implemented -->
     <screen name="TransactionTotals">
         <section>