📄 technicaldocs.sgml
字号:
<para>Service <code>getOrgInventoryValue</code> takes organizationPartyId, productId, and returns an inventoryValue, which is the value of the inventory for productId. This is done by using <code>getProductOrgGlAccount</code> to get the INVENTORY GL account and then calculating the sum of all Debit and all Credits to this GL account for the input organizationPartyId. The amount is the debit sum minus the credit sum.</para> <para>Service <code>createProductAverageCost</code> takes organizationPartyId, productId, and averageCost (a double value). First it checks if a current ProductAverageCost entity already exists and expires it if it does. Then, it creates a new ProductAverageCost entity from parameters.</para> <para>Service <code>updateProductAverageCost</code> takes organizationPartyId and productId. It uses getOrgInventoryQuantity and getOrgInventoryValue to calculate the average cost (which is amount divided by quantity) and calls createProductAverageCost to update the ProductAverageCost entity's record of it.</para> <para>Service <code>updateInvoiceAverageCosts</code> takes an invoiceId. If it is a PURCHASE_INVOICE, it will go through each item of the invoice which are of PINV_FPROD_ITEM invoiceItemTypeId (product items) and call updateProductAverageCost for the product on this item. The organizationPartyId is taken from the BILL_TO_CUSTOMER of the invoice. If it is a SALES_INVOICE nothing is done.</para> </chapter> <chapter> <title>LIFO and FIFO Costs</title> <para>Will we need to associate InvoiceItem with InventoryItem (by changing <code>InvoiceServices.java</code>?)</para> <para>Service <code>updateInvoiceInventoryCosts</code> takes the PINV_FPROD_ITEM (purchase product items) invoice items of a PURCHASE_INVOICE and updates the unitCost field of InventoryItem for the items. It does a currency conversion if the currencyUomId of the invoice item is not equal to the baseCurrencyUomId of the PartyAcctgPreference of the BILL_TO_CUSTOMER on the invoice. If the invoice is a SALES_INVOICE it does not do anything.</para> </chapter> <chapter> <title>Reconciliations</title> <para>Reconciliations are recorded in the <code>GlReconciliation</code> and <code>GlReconciliationEntry</code> entities. <code>GlReconciliation</code> records the date of the reconciliation, the final balance, the organization, and the GL account reconciled. <code>GlReconciliationEntry</code> is used to mark which <code>AcctgTransEntry</code> has been reconciled.</para> <para><code>AcctgTransEntry</code> values record whether the particular entry has been reconciled. Initially, they are marked as "not reconciled" (AES_NOT_RECONCILED) When a reconciliation is saved, they are marked "partly reconciled" (AES_PARTLY_RECON) When the entry has been reconciled, it is marked "reconciled" (AES_RECONCILED)</para> <para>Unlike the rest of the application, there is a tight link between the user interface screen and the service for doing reconciliation. This is because reconciliation is very closely tied to user input. A reconciliation is only done for a specific set of entries the user has selected and is not otherwise related to ranges of dates or other selection criteria.</para> <para>The implementation is done with a Javascript-heavy page which allows the user to enter the final balance, check off transaction entries, and track the calculated balance and user-input ending balance. When the amounts agree, a button for "Reconcile" becomes live, and the service <code>reconcileGlAccount</code> is called to record the reconciliation.</para> <para>The service <code>reconcileGlAccount</code> records the glAccountId, organizationPartyId, reconciledDate, and reconciledBalance and the list of AcctgTransEntries which have been reconciled. The latter is passed in as a List of "acctgTransId|acctgTransEntrySeqId" strings, which are parsed, using the "string-list-suffix" attribute of the service definition. <code>reconcileGlAccount</code> will create a new GlReconciliation entity, mark AcctgTransEntry entities as reconciled, and create GlReconciliationEntry entities to record which AcctgTransEntry entities were reconciled during this reconciliation. It uses the create and update services for these entities. It also checks each acctgTransEntry to ensure it has not been reconciled yet. If it has been reconciled, the service returns an error and the transactions are rolled back.</para> </chapter> <chapter> <title>Completing the Accounting Cycle</title> <section> <title>Posting Transactions</title> <para>Service <code>postAcctgTrans</code> takes an acctgTransId and posts it: updates the postedBalance of all GlAccounts involved in the transaction, update the postedDebits and postedCredits of all GlAccountHistory for all the time periods which the transaction date belongs to, and then marks the accounting transaction posted (acctgTrans.isPosted = "Y".) Once a transaction is posted, then the GL account balances have been updated. The GL account balance is updated during all the relevant time periods (year, quarter, month, etc.) If the time period to which a transaction belongs is already closed, the transaction will not be posted.</para> <para>Service <code>postGlJournal</code> takes a glJournalId and posts the accounting transactions associated with this GlJournal entry. This is used for manually created GlJournal entries.</para> <para>Service <code>calculateGlJournalTrialBalance</code> is a helper service which adds up the total debits and credits of the accounting transactions of a GlJournal.</para> <para>To automate posting, <code>postAcctgTrans</code> can be linked to another service (like createAcctgTransAndEntries) in a SECA. Use "synch" if the failure to post should cause the business transaction to fail (this is usually what you want.) Use "asynch" if you want the system to be able to create business transactions even when it is not able to post them to the GL. Link postAcctgTrans to createAcctgTransAndEntries and all your business transactions (invoices, payments, refunds, inventory variances, etc. etc.) will post automatically.</para> </section> <section> <title>Closing an Accounting Period</title> <para>Service <code>closeTimePeriod</code> handles closing of a particular customTimePeriodId for an organizationPartyId. It uses <code>getActualNetIncomeSinceLastClosing</code> to calculate net income since the last closed time period. It will check if the net income needs to be posted to this time period, or if prior closings have already posted the same amount. If it needs to be posted, it will use <code>createAcctgTransAndEntries</code> to debit PROFIT_LOSS_ACCOUNT and credit RETAINED_EARNINGS account for the organization. Note that the posting will use a transaction date immediately before (1 millisecond) the end of the time period. It will then update GlAccountHistory, calculating endingBalance based on period activity. GlAccountHistory ending balances for ASSET, LIABILITY, and EQUITY accounts from the immediately preceding period will be carried forward--added to the ending balance of this period.</para> <para>Service <code>closeAllTimePeriods</code> also takes an organizationPartyId and customTimePeriodId but will close out all time periods which end on the ending date of the customTimePeriodId, in the sequence of DAY, WEEK, MONTH, QUARTER, YEAR. It is very important that this sequence is preserved, as sub-periods must be closed before parent periods are closed.</para> <para>Service <code>resetOrgGlAccountBalances</code> takes an organizationPartyId and customTimePeriodId and will reset the postedBalance of GlAccountOrganization for this GL account of all REVENUE, INCOME, and EXPENSE acount classes. The posted balance is set to the net balance of all transactions after the customTimePeriodId's time period has ended. Otherwise, closing a transaction after its end date has passed will cause the trial balance to be incorrect. This service uses the <code>getIncomeStatementAccountSumsByDate</code> service.</para> <para>In the webapp, only the earliest un-closed time period can be closed. This is to avoid problems of "gaps," where some periods are unclosed when those that come after them are closed.</para> </section> </chapter> <chapter> <title>Generating Financial Statements</title> <section> <title>Income Statements</title> <para>Service <code>getIncomeStatementByTimePeriods</code> takes organizationPartyId, fromTimePeriodId, thruTimePeriodId, glFiscalTypeId and returns a netIncome, a Map of GlAccount and amounts for the CustomTimePeriods starting with startTimePeriodId and ending with endTimePeriodId, a retainedEarningsGlAccount (GenericValue), and an "isClosed" flag. It will make sure those time periods belong to the organization. Note the Map key is the GlAccount GenericEntity not just glAccountId. The amounts are negative for EXPENSE GL accounts and positive for INCOME GL accounts. It calls <code>getIncomeStatementByDates</code> to the work.</para> <para>Service <code>getIncomeStatementByDates</code> takes organizationPartyId, fromDate, thruDate, glFiscalTypeId and returns netIncome, the Map, a retainedEarningsGlAccount (GenericValue), and an isClosed flag. isClosed is set to "N" if there are any unposted transactions during the dates. It calls <code>getAcctgTransAndEntriesByType</code> to look up REVENUE, EXPENSE, or INCOME accounting transaction entries and the <code>addToAccountBalances</code> service to build a Map of GlAccount and balances. Transaction entries from PERIOD_CLOSING transactions are filtered out (Otherwise, we will get double counting of net income. For example, if we are calculating quarterly net income and one or two of the interim months have been closed, then the net income of those sub-periods will be calculated twice.) This service determines whether all the accounting time periods during the date range are closed and returns the "isClosed" flag. retainedEarningsGlAccount is the RETAINED_EARNINGS account of the organization, derived by <code>getOrganizationGlAccount</code>. <emphasis>This has not been implemented correctly yet. See OFBAC-31.</emphasis></para> <para>Service <code>getActualNetIncomeSinceLastClosing</code> takes organizationPartyId, thruDate and returns a netIncome which is the cumulative netIncome of the organization since the end of the last closed accounting period of the periodTypeId. It uses <code>getLastClosedTimePeriod</code> with organizationPartyId to figure out the last closed period. This service uses <code>getIncomeStatementByDates</code> and is used to calculate provisional net income for balance sheets (see below) . <emphasis>Is it necessary to restrain periodTypeId here? Does not seem like it right now, as it seems that it is consistent if we use the last closed time period and calculate net income since then.</emphasis></para> <para>Service <code>addToAccountBalances</code> takes a Map of glAccountSums and a List of AcctgTransAndEntries and updates the balances of each GlAccount in the Map. If an account is not in the Map, it will create a new entry for it.</para> <para>Service <code>getAcctgTransAndEntriesByType</code> takes an organizationPartyId, fromDate, thruDate, glFiscalTypeId, glAccountClasses (List of glAccountClassIds) and returns AcctgTransAndEntries view-entities which satisfy these criteria (ie, is one of the glAccountClassIds supplied.)</para> </section> <section> <title>Balance Sheets</title> <para>Service <code>getBalanceSheetForTimePeriod</code> takes organizationPartyId, customTimePeriodId and returns Maps assetAccountBalances, liabilityAccountBalances, and equityAccountBalances, and an isClosed flag. isClosed is based on whether the time period has closed. It returns the GlAccountHistory of this time period. If the time period has not closed, it will use <code>getActualNetIncomeSinceLastClosing</code> to calculate the net income and add it to the RETAINED_EARNINGS GlAccount of the organization (otherwise, the balance sheet won't balance.)</para> <para>Service <code>getBalanceSheetForDate</code> takes organizationPartyId, date as parameters and returns the same Maps and isClosed flag as <code>getBalanceSheetForTimePeriod</code>. It will find the pervious closed CustomTimePeriod, call <code>getBalanceSheetForTimePeriod</code> to get the separate asset, liability, and equity account balances. It will then use <code>getAcctgTransAndEntriesByType</code> to find all the accounting transaction entries of ASSET, LIABILITY, and EQUITY GL accounts since the ending date of the previous CustomTimePeriod and call <code>addToAccountBalances</code> to add the new transactions to these Maps. Finally, it will call <code>getNetIncomeForDates</code> to derive a net income figure and add it to the RETAINED_EARNINGS account. isClosed is true is true if the previous CustomTimePeriod is closed and all time periods since then til today are closed.</para> <para>Will require implementation of the following two services: <code>getLastClosedTimePeriod</code> for an organizationPartyId which gets the last closed time period, or the earliest beginning date fo a time period. Optionally can filter the list for a periodTypeId (YEAR, QUARTER, MONTH, etc.); and <code>checkInterimPeriodsClosed</code> which will take a fromDate, endDate, organizationPartyId, and see if all the interim time periods between fromDate and endDate are closed.</para> </section> </chapter> <chapter> <title>Integration</title> <section> <title>Exporting</title> <para>Service <code>exportGLToFile</code> is a <code>storeEntitySyncData</code> service, meaning it takes in valuesToCreate, valuesToStore, and valuesToRemove Lists of GenericValues. In this case, it should only have AcctgTrans entities. It will filter out non-posted transactions and then use the template defined in GLExport.properties file to generate output for the outside accounting system. It uses GL account mappings in GLExport.properties to map OFBiz GL accounts to GL accounts of the external system. It relies on the ContentWorker.renderContentAsText method from the content management application to do this. It then writes to the file named in GLExport.properties. <emphasis>This service should only be called from runEntitySync.</emphasis> <emphasis>We may need to immplement some kind of roudning off/dummy account to truncate andd round amounts exported.</emphasis></para> <para /> </section> </chapter></book>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -