From a98dbf339e72dad024d4bc4446018a36e51d99fa Mon Sep 17 00:00:00 2001 From: tahzeer Date: Thu, 29 Oct 2026 16:58:09 +0530 Subject: [PATCH 1/6] G2P-5803 refactor!: drop sql_query rules in favor of pbms_domain BREAKING CHANGE: sql_query column is removed from eligibility, entitlement and priority rule definitions (core models and odoo module), along with the _build_sql_query pipeline and the agent's query UI fields. Rules now carry pbms_domain only, which the registry adapters evaluate. --- .../models/eligibility_rule_definition.py | 1 - .../models/entitlement_rule_definition.py | 1 - .../models/priority_rule_definition.py | 1 - odoo/g2p_pbms/__manifest__.py | 1 + .../beneficiary_list/bgtask_summary_wizard.py | 76 +------------------ .../eligibility_rule_definition.py | 76 +------------------ .../entitlement_rule_definition.py | 70 ----------------- .../priority/priority_rule_definition.py | 76 +------------------ .../eligibility_rule_view.xml | 5 -- .../entitlement_rule_view.xml | 5 -- .../priority_rule/priority_rule_view.xml | 5 -- odoo/g2p_pbms_program_access/__manifest__.py | 1 + 12 files changed, 6 insertions(+), 312 deletions(-) diff --git a/core/openg2p-pbms-models/src/openg2p_pbms_models/models/eligibility_rule_definition.py b/core/openg2p-pbms-models/src/openg2p_pbms_models/models/eligibility_rule_definition.py index 943f489..919a77d 100644 --- a/core/openg2p-pbms-models/src/openg2p_pbms_models/models/eligibility_rule_definition.py +++ b/core/openg2p-pbms-models/src/openg2p_pbms_models/models/eligibility_rule_definition.py @@ -19,6 +19,5 @@ class G2PEligibilityRuleDefinition(BaseORMModel): description = mapped_column(String, nullable=True) target_registry = mapped_column(String, nullable=False) pbms_domain = mapped_column(String, nullable=False) - sql_query = mapped_column(String, nullable=True) create_date = mapped_column(TIMESTAMP(timezone=False), nullable=True) write_date = mapped_column(TIMESTAMP(timezone=False), nullable=True) diff --git a/core/openg2p-pbms-models/src/openg2p_pbms_models/models/entitlement_rule_definition.py b/core/openg2p-pbms-models/src/openg2p_pbms_models/models/entitlement_rule_definition.py index 8f003b3..b9c7099 100644 --- a/core/openg2p-pbms-models/src/openg2p_pbms_models/models/entitlement_rule_definition.py +++ b/core/openg2p-pbms-models/src/openg2p_pbms_models/models/entitlement_rule_definition.py @@ -20,7 +20,6 @@ class G2PEntitlementRuleDefinition(BaseORMModel): decimal_places = mapped_column(Integer, nullable=True) multiplier = mapped_column(String, nullable=True) pbms_domain = mapped_column(String, nullable=False) - sql_query = mapped_column(String, nullable=False) create_date = mapped_column( String, nullable=True ) # Should be DateTime, but using String for "timestamp without time zone" diff --git a/core/openg2p-pbms-models/src/openg2p_pbms_models/models/priority_rule_definition.py b/core/openg2p-pbms-models/src/openg2p_pbms_models/models/priority_rule_definition.py index 81ba339..eaca396 100644 --- a/core/openg2p-pbms-models/src/openg2p_pbms_models/models/priority_rule_definition.py +++ b/core/openg2p-pbms-models/src/openg2p_pbms_models/models/priority_rule_definition.py @@ -16,4 +16,3 @@ class G2PPriorityRuleDefinition(BaseORMModel): program_id = mapped_column(Integer, nullable=True) target_registry = mapped_column(String, nullable=False) pbms_domain = mapped_column(String, nullable=False) - sql_query = mapped_column(String, nullable=False) diff --git a/odoo/g2p_pbms/__manifest__.py b/odoo/g2p_pbms/__manifest__.py index 0186e1e..13447e5 100644 --- a/odoo/g2p_pbms/__manifest__.py +++ b/odoo/g2p_pbms/__manifest__.py @@ -1,3 +1,4 @@ +# ruff: noqa: B018 { "name": "PBMS", "version": "3.1.0", diff --git a/odoo/g2p_pbms/models/beneficiary_list/bgtask_summary_wizard.py b/odoo/g2p_pbms/models/beneficiary_list/bgtask_summary_wizard.py index 3fb80c5..c5cb48c 100644 --- a/odoo/g2p_pbms/models/beneficiary_list/bgtask_summary_wizard.py +++ b/odoo/g2p_pbms/models/beneficiary_list/bgtask_summary_wizard.py @@ -4,10 +4,7 @@ import requests from odoo.exceptions import UserError, AccessError from odoo import models, fields, api, _ -from odoo.tools.safe_eval import safe_eval - from odoo.addons.g2p_registry_type_addon.models import ( - G2PTargetModelMapping, G2PRegistryType, ) from openg2p_fastapi_common.schemas import G2PRequestHeader, G2PPaginationRequest @@ -92,7 +89,6 @@ class G2PBGTaskSummaryWizard(models.TransientModel): dummy_beneficiaries_field = fields.Text(string="Beneficiaries", compute="_compute_dummy") - sql_query = fields.Char(string="Query", store=True) order_by_condition = fields.Char(string="Order By", default="name") # Fields for Disbursement Envelope and Disbursement Batch Lines @@ -394,73 +390,6 @@ def _compute_entitlement_group_title(self): for rec in self: rec.entitlement_group_title = 'Entitlement Statistics for %s' % rec.target_registry.capitalize() - def _build_sql_query(self, odoo_domain, target_registry): - sql_query="" - order_by_field="internal_record_id" - try: - domain_value = safe_eval(odoo_domain or "[]") - except Exception as e: - _logger.error( - "Error evaluating domain: %s", - e, - ) - sql_query = "Invalid search term" - return sql_query, order_by_field - - target_model_name = G2PTargetModelMapping.get_target_model_name(target_registry) - - if not target_model_name: - _logger.error( - "Unknown target_registry '%s'", - target_registry, - ) - sql_query = "Unknown target registry type" - return sql_query, order_by_field - - target_model = self.env[target_model_name] - - try: - query = target_model._where_calc(domain_value) - except Exception as e: - _logger.error( - "Error calculating where clause for rule: %s", e - ) - sql_query = "Error calculating query" - return sql_query, order_by_field - - try: - _, where_clause, where_clause_params = query.get_sql() - except Exception as e: - _logger.error( - "Error generating SQL from query: %s", e - ) - sql_query = "Error generating SQL" - return sql_query, order_by_field - - where_str = ("%s" % where_clause) if where_clause else "" - # Use the target model's table name in the SQL query. - query_str = ( - where_str - ) - - # Format the parameters as strings. - formatted_params = list( - map(lambda x: "'" + str(x) + "'", where_clause_params) - ) - - try: - formatted_query = query_str % tuple(formatted_params) - # formatted_query = formatted_query.replace('"', '\\"') - sql_query = formatted_query - _logger.info("Query: %s", sql_query) - except Exception as e: - _logger.error( - "Error formatting query: %s", - e, - ) - sql_query = "Error formatting query" - return sql_query, order_by_field - @api.model def get_beneficiaries(self, wizard_id, page, page_size, odoo_domain): wizard = self.sudo().browse(wizard_id) @@ -470,7 +399,6 @@ def get_beneficiaries(self, wizard_id, page, page_size, odoo_domain): if not api_url: _logger.error("API URL not set in environment") - sql_query, order_by_condition = self._build_sql_query(odoo_domain, wizard.target_registry) endpoint = f"{api_url}/search_beneficiaries" payload = BeneficiarySearchRequest( @@ -484,8 +412,8 @@ def get_beneficiaries(self, wizard_id, page, page_size, odoo_domain): pagination_request=G2PPaginationRequest( current_page=page, page_size=page_size, - sort_by=order_by_condition or "internal_record_id asc", - search_text=sql_query or "", + sort_by="internal_record_id asc", + search_text=odoo_domain or "", ), request_payload=BeneficiarySearchRequestPayload( beneficiary_list_id=wizard.beneficiary_list_uuid, diff --git a/odoo/g2p_pbms/models/eligibility/eligibility_rule_definition.py b/odoo/g2p_pbms/models/eligibility/eligibility_rule_definition.py index 6a62f93..c50ac36 100644 --- a/odoo/g2p_pbms/models/eligibility/eligibility_rule_definition.py +++ b/odoo/g2p_pbms/models/eligibility/eligibility_rule_definition.py @@ -1,10 +1,6 @@ from odoo import models, fields, api -from odoo.tools.safe_eval import safe_eval -import logging -from odoo.addons.g2p_registry_type_addon.models import G2PRegistryType, G2PTargetModelMapping - -_logger = logging.getLogger(__name__) +from odoo.addons.g2p_registry_type_addon.models import G2PRegistryType class G2PEligibilityRuleDefinition(models.Model): @@ -37,7 +33,6 @@ class G2PEligibilityRuleDefinition(models.Model): required=True ) pbms_domain = fields.Char(string="Domain", required=True) - sql_query = fields.Char(string="SQL Query", compute="_get_query", store=True) _sql_constraints = [ ('rule_number_program_id_unique', 'unique(rule_number, program_id)', 'Rule Number must be unique per Program.') @@ -50,75 +45,6 @@ def _get_default_rule_number(self): last = self.search([('program_id', '=', program_id)], order='rule_number desc', limit=1) return last.rule_number + 1 if last else 1 - @api.depends("pbms_domain", "target_registry") - def _get_query(self): - for rec in self: - try: - # Convert the domain string into a valid Python list of tuples. - domain_value = safe_eval(rec.pbms_domain or "[]") - except Exception as e: - _logger.error( - "Error evaluating domain for eligibility rule %s: %s", - rec.mnemonic, - e, - ) - rec.sql_query = "Invalid domain" - continue - - target_model_name = G2PTargetModelMapping.get_target_model_name(rec.target_registry) - if not target_model_name: - _logger.error( - "Unknown target_registry '%s' for rule %s", - rec.target_registry, - rec.mnemonic, - ) - rec.sql_query = "Unknown target registry type" - continue - - # Get the target model's recordset. - target_model = self.env[target_model_name] - - try: - # Calculate the where clause for the target model based on the evaluated domain. - query = target_model._where_calc(domain_value) - except Exception as e: - _logger.error( - "Error calculating where clause for rule %s: %s", rec.mnemonic, e - ) - rec.sql_query = "Error calculating query" - continue - - try: - from_clause, where_clause, where_clause_params = query.get_sql() - except Exception as e: - _logger.error( - "Error generating SQL from query for rule %s: %s", rec.mnemonic, e - ) - rec.sql_query = "Error generating SQL" - continue - - where_str = (" WHERE %s" % where_clause) if where_clause else "" - # Use the target model's table name in the SQL query. - query_str = ( - 'SELECT "%s".internal_record_id FROM ' % target_model._table + from_clause + where_str - ) - - # Format the parameters as strings. - formatted_params = list( - map(lambda x: "'" + str(x) + "'", where_clause_params) - ) - - try: - rec.sql_query = query_str % tuple(formatted_params) - _logger.info("Query for rule %s: %s", rec.mnemonic, rec.sql_query) - except Exception as e: - _logger.error( - "Error formatting query for eligibility rule %s: %s", - rec.mnemonic, - e, - ) - rec.sql_query = "Error formatting query" - def action_open_view(self): return { "type": "ir.actions.act_window", diff --git a/odoo/g2p_pbms/models/entitlement/entitlement_rule_definition.py b/odoo/g2p_pbms/models/entitlement/entitlement_rule_definition.py index db74d84..3fc19fe 100644 --- a/odoo/g2p_pbms/models/entitlement/entitlement_rule_definition.py +++ b/odoo/g2p_pbms/models/entitlement/entitlement_rule_definition.py @@ -1,5 +1,4 @@ from odoo import models, fields, api -from odoo.tools.safe_eval import safe_eval import logging import json @@ -40,7 +39,6 @@ class G2PEntitlementRuleDefinition(models.Model): selection=G2PRegistryType.selection(), string="Target Registry", required=True ) pbms_domain = fields.Char(string="Domain", required=True) - sql_query = fields.Char(string="SQL Query", compute="_get_query", store=True) allowed_benefit_code_ids = fields.Many2many( 'g2p.benefit.codes', related='program_id.benefit_code_ids', store=False ) @@ -74,74 +72,6 @@ def _compute_multiplier_options(self): ] rec.allowed_multipliers = json.dumps(numeric_fields) - @api.depends("pbms_domain", "target_registry") - def _get_query(self): - for rec in self: - try: - # Convert the domain string into a valid Python list of tuples. - domain_value = safe_eval(rec.pbms_domain or "[]") - except Exception as e: - _logger.error( - "Error evaluating domain for entitlement rule %s: %s", - rec.mnemonic, - e, - ) - rec.sql_query = "Invalid domain" - continue - target_model_name = G2PTargetModelMapping.get_target_model_name(rec.target_registry) - if not target_model_name: - _logger.error( - "Unknown target_registry '%s' for rule %s", - rec.target_registry, - rec.mnemonic, - ) - rec.sql_query = "Unknown target registry type" - continue - - # Get the target model's recordset. - target_model = self.env[target_model_name] - - try: - # Calculate the where clause for the target model based on the evaluated domain. - query = target_model._where_calc(domain_value) - except Exception as e: - _logger.error( - "Error calculating where clause for rule %s: %s", rec.mnemonic, e - ) - rec.sql_query = "Error calculating query" - continue - - try: - from_clause, where_clause, where_clause_params = query.get_sql() - except Exception as e: - _logger.error( - "Error generating SQL from query for rule %s: %s", rec.mnemonic, e - ) - rec.sql_query = "Error generating SQL" - continue - - where_str = (" WHERE %s" % where_clause) if where_clause else "" - # Use the target model's table name in the SQL query. - query_str = ( - 'SELECT "%s".internal_record_id FROM ' % target_model._table + from_clause + where_str - ) - - # Format the parameters as strings. - formatted_params = list( - map(lambda x: "'" + str(x) + "'", where_clause_params) - ) - - try: - rec.sql_query = query_str % tuple(formatted_params) - _logger.info("Query for rule %s: %s", rec.mnemonic, rec.sql_query) - except Exception as e: - _logger.error( - "Error formatting query for entitlement rule %s: %s", - rec.mnemonic, - e, - ) - rec.sql_query = "Error formatting query" - def action_open_view(self): return { "type": "ir.actions.act_window", diff --git a/odoo/g2p_pbms/models/priority/priority_rule_definition.py b/odoo/g2p_pbms/models/priority/priority_rule_definition.py index da85b58..2c25fe4 100644 --- a/odoo/g2p_pbms/models/priority/priority_rule_definition.py +++ b/odoo/g2p_pbms/models/priority/priority_rule_definition.py @@ -1,10 +1,6 @@ from odoo import models, fields, api -from odoo.tools.safe_eval import safe_eval -import logging -from odoo.addons.g2p_registry_type_addon.models import G2PRegistryType, G2PTargetModelMapping - -_logger = logging.getLogger(__name__) +from odoo.addons.g2p_registry_type_addon.models import G2PRegistryType class G2PPriorityRuleDefinition(models.Model): _name = "g2p.priority.rule.definition" @@ -19,76 +15,6 @@ class G2PPriorityRuleDefinition(models.Model): selection=G2PRegistryType.selection(), string="Registry Type", required=True ) pbms_domain = fields.Char(string="Domain", required=True) - sql_query = fields.Char(string="SQL Query", compute="_get_query", store=True) - - @api.depends("pbms_domain", "target_registry") - def _get_query(self): - for rec in self: - try: - # Convert the domain string into a valid Python list of tuples. - domain_value = safe_eval(rec.pbms_domain or "[]") - except Exception as e: - _logger.error( - "Error evaluating domain for priority rule %s: %s", - rec.mnemonic, - e, - ) - rec.sql_query = "Invalid domain" - continue - - target_model_name = G2PTargetModelMapping.get_target_model_name(rec.target_registry) - if not target_model_name: - _logger.error( - "Unknown target_registry '%s' for rule %s", - rec.target_registry, - rec.mnemonic, - ) - rec.sql_query = "Unknown target registry type" - continue - - # Get the target model's recordset. - target_model = self.env[target_model_name] - - try: - # Calculate the where clause for the target model based on the evaluated domain. - query = target_model._where_calc(domain_value) - except Exception as e: - _logger.error( - "Error calculating where clause for rule %s: %s", rec.mnemonic, e - ) - rec.sql_query = "Error calculating query" - continue - - try: - from_clause, where_clause, where_clause_params = query.get_sql() - except Exception as e: - _logger.error( - "Error generating SQL from query for rule %s: %s", rec.mnemonic, e - ) - rec.sql_query = "Error generating SQL" - continue - - where_str = (" WHERE %s" % where_clause) if where_clause else "" - # Use the target model's table name in the SQL query. - query_str = ( - 'SELECT "%s".internal_record_id FROM ' % target_model._table + from_clause + where_str - ) - - # Format the parameters as strings. - formatted_params = list( - map(lambda x: "'" + str(x) + "'", where_clause_params) - ) - - try: - rec.sql_query = query_str % tuple(formatted_params) - _logger.info("Query for rule %s: %s", rec.mnemonic, rec.sql_query) - except Exception as e: - _logger.error( - "Error formatting query for priority rule %s: %s", - rec.mnemonic, - e, - ) - rec.sql_query = "Error formatting query" @api.model def default_get(self, fields): diff --git a/odoo/g2p_pbms/views/eligibility_rule/eligibility_rule_view.xml b/odoo/g2p_pbms/views/eligibility_rule/eligibility_rule_view.xml index c88a71f..168f1fa 100644 --- a/odoo/g2p_pbms/views/eligibility_rule/eligibility_rule_view.xml +++ b/odoo/g2p_pbms/views/eligibility_rule/eligibility_rule_view.xml @@ -21,11 +21,6 @@ - - - - - diff --git a/odoo/g2p_pbms/views/entitlement_rule/entitlement_rule_view.xml b/odoo/g2p_pbms/views/entitlement_rule/entitlement_rule_view.xml index cc67766..e934428 100644 --- a/odoo/g2p_pbms/views/entitlement_rule/entitlement_rule_view.xml +++ b/odoo/g2p_pbms/views/entitlement_rule/entitlement_rule_view.xml @@ -25,11 +25,6 @@ - - - - - diff --git a/odoo/g2p_pbms/views/priority_rule/priority_rule_view.xml b/odoo/g2p_pbms/views/priority_rule/priority_rule_view.xml index ed39e19..f5467eb 100644 --- a/odoo/g2p_pbms/views/priority_rule/priority_rule_view.xml +++ b/odoo/g2p_pbms/views/priority_rule/priority_rule_view.xml @@ -19,11 +19,6 @@ - - - - - diff --git a/odoo/g2p_pbms_program_access/__manifest__.py b/odoo/g2p_pbms_program_access/__manifest__.py index b2e1157..8a5abfa 100644 --- a/odoo/g2p_pbms_program_access/__manifest__.py +++ b/odoo/g2p_pbms_program_access/__manifest__.py @@ -1,3 +1,4 @@ +# ruff: noqa: B018 { "name": "PBMS Program Access", "version": "3.1.0", From 4bf6f59f8a10f02a3ce4c58443d617163139300c Mon Sep 17 00:00:00 2001 From: tahzeer Date: Thu, 29 Oct 2026 16:58:14 +0530 Subject: [PATCH 2/6] G2P-5803 refactor!: move registry extensions to pbms-connectors Registry adapters and odoo registry/theme addons now live in pbms-connectors, whose images extend these bases. Drop their COPY and pip lines here and remove extensions from the lint matrix. BREAKING CHANGE: docker builds no longer bake registry adapters; deploy the pbms-connectors images/chart instead. --- .github/workflows/pre-commit.yml | 1 - .../openg2p-pbms-bene-portal-api/.env.example | 2 +- .../bene-portal-api/Dockerfile | 10 +- .../staff-portal-api/Dockerfile | 12 +- docker/openg2p-pbms-odoo/utils/Dockerfile | 1 - extensions/.gitignore | 207 --------- extensions/.pre-commit-config.yaml | 49 -- extensions/.ruff.toml | 16 - extensions/LICENSE | 373 --------------- extensions/README.md | 3 - .../CODE-OF-CONDUCT.md | 114 ----- .../CONTRIBUTING.md | 2 - .../README.md | 0 .../pyproject.toml | 33 -- .../__init__.py | 1 - .../cache.py | 18 - .../computations/__init__.py | 2 - .../computations/register_household.py | 438 ------------------ .../computations/registry_farmer.py | 434 ----------------- .../factory/__init__.py | 1 - .../factory/registry_factory.py | 23 - .../interface/__init__.py | 1 - .../interface/registry_interface.py | 240 ---------- .../migrate.py | 11 - .../models/__init__.py | 5 - .../models/beneficiary_list_summary_farmer.py | 26 -- .../beneficiary_list_summary_household.py | 38 -- .../models/register_household.py | 64 --- .../models/registry_farmer.py | 57 --- .../models/registry_type.py | 7 - .../schema/__init__.py | 15 - .../schema/beneficiary_list_summary.py | 21 - .../schema/beneficiary_list_summary_farmer.py | 27 -- .../beneficiary_list_summary_household.py | 35 -- .../schema/register_household.py | 26 -- .../schema/registry.py | 5 - .../schema/registry_farmer.py | 15 - odoo/README.md | 2 +- odoo/extensions/.gitignore | 207 --------- odoo/extensions/LICENSE | 373 --------------- odoo/extensions/README.md | 3 - .../extensions/g2p_registry_addon/__init__.py | 2 - .../g2p_registry_addon/__manifest__.py | 29 -- .../g2p_registry_addon/models/__init__.py | 3 - .../models/farmer_registry.py | 126 ----- .../g2p_registry_addon/models/household.py | 184 -------- .../g2p_registry_addon/models/registry.py | 19 - .../security/ir.model.access.csv | 5 - .../static/description/icon.png | Bin 3985 -> 0 bytes .../static/src/css/registry_styles.scss | 10 - .../static/src/js/beneficiaries_widget.js | 110 ----- .../src/xml/g2p_beneficiaries_info_tpl.xml | 175 ------- .../views/bgtask/bgtask_view.xml | 18 - .../eligibility/eligibility_rule_view.xml | 25 - .../entitlement/entitlement_rule_view.xml | 25 - .../g2p_registry_addon/views/menu.xml | 12 - .../views/priority/priority_rule_view.xml | 25 - .../views/registry/farmer_registry_view.xml | 87 ---- .../registry/household_registry_view.xml | 88 ---- .../g2p_registry_type_addon/__init__.py | 2 - .../g2p_registry_type_addon/__manifest__.py | 18 - .../models/__init__.py | 1 - .../models/registry_type.py | 23 - .../security/ir.model.access.csv | 1 - .../static/description/icon.png | Bin 3985 -> 0 bytes .../extensions/pbms_theme_extension/README.md | 3 - .../pbms_theme_extension/__init__.py | 2 - .../pbms_theme_extension/__manifest__.py | 29 -- .../controllers/__init__.py | 1 - .../controllers/web_login.py | 16 - .../pbms_theme_extension/models/__init__.py | 2 - .../models/res_company.py | 16 - .../pbms_theme_extension/models/res_user.py | 35 -- .../pbms_theme_extension/pyproject.toml | 3 - .../static/description/icon.png | Bin 3985 -> 0 bytes .../static/src/css/fonts/Roboto-Black.woff | Bin 90664 -> 0 bytes .../src/css/fonts/Roboto-BlackItalic.woff | Bin 98296 -> 0 bytes .../static/src/css/fonts/Roboto-Bold.woff | Bin 90308 -> 0 bytes .../src/css/fonts/Roboto-BoldItalic.woff | Bin 96244 -> 0 bytes .../static/src/css/fonts/Roboto-Italic.woff | Bin 95740 -> 0 bytes .../static/src/css/fonts/Roboto-Light.woff | Bin 89672 -> 0 bytes .../src/css/fonts/Roboto-LightItalic.woff | Bin 96952 -> 0 bytes .../static/src/css/fonts/Roboto-Medium.woff | Bin 90560 -> 0 bytes .../src/css/fonts/Roboto-MediumItalic.woff | Bin 97476 -> 0 bytes .../static/src/css/fonts/Roboto-Regular.woff | Bin 89828 -> 0 bytes .../static/src/css/fonts/Roboto-Thin.woff | Bin 88132 -> 0 bytes .../src/css/fonts/Roboto-ThinItalic.woff | Bin 94808 -> 0 bytes .../static/src/css/style.css | 434 ----------------- .../static/src/img/57481.png | Bin 7836 -> 0 bytes .../static/src/img/57485.png | Bin 10003 -> 0 bytes .../src/img/favicon-black-background.png | Bin 355101 -> 0 bytes .../src/img/favicon-white-background.png | Bin 355940 -> 0 bytes .../static/src/img/favicon.png | Bin 15175 -> 0 bytes .../static/src/img/openg2p-black.png | Bin 35098 -> 0 bytes .../static/src/img/openg2p-white.png | Bin 34631 -> 0 bytes .../static/src/js/g2p_window_title.js | 10 - .../static/src/scss/assets_menu.scss | 70 --- .../static/src/scss/g2p_login_page.scss | 52 --- .../static/src/scss/new_login_page.scss | 157 ------- .../templates/g2p_login_page.xml | 67 --- .../templates/g2p_reset_password.xml | 45 -- .../views/webclient_templates.xml | 11 - 102 files changed, 10 insertions(+), 4849 deletions(-) delete mode 100644 extensions/.gitignore delete mode 100644 extensions/.pre-commit-config.yaml delete mode 100644 extensions/.ruff.toml delete mode 100644 extensions/LICENSE delete mode 100644 extensions/README.md delete mode 100644 extensions/openg2p-bg-task-registry-adapters/CODE-OF-CONDUCT.md delete mode 100644 extensions/openg2p-bg-task-registry-adapters/CONTRIBUTING.md delete mode 100644 extensions/openg2p-bg-task-registry-adapters/README.md delete mode 100644 extensions/openg2p-bg-task-registry-adapters/pyproject.toml delete mode 100644 extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/__init__.py delete mode 100644 extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/cache.py delete mode 100644 extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/computations/__init__.py delete mode 100644 extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/computations/register_household.py delete mode 100644 extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/computations/registry_farmer.py delete mode 100644 extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/factory/__init__.py delete mode 100644 extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/factory/registry_factory.py delete mode 100644 extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/interface/__init__.py delete mode 100644 extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/interface/registry_interface.py delete mode 100644 extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/migrate.py delete mode 100644 extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/models/__init__.py delete mode 100644 extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/models/beneficiary_list_summary_farmer.py delete mode 100644 extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/models/beneficiary_list_summary_household.py delete mode 100644 extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/models/register_household.py delete mode 100644 extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/models/registry_farmer.py delete mode 100644 extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/models/registry_type.py delete mode 100644 extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/schema/__init__.py delete mode 100644 extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/schema/beneficiary_list_summary.py delete mode 100644 extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/schema/beneficiary_list_summary_farmer.py delete mode 100644 extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/schema/beneficiary_list_summary_household.py delete mode 100644 extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/schema/register_household.py delete mode 100644 extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/schema/registry.py delete mode 100644 extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/schema/registry_farmer.py delete mode 100644 odoo/extensions/.gitignore delete mode 100644 odoo/extensions/LICENSE delete mode 100644 odoo/extensions/README.md delete mode 100644 odoo/extensions/g2p_registry_addon/__init__.py delete mode 100644 odoo/extensions/g2p_registry_addon/__manifest__.py delete mode 100644 odoo/extensions/g2p_registry_addon/models/__init__.py delete mode 100644 odoo/extensions/g2p_registry_addon/models/farmer_registry.py delete mode 100644 odoo/extensions/g2p_registry_addon/models/household.py delete mode 100644 odoo/extensions/g2p_registry_addon/models/registry.py delete mode 100644 odoo/extensions/g2p_registry_addon/security/ir.model.access.csv delete mode 100644 odoo/extensions/g2p_registry_addon/static/description/icon.png delete mode 100644 odoo/extensions/g2p_registry_addon/static/src/css/registry_styles.scss delete mode 100644 odoo/extensions/g2p_registry_addon/static/src/js/beneficiaries_widget.js delete mode 100644 odoo/extensions/g2p_registry_addon/static/src/xml/g2p_beneficiaries_info_tpl.xml delete mode 100644 odoo/extensions/g2p_registry_addon/views/bgtask/bgtask_view.xml delete mode 100644 odoo/extensions/g2p_registry_addon/views/eligibility/eligibility_rule_view.xml delete mode 100644 odoo/extensions/g2p_registry_addon/views/entitlement/entitlement_rule_view.xml delete mode 100644 odoo/extensions/g2p_registry_addon/views/menu.xml delete mode 100644 odoo/extensions/g2p_registry_addon/views/priority/priority_rule_view.xml delete mode 100644 odoo/extensions/g2p_registry_addon/views/registry/farmer_registry_view.xml delete mode 100644 odoo/extensions/g2p_registry_addon/views/registry/household_registry_view.xml delete mode 100644 odoo/extensions/g2p_registry_type_addon/__init__.py delete mode 100644 odoo/extensions/g2p_registry_type_addon/__manifest__.py delete mode 100644 odoo/extensions/g2p_registry_type_addon/models/__init__.py delete mode 100644 odoo/extensions/g2p_registry_type_addon/models/registry_type.py delete mode 100644 odoo/extensions/g2p_registry_type_addon/security/ir.model.access.csv delete mode 100644 odoo/extensions/g2p_registry_type_addon/static/description/icon.png delete mode 100644 odoo/extensions/pbms_theme_extension/README.md delete mode 100644 odoo/extensions/pbms_theme_extension/__init__.py delete mode 100644 odoo/extensions/pbms_theme_extension/__manifest__.py delete mode 100644 odoo/extensions/pbms_theme_extension/controllers/__init__.py delete mode 100644 odoo/extensions/pbms_theme_extension/controllers/web_login.py delete mode 100644 odoo/extensions/pbms_theme_extension/models/__init__.py delete mode 100644 odoo/extensions/pbms_theme_extension/models/res_company.py delete mode 100644 odoo/extensions/pbms_theme_extension/models/res_user.py delete mode 100644 odoo/extensions/pbms_theme_extension/pyproject.toml delete mode 100644 odoo/extensions/pbms_theme_extension/static/description/icon.png delete mode 100644 odoo/extensions/pbms_theme_extension/static/src/css/fonts/Roboto-Black.woff delete mode 100644 odoo/extensions/pbms_theme_extension/static/src/css/fonts/Roboto-BlackItalic.woff delete mode 100644 odoo/extensions/pbms_theme_extension/static/src/css/fonts/Roboto-Bold.woff delete mode 100644 odoo/extensions/pbms_theme_extension/static/src/css/fonts/Roboto-BoldItalic.woff delete mode 100644 odoo/extensions/pbms_theme_extension/static/src/css/fonts/Roboto-Italic.woff delete mode 100644 odoo/extensions/pbms_theme_extension/static/src/css/fonts/Roboto-Light.woff delete mode 100644 odoo/extensions/pbms_theme_extension/static/src/css/fonts/Roboto-LightItalic.woff delete mode 100644 odoo/extensions/pbms_theme_extension/static/src/css/fonts/Roboto-Medium.woff delete mode 100644 odoo/extensions/pbms_theme_extension/static/src/css/fonts/Roboto-MediumItalic.woff delete mode 100644 odoo/extensions/pbms_theme_extension/static/src/css/fonts/Roboto-Regular.woff delete mode 100644 odoo/extensions/pbms_theme_extension/static/src/css/fonts/Roboto-Thin.woff delete mode 100644 odoo/extensions/pbms_theme_extension/static/src/css/fonts/Roboto-ThinItalic.woff delete mode 100644 odoo/extensions/pbms_theme_extension/static/src/css/style.css delete mode 100644 odoo/extensions/pbms_theme_extension/static/src/img/57481.png delete mode 100644 odoo/extensions/pbms_theme_extension/static/src/img/57485.png delete mode 100644 odoo/extensions/pbms_theme_extension/static/src/img/favicon-black-background.png delete mode 100644 odoo/extensions/pbms_theme_extension/static/src/img/favicon-white-background.png delete mode 100644 odoo/extensions/pbms_theme_extension/static/src/img/favicon.png delete mode 100644 odoo/extensions/pbms_theme_extension/static/src/img/openg2p-black.png delete mode 100644 odoo/extensions/pbms_theme_extension/static/src/img/openg2p-white.png delete mode 100644 odoo/extensions/pbms_theme_extension/static/src/js/g2p_window_title.js delete mode 100644 odoo/extensions/pbms_theme_extension/static/src/scss/assets_menu.scss delete mode 100644 odoo/extensions/pbms_theme_extension/static/src/scss/g2p_login_page.scss delete mode 100644 odoo/extensions/pbms_theme_extension/static/src/scss/new_login_page.scss delete mode 100644 odoo/extensions/pbms_theme_extension/templates/g2p_login_page.xml delete mode 100644 odoo/extensions/pbms_theme_extension/templates/g2p_reset_password.xml delete mode 100644 odoo/extensions/pbms_theme_extension/views/webclient_templates.xml diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 442e1e9..8c637f7 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -18,7 +18,6 @@ jobs: matrix: project: - core - - extensions - apis - docker - deployment diff --git a/apis/openg2p-pbms-bene-portal-api/.env.example b/apis/openg2p-pbms-bene-portal-api/.env.example index 7f21170..1c2d161 100644 --- a/apis/openg2p-pbms-bene-portal-api/.env.example +++ b/apis/openg2p-pbms-bene-portal-api/.env.example @@ -1,4 +1,4 @@ -# Social Registry Database +# PBMS database PBMS_BENE_PORTAL_API_DB_USERNAME_PBMS='postgres' PBMS_BENE_PORTAL_API_DB_PASSWORD_PBMS='password' PBMS_BENE_PORTAL_API_DB_HOSTNAME_PBMS='localhost' diff --git a/docker/openg2p-pbms-apis/bene-portal-api/Dockerfile b/docker/openg2p-pbms-apis/bene-portal-api/Dockerfile index 997c833..0ba707b 100644 --- a/docker/openg2p-pbms-apis/bene-portal-api/Dockerfile +++ b/docker/openg2p-pbms-apis/bene-portal-api/Dockerfile @@ -1,8 +1,7 @@ FROM python:3.12.11-alpine3.22 # External OpenG2P library refs (not part of this repo). Override via build-arg / -# workflow input. The PBMS API code + registry adapter extensions are installed -# from LOCAL source (build context = repo root). +# workflow input. The beneficiary portal API is installed from local source. ARG FASTAPI_COMMON_REF=develop RUN apk add --no-cache --virtual .build-deps gcc libc-dev linux-headers make \ @@ -17,17 +16,14 @@ RUN pip install --no-cache-dir \ "git+https://github.com/openg2p/openg2p-fastapi-common@${FASTAPI_COMMON_REF}#subdirectory=openg2p-fastapi-auth-models" \ && pip install --no-cache-dir jinja2 -# Local source: PBMS + bg-task models, the beneficiary portal API, and the -# registry adapter extensions. +# Local source: PBMS + bg-task models and the beneficiary portal API. COPY core/openg2p-pbms-models /src/openg2p-pbms-models COPY core/openg2p-bg-task-models /src/openg2p-bg-task-models COPY apis/openg2p-pbms-bene-portal-api /src/openg2p-pbms-bene-portal-api -COPY extensions/openg2p-bg-task-registry-adapters /src/openg2p-bg-task-registry-adapters RUN pip install --no-cache-dir \ /src/openg2p-pbms-models \ /src/openg2p-bg-task-models \ - /src/openg2p-pbms-bene-portal-api \ - /src/openg2p-bg-task-registry-adapters + /src/openg2p-pbms-bene-portal-api RUN apk del --no-network .build-deps diff --git a/docker/openg2p-pbms-apis/staff-portal-api/Dockerfile b/docker/openg2p-pbms-apis/staff-portal-api/Dockerfile index 3dcce0b..3737597 100644 --- a/docker/openg2p-pbms-apis/staff-portal-api/Dockerfile +++ b/docker/openg2p-pbms-apis/staff-portal-api/Dockerfile @@ -1,8 +1,8 @@ FROM python:3.12.11-alpine3.22 # External OpenG2P library refs (not part of this repo). Override via build-arg / -# workflow input. The PBMS API code + registry adapter extensions are installed -# from LOCAL source (build context = repo root). +# workflow input. The staff portal API is installed from local source. +# pbms-connectors installs registry-adapters on top of this image. ARG FASTAPI_COMMON_REF=develop RUN apk add --no-cache --virtual .build-deps gcc libc-dev linux-headers make \ @@ -17,17 +17,15 @@ RUN pip install --no-cache-dir \ "git+https://github.com/openg2p/openg2p-fastapi-common@${FASTAPI_COMMON_REF}#subdirectory=openg2p-fastapi-auth-models" \ && pip install --no-cache-dir jinja2 -# Local source: PBMS + bg-task models, the staff portal API, and the registry -# adapter extensions. +# Local source: PBMS + bg-task models and the staff portal API. +# Registry adapters are installed by the pbms-connectors image. COPY core/openg2p-pbms-models /src/openg2p-pbms-models COPY core/openg2p-bg-task-models /src/openg2p-bg-task-models COPY apis/openg2p-pbms-staff-portal-api /src/openg2p-pbms-staff-portal-api -COPY extensions/openg2p-bg-task-registry-adapters /src/openg2p-bg-task-registry-adapters RUN pip install --no-cache-dir \ /src/openg2p-pbms-models \ /src/openg2p-bg-task-models \ - /src/openg2p-pbms-staff-portal-api \ - /src/openg2p-bg-task-registry-adapters + /src/openg2p-pbms-staff-portal-api RUN apk del --no-network .build-deps diff --git a/docker/openg2p-pbms-odoo/utils/Dockerfile b/docker/openg2p-pbms-odoo/utils/Dockerfile index e111d00..acbb639 100644 --- a/docker/openg2p-pbms-odoo/utils/Dockerfile +++ b/docker/openg2p-pbms-odoo/utils/Dockerfile @@ -20,7 +20,6 @@ RUN ln -s $(which python3) /usr/bin/python COPY odoo/g2p_pbms ${EXTRA_ADDONS_DIR}/pbms-core/g2p_pbms COPY odoo/g2p_pbms_program_access ${EXTRA_ADDONS_DIR}/pbms-core/g2p_pbms_program_access COPY odoo/requirements.txt ${EXTRA_ADDONS_DIR}/pbms-core/requirements.txt -COPY odoo/extensions ${EXTRA_ADDONS_DIR}/pbms-extensions COPY odoo/community-addons ${EXTRA_ADDONS_DIR}/community-addons # External OpenG2P Odoo commons, baked in at build time. diff --git a/extensions/.gitignore b/extensions/.gitignore deleted file mode 100644 index 09be0ef..0000000 --- a/extensions/.gitignore +++ /dev/null @@ -1,207 +0,0 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[codz] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py.cover -.hypothesis/ -.pytest_cache/ -cover/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -.pybuilder/ -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -# For a library or package, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: -# .python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# UV -# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control. -# This is especially recommended for binary packages to ensure reproducibility, and is more -# commonly ignored for libraries. -#uv.lock - -# poetry -# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. -# This is especially recommended for binary packages to ensure reproducibility, and is more -# commonly ignored for libraries. -# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control -#poetry.lock -#poetry.toml - -# pdm -# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. -# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python. -# https://pdm-project.org/en/latest/usage/project/#working-with-version-control -#pdm.lock -#pdm.toml -.pdm-python -.pdm-build/ - -# pixi -# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control. -#pixi.lock -# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one -# in the .venv directory. It is recommended not to include this directory in version control. -.pixi - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.envrc -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# Cython debug symbols -cython_debug/ - -# PyCharm -# JetBrains specific template is maintained in a separate JetBrains.gitignore that can -# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore -# and can be added to the global gitignore or merged into this file. For a more nuclear -# option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ - -# Abstra -# Abstra is an AI-powered process automation framework. -# Ignore directories containing user credentials, local state, and settings. -# Learn more at https://abstra.io/docs -.abstra/ - -# Visual Studio Code -# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore -# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore -# and can be added to the global gitignore or merged into this file. However, if you prefer, -# you could uncomment the following to ignore the entire vscode folder -# .vscode/ - -# Ruff stuff: -.ruff_cache/ - -# PyPI configuration file -.pypirc - -# Cursor -# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to -# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data -# refer to https://docs.cursor.com/context/ignore-files -.cursorignore -.cursorindexingignore - -# Marimo -marimo/_static/ -marimo/_lsp/ -__marimo__/ diff --git a/extensions/.pre-commit-config.yaml b/extensions/.pre-commit-config.yaml deleted file mode 100644 index 336b7e1..0000000 --- a/extensions/.pre-commit-config.yaml +++ /dev/null @@ -1,49 +0,0 @@ -exclude: | - (?x) - # We don't want to mess with tool-generated files - .svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/| - # Maybe reactivate this when all README files include prettier ignore tags? - ^README\.md$| - # Repos using Sphinx to generate docs don't need prettying - ^docs/_templates/.*\.html$| - # You don't usually want a bot to modify your legal texts - (LICENSE.*|COPYING.*) -default_language_version: - python: python3 -repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 - hooks: - - id: trailing-whitespace - - id: end-of-file-fixer - - id: debug-statements - - id: fix-encoding-pragma - args: ["--remove"] - - id: check-case-conflict - - id: check-docstring-first - - id: check-executables-have-shebangs - - id: check-merge-conflict - - id: check-symlinks - - id: check-toml - - id: check-yaml - args: - - --unsafe - - id: mixed-line-ending - args: ["--fix=lf"] - - repo: https://github.com/asottile/pyupgrade - rev: v3.11.0 - hooks: - - id: pyupgrade - args: - - --py3-plus - - --keep-runtime-typing - - repo: https://github.com/psf/black - rev: 23.9.1 - hooks: - - id: black - - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.289 - hooks: - - id: ruff - args: - - --fix diff --git a/extensions/.ruff.toml b/extensions/.ruff.toml deleted file mode 100644 index aa1fc5b..0000000 --- a/extensions/.ruff.toml +++ /dev/null @@ -1,16 +0,0 @@ -select = [ - "E", # pycodestyle errors - "W", # pycodestyle warnings - "F", # pyflakes - "I", # isort - "C", # flake8-comprehensions - "B", # flake8-bugbear -] -ignore = [ - "E501", # line too long, handled by black - "B008", # do not perform function calls in argument defaults - "C901", # too complex -] - -[per-file-ignores] -"__init__.py" = ["F401"] diff --git a/extensions/LICENSE b/extensions/LICENSE deleted file mode 100644 index a612ad9..0000000 --- a/extensions/LICENSE +++ /dev/null @@ -1,373 +0,0 @@ -Mozilla Public License Version 2.0 -================================== - -1. Definitions --------------- - -1.1. "Contributor" - means each individual or legal entity that creates, contributes to - the creation of, or owns Covered Software. - -1.2. "Contributor Version" - means the combination of the Contributions of others (if any) used - by a Contributor and that particular Contributor's Contribution. - -1.3. "Contribution" - means Covered Software of a particular Contributor. - -1.4. "Covered Software" - means Source Code Form to which the initial Contributor has attached - the notice in Exhibit A, the Executable Form of such Source Code - Form, and Modifications of such Source Code Form, in each case - including portions thereof. - -1.5. "Incompatible With Secondary Licenses" - means - - (a) that the initial Contributor has attached the notice described - in Exhibit B to the Covered Software; or - - (b) that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the - terms of a Secondary License. - -1.6. "Executable Form" - means any form of the work other than Source Code Form. - -1.7. "Larger Work" - means a work that combines Covered Software with other material, in - a separate file or files, that is not Covered Software. - -1.8. "License" - means this document. - -1.9. "Licensable" - means having the right to grant, to the maximum extent possible, - whether at the time of the initial grant or subsequently, any and - all of the rights conveyed by this License. - -1.10. "Modifications" - means any of the following: - - (a) any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered - Software; or - - (b) any new file in Source Code Form that contains any Covered - Software. - -1.11. "Patent Claims" of a Contributor - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the - License, by the making, using, selling, offering for sale, having - made, import, or transfer of either its Contributions or its - Contributor Version. - -1.12. "Secondary License" - means either the GNU General Public License, Version 2.0, the GNU - Lesser General Public License, Version 2.1, the GNU Affero General - Public License, Version 3.0, or any later versions of those - licenses. - -1.13. "Source Code Form" - means the form of the work preferred for making modifications. - -1.14. "You" (or "Your") - means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that - controls, is controlled by, or is under common control with You. For - purposes of this definition, "control" means (a) the power, direct - or indirect, to cause the direction or management of such entity, - whether by contract or otherwise, or (b) ownership of more than - fifty percent (50%) of the outstanding shares or beneficial - ownership of such entity. - -2. License Grants and Conditions --------------------------------- - -2.1. Grants - -Each Contributor hereby grants You a world-wide, royalty-free, -non-exclusive license: - -(a) under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or - as part of a Larger Work; and - -(b) under Patent Claims of such Contributor to make, use, sell, offer - for sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. - -2.2. Effective Date - -The licenses granted in Section 2.1 with respect to any Contribution -become effective for each Contribution on the date the Contributor first -distributes such Contribution. - -2.3. Limitations on Grant Scope - -The licenses granted in this Section 2 are the only rights granted under -this License. No additional rights or licenses will be implied from the -distribution or licensing of Covered Software under this License. -Notwithstanding Section 2.1(b) above, no patent license is granted by a -Contributor: - -(a) for any code that a Contributor has removed from Covered Software; - or - -(b) for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - -(c) under Patent Claims infringed by Covered Software in the absence of - its Contributions. - -This License does not grant any rights in the trademarks, service marks, -or logos of any Contributor (except as may be necessary to comply with -the notice requirements in Section 3.4). - -2.4. Subsequent Licenses - -No Contributor makes additional grants as a result of Your choice to -distribute the Covered Software under a subsequent version of this -License (see Section 10.2) or under the terms of a Secondary License (if -permitted under the terms of Section 3.3). - -2.5. Representation - -Each Contributor represents that the Contributor believes its -Contributions are its original creation(s) or it has sufficient rights -to grant the rights to its Contributions conveyed by this License. - -2.6. Fair Use - -This License is not intended to limit any rights You have under -applicable copyright doctrines of fair use, fair dealing, or other -equivalents. - -2.7. Conditions - -Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted -in Section 2.1. - -3. Responsibilities -------------------- - -3.1. Distribution of Source Form - -All distribution of Covered Software in Source Code Form, including any -Modifications that You create or to which You contribute, must be under -the terms of this License. You must inform recipients that the Source -Code Form of the Covered Software is governed by the terms of this -License, and how they can obtain a copy of this License. You may not -attempt to alter or restrict the recipients' rights in the Source Code -Form. - -3.2. Distribution of Executable Form - -If You distribute Covered Software in Executable Form then: - -(a) such Covered Software must also be made available in Source Code - Form, as described in Section 3.1, and You must inform recipients of - the Executable Form how they can obtain a copy of such Source Code - Form by reasonable means in a timely manner, at a charge no more - than the cost of distribution to the recipient; and - -(b) You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter - the recipients' rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - -You may create and distribute a Larger Work under terms of Your choice, -provided that You also comply with the requirements of this License for -the Covered Software. If the Larger Work is a combination of Covered -Software with a work governed by one or more Secondary Licenses, and the -Covered Software is not Incompatible With Secondary Licenses, this -License permits You to additionally distribute such Covered Software -under the terms of such Secondary License(s), so that the recipient of -the Larger Work may, at their option, further distribute the Covered -Software under the terms of either this License or such Secondary -License(s). - -3.4. Notices - -You may not remove or alter the substance of any license notices -(including copyright notices, patent notices, disclaimers of warranty, -or limitations of liability) contained within the Source Code Form of -the Covered Software, except that You may alter any license notices to -the extent required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - -You may choose to offer, and to charge a fee for, warranty, support, -indemnity or liability obligations to one or more recipients of Covered -Software. However, You may do so only on Your own behalf, and not on -behalf of any Contributor. You must make it absolutely clear that any -such warranty, support, indemnity, or liability obligation is offered by -You alone, and You hereby agree to indemnify every Contributor for any -liability incurred by such Contributor as a result of warranty, support, -indemnity or liability terms You offer. You may include additional -disclaimers of warranty and limitations of liability specific to any -jurisdiction. - -4. Inability to Comply Due to Statute or Regulation ---------------------------------------------------- - -If it is impossible for You to comply with any of the terms of this -License with respect to some or all of the Covered Software due to -statute, judicial order, or regulation then You must: (a) comply with -the terms of this License to the maximum extent possible; and (b) -describe the limitations and the code they affect. Such description must -be placed in a text file included with all distributions of the Covered -Software under this License. Except to the extent prohibited by statute -or regulation, such description must be sufficiently detailed for a -recipient of ordinary skill to be able to understand it. - -5. Termination --------------- - -5.1. The rights granted under this License will terminate automatically -if You fail to comply with any of its terms. However, if You become -compliant, then the rights granted under this License from a particular -Contributor are reinstated (a) provisionally, unless and until such -Contributor explicitly and finally terminates Your grants, and (b) on an -ongoing basis, if such Contributor fails to notify You of the -non-compliance by some reasonable means prior to 60 days after You have -come back into compliance. Moreover, Your grants from a particular -Contributor are reinstated on an ongoing basis if such Contributor -notifies You of the non-compliance by some reasonable means, this is the -first time You have received notice of non-compliance with this License -from such Contributor, and You become compliant prior to 30 days after -Your receipt of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent -infringement claim (excluding declaratory judgment actions, -counter-claims, and cross-claims) alleging that a Contributor Version -directly or indirectly infringes any patent, then the rights granted to -You by any and all Contributors for the Covered Software under Section -2.1 of this License shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all -end user license agreements (excluding distributors and resellers) which -have been validly granted by You or Your distributors under this License -prior to termination shall survive termination. - -************************************************************************ -* * -* 6. Disclaimer of Warranty * -* ------------------------- * -* * -* Covered Software is provided under this License on an "as is" * -* basis, without warranty of any kind, either expressed, implied, or * -* statutory, including, without limitation, warranties that the * -* Covered Software is free of defects, merchantable, fit for a * -* particular purpose or non-infringing. The entire risk as to the * -* quality and performance of the Covered Software is with You. * -* Should any Covered Software prove defective in any respect, You * -* (not any Contributor) assume the cost of any necessary servicing, * -* repair, or correction. This disclaimer of warranty constitutes an * -* essential part of this License. No use of any Covered Software is * -* authorized under this License except under this disclaimer. * -* * -************************************************************************ - -************************************************************************ -* * -* 7. Limitation of Liability * -* -------------------------- * -* * -* Under no circumstances and under no legal theory, whether tort * -* (including negligence), contract, or otherwise, shall any * -* Contributor, or anyone who distributes Covered Software as * -* permitted above, be liable to You for any direct, indirect, * -* special, incidental, or consequential damages of any character * -* including, without limitation, damages for lost profits, loss of * -* goodwill, work stoppage, computer failure or malfunction, or any * -* and all other commercial damages or losses, even if such party * -* shall have been informed of the possibility of such damages. This * -* limitation of liability shall not apply to liability for death or * -* personal injury resulting from such party's negligence to the * -* extent applicable law prohibits such limitation. Some * -* jurisdictions do not allow the exclusion or limitation of * -* incidental or consequential damages, so this exclusion and * -* limitation may not apply to You. * -* * -************************************************************************ - -8. Litigation -------------- - -Any litigation relating to this License may be brought only in the -courts of a jurisdiction where the defendant maintains its principal -place of business and such litigation shall be governed by laws of that -jurisdiction, without reference to its conflict-of-law provisions. -Nothing in this Section shall prevent a party's ability to bring -cross-claims or counter-claims. - -9. Miscellaneous ----------------- - -This License represents the complete agreement concerning the subject -matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the extent -necessary to make it enforceable. Any law or regulation which provides -that the language of a contract shall be construed against the drafter -shall not be used to construe this License against a Contributor. - -10. Versions of the License ---------------------------- - -10.1. New Versions - -Mozilla Foundation is the license steward. Except as provided in Section -10.3, no one other than the license steward has the right to modify or -publish new versions of this License. Each version will be given a -distinguishing version number. - -10.2. Effect of New Versions - -You may distribute the Covered Software under the terms of the version -of the License under which You originally received the Covered Software, -or under the terms of any subsequent version published by the license -steward. - -10.3. Modified Versions - -If you create software not governed by this License, and you want to -create a new license for such software, you may create and use a -modified version of this License if you rename the license and remove -any references to the name of the license steward (except to note that -such modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary -Licenses - -If You choose to distribute Source Code Form that is Incompatible With -Secondary Licenses under the terms of this version of the License, the -notice described in Exhibit B of this License must be attached. - -Exhibit A - Source Code Form License Notice -------------------------------------------- - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - -If it is not possible or desirable to put the notice in a particular -file, then You may include the notice in a location (such as a LICENSE -file in a relevant directory) where a recipient would be likely to look -for such a notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - "Incompatible With Secondary Licenses" Notice ---------------------------------------------------------- - - This Source Code Form is "Incompatible With Secondary Licenses", as - defined by the Mozilla Public License, v. 2.0. diff --git a/extensions/README.md b/extensions/README.md deleted file mode 100644 index cf5dcd5..0000000 --- a/extensions/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# openg2p-pbms-bg-tasks-extensions - -Registry adapter extensions for the OpenG2P PBMS background-task engine. diff --git a/extensions/openg2p-bg-task-registry-adapters/CODE-OF-CONDUCT.md b/extensions/openg2p-bg-task-registry-adapters/CODE-OF-CONDUCT.md deleted file mode 100644 index e1949e1..0000000 --- a/extensions/openg2p-bg-task-registry-adapters/CODE-OF-CONDUCT.md +++ /dev/null @@ -1,114 +0,0 @@ -# Code of Conduct - -## Contributor Covenant Code of Conduct - -### Preamble - -OpenG2P was created to foster an open, innovative and inclusive community around open source & open standard. -To clarify expected behaviour in our communities we have adopted the Contributor Covenant. This code of -conduct has been adopted by many other open source communities and we feel it expresses our values well. - -### Our Pledge - -We as members, contributors, and leaders pledge to make participation in our community a harassment-free -experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex -characteristics, gender identity and expression, level of experience, education, socio-economic status, -nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation. - -We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy -community. - -### Our Standards - -Examples of behavior that contributes to a positive environment for our community include: - -- Demonstrating empathy and kindness toward other people -- Being respectful of differing opinions, viewpoints, and experiences -- Giving and gracefully accepting constructive feedback -- Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience -- Focusing on what is best not just for us as individuals, but for the overall community - -Examples of unacceptable behavior include: - -- The use of sexualized language or imagery, and sexual attention or advances of any kind -- Trolling, insulting or derogatory comments, and personal or political attacks -- Public or private harassment -- Publishing others' private information, such as a physical or email address, without their explicit - permission -- Other conduct which could reasonably be considered inappropriate in a professional setting - -### Enforcement Responsibilities - -Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will -take appropriate and fair corrective action in response to any behavior that they deem inappropriate, -threatening, offensive, or harmful. - -Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki -edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate -reasons for moderation decisions when appropriate. - -### Scope - -This Code of Conduct applies within all community spaces, and also applies when an individual is officially -representing the community in public spaces. Examples of representing our community include using an official -e-mail address, posting via an official social media account, or acting as an appointed representative at an -online or offline event. - -### Enforcement - -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders -responsible for enforcement at \[INSERT CONTACT METHOD]. All complaints will be reviewed and investigated -promptly and fairly. - -All community leaders are obligated to respect the privacy and security of the reporter of any incident. - -### Enforcement Guidelines - -Community leaders will follow these Community Impact Guidelines in determining the consequences for any action -they deem in violation of this Code of Conduct: - -#### 1. Correction - -**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in -the community. - -**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the -violation and an explanation of why the behavior was inappropriate. A public apology may be requested. - -#### 2. Warning - -**Community Impact**: A violation through a single incident or series of actions. - -**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, -including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. -This includes avoiding interactions in community spaces as well as external channels like social media. -Violating these terms may lead to a temporary or permanent ban. - -#### 3. Temporary Ban - -**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. - -**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a -specified period of time. No public or private interaction with the people involved, including unsolicited -interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may -lead to a permanent ban. - -#### 4. Permanent Ban - -**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained -inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of -individuals. - -**Consequence**: A permanent ban from any sort of public interaction within the community. - -### Attribution - -This Code of Conduct is adapted from the -[Contributor Covenant version 2.1](https://www.contributor-covenant.org/version/2/1/code_of_conduct/). - -Community Impact Guidelines were inspired by -[Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity). - -For answers to common questions about this code of conduct, see the -[FAQ](https://www.contributor-covenant.org/faq). Translations are available -[here](https://www.contributor-covenant.org/translations). diff --git a/extensions/openg2p-bg-task-registry-adapters/CONTRIBUTING.md b/extensions/openg2p-bg-task-registry-adapters/CONTRIBUTING.md deleted file mode 100644 index c187f93..0000000 --- a/extensions/openg2p-bg-task-registry-adapters/CONTRIBUTING.md +++ /dev/null @@ -1,2 +0,0 @@ -Refer to contribution guidelines -[here](https://github.com/OpenG2P/openg2p-documentation/blob/1.0.0/community/contributing-to-openg2p.md). diff --git a/extensions/openg2p-bg-task-registry-adapters/README.md b/extensions/openg2p-bg-task-registry-adapters/README.md deleted file mode 100644 index e69de29..0000000 diff --git a/extensions/openg2p-bg-task-registry-adapters/pyproject.toml b/extensions/openg2p-bg-task-registry-adapters/pyproject.toml deleted file mode 100644 index 36635ed..0000000 --- a/extensions/openg2p-bg-task-registry-adapters/pyproject.toml +++ /dev/null @@ -1,33 +0,0 @@ -[build-system] -requires = ["hatchling"] -build-backend = "hatchling.build" - -[project] -name = "openg2p-bg-task-registry-adapters" -authors = [ - { name="OpenG2P", email="info@openg2p.org" }, -] -description = "OpenG2P PBMS Background Task Registry Adapters" -readme = "README.md" -requires-python = ">=3.7" -classifiers = [ - "Programming Language :: Python :: 3", - "License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)", - "Operating System :: OS Independent", -] -dependencies = [ - "openg2p-fastapi-common", - "openg2p-fastapi-auth", - "fastapi-cache2", - "numpy" -] -dynamic = ["version"] - -[project.urls] -Homepage = "https://openg2p.org" -Documentation = "https://docs.openg2p.org/" -Repository = "https://github.com/OpenG2P/pbms" -Source = "https://github.com/OpenG2P/pbms" - -[tool.hatch.version] -path = "src/openg2p_bg_task_registry_adapters/__init__.py" diff --git a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/__init__.py b/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/__init__.py deleted file mode 100644 index d539d50..0000000 --- a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/__init__.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = "3.1.1" diff --git a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/cache.py b/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/cache.py deleted file mode 100644 index b0fab13..0000000 --- a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/cache.py +++ /dev/null @@ -1,18 +0,0 @@ -from fastapi_cache import FastAPICache -from fastapi_cache.backends.inmemory import InMemoryBackend - - -def init_cache(): - FastAPICache.init(InMemoryBackend(), prefix="fastapi-cache") - - -# Custom key builder function -def beneficiary_count_key_builder(func, namespace: str, *args, **kwargs): - """ - Build a custom cache key with `beneficiary_list_id` and `search_query`. - """ - args: list = kwargs.get("args") - beneficiary_list_id: str = args[2] - search_query: str = args[4] - - return f"{namespace}{beneficiary_list_id}{search_query}" diff --git a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/computations/__init__.py b/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/computations/__init__.py deleted file mode 100644 index d33549d..0000000 --- a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/computations/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -from .register_household import RegisterHousehold -from .registry_farmer import RegistryFarmer diff --git a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/computations/register_household.py b/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/computations/register_household.py deleted file mode 100644 index bbf5819..0000000 --- a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/computations/register_household.py +++ /dev/null @@ -1,438 +0,0 @@ -import logging -from typing import Any, Dict, List, Optional, Tuple - -import numpy as np -from fastapi_cache.decorator import cache -from openg2p_bg_task_models.models import BeneficiaryListDetails -from openg2p_bg_task_models.schemas import ( - BeneficiarySearchResponsePayload, - RegistrantDetails, -) -from sqlalchemy import update -from sqlalchemy.ext.asyncio import AsyncSession -from sqlalchemy.future import select -from sqlalchemy.orm import Session - -from ..cache import beneficiary_count_key_builder -from ..interface import RegistryInterface -from ..models import ( - BeneficiaryListSummaryHousehold as BeneficiaryListSummaryHouseholdModel, -) -from ..models import G2PRegisterHousehold -from ..schema import ( - BeneficiaryListSummary, - BeneficiaryListSummaryHousehold, - BeneficiaryListSummaryHouseholdPayload, - G2PRegisterHouseholdPayload, -) - -_logger = logging.getLogger("app") - - -class RegisterHousehold(RegistryInterface): - """Fetches household data and computes summary statistics""" - - # =================== - # Summary API Methods - # =================== - async def get_summary( - self, - beneficiary_list_id: str, - bg_task_session: AsyncSession, - formated: bool = False, - ) -> BeneficiaryListSummaryHouseholdPayload: - result = await bg_task_session.execute( - select(BeneficiaryListSummaryHouseholdModel).where( - BeneficiaryListSummaryHouseholdModel.beneficiary_list_id - == beneficiary_list_id - ) - ) - summary_row = result.scalars().first() - return self._build_summary_payload(summary_row) - - def get_summary_sync( - self, beneficiary_list_id: str, bg_task_session: Session - ) -> BeneficiaryListSummaryHouseholdPayload: - summary_row = ( - bg_task_session.query(BeneficiaryListSummaryHouseholdModel) - .filter_by(beneficiary_list_id=beneficiary_list_id) - .first() - ) - return self._build_summary_payload(summary_row) - - def _build_summary_payload(self, row) -> BeneficiaryListSummaryHouseholdPayload: - def fmt(value, units): - return f"{value} {units}" if value is not None else None - - return BeneficiaryListSummaryHouseholdPayload( - beneficiary_list_summary=BeneficiaryListSummary( - id=row.id, - program_id=row.program_id, - program_mnemonic=row.program_mnemonic, - target_registry=row.target_registry, - beneficiary_list_id=row.beneficiary_list_id, - number_of_registrants=row.number_of_registrants, - date_created=row.date_created, - total_disbursement_quantity=row.total_disbursement_quantity, - average_entitlement_per_registrant=row.average_entitlement_per_person, - ), - registry_summary=BeneficiaryListSummaryHousehold( - size_children_u5_mean=fmt( - row.size_children_u5_mean, row.size_children_u5_units - ), - size_children_u5_q1=fmt( - row.size_children_u5_q1, row.size_children_u5_units - ), - size_children_u5_q2=fmt( - row.size_children_u5_q2, row.size_children_u5_units - ), - size_children_u5_q3=fmt( - row.size_children_u5_q3, row.size_children_u5_units - ), - size_elderly_mean=fmt(row.size_elderly_mean, row.size_elderly_units), - size_elderly_q1=fmt(row.size_elderly_q1, row.size_elderly_units), - size_elderly_q2=fmt(row.size_elderly_q2, row.size_elderly_units), - size_elderly_q3=fmt(row.size_elderly_q3, row.size_elderly_units), - rooms_count_mean=fmt(row.rooms_count_mean, row.rooms_count_units), - rooms_count_q1=fmt(row.rooms_count_q1, row.rooms_count_units), - rooms_count_q2=fmt(row.rooms_count_q2, row.rooms_count_units), - rooms_count_q3=fmt(row.rooms_count_q3, row.rooms_count_units), - overcrowding_indicator_mean=fmt( - row.overcrowding_indicator_mean, row.overcrowding_indicator_units - ), - overcrowding_indicator_q1=fmt( - row.overcrowding_indicator_q1, row.overcrowding_indicator_units - ), - overcrowding_indicator_q2=fmt( - row.overcrowding_indicator_q2, row.overcrowding_indicator_units - ), - overcrowding_indicator_q3=fmt( - row.overcrowding_indicator_q3, row.overcrowding_indicator_units - ), - entitlement_amount_q1=row.entitlement_amount_q1, - entitlement_amount_q2=row.entitlement_amount_q2, - entitlement_amount_q3=row.entitlement_amount_q3, - ), - ) - - # ============================== - # Beneficiary Search API Methods - # ============================== - async def search_beneficiaries( - self, - bg_task_session: AsyncSession, - sr_session: AsyncSession, - beneficiary_list_id: str, - target_registry: str, - search_query, - page: int = 1, - page_size: int = 10, - order_by: str = "internal_record_id asc", - ) -> Tuple[BeneficiarySearchResponsePayload, int]: - registrant_details_result = await bg_task_session.execute( - select(BeneficiaryListDetails.registrant_details).where( - BeneficiaryListDetails.beneficiary_list_id == beneficiary_list_id - ) - ) - registrant_details = registrant_details_result.scalars().all() - _logger.info( - "search_beneficiaries: beneficiary_list_id=%r registrant_details row_count=%d", - beneficiary_list_id, - len(registrant_details), - ) - registrant_ids = [] - for registrant_detail in registrant_details: - for registrant in registrant_detail: - registrant_ids.append(registrant["registrant_id"]) - - _logger.info( - "search_beneficiaries: registrant_ids count=%d ids=%r", - len(registrant_ids), - registrant_ids, - ) - _logger.info( - "search_beneficiaries: search_query=%r order_by=%r page=%r page_size=%r", - search_query, - order_by, - page, - page_size, - ) - - ( - household_search_query, - household_search_params, - ) = self.construct_beneficiary_search_sql_query( - registrant_ids, - target_registry, - search_query, - order_by, - page_size, - page, - ) - _logger.info( - "search_beneficiaries: sql=%r params=%r", - str(household_search_query), - household_search_params, - ) - - household_search_results = ( - (await sr_session.execute(household_search_query, household_search_params)) - .mappings() - .all() - ) - _logger.info( - "search_beneficiaries: result_count=%d", len(household_search_results) - ) - - total_beneficiary_count: int = await self._get_total_beneficiary_count( - sr_session, beneficiary_list_id, registrant_ids, search_query - ) - _logger.info( - "search_beneficiaries: total_beneficiary_count=%d", total_beneficiary_count - ) - - beneficiaries = [] - if household_search_results: - beneficiaries = [ - G2PRegisterHouseholdPayload( - internal_record_id=row["internal_record_id"], - functional_record_id=row["functional_record_id"], - household_head_name=row["household_head_name"], - headship_type=row["headship_type"], - size_total=row["size_total"], - size_children_u5=row["size_children_u5"], - size_elderly=row["size_elderly"], - number_of_female_members=row["number_of_female_members"], - number_of_male_members=row["number_of_male_members"], - dwelling_type=row["dwelling_type"], - tenure_status=row["tenure_status"], - rooms_count=row["rooms_count"], - overcrowding_indicator=float(row["overcrowding_indicator"]) - if row["overcrowding_indicator"] is not None - else None, - water_source_type=row["water_source_type"], - sanitation_type=row["sanitation_type"], - lighting_source=row["lighting_source"], - cooking_fuel_type=row["cooking_fuel_type"], - address_line_1=row["address_line_1"], - address_line_2=row["address_line_2"], - postal_code=row["postal_code"], - country_code=row["country_code"], - ) - for row in household_search_results - ] - - response_payload = BeneficiarySearchResponsePayload( - beneficiary_count=len(beneficiaries), - beneficiaries=beneficiaries, - ) - - return response_payload, total_beneficiary_count - - @cache(expire=120, key_builder=beneficiary_count_key_builder) - async def _get_total_beneficiary_count( - self, - sr_session: AsyncSession, - beneficiary_list_id: str, - registrant_ids: List[str], - search_query: Optional[str] = None, - ) -> int: - _logger.info( - "_get_total_beneficiary_count: registrant_ids count=%d search_query=%r", - len(registrant_ids), - search_query, - ) - ( - beneficiary_count_query, - beneficiary_count_params, - ) = self.construct_beneficiary_search_count_sql_query( - registrant_ids, "households", search_query - ) - _logger.info( - "_get_total_beneficiary_count: count_sql=%r params=%r", - str(beneficiary_count_query), - beneficiary_count_params, - ) - total_beneficiary_count = ( - await sr_session.execute(beneficiary_count_query, beneficiary_count_params) - ).scalar_one() - _logger.info("_get_total_beneficiary_count: result=%d", total_beneficiary_count) - return total_beneficiary_count - - # ================================= - # Eligibility Celery Worker Methods - # ================================= - def compute_eligibility_statistics( - self, - beneficiary_list_details: List[BeneficiaryListDetails], - base_summary, - sr_session: Session, - bg_task_session: Session, - ): - household_summary = BeneficiaryListSummaryHouseholdModel( - program_id=base_summary.program_id, - program_mnemonic=base_summary.program_mnemonic, - target_registry=base_summary.target_registry, - beneficiary_list_id=base_summary.beneficiary_list_id, - number_of_registrants=base_summary.number_of_registrants, - date_created=base_summary.date_created, - ) - - size_children_u5: List[int] = [] - size_elderly: List[int] = [] - rooms_count: List[int] = [] - overcrowding_indicator: List[float] = [] - - for beneficiary_list_detail in beneficiary_list_details: - registrant_ids = [] - for registrant_detail in beneficiary_list_detail.registrant_details: - registrant_detail = RegistrantDetails(**registrant_detail) - registrant_ids.append(registrant_detail.registrant_id) - - registrants = self.get_registrants_by_ids(registrant_ids, sr_session) - for household in registrants: - if household.size_children_u5 is not None: - size_children_u5.append(household.size_children_u5) - if household.size_elderly is not None: - size_elderly.append(household.size_elderly) - if household.rooms_count is not None: - rooms_count.append(household.rooms_count) - if household.overcrowding_indicator is not None: - overcrowding_indicator.append( - float(household.overcrowding_indicator) - ) - - self._apply_quartiles(household_summary, "size_children_u5", size_children_u5) - self._apply_quartiles(household_summary, "size_elderly", size_elderly) - self._apply_quartiles(household_summary, "rooms_count", rooms_count) - self._apply_quartiles( - household_summary, "overcrowding_indicator", overcrowding_indicator - ) - - bg_task_session.add(household_summary) - - @staticmethod - def _apply_quartiles(summary_obj, prefix: str, values: List[float]) -> None: - if not values: - return - arr = np.array(values) - setattr(summary_obj, f"{prefix}_mean", round(float(np.mean(arr)), 2)) - setattr( - summary_obj, - f"{prefix}_q1", - round(float(np.percentile(arr, 25, method="midpoint")), 2), - ) - setattr( - summary_obj, - f"{prefix}_q2", - round(float(np.percentile(arr, 50, method="midpoint")), 2), - ) - setattr( - summary_obj, - f"{prefix}_q3", - round(float(np.percentile(arr, 75, method="midpoint")), 2), - ) - - def get_registrants_by_ids( - self, registrant_ids, sr_session - ) -> List[G2PRegisterHousehold]: - households = sr_session.query(G2PRegisterHousehold).filter( - G2PRegisterHousehold.internal_record_id.in_(registrant_ids) - ) - return list(households.yield_per(500)) - - # ================================= - # Entitlement Celery Worker Methods - # ================================= - def get_is_registant_entitled( - self, registrant_id: str, sql_query: str, sr_session: Session - ) -> bool: - sql_query_with_registrant_id = ( - self.construct_get_is_registrant_entitled_sql_query( - registrant_id, "households", sql_query - ) - ) - result = sr_session.execute(sql_query_with_registrant_id).fetchone() - return result is not None - - def get_entitlement_multiplier( - self, multiplier: str, registrant_id: str, sr_session: Session - ) -> int: - if not multiplier or multiplier == "none": - return 1 - - sql_query = self.construct_multiplier_sql_query( - multiplier, target_registry="households" - ) - params = {"registrant_id": registrant_id} - result = sr_session.execute(sql_query, params).fetchone() - multiplier_value: int = ( - int(result[0]) if result and result[0] is not None else 1 - ) - return multiplier_value - - def compute_entitlement_statistics( - self, beneficiary_list_id: str, bg_task_session: Session, sr_session: Session - ): - beneficiary_list_details = ( - bg_task_session.query(BeneficiaryListDetails) - .filter_by(beneficiary_list_id=beneficiary_list_id) - .all() - ) - - entitlements: Dict[Any, List[float]] = {} - - for beneficiary_list_detail in beneficiary_list_details: - for registrant_detail in beneficiary_list_detail.registrant_details: - registrant_detail = RegistrantDetails(**registrant_detail) - for benefit_code_id, value in registrant_detail.entitlement.items(): - entitlements.setdefault(benefit_code_id, []).append(value) - - entitlement_stats = self.compute_stats_dict(entitlements) - - bg_task_session.execute( - update(BeneficiaryListSummaryHouseholdModel) - .where( - BeneficiaryListSummaryHouseholdModel.beneficiary_list_id - == beneficiary_list_id - ) - .values( - total_disbursement_quantity=dict(entitlement_stats["total"]), - average_entitlement_per_person=dict(entitlement_stats["average"]), - entitlement_amount_q1=dict(entitlement_stats["q1"]), - entitlement_amount_q2=dict(entitlement_stats["q2"]), - entitlement_amount_q3=dict(entitlement_stats["q3"]), - ) - ) - - def compute_stats_dict( - self, entitlements_dict: Dict[Any, List[float]] - ) -> Dict[str, Dict[Any, float]]: - stats: Dict[str, Dict[Any, float]] = { - "average": {}, - "q1": {}, - "q2": {}, - "q3": {}, - "total": {}, - } - for benefit_code_id, values in entitlements_dict.items(): - if not values: - stats["average"][benefit_code_id] = 0.0 - stats["q1"][benefit_code_id] = 0.0 - stats["q2"][benefit_code_id] = 0.0 - stats["q3"][benefit_code_id] = 0.0 - stats["total"][benefit_code_id] = 0.0 - else: - arr = np.array(values) - stats["average"][benefit_code_id] = round(float(np.mean(arr)), 2) - stats["q1"][benefit_code_id] = round( - float(np.percentile(arr, 25, method="midpoint")), 2 - ) - stats["q2"][benefit_code_id] = round( - float(np.percentile(arr, 50, method="midpoint")), 2 - ) - stats["q3"][benefit_code_id] = round( - float(np.percentile(arr, 75, method="midpoint")), 2 - ) - stats["total"][benefit_code_id] = float(np.sum(arr)) - return stats diff --git a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/computations/registry_farmer.py b/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/computations/registry_farmer.py deleted file mode 100644 index 69721af..0000000 --- a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/computations/registry_farmer.py +++ /dev/null @@ -1,434 +0,0 @@ -from typing import List - -import numpy as np -from fastapi_cache.decorator import cache -from openg2p_bg_task_models.models import BeneficiaryListDetails -from openg2p_bg_task_models.schemas import ( - BeneficiarySearchResponsePayload, - RegistrantDetails, -) -from openg2p_pbms_models.models import Gender -from sqlalchemy import update -from sqlalchemy.ext.asyncio import AsyncSession -from sqlalchemy.future import select -from sqlalchemy.orm import Session - -from ..cache import beneficiary_count_key_builder -from ..interface import RegistryInterface -from ..models import ( - BeneficiaryListSummaryFarmer as BeneficiaryListSummaryFarmerModel, -) -from ..models import ( - G2PFarmerRegistry, -) -from ..schema import ( - BeneficiaryListSummary, - BeneficiaryListSummaryFarmer, - BeneficiaryListSummaryFarmerPayload, - G2PFarmerRegistryPayload, -) - - -class RegistryFarmer(RegistryInterface): - """Fetches farmer data and computes summary statistics""" - - # =================== - # Summary API Methods - # =================== - async def get_summary( - self, - beneficiary_list_id: str, - bg_task_session: AsyncSession, - formated: bool = False, - ) -> BeneficiaryListSummaryFarmerPayload: - beneficiary_list_summary_farmer = await bg_task_session.execute( - select(BeneficiaryListSummaryFarmerModel).where( - BeneficiaryListSummaryFarmerModel.beneficiary_list_id - == beneficiary_list_id - ) - ) - beneficiary_list_summary_farmer = ( - beneficiary_list_summary_farmer.scalars().first() - ) - - summary_farmer_payload = BeneficiaryListSummaryFarmerPayload( - beneficiary_list_summary=BeneficiaryListSummary( - id=beneficiary_list_summary_farmer.id, - program_id=beneficiary_list_summary_farmer.program_id, - program_mnemonic=beneficiary_list_summary_farmer.program_mnemonic, - target_registry=beneficiary_list_summary_farmer.target_registry, - beneficiary_list_id=beneficiary_list_summary_farmer.beneficiary_list_id, - number_of_registrants=beneficiary_list_summary_farmer.number_of_registrants, - date_created=beneficiary_list_summary_farmer.date_created, - total_disbursement_quantity=beneficiary_list_summary_farmer.total_disbursement_quantity, - average_entitlement_per_registrant=beneficiary_list_summary_farmer.average_entitlement_per_person, - ), - registry_summary=BeneficiaryListSummaryFarmer( - estimated_age_mean=f"{beneficiary_list_summary_farmer.estimated_age_mean} {beneficiary_list_summary_farmer.estimated_age_units}" - if beneficiary_list_summary_farmer.estimated_age_mean is not None - else None, - estimated_age_q1=f"{beneficiary_list_summary_farmer.estimated_age_q1} {beneficiary_list_summary_farmer.estimated_age_units}" - if beneficiary_list_summary_farmer.estimated_age_q1 is not None - else None, - estimated_age_q2=f"{beneficiary_list_summary_farmer.estimated_age_q2} {beneficiary_list_summary_farmer.estimated_age_units}" - if beneficiary_list_summary_farmer.estimated_age_q2 is not None - else None, - estimated_age_q3=f"{beneficiary_list_summary_farmer.estimated_age_q3} {beneficiary_list_summary_farmer.estimated_age_units}" - if beneficiary_list_summary_farmer.estimated_age_q3 is not None - else None, - average_entitlement_female=beneficiary_list_summary_farmer.average_entitlement_female, - average_entitlement_male=beneficiary_list_summary_farmer.average_entitlement_male, - entitlement_amount_q3=beneficiary_list_summary_farmer.entitlement_amount_q3, - entitlement_amount_q2=beneficiary_list_summary_farmer.entitlement_amount_q2, - entitlement_amount_q1=beneficiary_list_summary_farmer.entitlement_amount_q1, - entitlement_amount_male_q3=beneficiary_list_summary_farmer.entitlement_amount_male_q3, - entitlement_amount_male_q2=beneficiary_list_summary_farmer.entitlement_amount_male_q2, - entitlement_amount_male_q1=beneficiary_list_summary_farmer.entitlement_amount_male_q1, - entitlement_amount_female_q3=beneficiary_list_summary_farmer.entitlement_amount_female_q3, - entitlement_amount_female_q2=beneficiary_list_summary_farmer.entitlement_amount_female_q2, - entitlement_amount_female_q1=beneficiary_list_summary_farmer.entitlement_amount_female_q1, - ), - ) - - return summary_farmer_payload - - def get_summary_sync( - self, beneficiary_list_id: str, bg_task_session: Session - ) -> BeneficiaryListSummaryFarmerPayload: - beneficiary_list_summary_farmer = ( - bg_task_session.query(BeneficiaryListSummaryFarmerModel) - .filter_by(beneficiary_list_id=beneficiary_list_id) - .first() - ) - - summary_farmer_payload = BeneficiaryListSummaryFarmerPayload( - beneficiary_list_summary=BeneficiaryListSummary( - id=beneficiary_list_summary_farmer.id, - program_id=beneficiary_list_summary_farmer.program_id, - program_mnemonic=beneficiary_list_summary_farmer.program_mnemonic, - target_registry=beneficiary_list_summary_farmer.target_registry, - beneficiary_list_id=beneficiary_list_summary_farmer.beneficiary_list_id, - number_of_registrants=beneficiary_list_summary_farmer.number_of_registrants, - date_created=beneficiary_list_summary_farmer.date_created, - total_disbursement_quantity=beneficiary_list_summary_farmer.total_disbursement_quantity, - average_entitlement_per_registrant=beneficiary_list_summary_farmer.average_entitlement_per_person, - ), - registry_summary=BeneficiaryListSummaryFarmer( - estimated_age_mean=f"{beneficiary_list_summary_farmer.estimated_age_mean} {beneficiary_list_summary_farmer.estimated_age_units}" - if beneficiary_list_summary_farmer.estimated_age_mean is not None - else None, - estimated_age_q3=f"{beneficiary_list_summary_farmer.estimated_age_q3} {beneficiary_list_summary_farmer.estimated_age_units}" - if beneficiary_list_summary_farmer.estimated_age_q3 is not None - else None, - estimated_age_q2=f"{beneficiary_list_summary_farmer.estimated_age_q2} {beneficiary_list_summary_farmer.estimated_age_units}" - if beneficiary_list_summary_farmer.estimated_age_q2 is not None - else None, - estimated_age_q1=f"{beneficiary_list_summary_farmer.estimated_age_q1} {beneficiary_list_summary_farmer.estimated_age_units}" - if beneficiary_list_summary_farmer.estimated_age_q1 is not None - else None, - average_entitlement_female=beneficiary_list_summary_farmer.average_entitlement_female, - average_entitlement_male=beneficiary_list_summary_farmer.average_entitlement_male, - entitlement_amount_q3=beneficiary_list_summary_farmer.entitlement_amount_q3, - entitlement_amount_q2=beneficiary_list_summary_farmer.entitlement_amount_q2, - entitlement_amount_q1=beneficiary_list_summary_farmer.entitlement_amount_q1, - entitlement_amount_male_q3=beneficiary_list_summary_farmer.entitlement_amount_male_q3, - entitlement_amount_male_q2=beneficiary_list_summary_farmer.entitlement_amount_male_q2, - entitlement_amount_male_q1=beneficiary_list_summary_farmer.entitlement_amount_male_q1, - entitlement_amount_female_q3=beneficiary_list_summary_farmer.entitlement_amount_female_q3, - entitlement_amount_female_q2=beneficiary_list_summary_farmer.entitlement_amount_female_q2, - entitlement_amount_female_q1=beneficiary_list_summary_farmer.entitlement_amount_female_q1, - ), - ) - return summary_farmer_payload - - # ============================== - # Beneficiary Search API Methods - # ============================== - async def search_beneficiaries( - self, - bg_task_session: AsyncSession, - sr_session: AsyncSession, - beneficiary_list_id: str, - target_registry: str, - search_query, - page=1, - page_size=10, - order_by="id asc", - ) -> BeneficiarySearchResponsePayload: - registrant_details = await bg_task_session.execute( - select(BeneficiaryListDetails.registrant_details).where( - BeneficiaryListDetails.beneficiary_list_id == beneficiary_list_id - ) - ) - registrant_details = registrant_details.scalars().all() - registrant_ids = [] - for registrant_detail in registrant_details: - for registrant in registrant_detail: - registrant_ids.append(registrant["registrant_id"]) - - ( - farmer_search_query, - farmer_search_params, - ) = self.construct_beneficiary_search_sql_query( - registrant_ids, - target_registry, - search_query, - order_by, - page_size, - page, - ) - farmer_search_results = ( - (await sr_session.execute(farmer_search_query, farmer_search_params)) - .mappings() - .all() - ) - - total_beneficiary_count: int = await self._get_total_beneficiary_count( - sr_session, beneficiary_list_id, registrant_ids, search_query - ) - beneficiaries = [] - if farmer_search_results: - beneficiaries = [ - G2PFarmerRegistryPayload( - internal_record_id=farmer["internal_record_id"], - functional_record_id=farmer["functional_record_id"], - first_name=farmer["first_name"], - last_name=farmer["last_name"], - gender=farmer["gender"], - estimated_age=farmer["estimated_age"], - disabled=farmer["disabled"], - source_of_income=farmer["source_of_income"], - education_level=farmer["education_level"], - country_code=farmer["country_code"], - ) - for farmer in farmer_search_results - ] - - response_payload = BeneficiarySearchResponsePayload( - total_beneficiary_count=total_beneficiary_count, - page=page, - page_size=page_size, - beneficiaries=beneficiaries, - ) - - return response_payload - - @cache(expire=120, key_builder=beneficiary_count_key_builder) - async def _get_total_beneficiary_count( - self, - sr_session: AsyncSession, - beneficiary_list_id: str, - registrant_ids: List[str], - search_query: str, - ) -> int: - ( - beneficiary_count_query, - beneficiary_count_params, - ) = self.construct_beneficiary_search_count_sql_query( - registrant_ids, "farmer", search_query - ) - total_beneficiary_count = ( - await sr_session.execute(beneficiary_count_query, beneficiary_count_params) - ).scalar_one() - - return total_beneficiary_count - - # ================================= - # Eligibility Celery Worker Methods - # ================================= - def compute_eligibility_statistics( - self, - beneficiary_list_details: List[BeneficiaryListDetails], - base_summary, - sr_session: Session, - bg_task_session: Session, - ): - farmer_summary = BeneficiaryListSummaryFarmerModel( - program_id=base_summary.program_id, - program_mnemonic=base_summary.program_mnemonic, - target_registry=base_summary.target_registry, - beneficiary_list_id=base_summary.beneficiary_list_id, - number_of_registrants=base_summary.number_of_registrants, - date_created=base_summary.date_created, - ) - - estimated_ages = [] - - for beneficiary_list_detail in beneficiary_list_details: - registrant_ids = [] - for registrant_detail in beneficiary_list_detail.registrant_details: - registrant_detail = RegistrantDetails(**registrant_detail) - registrant_ids.append(registrant_detail.registrant_id) - - registrants = self.get_registrants_by_ids(registrant_ids, sr_session) - for farmer in registrants: - if farmer.estimated_age is not None: - estimated_ages.append(farmer.estimated_age) - - # Estimated Age Summary - if estimated_ages: - estimated_ages_array = np.array(estimated_ages) - farmer_summary.estimated_age_mean = round( - float(np.mean(estimated_ages_array)), 2 - ) - farmer_summary.estimated_age_q1 = round( - float(np.percentile(estimated_ages_array, 25, method="midpoint")), 2 - ) - farmer_summary.estimated_age_q2 = round( - float(np.percentile(estimated_ages_array, 50, method="midpoint")), 2 - ) - farmer_summary.estimated_age_q3 = round( - float(np.percentile(estimated_ages_array, 75, method="midpoint")), 2 - ) - - bg_task_session.add(farmer_summary) - - def get_registrants_by_ids( - self, registrant_ids, sr_session - ) -> List[G2PFarmerRegistry]: - farmers = sr_session.query(G2PFarmerRegistry).filter( - G2PFarmerRegistry.internal_record_id.in_(registrant_ids) - ) - - return list(farmers.yield_per(500)) - - # ================================= - # Entitlement Celery Worker Methods - # ================================= - def get_is_registant_entitled( - self, registrant_id: str, sql_query: str, sr_session: Session - ) -> bool: - sql_query_with_registrant_id = ( - self.construct_get_is_registrant_entitled_sql_query( - registrant_id, "farmer", sql_query - ) - ) - result = sr_session.execute(sql_query_with_registrant_id).fetchone() - return result is not None - - def get_entitlement_multiplier( - self, multiplier: str, registrant_id: str, sr_session: Session - ) -> int: - if not multiplier or multiplier == "none": - return 1 - - sql_query = self.construct_multiplier_sql_query( - multiplier, target_registry="farmer" - ) - params = {"registrant_id": registrant_id} - result = sr_session.execute(sql_query, params).fetchone() - multiplier_value: int = ( - int(result[0]) if result and result[0] is not None else 1 - ) - - return multiplier_value - - def compute_entitlement_statistics( - self, beneficiary_list_id: str, bg_task_session: Session, sr_session: Session - ): - beneficiary_list_details = ( - bg_task_session.query(BeneficiaryListDetails) - .filter_by(beneficiary_list_id=beneficiary_list_id) - .all() - ) - - registrant_map_from_registry: dict[str, G2PFarmerRegistry] = {} - - for beneficiary_list_detail in beneficiary_list_details: - registrant_ids = [] - for registrant_detail in beneficiary_list_detail.registrant_details: - registrant_detail = RegistrantDetails(**registrant_detail) - registrant_ids.append(registrant_detail.registrant_id) - - # Fething registrants in batches - registrants_list: List[G2PFarmerRegistry] = self.get_registrants_by_ids( - registrant_ids, sr_session - ) - - for registrant in registrants_list: - registrant_map_from_registry[ - str(registrant.internal_record_id) - ] = registrant - - # Collect entitlements per benefit_code_id - entitlements: dict[int, list[float]] = {} - entitlements_male: dict[int, list[float]] = {} - entitlements_female: dict[int, list[float]] = {} - - for beneficiary_list_detail in beneficiary_list_details: - for registrant_detail in beneficiary_list_detail.registrant_details: - registrant_detail = RegistrantDetails(**registrant_detail) - registrant = registrant_map_from_registry.get( - str(registrant_detail.registrant_id) - ) - gender = (registrant.gender or "").lower() if registrant else None - - for benefit_code_id, value in registrant_detail.entitlement.items(): - # All entitlements - entitlements.setdefault(benefit_code_id, []).append(value) - # By gender (skip non-binary / unknown genders) - if gender == Gender.MALE.value: - entitlements_male.setdefault(benefit_code_id, []).append(value) - elif gender == Gender.FEMALE.value: - entitlements_female.setdefault(benefit_code_id, []).append( - value - ) - - # Compute all summary stats per benefit_code_id - entitlement_stats = self.compute_stats_dict(entitlements) - entitlement_male_stats = self.compute_stats_dict(entitlements_male) - entitlement_female_stats = self.compute_stats_dict(entitlements_female) - - bg_task_session.execute( - update(BeneficiaryListSummaryFarmerModel) - .where( - BeneficiaryListSummaryFarmerModel.beneficiary_list_id - == beneficiary_list_id - ) - .values( - total_disbursement_quantity=dict(entitlement_stats["total"]), - average_entitlement_per_person=dict(entitlement_stats["average"]), - entitlement_amount_q1=dict(entitlement_stats["q1"]), - entitlement_amount_q2=dict(entitlement_stats["q2"]), - entitlement_amount_q3=dict(entitlement_stats["q3"]), - average_entitlement_male=dict(entitlement_male_stats["average"]), - entitlement_amount_male_q1=dict(entitlement_male_stats["q1"]), - entitlement_amount_male_q2=dict(entitlement_male_stats["q2"]), - entitlement_amount_male_q3=dict(entitlement_male_stats["q3"]), - average_entitlement_female=dict(entitlement_female_stats["average"]), - entitlement_amount_female_q1=dict(entitlement_female_stats["q1"]), - entitlement_amount_female_q2=dict(entitlement_female_stats["q2"]), - entitlement_amount_female_q3=dict(entitlement_female_stats["q3"]), - ) - ) - - def compute_stats_dict(self, entitlements_dict: dict[int, list[float]]) -> dict: - # Returns a dict of stats per benefit_code_id for each stat - stats = { - "average": {}, - "q1": {}, - "q2": {}, - "q3": {}, - "total": {}, - } - for benefit_code_id, values in entitlements_dict.items(): - if not values: - stats["average"][benefit_code_id] = 0.0 - stats["q1"][benefit_code_id] = 0.0 - stats["q2"][benefit_code_id] = 0.0 - stats["q3"][benefit_code_id] = 0.0 - stats["total"][benefit_code_id] = 0.0 - else: - arr = np.array(values) - stats["average"][benefit_code_id] = round(float(np.mean(arr)), 2) - stats["q1"][benefit_code_id] = round( - float(np.percentile(arr, 25, method="midpoint")), 2 - ) - stats["q2"][benefit_code_id] = round( - float(np.percentile(arr, 50, method="midpoint")), 2 - ) - stats["q3"][benefit_code_id] = round( - float(np.percentile(arr, 75, method="midpoint")), 2 - ) - stats["total"][benefit_code_id] = float(np.sum(arr)) - return stats diff --git a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/factory/__init__.py b/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/factory/__init__.py deleted file mode 100644 index c234721..0000000 --- a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/factory/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .registry_factory import RegistryFactory diff --git a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/factory/registry_factory.py b/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/factory/registry_factory.py deleted file mode 100644 index 1926b1e..0000000 --- a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/factory/registry_factory.py +++ /dev/null @@ -1,23 +0,0 @@ -from openg2p_bg_task_models.errors import BGTaskErrorCodes, BGTaskException - -from ..computations import ( - RegisterHousehold, - RegistryFarmer, -) -from ..interface import RegistryInterface -from ..models import G2PRegistryType - - -class RegistryFactory: - """Get the appropriate summary computation class based on the registrant type""" - - @staticmethod - def get_registry_class( - target_registry, - ) -> RegistryInterface: - if target_registry == G2PRegistryType.FARMER.value: - return RegistryFarmer() - elif target_registry == G2PRegistryType.HOUSEHOLDS.value: - return RegisterHousehold() - else: - raise BGTaskException(code=BGTaskErrorCodes.INVALID_REQUEST) diff --git a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/interface/__init__.py b/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/interface/__init__.py deleted file mode 100644 index 505cb28..0000000 --- a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/interface/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .registry_interface import RegistryInterface diff --git a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/interface/registry_interface.py b/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/interface/registry_interface.py deleted file mode 100644 index 5949d09..0000000 --- a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/interface/registry_interface.py +++ /dev/null @@ -1,240 +0,0 @@ -from abc import ABC, abstractmethod -from typing import Any, Dict, List, Tuple - -from openg2p_bg_task_models.models import BeneficiaryListDetails -from openg2p_bg_task_models.schemas import ( - BeneficiarySearchResponsePayload, - Disbursement, -) -from openg2p_pbms_models.models import G2PRegistry -from sqlalchemy import TextClause, text -from sqlalchemy.ext.asyncio import AsyncSession -from sqlalchemy.orm import Session - -from ..schema import BeneficiaryListSummaryPayload - - -class RegistryInterface(ABC): - """ - Base class for Registry Interface - Defines methods for interacting with the registry classes - """ - - # ================ - # Summary methods - # ================ - @abstractmethod - async def get_summary( - self, - beneficiary_list_id: str, - bg_task_session: AsyncSession, - formated: bool = False, - ) -> BeneficiaryListSummaryPayload: - """ - Abstract method to get async summary statistics for a given beneficiary_list_id. - """ - raise NotImplementedError("Subclasses must implement get_summary()") - - @abstractmethod - def get_summary_sync( - self, beneficiary_list_id: str, bg_task_session: Session - ) -> BeneficiaryListSummaryPayload: - """ - Abstract method to get synchronous summary statistics for a given beneficiary_list_id. - """ - raise NotImplementedError("Subclasses must implement get_summary_sync()") - - @abstractmethod - def compute_eligibility_statistics( - self, - beneficiary_list_details: List[BeneficiaryListDetails], - base_summary, - sr_session: Session, - bg_task_session: Session, - ): - """ - Abstract method to compute eligibility summary statistics and update the summary table. - """ - raise NotImplementedError( - "Subclasses must implement compute_eligibility_statistics()" - ) - - @abstractmethod - def compute_entitlement_statistics( - self, beneficiary_list_id: str, bg_task_session: Session, sr_session: Session - ): - """ - Abstract method to compute entitlement statistics and update relevant summary fields. - """ - raise NotImplementedError( - "Subclasses must implement compute_entitlement_statistics()" - ) - - # ================= - # Registry methods - # ================= - @abstractmethod - def get_registrants_by_ids( - self, registrant_ids: List, sr_session: Session - ) -> List[G2PRegistry]: - """ - Abstract method to fetch registrants for given registrant_ids from the registry database. - """ - raise NotImplementedError("Subclasses must implement get_registrants_by_ids()") - - @abstractmethod - def get_is_registant_entitled( - self, registrant_id: str, sql_query: str, sr_session: Session - ) -> bool: - """ - Abstract method to check if a registrant is entitled based on custom SQL and session. - """ - raise NotImplementedError( - "Subclasses must implement get_is_registant_entitled()" - ) - - @abstractmethod - def get_entitlement_multiplier( - self, multiplier: str, registrant_id: str, sr_session: Session - ) -> int: - """ - Abstract method to get the multiplier value for entitlement calculation - for a single registrant_id by executing a SQL query. - """ - raise NotImplementedError( - "Subclasses must implement get_entitlement_multiplier()" - ) - - @abstractmethod - async def search_beneficiaries( - self, - bg_task_session: AsyncSession, - sr_session: AsyncSession, - beneficiary_list_id: str, - target_registry: str, - search_query, - page: int = 1, - page_size: int = 10, - order_by: str = "internal_record_id asc", - ) -> Tuple[BeneficiarySearchResponsePayload, int]: - """ - Abstract method to search beneficiaries for particular eligibility request id. - Returns a tuple of (response_payload, total_count) where total_count is the - total number of matching beneficiaries (used for pagination response). - """ - raise NotImplementedError("Subclasses must implement search_beneficiaries()") - - def get_bridge_disbursement_details( - self, - beneficiary_list_id: str, - registrant_ids: List[str], - bg_task_session: Session, - ) -> List[Disbursement]: - raise NotImplementedError( - "Subclasses must implement get_bridge_disbursement_details()" - ) - - # =============================== - # Registry SQL Query Constructors - # =============================== - def construct_multiplier_sql_query( - self, multiplier: str, target_registry: str - ) -> TextClause: - if not multiplier or multiplier == "none": - return None - - table_name = f"g2p_register_{target_registry}" - sql_query = text( - f""" - SELECT {multiplier} FROM {table_name} - WHERE internal_record_id = :registrant_id - """ - ) - return sql_query - - def construct_beneficiary_search_sql_query( - self, - registrant_ids: List[str], - target_registry: str, - where_clause: str, - order_by: str, - page_size: int, - page: int, - ) -> Tuple[TextClause, Dict[str, Any]]: - if not registrant_ids: - return None, {} - - # Replace curly quotes in the where clause - where_clause = where_clause.replace("“", '"').replace("”", '"') - where_clause = where_clause.replace("‘", "'").replace("’", "'") - - table_name = f"g2p_register_{target_registry}" - where_clause_sql = f" AND {where_clause}" if where_clause else "" - registrant_placeholders = ", ".join( - [f":registrant_id_{i}" for i in range(len(registrant_ids))] - ) - - sql_query = text( - f""" - SELECT * FROM {table_name} - WHERE internal_record_id IN ({registrant_placeholders}) {where_clause_sql} - ORDER BY {order_by} - OFFSET :offset - LIMIT :limit - """ - ) - - params = { - f"registrant_id_{i}": registrant_ids[i] for i in range(len(registrant_ids)) - } - params.update({"offset": page_size * (page - 1), "limit": page_size}) - - return sql_query, params - - def construct_beneficiary_search_count_sql_query( - self, registrant_ids: List[str], target_registry: str, where_clause: str - ) -> Tuple[TextClause, Dict[str, Any]]: - if not registrant_ids: - return None, {} - - # Replace curly quotes in the where clause - where_clause = where_clause.replace("“", '"').replace("”", '"') - where_clause = where_clause.replace("‘", "'").replace("’", "'") - - table_name = f"g2p_register_{target_registry}" - where_clause_sql = f" AND {where_clause}" if where_clause else "" - registrant_placeholders = ", ".join( - [f":registrant_id_{i}" for i in range(len(registrant_ids))] - ) - - sql_query = text( - f""" - SELECT COUNT(*) FROM {table_name} - WHERE internal_record_id IN ({registrant_placeholders}) {where_clause_sql} - """ - ) - - params = { - f"registrant_id_{i}": registrant_ids[i] for i in range(len(registrant_ids)) - } - - return sql_query, params - - def construct_get_is_registrant_entitled_sql_query( - self, registrant_id: str, target_registry: str, sql_query: str - ) -> TextClause: - sql_query = sql_query.strip() - - if not registrant_id: - raise ValueError("registrant_id cannot be None or zero") - if not sql_query.upper().startswith("SELECT"): - raise ValueError("Invalid SQL query: Must be a valid SELECT statement") - - if "WHERE" in sql_query.upper(): - sql_query += f" AND g2p_register_{target_registry}.internal_record_id = :registrant_id" - else: - sql_query += f" WHERE g2p_register_{target_registry}.internal_record_id = :registrant_id" - - params = {"registrant_id": registrant_id} - - return text(sql_query).params(**params) diff --git a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/migrate.py b/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/migrate.py deleted file mode 100644 index ceded1f..0000000 --- a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/migrate.py +++ /dev/null @@ -1,11 +0,0 @@ -from .models import ( - BeneficiaryListSummaryFarmer, - BeneficiaryListSummaryHousehold, -) - - -def get_models(): - return [ - BeneficiaryListSummaryFarmer, - BeneficiaryListSummaryHousehold, - ] diff --git a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/models/__init__.py b/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/models/__init__.py deleted file mode 100644 index ff0f650..0000000 --- a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/models/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -from .beneficiary_list_summary_farmer import BeneficiaryListSummaryFarmer -from .beneficiary_list_summary_household import BeneficiaryListSummaryHousehold -from .register_household import G2PRegisterHousehold -from .registry_farmer import G2PFarmerRegistry -from .registry_type import G2PRegistryType diff --git a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/models/beneficiary_list_summary_farmer.py b/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/models/beneficiary_list_summary_farmer.py deleted file mode 100644 index 2977c71..0000000 --- a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/models/beneficiary_list_summary_farmer.py +++ /dev/null @@ -1,26 +0,0 @@ -from openg2p_bg_task_models.models import BeneficiaryListSummary -from sqlalchemy import JSON, Float, String -from sqlalchemy.orm import mapped_column - - -class BeneficiaryListSummaryFarmer(BeneficiaryListSummary): - __tablename__ = "beneficiary_list_summary_farmer" - - estimated_age_q1 = mapped_column(Float, nullable=True, default=0) - estimated_age_q2 = mapped_column(Float, nullable=True, default=0) - estimated_age_q3 = mapped_column(Float, nullable=True, default=0) - estimated_age_mean = mapped_column(Float, nullable=True, default=0) - estimated_age_units = mapped_column(String, nullable=False, default="years") - - average_entitlement_female = mapped_column(JSON, nullable=True) - average_entitlement_male = mapped_column(JSON, nullable=True) - entitlement_amount_male_q1 = mapped_column(JSON, nullable=True) - entitlement_amount_male_q2 = mapped_column(JSON, nullable=True) - entitlement_amount_male_q3 = mapped_column(JSON, nullable=True) - entitlement_amount_female_q1 = mapped_column(JSON, nullable=True) - entitlement_amount_female_q2 = mapped_column(JSON, nullable=True) - entitlement_amount_female_q3 = mapped_column(JSON, nullable=True) - entitlement_amount_q1 = mapped_column(JSON, nullable=True) - entitlement_amount_q2 = mapped_column(JSON, nullable=True) - entitlement_amount_q3 = mapped_column(JSON, nullable=True) - entitlement_units = mapped_column(JSON, nullable=True) diff --git a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/models/beneficiary_list_summary_household.py b/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/models/beneficiary_list_summary_household.py deleted file mode 100644 index 24c62f5..0000000 --- a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/models/beneficiary_list_summary_household.py +++ /dev/null @@ -1,38 +0,0 @@ -from openg2p_bg_task_models.models import BeneficiaryListSummary -from sqlalchemy import JSON, Float, String -from sqlalchemy.orm import mapped_column - - -class BeneficiaryListSummaryHousehold(BeneficiaryListSummary): - __tablename__ = "beneficiary_list_summary_household" - - size_children_u5_q1 = mapped_column(Float, nullable=True, default=0) - size_children_u5_q2 = mapped_column(Float, nullable=True, default=0) - size_children_u5_q3 = mapped_column(Float, nullable=True, default=0) - size_children_u5_mean = mapped_column(Float, nullable=True, default=0) - size_children_u5_units = mapped_column(String, nullable=False, default="persons") - - size_elderly_q1 = mapped_column(Float, nullable=True, default=0) - size_elderly_q2 = mapped_column(Float, nullable=True, default=0) - size_elderly_q3 = mapped_column(Float, nullable=True, default=0) - size_elderly_mean = mapped_column(Float, nullable=True, default=0) - size_elderly_units = mapped_column(String, nullable=False, default="persons") - - rooms_count_q1 = mapped_column(Float, nullable=True, default=0) - rooms_count_q2 = mapped_column(Float, nullable=True, default=0) - rooms_count_q3 = mapped_column(Float, nullable=True, default=0) - rooms_count_mean = mapped_column(Float, nullable=True, default=0) - rooms_count_units = mapped_column(String, nullable=False, default="rooms") - - overcrowding_indicator_q1 = mapped_column(Float, nullable=True, default=0) - overcrowding_indicator_q2 = mapped_column(Float, nullable=True, default=0) - overcrowding_indicator_q3 = mapped_column(Float, nullable=True, default=0) - overcrowding_indicator_mean = mapped_column(Float, nullable=True, default=0) - overcrowding_indicator_units = mapped_column( - String, nullable=False, default="ratio" - ) - - entitlement_amount_q1 = mapped_column(JSON, nullable=True) - entitlement_amount_q2 = mapped_column(JSON, nullable=True) - entitlement_amount_q3 = mapped_column(JSON, nullable=True) - entitlement_units = mapped_column(JSON, nullable=True) diff --git a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/models/register_household.py b/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/models/register_household.py deleted file mode 100644 index 1358358..0000000 --- a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/models/register_household.py +++ /dev/null @@ -1,64 +0,0 @@ -from openg2p_pbms_models.models import G2PRegistry -from sqlalchemy import JSON, Boolean, DateTime, Integer, Numeric, String -from sqlalchemy.orm import Mapped, mapped_column - - -class G2PRegisterHousehold(G2PRegistry): - __tablename__ = "g2p_register_households" - - # G2PRegister identity fields - functional_record_id: Mapped[str] = mapped_column(String, nullable=True) - link_internal_record_id: Mapped[str] = mapped_column(String, nullable=True) - link_foundational_id: Mapped[str] = mapped_column(String, nullable=True) - record_name: Mapped[str] = mapped_column(String, nullable=True) - record_status: Mapped[str] = mapped_column(String, nullable=True) - record_status_reason: Mapped[str] = mapped_column(String, nullable=True) - - # Geo - latitude: Mapped[str] = mapped_column(String, nullable=True) - longitude: Mapped[str] = mapped_column(String, nullable=True) - altitude: Mapped[str] = mapped_column(String, nullable=True) - plus_code: Mapped[str] = mapped_column(String, nullable=True) - address_line_1: Mapped[str] = mapped_column(String, nullable=True) - address_line_2: Mapped[str] = mapped_column(String, nullable=True) - postal_code: Mapped[str] = mapped_column(String, nullable=True) - country_code: Mapped[str] = mapped_column(String, nullable=True) - geo_lowest_level_value_id: Mapped[str] = mapped_column(String, nullable=True) - geo_code_hierarchy_json: Mapped[dict] = mapped_column(JSON, nullable=True) - - # Household head - household_head_internal_record_id: Mapped[str] = mapped_column( - String, nullable=True - ) - household_head_name: Mapped[str] = mapped_column(String, nullable=True) - headship_type: Mapped[str] = mapped_column(String, nullable=True) - - # Composition - size_total: Mapped[int] = mapped_column(Integer, nullable=True) - size_adults: Mapped[int] = mapped_column(Integer, nullable=True) - size_children_u5: Mapped[int] = mapped_column(Integer, nullable=True) - size_school_age: Mapped[int] = mapped_column(Integer, nullable=True) - size_elderly: Mapped[int] = mapped_column(Integer, nullable=True) - number_of_female_members: Mapped[int] = mapped_column(Integer, nullable=True) - number_of_male_members: Mapped[int] = mapped_column(Integer, nullable=True) - elderly_member_present: Mapped[bool] = mapped_column(Boolean, nullable=True) - - # Dwelling - dwelling_type: Mapped[str] = mapped_column(String, nullable=True) - roof_material: Mapped[str] = mapped_column(String, nullable=True) - wall_material: Mapped[str] = mapped_column(String, nullable=True) - floor_material: Mapped[str] = mapped_column(String, nullable=True) - tenure_status: Mapped[str] = mapped_column(String, nullable=True) - rooms_count: Mapped[int] = mapped_column(Integer, nullable=True) - overcrowding_indicator: Mapped[float] = mapped_column(Numeric, nullable=True) - - # Utilities - water_source_type: Mapped[str] = mapped_column(String, nullable=True) - water_distance_minutes: Mapped[int] = mapped_column(Integer, nullable=True) - sanitation_type: Mapped[str] = mapped_column(String, nullable=True) - lighting_source: Mapped[str] = mapped_column(String, nullable=True) - cooking_fuel_type: Mapped[str] = mapped_column(String, nullable=True) - mobile_phone_type: Mapped[str] = mapped_column(String, nullable=True) - - husband_dead: Mapped[bool] = mapped_column(Boolean, nullable=True) - husband_death_date: Mapped[DateTime] = mapped_column(DateTime, nullable=True) diff --git a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/models/registry_farmer.py b/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/models/registry_farmer.py deleted file mode 100644 index 26fd592..0000000 --- a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/models/registry_farmer.py +++ /dev/null @@ -1,57 +0,0 @@ -from openg2p_pbms_models.models import G2PRegistry -from sqlalchemy import JSON, Boolean, Date, Integer, String -from sqlalchemy.orm import Mapped, mapped_column - - -class G2PFarmerRegistry(G2PRegistry): - __tablename__ = "g2p_register_farmer" - - # G2PRegister identity fields - functional_record_id: Mapped[str] = mapped_column(String, nullable=True) - link_internal_record_id: Mapped[str] = mapped_column(String, nullable=True) - link_foundational_id: Mapped[str] = mapped_column(String, nullable=True) - record_name: Mapped[str] = mapped_column(String, nullable=True) - record_status: Mapped[str] = mapped_column(String, nullable=True) - record_status_reason: Mapped[str] = mapped_column(String, nullable=True) - - # Person - foundational_id: Mapped[str] = mapped_column(String, nullable=True) - first_name: Mapped[str] = mapped_column(String, nullable=True) - middle_name: Mapped[str] = mapped_column(String, nullable=True) - last_name: Mapped[str] = mapped_column(String, nullable=True) - given_name: Mapped[str] = mapped_column(String, nullable=True) - prefix: Mapped[str] = mapped_column(String, nullable=True) - suffix: Mapped[str] = mapped_column(String, nullable=True) - gender: Mapped[str] = mapped_column(String, nullable=True) - birth_date: Mapped[Date] = mapped_column(Date, nullable=True) - phone_numbers: Mapped[list] = mapped_column(JSON, nullable=True) - emails: Mapped[list] = mapped_column(JSON, nullable=True) - marital_status: Mapped[str] = mapped_column(String, nullable=True) - occupation: Mapped[str] = mapped_column(String, nullable=True) - income_level: Mapped[str] = mapped_column(String, nullable=True) - language_code: Mapped[str] = mapped_column(String, nullable=True) - registration_date: Mapped[Date] = mapped_column(Date, nullable=True) - - # Geo - latitude: Mapped[str] = mapped_column(String, nullable=True) - longitude: Mapped[str] = mapped_column(String, nullable=True) - altitude: Mapped[str] = mapped_column(String, nullable=True) - plus_code: Mapped[str] = mapped_column(String, nullable=True) - address_line_1: Mapped[str] = mapped_column(String, nullable=True) - address_line_2: Mapped[str] = mapped_column(String, nullable=True) - postal_code: Mapped[str] = mapped_column(String, nullable=True) - country_code: Mapped[str] = mapped_column(String, nullable=True) - geo_lowest_level_value_id: Mapped[str] = mapped_column(String, nullable=True) - geo_code_hierarchy_json: Mapped[dict] = mapped_column(JSON, nullable=True) - - # Farmer-specific - estimated_age: Mapped[int] = mapped_column(Integer, nullable=True) - has_personal_phone: Mapped[bool] = mapped_column(Boolean, nullable=True) - disabled: Mapped[bool] = mapped_column(Boolean, nullable=True) - disability_type: Mapped[str] = mapped_column(String, nullable=True) - disability_severity: Mapped[str] = mapped_column(String, nullable=True) - source_of_income: Mapped[str] = mapped_column(String, nullable=True) - source_of_income_other: Mapped[str] = mapped_column(String, nullable=True) - language_spoken: Mapped[str] = mapped_column(String, nullable=True) - education_level: Mapped[str] = mapped_column(String, nullable=True) - national_id_masked: Mapped[str] = mapped_column(String, nullable=True) diff --git a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/models/registry_type.py b/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/models/registry_type.py deleted file mode 100644 index 43f63cb..0000000 --- a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/models/registry_type.py +++ /dev/null @@ -1,7 +0,0 @@ -from enum import Enum - - -class G2PRegistryType(Enum): - FARMER = "farmer" - HOUSEHOLDS = "households" - OTHER = "other" diff --git a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/schema/__init__.py b/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/schema/__init__.py deleted file mode 100644 index 97161f3..0000000 --- a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/schema/__init__.py +++ /dev/null @@ -1,15 +0,0 @@ -from .beneficiary_list_summary import ( - BeneficiaryListSummary, - BeneficiaryListSummaryPayload, -) -from .beneficiary_list_summary_farmer import ( - BeneficiaryListSummaryFarmer, - BeneficiaryListSummaryFarmerPayload, -) -from .beneficiary_list_summary_household import ( - BeneficiaryListSummaryHousehold, - BeneficiaryListSummaryHouseholdPayload, -) -from .register_household import G2PRegisterHouseholdPayload -from .registry import G2PRegistryPayload -from .registry_farmer import G2PFarmerRegistryPayload diff --git a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/schema/beneficiary_list_summary.py b/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/schema/beneficiary_list_summary.py deleted file mode 100644 index b097d93..0000000 --- a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/schema/beneficiary_list_summary.py +++ /dev/null @@ -1,21 +0,0 @@ -from datetime import datetime -from typing import Any, Optional - -from pydantic import BaseModel - - -class BeneficiaryListSummary(BaseModel): - id: str - program_id: int - program_mnemonic: str - target_registry: str - beneficiary_list_id: str - number_of_registrants: int - date_created: Optional[datetime] - total_disbursement_quantity: Optional[dict] = None - average_entitlement_per_registrant: Optional[dict] = None - - -class BeneficiaryListSummaryPayload(BaseModel): - beneficiary_list_summary: BeneficiaryListSummary - registry_summary: Optional[Any] = None diff --git a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/schema/beneficiary_list_summary_farmer.py b/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/schema/beneficiary_list_summary_farmer.py deleted file mode 100644 index 595b77e..0000000 --- a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/schema/beneficiary_list_summary_farmer.py +++ /dev/null @@ -1,27 +0,0 @@ -from typing import Optional - -from pydantic import BaseModel - -from .beneficiary_list_summary import BeneficiaryListSummaryPayload - - -class BeneficiaryListSummaryFarmer(BaseModel): - estimated_age_mean: Optional[str] = None - estimated_age_q3: Optional[str] = None - estimated_age_q2: Optional[str] = None - estimated_age_q1: Optional[str] = None - average_entitlement_female: Optional[dict] = None - average_entitlement_male: Optional[dict] = None - entitlement_amount_q3: Optional[dict] = None - entitlement_amount_q2: Optional[dict] = None - entitlement_amount_q1: Optional[dict] = None - entitlement_amount_male_q3: Optional[dict] = None - entitlement_amount_male_q2: Optional[dict] = None - entitlement_amount_male_q1: Optional[dict] = None - entitlement_amount_female_q3: Optional[dict] = None - entitlement_amount_female_q2: Optional[dict] = None - entitlement_amount_female_q1: Optional[dict] = None - - -class BeneficiaryListSummaryFarmerPayload(BeneficiaryListSummaryPayload): - registry_summary: BeneficiaryListSummaryFarmer diff --git a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/schema/beneficiary_list_summary_household.py b/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/schema/beneficiary_list_summary_household.py deleted file mode 100644 index 2ee35ad..0000000 --- a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/schema/beneficiary_list_summary_household.py +++ /dev/null @@ -1,35 +0,0 @@ -from typing import Optional - -from pydantic import BaseModel - -from .beneficiary_list_summary import BeneficiaryListSummaryPayload - - -class BeneficiaryListSummaryHousehold(BaseModel): - size_children_u5_mean: Optional[str] = None - size_children_u5_q1: Optional[str] = None - size_children_u5_q2: Optional[str] = None - size_children_u5_q3: Optional[str] = None - - size_elderly_mean: Optional[str] = None - size_elderly_q1: Optional[str] = None - size_elderly_q2: Optional[str] = None - size_elderly_q3: Optional[str] = None - - rooms_count_mean: Optional[str] = None - rooms_count_q1: Optional[str] = None - rooms_count_q2: Optional[str] = None - rooms_count_q3: Optional[str] = None - - overcrowding_indicator_mean: Optional[str] = None - overcrowding_indicator_q1: Optional[str] = None - overcrowding_indicator_q2: Optional[str] = None - overcrowding_indicator_q3: Optional[str] = None - - entitlement_amount_q1: Optional[dict] = None - entitlement_amount_q2: Optional[dict] = None - entitlement_amount_q3: Optional[dict] = None - - -class BeneficiaryListSummaryHouseholdPayload(BeneficiaryListSummaryPayload): - registry_summary: BeneficiaryListSummaryHousehold diff --git a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/schema/register_household.py b/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/schema/register_household.py deleted file mode 100644 index febe5cd..0000000 --- a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/schema/register_household.py +++ /dev/null @@ -1,26 +0,0 @@ -from typing import Optional - -from .registry import G2PRegistryPayload - - -class G2PRegisterHouseholdPayload(G2PRegistryPayload): - functional_record_id: Optional[str] = None - household_head_name: Optional[str] = None - headship_type: Optional[str] = None - size_total: Optional[int] = None - size_children_u5: Optional[int] = None - size_elderly: Optional[int] = None - number_of_female_members: Optional[int] = None - number_of_male_members: Optional[int] = None - dwelling_type: Optional[str] = None - tenure_status: Optional[str] = None - rooms_count: Optional[int] = None - overcrowding_indicator: Optional[float] = None - water_source_type: Optional[str] = None - sanitation_type: Optional[str] = None - lighting_source: Optional[str] = None - cooking_fuel_type: Optional[str] = None - address_line_1: Optional[str] = None - address_line_2: Optional[str] = None - postal_code: Optional[str] = None - country_code: Optional[str] = None diff --git a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/schema/registry.py b/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/schema/registry.py deleted file mode 100644 index e66e1e4..0000000 --- a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/schema/registry.py +++ /dev/null @@ -1,5 +0,0 @@ -from pydantic import BaseModel - - -class G2PRegistryPayload(BaseModel): - internal_record_id: str diff --git a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/schema/registry_farmer.py b/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/schema/registry_farmer.py deleted file mode 100644 index 05a531f..0000000 --- a/extensions/openg2p-bg-task-registry-adapters/src/openg2p_bg_task_registry_adapters/schema/registry_farmer.py +++ /dev/null @@ -1,15 +0,0 @@ -from typing import Optional - -from .registry import G2PRegistryPayload - - -class G2PFarmerRegistryPayload(G2PRegistryPayload): - functional_record_id: Optional[str] = None - first_name: Optional[str] = None - last_name: Optional[str] = None - gender: Optional[str] = None - estimated_age: Optional[int] = None - disabled: Optional[bool] = None - source_of_income: Optional[str] = None - education_level: Optional[str] = None - country_code: Optional[str] = None diff --git a/odoo/README.md b/odoo/README.md index 2d66779..688395e 100644 --- a/odoo/README.md +++ b/odoo/README.md @@ -1,3 +1,3 @@ # openg2p-pbms-odoo -Odoo modules for OpenG2P PBMS (core `g2p_pbms`, program access, registry extensions, and community addons). +Odoo modules for OpenG2P PBMS (core `g2p_pbms`, program access, and community addons). diff --git a/odoo/extensions/.gitignore b/odoo/extensions/.gitignore deleted file mode 100644 index b7faf40..0000000 --- a/odoo/extensions/.gitignore +++ /dev/null @@ -1,207 +0,0 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[codz] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py.cover -.hypothesis/ -.pytest_cache/ -cover/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -.pybuilder/ -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -# For a library or package, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: -# .python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# UV -# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control. -# This is especially recommended for binary packages to ensure reproducibility, and is more -# commonly ignored for libraries. -#uv.lock - -# poetry -# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. -# This is especially recommended for binary packages to ensure reproducibility, and is more -# commonly ignored for libraries. -# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control -#poetry.lock -#poetry.toml - -# pdm -# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. -# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python. -# https://pdm-project.org/en/latest/usage/project/#working-with-version-control -#pdm.lock -#pdm.toml -.pdm-python -.pdm-build/ - -# pixi -# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control. -#pixi.lock -# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one -# in the .venv directory. It is recommended not to include this directory in version control. -.pixi - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.envrc -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - -# pytype static type analyzer -.pytype/ - -# Cython debug symbols -cython_debug/ - -# PyCharm -# JetBrains specific template is maintained in a separate JetBrains.gitignore that can -# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore -# and can be added to the global gitignore or merged into this file. For a more nuclear -# option (not recommended) you can uncomment the following to ignore the entire idea folder. -#.idea/ - -# Abstra -# Abstra is an AI-powered process automation framework. -# Ignore directories containing user credentials, local state, and settings. -# Learn more at https://abstra.io/docs -.abstra/ - -# Visual Studio Code -# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore -# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore -# and can be added to the global gitignore or merged into this file. However, if you prefer, -# you could uncomment the following to ignore the entire vscode folder -# .vscode/ - -# Ruff stuff: -.ruff_cache/ - -# PyPI configuration file -.pypirc - -# Cursor -# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to -# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data -# refer to https://docs.cursor.com/context/ignore-files -.cursorignore -.cursorindexingignore - -# Marimo -marimo/_static/ -marimo/_lsp/ -__marimo__/ diff --git a/odoo/extensions/LICENSE b/odoo/extensions/LICENSE deleted file mode 100644 index d0a1fa1..0000000 --- a/odoo/extensions/LICENSE +++ /dev/null @@ -1,373 +0,0 @@ -Mozilla Public License Version 2.0 -================================== - -1. Definitions --------------- - -1.1. "Contributor" - means each individual or legal entity that creates, contributes to - the creation of, or owns Covered Software. - -1.2. "Contributor Version" - means the combination of the Contributions of others (if any) used - by a Contributor and that particular Contributor's Contribution. - -1.3. "Contribution" - means Covered Software of a particular Contributor. - -1.4. "Covered Software" - means Source Code Form to which the initial Contributor has attached - the notice in Exhibit A, the Executable Form of such Source Code - Form, and Modifications of such Source Code Form, in each case - including portions thereof. - -1.5. "Incompatible With Secondary Licenses" - means - - (a) that the initial Contributor has attached the notice described - in Exhibit B to the Covered Software; or - - (b) that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the - terms of a Secondary License. - -1.6. "Executable Form" - means any form of the work other than Source Code Form. - -1.7. "Larger Work" - means a work that combines Covered Software with other material, in - a separate file or files, that is not Covered Software. - -1.8. "License" - means this document. - -1.9. "Licensable" - means having the right to grant, to the maximum extent possible, - whether at the time of the initial grant or subsequently, any and - all of the rights conveyed by this License. - -1.10. "Modifications" - means any of the following: - - (a) any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered - Software; or - - (b) any new file in Source Code Form that contains any Covered - Software. - -1.11. "Patent Claims" of a Contributor - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the - License, by the making, using, selling, offering for sale, having - made, import, or transfer of either its Contributions or its - Contributor Version. - -1.12. "Secondary License" - means either the GNU General Public License, Version 2.0, the GNU - Lesser General Public License, Version 2.1, the GNU Affero General - Public License, Version 3.0, or any later versions of those - licenses. - -1.13. "Source Code Form" - means the form of the work preferred for making modifications. - -1.14. "You" (or "Your") - means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that - controls, is controlled by, or is under common control with You. For - purposes of this definition, "control" means (a) the power, direct - or indirect, to cause the direction or management of such entity, - whether by contract or otherwise, or (b) ownership of more than - fifty percent (50%) of the outstanding shares or beneficial - ownership of such entity. - -2. License Grants and Conditions --------------------------------- - -2.1. Grants - -Each Contributor hereby grants You a world-wide, royalty-free, -non-exclusive license: - -(a) under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or - as part of a Larger Work; and - -(b) under Patent Claims of such Contributor to make, use, sell, offer - for sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. - -2.2. Effective Date - -The licenses granted in Section 2.1 with respect to any Contribution -become effective for each Contribution on the date the Contributor first -distributes such Contribution. - -2.3. Limitations on Grant Scope - -The licenses granted in this Section 2 are the only rights granted under -this License. No additional rights or licenses will be implied from the -distribution or licensing of Covered Software under this License. -Notwithstanding Section 2.1(b) above, no patent license is granted by a -Contributor: - -(a) for any code that a Contributor has removed from Covered Software; - or - -(b) for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - -(c) under Patent Claims infringed by Covered Software in the absence of - its Contributions. - -This License does not grant any rights in the trademarks, service marks, -or logos of any Contributor (except as may be necessary to comply with -the notice requirements in Section 3.4). - -2.4. Subsequent Licenses - -No Contributor makes additional grants as a result of Your choice to -distribute the Covered Software under a subsequent version of this -License (see Section 10.2) or under the terms of a Secondary License (if -permitted under the terms of Section 3.3). - -2.5. Representation - -Each Contributor represents that the Contributor believes its -Contributions are its original creation(s) or it has sufficient rights -to grant the rights to its Contributions conveyed by this License. - -2.6. Fair Use - -This License is not intended to limit any rights You have under -applicable copyright doctrines of fair use, fair dealing, or other -equivalents. - -2.7. Conditions - -Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted -in Section 2.1. - -3. Responsibilities -------------------- - -3.1. Distribution of Source Form - -All distribution of Covered Software in Source Code Form, including any -Modifications that You create or to which You contribute, must be under -the terms of this License. You must inform recipients that the Source -Code Form of the Covered Software is governed by the terms of this -License, and how they can obtain a copy of this License. You may not -attempt to alter or restrict the recipients' rights in the Source Code -Form. - -3.2. Distribution of Executable Form - -If You distribute Covered Software in Executable Form then: - -(a) such Covered Software must also be made available in Source Code - Form, as described in Section 3.1, and You must inform recipients of - the Executable Form how they can obtain a copy of such Source Code - Form by reasonable means in a timely manner, at a charge no more - than the cost of distribution to the recipient; and - -(b) You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter - the recipients' rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - -You may create and distribute a Larger Work under terms of Your choice, -provided that You also comply with the requirements of this License for -the Covered Software. If the Larger Work is a combination of Covered -Software with a work governed by one or more Secondary Licenses, and the -Covered Software is not Incompatible With Secondary Licenses, this -License permits You to additionally distribute such Covered Software -under the terms of such Secondary License(s), so that the recipient of -the Larger Work may, at their option, further distribute the Covered -Software under the terms of either this License or such Secondary -License(s). - -3.4. Notices - -You may not remove or alter the substance of any license notices -(including copyright notices, patent notices, disclaimers of warranty, -or limitations of liability) contained within the Source Code Form of -the Covered Software, except that You may alter any license notices to -the extent required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - -You may choose to offer, and to charge a fee for, warranty, support, -indemnity or liability obligations to one or more recipients of Covered -Software. However, You may do so only on Your own behalf, and not on -behalf of any Contributor. You must make it absolutely clear that any -such warranty, support, indemnity, or liability obligation is offered by -You alone, and You hereby agree to indemnify every Contributor for any -liability incurred by such Contributor as a result of warranty, support, -indemnity or liability terms You offer. You may include additional -disclaimers of warranty and limitations of liability specific to any -jurisdiction. - -4. Inability to Comply Due to Statute or Regulation ---------------------------------------------------- - -If it is impossible for You to comply with any of the terms of this -License with respect to some or all of the Covered Software due to -statute, judicial order, or regulation then You must: (a) comply with -the terms of this License to the maximum extent possible; and (b) -describe the limitations and the code they affect. Such description must -be placed in a text file included with all distributions of the Covered -Software under this License. Except to the extent prohibited by statute -or regulation, such description must be sufficiently detailed for a -recipient of ordinary skill to be able to understand it. - -5. Termination --------------- - -5.1. The rights granted under this License will terminate automatically -if You fail to comply with any of its terms. However, if You become -compliant, then the rights granted under this License from a particular -Contributor are reinstated (a) provisionally, unless and until such -Contributor explicitly and finally terminates Your grants, and (b) on an -ongoing basis, if such Contributor fails to notify You of the -non-compliance by some reasonable means prior to 60 days after You have -come back into compliance. Moreover, Your grants from a particular -Contributor are reinstated on an ongoing basis if such Contributor -notifies You of the non-compliance by some reasonable means, this is the -first time You have received notice of non-compliance with this License -from such Contributor, and You become compliant prior to 30 days after -Your receipt of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent -infringement claim (excluding declaratory judgment actions, -counter-claims, and cross-claims) alleging that a Contributor Version -directly or indirectly infringes any patent, then the rights granted to -You by any and all Contributors for the Covered Software under Section -2.1 of this License shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all -end user license agreements (excluding distributors and resellers) which -have been validly granted by You or Your distributors under this License -prior to termination shall survive termination. - -************************************************************************ -* * -* 6. Disclaimer of Warranty * -* ------------------------- * -* * -* Covered Software is provided under this License on an "as is" * -* basis, without warranty of any kind, either expressed, implied, or * -* statutory, including, without limitation, warranties that the * -* Covered Software is free of defects, merchantable, fit for a * -* particular purpose or non-infringing. The entire risk as to the * -* quality and performance of the Covered Software is with You. * -* Should any Covered Software prove defective in any respect, You * -* (not any Contributor) assume the cost of any necessary servicing, * -* repair, or correction. This disclaimer of warranty constitutes an * -* essential part of this License. No use of any Covered Software is * -* authorized under this License except under this disclaimer. * -* * -************************************************************************ - -************************************************************************ -* * -* 7. Limitation of Liability * -* -------------------------- * -* * -* Under no circumstances and under no legal theory, whether tort * -* (including negligence), contract, or otherwise, shall any * -* Contributor, or anyone who distributes Covered Software as * -* permitted above, be liable to You for any direct, indirect, * -* special, incidental, or consequential damages of any character * -* including, without limitation, damages for lost profits, loss of * -* goodwill, work stoppage, computer failure or malfunction, or any * -* and all other commercial damages or losses, even if such party * -* shall have been informed of the possibility of such damages. This * -* limitation of liability shall not apply to liability for death or * -* personal injury resulting from such party's negligence to the * -* extent applicable law prohibits such limitation. Some * -* jurisdictions do not allow the exclusion or limitation of * -* incidental or consequential damages, so this exclusion and * -* limitation may not apply to You. * -* * -************************************************************************ - -8. Litigation -------------- - -Any litigation relating to this License may be brought only in the -courts of a jurisdiction where the defendant maintains its principal -place of business and such litigation shall be governed by laws of that -jurisdiction, without reference to its conflict-of-law provisions. -Nothing in this Section shall prevent a party's ability to bring -cross-claims or counter-claims. - -9. Miscellaneous ----------------- - -This License represents the complete agreement concerning the subject -matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the extent -necessary to make it enforceable. Any law or regulation which provides -that the language of a contract shall be construed against the drafter -shall not be used to construe this License against a Contributor. - -10. Versions of the License ---------------------------- - -10.1. New Versions - -Mozilla Foundation is the license steward. Except as provided in Section -10.3, no one other than the license steward has the right to modify or -publish new versions of this License. Each version will be given a -distinguishing version number. - -10.2. Effect of New Versions - -You may distribute the Covered Software under the terms of the version -of the License under which You originally received the Covered Software, -or under the terms of any subsequent version published by the license -steward. - -10.3. Modified Versions - -If you create software not governed by this License, and you want to -create a new license for such software, you may create and use a -modified version of this License if you rename the license and remove -any references to the name of the license steward (except to note that -such modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary -Licenses - -If You choose to distribute Source Code Form that is Incompatible With -Secondary Licenses under the terms of this version of the License, the -notice described in Exhibit B of this License must be attached. - -Exhibit A - Source Code Form License Notice -------------------------------------------- - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at https://mozilla.org/MPL/2.0/. - -If it is not possible or desirable to put the notice in a particular -file, then You may include the notice in a location (such as a LICENSE -file in a relevant directory) where a recipient would be likely to look -for such a notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - "Incompatible With Secondary Licenses" Notice ---------------------------------------------------------- - - This Source Code Form is "Incompatible With Secondary Licenses", as - defined by the Mozilla Public License, v. 2.0. diff --git a/odoo/extensions/README.md b/odoo/extensions/README.md deleted file mode 100644 index 50f17ae..0000000 --- a/odoo/extensions/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# openg2p-pbms-odoo-extensions - -Registry model addons and theme extensions for OpenG2P PBMS Odoo. diff --git a/odoo/extensions/g2p_registry_addon/__init__.py b/odoo/extensions/g2p_registry_addon/__init__.py deleted file mode 100644 index a0fdc10..0000000 --- a/odoo/extensions/g2p_registry_addon/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -# -*- coding: utf-8 -*- -from . import models diff --git a/odoo/extensions/g2p_registry_addon/__manifest__.py b/odoo/extensions/g2p_registry_addon/__manifest__.py deleted file mode 100644 index 25e8967..0000000 --- a/odoo/extensions/g2p_registry_addon/__manifest__.py +++ /dev/null @@ -1,29 +0,0 @@ -{ - "name": "PBMS Registry Addon", - "version": "3.1.1", - "summary": "OpenG2P Registry Addon", - "description": "OpenG2P Registry Addon", - "category": "G2P", - "license": "LGPL-3", - "depends": ["base_setup", "web", "g2p_pbms"], - "data": [ - "security/ir.model.access.csv", - "views/eligibility/eligibility_rule_view.xml", - "views/entitlement/entitlement_rule_view.xml", - "views/priority/priority_rule_view.xml", - "views/registry/farmer_registry_view.xml", - "views/registry/household_registry_view.xml", - "views/bgtask/bgtask_view.xml", - "views/menu.xml", - ], - "assets": { - "web.assets_backend": [ - "/g2p_registry_addon/static/src/css/registry_styles.scss", - "/g2p_registry_addon/static/src/js/beneficiaries_widget.js", - "/g2p_registry_addon/static/src/xml/g2p_beneficiaries_info_tpl.xml", - ], - }, - "installable": True, - "application": True, - "auto_install": False, -} diff --git a/odoo/extensions/g2p_registry_addon/models/__init__.py b/odoo/extensions/g2p_registry_addon/models/__init__.py deleted file mode 100644 index f9b176a..0000000 --- a/odoo/extensions/g2p_registry_addon/models/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -from .registry import G2PRegistry -from .farmer_registry import G2PFarmerRegistry -from .household import G2PRegisterHousehold \ No newline at end of file diff --git a/odoo/extensions/g2p_registry_addon/models/farmer_registry.py b/odoo/extensions/g2p_registry_addon/models/farmer_registry.py deleted file mode 100644 index 7e28fe4..0000000 --- a/odoo/extensions/g2p_registry_addon/models/farmer_registry.py +++ /dev/null @@ -1,126 +0,0 @@ -from odoo import models, fields - -from .registry import G2PRegistry - - -class G2PFarmerRegistry(models.Model): - _name = "g2p.register.farmer" - _description = "Farmer Registry" - _inherit = "g2p.registry" - - # G2PRegister fields - functional_record_id = fields.Char(string="Functional Record ID", index=True) - link_internal_record_id = fields.Char(string="Link Internal Record ID", index=True) - link_foundational_id = fields.Char(string="Link Foundational ID", index=True) - record_name = fields.Char(string="Record Name") - record_image_storage_id = fields.Text(string="Record Image Storage ID") - created_by = fields.Char(string="Created By") - created_at = fields.Datetime(string="Created At") - last_approved_at = fields.Datetime(string="Last Approved At") - last_approved_by = fields.Char(string="Last Approved By") - search_text = fields.Text(string="Search Text") - record_status = fields.Selection( - selection=[ - ("active", "Active"), - ("inactive", "Inactive"), - ("archived", "Archived"), - ], - string="Record Status", - default="active", - ) - record_status_reason = fields.Char(string="Record Status Reason") - - # G2PPerson fields - foundational_id = fields.Char(string="Foundational ID", index=True) - first_name = fields.Char(string="First Name") - middle_name = fields.Char(string="Middle Name") - last_name = fields.Char(string="Last Name") - given_name = fields.Char(string="Given Name") - prefix = fields.Char(string="Prefix") - suffix = fields.Char(string="Suffix") - gender = fields.Selection( - selection=[ - ("MALE", "Male"), - ("FEMALE", "Female"), - ("OTHERS", "Others"), - ("UNKNOWN", "Unknown"), - ], - string="Gender", - ) - birth_date = fields.Date(string="Birth Date") - phone_numbers = fields.Json(string="Phone Numbers") - emails = fields.Json(string="Emails") - marital_status = fields.Selection( - selection=[ - ("SINGLE", "Single"), - ("MARRIED", "Married"), - ("DIVORCED", "Divorced"), - ("WIDOWED", "Widowed"), - ("SEPARATED", "Separated"), - ("UNKNOWN", "Unknown"), - ], - string="Marital Status", - ) - occupation = fields.Char(string="Occupation") - income_level = fields.Char(string="Income Level") - language_code = fields.Char(string="Language Code") - registration_date = fields.Date(string="Registration Date") - - # G2PGeo fields - latitude = fields.Char(string="Latitude") - longitude = fields.Char(string="Longitude") - altitude = fields.Char(string="Altitude") - plus_code = fields.Char(string="Plus Code", index=True) - address_line_1 = fields.Char(string="Address Line 1") - address_line_2 = fields.Char(string="Address Line 2") - postal_code = fields.Char(string="Postal Code", index=True) - country_code = fields.Char(string="Country Code", index=True) - geo_lowest_level_value_id = fields.Char(string="Geo Lowest Level Value ID", index=True) - geo_code_hierarchy_json = fields.Json(string="Geo Code Hierarchy") - - # G2PFarmer fields - estimated_age = fields.Integer(string="Estimated Age") - has_personal_phone = fields.Boolean(string="Has Personal Phone") - disabled = fields.Boolean(string="Disabled") - disability_type = fields.Selection( - selection=[ - ("VISION", "Vision"), - ("HEARING", "Hearing"), - ("MOBILITY", "Mobility"), - ("COGNITION", "Cognition"), - ("SELF_CARE", "Self Care"), - ("COMMUNICATION", "Communication"), - ], - string="Disability Type", - ) - disability_severity = fields.Selection( - selection=[ - ("NO_DIFFICULTY", "No Difficulty"), - ("SOME_DIFFICULTY", "Some Difficulty"), - ("A_LOT_OF_DIFFICULTY", "A Lot of Difficulty"), - ("CANNOT_DO_AT_ALL", "Cannot Do At All"), - ], - string="Disability Severity", - ) - source_of_income = fields.Selection( - selection=[ - ("CROP_PRODUCTION", "Crop Production"), - ("LIVESTOCK_PRODUCTION", "Livestock Production"), - ("GOVERNMENT_NGO_SUPPORT", "Government / NGO Support"), - ("OTHERS", "Others"), - ], - string="Source of Income", - ) - source_of_income_other = fields.Char(string="Source of Income (Other)") - language_spoken = fields.Char(string="Language Spoken") - education_level = fields.Selection( - selection=[ - ("ILLITERATE", "Illiterate"), - ("CAN_READ_AND_WRITE", "Can Read and Write"), - ("BASIC", "Basic"), - ("INTERMEDIARY", "Intermediary"), - ("HIGHER_EDUCATION", "Higher Education"), - ], - string="Education Level", - ) - national_id_masked = fields.Char(string="National ID (Masked)") diff --git a/odoo/extensions/g2p_registry_addon/models/household.py b/odoo/extensions/g2p_registry_addon/models/household.py deleted file mode 100644 index 0bdf50f..0000000 --- a/odoo/extensions/g2p_registry_addon/models/household.py +++ /dev/null @@ -1,184 +0,0 @@ -from odoo import models, fields - -from .registry import G2PRegistry - - -class G2PRegisterHousehold(models.Model): - _name = "g2p.register.households" - _description = "Register Household" - _inherit = "g2p.registry" - - # G2PRegister fields - functional_record_id = fields.Char(string="Functional Record ID", index=True) - link_internal_record_id = fields.Char(string="Link Internal Record ID", index=True) - link_foundational_id = fields.Char(string="Link Foundational ID", index=True) - record_name = fields.Char(string="Record Name") - record_image_storage_id = fields.Text(string="Record Image Storage ID") - created_by = fields.Char(string="Created By") - created_at = fields.Datetime(string="Created At") - last_approved_at = fields.Datetime(string="Last Approved At") - last_approved_by = fields.Char(string="Last Approved By") - search_text = fields.Text(string="Search Text") - record_status = fields.Selection( - selection=[ - ("active", "Active"), - ("inactive", "Inactive"), - ("archived", "Archived"), - ], - string="Record Status", - default="active", - ) - record_status_reason = fields.Char(string="Record Status Reason") - - # G2PGeo fields - latitude = fields.Char(string="Latitude") - longitude = fields.Char(string="Longitude") - altitude = fields.Char(string="Altitude") - plus_code = fields.Char(string="Plus Code", index=True) - address_line_1 = fields.Char(string="Address Line 1") - address_line_2 = fields.Char(string="Address Line 2") - postal_code = fields.Char(string="Postal Code", index=True) - country_code = fields.Char(string="Country Code", index=True) - geo_lowest_level_value_id = fields.Char(string="Geo Lowest Level Value ID", index=True) - geo_code_hierarchy_json = fields.Json(string="Geo Code Hierarchy") - - # Household head - household_head_internal_record_id = fields.Char( - string="Household Head Internal Record ID", index=True - ) - household_head_name = fields.Char(string="Household Head Name") - headship_type = fields.Selection( - selection=[ - ("MALE_HEADED", "Male Headed"), - ("FEMALE_HEADED", "Female Headed"), - ("CHILD_HEADED", "Child Headed"), - ("ELDERLY_HEADED", "Elderly Headed"), - ("DISABLED_HEADED", "Disabled Headed"), - ], - string="Headship Type", - ) - - # Household composition - size_total = fields.Integer(string="Total Size") - size_adults = fields.Integer(string="Adults") - size_children_u5 = fields.Integer(string="Children Under 5") - size_school_age = fields.Integer(string="School Age") - size_elderly = fields.Integer(string="Elderly") - number_of_female_members = fields.Integer(string="Number of Female Members") - number_of_male_members = fields.Integer(string="Number of Male Members") - elderly_member_present = fields.Boolean(string="Elderly Member Present") - - # Dwelling - dwelling_type = fields.Selection( - selection=[ - ("PERMANENT", "Permanent"), - ("SEMI_PERMANENT", "Semi-Permanent"), - ("TEMPORARY", "Temporary"), - ], - string="Dwelling Type", - ) - roof_material = fields.Selection( - selection=[ - ("THATCH", "Thatch"), - ("CORRUGATED_IRON", "Corrugated Iron"), - ("CONCRETE", "Concrete"), - ("TILE", "Tile"), - ("PLASTIC_SHEET", "Plastic Sheet"), - ("OTHER", "Other"), - ], - string="Roof Material", - ) - wall_material = fields.Selection( - selection=[ - ("MUD", "Mud"), - ("WOOD", "Wood"), - ("BAMBOO", "Bamboo"), - ("STONE", "Stone"), - ("BRICK", "Brick"), - ("CONCRETE", "Concrete"), - ("OTHER", "Other"), - ], - string="Wall Material", - ) - floor_material = fields.Selection( - selection=[ - ("EARTH", "Earth"), - ("WOOD", "Wood"), - ("CEMENT", "Cement"), - ("TILE", "Tile"), - ("OTHER", "Other"), - ], - string="Floor Material", - ) - tenure_status = fields.Selection( - selection=[ - ("OWNED", "Owned"), - ("RENTED", "Rented"), - ("HOSTED", "Hosted"), - ("TEMPORARY", "Temporary"), - ], - string="Tenure Status", - ) - rooms_count = fields.Integer(string="Rooms Count") - overcrowding_indicator = fields.Float(string="Overcrowding Indicator") - - # Utilities - water_source_type = fields.Selection( - selection=[ - ("PIPED", "Piped"), - ("PUBLIC_TAP", "Public Tap"), - ("WELL", "Well"), - ("SPRING", "Spring"), - ("SURFACE_WATER", "Surface Water"), - ("RAINWATER", "Rainwater"), - ("TANKER_TRUCK", "Tanker Truck"), - ("OTHER", "Other"), - ], - string="Water Source Type", - ) - water_distance_minutes = fields.Integer(string="Water Distance (Minutes)") - sanitation_type = fields.Selection( - selection=[ - ("FLUSH_TOILET", "Flush Toilet"), - ("PIT_LATRINE", "Pit Latrine"), - ("COMPOSTING_TOILET", "Composting Toilet"), - ("SHARED", "Shared"), - ("OPEN", "Open"), - ("OTHER", "Other"), - ], - string="Sanitation Type", - ) - lighting_source = fields.Selection( - selection=[ - ("GRID", "Grid"), - ("SOLAR", "Solar"), - ("GENERATOR", "Generator"), - ("KEROSENE", "Kerosene"), - ("CANDLE", "Candle"), - ("NONE", "None"), - ], - string="Lighting Source", - ) - cooking_fuel_type = fields.Selection( - selection=[ - ("ELECTRICITY", "Electricity"), - ("GAS", "Gas"), - ("KEROSENE", "Kerosene"), - ("CHARCOAL", "Charcoal"), - ("FIREWOOD", "Firewood"), - ("BIOMASS", "Biomass"), - ("OTHER", "Other"), - ], - string="Cooking Fuel Type", - ) - mobile_phone_type = fields.Selection( - selection=[ - ("NONE", "None"), - ("BASIC", "Basic"), - ("SMARTPHONE", "Smartphone"), - ], - string="Mobile Phone Type", - ) - - husband_dead = fields.Boolean(string="Is Husband Dead") - husband_death_date = fields.Datetime(string="Husband Death Date") diff --git a/odoo/extensions/g2p_registry_addon/models/registry.py b/odoo/extensions/g2p_registry_addon/models/registry.py deleted file mode 100644 index 513078a..0000000 --- a/odoo/extensions/g2p_registry_addon/models/registry.py +++ /dev/null @@ -1,19 +0,0 @@ -from odoo import models, fields - - -class G2PRegistry(models.AbstractModel): - _name = "g2p.registry" - _description = "Abstract G2P Registry" - - internal_record_id = fields.Char(string="Internal Record ID") - - def action_open_view(self): - return { - "type": "ir.actions.act_window", - "name": "View Registry Record", - "res_model": self._name, - "res_id": self.id, - "view_mode": "form", - "target": "new", - "flags": {"mode": "readonly"}, - } diff --git a/odoo/extensions/g2p_registry_addon/security/ir.model.access.csv b/odoo/extensions/g2p_registry_addon/security/ir.model.access.csv deleted file mode 100644 index 54e7501..0000000 --- a/odoo/extensions/g2p_registry_addon/security/ir.model.access.csv +++ /dev/null @@ -1,5 +0,0 @@ -id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink -g2p_register_farmer_read,Read Farmer Registry,model_g2p_register_farmer,g2p_pbms.group_beneficiary_list_viewer,1,0,0,0 -g2p_register_farmer_write,Write Farmer Registry,model_g2p_register_farmer,g2p_pbms.group_beneficiary_list_editor,1,1,1,1 -g2p_register_household_read,Read Register Household,model_g2p_register_households,g2p_pbms.group_beneficiary_list_viewer,1,0,0,0 -g2p_register_household_write,Write Register Household,model_g2p_register_households,g2p_pbms.group_beneficiary_list_editor,1,1,1,1 diff --git a/odoo/extensions/g2p_registry_addon/static/description/icon.png b/odoo/extensions/g2p_registry_addon/static/description/icon.png deleted file mode 100644 index 5ecb429ea9ceb3863d46ea852dc9c9f78d4e901b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3985 zcmZ{n`9BkmAIC8pv!Q92t8$HU&3*S_?hrzbeAwnL%6)_wHrJX+S}0c-Wzr~eMDCAc z3e6Qh%8{GMmHPTVzCV9|c)eeb_v7^sJfCT{SIxM>=H)Shy|Bjjx?H>A&FwonBg- z;pNj}4ZUWDW}WDhk3W6DLFO)@EG&?-{|zfkUIBuIg;&GE*w7)WVErlh0sk03aU#cr z9mpQ+1?EO`UJ_2TBS{!@!w8&ZuzKTvq!sP5i}*;?G6Ozf31_umSm!HX_UqwnT(H@F z!;4+U(}n_e!#;GwpT87{g+-6+*1w#%zH;3OnWfOilJi--y~$P9xDhgz4Ss2SZy>& zeDnlOJI>wC&e{J?`*!KF3>sZC5(&vKSp&S)Nexs^!d`0pD&bEb&``VbyL3ffQ28~a zPqZo{@J3Fr+GEx3>w?XUGfX&*5<-x$@j_YB{I5p9Wb*aKjwXh@a#PQUcED$`n6pM! zU$y4@_|tV0KFY)749csA9d;b#Qb*)rN~&GVL3+Fc-}|qrGJGx6L~9!$lLB1#VZ1zEe5&g^$1THq`Vs5Lbc1CjIy~SZv z=lz0hR|xp!(sr{5TyjhPE+L%M{{*+)5R!t62oDgzu{t%&quHjkH7q;R1eCAI%nJ|^ ztw4^@1)i>ESwKg?T>4`ZbIc|Q>N(xnUF(bL+EN;tE~ZGTq6Y2_C#&9;6Hi<6@}j^5 zl*yjySU%qk^w^8lNt7|rcltV-FFr2|OVcFPzzz~F60rr1M&frEy(qJw?m%g&?FJGw zl!lF!iHdDu^n@((5Sozy`Wm#~{}Ow46zBNYae0TJ(m&E#x8?1j*A?o~XmQ3s8)`GC zdq6^J$GV5;f<-WkF=F=6M+5$n9cq9kQISRQjfQH1m;35CY9G<9o}f(ZPybuap>(iv zGf`{NCB>&$;FCYHG4zs+bzIn3v{`1N07zM#rADR8AhYvL7cJ#O9WefihzwcVLhv&I z>ux1t!+kFtusq)w?@$gEqj*O;57~?Askg^~=`QZ< z975e6wC`Tl+sKn0l7A(*dqqTv><|8|DzeD%|Jv(j9&l^xe7Qt5yP0rz@Vg#nNNJP9 zDvmh<{NpNErK0B7Jx_Ut5qapcOb(}7Y^Vrk$H1NaT%HRW2zIR6s}_1*^669!W*P^B z7T~uymT&Xvl6CoGaaj1f4r|syYnq3Oc%OAULg^%7_Bv{Y?tGl&S+jGXvyytbizZn0 z+3q*=kBp)I!-HTqv$)vFw7Fe#5guV-X_{!VSK)GH8S<8A`VKG(QNT{(tFB@4$9DS( z2w$UmtmVnt>b}yii5h*2n=a_8s-UxSjO&MZ)qFr)^bPkNqhC& zy+AU@E@KJL#RzdptH}HL12Ks1BtIy%b-Hdh;QeM3HmUWroq&Nxoza6L6JT@DpoT&9 zo7J|{QV~H~u4_L==Oz(utH-j8o z*#O=xe!9y{MvU>w<1ZJ%?xs$xxn(L6mc`VkPdq}vt|wa$8*X*5KmG8n-)M%#H13K7 zvY7fsf9&178e}_Dipe`-bMLMge4PcZ&6j>;#E7kpS8n}@yBlud5OqSen5s36%=2;i zX8xRz=)O1y)WkVwBW!m?paXohe4^`G))F>*bgM`&I4&Yvi#lr*nL9z+8*XBJr-fd> zMZocZUWnx_1gdytJKHYj%MWHxeJd9eA;r8giAKX>qMHF}gmLptV~csPBV)C~ikKF4 zb~o&4zp$JQxAd@UMTP!b$S?4u=N-(aarBrN!#|fZZ%xh7J=MO~Uf1Ch^bfBpiffy@ zVcJre$X}K9?LOJcD1dW}V#o2gkp|ltO^m*&I9qbwNHK2^R%ZvZcC$J8T{MeL=jI3! zO6e}Xn^5xAr9@{|KbPux8}7Vv@+YENV>t21;|Yb3%yy3LSx5kdGY@ZeJoC}7eits2 zRk67A41~lx=4QSKe3pmt9#b*gewUD`qGH{dXKNkUVE&h|JtLeJjxN5D@S@$){b;CZ zZ%&WqZ2PJZuOO6M*j18>6wzF|Ki8 z04-~EVjJh^6)8k{ejR~)+%ormPQW%W_gZq*p0PsCpf@JR)tlm`kyu%Dt1^D}IoFtG zru!uTee_C)aV!vtzp3o0;PBLcpK!CK9zo2h#Y#{oe%~6Vj=qmCK<~MaoNtyUR@$p{ z7%TNMlFmQU;jn;L@y3vO#yBK9QPRmeP&22LCT?)ou^|-%qsLmMVYyy$=GfqH@T$Mh z_i7a*%EMlQ7T(_Sf)Q@+Us~C^Ax*rZO+87&UZX7fFtrm5 zdDu$Z6@yrkC$+8;)zIoXSLtg*ypHxK;H_9{tCVFS`>#t5Q&c-k(jxF}C@dxGpJ`O* zxid`+S|ujEw0(6__AnN(vDp08A*L9?-S%t9WqFQbzkcbW`taAkGvo zr*J=;arqUT6t%k5Ae-Z8mh7?Ac7XSACXil3x$p8jeBe_|9KH%N1z` zGM!*QHykP8((We#uUABH&UkA;)sN3sTbpi!67|WOviA6o%p1l)IMwk{Ci_jCR*$Y# zNmEA6yCZ;^Y4P>XatST*<_=3uO@j;gIN!OylGyvB?0S)yvW_OMy|2AIP#OWZ&sHds zM<9av;&2S75Nz()9Gn@=x4>z#$^IFEARfiwBE!&z#|KsM$y4%o*d`EEIQrjA@aPKu zxleJ{>b>A46GM?C8!^fPP}wrA%=%&7`^EJO?VoO(+-?ud^)+0%b0SCA%z+! z3trk8b0Dk__(b#9^+^bpBqs{dc+)dY0@)P44kdl~O_-1u!N`Q<*n@bjsKgMqBGNs$JxFytI$)E$+%TA0GNs!$(99>Tl&T%(pMMubbHA7A+K zWkF*$WC$Y0`z}eYy`@$7R{^jbKh@4+tFS+EQ5L@9u$8=_S-FyB82<-Isr=Kjt;I!d zDQ`QR1>=aU4|XFk9HlN)4rbKMeT{#V+Spz-_J;eRKg(cBJf5Zq*cSO<&_!=#EJtk6 zx6+Xu7frJvZjt^o+IKQ_hn50`vbOo+)=JWy-z8MEZR9Xd*rqwFm?=YcMLcs0Ii`I} zj$3gZtGs=U`Glfnl7`1%=%HpQ7I{D{9c;~$Y@VE-R5QPFwz;auSpI~zQ(NXDv8=}r zQdVQFSq^O$*iRkVWcB}}=>)X4L%E92z3}ID%j~K!jE)xq5-Mvpp`t$85A3%_Z`3U| z_mfD+Z_U>vNs*6hk&PX})%6n%^A|QW)1+04wKP%r((^n?&XXKB8FM9azaNY)UY@_0x7Uvrd2Yker2@P*8^o9r@)VN14D=0#ZmhP{I^=G6Ud6%;*k02fl8|u`G0`mg0 zbwwjz1L(%`>S=wAwiFn7fKPeoLixCF1B1DbhK!MpvV*2^DMaxjO6P)u>=4%}!nKRh zYXnML1|4z;L}fM4<_^a$$>~NqUwX9P+&$}$zw0u~w8XRY+cnBdpcg42D>W1T6{%Y*U|J?nqQC@Ju$M4~q)PoHwr*NY|Oo!U_cUq)QE9WxIt7 zu`}SIkE2V`tV*2-a;&yp(HjW}We~mOIq_K0sdcih=M5qN5ToT3Ul^Z?dE&8g>n%Y2 zV~pS_U+TRNgH>ED4>T-S?NK8i+J*7?#ty-$eU@+X#XfCoHm1Y+Vl#_n_fb8@XWyUS zTi3ktJP>mn(!J;=`?C>$=pMcbP*-C19i-H_BF`%$h%I}?)<0rAtRJJ&(gcprGsK*b z==K|lG3~j@rp0j{8-T#SyUQ|mP8ABIO{$fntjf%CP(TL$T?u2kuce)eboTsk2mEtF zar;GOQo6f^yFbuD{C(#o z_`)S=%=3|fEAXaiyhxzL5#8eAyg}kr0vCkL_9QO(@B9?xjruX>Umt32uV(&VG5w#k cQjyE?yb-=lO40g}r&`ToVRF@&hQ=iR2lB5=%K!iX diff --git a/odoo/extensions/g2p_registry_addon/static/src/css/registry_styles.scss b/odoo/extensions/g2p_registry_addon/static/src/css/registry_styles.scss deleted file mode 100644 index 40cd300..0000000 --- a/odoo/extensions/g2p_registry_addon/static/src/css/registry_styles.scss +++ /dev/null @@ -1,10 +0,0 @@ -.o_widget.o_widget_g2p_beneficiaries_widget { - width: 180% !important; - box-sizing: border-box; -} - -.o_form_view .o_notebook > .tab-content > .tab-pane > :first-child:not(.o_group) .o_field_x2many.o_field_x2many_list .o_list_renderer, -.o_form_view .o_notebook > .tab-content > .tab-pane > .o_invisible_modifier:first-child .o_field_x2many.o_field_x2many_list .o_list_renderer { - --ListRenderer-margin-x: 0 !important; -} - \ No newline at end of file diff --git a/odoo/extensions/g2p_registry_addon/static/src/js/beneficiaries_widget.js b/odoo/extensions/g2p_registry_addon/static/src/js/beneficiaries_widget.js deleted file mode 100644 index 7fb0b99..0000000 --- a/odoo/extensions/g2p_registry_addon/static/src/js/beneficiaries_widget.js +++ /dev/null @@ -1,110 +0,0 @@ -/** @odoo-module **/ - -import { Component, useState } from "@odoo/owl"; -import { DomainSelector } from "@web/core/domain_selector/domain_selector"; -// import { Domain, InvalidDomainError } from "@web/core/domain"; -// import { EvaluationError } from "@web/core/py_js/py_builtin"; -import { useService } from "@web/core/utils/hooks"; -import { _t } from "@web/core/l10n/translation"; -import { registry } from "@web/core/registry"; - -export class G2PBeneficiariesComponent extends Component { - static template = "g2p_beneficiaries_info_tpl"; - static components = { - DomainSelector - }; - static props = { - context: { type: Object, optional: true }, - resModel: { type: String, optional: true }, - record: { type: Object, optional: true }, - readonly: { type: Boolean, optional: true }, - }; - - setup() { - const recordData = this.props.record?.data || {}; - this.state = useState({ - title: _t("Beneficiaries"), - records: [], - page: 1, - pageSize: 3, - totalCount: 0, - totalPages: 1, - target_registry: recordData.target_registry || null, - searched: false, - domain: "[]", - showAllColumns: false, - }); - this.orm = useService("orm"); - console.log(this); - } - - onDomainChange(newDomain) { - this.state.domain = newDomain; - this.render(); - } - - getEvaluatedDomain() { - return this.state.domain; - } - - searchRegistrants() { - this.state.searched = true; // show title and pagination when search is clicked - this.state.page = 1; - this.state.pageSize = 20; - this._fetchRecords(); - } - - async _fetchRecords() { - const result = await this.orm.call( - 'g2p.bgtask.summary.wizard', - 'get_beneficiaries', - [this.props.record.resId, this.state.page, this.state.pageSize, this.getEvaluatedDomain()], - {}, - ); - - if (result?.response_body) { - const body = result.response_body; - this.state.records = body.response_payload?.beneficiaries || []; - this.state.totalCount = body.pagination_response?.number_of_items || 0; - this.state.totalPages = body.pagination_response?.number_of_pages || 1; - } else if (result?.message) { - this.state.records = result.message.beneficiaries || []; - this.state.totalCount = result.message.total_beneficiary_count || 0; - this.state.totalPages = Math.ceil(this.state.totalCount / this.state.pageSize) || 1; - } else if (result) { - this.state.records = result.records || []; - this.state.totalCount = result.total_count || 0; - this.state.totalPages = Math.ceil(this.state.totalCount / this.state.pageSize) || 1; - } - } - - async nextPage() { - if (this.state.page < this.state.totalPages) { - this.state.page++; - await this._fetchRecords(); - } - } - - async prevPage() { - if (this.state.page > 1) { - this.state.page--; - await this._fetchRecords(); - } - } - - toggleColumns() { - this.state.showAllColumns = !this.state.showAllColumns; - } -} - -export const g2pBeneficiariesWidget = { - component: G2PBeneficiariesComponent, - extractProps({ attrs }, dynamicInfo) { - console.log(attrs, dynamicInfo) - return { - resModel: attrs.model, - context: dynamicInfo.context, - }; - }, -}; -registry.category("view_widgets").add("g2p_beneficiaries_widget", g2pBeneficiariesWidget); diff --git a/odoo/extensions/g2p_registry_addon/static/src/xml/g2p_beneficiaries_info_tpl.xml b/odoo/extensions/g2p_registry_addon/static/src/xml/g2p_beneficiaries_info_tpl.xml deleted file mode 100644 index fbb4ac0..0000000 --- a/odoo/extensions/g2p_registry_addon/static/src/xml/g2p_beneficiaries_info_tpl.xml +++ /dev/null @@ -1,175 +0,0 @@ - - - - -
- -
- - -
- -
- - -
- -
-
- - -
- - Page of - -
-
- - -
- -
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Internal IDFunctional IDFirst NameLast NameGenderEst. AgeDisabledSource of IncomeEducation LevelCountryInternal IDFunctional IDHead NameHeadshipSizeChildren U5ElderlyFemaleMaleDwellingTenureRoomsOvercrowdingWaterSanitationLightingCooking FuelAddress 1Address 2PostalCountry
- - - -
- - No records found. - - - No records found. - - - No records found. -
-
- - - -
- - - Page of - - -
-
-
-
-
diff --git a/odoo/extensions/g2p_registry_addon/views/bgtask/bgtask_view.xml b/odoo/extensions/g2p_registry_addon/views/bgtask/bgtask_view.xml deleted file mode 100644 index f1ca744..0000000 --- a/odoo/extensions/g2p_registry_addon/views/bgtask/bgtask_view.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - g2p.bgtask.summary.wizard.form.inherit.beneficiaries - g2p.bgtask.summary.wizard - - - - - - - - - - - - - - \ No newline at end of file diff --git a/odoo/extensions/g2p_registry_addon/views/eligibility/eligibility_rule_view.xml b/odoo/extensions/g2p_registry_addon/views/eligibility/eligibility_rule_view.xml deleted file mode 100644 index 7f1a92c..0000000 --- a/odoo/extensions/g2p_registry_addon/views/eligibility/eligibility_rule_view.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - g2p.eligibility.rule.definition.form.inherit - g2p.eligibility.rule.definition - - - - - - - - - - - - - - - - diff --git a/odoo/extensions/g2p_registry_addon/views/entitlement/entitlement_rule_view.xml b/odoo/extensions/g2p_registry_addon/views/entitlement/entitlement_rule_view.xml deleted file mode 100644 index a0a4d91..0000000 --- a/odoo/extensions/g2p_registry_addon/views/entitlement/entitlement_rule_view.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - g2p.entitlement.rule.definition.form.inherit - g2p.entitlement.rule.definition - - - - - - - - - - - - - - - - diff --git a/odoo/extensions/g2p_registry_addon/views/menu.xml b/odoo/extensions/g2p_registry_addon/views/menu.xml deleted file mode 100644 index 7b740d9..0000000 --- a/odoo/extensions/g2p_registry_addon/views/menu.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - diff --git a/odoo/extensions/g2p_registry_addon/views/priority/priority_rule_view.xml b/odoo/extensions/g2p_registry_addon/views/priority/priority_rule_view.xml deleted file mode 100644 index faa3830..0000000 --- a/odoo/extensions/g2p_registry_addon/views/priority/priority_rule_view.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - g2p.priority.rule.definition.form.inherit - g2p.priority.rule.definition - - - - - - - - - - - - - - - - diff --git a/odoo/extensions/g2p_registry_addon/views/registry/farmer_registry_view.xml b/odoo/extensions/g2p_registry_addon/views/registry/farmer_registry_view.xml deleted file mode 100644 index cc19f91..0000000 --- a/odoo/extensions/g2p_registry_addon/views/registry/farmer_registry_view.xml +++ /dev/null @@ -1,87 +0,0 @@ - - - - - Farmer Registry - g2p.register.farmer - tree,form - - - - g2p.register.farmer.form - g2p.register.farmer - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
- - - g2p.register.farmer.tree - g2p.register.farmer - - - - - - - - - - - - -