-
  I create a cash account type
-
  !record {model: account.account.type, id: account_account_type_cash_0}:
    close_method: balance
    code: cash
    name: Cash
    sign: 1
    report_type: asset
-
  I create a X11003 Cash Account.
-
  !record {model: account.account, id: account_account_cash0}:
    code: 'X11003-test'
    company_id: base.main_company
    currency_mode: current
    name: Cash (test)
    type: liquidity
    reconcile: False
    user_type : account_account_type_cash_0
    activation_date: !eval time.strftime('%Y-01-01')
-
  We create Timesheet journal for employee.
-
  !record {model: account.analytic.journal, id: analytic_journal_1}:
    code: CANJ
    name: Cash Analytic Journal
    type: general
-
  In order to check the Journal default value and register creation, we create a new cash journal.
-
  !record {model: account.journal, id: account_journal_1}:
    name: Cash Journal EUR
    code: CEUR
    currency: base.EUR
    type: cash
    analytic_journal_id: analytic_journal_1
    default_debit_account_id: account_account_cash0
    default_credit_account_id: account_account_cash0
-
  We check that the default parameters are correctly set
-
  !assert {model: account.journal, id: account_journal_1}:
    - allow_date == False
    - centralisation == False
    - entry_posted == False
    - update_posted == True
    - group_invoice_lines == False
-
  We check that the cash register was created
-
  !assert {model: account.bank.statement, search: "[('journal_id', '=', ref('account_journal.account_journal_1'))]"}:
    - name == 'Cash Journal EUR'
    - currency.id == ref("base.EUR")
-
  In order to test engagement journal, I create an invoice with the global_distrib_1 (75% for gabon, 25% for Kenya)
-
  !record {model: account.invoice, id: invoice_for_engagement_1}:
    account_id: account.a_pay
    address_contact_id: base.res_partner_address_3000
    address_invoice_id: base.res_partner_address_3000
    check_total: 250.0
    company_id: base.main_company
    currency_id: base.EUR
    journal_id: account.expenses_journal
    partner_id: base.res_partner_desertic_hispafuentes
    reference_type: none
    type: in_invoice
    analytic_distribution_id: global_distrib_1
    date_invoice: !eval time.strftime('%Y-%m-%d')
-
  Then I add an invoice line in order it takes analytic distribution from invoice
-
  !python {model: account.invoice.line}: |
    vals = {
        'account_id': ref('account_account_expense0'),
        'name': 'Product PC1',
        'price_unit': 50.0,
        'product_id': ref('product.product_product_pc1'),
        'quantity': 5.0,
        'uos_id': ref('product.product_uom_unit'),
        'invoice_id': ref('account_journal.invoice_for_engagement_1'),
    }
    self.create(cr, uid, vals)
-
  We validate the invoice
-
  !python {model: account.invoice}: |
    self.action_open_invoice(cr, uid, [ref('invoice_for_engagement_1')])
-
  I check that analytic lines where written for Gabon and Kenya in funding_pool elements.
-
  !python {model: account.analytic.line}: |
    # We should 2 lines for each analytic account with an amount of -187.5 and one of -62.5
    for el in [(187.50, ref('analytic_account_gabon')), (62.50, ref('analytic_account_kenya'))]:
        search_ids = self.search(cr, uid, [('amount', '=', -1 * el[0])])
        assert len(search_ids) == 1, "Some lines are missing."
