Browse Source

Merge pull request #301 from Eficent/9.0-fix-customer-outstanding-statement

[9.0][FIX] Customer Outstanding Statement (Aging buckets)
pull/311/head
Jordi Ballester Alomar 8 years ago
committed by GitHub
parent
commit
03c681401d
  1. 2
      customer_outstanding_statement/__openerp__.py
  2. 26
      customer_outstanding_statement/report/customer_outstanding_statement.py

2
customer_outstanding_statement/__openerp__.py

@ -6,7 +6,7 @@
{ {
'name': 'Customer Outstanding Statement', 'name': 'Customer Outstanding Statement',
'version': '9.0.1.0.0', 'version': '9.0.1.0.0',
'category': 'Reports/pdf',
'category': 'Accounting & Finance',
'summary': 'OCA Financial Reports', 'summary': 'OCA Financial Reports',
'author': "Eficent, Odoo Community Association (OCA)", 'author': "Eficent, Odoo Community Association (OCA)",
'website': 'https://github.com/OCA/account-financial-reporting', 'website': 'https://github.com/OCA/account-financial-reporting',

26
customer_outstanding_statement/report/customer_outstanding_statement.py

@ -107,9 +107,14 @@ class CustomerOutstandingStatement(models.AbstractModel):
def _show_buckets_sql_q1(self, partners, date_end): def _show_buckets_sql_q1(self, partners, date_end):
return """ return """
SELECT l.partner_id, l.currency_id, l.company_id, l.move_id, SELECT l.partner_id, l.currency_id, l.company_id, l.move_id,
l.balance - sum(coalesce(pr.amount, 0.0)) as open_due,
l.amount_currency - sum(coalesce(pr.amount_currency, 0.0))
AS open_due_currency,
CASE WHEN l.balance > 0.0
THEN l.balance - sum(coalesce(pd.amount, 0.0))
ELSE l.balance + sum(coalesce(pc.amount, 0.0))
END AS open_due,
CASE WHEN l.balance > 0.0
THEN l.amount_currency - sum(coalesce(pd.amount_currency, 0.0))
ELSE l.amount_currency + sum(coalesce(pc.amount_currency, 0.0))
END AS open_due_currency,
CASE WHEN l.date_maturity is null CASE WHEN l.date_maturity is null
THEN l.date THEN l.date
ELSE l.date_maturity ELSE l.date_maturity
@ -117,21 +122,24 @@ class CustomerOutstandingStatement(models.AbstractModel):
FROM account_move_line l FROM account_move_line l
JOIN account_account_type at ON (at.id = l.user_type_id) JOIN account_account_type at ON (at.id = l.user_type_id)
JOIN account_move m ON (l.move_id = m.id) JOIN account_move m ON (l.move_id = m.id)
LEFT JOIN (
SELECT pr.*
LEFT JOIN (SELECT pr.*
FROM account_partial_reconcile pr FROM account_partial_reconcile pr
INNER JOIN account_move_line l2 INNER JOIN account_move_line l2
ON pr.credit_move_id = l2.id ON pr.credit_move_id = l2.id
WHERE l2.date <= '%s' WHERE l2.date <= '%s'
) as pr
ON pr.debit_move_id = l.id
) as pd ON pd.debit_move_id = l.id
LEFT JOIN (SELECT pr.*
FROM account_partial_reconcile pr
INNER JOIN account_move_line l2
ON pr.debit_move_id = l2.id
WHERE l2.date <= '%s'
) as pc ON pc.credit_move_id = l.id
WHERE l.partner_id IN (%s) AND at.type = 'receivable' WHERE l.partner_id IN (%s) AND at.type = 'receivable'
AND not l.reconciled AND not l.blocked AND not l.reconciled AND not l.blocked
AND l.balance > 0.0
GROUP BY l.partner_id, l.currency_id, l.date, l.date_maturity, GROUP BY l.partner_id, l.currency_id, l.date, l.date_maturity,
l.amount_currency, l.balance, l.move_id, l.amount_currency, l.balance, l.move_id,
l.company_id l.company_id
""" % (date_end, partners)
""" % (date_end, date_end, partners)
def _show_buckets_sql_q2(self, today, minus_30, minus_60, minus_90, def _show_buckets_sql_q2(self, today, minus_30, minus_60, minus_90,
minus_120): minus_120):

Loading…
Cancel
Save