forked from Support/sp-hydra-veil-gui
Paid status stable for individual and tickets, getting to prep page via new flow
This commit is contained in:
parent
4273baebc2
commit
ffea00e1ff
7 changed files with 85 additions and 19 deletions
|
|
@ -120,7 +120,14 @@ def gui_starts_invoice(invoice_ui_caller: Callable, timer_resume_caller: Callabl
|
||||||
# insert function here to get it via the data inside.
|
# insert function here to get it via the data inside.
|
||||||
return error_msg
|
return error_msg
|
||||||
else:
|
else:
|
||||||
return return_pre_existing_invoice(billing_code=billing_code, connection_observer=connection_observer)
|
pre_existing = return_pre_existing_invoice(billing_code=billing_code, connection_observer=connection_observer)
|
||||||
|
logger.info(f"Inside GUI's start of invoice, with {pre_existing.error_type}")
|
||||||
|
if not pre_existing.valid and pre_existing.error_type == ResultError.PAID and payment_cycle.category == PaymentCategory.TICKET:
|
||||||
|
logger.info("Navigating to ticket prep page")
|
||||||
|
return Result(valid=True, error_type=NAVIGATE_TO, navigate_to="ticket_prep")
|
||||||
|
else:
|
||||||
|
logger.info("returning normally..")
|
||||||
|
return pre_existing
|
||||||
|
|
||||||
notification = "Fetching Invoice.."
|
notification = "Fetching Invoice.."
|
||||||
Notifications.emit(EventType.STATUS_UPDATE, notification)
|
Notifications.emit(EventType.STATUS_UPDATE, notification)
|
||||||
|
|
|
||||||
|
|
@ -122,10 +122,16 @@ def fetch_ticket_invoice(ui_caller: Callable):
|
||||||
|
|
||||||
def start_bulk_ticket_prep(ui_caller: Callable) -> Result:
|
def start_bulk_ticket_prep(ui_caller: Callable) -> Result:
|
||||||
"""After paid for, start the actual math"""
|
"""After paid for, start the actual math"""
|
||||||
|
logger.info("Starting a bulk ticket prep")
|
||||||
ticket_cycle = TicketPaymentData()
|
ticket_cycle = TicketPaymentData()
|
||||||
how_many_profiles = ticket_cycle.how_many_profiles
|
how_many_profiles = ticket_cycle.how_many_profiles
|
||||||
|
|
||||||
return take_action(
|
if not ticket_cycle.paid:
|
||||||
|
logger.error("Not yet paid")
|
||||||
|
return Result(valid=False, error_type=ResultError.NAVIGATE_TO, navigate_to="id", message="Tickets are not yet paid for, yet the prep started.")
|
||||||
|
|
||||||
|
logger.info("Threading to prepare_tickets")
|
||||||
|
take_action(
|
||||||
action=prepare_tickets,
|
action=prepare_tickets,
|
||||||
ui_caller=ui_caller,
|
ui_caller=ui_caller,
|
||||||
how_many_profiles=how_many_profiles,
|
how_many_profiles=how_many_profiles,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
from core.models.Result import Result, ResultError
|
from core.models.Result import Result, ResultError
|
||||||
from core.controllers.SyncController import new_sync
|
from core.controllers.SyncController import new_sync
|
||||||
from core.services.subscriptions.subscriptions_by_protocol import wipe_billing_cycle
|
from core.services.subscriptions.subscriptions_by_protocol import wipe_billing_cycle
|
||||||
|
# from core.services.payment_phase.check_payment_loop import mark_as_paid
|
||||||
# from gui.v2.actions.payment_actions import stop_payment_timer
|
# from gui.v2.actions.payment_actions import stop_payment_timer
|
||||||
|
|
||||||
ENUM_MAP = {
|
ENUM_MAP = {
|
||||||
|
|
@ -8,6 +9,7 @@ ENUM_MAP = {
|
||||||
ResultError.NEED_SYNC: (new_sync),
|
ResultError.NEED_SYNC: (new_sync),
|
||||||
ResultError.ACTIVE_BILLING: (wipe_billing_cycle),
|
ResultError.ACTIVE_BILLING: (wipe_billing_cycle),
|
||||||
ResultError.EXPIRED_INVOICE: (wipe_billing_cycle),
|
ResultError.EXPIRED_INVOICE: (wipe_billing_cycle),
|
||||||
|
# ResultError.PAID: (mark_as_paid),
|
||||||
ResultError.INVALID_API_REPLY: None,
|
ResultError.INVALID_API_REPLY: None,
|
||||||
ResultError.ENCRYPTION: None
|
ResultError.ENCRYPTION: None
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,7 @@
|
||||||
|
from core.models.Result import Result, ResultError
|
||||||
|
from core.errors.logger import logger
|
||||||
|
|
||||||
|
|
||||||
from gui.v2.ui.popups.error_popup import ErrorPopup
|
from gui.v2.ui.popups.error_popup import ErrorPopup
|
||||||
|
|
||||||
from gui.v2.infrastructure.ThreadSafetyTool import ThreadSafetyTool
|
from gui.v2.infrastructure.ThreadSafetyTool import ThreadSafetyTool
|
||||||
|
|
@ -117,16 +121,28 @@ class Page(QWidget):
|
||||||
@mainthread
|
@mainthread
|
||||||
def show_a_popup(self, message: str, title: str = "Error"):
|
def show_a_popup(self, message: str, title: str = "Error"):
|
||||||
"""Display a popup with an error"""
|
"""Display a popup with an error"""
|
||||||
error_popup = ErrorPopup(
|
|
||||||
choice=False,
|
|
||||||
title=title,
|
|
||||||
message=message,
|
|
||||||
end_app = False,
|
|
||||||
on_answer = None,
|
|
||||||
passed_result = None,
|
|
||||||
)
|
|
||||||
|
|
||||||
error_popup.show()
|
# MISTAKE CATCHER:
|
||||||
|
if isinstance(message, Result):
|
||||||
|
final_message = message.message
|
||||||
|
title = message.error_type.value
|
||||||
|
else:
|
||||||
|
final_message = message
|
||||||
|
|
||||||
|
# FINAL REAL CHECK
|
||||||
|
if isinstance(final_message, str) and isinstance(title, str):
|
||||||
|
error_popup = ErrorPopup(
|
||||||
|
choice=False,
|
||||||
|
title=title,
|
||||||
|
message=final_message,
|
||||||
|
end_app = False,
|
||||||
|
on_answer = None,
|
||||||
|
passed_result = None,
|
||||||
|
)
|
||||||
|
|
||||||
|
error_popup.show()
|
||||||
|
else:
|
||||||
|
logger.error("Show a popup was sent non valid strings to display.")
|
||||||
|
|
||||||
|
|
||||||
def display_error(self, whats_wrong: DataError, whats_it_called: str, the_thing: Any):
|
def display_error(self, whats_wrong: DataError, whats_it_called: str, the_thing: Any):
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ from PyQt6 import QtCore
|
||||||
# core
|
# core
|
||||||
# from core.models.enum_models import PaymentCategory
|
# from core.models.enum_models import PaymentCategory
|
||||||
from core.services.prepare_tickets.ticket_tracker import delete_ticket_data
|
from core.services.prepare_tickets.ticket_tracker import delete_ticket_data
|
||||||
|
from core.services.payment_phase.payment_state import TicketPaymentData
|
||||||
from core.models.Result import Result
|
from core.models.Result import Result
|
||||||
# from core.services.payment_phase.ticket_config_tools import do_we_have_billing_id
|
# from core.services.payment_phase.ticket_config_tools import do_we_have_billing_id
|
||||||
|
|
||||||
|
|
@ -198,8 +199,18 @@ class IdPage(Page):
|
||||||
return
|
return
|
||||||
|
|
||||||
billing_code = payment_cycle.billing_code
|
billing_code = payment_cycle.billing_code
|
||||||
|
paid = TicketPaymentData().paid
|
||||||
|
|
||||||
if billing_code:
|
print(f"paid {paid}")
|
||||||
|
|
||||||
|
if paid:
|
||||||
|
print("paid going to prep..")
|
||||||
|
self.custom_window.navigator.navigate("ticket_prep")
|
||||||
|
# prep_page = self.custom_window.navigator.get_cached("ticket_prep")
|
||||||
|
# if prep_page is not None:
|
||||||
|
# prep_page.start_prep()
|
||||||
|
|
||||||
|
elif billing_code:
|
||||||
self._prompt_existing_tickets(billing_code)
|
self._prompt_existing_tickets(billing_code)
|
||||||
else:
|
else:
|
||||||
self._continue_multiple_flow()
|
self._continue_multiple_flow()
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ from core.services.payment_phase.payment_state import PaymentData
|
||||||
from core.models.pydantic_models.ServerReply import SubscriptionInvoice
|
from core.models.pydantic_models.ServerReply import SubscriptionInvoice
|
||||||
from core.models.invoice.TicketInvoice import TicketInvoice
|
from core.models.invoice.TicketInvoice import TicketInvoice
|
||||||
from core.models.enum_models import Currency
|
from core.models.enum_models import Currency
|
||||||
from core.models.Result import Result
|
from core.models.Result import Result, ResultError
|
||||||
from core.observers.Notifications import Notifications, EventType
|
from core.observers.Notifications import Notifications, EventType
|
||||||
|
|
||||||
# GUI
|
# GUI
|
||||||
|
|
@ -273,6 +273,8 @@ class PaymentDetailsPage(Page):
|
||||||
def receive_invoice(self, invoice_result: Result):
|
def receive_invoice(self, invoice_result: Result):
|
||||||
"""Callback for the background API thread to update the UI"""
|
"""Callback for the background API thread to update the UI"""
|
||||||
|
|
||||||
|
print("receive_invoice is recieving the invoice result")
|
||||||
|
|
||||||
if not invoice_result:
|
if not invoice_result:
|
||||||
self.display_error(
|
self.display_error(
|
||||||
whats_wrong=DataError.BLANK,
|
whats_wrong=DataError.BLANK,
|
||||||
|
|
@ -290,6 +292,21 @@ class PaymentDetailsPage(Page):
|
||||||
return
|
return
|
||||||
|
|
||||||
if not invoice_result.valid:
|
if not invoice_result.valid:
|
||||||
|
# Paid already, then navigate away:
|
||||||
|
if invoice_result.error_type == ResultError.PAID:
|
||||||
|
print("already paid")
|
||||||
|
print("already paid")
|
||||||
|
print("already paid")
|
||||||
|
print("already paid")
|
||||||
|
if paying_for_tickets():
|
||||||
|
print("triggering ticketing confirmed")
|
||||||
|
self.ticket_payment_confirmed()
|
||||||
|
else:
|
||||||
|
self.update_status.update_status('Paid. Please proceed.')
|
||||||
|
self.custom_window.navigator.navigate("menu")
|
||||||
|
return
|
||||||
|
|
||||||
|
# otherwise display the error:
|
||||||
self.update_status.update_status(str(invoice_result.error_type.value))
|
self.update_status.update_status(str(invoice_result.error_type.value))
|
||||||
self.show_a_popup(str(invoice_result.message))
|
self.show_a_popup(str(invoice_result.message))
|
||||||
return
|
return
|
||||||
|
|
@ -463,22 +480,25 @@ class PaymentDetailsPage(Page):
|
||||||
|
|
||||||
def regular_payment_confirmed(self, billing_code: str):
|
def regular_payment_confirmed(self, billing_code: str):
|
||||||
"""Conclude a regular payment by putting the billing code on the final confirmation window."""
|
"""Conclude a regular payment by putting the billing code on the final confirmation window."""
|
||||||
|
print("calling regular_payment_confirmed")
|
||||||
payment_page = self.custom_window.navigator.get_cached("payment_confirmed")
|
payment_page = self.custom_window.navigator.get_cached("payment_confirmed")
|
||||||
if payment_page is not None:
|
if payment_page is not None:
|
||||||
for line in self.text_fields:
|
for line in self.text_fields:
|
||||||
line.setText('')
|
line.setText('')
|
||||||
payment_page.set_billing_code(billing_code)
|
payment_page.set_billing_code(billing_code)
|
||||||
|
self.custom_window.navigator.navigate("payment_confirmed")
|
||||||
else:
|
else:
|
||||||
print("PaymentConfirmed page not found")
|
print("PaymentConfirmed page not found")
|
||||||
|
self.update_status.update_status('Paid. Please proceed.')
|
||||||
|
self.custom_window.navigator.navigate("menu")
|
||||||
|
|
||||||
def ticket_payment_confirmed(self):
|
def ticket_payment_confirmed(self):
|
||||||
"""Conclude a ticket payment by forwarding to the prep page."""
|
"""Conclude a ticket payment by forwarding to the prep page."""
|
||||||
# self.ticketing = False
|
|
||||||
self.update_status.update_status('Payment received.')
|
self.update_status.update_status('Payment received.')
|
||||||
self.custom_window.navigator.navigate("ticket_prep")
|
self.custom_window.navigator.navigate("ticket_prep")
|
||||||
prep_page = self.custom_window.navigator.get_cached("ticket_prep")
|
# prep_page = self.custom_window.navigator.get_cached("ticket_prep")
|
||||||
if prep_page is not None:
|
# if prep_page is not None:
|
||||||
prep_page.start_prep()
|
# prep_page.start_prep()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ class TicketPrepPage(Page):
|
||||||
self._terminal_bound = False
|
self._terminal_bound = False
|
||||||
self._tickets_ready = False
|
self._tickets_ready = False
|
||||||
self.setup_initial_layout()
|
self.setup_initial_layout()
|
||||||
|
self.active_prep = False
|
||||||
self.start_prep()
|
self.start_prep()
|
||||||
|
|
||||||
def setup_initial_layout(self):
|
def setup_initial_layout(self):
|
||||||
|
|
@ -62,10 +63,13 @@ class TicketPrepPage(Page):
|
||||||
self.status_label.setText("Preparing tickets...")
|
self.status_label.setText("Preparing tickets...")
|
||||||
self.update_status.update_status("Preparing tickets...")
|
self.update_status.update_status("Preparing tickets...")
|
||||||
|
|
||||||
# Actually Start it:
|
if not self.active_prep:
|
||||||
start_bulk_ticket_prep(ui_caller=self.on_prep_done)
|
# Actually Start it:
|
||||||
|
start_bulk_ticket_prep(ui_caller=self.on_prep_done)
|
||||||
|
self.active_prep = True
|
||||||
|
|
||||||
def on_prep_done(self, result: Result):
|
def on_prep_done(self, result: Result):
|
||||||
|
print(f"on_prep_done called with {result}")
|
||||||
self.continue_button.setEnabled(True)
|
self.continue_button.setEnabled(True)
|
||||||
|
|
||||||
if not result or not isinstance(result, Result):
|
if not result or not isinstance(result, Result):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue