Example #1
0
    def test_salary_history(self, run_dialog):
        client = self.create_client()
        slave = ClientCreditSlave(self.store, client)

        self.click(slave.salary_history_button)
        run_dialog.assert_called_once_with(ClientSalaryHistorySearch,
                                           slave.get_toplevel().get_toplevel(),
                                           self.store,
                                           client=client)
Example #2
0
    def test_credit_transactions(self, run_dialog):
        client = self.create_client()
        slave = ClientCreditSlave(self.store, client)

        self.click(slave.credit_transactions_button)
        run_dialog.assert_called_once_with(CreditInfoListDialog,
                                           slave.get_toplevel().get_toplevel(),
                                           self.store,
                                           client,
                                           reuse_store=True)
Example #3
0
    def test_credit_limit_update(self):
        sysparam.set_decimal(self.store, "CREDIT_LIMIT_SALARY_PERCENT",
                             Decimal(10))

        client = self.create_client()
        client.salary = 50
        slave = ClientCreditSlave(self.store, client)
        slave.salary.emit('changed')
        self.assertEqual(slave.credit_limit.read(), 5)

        # checks if credit limit updated correctly when salary changes
        # and parameter salary percent is not 0
        slave.salary.update(100)
        slave.salary.emit('changed')
        self.assertEqual(slave.credit_limit.read(), 10)

        sysparam.set_decimal(self.store, "CREDIT_LIMIT_SALARY_PERCENT",
                             Decimal(0))

        # checks if credit limit does not update (correct behavior)
        # when salary percent is 0 and salary changes
        credit_limit = 0
        client.credit_limit = credit_limit
        slave.credit_limit.update(credit_limit)
        slave.credit_limit.emit('changed')

        slave.salary.update(200)
        slave.salary.emit('changed')

        self.assertEqual(slave.credit_limit.read(), credit_limit)
Example #4
0
    def test_credit_limit_active(self):
        sysparam.set_decimal(self.store, "CREDIT_LIMIT_SALARY_PERCENT",
                             Decimal(10))

        client = self.create_client()
        slave = ClientCreditSlave(self.store, client)

        # if CREDIT_LIMIT_SALARY_PERCENT is higher than 0, credit limit
        # should not be editable
        self.assertNotSensitive(slave, ['credit_limit'])

        # if salary percent is 0 credit limit should be editable
        sysparam.set_decimal(self.store, "CREDIT_LIMIT_SALARY_PERCENT",
                             Decimal(0))
        slave = ClientCreditSlave(self.store, client)
        self.assertSensitive(slave, ['credit_limit'])
Example #5
0
    def test_print_credit_letter(self, print_report):
        client = self.create_client()
        slave = ClientCreditSlave(self.store, client)

        self.click(slave.print_credit_letter)

        print_report.assert_called_once_with(ClientCreditReport, client)
Example #6
0
    def test_salary_validate(self):
        client = self.create_client()
        slave = ClientCreditSlave(self.store, client)

        # checks a valid salary
        self.assertEqual(None, slave.salary.emit('validate', 10))

        # checks invalid salary
        self.assertEqual("Salary can't be lower than 0.",
                         str(slave.salary.emit('validate', -10)))
Example #7
0
    def setup_slaves(self):
        BasePersonRoleEditor.setup_slaves(self)
        self.status_slave = ClientStatusSlave(self.store, self.model,
                                              visual_mode=self.visual_mode)
        self.main_slave.attach_person_slave(self.status_slave)

        credit_slave = ClientCreditSlave(self.store, self.model,
                                         visual_mode=self.visual_mode,
                                         edit_mode=self.edit_mode)
        self.main_slave._person_slave.add_extra_tab(_('Credit Details'),
                                                    credit_slave)
Example #8
0
    def test_credit_limit_validate(self):
        client = self.create_client()
        slave = ClientCreditSlave(self.store, client)

        # checks a valid credit limit
        self.assertEqual(None, slave.credit_limit.emit('validate', 10))
        self.assertEqual(None, slave.credit_limit.emit('validate', 0))

        # checks invalid credit limit
        self.assertEqual("Credit limit must be greater than or equal to 0",
                         str(slave.credit_limit.emit('validate', -10)))