Compute the aged balance over all fiscalyears and reverse dates order

review505005
This commit is contained in:
Nicolas Évrard committed 2012-09-28 18:55:52 +02:00
1 parent 85f88bfd14
commit 90aac98259
3 files changed
+8 -24

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
* Compute the aged balance over all fiscalyears and reverse dates order
* Add cumulate option for Debit/Credit on Account
* Allow to open accounts from balance sheet
* Add start/end balance to Trial balance
+7 -21
View File
@@ -1998,8 +1998,6 @@ class OpenAgedBalanceStart(ModelView):
'Open Aged Balance'
__name__ = 'account.open_aged_balance.start'
company = fields.Many2One('company.company', 'Company', required=True)
fiscalyear = fields.Many2One('account.fiscalyear', 'Fiscal Year',
required=True)
balance_type = fields.Selection(
[('customer', 'Customer'), ('supplier', 'Supplier'), ('both', 'Both')],
"Type", required=True)
@@ -2010,12 +2008,6 @@ class OpenAgedBalanceStart(ModelView):
[('day', 'Day'), ('month', 'Month')], "Unit", required=True)
posted = fields.Boolean('Posted Move', help='Show only posted move')
@staticmethod
def default_fiscalyear():
FiscalYear = Pool().get('account.fiscalyear')
return FiscalYear.find(
Transaction().context.get('company'), exception=False)
@staticmethod
def default_balance_type():
return "customer"
@@ -2068,7 +2060,6 @@ class OpenAgedBalance(Wizard):
error_description="term_overlap_desc")
data = {
'company': self.start.company.id,
'fiscalyear': self.start.fiscalyear.id,
'term1': self.start.term1,
'term2': self.start.term2,
'term3': self.start.term3,
@@ -2096,16 +2087,15 @@ class AgedBalance(Report):
company = Company(data['company'])
localcontext['digits'] = company.currency.digits
localcontext['fiscalyear'] = data['fiscalyear']
localcontext['posted'] = data['posted']
with Transaction().set_context(context=localcontext):
line_query, _ = MoveLine.query_get()
terms = (data['term1'], data['term2'], data['term3'])
if data['unit'] == 'month':
coef = 30
coef = datetime.timedelta(days=30)
else:
coef = 1
coef = datetime.timedelta(days=1)
kind = {
'both': ('payable', 'receivable'),
@@ -2115,19 +2105,15 @@ class AgedBalance(Report):
res = {}
for position, term in enumerate(terms):
if position == 0:
term_query = '(l.maturity_date <= %s '\
'OR l.maturity_date IS NULL) '
term_args = (Date.today() +
datetime.timedelta(days=term * coef),)
if position == 2:
term_query = 'l.maturity_date <= %s'
term_args = (Date.today() - term * coef,)
else:
term_query = '(l.maturity_date <= %s '\
'AND l.maturity_date > %s) '
term_args = (
Date.today() + datetime.timedelta(days=term * coef),
Date.today()
+ datetime.timedelta(days=terms[position - 1] * coef),
)
Date.today() - term * coef,
Date.today() - terms[position + 1] * coef)
cursor.execute('SELECT l.party, SUM(l.debit) - SUM(l.credit) '
'FROM account_move_line l '
-3
View File
@@ -1004,9 +1004,6 @@ this repository contains the full copyright notices and license terms. -->
<field name="arch" type="xml">
<![CDATA[
<form string="Open Aged Balance" col="4">
<label name="fiscalyear"/>
<field name="fiscalyear"/>
<newline/>
<label name="balance_type"/>
<field name="balance_type"/>
<newline/>