コード例 #1
0
ファイル: test_invoice.py プロジェクト: fibbarth/stoq
    def test_has_invoice_number(self):
        sale = self.create_sale()
        for i in range(10):
            self._add_product(sale, tax=18, price=50 + i)

        sale.order()
        self._add_payments(sale)
        sale.confirm()
        sale.client = self.create_client()
        address = self.create_address()
        address.person = sale.client.person

        layout = self.store.find(InvoiceLayout).one()
        invoice = SaleInvoice(sale, layout)
        self.assertFalse(invoice.has_invoice_number())

        field = self.store.find(InvoiceField, field_name=u'INVOICE_NUMBER').one()
        if field is None:
            field = InvoiceField(x=0, y=0, width=6, height=1, layout=layout,
                                 field_name=u'INVOICE_NUMBER',
                                 store=self.store)
        else:
            field.layout = layout

        new_invoice = SaleInvoice(sale, layout)
        self.assertTrue(new_invoice.has_invoice_number())
コード例 #2
0
ファイル: test_invoice.py プロジェクト: tmaxter/stoq
    def testHasInvoiceNumber(self):
        sale = self.create_sale()
        for i in range(10):
            self._add_product(sale, tax=18, price=50 + i)

        sale.order()
        self._add_payments(sale)
        sale.confirm()
        sale.client = self.create_client()
        address = self.create_address()
        address.person = sale.client.person

        layout = self.store.find(InvoiceLayout).one()
        invoice = SaleInvoice(sale, layout)
        self.assertFalse(invoice.has_invoice_number())

        field = self.store.find(InvoiceField,
                                field_name=u'INVOICE_NUMBER').one()
        if field is None:
            field = InvoiceField(x=0,
                                 y=0,
                                 width=6,
                                 height=1,
                                 layout=layout,
                                 field_name=u'INVOICE_NUMBER',
                                 store=self.store)
        else:
            field.layout = layout

        new_invoice = SaleInvoice(sale, layout)
        self.assertTrue(new_invoice.has_invoice_number())
コード例 #3
0
 def test_fields(self):
     layout = self.create_layout()
     self.assertTrue(layout.fields.is_empty())
     field = InvoiceField(layout=layout, x=0, y=0, width=1, height=1,
                          field_name=u'field',
                          store=self.store)
     self.assertFalse(layout.fields.is_empty())
     self.assertTrue(field in layout.fields)
     self.assertEqual([field], list(layout.fields))
コード例 #4
0
ファイル: invoiceeditor.py プロジェクト: sarkis89/stoq
 def _field_added(self, grid_field):
     if grid_field.model:
         return
     field = InvoiceField(layout=self.model,
                          field_name=grid_field.name,
                          x=grid_field.x,
                          y=grid_field.y,
                          width=grid_field.width,
                          height=grid_field.height,
                          store=self.store)
     grid_field.model = field
コード例 #5
0
ファイル: test_invoice.py プロジェクト: rosalin/stoq
 def test_get_field_by_name(self):
     layout = self.create_layout()
     self.failIf(layout.get_field_by_name(u'field'))
     InvoiceField(layout=layout,
                  x=0,
                  y=0,
                  width=1,
                  height=1,
                  field_name=u'field',
                  store=self.store)
     field = layout.get_field_by_name(u'field')
     self.failUnless(field)
     self.assertEquals(field.field_name, u'field')
コード例 #6
0
    def process_one(self, data, fields, store):
        layout = self._get_or_create(
            InvoiceLayout, store,
            description=data.layout_description,
            width=int(data.layout_width),
            height=int(data.layout_height))

        InvoiceField(layout=layout,
                     field_name=data.field_name,
                     x=int(data.field_x),
                     y=int(data.field_y),
                     width=int(data.field_width),
                     height=int(data.field_height),
                     store=store)
コード例 #7
0
ファイル: invoiceeditor.py プロジェクト: tmaxter/stoq
 def _field_added(self, grid_field):
     field = self.model.get_field_by_name(grid_field.text)
     if field is not None:
         field.x = grid_field.x
         field.y = grid_field.y
         field.width = grid_field.width
         field.height = grid_field.height
     else:
         field = InvoiceField(layout=self.model,
                              field_name=grid_field.text,
                              x=grid_field.x,
                              y=grid_field.y,
                              width=grid_field.width,
                              height=grid_field.height,
                              store=self.store)
     grid_field.model = field
コード例 #8
0
ファイル: test_sales.py プロジェクト: prohealthbox/stoq
    def test_print_invoice(self, info, print_sale_invoice, run_dialog,
                           new_store):
        new_store.return_value = self.store

        app = self.create_app(SalesApp, u'sales')
        results = app.results
        results.select(results[0])

        self.activate(app.SalesPrintInvoice)
        info.assert_called_once_with(
            u"There are no invoice printer configured "
            u"for this station")

        layout = InvoiceLayout(description=u'layout',
                               width=10,
                               height=20,
                               store=self.store)
        printer = InvoicePrinter(store=self.store,
                                 description=u'test invoice',
                                 layout=layout,
                                 device_name=u'/dev/lp0',
                                 station=api.get_current_station(self.store))
        self.activate(app.SalesPrintInvoice)
        self.assertEquals(print_sale_invoice.call_count, 1)
        args, kwargs = print_sale_invoice.call_args
        invoice, called_printer = args
        self.assertTrue(isinstance(invoice, SaleInvoice))
        self.assertEquals(printer, called_printer)

        results[0].sale.invoice.invoice_number = None
        InvoiceField(layout=layout,
                     x=0,
                     y=0,
                     width=1,
                     height=1,
                     field_name=u'INVOICE_NUMBER',
                     store=self.store)
        with mock.patch.object(self.store, 'commit'):
            with mock.patch.object(self.store, 'close'):
                self.activate(app.SalesPrintInvoice)
                run_dialog.assert_called_once_with(SaleInvoicePrinterDialog,
                                                   self.store, results[0].sale,
                                                   printer)
コード例 #9
0
ファイル: invoicedialog.py プロジェクト: tmaxter/stoq
 def delete_model(self, model, store):
     for field in model.fields:
         InvoiceField.delete(field.id, store)
     ModelListDialog.delete_model(self, model, store)
コード例 #10
0
ファイル: invoiceeditor.py プロジェクト: leandrorchaves/stoq
 def _field_removed(self, grid_field):
     invoice_field = grid_field.model
     InvoiceField.delete(invoice_field.id, self.store)
コード例 #11
0
ファイル: invoiceeditor.py プロジェクト: tmaxter/stoq
 def _field_removed(self, grid_field):
     invoice_field = grid_field.model
     InvoiceField.delete(invoice_field.id, self.store)
コード例 #12
0
ファイル: invoicedialog.py プロジェクト: leandrorchaves/stoq
 def delete_model(self, model, store):
     for field in model.fields:
         InvoiceField.delete(field.id, store)
     ModelListDialog.delete_model(self, model, store)