changeset 9f6bf9d17129 in modules/account:default details: https://hg.tryton.org/modules/account?cmd=changeset&node=9f6bf9d17129 description: Computes GeneralLedger timespan on either dates or period (scenario patch)
issue10249 review351991002 diffstat: tests/scenario_reports.rst | 77 +++++++++++++++++++++++++++++++++++++++------ 1 files changed, 66 insertions(+), 11 deletions(-) diffs (132 lines): diff -r 1b3d9d7a758f -r 9f6bf9d17129 tests/scenario_reports.rst --- a/tests/scenario_reports.rst Tue Oct 12 11:29:34 2021 +0200 +++ b/tests/scenario_reports.rst Tue Oct 12 11:32:48 2021 +0200 @@ -28,7 +28,8 @@ >>> fiscalyear = create_fiscalyear(company) >>> fiscalyear.click('create_period') - >>> period = fiscalyear.periods[0] + >>> periods = fiscalyear.periods + >>> period_1, period_3, period_5 = periods[0], periods[2], periods[4] Create chart of accounts:: @@ -56,9 +57,9 @@ ... ('code', '=', 'CASH'), ... ]) >>> move = Move() - >>> move.period = period + >>> move.period = period_3 >>> move.journal = journal_revenue - >>> move.date = period.start_date + >>> move.date = period_3.start_date >>> line = move.lines.new() >>> line.account = revenue >>> line.credit = Decimal(10) @@ -69,9 +70,9 @@ >>> move.save() >>> move = Move() - >>> move.period = period + >>> move.period = period_5 >>> move.journal = journal_cash - >>> move.date = period.start_date + >>> move.date = period_5.start_date >>> line = move.lines.new() >>> line.account = cash >>> line.debit = Decimal(10) @@ -128,8 +129,8 @@ >>> context = { ... 'company': company.id, ... 'fiscalyear': fiscalyear.id, - ... 'from_date': fiscalyear.periods[0].start_date, - ... 'to_date': fiscalyear.periods[1].end_date, + ... 'from_date': period_1.start_date, + ... 'to_date': period_3.end_date, ... } >>> with config.set_context(context): ... gl_revenue, = GeneralLedgerAccount.find([ @@ -150,16 +151,70 @@ >>> glp_receivable.start_balance Decimal('0.00') >>> glp_receivable.credit - Decimal('10.00') + Decimal('0.00') >>> glp_receivable.debit Decimal('10.00') >>> glp_receivable.end_balance + Decimal('10.00') + + >>> context = { + ... 'company': company.id, + ... 'fiscalyear': fiscalyear.id, + ... 'start_period': period_3.id, + ... } + >>> with config.set_context(context): + ... gl_revenue, = GeneralLedgerAccount.find([ + ... ('account', '=', revenue.id), + ... ]) + >>> gl_revenue.start_balance Decimal('0.00') + >>> gl_revenue.credit + Decimal('10.00') + >>> gl_revenue.debit + Decimal('0.00') + >>> gl_revenue.end_balance + Decimal('-10.00') >>> context = { ... 'company': company.id, ... 'fiscalyear': fiscalyear.id, - ... 'start_period': fiscalyear.periods[1].id, + ... 'start_period': period_5.id, + ... } + >>> with config.set_context(context): + ... gl_revenue, = GeneralLedgerAccount.find([ + ... ('account', '=', revenue.id), + ... ]) + >>> gl_revenue.start_balance + Decimal('-10.00') + >>> gl_revenue.credit + Decimal('0.00') + >>> gl_revenue.debit + Decimal('0.00') + >>> gl_revenue.end_balance + Decimal('-10.00') + + >>> context = { + ... 'company': company.id, + ... 'fiscalyear': fiscalyear.id, + ... 'from_date': period_3.start_date, + ... } + >>> with config.set_context(context): + ... gl_revenue, = GeneralLedgerAccount.find([ + ... ('account', '=', revenue.id), + ... ]) + >>> gl_revenue.start_balance + Decimal('0.00') + >>> gl_revenue.credit + Decimal('10.00') + >>> gl_revenue.debit + Decimal('0.00') + >>> gl_revenue.end_balance + Decimal('-10.00') + + >>> context = { + ... 'company': company.id, + ... 'fiscalyear': fiscalyear.id, + ... 'from_date': period_5.start_date, ... } >>> with config.set_context(context): ... gl_revenue, = GeneralLedgerAccount.find([ @@ -204,8 +259,8 @@ >>> _ = general_journal.execute(Move.find([])) >>> with config.set_context( - ... start_date=period.start_date, - ... end_date=period.end_date): + ... start_date=period_5.start_date, + ... end_date=period_5.end_date): ... journal_cash = Journal(journal_cash.id) >>> journal_cash.credit Decimal('0.00')