book: Feld 'start_date' + test,
line: balance-berechnung mit abstimmung gekoppelt + test, abstimmung: start/enddatum automatisch
This commit is contained in:
parent
5729ed0a07
commit
91a34e216b
13 changed files with 446 additions and 20 deletions
|
@ -13,6 +13,7 @@ from trytond.i18n import gettext
|
|||
from decimal import Decimal
|
||||
from sql.operators import Equal, Between
|
||||
from sql import Literal, Null
|
||||
from datetime import timedelta
|
||||
from .book import sel_state_book
|
||||
|
||||
|
||||
|
@ -299,6 +300,22 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
|||
'num': len(self.lines),
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def default_date_from(cls):
|
||||
""" 1st day of current month
|
||||
"""
|
||||
return Pool().get('ir.date').today().replace(day=1)
|
||||
|
||||
@classmethod
|
||||
def default_date_to(cls):
|
||||
""" last day of current month
|
||||
"""
|
||||
IrDate = Pool().get('ir.date')
|
||||
|
||||
dt1 = IrDate.today().replace(day=28) + timedelta(days=5)
|
||||
dt1 = dt1.replace(day=1) - timedelta(days=1)
|
||||
return dt1
|
||||
|
||||
@classmethod
|
||||
def default_start_amount(cls):
|
||||
return Decimal('0.0')
|
||||
|
@ -360,15 +377,31 @@ class Reconciliation(Workflow, ModelSQL, ModelView):
|
|||
def create(cls, vlist):
|
||||
""" add debit/credit
|
||||
"""
|
||||
Recon = Pool().get('cashbook.recon')
|
||||
pool = Pool()
|
||||
Recon = pool.get('cashbook.recon')
|
||||
Line = pool.get('cashbook.line')
|
||||
Cashbook = pool.get('cashbook.book')
|
||||
|
||||
for values in vlist:
|
||||
# set date_from date_to of predecessor
|
||||
id_cashbook = values.get('cashbook', -1)
|
||||
|
||||
# set date_from to date_to of predecessor
|
||||
recons = Recon.search([
|
||||
('cashbook.id', '=', values.get('cashbook', -1)),
|
||||
('cashbook.id', '=', id_cashbook),
|
||||
], order=[('date_to', 'DESC')], limit=1)
|
||||
if len(recons) > 0:
|
||||
values['date_from'] = recons[0].date_to
|
||||
elif id_cashbook != -1:
|
||||
values['date_from'] = Cashbook(id_cashbook).start_date
|
||||
|
||||
# set date_to to day of last 'checked'-booking in selected cashbook
|
||||
lines = Line.search([
|
||||
('cashbook.id', '=', id_cashbook),
|
||||
('state', '=', 'check'),
|
||||
('reconciliation', '=', None),
|
||||
], order=[('date', 'DESC')], limit=1)
|
||||
if len(lines) > 0:
|
||||
values['date_to'] = lines[0].date
|
||||
|
||||
cls.check_overlap_dates(
|
||||
values.get('date_from', None),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue