<commit_before># -*- coding: utf-8 -*-
#
# Author: <NAME>
# ©  2015 Apulia Software srl
#
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp.tests.common import TransactionCase


class TestInvoiceDueCost(TransactionCase):

    def _create_pterm(self):
        return self.env['account.payment.term'].create({
            'name': 'Ri.Ba. 30/60',
            'riba': True,
            'riba_payment_cost': 5.00,
            'line_ids': [
                (0, 0,
                 {'value': 'procent', 'days': 30,
                  'days2': -1, 'value_amount': 0.50}),
                (0, 0,
                 {'value': 'balance', 'days': 60,
                  'days2': -1})
            ]
        })

    def _create_pterm2(self):
        return self.env['account.payment.term'].create({
            'name': 'Ri.Ba. 30',
            'riba': True,
            'riba_payment_cost': 5.00,
            'line_ids': [
                (0, 0,
                 {'value': 'balance', 'days': 30,
                  'days2': -1})
            ]
        })

    def _account_expense(self):
        return self.env['account.account'].create({
            'code': 'demo_due_cost',
            'name': 'cashing fees',
            'type': 'other',
            'user_type': self.env.ref('account.data_account_type_income').id
        })

    def _create_service_due_cost(self):
        return self.env['product.product'].create({
            'name': 'Due Cost',
            'type': 'service',
            'property_account_income': self._account_expense(),
        })

    def _create_invoice(self):
        return self.env['account.invoice'].create({
            'type': 'out_invoice',
            'journal_id': self.journalrec.id,
            'partner_id': self.partner.id,
            'payment_term': self.payment_term1.id,
            'account_id': self.credit_account.id,
            'invoice_line': [(
                0, 0, {
                    'name': self.product1.partner_ref,
                    'product_id': self.product1.id,
                    'quantity': 1.0,
                    'price_unit': 100.00,
                    'account_id': self.sale_account.id
                }
            )]
        })

    def setUp(self):
        super(TestInvoiceDueCost, self).setUp()
        self.partner = self.env.ref('base.res_partner_8')
        self.product1 = self.env.ref('product.product_product_33')
        self.journalrec = self.env['account.journal'].search(
            [('type', '=', 'sale')])[0]
        self.payment_term1 = self._create_pterm()
        self.payment_term2 = self._create_pterm2()
        self.service_due_cost = self._create_service_due_cost()
        self.credit_account = self.env.ref('account.a_recv')
        self.sale_account = self.env.ref('account.a_sale')
        self.invoice = self._create_invoice()
        self.invoice2 = self._create_invoice()<commit_msg>[FIX] Solve problem with tests of l10n_it_ricevute_bancarie after add of account_invoice_sequential_dates<commit_after># -*- coding: utf-8 -*-
#
# Author: <NAME>
# ©  2015 Apulia Software srl
#
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from openerp.tests.common import TransactionCase


class TestInvoiceDueCost(TransactionCase):

    def _create_pterm(self):
        return self.env['account.payment.term'].create({
            'name': 'Ri.Ba. 30/60',
            'riba': True,
            'riba_payment_cost': 5.00,
            'line_ids': [
                (0, 0,
                 {'value': 'procent', 'days': 30,
                  'days2': -1, 'value_amount': 0.50}),
                (0, 0,
                 {'value': 'balance', 'days': 60,
                  'days2': -1})
            ]
        })

    def _create_pterm2(self):
        return self.env['account.payment.term'].create({
            'name': 'Ri.Ba. 30',
            'riba': True,
            'riba_payment_cost': 5.00,
            'line_ids': [
                (0, 0,
                 {'value': 'balance', 'days': 30,
                  'days2': -1})
            ]
        })

    def _account_expense(self):
        return self.env['account.account'].create({
            'code': 'demo_due_cost',
            'name': 'cashing fees',
            'type': 'other',
            'user_type': self.env.ref('account.data_account_type_income').id
        })

    def _create_service_due_cost(self):
        return self.env['product.product'].create({
            'name': 'Due Cost',
            'type': 'service',
            'property_account_income': self._account_expense(),
        })

    def _create_invoice(self):
        # ----- Set invoice date to biggest date in the system
        # ----- This solves problems with account_invoice_sequential_dates
        biggest_data = self.env['account.invoice'].search(
            [('date_invoice', '!=', False)], order='date_invoice desc',
            limit=1).date_invoice
        return self.env['account.invoice'].create({
            'date_invoice': biggest_data,
            'type': 'out_invoice',
            'journal_id': self.journalrec.id,
            'partner_id': self.partner.id,
            'payment_term': self.payment_term1.id,
            'account_id': self.credit_account.id,
            'invoice_line': [(
                0, 0, {
                    'name': self.product1.partner_ref,
                    'product_id': self.product1.id,
                    'quantity': 1.0,
                    'price_unit': 100.00,
                    'account_id': self.sale_account.id
                }
            )]
        })

    def setUp(self):
        super(TestInvoiceDueCost, self).setUp()
        self.partner = self.env.ref('base.res_partner_8')
        self.product1 = self.env.ref('product.product_product_33')
        self.journalrec = self.env['account.journal'].search(
            [('type', '=', 'sale')])[0]
        self.payment_term1 = self._create_pterm()
        self.payment_term2 = self._create_pterm2()
        self.service_due_cost = self._create_service_due_cost()
        self.credit_account = self.env.ref('account.a_recv')
        self.sale_account = self.env.ref('account.a_sale')
        self.invoice = self._create_invoice()
        self.invoice2 = self._create_invoice()
{'fraction_non_alphanumeric': 0.14628297362110312, 'fraction_numerical': 0.020303756994404478, 'mean_word_length': 1.7953529937444146, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6643855', 'n_tokens_mistral': 2038, 'n_tokens_neox': 1899, 'n_words': 328}