def test_service_create(self):
        self.demo_request_1.validate_subscription_request()
        invoice = self.demo_request_1.capital_release_request
        journal = self.bank_journal

        result = self.ap_service.create(
            payment_date=Date.to_string(Date.today()),
            amount=self.demo_request_1.subscription_amount,
            payment_type="inbound",
            payment_method="manual",
            communication=invoice.reference,
            invoice=invoice.get_api_external_id(),
            journal=journal.get_api_external_id(),
        )

        demo_payment_dict = {
            "id": result["id"],
            "communication": invoice.reference,
            "invoice": {
                "id": invoice.get_api_external_id(),
                "name": invoice.name,
            },
            "amount": self.demo_request_1.subscription_amount,
            "payment_date": Date.to_string(Date.today()),
            "journal": {
                "id": self.bank_journal.get_api_external_id(),
                "name": self.bank_journal.name,
            },
        }
        self.assertEquals(demo_payment_dict, result)

        invoice = self.ai_service.get(invoice.get_api_external_id())
        self.assertEquals("paid", invoice["state"])
Beispiel #2
0
    def _test_contract(self):
        struct = self.create_salary_structure(self.hr_payroll_user,
                                              'Salary Structure', 'SOO1')

        # Contract without car and without fleet access rights
        contract_cdd = self.create_contract(
            user=self.hr_contract_manager,
            name="%s's CDD" % self.user.employee_id,
            employee=self.user.employee_id,
            structure=struct,
            start=Date.today() + relativedelta(day=1, months=-1),
            end=Date.today().replace(day=15),
            wage=1500,
            state='close',
        )

        # Contract with a car and with access rights
        with additional_groups(self.hr_contract_manager,
                               'fleet.fleet_group_manager'):
            contract_cdi = self.create_contract(
                user=self.hr_contract_manager,
                name="%s's CDD" % self.user.employee_id,
                structure=struct,
                employee=self.user.employee_id,
                start=Date.today().replace(day=16),
                car=self.env['fleet.vehicle'].search([
                    ('driver_id', '=',
                     self.user.employee_id.address_home_id.id),
                    ('company_id', '=', self.user.employee_id.company_id.id),
                ],
                                                     limit=1),
                wage=2500,
                state='draft',
            )
            contract_cdi.state = 'open'
Beispiel #3
0
 def test_onchange_product_id_recurring_info(self):
     self.product2.write({
         'recurring_rule_type': 'monthly',
         'recurring_invoicing_type': 'pre-paid',
         'is_auto_renew': True,
         'default_qty': 12,
         'termination_notice_interval': '6',
         'termination_notice_rule_type': 'weekly',
     })
     self.contract_line.write({
         'date_start':
         Date.today(),
         'date_end':
         Date.today() + relativedelta(years=1),
         'recurring_next_date':
         Date.today(),
         'product_id':
         self.product2.id,
     })
     self.contract_line._onchange_product_id_recurring_info()
     self.assertEqual(self.contract_line.recurring_rule_type, 'monthly')
     self.assertEqual(self.contract_line.recurring_invoicing_type,
                      'pre-paid')
     self.assertEqual(self.contract_line.recurring_interval, 1)
     self.assertEqual(self.contract_line.is_auto_renew, True)
     self.assertEqual(self.contract_line.auto_renew_interval, 12)
     self.assertEqual(self.contract_line.auto_renew_rule_type, 'monthly')
     self.assertEqual(self.contract_line.termination_notice_interval, 6)
     self.assertEqual(self.contract_line.termination_notice_rule_type,
                      'weekly')
Beispiel #4
0
 def check_apply_plan(self, key, value, modulus, difference):
     plan = self.env["medical.guard.plan"].create(
         {
             "location_id": self.center.id,
             "product_id": self.product.id,
             "start_time": 0,
             "delay": 1,
             "weekday": "*",
             "monthday": "*",
             "month": "*",
         }
     )
     self.assertFalse(
         self.env["medical.guard"].search([("plan_guard_id", "=", plan.id)])
     )
     plan.write({key: ((value + 1) % modulus) + difference})
     self.env["medical.guard.plan.apply"].create(
         {
             "start_date": Date.today(),
             "end_date": Date.to_string(Date.from_string(Date.today())),
         }
     ).run()
     self.assertFalse(
         self.env["medical.guard"].search([("plan_guard_id", "=", plan.id)])
     )
     plan.write({key: value})
     self.env["medical.guard.plan.apply"].create(
         {
             "start_date": Date.today(),
             "end_date": Date.to_string(Date.from_string(Date.today())),
         }
     ).run()
     self.assertTrue(
         self.env["medical.guard"].search([("plan_guard_id", "=", plan.id)])
     )
Beispiel #5
0
 def check_apply_plan(self, key, value, modulus, difference):
     plan = self.env['medical.guard.plan'].create({
         'location_id': self.center.id,
         'product_id': self.product.id,
         'start_time': 0,
         'delay': 1,
         'weekday': '*',
         'monthday': '*',
         'month': '*'
     })
     self.assertFalse(self.env['medical.guard'].search([
         ('plan_guard_id', '=', plan.id)
     ]))
     plan.write({key: ((value+1) % modulus) + difference})
     self.env['medical.guard.plan.apply'].create({
         'start_date': Date.today(),
         'end_date': Date.to_string(
             Date.from_string(Date.today())),
     }).run()
     self.assertFalse(self.env['medical.guard'].search([
         ('plan_guard_id', '=', plan.id)
     ]))
     plan.write({key: value})
     self.env['medical.guard.plan.apply'].create({
         'start_date': Date.today(),
         'end_date': Date.to_string(
             Date.from_string(Date.today())),
     }).run()
     self.assertTrue(self.env['medical.guard'].search([
         ('plan_guard_id', '=', plan.id)
     ]))
    def test_emc_user_access_to_own_subscription_register(self):
        self.as_emc_user()
        partner = self.env["res.users"].browse(self.uid).partner_id
        partner.structure = self.coopiteasy

        vals = {
            "name": "create passes",
            "register_number_operation": 5,
            "partner_id":
            self.ref("easy_my_coop.res_partner_cooperator_1_demo"),
            "date": Date.today(),
            "share_product_id": self.cie_share_product_product,
            "structure": self.coopiteasy.id,
        }
        register = self.env["subscription.register"].create(vals)
        _ = register.structure
        register.write({"name": "write passes"})
        with self.assertRaises(AccessError):
            register.unlink()

        vals = {
            "name": "create fails",
            "register_number_operation": 5,
            "partner_id":
            self.ref("easy_my_coop.res_partner_cooperator_1_demo"),
            "date": Date.today(),
            "share_product_id": self.cc_share_product_product,
            "structure": self.coopcity.id,
        }
        with self.assertRaises(AccessError):
            self.env["subscription.register"].create(vals)
    def test_register_payment_for_capital_release(self):
        self.as_emc_user()
        self.request.validate_subscription_request()
        invoice = self.request.capital_release_request

        ctx = {"active_model": "account.invoice", "active_ids": [invoice.id]}
        register_payments = (
            self.env["account.register.payments"].with_context(ctx).create({
                "payment_date":
                Date.today(),
                "journal_id":
                self.bank_journal_euro.id,
                "payment_method_id":
                self.payment_method_manual_in.id,
            }))
        register_payments.create_payments()
        self.assertEquals(self.request.capital_release_request.state, "paid")

        partner = self.request.partner_id
        self.assertFalse(partner.coop_candidate)
        self.assertTrue(partner.member)
        self.assertTrue(partner.share_ids)
        self.assertEquals(self.request.partner_id.effective_date, Date.today())

        share = partner.share_ids[0]
        self.assertEquals(share.share_number, self.request.ordered_parts)
        self.assertEquals(share.share_product_id,
                          self.request.share_product_id)
        self.assertEquals(share.effective_date, Date.today())
    def test_complete_loan_flow(self):

        loan_issue_values = {
            "name": "test loan issue",
            "default_issue": "xx",
            "subscription_start_date": Date.today(),
            "subscription_end_date": Date.today() + timedelta(days=60),
            "user_id": self.ref("easy_my_coop.res_users_manager_emc_demo"),
            "term_date": Date.today() + timedelta(days=600),  # ?
            "gross_rate": 0.03,
            "face_value": 100,
            "minimum_amount": 4000,
            "maximum_amount": 10000,
            "interest_payment": "end",
            "by_company": True,
            "by_individual": True,
            "display_on_website": True,
            "taxes_rate": 0.08,
            "loan_term": 12,
        }

        self.as_emc_manager()
        loan_issue = self.env["loan.issue"].create(loan_issue_values)
        loan_issue.action_confirm()
        loan_issue.action_open()
        loan_issue.action_cancel()
        loan_issue.action_draft()
        loan_issue.action_open()
 def setUp(self):
     super(TestContract, self).setUp()
     self.brand_id = self.env["res.brand"].create({"name": "brand"})
     self.line_vals["date_start"] = Date.today()
     self.line_vals["recurring_next_date"] = Date.today()
     self.acct_line = (self.env["contract.line"].with_context(
         test_queue_job_no_delay=True).create(self.line_vals))
 def setUp(self):
     self.env = self.env(
         context=dict(self.env.context, test_queue_job_no_delay=True))
     super(TestContractLineForecastPeriod, self).setUp()
     self.this_year = Date.today().year
     self.line_vals["date_start"] = Date.today()
     self.line_vals["recurring_next_date"] = Date.today()
     self.acct_line = self.env["contract.line"].create(self.line_vals)
Beispiel #11
0
    def _get_car_atn(self, acquisition_date, car_value, fuel_type, co2):
        # Compute the correction coefficient from the age of the car
        now = Date.today()
        if acquisition_date:
            number_of_month = ((now.year - acquisition_date.year) * 12.0 + now.month -
                               acquisition_date.month +
                               int(bool(now.day - acquisition_date.day + 1)))
            if number_of_month <= 12:
                age_coefficient = 1.00
            elif number_of_month <= 24:
                age_coefficient = 0.94
            elif number_of_month <= 36:
                age_coefficient = 0.88
            elif number_of_month <= 48:
                age_coefficient = 0.82
            elif number_of_month <= 60:
                age_coefficient = 0.76
            else:
                age_coefficient = 0.70
            car_value = car_value * age_coefficient
            # Compute atn value from corrected car_value
            magic_coeff = 6.0 / 7.0  # Don't ask me why
            if fuel_type == 'electric':
                atn = 0.0
            else:
                if fuel_type in ['diesel', 'hybrid']:
                    reference = 86.0
                else:
                    reference = 88.0

                if co2 <= reference:
                    atn = car_value * max(0.04, (0.055 - 0.001 * (reference - co2))) * magic_coeff
                else:
                    atn = car_value * min(0.18, (0.055 + 0.001 * (co2 - reference))) * magic_coeff
            return max(1310, atn) / 12.0
Beispiel #12
0
def compute_when(date_start, date_end):
    today = Date.today()
    if today < date_start:
        return 'BEFORE'
    if date_end and today > date_end:
        return 'AFTER'
    return 'IN'
    def test_iwp_manager_access_to_all_loan_issue_and_lines(self):
        self.as_iwp_user()
        partner = self.env["res.users"].browse(self.uid).partner_id
        partner.structure = False

        vals = {
            "name": "create passes",
            "face_value": 100,
            "taxes_rate": 0.03,
            "structure": self.coopiteasy.id,
        }
        loan_issue = self.env["loan.issue"].create(vals)
        _ = loan_issue.structure
        loan_issue.write({"name": "write passes"})
        with self.assertRaises(AccessError):
            loan_issue.unlink()

        vals = {
            "loan_issue_id": loan_issue.id,
            "quantity": 3,
            "partner_id": self.ref("easy_my_coop"
                                   ".res_partner_cooperator_3_demo"),
            "date": Date.today(),
            "state": "subscribed",
            "structure": self.coopiteasy.id,
        }
        loan = self.env["loan.issue.line"].create(vals)
        _ = loan.structure
        loan.write({"quantity": 3})
        with self.assertRaises(AccessError):
            loan.unlink()
Beispiel #14
0
    def setUp(self):
        super(TestPayslipBase, self).setUp()

        # Some salary rules references
        self.hra_rule_id = self.ref(
            'hr_payroll.hr_salary_rule_houserentallowance1')
        self.conv_rule_id = self.ref(
            'hr_payroll.hr_salary_rule_convanceallowance1')
        self.prof_tax_rule_id = self.ref(
            'hr_payroll.hr_salary_rule_professionaltax1')
        self.pf_rule_id = self.ref('hr_payroll.hr_salary_rule_providentfund1')
        self.mv_rule_id = self.ref('hr_payroll.hr_salary_rule_meal_voucher')
        self.comm_rule_id = self.ref(
            'hr_payroll.hr_salary_rule_sales_commission')

        # I create a new employee "Richard"
        self.richard_emp = self.env['hr.employee'].create({
            'name':
            'Richard',
            'gender':
            'male',
            'birthday':
            '1984-05-01',
            'country_id':
            self.ref('base.be'),
            'department_id':
            self.ref('hr.dep_rd')
        })

        # I create a salary structure for "Software Developer"
        self.developer_pay_structure = self.env['hr.payroll.structure'].create(
            {
                'name':
                'Salary Structure for Software Developer',
                'code':
                'SD',
                'company_id':
                self.ref('base.main_company'),
                'rule_ids': [(4, self.hra_rule_id), (4, self.conv_rule_id),
                             (4, self.prof_tax_rule_id), (4, self.pf_rule_id),
                             (4, self.mv_rule_id), (4, self.comm_rule_id)],
            })

        # I create a contract for "Richard"
        self.env['hr.contract'].create({
            'date_end':
            Date.to_string((datetime.now() + timedelta(days=365))),
            'date_start':
            Date.today(),
            'name':
            'Contract for Richard',
            'wage':
            5000.0,
            'type_id':
            self.ref('hr_contract.hr_contract_type_emp'),
            'employee_id':
            self.richard_emp.id,
            'struct_id':
            self.developer_pay_structure.id,
        })
def compute_when(date_start, date_end):
    today = Date.today()
    if today < date_start:
        return "BEFORE"
    if date_end and today > date_end:
        return "AFTER"
    return "IN"
Beispiel #16
0
 def test_company_constrain(self):
     with self.assertRaises(ValidationError):
         self.env['mis.cash_flow.forecast_line'].create({
             'account_id': self.account.id,
             'date': Date.today(),
             'balance': 1000,
         })
 def default_get(self, fields):
     result = super(GenerateSimulationLink, self).default_get(fields)
     if not set(fields) & set(['contract_id', 'employee_id', 'employee_contract_id', 'applicant_id']):
         return result
     model = self.env.context.get('active_model')
     if model == 'hr.contract':
         contract_id = self.env.context.get('active_id')
         contract = self.env['hr.contract'].sudo().browse(contract_id)
         if not contract.employee_id:
             result['contract_id'] = contract_id
         else:
             result['employee_id'] = contract.employee_id.id
             result['employee_contract_id'] = contract.id
             result['contract_id'] = contract.id
     elif model == 'hr.applicant':
         applicant_id = self.env.context.get('active_id')
         applicant = self.env['hr.applicant'].sudo().browse(applicant_id)
         if not applicant.access_token or applicant.access_token_end_date < Date.today():
             applicant.access_token = uuid.uuid4().hex
             applicant.access_token_end_date = self.env['hr.applicant']._get_access_token_end_date()
         result['applicant_id'] = applicant_id
         contract = applicant.job_id.default_contract_id
         result['contract_id'] = applicant.job_id.default_contract_id.id
     if not result.get('applicant_id') and not contract.contract_update_template_id or result.get('applicant_id') and not contract.sign_template_id:
         raise ValidationError(_('No signature template defined on the contract.'))
     if not contract.hr_responsible_id:
         raise ValidationError(_('No HR responsible defined on the contract.'))
     return result
    def test_route_create(self):
        url = "/api/subscription-request"
        data = {
            "name": "Lisa des Danses",
            "email": "*****@*****.**",
            "ordered_parts": 3,
            "share_product": self.demo_share_product.id,
            "address": {
                "street": "schaerbeekstraat",
                "zip_code": "1111",
                "city": "Brussels",
                "country": "BE",
            },
            "lang": "en_US",
        }

        response = self.http_post(url, data=data)
        self.assertEquals(response.status_code, 200)
        content = json.loads(response.content.decode("utf-8"))

        content.pop("id")  # can't know id in advance
        expected = {
            **data,
            **{
                "date": Date.to_string(Date.today()),
                "state": "draft",
                "share_product": {
                    "id": self.demo_share_product.get_api_external_id(),
                    "name": self.demo_share_product.name,
                },
                "capital_release_request": [],
            },
        }
        self.assertEquals(expected, content)
Beispiel #19
0
    def test_settings_pls_start_date(self):
        # We test here that settings never crash due to ill-configured config param 'crm.pls_start_date'
        set_param = self.env['ir.config_parameter'].sudo().set_param
        str_date_8_days_ago = Date.to_string(Date.today() - timedelta(days=8))
        resConfig = self.env['res.config.settings']

        set_param("crm.pls_start_date", "2021-10-10")
        res_config_new = resConfig.new()
        self.assertEqual(
            Date.to_string(res_config_new.predictive_lead_scoring_start_date),
            "2021-10-10",
            "If config param is a valid date, date in settings should match with config param"
        )

        set_param("crm.pls_start_date", "")
        res_config_new = resConfig.new()
        self.assertEqual(
            Date.to_string(res_config_new.predictive_lead_scoring_start_date),
            str_date_8_days_ago,
            "If config param is empty, date in settings should be set to 8 days before today"
        )

        set_param(
            "crm.pls_start_date",
            "One does not simply walk into system parameters to corrupt them")
        res_config_new = resConfig.new()
        self.assertEqual(
            Date.to_string(res_config_new.predictive_lead_scoring_start_date),
            str_date_8_days_ago,
            "If config param is not a valid date, date in settings should be set to 8 days before today"
        )
Beispiel #20
0
    def _get_car_atn(self, acquisition_date, car_value, fuel_type, co2):
        # Compute the correction coefficient from the age of the car
        now = Date.today()
        if acquisition_date:
            number_of_month = ((now.year - acquisition_date.year) * 12.0 + now.month -
                               acquisition_date.month +
                               int(bool(now.day - acquisition_date.day + 1)))
            if number_of_month <= 12:
                age_coefficient = 1.00
            elif number_of_month <= 24:
                age_coefficient = 0.94
            elif number_of_month <= 36:
                age_coefficient = 0.88
            elif number_of_month <= 48:
                age_coefficient = 0.82
            elif number_of_month <= 60:
                age_coefficient = 0.76
            else:
                age_coefficient = 0.70
            car_value = car_value * age_coefficient
            # Compute atn value from corrected car_value
            magic_coeff = 6.0 / 7.0  # Don't ask me why
            if fuel_type == 'electric':
                atn = 0.0
            else:
                if fuel_type in ['diesel', 'hybrid']:
                    reference = 87.0
                else:
                    reference = 105.0

                if co2 <= reference:
                    atn = car_value * max(0.04, (0.055 - 0.001 * (reference - co2))) * magic_coeff
                else:
                    atn = car_value * min(0.18, (0.055 + 0.001 * (co2 - reference))) * magic_coeff
            return max(1280, atn) / 12.0
Beispiel #21
0
 def _compute_age(self):
     today = fDate.from_string(fDate.today())
     
     for lote in self.filtered('removal_date'):
         fecha_vencimiento = dateutil.parser.parse(lote.removal_date).date()
         # import pdb; pdb.set_trace()
         delta = (fecha_vencimiento - today)
         lote.dias_vencimiento = delta.days
    def setUp(self):
        super(TestL10nMxTaxCashBasis, self).setUp()
        with registry().cursor() as cr:
            env = api.Environment(cr, 1, {})
            dp = env.ref('product.decimal_price')
            dp.digits = 3

        self.today = Date.today()
        self.yesterday = self.today - timedelta(days=1)
        self.two_days_ago = self.today - timedelta(days=2)
        self.a_week_ago = self.today - timedelta(days=7)

        # In order to avoid using this method we at l10n_mx_edi need to use a
        # company of our own. Having MXN as currency. And Loading our Chart of
        # account and base our tests on it.
        # /!\ FIXME: @luistorresm or @hbto
        self.delete_journal_data()

        self.env.user.company_id.write({'currency_id': self.mxn.id})
        self.create_rates()

        self.tax_cash_basis_journal_id = self.company.tax_cash_basis_journal_id
        self.user_type_id = self.env.ref(
            'account.data_account_type_current_liabilities')
        self.account_model = self.env['account.account']
        self.account_move_model = self.env['account.move']
        self.account_move_line_model = self.env['account.move.line']
        self.journal_model = self.env['account.journal']
        self.refund_model = self.env['account.invoice.refund']
        self.register_payments_model = self.env['account.register.payments']
        self.precision = self.env.user.company_id.currency_id.decimal_places
        self.payment_method_manual_out = self.env.ref(
            'account.account_payment_method_manual_out')
        self.payment_method_manual_in = self.env.ref(
            'account.account_payment_method_manual_in')
        self.bank_journal_mxn = self.env['account.journal'].create(
            {'name': 'Bank MXN',
             'type': 'bank',
             'code': 'BNK37'})
        self.bank_journal_usd = self.env['account.journal'].create(
            {'name': 'Bank USD',
             'type': 'bank',
             'code': 'BNK52',
             'currency_id': self.usd.id})
        self.tax_model = self.env['account.tax']
        self.tax_account = self.create_account(
            '11111101', 'Tax Account')
        self.cash_tax_account = self.create_account(
            '77777777', 'Cash Tax Account')
        self.account_tax_cash_basis = self.create_account(
            '99999999', 'Tax Base Account')
        self.tax_positive.write({
            'l10n_mx_cfdi_tax_type': 'Tasa',
            'tax_exigibility': 'on_payment',
            'account_id': self.tax_account.id,
            'refund_account_id': self.tax_account.id,
            'cash_basis_account_id': self.cash_tax_account.id,
            'cash_basis_base_account_id': self.account_tax_cash_basis.id})
 def _compute_age(self):
     today = fDate.from_string(fDate.today())
     for book in self.filtered('date_release'):
         try:
             delta = (today - fDate.from_string(book.date_release))
             book.age_days = delta.days
         except (IOError, OSError) as exc:
             message = _('Unable to compute age days') % exc
             raise UserError(message)
Beispiel #24
0
 def test_complex_plan(self):
     plan = self.env['medical.guard.plan'].create({
         'location_id': self.center.id,
         'product_id': self.product.id,
         'start_time': 0,
         'delay': 1,
         'weekday': '*',
         'monthday': '*',
         'month': '*'
     })
     self.assertFalse(self.env['medical.guard'].search([
         ('plan_guard_id', '=', plan.id)
     ]))
     plan.monthday = '1-40'
     date = Date.from_string(Date.today()).replace(day=1)
     with self.assertRaises(UserError):
         self.env['medical.guard.plan.apply'].create({
             'start_date': Date.to_string(date),
             'end_date': Date.to_string(date + timedelta(days=1)),
         }).run()
     plan.monthday = '1%'
     with self.assertRaises(UserError):
         self.env['medical.guard.plan.apply'].create({
             'start_date': Date.to_string(date),
             'end_date': Date.to_string(date + timedelta(days=1)),
         }).run()
     plan.monthday = 'AB/2'
     with self.assertRaises(UserError):
         self.env['medical.guard.plan.apply'].create({
             'start_date': Date.to_string(date),
             'end_date': Date.to_string(date + timedelta(days=1)),
         }).run()
     plan.monthday = '*/2'
     self.env['medical.guard.plan.apply'].create({
         'start_date': Date.to_string(date + timedelta(days=1)),
         'end_date': Date.to_string(date + timedelta(days=1)),
     }).run()
     self.assertFalse(self.env['medical.guard'].search([
         ('plan_guard_id', '=', plan.id)
     ]))
     plan.monthday = '15-20'
     self.env['medical.guard.plan.apply'].create({
         'start_date': Date.to_string(date),
         'end_date': Date.to_string(date + timedelta(days=1)),
     }).run()
     self.assertFalse(self.env['medical.guard'].search([
         ('plan_guard_id', '=', plan.id)
     ]))
     plan.monthday = '15-5'
     self.env['medical.guard.plan.apply'].create({
         'start_date': Date.to_string(date),
         'end_date': Date.to_string(date + timedelta(days=1)),
     }).run()
     self.assertTrue(self.env['medical.guard'].search([
         ('plan_guard_id', '=', plan.id)
     ]))
 def test_forecast_period_on_contract_line_update_7(self):
     self.acct_line.write({
         'date_end': Date.today() + relativedelta(months=3),
         'recurring_rule_type': "monthlylastday",
         'recurring_invoicing_type': 'pre-paid',
         'is_auto_renew': True,
     })
     self.acct_line._onchange_date_start()
     self.assertTrue(self.acct_line.forecast_period_ids)
     self.assertEqual(len(self.acct_line.forecast_period_ids), 4)
Beispiel #26
0
 def test_company_constrain(self):
     with self.assertRaises(ValidationError):
         self.env["mis.cash_flow.forecast_line"].create({
             "account_id":
             self.account.id,
             "date":
             Date.today(),
             "balance":
             1000
         })
    def test_forecast_period_for_undefined_date_end_contract(self):
        """If a contract line have and undefined date end the forecast should
        continue to the company forecast period"""
        self.acct_line.contract_id.company_id.contract_forecast_interval = 36
        self.acct_line.write({
            'date_start': Date.today(),
            'recurring_next_date': Date.today(),
            'date_end': Date.today() + relativedelta(years=1),
            'recurring_rule_type': "monthlylastday",
            'last_date_invoiced': False,
            'recurring_invoicing_type': 'pre-paid',
            'is_auto_renew': False,
        })
        self.assertTrue(self.acct_line.forecast_period_ids)
        self.assertEqual(len(self.acct_line.forecast_period_ids), 13)

        self.acct_line.write({'date_end': False})
        self.assertTrue(self.acct_line.forecast_period_ids)
        self.assertEqual(len(self.acct_line.forecast_period_ids), 37)
 def test_locking(self):
     vals = {
         'journal_ids': [(4, self.cust_invoices_journal.id, 0)],
         'date_start': Date.to_string(datetime.now() - timedelta(days=365)),
         'date_end': Date.today(),
     }
     lock_wiz = self.env['lock.account.move'].create(vals)
     lock_wiz.lock_move({})
     for move in self.entries:
         self.assertTrue(move.locked)
Beispiel #29
0
    def setUp(self):
        res = super().setUp()
        collection = _PseudoCollection("emc.services", self.env)
        emc_services_env = WorkContext(model_name="rest.service.registration",
                                       collection=collection)
        self.ai_service = emc_services_env.component(usage="invoice")

        self.share_type_A = self.browse_ref(
            "easy_my_coop.product_template_share_type_1_demo")
        self._capital_release_create()

        today = Date.to_string(Date.today())
        self.demo_invoice_dict = {
            "id":
            1,
            "name":
            "Capital Release Example",
            "partner": {
                "id": 1,
                "name": "Catherine des Champs"
            },
            "account": {
                "id": 1,
                "name": "Cooperators"
            },
            "journal": {
                "id": 1,
                "name": "Subscription Journal"
            },
            "subscription_request": {},
            "state":
            "open",
            "date":
            today,
            "date_invoice":
            today,
            "date_due":
            today,
            "type":
            "out_invoice",
            "invoice_lines": [{
                "name": "Share Type A",
                "product": {
                    "id": 1,
                    "name": "Part A - Founder"
                },
                "price_unit": 100.0,
                "quantity": 2.0,
                "account": {
                    "id": 2,
                    "name": "Equity"
                },
            }],
        }
        return res
Beispiel #30
0
    def test_check_dob(self):
        """
        Data de nascimento maior do que hoje.
        """
        self.employee_dependent.write(
            {"dependent_dob": Date.today() + relativedelta(days=1)})

        with self.assertRaises(ValidationError) as context:
            self.employee._check_dob()

        self.assertEqual("Invalid birth date for dependent Dependent 01",
                         context.exception.name)
Beispiel #31
0
 def test_completion(self):
     guard = self.env["medical.guard"].create({
         "product_id": self.product.id,
         "location_id": self.center.id,
         "date": Datetime.now(),
         "delay": 1,
     })
     self.assertEqual(guard.state, "draft")
     with self.assertRaises(ValidationError):
         guard.complete()
     guard.practitioner_id = self.practitioner
     guard.complete()
     self.assertEqual(guard.state, "completed")
     self.assertFalse(guard.invoice_line_ids)
     self.env["medical.guard.invoice"].create({
         "date_from": Date.today(),
         "date_to": Date.today()
     }).run()
     guard.refresh()
     self.assertTrue(guard.invoice_line_ids)
     self.assertEqual(guard.invoice_line_ids.invoice_id.amount_untaxed, 100)
Beispiel #32
0
    def setUp(self):
        super(TestTheoreticalAmount, self).setUp()
        #create the budgetary position
        user_type_id = self.ref('account.data_account_type_revenue')
        tag_id = self.ref('account.account_tag_operating')
        account_rev = self.env['account.account'].create({
            'code': 'Y2020',
            'name': 'Budget - Test Revenue Account',
            'user_type_id': user_type_id,
            'tag_ids': [(4, tag_id, 0)]
        })
        buget_post = self.env['account.budget.post'].create({
            'name': 'Sales',
            'account_ids': [(4, account_rev.id, 0)],
        })
        #create the budget and budget lines
        first_january = Datetime.now().replace(day=1, month=1)
        self.last_day_of_budget = first_january + timedelta(days=364)  # will be 30th of December or 31th in case of leap year

        date_from = first_january.date()
        date_to = self.last_day_of_budget.date()

        crossovered_budget = self.env['crossovered.budget'].create({
            'name': 'test budget name',
            'date_from': date_from,
            'date_to': date_to,
        })
        crossovered_budget_line_obj = self.env['crossovered.budget.lines']
        self.line = crossovered_budget_line_obj.create({
            'crossovered_budget_id': crossovered_budget.id,
            'general_budget_id': buget_post.id,
            'date_from': date_from,
            'date_to': date_to,
            'planned_amount': -364,
        })
        self.paid_date_line = crossovered_budget_line_obj.create({
            'crossovered_budget_id': crossovered_budget.id,
            'general_budget_id': buget_post.id,
            'date_from': date_from,
            'date_to': date_to,
            'planned_amount': -364,
            'paid_date':  Date.today().replace(day=9, month=9),
        })

        self.patcher = patch('odoo.addons.account_budget.models.account_budget.fields.Date', wraps=Date)
        self.mock_date = self.patcher.start()
Beispiel #33
0
    def setUp(self):
        super(TestPayslipBase, self).setUp()

        # Some salary rules references
        self.hra_rule_id = self.ref('hr_payroll.hr_salary_rule_houserentallowance1')
        self.conv_rule_id = self.ref('hr_payroll.hr_salary_rule_convanceallowance1')
        self.prof_tax_rule_id = self.ref('hr_payroll.hr_salary_rule_professionaltax1')
        self.pf_rule_id = self.ref('hr_payroll.hr_salary_rule_providentfund1')
        self.mv_rule_id = self.ref('hr_payroll.hr_salary_rule_meal_voucher')
        self.comm_rule_id = self.ref('hr_payroll.hr_salary_rule_sales_commission')

        # I create a new employee "Richard"
        self.richard_emp = self.env['hr.employee'].create({
            'name': 'Richard',
            'gender': 'male',
            'birthday': '1984-05-01',
            'country_id': self.ref('base.be'),
            'department_id': self.ref('hr.dep_rd')
        })

        # I create a salary structure for "Software Developer"
        self.developer_pay_structure = self.env['hr.payroll.structure'].create({
            'name': 'Salary Structure for Software Developer',
            'code': 'SD',
            'company_id': self.ref('base.main_company'),
            'rule_ids': [(4, self.hra_rule_id), (4, self.conv_rule_id),
                         (4, self.prof_tax_rule_id), (4, self.pf_rule_id),
                         (4, self.mv_rule_id), (4, self.comm_rule_id)],
        })

        # I create a contract for "Richard"
        self.env['hr.contract'].create({
            'date_end': Date.to_string((datetime.now() + timedelta(days=365))),
            'date_start': Date.today(),
            'name': 'Contract for Richard',
            'wage': 5000.0,
            'type_id': self.ref('hr_contract.hr_contract_type_emp'),
            'employee_id': self.richard_emp.id,
            'struct_id': self.developer_pay_structure.id,
        })