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())
def _print_preview(self): # Get the last opened date sale = self.store.find(Sale).order_by(Sale.identifier).last() if not sale: info(_("You need at least one sale to be able to preview " "invoice layouts")) return invoice = SaleInvoice(sale, self.model) invoice_pages = invoice.generate_pages() if not invoice_pages: info(_(u'Not enough fields or data to create an invoice preview.')) return for page in invoice_pages: for line in page: print(repr(line.tostring()))
def test_invoice_without_client(self): sale = self.create_sale() for i in range(10): price = 50 + i code = str(1000 + i) self._add_product(sale, tax=18, price=price, code=code) sale.order(self.current_user) self._add_payments(sale) sale.confirm(self.current_user) layout = self.store.find(InvoiceLayout).one() layout.continuous_page = True invoice = SaleInvoice(sale, layout) invoice.today = datetime.datetime(2007, 1, 1, 10, 20, 30) try: compare_invoice_file(invoice, 'sale-invoice-without-client') except AssertionError as e: self.fail(e)
def _print_invoice(self): sale_view = self.results.get_selected() assert sale_view sale = sale_view.sale station = api.get_current_station(self.store) printer = InvoicePrinter.get_by_station(station, self.store) if printer is None: info(_("There are no invoice printer configured for this station")) return assert printer.layout invoice = SaleInvoice(sale, printer.layout) if not invoice.has_invoice_number() or sale.invoice.invoice_number: print_sale_invoice(invoice, printer) else: store = api.new_store() retval = self.run_dialog(SaleInvoicePrinterDialog, store, store.fetch(sale), printer) store.confirm(retval) store.close()
def test_invoice_without_client(self): sale = self.create_sale() for i in range(10): price = 50 + i code = unicode(1000 + i) self._add_product(sale, tax=18, price=price, code=code) sale.order() self._add_payments(sale) sale.confirm() layout = self.store.find(InvoiceLayout).one() layout.continuous_page = True invoice = SaleInvoice(sale, layout) invoice.today = datetime.datetime(2007, 1, 1, 10, 20, 30) try: compare_invoice_file(invoice, 'sale-invoice-without-client') except AssertionError as e: self.fail(e)
def _print_invoice(self): sale_view = self.results.get_selected() assert sale_view sale = sale_view.sale station = api.get_current_station(self.store) printer = InvoicePrinter.get_by_station(station, self.store) if printer is None: info(_("There are no invoice printer configured for this station")) return assert printer.layout invoice = SaleInvoice(sale, printer.layout) if not invoice.has_invoice_number() or sale.invoice_number: print_sale_invoice(invoice, printer) else: store = api.new_store() retval = self.run_dialog(SaleInvoicePrinterDialog, store, store.fetch(sale), printer) store.confirm(retval) store.close()
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())
def testSaleInvoice(self): sale = self.create_sale() for i in range(10): price = 50 + i code = unicode(1000 + i) self._add_product(sale, tax=18, price=price, code=code) 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) invoice.today = datetime.datetime(2007, 1, 1, 10, 20, 30) try: compare_invoice_file(invoice, 'sale-invoice') except AssertionError as e: self.fail(e)
def test_sale_invoice(self): sale = self.create_sale() for i in range(10): price = 50 + i code = unicode(1000 + i) self._add_product(sale, tax=18, price=price, code=code) 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) invoice.today = datetime.datetime(2007, 1, 1, 10, 20, 30) try: compare_invoice_file(invoice, 'sale-invoice') except AssertionError as e: self.fail(e)
def on_confirm(self): invoice = SaleInvoice(self.model, self._printer.layout) print_sale_invoice(invoice, self._printer)