commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

r6198 - trunk/gnue-packages/finance


From: reinhard
Subject: r6198 - trunk/gnue-packages/finance
Date: Tue, 24 Aug 2004 08:40:11 -0500 (CDT)

Author: reinhard
Date: 2004-08-24 08:40:10 -0500 (Tue, 24 Aug 2004)
New Revision: 6198

Added:
   trunk/gnue-packages/finance/gl.gcd
Log:
First draft for a general ledger module.


Added: trunk/gnue-packages/finance/gl.gcd
===================================================================
--- trunk/gnue-packages/finance/gl.gcd  2004-08-24 12:39:49 UTC (rev 6197)
+++ trunk/gnue-packages/finance/gl.gcd  2004-08-24 13:40:10 UTC (rev 6198)
@@ -0,0 +1,168 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<module name="gl" comment="General Ledger">
+  <class name="year" comment="Fiscal year">
+    <property name="name"     type="string(17)" nullable="False" />
+    <property name="start"    type="date"       nullable="False" />
+    <property name="end"      type="date"       nullable="False" />
+    <property name="previous" type="gl_year"    />
+    <property name="active"   type="boolean"    nullable="False" />
+    <property name="last"     type="number(6)"  comment="Last journal serial" 
/>
+    <procedure name="OnChange">
+      <![CDATA[
+        # TODO: self.start and self.end may not be changed if there are already
+        #       some journals in this year (?)
+        # TODO: if self.active is set to False, set all periods to inactive,
+        #       too
+      ]]>
+    </procedure>
+    <procedure name="OnValidate">
+      <![CDATA[
+        # TODO: check: self.start must be the first day of a month
+        # TODO: check: self.last must be the last day of a month
+        # TODO: check: self.end > self.start
+        # TODO: check: self.previous.end + 1day = self.start
+        # TODO: generate accounting periods
+      ]]>
+    </procedure>
+  </class>
+
+  <class name="period" comment="Accouning period">
+    <property name="year"   type="gl_year"    nullable="False" />
+    <property name="name"   type="string(17)" nullable="False" />
+    <property name="start"  type="date"       nullable="False" />
+    <property name="end"    type="date"       nullable="False" />
+    <property name="active" type="boolean"    nullable="False" />
+    <procedure name="OnChange">
+      <![CDATA[
+        # TODO: self.start and self.end may not be changed if there are already
+        #       some journals in this period (?)
+      ]]>
+    </procedure>
+    <procedure name="OnValidate">
+      <![CDATA[
+        # TODO: self.end must be the last day of the same month of which
+        #       self.start is the first day.
+        # TODO: self.start and self.end must be within self.year.start and
+        #       self.year.end
+        # TODO: may not be active if year is inactive
+      ]]>
+    </procedure>
+  </class>
+
+  <class name="account" comment="General Ledger Account">
+    <property name="year"   type="gl_year"    nullable="False" />
+    <property name="number" type="string(17)" nullable="False" />
+    <property name="name"   type="string(35)" />
+    <property name="active" type="boolean"    nullable="False" />
+    <!-- property name="currency" -->
+    <procedure name="OnChange">
+      <![CDATA[
+        # TODO: number may not be changed if account was already used
+      ]]>
+    </procedure>
+  </class>
+
+  <class name="doctype" comment="Document type">
+    <property name="code"    type="string(8)"  nullable="False" />
+    <property name="name"    type="string(35)" />
+    <!-- This account will be used automatically, e.g. bank account -->
+    <!-- Problem: the accounts are per year, this class is general... -->
+    <!-- Maybe have this class per year, too? -->
+    <property name="account" type="gl_account" />
+  </class>
+
+  <class name="journal" comment="General Ledger Journal">
+    <property name="period"   type="gl_period" nullable="False" />
+    <property name="serial"   type="number(6)" nullable="False" />
+    <property name="last"     type="number(6)" comment="Last transact serial" 
/>
+    <property name="balanced" type="boolean"   nullable="False">
+      <![CDATA[
+        # Find out whether the journal is balanced
+        for trans in find ('trans', conditions = {'journal': self}):
+          if not trans.balanced:
+            return False
+        return True
+      ]]>
+    </property>
+    <property name="posted"   type="date"      />
+    <procedure name="post">
+      <![CDATA[
+        # Post the journal, which means it will not be changeable any more
+        import mx.DateTime
+        if not self.balanced:
+          # TODO: How do we handle exceptions???
+          raise "Journal is not balanced"
+        self.posted = mx.DateTime.now () # Should probably be a parameter
+      ]]>
+    </procedure>
+    <procedure name="OnValidate">
+      <![CDATA[
+        if not self.period.active:
+          raise "Accounting period is inactive"
+        if not self.serial:
+          self.period.year.last += 1
+          self.serial = self.period.year.last
+        self.last = 0
+      ]]>
+    </procedure>
+  </class>
+
+  <class name="trans" comment="General Ledger Transaction">
+    <property name="journal"  type="gl_journal" nullable="False" />
+    <property name="serial"   type="number(6)"  comment="Pos. in journal" />
+    <property name="source"   type="gl_doctype" comment="Document type" />
+    <property name="number"   type="string(17)" comment="Document number" />
+    <property name="date"     type="date"       comment="Document date" />
+    <!-- property name="currency" -->
+    <property name="last"     type="number(6)"  comment="Last entry serial" />
+    <property name="balanced" type="boolean"    nullable="False">
+      <![CDATA[
+        # Find out whether the transaction is balanced
+        sum = 0
+        for entry in find ('entry', conditions = {'trans': self},
+                                    properties = ['credit', 'amountt']):
+          if entry.credit:
+            sum -= entry.amountt
+          else:
+            sum += entry.amountt
+        return (sum == 0)
+      ]]>
+    </property>
+    <procedure name="OnValidate">
+      <![CDATA[
+        # Find out whether the transaction can be entered
+        if self.journal.posted:
+          raise "Journal is already posted"
+        if not self.serial:
+          self.journal.last += 1
+          self.serial = self.journal.last
+        self.last = 0
+      ]]>
+    </procedure>
+  </class>
+
+  <class name="entry" comment="General Ledger Entry">
+    <property name="trans"   type="gl_trans"   nullable="False" />
+    <property name="serial"  type="number(6)"  comment="Pos. in transaction" />
+    <property name="account" type="gl_account" nullable="False" />
+    <property name="credit"  type="boolean"    nullable="False" />
+    <property name="amountt" type="number(15)" comment="in transact currency" 
/>
+    <property name="amounta" type="number(15)" comment="in account currency" />
+    <property name="amountb" type="number(15)" comment="in base currency" />
+    <property name="comment" type="string(70)" />
+    <procedure name="OnValidate">
+      <![CDATA[
+        # Find out whether the entry is valid
+        if not self.account.active
+          raise "Account is inactive"
+        # TODO: calculate amounta and amountb
+        self.amounta = self.amountt
+        self.amountb = self.amountt
+        if not self.serial:
+          self.trans.last += 1
+          self.serial = self.trans.last
+      ]]>
+    </procedure>
+  </class>
+</module>





reply via email to

[Prev in Thread] Current Thread [Next in Thread]