Beispiel #1
0
 def print_quote_details(self, model, payments_created=False):
     msg = _('Would you like to print the quote details now?')
     # We can only print the details if the quote was confirmed.
     if yesno(msg, Gtk.ResponseType.YES, _("Print quote details"),
              _("Don't print")):
         orders = WorkOrder.find_by_sale(self.model.store, self.model)
         print_report(OpticalWorkOrderReceiptReport, list(orders))
Beispiel #2
0
 def _print_test_bill(self):
     try:
         bank_info = get_bank_info_by_number(self.bank_model.bank_number)
     except NotImplementedError:
         info(_("This bank does not support printing of bills"))
         return
     kwargs = dict(
         valor_documento=12345.67,
         data_vencimento=datetime.date.today(),
         data_documento=datetime.date.today(),
         data_processamento=datetime.date.today(),
         nosso_numero=u'24533',
         numero_documento=u'1138',
         sacado=[_(u"Drawee"), _(u"Address"),
                 _(u"Details")],
         cedente=[_(u"Supplier"),
                  _(u"Address"),
                  _(u"Details"), ("CNPJ")],
         demonstrativo=[_(u"Demonstration")],
         instrucoes=[_(u"Instructions")],
         agencia=self.bank_model.bank_branch,
         conta=self.bank_model.bank_account,
     )
     for opt in self.bank_model.options:
         kwargs[opt.option] = opt.value
     data = bank_info(**kwargs)
     print_report(BillTestReport, data)
Beispiel #3
0
    def _print_report(self):
        if self.model.status == PurchaseOrder.ORDER_QUOTING:
            report = PurchaseQuoteReport
        else:
            report = PurchaseOrderReport

        print_report(report, self.model)
Beispiel #4
0
    def on_print_booklets__clicked(self, button):
        # Remove cancelled and not store_credit payments
        payments = [
            p for p in self.payments_list if
            p.method.method_name == u'store_credit' and not p.is_cancelled()
        ]

        print_report(BookletReport, payments)
Beispiel #5
0
 def on_PrintReceipt__activate(self, action):
     payment_views = self.results.get_selected_rows()
     payments = [v.payment for v in payment_views]
     date = localtoday().date()
     print_report(OutPaymentReceipt,
                  payment=payments[0],
                  order=payment_views[0].purchase,
                  date=date)
Beispiel #6
0
    def _print_transaction_report(self):
        assert not self._is_accounts_tab()

        page = self.get_current_page()
        print_report(AccountTransactionReport,
                     page.result_view,
                     list(page.result_view),
                     account=page.model,
                     filters=page.search.get_search_filters())
Beispiel #7
0
    def print_report(self):
        salesperson_id = self._salesperson_filter.combo.get_selected()
        salesperson = (salesperson_id
                       and self.store.get(SalesPerson, salesperson_id))

        print_report(self.report_class,
                     list(self.results),
                     salesperson=salesperson,
                     filters=self.search.get_search_filters())
Beispiel #8
0
    def _on_PrintReportEvent(self, report_class, *args, **kwargs):
        if issubclass(report_class, SaleOrderReport):
            sale = args[0]
            store = sale.store
            workorders = list(WorkOrder.find_by_sale(store, sale))
            if len(workorders):
                print_report(OpticalWorkOrderReceiptReport, workorders)
                return True

        return False
Beispiel #9
0
    def on_print_bills__clicked(self, button):
        # Remove cancelled and not bill payments
        payments = [
            p for p in self.payments_list
            if p.method.method_name == u'bill' and not p.is_cancelled()
        ]

        if not BillReport.check_printable(payments):
            return False

        print_report(BillReport, payments)
    def confirm(self):
        DateRangeDialog.confirm(self)
        start = self.retval.start
        end = self.retval.end

        results = PaymentFlowDay.get_flow_history(self.store, start, end)
        if not results:
            info(_('No payment history found.'))
            return False

        print_report(PaymentFlowHistoryReport, payment_histories=results)
        return True
Beispiel #11
0
    def print_quote_details(self, quote, payments_created=False):
        already_printed = SaleQuoteFinishPrintEvent.emit(self.model)
        if already_printed is not None:
            return
        msg_list = []
        if not quote.group.payments.is_empty():
            msg_list.append(
                _('The created payments can be found in the Accounts '
                  'Receivable application and you can set them as paid '
                  'there at any time.'))
        msg_list.append(_('Would you like to print the quote details now?'))

        # We can only print the details if the quote was confirmed.
        if yesno('\n\n'.join(msg_list), Gtk.ResponseType.YES,
                 _("Print quote details"), _("Don't print")):
            print_report(SaleOrderReport, self.model)
Beispiel #12
0
    def finish(self):
        invoice_ok = InvoiceSetupEvent.emit()
        if invoice_ok is False:
            # If there is any problem with the invoice, the event will display an error
            # message and the dialog is kept open so the user can fix whatever is wrong.
            return

        login_user = api.get_current_user(self.store)
        self.model.return_(login_user, method_name=u'credit' if self.credit else u'money')
        SaleReturnWizardFinishEvent.emit(self.model)
        self.retval = self.model
        self.close()

        # Commit before printing to avoid losing data if something breaks
        self.store.confirm(self.retval)
        if self.credit:
            if yesno(_(u'Would you like to print the credit letter?'),
                     Gtk.ResponseType.YES, _(u"Print Letter"), _(u"Don't print")):
                print_report(ClientCreditReport, self.model.client)
Beispiel #13
0
 def on_PrintDocument__activate(self, action):
     view = self.results.get_selected_rows()[0]
     payments = [view.payment]
     report = view.operation.print_(payments)
     if report is not None:
         print_report(report, payments)
Beispiel #14
0
 def on_PrintReceipt__activate(self, action):
     receivable_view = self.results.get_selected_rows()[0]
     payment = receivable_view.payment
     date = localtoday().date()
     print_report(InPaymentReceipt, payment=payment,
                  order=receivable_view.sale, date=date)
Beispiel #15
0
 def on_print_price_button_clicked(self, button):
     print_report(ServicePriceReport, list(self.results),
                  filters=self.search.get_search_filters())
Beispiel #16
0
 def print_report(self):
     print_report(self.report_class,
                  self.results,
                  list(self.results.iter_items(include_parents=True)),
                  filters=self.search.get_search_filters())
Beispiel #17
0
 def on_print_price_button_clicked(self, button):
     print_report(ProductPriceReport,
                  list(self.results),
                  filters=self.search.get_search_filters(),
                  branch_name=self.branch_filter.combo.get_selected_label())
Beispiel #18
0
 def _print_button_clicked(self, button):
     print_report(TillHistoryReport, self.results, list(self.results),
                  filters=self.search.get_search_filters())
Beispiel #19
0
 def on_print_button__clicked(self, widget):
     branch = self.model.branch
     daterange = self.get_daterange()
     print_report(TillDailyMovementReport, self.store, branch, daterange,
                  self)
Beispiel #20
0
 def print_report(self):
     print_report(self.report_class,
                  self.results,
                  list(self.results),
                  filters=self.search.get_search_filters())
Beispiel #21
0
 def print_sale_details(self):
     if yesno(_("Do you want to print this sale's details?"),
              Gtk.ResponseType.YES, _("Print Details"), _("Don't Print")):
         print_report(SaleOrderReport, self.model)
Beispiel #22
0
 def _print_receipt(self, order):
     # we can only print the receipt if the loan was confirmed.
     if yesno(_('Would you like to print the receipt now?'),
              Gtk.ResponseType.YES, _("Print receipt"), _("Don't print")):
         print_report(LoanReceipt, order)
Beispiel #23
0
 def on_print_credit_letter__clicked(self, button):
     print_report(ClientCreditReport, self.model)
Beispiel #24
0
 def on_print_button__clicked(self, button):
     print_report(PurchaseOrderReport, self.model)
Beispiel #25
0
    def confirm(self, sale, store, savepoint=None, subtotal=None):
        """Confirms a |sale| on fiscalprinter and database

        If the sale is confirmed, the store will be committed for you.
        There's no need for the callsite to call store.confirm().
        If the sale is not confirmed, for instance the user cancelled the
        sale or there was a problem with the fiscal printer, then the
        store will be rolled back.

        :param sale: the |sale| to be confirmed
        :param trans: a store
        :param savepoint: if specified, a database savepoint name that
            will be used to rollback to if the sale was not confirmed.
        :param subtotal: the total value of all the items in the sale
        """
        # Actually, we are confirming the sale here, so the sale
        # confirmation process will be available to others applications
        # like Till and not only to the POS.
        payments_total = sale.group.get_total_confirmed_value()
        sale_total = sale.get_total_sale_amount()

        payment = get_formatted_price(payments_total)
        amount = get_formatted_price(sale_total)
        msg = _(u"Payment value (%s) is greater than sale's total (%s). "
                "Do you want to confirm it anyway?") % (payment, amount)
        if (sale_total < payments_total
                and not yesno(msg, Gtk.ResponseType.NO, _(u"Confirm Sale"),
                              _(u"Don't Confirm"))):
            return False

        model = run_dialog(ConfirmSaleWizard,
                           self._parent,
                           store,
                           sale,
                           subtotal=subtotal,
                           total_paid=payments_total,
                           current_document=self._current_document)

        if not model:
            CancelPendingPaymentsEvent.emit()
            store.rollback(name=savepoint, close=False)
            return False

        if sale.client and not self.is_customer_identified():
            self.identify_customer(sale.client.person)

        try:
            if not self.totalize(sale):
                store.rollback(name=savepoint, close=False)
                return False

            if not self.setup_payments(sale):
                store.rollback(name=savepoint, close=False)
                return False

            if not self.close(sale, store):
                store.rollback(name=savepoint, close=False)
                return False

            if not self.print_receipts(sale):
                store.rollback(name=savepoint, close=False)
                return False

            # FIXME: This used to be done inside sale.confirm. Maybe it would
            # be better to do a proper error handling
            till = Till.get_current(store, api.get_current_station(store))
            assert till
            sale.confirm(api.get_current_user(store), till=till)

            # Only finish the transaction after everything passed above.
            store.confirm(model)
        except Exception as e:
            traceback.print_exception(*sys.exc_info())
            message = _("An error happened while trying to confirm the sale.")
            # Just cancel the sale if the coupon is actually being used.
            if get_plugin_manager().is_active('ecf'):
                warning(message + ' ' + _("Cancelling the coupon now..."),
                        str(e))
                self.cancel()
                store.rollback(name=savepoint, close=False)
                return False
            warning(_(message), str(e))

        print_cheques_for_payment_group(store, sale.group)

        # Try to print only after the transaction is commited, to prevent
        # losing data if something fails while printing
        group = sale.group
        booklets = list(group.get_payments_by_method_name(u'store_credit'))
        bills = list(group.get_payments_by_method_name(u'bill'))

        if (booklets and yesno(
                _("Do you want to print the booklets for this sale?"),
                Gtk.ResponseType.YES, _("Print booklets"), _("Don't print"))):
            try:
                print_report(BookletReport, booklets)
            except ReportError:
                warning(_("Could not print booklets"))

        if (bills and BillReport.check_printable(bills) and yesno(
                _("Do you want to print the bills for this sale?"),
                Gtk.ResponseType.YES, _("Print bills"), _("Don't print"))):
            try:
                print_report(BillReport, bills)
            except ReportError:
                # TRANSLATORS: bills here refers to "boletos" in pt_BR
                warning(_("Could not print bills"))

        return True
Beispiel #26
0
 def _receipt_dialog(self):
     msg = _('Would you like to print a receipt?')
     if yesno(msg, Gtk.ResponseType.YES, _("Print receipt"),
              _("Don't print")):
         print_report(StockDecreaseReceipt, self.model)
 def on_print_button__clicked(self, button):
     print_report(self.report_class, self.model)
Beispiel #28
0
 def on_print_button__clicked(self, widget):
     print_report(ProductionOrderReport, self.model)
Beispiel #29
0
    def print_report(self, report_class, *args, **kwargs):
        filters = self.search.get_search_filters()
        if filters:
            kwargs['filters'] = filters

        print_report(report_class, *args, **kwargs)
Beispiel #30
0
 def _on_print_button__clicked(self, widget):
     print_report(CallsReport,
                  self.results,
                  list(self.results),
                  filters=self.search.get_search_filters(),
                  person=self.person)