diff --git a/erpnext/locale/fr.po b/erpnext/locale/fr.po index 7af86d0cb0d5dacb5883b861aa40eb32d30f33c4..1c00697f943fe7f24ccb270ae6934eea25ea8234 100644 --- a/erpnext/locale/fr.po +++ b/erpnext/locale/fr.po @@ -64897,7 +64897,7 @@ msgstr "{0}, complétez l'opération {1} avant l'opération {2}." #: public/js/event.js:141 msgid "{0}/{1}" -msgstr "{0} {1}" +msgstr "{0}/{1}" #: accounts/doctype/shipping_rule/shipping_rule.py:253 #: accounts/doctype/shipping_rule/shipping_rule.py:263 public/js/event.js:146 diff --git a/erpnext/venue/doctype/event_registration/event_registration.py b/erpnext/venue/doctype/event_registration/event_registration.py index 46b56b680cce9499e1b46bbee7c524da44584add..bc654a3964d4ea564019f0f9f969417b19b249f8 100644 --- a/erpnext/venue/doctype/event_registration/event_registration.py +++ b/erpnext/venue/doctype/event_registration/event_registration.py @@ -94,6 +94,7 @@ class EventRegistration(Document): if cint(self.qty) < 1: self.qty = 1 + self.amount = self.get_payment_amount() self.validate_duplicates() self.validate_available_capacity_of_event() @@ -216,43 +217,46 @@ class EventRegistration(Document): event.save(ignore_permissions=True) def on_payment_authorized(self, status: str, reference_no: str | None = None): - # Draft, Initiated, Pending, Paid, Failed, Cancelled, Completed - new_status = status - curr_status = self.payment_status or "Unpaid" # Probably created from the desk - - if self.get_payment_amount() <= 0: - self.db_set("payment_status", new_status) - frappe.log_error( - message=f"A payment for {self!r} was received with status {new_status!r} (ref_no: {reference_no}) but the payment amount is zero (or negative)", - ) - return - - PAID_STATUSES = ("Authorized", "Completed", "Paid") - if new_status in PAID_STATUSES and curr_status in ("Unpaid", "Pending"): - self.flags.ignore_permissions = True - self.db_set( - "payment_status", "Paid", commit=True - ) # Commit because we this is a change we don't want to lose - self.db_set("reference_no", reference_no, commit=True) - self.submit() - - if not self.payment_gateway: - frappe.throw(_("Missing Payment Gateway")) - if not reference_no: - frappe.throw(_("Missing Reference Number")) - - invoice = self.make_and_submit_invoice() - self.make_payment_entry( - reference_no=reference_no, payment_gateway=self.payment_gateway, invoice_doc=invoice - ) - frappe.db.commit() - elif new_status in ("Failed", "Cancelled"): - self.set("payment_status", new_status) - self.cancel() - elif new_status == "Pending" and curr_status == "Unpaid": - self.set("payment_status", new_status) - self.flags.ignore_permissions = True - self.save() + try: + # Draft, Initiated, Pending, Paid, Failed, Cancelled, Completed + new_status = status + curr_status = self.payment_status or "Unpaid" # Probably created from the desk + + if self.get_payment_amount() <= 0: + self.db_set("payment_status", new_status) + frappe.log_error( + message=f"A payment for {self!r} was received with status {new_status!r} (ref_no: {reference_no}) but the payment amount is zero (or negative)", + ) + return + + PAID_STATUSES = ("Authorized", "Completed", "Paid") + if new_status in PAID_STATUSES and curr_status in ("Unpaid", "Pending"): + self.flags.ignore_permissions = True + self.db_set( + "payment_status", "Paid", commit=True + ) # Commit because we this is a change we don't want to lose + self.db_set("reference_no", reference_no, commit=True) + self.submit() + + if not self.payment_gateway: + frappe.throw(_("Missing Payment Gateway")) + if not reference_no: + frappe.throw(_("Missing Reference Number")) + + invoice = self.make_and_submit_invoice() + self.make_payment_entry( + reference_no=reference_no, payment_gateway=self.payment_gateway, invoice_doc=invoice + ) + frappe.db.commit() + elif new_status in ("Failed", "Cancelled"): + self.set("payment_status", new_status) + self.cancel() + elif new_status == "Pending" and curr_status == "Unpaid": + self.set("payment_status", new_status) + self.flags.ignore_permissions = True + self.save() + except Exception: + self.log_error(title=_("Event Registration Payment Error")) def on_webform_save(self, webform): # The document is created from the Web Form, it means that someone wants to register @@ -260,14 +264,11 @@ class EventRegistration(Document): if not self.company: self.set_company_from_cart_settings() + self.payment_status = "Unpaid" if not self.flags.in_payment_webform: # Free registration self.payment_status = "" self.submit() # Automatically submit when created from a Web Form. - else: - self.amount = self.get_payment_amount() - self.payment_status = "Unpaid" - self.save() def get_payment_amount(self) -> float: """This is a PURE function that returns the amount to be paid (INCLUDING taxes) for the Event Registration. @@ -280,7 +281,7 @@ class EventRegistration(Document): ``` """ # TODO: Fetch from item instead - return self.amount + return self.amount * int(self.qty) def get_item_code(self): """Returns the item_code of the Item used for the invoicing.