Esempio n. 1
0
 def __init__(self, store, branch: Branch, **kwargs):
     kwargs['invoice'] = Invoice(store=store,
                                 invoice_type=Invoice.TYPE_IN,
                                 branch=branch)
     super(ReturnedSale, self).__init__(store=store,
                                        branch=branch,
                                        **kwargs)
Esempio n. 2
0
 def __init__(self, store, branch: Branch, **kwargs):
     kwargs['invoice'] = Invoice(store=store,
                                 invoice_type=Invoice.TYPE_OUT,
                                 branch=branch)
     super(TransferOrder, self).__init__(store=store,
                                         branch=branch,
                                         **kwargs)
Esempio n. 3
0
 def __init__(self, store, branch: Branch, **kwargs):
     kwargs['invoice'] = Invoice(store=store,
                                 branch=branch,
                                 invoice_type=Invoice.TYPE_OUT)
     super(StockDecrease, self).__init__(store=store,
                                         branch=branch,
                                         **kwargs)
Esempio n. 4
0
    def setup_widgets(self):
        marker('Setting up widgets')
        # Only quotes have expire date.
        self.expire_date.hide()
        self.expire_label.hide()

        # Hide client category widgets
        self.client_category_lbl.hide()
        self.client_category.hide()

        # if the NF-e plugin is active, the client is mandantory in this
        # wizard (in this situation, we have only quote sales).
        if self.model.status == Sale.STATUS_QUOTE:
            manager = get_plugin_manager()
            mandatory_client = manager.is_active('nfe')
            self.client.set_property('mandatory', mandatory_client)

        marker('Filling sales persons')
        salespersons = self.store.find(SalesPerson)
        self.salesperson.prefill(api.for_person_combo(salespersons))
        marker('Finished filling sales persons')

        marker('Read parameter')
        change_salesperson = sysparam.get_int('ACCEPT_CHANGE_SALESPERSON')
        if change_salesperson == ChangeSalespersonPolicy.ALLOW:
            self.salesperson.grab_focus()
        elif change_salesperson == ChangeSalespersonPolicy.DISALLOW:
            self.salesperson.set_sensitive(False)
        elif change_salesperson == ChangeSalespersonPolicy.FORCE_CHOOSE:
            self.model.salesperson = None
            self.salesperson.grab_focus()
        else:
            raise AssertionError
        marker('Finished reading parameter')
        self._setup_clients_widget()
        self._fill_transporter_combo()
        self._fill_cost_center_combo()

        if sysparam.get_bool('ASK_SALES_CFOP'):
            self._fill_cfop_combo()
        else:
            self.cfop_lbl.hide()
            self.cfop.hide()
            self.create_cfop.hide()

        # the maximum number allowed for an invoice is 999999999.
        self.invoice_number.set_adjustment(
            gtk.Adjustment(lower=1, upper=999999999, step_incr=1))

        if not self.model.invoice_number:
            new_invoice_number = Invoice.get_next_invoice_number(self.store)
            self.invoice_model.invoice_number = new_invoice_number
        else:
            new_invoice_number = self.model.invoice_number
            self.invoice_model.invoice_number = new_invoice_number
            self.invoice_number.set_sensitive(False)

        self.invoice_model.original_invoice = new_invoice_number
        marker('Finished setting up widgets')
Esempio n. 5
0
    def setup_widgets(self):
        marker('Setting up widgets')
        # Only quotes have expire date.
        self.expire_date.hide()
        self.expire_label.hide()

        # Hide client category widgets
        self.client_category_lbl.hide()
        self.client_category.hide()

        # if the NF-e plugin is active, the client is mandantory in this
        # wizard (in this situation, we have only quote sales).
        if self.model.status == Sale.STATUS_QUOTE:
            manager = get_plugin_manager()
            mandatory_client = manager.is_active('nfe')
            self.client.set_property('mandatory', mandatory_client)

        marker('Filling sales persons')
        salespersons = self.store.find(SalesPerson)
        self.salesperson.prefill(api.for_person_combo(salespersons))
        marker('Finished filling sales persons')

        marker('Read parameter')
        change_salesperson = sysparam.get_int('ACCEPT_CHANGE_SALESPERSON')
        if change_salesperson == ChangeSalespersonPolicy.ALLOW:
            self.salesperson.grab_focus()
        elif change_salesperson == ChangeSalespersonPolicy.DISALLOW:
            self.salesperson.set_sensitive(False)
        elif change_salesperson == ChangeSalespersonPolicy.FORCE_CHOOSE:
            self.model.salesperson = None
            self.salesperson.grab_focus()
        else:
            raise AssertionError
        marker('Finished reading parameter')
        self._setup_clients_widget()
        self._fill_transporter_combo()
        self._fill_cost_center_combo()

        if sysparam.get_bool('ASK_SALES_CFOP'):
            self._fill_cfop_combo()
        else:
            self.cfop_lbl.hide()
            self.cfop.hide()
            self.create_cfop.hide()

        # the maximum number allowed for an invoice is 999999999.
        self.invoice_number.set_adjustment(
            gtk.Adjustment(lower=1, upper=999999999, step_incr=1))

        if not self.model.invoice_number:
            new_invoice_number = Invoice.get_next_invoice_number(self.store)
            self.invoice_model.invoice_number = new_invoice_number
        else:
            new_invoice_number = self.model.invoice_number
            self.invoice_model.invoice_number = new_invoice_number
            self.invoice_number.set_sensitive(False)

        self.invoice_model.original_invoice = new_invoice_number
        marker('Finished setting up widgets')
Esempio n. 6
0
    def _setup_widgets(self):
        self.main_dialog.ok_button.set_label(gtk.STOCK_PRINT)

        if self.model.invoice.invoice_number is not None:
            self.invoice_number.set_sensitive(False)
        else:
            next_invoice_number = Invoice.get_next_invoice_number(self.store)
            self.invoice_number.update(next_invoice_number)
Esempio n. 7
0
    def _setup_widgets(self):
        self.main_dialog.ok_button.set_label(gtk.STOCK_PRINT)

        if self.model.invoice.invoice_number is not None:
            self.invoice_number.set_sensitive(False)
        else:
            next_invoice_number = Invoice.get_next_invoice_number(self.store)
            self.invoice_number.update(next_invoice_number)
    def test_sale_return_invoice_step(self):
        main_branch = get_current_branch(self.store)
        sale = self.create_sale(branch=main_branch)
        self.add_product(sale)
        self.add_product(sale, quantity=2)
        self.add_payments(sale)
        sale.order()
        sale.confirm()
        returned_sale = sale.create_sale_return_adapter()
        wizard = SaleReturnWizard(self.store, returned_sale)
        self.click(wizard.next_button)
        step = wizard.get_current_step()

        self.check_wizard(wizard, 'wizard-sale-return-invoice-step')
        self.assertNotSensitive(wizard, ['next_button'])

        self.assertInvalid(step, ['reason'])
        step.reason.update(
            "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed\n"
            "do eiusmod tempor incididunt ut labore et dolore magna aliqua.")
        self.assertValid(step, ['reason'])

        # XXX: changed because invoice_number is no longer mandatory
        self.assertSensitive(wizard, ['next_button'])

        step.invoice_number.update(0)
        self.assertInvalid(step, ['invoice_number'])
        step.invoice_number.update(1000000000)
        self.assertInvalid(step, ['invoice_number'])
        self.assertNotSensitive(wizard, ['next_button'])

        # Check if the invoice number already exists in Invoice table
        invoice = Invoice(invoice_type=Invoice.TYPE_OUT, branch=main_branch)
        invoice.invoice_number = 123
        step.invoice_number.update(123)
        self.assertInvalid(step, ['invoice_number'])
        self.assertNotSensitive(wizard, ['next_button'])

        step.invoice_number.update(1)
        self.assertValid(step, ['invoice_number'])
        invoice.branch = self.create_branch()
        step.invoice_number.update(123)
        self.assertValid(step, ['invoice_number'])
        self.assertSensitive(wizard, ['next_button'])
Esempio n. 9
0
    def test_sale_return_invoice_step(self):
        main_branch = get_current_branch(self.store)
        sale = self.create_sale(branch=main_branch)
        self.add_product(sale)
        self.add_product(sale, quantity=2)
        self.add_payments(sale)
        sale.order()
        sale.confirm()
        returned_sale = sale.create_sale_return_adapter()
        wizard = SaleReturnWizard(self.store, returned_sale)
        self.click(wizard.next_button)
        step = wizard.get_current_step()

        self.check_wizard(wizard, 'wizard-sale-return-invoice-step')
        self.assertNotSensitive(wizard, ['next_button'])

        self.assertInvalid(step, ['reason'])
        step.reason.update(
            "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed\n"
            "do eiusmod tempor incididunt ut labore et dolore magna aliqua.")
        self.assertValid(step, ['reason'])

        # XXX: changed because invoice_number is no longer mandatory
        self.assertSensitive(wizard, ['next_button'])

        step.invoice_number.update(0)
        self.assertInvalid(step, ['invoice_number'])
        step.invoice_number.update(1000000000)
        self.assertInvalid(step, ['invoice_number'])
        self.assertNotSensitive(wizard, ['next_button'])

        # Check if the invoice number already exists in Invoice table
        invoice = Invoice(invoice_type=Invoice.TYPE_OUT, branch=main_branch)
        invoice.invoice_number = 123
        step.invoice_number.update(123)
        self.assertInvalid(step, ['invoice_number'])
        self.assertNotSensitive(wizard, ['next_button'])

        step.invoice_number.update(1)
        self.assertValid(step, ['invoice_number'])
        invoice.branch = self.create_branch()
        step.invoice_number.update(123)
        self.assertValid(step, ['invoice_number'])
        self.assertSensitive(wizard, ['next_button'])
Esempio n. 10
0
    def setup_proxies(self):
        manager = get_plugin_manager()
        nfe_is_active = manager.is_active('nfe')
        self.invoice_number.set_property('mandatory', nfe_is_active)

        # Set an initial invoice number.
        if not self.model.invoice_number:
            new_invoice_number = Invoice.get_next_invoice_number(self.store)
            self.model.invoice_number = new_invoice_number

        self.proxy = self.add_proxy(self.model, self.proxy_widgets)
Esempio n. 11
0
    def setup_proxies(self):
        manager = get_plugin_manager()
        nfe_is_active = manager.is_active('nfe')
        self.invoice_number.set_property('mandatory', nfe_is_active)

        # Set an initial invoice number.
        if not self.model.invoice_number:
            new_invoice_number = Invoice.get_next_invoice_number(self.store)
            self.model.invoice_number = new_invoice_number

        self.proxy = self.add_proxy(self.model, self.proxy_widgets)
Esempio n. 12
0
    def _setup_widgets(self):
        self.main_dialog.ok_button.set_label(Gtk.STOCK_PRINT)

        if self.model.invoice.invoice_number is not None:
            self.invoice_number.set_sensitive(False)
        else:
            # FIXME: This is for the old invoice printing infrastructure that is
            # no longer used. Remove this code when possible
            next_invoice_number = Invoice.get_next_invoice_number(self.store,
                                                                  series=1)
            self.invoice_number.update(next_invoice_number)
Esempio n. 13
0
    def _setup_widgets(self):
        self.main_dialog.ok_button.set_label(Gtk.STOCK_PRINT)

        if self.model.invoice.invoice_number is not None:
            self.invoice_number.set_sensitive(False)
        else:
            # FIXME: This is for the old invoice printing infrastructure that is
            # no longer used. Remove this code when possible
            next_invoice_number = Invoice.get_next_invoice_number(
                self.store, api.get_current_branch(self.store), series=1)
            self.invoice_number.update(next_invoice_number)
Esempio n. 14
0
    def _setup_widgets(self):
        branches = Branch.get_active_remote_branches(self.store)
        self.destination_branch.prefill(api.for_person_combo(branches))
        self.source_branch.set_text(self.branch.get_description())

        employees = self.store.find(Employee)
        self.source_responsible.prefill(api.for_person_combo(employees))

        self.invoice_number.set_property('mandatory', self._nfe_is_active)

        # Set an initial invoice number to TransferOrder and Invoice
        if not self.model.invoice_number:
            new_invoice_number = Invoice.get_next_invoice_number(self.store)
            self.model.invoice_number = new_invoice_number
Esempio n. 15
0
    def _setup_widgets(self):
        branches = Branch.get_active_remote_branches(self.store)
        self.destination_branch.prefill(api.for_person_combo(branches))
        self.source_branch.set_text(self.branch.get_description())

        employees = self.store.find(Employee)
        self.source_responsible.prefill(api.for_person_combo(employees))

        self.invoice_number.set_property('mandatory', self._nfe_is_active)

        # Set an initial invoice number to TransferOrder and Invoice
        if not self.model.invoice_number:
            new_invoice_number = Invoice.get_next_invoice_number(self.store)
            self.model.invoice_number = new_invoice_number
Esempio n. 16
0
    def test_get_next_invoice_number(self):
        with mock.patch('stoqlib.lib.pluginmanager.PluginManager.is_active'
                        ) as is_active:
            is_active.return_value = True
            main_branch = get_current_branch(self.store)
            sale = self.create_sale(branch=main_branch)
            sale.invoice.series = 1
            sale.invoice.invoice_number = 1234
            self.add_product(sale)
            self.add_payments(sale, u'money')
            sale.order()
            sale.confirm()

            last_invoice_number = Invoice.get_last_invoice_number(self.store,
                                                                  series=1)
            next_invoice_number = Invoice.get_next_invoice_number(self.store,
                                                                  series=1)
            self.assertEquals(last_invoice_number, 1234)
            self.assertEquals(next_invoice_number, 1235)

            # Creating a transfer order on same branch.
            transfer = self.create_transfer_order(source_branch=main_branch)
            transfer.invoice.series = 1
            transfer.invoice.invoice_number = next_invoice_number
            self.create_transfer_order_item(transfer)
            transfer.send()
            next_invoice_number = Invoice.get_next_invoice_number(self.store,
                                                                  series=1)
            self.assertEquals(transfer.invoice.invoice_number, 1235)
            self.assertEquals(next_invoice_number, 1236)

            # Creating a new sale and new tranfer on a different branch
            with mock.patch(
                    'stoqlib.domain.fiscal.get_current_branch') as get_branch:
                new_branch = self.create_branch()
                get_branch.return_value = new_branch
                new_sale = self.create_sale(branch=new_branch)
                new_sale.invoice.series = 1
                new_sale.invoice.invoice_number = 1234
                last_invoice_number = Invoice.get_last_invoice_number(
                    self.store, series=1)
                next_invoice_number = Invoice.get_next_invoice_number(
                    self.store, series=1)
                self.assertEquals(last_invoice_number, 1234)
                self.assertEquals(next_invoice_number, 1235)

                new_transfer = self.create_transfer_order(
                    source_branch=new_branch)
                new_transfer.invoice.series = 1
                new_transfer.invoice.invoice_number = next_invoice_number
                self.create_transfer_order_item(new_transfer)
                new_transfer.send()
                next_invoice_number = Invoice.get_next_invoice_number(
                    self.store, series=1)
                self.assertEquals(new_transfer.invoice.invoice_number, 1235)
                self.assertEquals(next_invoice_number, 1236)
Esempio n. 17
0
    def _setup_widgets(self):
        self.confirm_date.set_sensitive(False)
        self._fill_employee_combo()
        self._fill_branch_combo()
        self._fill_cfop_combo()
        self._fill_cost_center_combo()
        self._fill_person_combo()

        manager = get_plugin_manager()
        nfe_is_active = manager.is_active('nfe')
        self.invoice_number.set_property('mandatory', nfe_is_active)
        self.person.set_property('mandatory', nfe_is_active)

        if not self.model.invoice_number:
            new_invoice_number = Invoice.get_next_invoice_number(self.store)
            self.model.invoice_number = new_invoice_number

        if not sysparam.get_bool('CREATE_PAYMENTS_ON_STOCK_DECREASE'):
            self.create_payments.hide()
Esempio n. 18
0
    def _setup_widgets(self):
        self.confirm_date.set_sensitive(False)
        self._fill_employee_combo()
        self._fill_branch_combo()
        self._fill_cfop_combo()
        self._fill_cost_center_combo()
        self._fill_person_combo()

        manager = get_plugin_manager()
        nfe_is_active = manager.is_active('nfe')
        self.invoice_number.set_property('mandatory', nfe_is_active)
        self.person.set_property('mandatory', nfe_is_active)

        if not self.model.invoice_number:
            new_invoice_number = Invoice.get_next_invoice_number(self.store)
            self.model.invoice_number = new_invoice_number

        if not sysparam.get_bool('CREATE_PAYMENTS_ON_STOCK_DECREASE'):
            self.create_payments.hide()
Esempio n. 19
0
    def test_get_next_invoice_number(self):
        with mock.patch('stoqlib.lib.pluginmanager.PluginManager.is_active') as is_active:
            is_active.return_value = True
            main_branch = get_current_branch(self.store)
            sale = self.create_sale(branch=main_branch)
            sale.invoice.series = 1
            sale.invoice.invoice_number = 1234
            self.add_product(sale)
            self.add_payments(sale, u'money')
            sale.order()
            sale.confirm()

            last_invoice_number = Invoice.get_last_invoice_number(self.store,
                                                                  series=1)
            next_invoice_number = Invoice.get_next_invoice_number(self.store,
                                                                  series=1)
            self.assertEqual(last_invoice_number, 1234)
            self.assertEqual(next_invoice_number, 1235)

            # Creating a transfer order on same branch.
            transfer = self.create_transfer_order(source_branch=main_branch)
            transfer.invoice.series = 1
            transfer.invoice.invoice_number = next_invoice_number
            self.create_transfer_order_item(transfer)
            transfer.send()
            next_invoice_number = Invoice.get_next_invoice_number(self.store, series=1)
            self.assertEqual(transfer.invoice.invoice_number, 1235)
            self.assertEqual(next_invoice_number, 1236)

            # Creating a new sale and new tranfer on a different branch
            with mock.patch('stoqlib.domain.fiscal.get_current_branch') as get_branch:
                new_branch = self.create_branch()
                get_branch.return_value = new_branch
                new_sale = self.create_sale(branch=new_branch)
                new_sale.invoice.series = 1
                new_sale.invoice.invoice_number = 1234
                last_invoice_number = Invoice.get_last_invoice_number(self.store, series=1)
                next_invoice_number = Invoice.get_next_invoice_number(self.store, series=1)
                self.assertEqual(last_invoice_number, 1234)
                self.assertEqual(next_invoice_number, 1235)

                new_transfer = self.create_transfer_order(source_branch=new_branch)
                new_transfer.invoice.series = 1
                new_transfer.invoice.invoice_number = next_invoice_number
                self.create_transfer_order_item(new_transfer)
                new_transfer.send()
                next_invoice_number = Invoice.get_next_invoice_number(self.store, series=1)
                self.assertEqual(new_transfer.invoice.invoice_number, 1235)
                self.assertEqual(next_invoice_number, 1236)
Esempio n. 20
0
    def test_get_next_invoice_number(self):
        main_branch = get_current_branch(self.store)
        sale = self.create_sale(branch=main_branch)
        sale.invoice_number = 1234
        self.add_product(sale)
        self.add_payments(sale, u'money')
        sale.order()
        sale.confirm()

        # Test when the Invoice table is empty.
        self.store.execute(Update({Sale.invoice_id: None}, table=Sale))
        self.store.execute(
            Update({TransferOrder.invoice_id: None}, table=TransferOrder))
        self.clean_domain([Invoice])

        last_invoice_number = Invoice.get_last_invoice_number(self.store)
        next_invoice_number = Invoice.get_next_invoice_number(self.store)
        self.assertEquals(last_invoice_number, 1234)
        self.assertEquals(next_invoice_number, 1235)

        # Creating a transfer order on same branch.
        transfer = self.create_transfer_order(source_branch=main_branch)
        transfer.invoice_number = next_invoice_number
        self.create_transfer_order_item(transfer)
        transfer.send()
        next_invoice_number = Invoice.get_next_invoice_number(self.store)
        self.assertEquals(transfer.invoice.invoice_number, 1235)
        self.assertEquals(next_invoice_number, 1236)

        # Creating a new sale and new tranfer on a different branch
        with mock.patch(
                'stoqlib.domain.fiscal.get_current_branch') as get_branch:
            new_branch = self.create_branch()
            get_branch.return_value = new_branch
            new_sale = self.create_sale(branch=new_branch)
            new_sale.invoice_number = 1234
            last_invoice_number = Invoice.get_last_invoice_number(self.store)
            next_invoice_number = Invoice.get_next_invoice_number(self.store)
            self.assertEquals(last_invoice_number, 1234)
            self.assertEquals(next_invoice_number, 1235)

            new_transfer = self.create_transfer_order(source_branch=new_branch)
            new_transfer.invoice_number = next_invoice_number
            self.create_transfer_order_item(new_transfer)
            new_transfer.send()
            next_invoice_number = Invoice.get_next_invoice_number(self.store)
            self.assertEquals(new_transfer.invoice.invoice_number, 1235)
            self.assertEquals(next_invoice_number, 1236)
Esempio n. 21
0
    def test_get_next_invoice_number(self):
        main_branch = get_current_branch(self.store)
        sale = self.create_sale(branch=main_branch)
        sale.invoice_number = 1234
        self.add_product(sale)
        self.add_payments(sale, u'money')
        sale.order()
        sale.confirm()

        # Test when the Invoice table is empty.
        self.store.execute(Update({Sale.invoice_id: None}, table=Sale))
        self.store.execute(Update({TransferOrder.invoice_id: None},
                                  table=TransferOrder))
        self.clean_domain([Invoice])

        last_invoice_number = Invoice.get_last_invoice_number(self.store)
        next_invoice_number = Invoice.get_next_invoice_number(self.store)
        self.assertEquals(last_invoice_number, 1234)
        self.assertEquals(next_invoice_number, 1235)

        # Creating a transfer order on same branch.
        transfer = self.create_transfer_order(source_branch=main_branch)
        transfer.invoice_number = next_invoice_number
        self.create_transfer_order_item(transfer)
        transfer.send()
        next_invoice_number = Invoice.get_next_invoice_number(self.store)
        self.assertEquals(transfer.invoice.invoice_number, 1235)
        self.assertEquals(next_invoice_number, 1236)

        # Creating a new sale and new tranfer on a different branch
        with mock.patch('stoqlib.domain.fiscal.get_current_branch') as get_branch:
            new_branch = self.create_branch()
            get_branch.return_value = new_branch
            new_sale = self.create_sale(branch=new_branch)
            new_sale.invoice_number = 1234
            last_invoice_number = Invoice.get_last_invoice_number(self.store)
            next_invoice_number = Invoice.get_next_invoice_number(self.store)
            self.assertEquals(last_invoice_number, 1234)
            self.assertEquals(next_invoice_number, 1235)

            new_transfer = self.create_transfer_order(source_branch=new_branch)
            new_transfer.invoice_number = next_invoice_number
            self.create_transfer_order_item(new_transfer)
            new_transfer.send()
            next_invoice_number = Invoice.get_next_invoice_number(self.store)
            self.assertEquals(new_transfer.invoice.invoice_number, 1235)
            self.assertEquals(next_invoice_number, 1236)
Esempio n. 22
0
 def __init__(self, store, branch, **kwargs):
     kwargs['invoice'] = Invoice(store=store,
                                 branch=branch,
                                 invoice_type=Invoice.TYPE_OUT)
     super(Loan, self).__init__(store=store, branch=branch, **kwargs)
Esempio n. 23
0
 def __init__(self, store=None, **kwargs):
     kwargs['invoice'] = Invoice(store=store, invoice_type=Invoice.TYPE_OUT)
     super(TransferOrder, self).__init__(store=store, **kwargs)
Esempio n. 24
0
 def __init__(self, store=None, **kwargs):
     kwargs['invoice'] = Invoice(store=store, invoice_type=Invoice.TYPE_IN)
     super(ReturnedSale, self).__init__(store=store, **kwargs)