"""Get the data from the correct model.""" from reporting.constants.physical_reporting import US_SUPPLY_CHAIN from reporting.constants.report_map import REPORT_REGISTRY from reporting.models import persister def get_report_by_name(report_name, params): """Get the report data from the model.""" class_name = REPORT_REGISTRY[report_name]['model'] return class_name.all(params) def get_report_filters_by_type(report_name, vendor_id, sub_label_id): """Get the report filter from the model.""" class_name = REPORT_REGISTRY[report_name]['model'] return class_name.filter(vendor_id, sub_label_id) def get_top_open_orders( vendor_ids: list[int], subacct_ids: list[int] | None = None ) -> dict: """Get top 10 open orders for one or more vendors. Args: vendor_ids (list): the vendor IDs. subacct_ids (list, optional): if provided, filters results to these subaccount IDs only. Returns: dict: top 10 open order rows. """ rows = persister.get_top_open_orders( vendor_ids, US_SUPPLY_CHAIN, subacct_ids ) return {'results': rows} def get_top_yesterday_shipments( vendor_ids: list[int], subacct_ids: list[int] | None = None ) -> dict: """Get top 10 yesterday shipments for one or more vendors. Args: vendor_ids (list): the vendor IDs. subacct_ids (list, optional): if provided, filters results to these subaccount IDs only. Returns: dict: top 10 yesterday shipment rows. """ rows = persister.get_top_yesterday_shipments( vendor_ids, US_SUPPLY_CHAIN, subacct_ids ) return {'results': rows} def get_top_mtd_shipments( vendor_ids: list[int], subacct_ids: list[int] | None = None ) -> dict: """Get top 10 MTD shipments for one or more vendors. Args: vendor_ids (list): the vendor IDs. subacct_ids (list, optional): if provided, filters results to these subaccount IDs only. Returns: dict: top 10 MTD shipment rows. """ rows = persister.get_top_mtd_shipments( vendor_ids, US_SUPPLY_CHAIN, subacct_ids ) return {'results': rows} def get_label_subaccount_summary( vendor_ids: list[int], subacct_ids: list[int] | None = None ) -> dict: """Get label/subaccount summary totals for one or more vendors. Args: vendor_ids (list): the vendor IDs. subacct_ids (list, optional): if provided, filters results to these subaccount IDs only. Returns: dict: rows grouped by label and sublabel with shipment/return totals. """ rows = persister.get_label_subaccount_summary( vendor_ids, US_SUPPLY_CHAIN, subacct_ids ) return {'results': rows} def get_product_detail( vendor_ids: list[int], subacct_ids: list[int] | None = None ) -> dict: """Get product-level detail rows for one or more vendors. Args: vendor_ids (list): the vendor IDs. subacct_ids (list, optional): if provided, filters results to these subaccount IDs only. Returns: dict: one row per SKU with metadata and shipment/return totals. """ rows = persister.get_product_detail( vendor_ids, US_SUPPLY_CHAIN, subacct_ids ) return {'results': rows}