📄 technicaldocs.sgml
字号:
<?xml version='1.0'?><!-- * Copyright (C) 2006 Open Source Strategies, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA--><!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" "http://www.oasis-open.org/docbook/xml/4.3b2/docbookx.dtd"><book> <title>Accounting/GL Technical Documentation</title> <chapter> <title>Introduction</title> <para>This document contains information on the technical implementation of the accounting/GL component. It describes the entities and services used to impelement features in the User Docs.</para> </chapter> <chapter> <title>Creating Accounting Transactions</title> <section> <title>Introduction</title> <para>This section describes the key business transactions and how accounting transactions are created for them.</para> </section> <section> <title>Manual Accounting Transactions</title> <para>The simplest accounting transactions are created manually. This is done with the createGlJournalEntry service, which takes in debitGlAccountId, creditGlAccountId, amount, and optional fields from AcctgTrans and AcctgTransEntry entities. It calls the createAcctgTrans and createAcctgTransEntry services to create the accounting transactions. The result is an acctgTransId of the master AcctgTrans created. At this point, all AcctgTransEntry records are created with acctgTransEntryTypeId of _NA_ (the only type available.)</para> </section> <section> <title>Helper Classes and Services</title> <para> createAcctgTransAndEntries is a helper service. It takes a List of acctgTransEntry values and: <orderedlist> <listitem> <para>If any acctgTransEntry record has a negative amount, it changes the amount to positive and flips the debitCreditFlag from "D" to "C" or "C" to "D".</para> </listitem> <listitem><para>If an entry does not have a reconciled status, its sets it to a default of "not reconciled."</para></listitem> <listitem> <para>It checks that the sum of all debit amounts equals the sum of all credit amounts. If these sums do not equal, it aborts with an error message.</para> </listitem> <listitem> <para>It creates an AcctgTrans around the List of acctgTransEntry values using the createAcctgTrans service.</para> </listitem> <listitem> <para>It creates an AcctgTransEntry based on each acctgTransEntry value and the AcctgTrans created.</para> </listitem> </orderedlist> </para> <para>UtilAccounting is a class which isolates tasks such as determining whether an account is an asset, liability, or equity, income, revenue, or expense, debit or credt account and whether a payment is a disbursement or receipt. It uses recursion to trace up a parent types.</para> </section> <section> <title>Invoices</title> <para> Invoices are posted to the accounting transactions using the <code>postInvoiceToGl</code> service, which works for both SALES_INVOICE and PURCHASE_INVOICE types. The only parameter is invoiceId. The service does the following: <orderedlist> <listitem> <para>organizationPartyId is the partyId of the internal organization (ie, our company) in the transaction. This is the partyId from InvoiceRole, where roleTypeId is "BILL_FROM_VENDOR" for SALES_INVOICEs and "BILL_TO_CUSTOMER" for PURCHASE_INVOICEs.</para> </listitem> <listitem> <para>partyId is for the external party of the transaction (ie, our customer or vendor.) This is the partyId from InvoiceRole as well, but where roleTypeId is "BILL_TO_CUSTOMER" for SALES_INVOICEs and "BILL_FROM_VENDOR" for PURCHASE_INVOICEs. One exception is if the invoice has a taxAuthPartyId, in which case the taxAuthPartyId is the partyId of the transaction entry.</para> </listitem> <listitem> <para>each line item of the invoice (ie, each InvoiceItem value) is posted to the invoice on a GL account. The default debitCreditFlag is "C" for SALES_INVOICEs and "D" for PURCHASE_INVOICEs.</para> </listitem> <listitem> <para>if the currencyUomId of the InvoiceItem does not equal the baseCurrencyUomId of PartyAcctgPreference for organizationPartyId, the convertUom service is used to conver the amount of the InvoiceItem to an amount in the baseCurrencyUomId of the PartyAcctgPreference.</para> </listitem> <listitem> <para> for each invoice item, the GL account is determined in the following sequence: <orderedlist> <listitem> <para>InvoiceItem's overrideGlAccount field</para> </listitem> <listitem> <para>If the InvoiceItem is for a product, look for the product's ProductGlAccount of "SALES" type for SALES_INVOICEs and "UNINVOICED_SHIP_RCPT" type for PURCHASE_INVOICEs.</para> </listitem> <listitem> <para>If it is a purchase invoice and there is a difference between invoice amount and the original purchase order price, record the difference as a debit to the PURCHASE_PRICE_VAR account.</para> </listitem> <listitem> <para>from the invoiceItemTypeId, the InvoiceItemTypeGlAccount for this organization</para> </listitem> <listitem> <para>from the invoiceItemTypeId, the defaultGlAccount in InvoiceItem entity.</para> </listitem> </orderedlist> </para> </listitem> <listitem> <para> if the invoice is a SALES invoice, then: <orderedlist> <listitem> <para>call the getInvoiceItemCOGS service with parameter organizationPartyId, invoiceId, invoiceItemSeqId (from the invoice) and use the result COGS parameter as the value of COGS.</para> </listitem> <listitem> <para>use <code>getProductOrgGlAccount</code> to get GL account of the "COGS" type. This is the debit GL account.</para> </listitem> <listitem> <para>use <code>getProductOrgGlAccount</code> to get GL account of the "INVENTORY" type. This is the credit GL account.</para> </listitem> <listitem> <para>debit the COGS GL account and credit the INVENTORY GL account in the amount from COGS above.</para> </listitem> </orderedlist> </para> </listitem> <listitem> <para>actual posting is performed with createAcctgTransAndEntries service (see above.)</para> </listitem> </orderedlist> </para> <para>The service <code>getProductOrgGlAccount</code> takes parameters productId, productGlAccountTypeId, organizationPartyId, glAccountTypeId ("SALES", "INVENTORY", "COGS"), returns a glAccountId. It looks first in ProductGlAccount (based on productId, productGlAccountTypeId) and then in GlAccountTypeDefault (based on organizationPartyId and glAccountTypeId.)</para> <para>The service <code>getInvoiceItemCOGS</code> takes parameters organizationPartyId, invoiceId, invoiceItemSeqId and returns a double called "COGS." It checks the PartyAcctgPreference for organizationPartyId and finds out what the organization's COGS preference is (LIFO, FIFO, Average Cost.) If it is "Average Cost" then it calls <code>getProductAverageCost</code> with the organizationPartyId, productId from InvoiceItem (from invoiceId and invoiceItemSeqId) and returns the value of "averageCost" as COGS. <emphasis>LIFO and FIFO are not implemented yet.</emphasis></para> <para>The service <code>getProductAverageCost</code> takes parameters organizationPartyId and productId and returns a double called "averageCost", which is the current average cost of the product for this organization. It does it by looking up the ProductAverageCost entity.</para> </section> <section> <title>Payments</title> <para>Imagine receiving a check from your customer and depositing it to your company's checking account. What has happened here? You have reduced the Accounts Receivables account and increased the Cash account's value. This is typical of payment transactions--two GL accounts are involved, one specific to this payment (ie, the checking account) and one which offsets
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -