stable repeated ticketing invoice fetching

This commit is contained in:
SimplifiedPrivacy 2026-10-17 14:25:05 -04:00
parent 2cf3b60540
commit ac17183d7c
4 changed files with 43 additions and 12 deletions

View file

@ -27,7 +27,7 @@ def _system_state_profile_id():
def is_profile_enabled_for_gui(profile) -> bool: def is_profile_enabled_for_gui(profile) -> bool:
"""Checks Profile State Against in-memory Repo""" """Checks Profile State Against in-memory Repo"""
is_enabled = ProfileStateRepository().is_profile_active(profile.id) is_enabled = ProfileStateRepository().is_profile_active(profile.id)
print(f"profile id: {profile.id} | Enabled: {is_enabled}") # print(f"profile id: {profile.id} | Enabled: {is_enabled}")
return is_enabled return is_enabled

View file

@ -3,7 +3,7 @@ from core.controllers.tickets.UseTicketController import use_ticket
from core.models.BaseProfile import BaseProfile as Profile from core.models.BaseProfile import BaseProfile as Profile
from core.controllers.ProfileController import ProfileController from core.controllers.ProfileController import ProfileController
from core.controllers.tickets.TicketPayController import initiate_payment from core.controllers.tickets.TicketPayController import initiate_payment
from core.services.subscriptions.subscriptions_by_protocol import start_new_payment_cycle, save_subscription from core.services.subscriptions.subscriptions_by_protocol import start_new_payment_cycle, save_subscription, get_ticket_invoice
from core.services.payment_phase.payment_state import OverallPaymentCycle from core.services.payment_phase.payment_state import OverallPaymentCycle
from core.models.enum_models import PaymentCategory from core.models.enum_models import PaymentCategory
from core.services.prepare_tickets.ticket_tracker import get_all_unused_tickets from core.services.prepare_tickets.ticket_tracker import get_all_unused_tickets
@ -27,9 +27,13 @@ def start_ticket(ui_caller: Callable) -> Result:
) )
def fetch_ticket_invoice(invoice_ui_caller: Callable, timer_resume_caller: Callable) -> str | None: def fetch_ticket_invoice(ui_caller: Callable) -> str | None:
pass return take_action(
return None action=get_ticket_invoice,
ui_caller=ui_caller,
connection_observer=connection_observer
)
# def fetch_ticket_invoice(invoice_ui_caller: Callable, timer_resume_caller: Callable) -> str | None: # def fetch_ticket_invoice(invoice_ui_caller: Callable, timer_resume_caller: Callable) -> str | None:
# """Start the Ticketing process on the background thread with the relevant billing data.""" # """Start the Ticketing process on the background thread with the relevant billing data."""

View file

@ -18,6 +18,7 @@ from gui.v2.ui.pages.Page import Page
from gui.v2.ui.popups.message_box import style_message_box, mark_confirm_button from gui.v2.ui.popups.message_box import style_message_box, mark_confirm_button
from gui.v2.actions.menu_tasks import enable_profile from gui.v2.actions.menu_tasks import enable_profile
from gui.v2.actions.payment_actions import start_individual_payment from gui.v2.actions.payment_actions import start_individual_payment
from gui.v2.actions.ticket_actions import start_ticket
HOW_MANY_PROFILES_DEFAULT = 6 HOW_MANY_PROFILES_DEFAULT = 6
@ -179,14 +180,24 @@ class IdPage(Page):
else: else:
self.show_a_popup(str(result.message)) self.show_a_popup(str(result.message))
def go_multiple_profiles(self): def go_multiple_profiles(self):
result = start_new_payment_cycle( start_ticket(ui_caller=self.multi_ticket_callback)
category=PaymentCategory.TICKET,
) def multi_ticket_callback(self, result: Result):
if not result.valid: if not result.valid:
if result.message:
self.show_a_popup(str(result.message)) self.show_a_popup(str(result.message))
return
payment_cycle = result.data payment_cycle = result.data
if not payment_cycle:
return
billing_data = payment_cycle.billing_data
if not billing_data:
return
billing_code = payment_cycle.billing_code billing_code = payment_cycle.billing_code
if billing_code: if billing_code:
@ -229,11 +240,17 @@ class IdPage(Page):
failed_delete.exec() failed_delete.exec()
def _resume_existing_ticket(self, billing_id): def _resume_existing_ticket(self, billing_id):
print("resuming existing ticket in GUI")
self.update_status.update_status("Checking existing ticket payment...") self.update_status.update_status("Checking existing ticket payment...")
self.custom_window.navigator.navigate("payment_details")
payment_page = self.custom_window.navigator.get_cached("payment_details") payment_page = self.custom_window.navigator.get_cached("payment_details")
if payment_page is not None: if payment_page is not None:
payment_page.resume_ticket_billing(billing_id) print("calling fetch_ticket_invoice")
fetch_ticket_invoice(ui_caller=payment_page.receive_invoice)
print("navigating to payment details page..")
self.custom_window.navigator.navigate("payment_details")
# payment_page.resume_ticket_billing(billing_id)
def toggle_button_state(self): def toggle_button_state(self):
text = self.text_edit.toPlainText() text = self.text_edit.toPlainText()

View file

@ -1,6 +1,7 @@
# core # core
from core.models.enum_models import PaymentCategory from core.models.enum_models import PaymentCategory
from core.models.Result import Result from core.models.Result import Result
from core.services.payment_phase.payment_state import TicketPaymentData
# gui # gui
from gui.v2.actions.ticket_actions import start_ticket from gui.v2.actions.ticket_actions import start_ticket
@ -111,8 +112,10 @@ class PlanPickerPage(Page):
print("got pre-existing data") print("got pre-existing data")
def on_plan_clicked(self, item): def on_plan_clicked(self, item):
print(f"on_plan_clicked is {item}")
plan_key = item.data(QtCore.Qt.ItemDataRole.UserRole) plan_key = item.data(QtCore.Qt.ItemDataRole.UserRole)
if not plan_key: if not plan_key:
self.show_a_popup("Developer Error where the selected item is not showing up in on_plan_clicked.")
return return
print(f"plan_key is {plan_key}") print(f"plan_key is {plan_key}")
@ -121,9 +124,16 @@ class PlanPickerPage(Page):
if not self.billing_data: if not self.billing_data:
self.show_a_popup("Developer Error that ticket flow didn't produce a billing_data object in plan picker page.") self.show_a_popup("Developer Error that ticket flow didn't produce a billing_data object in plan picker page.")
self.billing_data.which_key = plan_key # self.billing_data.which_key = plan_key
print("Getting TicketPaymentData()")
billing_data = TicketPaymentData()
print(f"billing_data is {billing_data}")
billing_data.which_key = plan_key
print("saved the which_key. navigating to currency selection..") print("saved the which_key. navigating to currency selection..")
print(f"FINALLY billing_data is {billing_data}")
# go to next page: # go to next page:
# currency_page = self.custom_window.navigator.get_cached("currency_selection") # currency_page = self.custom_window.navigator.get_cached("currency_selection")
# if currency_page is not None: # if currency_page is not None: