def _add_payment(self): assert self._method if not self._can_add_payment(): return if self._method.method_name == u'money': self._setup_cash_payment() # We are about to create payments, so we need to consider the fiscal # printer and its operations. # See salewizard.SalesPersonStep.on_next_step for details. # (We only emit this event for sales.) if not isinstance(self.model, PurchaseOrder): retval = CreatePaymentEvent.emit(self._method, self.model, self.store, self._holder.value) else: retval = None if retval is None or retval == CreatePaymentStatus.UNHANDLED: if not self._method.method_name == u'money': self._run_payment_editor() self._has_modified_payments = True self._update_payment_list() # Exigência do TEF: Deve finalizar ao chegar no total da venda. if self.finish_on_total and self.can_confirm(): self._wizard.finish() self.update_view()
def next_step(self): if not self.wizard.need_create_payment(): return selected_method = self.get_selected_method() if selected_method.method_name == u'money': if not self.cash_change_slave.can_finish(): warning(_(u"Invalid value, please verify if it was " "properly typed.")) self.cash_change_slave.received_value.select_region( 0, len(self.cash_change_slave.received_value.get_text())) self.cash_change_slave.received_value.grab_focus() return self # We have to modify the payment, so the fiscal printer can # calculate and print the payback, if necessary. payment = self.setup_cash_payment() total = self.cash_change_slave.get_received_value() payment.base_value = total # Return None here means call wizard.finish, which is exactly # what we need return None elif selected_method.method_name == u'store_credit': client = self.model.client total = self.wizard.get_total_amount() assert client.can_purchase(selected_method, total) step_class = PaymentMethodStep elif selected_method.method_name == 'card': providers = CreditProvider.get_card_providers(self.store) if providers.is_empty(): warning(_("You need active credit providers to use the " "card payment method.")) return self step_class = PaymentMethodStep else: step_class = PaymentMethodStep retval = CreatePaymentEvent.emit(selected_method, self.model, self.store) # None means no one catched this event if retval is None or retval == CreatePaymentStatus.UNHANDLED: # FIXME: We cannot send outstanding_value to multiple editor # since if we have a trade going on, it will be calculated wrong if selected_method.method_name == 'multiple': outstanding_value = None else: outstanding_value = self.wizard.get_total_to_pay() return step_class(self.wizard, self, self.store, self.model, selected_method, outstanding_value=outstanding_value) # finish the wizard if retval == CreatePaymentStatus.SUCCESS: return None # returning self to stay on this step return self
def next_step(self): if not self.wizard.need_create_payment(): if self.cash_change_slave.credit_checkbutton.get_active(): self._create_change_payment() return selected_method = self.get_selected_method() if selected_method.method_name == u'money': if not self.cash_change_slave.can_finish(): warning( _(u"Invalid value, please verify if it was " "properly typed.")) self.cash_change_slave.received_value.select_region( 0, len(self.cash_change_slave.received_value.get_text())) self.cash_change_slave.received_value.grab_focus() return self # We have to modify the payment, so the fiscal printer can # calculate and print the payback, if necessary. payment = self.setup_cash_payment() if payment is None: return total = self.cash_change_slave.get_received_value() payment.base_value = total # Return None here means call wizard.finish, which is exactly # what we need return None elif selected_method.method_name == u'credit': client = self.model.client total = self.wizard.get_total_to_pay() assert client.can_purchase(selected_method, total) try: payment = selected_method.create_payment( Payment.TYPE_IN, self.model.group, self.model.branch, total) except PaymentMethodError as err: warning(str(err)) return self # Return None here means call wizard.finish, which is exactly # what we need return None elif selected_method.method_name == u'store_credit': client = self.model.client total = self.wizard.get_total_to_pay() assert client.can_purchase(selected_method, total) step_class = PaymentMethodStep elif selected_method.method_name == 'card': providers = CreditProvider.get_card_providers(self.store) if providers.is_empty(): warning( _("You need active credit providers to use the " "card payment method.")) return self step_class = PaymentMethodStep else: step_class = PaymentMethodStep retval = CreatePaymentEvent.emit(selected_method, self.model, self.store) # None means no one catched this event if retval is None or retval == CreatePaymentStatus.UNHANDLED: # FIXME: We cannot send outstanding_value to multiple editor # since if we have a trade going on, it will be calculated wrong if selected_method.method_name == 'multiple': outstanding_value = None else: outstanding_value = self.wizard.get_total_to_pay() manager = get_plugin_manager() return step_class(self.wizard, self, self.store, self.model, selected_method, outstanding_value=outstanding_value, finish_on_total=manager.is_active('tef')) # finish the wizard if retval == CreatePaymentStatus.SUCCESS: return None # returning self to stay on this step return self