From 4597662479be87d99952628b65458ae8a5b53a17 Mon Sep 17 00:00:00 2001 From: pavlo-mk Date: Fri, 20 Dec 2024 09:51:20 +0100 Subject: [PATCH] upd mutations --- .../apps/account/fixtures/data.json | 2 +- .../apps/account/migrations/0003_migration.py | 19 +++++++++ src/hct_mis_api/apps/account/permissions.py | 1 + src/hct_mis_api/apps/payment/celery_tasks.py | 7 +++- .../apps/payment/models/payment.py | 26 +++++++----- src/hct_mis_api/apps/payment/mutations.py | 41 +++++++++++++------ .../payment/services/payment_plan_services.py | 6 ++- ...lsx_payment_plan_export_per_fsp_service.py | 11 +++-- 8 files changed, 81 insertions(+), 32 deletions(-) create mode 100644 src/hct_mis_api/apps/account/migrations/0003_migration.py diff --git a/src/hct_mis_api/apps/account/fixtures/data.json b/src/hct_mis_api/apps/account/fixtures/data.json index e5c1bb55b3..c038394511 100644 --- a/src/hct_mis_api/apps/account/fixtures/data.json +++ b/src/hct_mis_api/apps/account/fixtures/data.json @@ -333,7 +333,7 @@ "updated_at": "2022-03-30 09:05:24.480-00:00", "name": "Role with all permissions", "subsystem": "HOPE", - "permissions": "[\"RDI_VIEW_LIST\", \"RDI_VIEW_DETAILS\", \"RDI_IMPORT_DATA\", \"RDI_RERUN_DEDUPE\", \"RDI_MERGE_IMPORT\", \"RDI_REFUSE_IMPORT\", \"POPULATION_VIEW_HOUSEHOLDS_LIST\", \"POPULATION_VIEW_HOUSEHOLDS_DETAILS\", \"POPULATION_VIEW_INDIVIDUALS_LIST\", \"POPULATION_VIEW_INDIVIDUALS_DETAILS\", \"PROGRAMME_VIEW_LIST_AND_DETAILS\", \"PROGRAMME_MANAGEMENT_VIEW\", \"PROGRAMME_DUPLICATE\", \"PROGRAMME_VIEW_PAYMENT_RECORD_DETAILS\", \"PROGRAMME_CREATE\", \"PROGRAMME_UPDATE\", \"PROGRAMME_REMOVE\", \"PROGRAMME_ACTIVATE\", \"PROGRAMME_FINISH\", \"TARGETING_VIEW_LIST\", \"TARGETING_VIEW_DETAILS\", \"TARGETING_CREATE\", \"TARGETING_UPDATE\", \"TARGETING_DUPLICATE\", \"TARGETING_REMOVE\", \"TARGETING_LOCK\", \"TARGETING_UNLOCK\", \"TARGETING_SEND\", \"PAYMENT_VERIFICATION_VIEW_LIST\", \"PAYMENT_VERIFICATION_VIEW_DETAILS\", \"PAYMENT_VERIFICATION_CREATE\", \"PAYMENT_VERIFICATION_UPDATE\", \"PAYMENT_VERIFICATION_ACTIVATE\", \"PAYMENT_VERIFICATION_DISCARD\", \"PAYMENT_VERIFICATION_FINISH\", \"PAYMENT_VERIFICATION_EXPORT\", \"PAYMENT_VERIFICATION_IMPORT\", \"PAYMENT_VERIFICATION_VERIFY\", \"PAYMENT_VERIFICATION_VIEW_PAYMENT_RECORD_DETAILS\", \"PAYMENT_VERIFICATION_DELETE\", \"PAYMENT_VERIFICATION_MARK_AS_FAILED\", \"USER_MANAGEMENT_VIEW_LIST\", \"DASHBOARD_VIEW_COUNTRY\", \"DASHBOARD_EXPORT\", \"GRIEVANCES_VIEW_LIST_EXCLUDING_SENSITIVE\", \"GRIEVANCES_VIEW_LIST_EXCLUDING_SENSITIVE_AS_CREATOR\", \"GRIEVANCES_VIEW_LIST_EXCLUDING_SENSITIVE_AS_OWNER\", \"GRIEVANCES_VIEW_LIST_SENSITIVE\", \"GRIEVANCES_VIEW_LIST_SENSITIVE_AS_CREATOR\", \"GRIEVANCES_VIEW_LIST_SENSITIVE_AS_OWNER\", \"GRIEVANCES_VIEW_DETAILS_EXCLUDING_SENSITIVE\", \"GRIEVANCES_VIEW_DETAILS_EXCLUDING_SENSITIVE_AS_CREATOR\", \"GRIEVANCES_VIEW_DETAILS_EXCLUDING_SENSITIVE_AS_OWNER\", \"GRIEVANCES_VIEW_DETAILS_SENSITIVE\", \"GRIEVANCES_VIEW_DETAILS_SENSITIVE_AS_CREATOR\", \"GRIEVANCES_VIEW_DETAILS_SENSITIVE_AS_OWNER\", \"GRIEVANCES_VIEW_HOUSEHOLD_DETAILS\", \"GRIEVANCES_VIEW_HOUSEHOLD_DETAILS_AS_CREATOR\", \"GRIEVANCES_VIEW_HOUSEHOLD_DETAILS_AS_OWNER\", \"GRIEVANCES_VIEW_INDIVIDUALS_DETAILS\", \"GRIEVANCES_VIEW_INDIVIDUALS_DETAILS_AS_CREATOR\", \"GRIEVANCES_VIEW_INDIVIDUALS_DETAILS_AS_OWNER\", \"GRIEVANCES_CREATE\", \"GRIEVANCES_UPDATE\", \"GRIEVANCES_UPDATE_AS_CREATOR\", \"GRIEVANCES_UPDATE_AS_OWNER\", \"GRIEVANCES_UPDATE_REQUESTED_DATA_CHANGE\", \"GRIEVANCES_UPDATE_REQUESTED_DATA_CHANGE_AS_CREATOR\", \"GRIEVANCES_UPDATE_REQUESTED_DATA_CHANGE_AS_OWNER\", \"GRIEVANCES_ADD_NOTE\", \"GRIEVANCES_ADD_NOTE_AS_CREATOR\", \"GRIEVANCES_ADD_NOTE_AS_OWNER\", \"GRIEVANCES_SET_IN_PROGRESS\", \"GRIEVANCES_SET_IN_PROGRESS_AS_CREATOR\", \"GRIEVANCES_SET_IN_PROGRESS_AS_OWNER\", \"GRIEVANCES_SET_ON_HOLD\", \"GRIEVANCES_SET_ON_HOLD_AS_CREATOR\", \"GRIEVANCES_SET_ON_HOLD_AS_OWNER\", \"GRIEVANCES_SEND_FOR_APPROVAL\", \"GRIEVANCES_SEND_FOR_APPROVAL_AS_CREATOR\", \"GRIEVANCES_SEND_FOR_APPROVAL_AS_OWNER\", \"GRIEVANCES_SEND_BACK\", \"GRIEVANCES_SEND_BACK_AS_CREATOR\", \"GRIEVANCES_SEND_BACK_AS_OWNER\", \"GRIEVANCES_APPROVE_DATA_CHANGE\", \"GRIEVANCES_APPROVE_DATA_CHANGE_AS_CREATOR\", \"GRIEVANCES_APPROVE_DATA_CHANGE_AS_OWNER\", \"GRIEVANCES_CLOSE_TICKET_EXCLUDING_FEEDBACK\", \"GRIEVANCES_CLOSE_TICKET_EXCLUDING_FEEDBACK_AS_CREATOR\", \"GRIEVANCES_CLOSE_TICKET_EXCLUDING_FEEDBACK_AS_OWNER\", \"GRIEVANCES_CLOSE_TICKET_FEEDBACK\", \"GRIEVANCES_CLOSE_TICKET_FEEDBACK_AS_CREATOR\", \"GRIEVANCES_CLOSE_TICKET_FEEDBACK_AS_OWNER\", \"GRIEVANCES_APPROVE_FLAG_AND_DEDUPE\", \"GRIEVANCES_APPROVE_FLAG_AND_DEDUPE_AS_CREATOR\", \"GRIEVANCES_APPROVE_FLAG_AND_DEDUPE_AS_OWNER\", \"GRIEVANCE_ASSIGN\", \"REPORTING_EXPORT\", \"ALL_VIEW_PII_DATA_ON_LISTS\", \"ACTIVITY_LOG_VIEW\", \"ACTIVITY_LOG_DOWNLOAD\", \"PM_CREATE\", \"PM_VIEW_DETAILS\", \"PM_VIEW_LIST\", \"PM_EXPORT_XLSX_FOR_FSP\", \"PM_DOWNLOAD_XLSX_FOR_FSP\", \"PM_SENDING_PAYMENT_PLAN_TO_FSP\", \"PM_MARK_PAYMENT_AS_FAILED\", \"PM_EXPORT_PDF_SUMMARY\", \"PAYMENT_VERIFICATION_INVALID\", \"GRIEVANCES_APPROVE_PAYMENT_VERIFICATION\", \"GRIEVANCES_APPROVE_PAYMENT_VERIFICATION_AS_CREATOR\", \"GRIEVANCES_APPROVE_PAYMENT_VERIFICATION_AS_OWNER\", \"GRIEVANCE_DOCUMENTS_UPLOAD\", \"PM_IMPORT_XLSX_WITH_ENTITLEMENTS\", \"PM_APPLY_RULE_ENGINE_FORMULA_WITH_ENTITLEMENTS\", \"PM_ADMIN_FINANCIAL_SERVICE_PROVIDER_UPDATE\", \"PM_LOCK_AND_UNLOCK\", \"PM_LOCK_AND_UNLOCK_FSP\", \"PM_EXCLUDE_BENEFICIARIES_FROM_FOLLOW_UP_PP\", \"PM_SEND_FOR_APPROVAL\", \"PM_ACCEPTANCE_PROCESS_APPROVE\", \"PM_ACCEPTANCE_PROCESS_AUTHORIZE\", \"PM_ACCEPTANCE_PROCESS_FINANCIAL_REVIEW\", \"PM_IMPORT_XLSX_WITH_RECONCILIATION\", \"ACCOUNTABILITY_COMMUNICATION_MESSAGE_VIEW_LIST\", \"ACCOUNTABILITY_COMMUNICATION_MESSAGE_VIEW_DETAILS\", \"ACCOUNTABILITY_COMMUNICATION_MESSAGE_VIEW_CREATE\", \"ACCOUNTABILITY_COMMUNICATION_MESSAGE_VIEW_DETAILS_AS_CREATOR\", \"GRIEVANCES_FEEDBACK_VIEW_CREATE\", \"GRIEVANCES_FEEDBACK_VIEW_LIST\", \"GRIEVANCES_FEEDBACK_VIEW_DETAILS\", \"GRIEVANCES_FEEDBACK_VIEW_UPDATE\", \"ACCOUNTABILITY_SURVEY_VIEW_CREATE\", \"ACCOUNTABILITY_SURVEY_VIEW_LIST\", \"ACCOUNTABILITY_SURVEY_VIEW_DETAILS\", \"GRIEVANCES_FEEDBACK_MESSAGE_VIEW_CREATE\", \"CAN_ADD_BUSINESS_AREA_TO_PARTNER\", \"GRIEVANCES_CROSS_AREA_FILTER\", \"PAYMENT_VIEW_LIST_MANAGERIAL\", \"PAYMENT_VIEW_LIST_MANAGERIAL_AS_CREATOR\", \"PAYMENT_VIEW_LIST_MANAGERIAL_AS_OWNER\", \"PAYMENT_VIEW_LIST_MANAGERIAL_AS_APPROVER\", \"PAYMENT_VIEW_LIST_MANAGERIAL_AS_AUTHORIZER\", \"PAYMENT_VIEW_LIST_MANAGERIAL\", \"PAYMENT_VIEW_LIST_MANAGERIAL_RELEASED\", \"PDU_VIEW_LIST_AND_DETAILS\", \"PDU_TEMPLATE_CREATE\", \"PDU_TEMPLATE_DOWNLOAD\", \"PDU_UPLOAD\", \"GEO_VIEW_LIST\", \"PM_PROGRAMME_CYCLE_VIEW_LIST\", \"PM_PROGRAMME_CYCLE_VIEW_DETAILS\", \"PM_PROGRAMME_CYCLE_CREATE\", \"PM_PROGRAMME_CYCLE_UPDATE\", \"PM_PROGRAMME_CYCLE_DELETE\", \"PM_UPLOAD_SUPPORTING_DOCUMENT\", \"PM_DOWNLOAD_SUPPORTING_DOCUMENT\", \"PM_DELETE_SUPPORTING_DOCUMENT\"]" + "permissions": "[\"RDI_VIEW_LIST\", \"RDI_VIEW_DETAILS\", \"RDI_IMPORT_DATA\", \"RDI_RERUN_DEDUPE\", \"RDI_MERGE_IMPORT\", \"RDI_REFUSE_IMPORT\", \"POPULATION_VIEW_HOUSEHOLDS_LIST\", \"POPULATION_VIEW_HOUSEHOLDS_DETAILS\", \"POPULATION_VIEW_INDIVIDUALS_LIST\", \"POPULATION_VIEW_INDIVIDUALS_DETAILS\", \"PROGRAMME_VIEW_LIST_AND_DETAILS\", \"PROGRAMME_MANAGEMENT_VIEW\", \"PROGRAMME_DUPLICATE\", \"PROGRAMME_VIEW_PAYMENT_RECORD_DETAILS\", \"PROGRAMME_CREATE\", \"PROGRAMME_UPDATE\", \"PROGRAMME_REMOVE\", \"PROGRAMME_ACTIVATE\", \"PROGRAMME_FINISH\", \"TARGETING_VIEW_LIST\", \"TARGETING_VIEW_DETAILS\", \"TARGETING_CREATE\", \"TARGETING_UPDATE\", \"TARGETING_DUPLICATE\", \"TARGETING_REMOVE\", \"TARGETING_LOCK\", \"TARGETING_UNLOCK\", \"TARGETING_SEND\", \"PAYMENT_VERIFICATION_VIEW_LIST\", \"PAYMENT_VERIFICATION_VIEW_DETAILS\", \"PAYMENT_VERIFICATION_CREATE\", \"PAYMENT_VERIFICATION_UPDATE\", \"PAYMENT_VERIFICATION_ACTIVATE\", \"PAYMENT_VERIFICATION_DISCARD\", \"PAYMENT_VERIFICATION_FINISH\", \"PAYMENT_VERIFICATION_EXPORT\", \"PAYMENT_VERIFICATION_IMPORT\", \"PAYMENT_VERIFICATION_VERIFY\", \"PAYMENT_VERIFICATION_VIEW_PAYMENT_RECORD_DETAILS\", \"PAYMENT_VERIFICATION_DELETE\", \"PAYMENT_VERIFICATION_MARK_AS_FAILED\", \"USER_MANAGEMENT_VIEW_LIST\", \"DASHBOARD_VIEW_COUNTRY\", \"DASHBOARD_EXPORT\", \"GRIEVANCES_VIEW_LIST_EXCLUDING_SENSITIVE\", \"GRIEVANCES_VIEW_LIST_EXCLUDING_SENSITIVE_AS_CREATOR\", \"GRIEVANCES_VIEW_LIST_EXCLUDING_SENSITIVE_AS_OWNER\", \"GRIEVANCES_VIEW_LIST_SENSITIVE\", \"GRIEVANCES_VIEW_LIST_SENSITIVE_AS_CREATOR\", \"GRIEVANCES_VIEW_LIST_SENSITIVE_AS_OWNER\", \"GRIEVANCES_VIEW_DETAILS_EXCLUDING_SENSITIVE\", \"GRIEVANCES_VIEW_DETAILS_EXCLUDING_SENSITIVE_AS_CREATOR\", \"GRIEVANCES_VIEW_DETAILS_EXCLUDING_SENSITIVE_AS_OWNER\", \"GRIEVANCES_VIEW_DETAILS_SENSITIVE\", \"GRIEVANCES_VIEW_DETAILS_SENSITIVE_AS_CREATOR\", \"GRIEVANCES_VIEW_DETAILS_SENSITIVE_AS_OWNER\", \"GRIEVANCES_VIEW_HOUSEHOLD_DETAILS\", \"GRIEVANCES_VIEW_HOUSEHOLD_DETAILS_AS_CREATOR\", \"GRIEVANCES_VIEW_HOUSEHOLD_DETAILS_AS_OWNER\", \"GRIEVANCES_VIEW_INDIVIDUALS_DETAILS\", \"GRIEVANCES_VIEW_INDIVIDUALS_DETAILS_AS_CREATOR\", \"GRIEVANCES_VIEW_INDIVIDUALS_DETAILS_AS_OWNER\", \"GRIEVANCES_CREATE\", \"GRIEVANCES_UPDATE\", \"GRIEVANCES_UPDATE_AS_CREATOR\", \"GRIEVANCES_UPDATE_AS_OWNER\", \"GRIEVANCES_UPDATE_REQUESTED_DATA_CHANGE\", \"GRIEVANCES_UPDATE_REQUESTED_DATA_CHANGE_AS_CREATOR\", \"GRIEVANCES_UPDATE_REQUESTED_DATA_CHANGE_AS_OWNER\", \"GRIEVANCES_ADD_NOTE\", \"GRIEVANCES_ADD_NOTE_AS_CREATOR\", \"GRIEVANCES_ADD_NOTE_AS_OWNER\", \"GRIEVANCES_SET_IN_PROGRESS\", \"GRIEVANCES_SET_IN_PROGRESS_AS_CREATOR\", \"GRIEVANCES_SET_IN_PROGRESS_AS_OWNER\", \"GRIEVANCES_SET_ON_HOLD\", \"GRIEVANCES_SET_ON_HOLD_AS_CREATOR\", \"GRIEVANCES_SET_ON_HOLD_AS_OWNER\", \"GRIEVANCES_SEND_FOR_APPROVAL\", \"GRIEVANCES_SEND_FOR_APPROVAL_AS_CREATOR\", \"GRIEVANCES_SEND_FOR_APPROVAL_AS_OWNER\", \"GRIEVANCES_SEND_BACK\", \"GRIEVANCES_SEND_BACK_AS_CREATOR\", \"GRIEVANCES_SEND_BACK_AS_OWNER\", \"GRIEVANCES_APPROVE_DATA_CHANGE\", \"GRIEVANCES_APPROVE_DATA_CHANGE_AS_CREATOR\", \"GRIEVANCES_APPROVE_DATA_CHANGE_AS_OWNER\", \"GRIEVANCES_CLOSE_TICKET_EXCLUDING_FEEDBACK\", \"GRIEVANCES_CLOSE_TICKET_EXCLUDING_FEEDBACK_AS_CREATOR\", \"GRIEVANCES_CLOSE_TICKET_EXCLUDING_FEEDBACK_AS_OWNER\", \"GRIEVANCES_CLOSE_TICKET_FEEDBACK\", \"GRIEVANCES_CLOSE_TICKET_FEEDBACK_AS_CREATOR\", \"GRIEVANCES_CLOSE_TICKET_FEEDBACK_AS_OWNER\", \"GRIEVANCES_APPROVE_FLAG_AND_DEDUPE\", \"GRIEVANCES_APPROVE_FLAG_AND_DEDUPE_AS_CREATOR\", \"GRIEVANCES_APPROVE_FLAG_AND_DEDUPE_AS_OWNER\", \"GRIEVANCE_ASSIGN\", \"REPORTING_EXPORT\", \"ALL_VIEW_PII_DATA_ON_LISTS\", \"ACTIVITY_LOG_VIEW\", \"ACTIVITY_LOG_DOWNLOAD\", \"PM_CREATE\", \"PM_VIEW_DETAILS\", \"PM_VIEW_LIST\", \"PM_EXPORT_XLSX_FOR_FSP\", \"PM_DOWNLOAD_XLSX_FOR_FSP\", \"PM_SENDING_PAYMENT_PLAN_TO_FSP\", \"PM_MARK_PAYMENT_AS_FAILED\", \"PM_EXPORT_PDF_SUMMARY\", \"PM_DOWNLOAD_MTCN\", \"PAYMENT_VERIFICATION_INVALID\", \"GRIEVANCES_APPROVE_PAYMENT_VERIFICATION\", \"GRIEVANCES_APPROVE_PAYMENT_VERIFICATION_AS_CREATOR\", \"GRIEVANCES_APPROVE_PAYMENT_VERIFICATION_AS_OWNER\", \"GRIEVANCE_DOCUMENTS_UPLOAD\", \"PM_IMPORT_XLSX_WITH_ENTITLEMENTS\", \"PM_APPLY_RULE_ENGINE_FORMULA_WITH_ENTITLEMENTS\", \"PM_ADMIN_FINANCIAL_SERVICE_PROVIDER_UPDATE\", \"PM_LOCK_AND_UNLOCK\", \"PM_LOCK_AND_UNLOCK_FSP\", \"PM_EXCLUDE_BENEFICIARIES_FROM_FOLLOW_UP_PP\", \"PM_SEND_FOR_APPROVAL\", \"PM_ACCEPTANCE_PROCESS_APPROVE\", \"PM_ACCEPTANCE_PROCESS_AUTHORIZE\", \"PM_ACCEPTANCE_PROCESS_FINANCIAL_REVIEW\", \"PM_IMPORT_XLSX_WITH_RECONCILIATION\", \"ACCOUNTABILITY_COMMUNICATION_MESSAGE_VIEW_LIST\", \"ACCOUNTABILITY_COMMUNICATION_MESSAGE_VIEW_DETAILS\", \"ACCOUNTABILITY_COMMUNICATION_MESSAGE_VIEW_CREATE\", \"ACCOUNTABILITY_COMMUNICATION_MESSAGE_VIEW_DETAILS_AS_CREATOR\", \"GRIEVANCES_FEEDBACK_VIEW_CREATE\", \"GRIEVANCES_FEEDBACK_VIEW_LIST\", \"GRIEVANCES_FEEDBACK_VIEW_DETAILS\", \"GRIEVANCES_FEEDBACK_VIEW_UPDATE\", \"ACCOUNTABILITY_SURVEY_VIEW_CREATE\", \"ACCOUNTABILITY_SURVEY_VIEW_LIST\", \"ACCOUNTABILITY_SURVEY_VIEW_DETAILS\", \"GRIEVANCES_FEEDBACK_MESSAGE_VIEW_CREATE\", \"CAN_ADD_BUSINESS_AREA_TO_PARTNER\", \"GRIEVANCES_CROSS_AREA_FILTER\", \"PAYMENT_VIEW_LIST_MANAGERIAL\", \"PAYMENT_VIEW_LIST_MANAGERIAL_AS_CREATOR\", \"PAYMENT_VIEW_LIST_MANAGERIAL_AS_OWNER\", \"PAYMENT_VIEW_LIST_MANAGERIAL_AS_APPROVER\", \"PAYMENT_VIEW_LIST_MANAGERIAL_AS_AUTHORIZER\", \"PAYMENT_VIEW_LIST_MANAGERIAL\", \"PAYMENT_VIEW_LIST_MANAGERIAL_RELEASED\", \"PDU_VIEW_LIST_AND_DETAILS\", \"PDU_TEMPLATE_CREATE\", \"PDU_TEMPLATE_DOWNLOAD\", \"PDU_UPLOAD\", \"GEO_VIEW_LIST\", \"PM_PROGRAMME_CYCLE_VIEW_LIST\", \"PM_PROGRAMME_CYCLE_VIEW_DETAILS\", \"PM_PROGRAMME_CYCLE_CREATE\", \"PM_PROGRAMME_CYCLE_UPDATE\", \"PM_PROGRAMME_CYCLE_DELETE\", \"PM_UPLOAD_SUPPORTING_DOCUMENT\", \"PM_DOWNLOAD_SUPPORTING_DOCUMENT\", \"PM_DELETE_SUPPORTING_DOCUMENT\"]" } }, { diff --git a/src/hct_mis_api/apps/account/migrations/0003_migration.py b/src/hct_mis_api/apps/account/migrations/0003_migration.py new file mode 100644 index 0000000000..399ab87a08 --- /dev/null +++ b/src/hct_mis_api/apps/account/migrations/0003_migration.py @@ -0,0 +1,19 @@ +# Generated by Django 3.2.25 on 2024-12-20 08:50 + +from django.db import migrations, models +import hct_mis_api.apps.account.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('account', '0002_migration'), + ] + + operations = [ + migrations.AlterField( + model_name='role', + name='permissions', + field=hct_mis_api.apps.account.fields.ChoiceArrayField(base_field=models.CharField(choices=[('RDI_VIEW_LIST', 'RDI VIEW LIST'), ('RDI_VIEW_DETAILS', 'RDI VIEW DETAILS'), ('RDI_IMPORT_DATA', 'RDI IMPORT DATA'), ('RDI_RERUN_DEDUPE', 'RDI RERUN DEDUPE'), ('RDI_MERGE_IMPORT', 'RDI MERGE IMPORT'), ('RDI_REFUSE_IMPORT', 'RDI REFUSE IMPORT'), ('POPULATION_VIEW_HOUSEHOLDS_LIST', 'POPULATION VIEW HOUSEHOLDS LIST'), ('POPULATION_VIEW_HOUSEHOLDS_DETAILS', 'POPULATION VIEW HOUSEHOLDS DETAILS'), ('POPULATION_VIEW_INDIVIDUALS_LIST', 'POPULATION VIEW INDIVIDUALS LIST'), ('POPULATION_VIEW_INDIVIDUALS_DETAILS', 'POPULATION VIEW INDIVIDUALS DETAILS'), ('POPULATION_VIEW_INDIVIDUAL_DELIVERY_MECHANISMS_SECTION', 'POPULATION VIEW INDIVIDUAL DELIVERY MECHANISMS SECTION'), ('PROGRAMME_VIEW_LIST_AND_DETAILS', 'PROGRAMME VIEW LIST AND DETAILS'), ('PROGRAMME_MANAGEMENT_VIEW', 'PROGRAMME MANAGEMENT VIEW'), ('PROGRAMME_VIEW_PAYMENT_RECORD_DETAILS', 'PROGRAMME VIEW PAYMENT RECORD DETAILS'), ('PROGRAMME_CREATE', 'PROGRAMME CREATE'), ('PROGRAMME_UPDATE', 'PROGRAMME UPDATE'), ('PROGRAMME_REMOVE', 'PROGRAMME REMOVE'), ('PROGRAMME_ACTIVATE', 'PROGRAMME ACTIVATE'), ('PROGRAMME_FINISH', 'PROGRAMME FINISH'), ('PROGRAMME_DUPLICATE', 'PROGRAMME DUPLICATE'), ('TARGETING_VIEW_LIST', 'TARGETING VIEW LIST'), ('TARGETING_VIEW_DETAILS', 'TARGETING VIEW DETAILS'), ('TARGETING_CREATE', 'TARGETING CREATE'), ('TARGETING_UPDATE', 'TARGETING UPDATE'), ('TARGETING_DUPLICATE', 'TARGETING DUPLICATE'), ('TARGETING_REMOVE', 'TARGETING REMOVE'), ('TARGETING_LOCK', 'TARGETING LOCK'), ('TARGETING_UNLOCK', 'TARGETING UNLOCK'), ('TARGETING_SEND', 'TARGETING SEND'), ('PAYMENT_VIEW_LIST_MANAGERIAL', 'PAYMENT VIEW LIST MANAGERIAL'), ('PAYMENT_VIEW_LIST_MANAGERIAL_RELEASED', 'PAYMENT VIEW LIST MANAGERIAL RELEASED'), ('PAYMENT_VERIFICATION_VIEW_LIST', 'PAYMENT VERIFICATION VIEW LIST'), ('PAYMENT_VERIFICATION_VIEW_DETAILS', 'PAYMENT VERIFICATION VIEW DETAILS'), ('PAYMENT_VERIFICATION_CREATE', 'PAYMENT VERIFICATION CREATE'), ('PAYMENT_VERIFICATION_UPDATE', 'PAYMENT VERIFICATION UPDATE'), ('PAYMENT_VERIFICATION_ACTIVATE', 'PAYMENT VERIFICATION ACTIVATE'), ('PAYMENT_VERIFICATION_DISCARD', 'PAYMENT VERIFICATION DISCARD'), ('PAYMENT_VERIFICATION_FINISH', 'PAYMENT VERIFICATION FINISH'), ('PAYMENT_VERIFICATION_EXPORT', 'PAYMENT VERIFICATION EXPORT'), ('PAYMENT_VERIFICATION_IMPORT', 'PAYMENT VERIFICATION IMPORT'), ('PAYMENT_VERIFICATION_VERIFY', 'PAYMENT VERIFICATION VERIFY'), ('PAYMENT_VERIFICATION_VIEW_PAYMENT_RECORD_DETAILS', 'PAYMENT VERIFICATION VIEW PAYMENT RECORD DETAILS'), ('PAYMENT_VERIFICATION_DELETE', 'PAYMENT VERIFICATION DELETE'), ('PAYMENT_VERIFICATION_INVALID', 'PAYMENT VERIFICATION INVALID'), ('PAYMENT_VERIFICATION_MARK_AS_FAILED', 'PAYMENT VERIFICATION MARK AS FAILED'), ('PM_VIEW_LIST', 'PM VIEW LIST'), ('PM_CREATE', 'PM CREATE'), ('PM_VIEW_DETAILS', 'PM VIEW DETAILS'), ('PM_IMPORT_XLSX_WITH_ENTITLEMENTS', 'PM IMPORT XLSX WITH ENTITLEMENTS'), ('PM_APPLY_RULE_ENGINE_FORMULA_WITH_ENTITLEMENTS', 'PM APPLY RULE ENGINE FORMULA WITH ENTITLEMENTS'), ('PM_SPLIT', 'PM SPLIT'), ('PM_LOCK_AND_UNLOCK', 'PM LOCK AND UNLOCK'), ('PM_LOCK_AND_UNLOCK_FSP', 'PM LOCK AND UNLOCK FSP'), ('PM_SEND_FOR_APPROVAL', 'PM SEND FOR APPROVAL'), ('PM_EXCLUDE_BENEFICIARIES_FROM_FOLLOW_UP_PP', 'PM EXCLUDE BENEFICIARIES FROM FOLLOW UP PP'), ('PM_ACCEPTANCE_PROCESS_APPROVE', 'PM ACCEPTANCE PROCESS APPROVE'), ('PM_ACCEPTANCE_PROCESS_AUTHORIZE', 'PM ACCEPTANCE PROCESS AUTHORIZE'), ('PM_ACCEPTANCE_PROCESS_FINANCIAL_REVIEW', 'PM ACCEPTANCE PROCESS FINANCIAL REVIEW'), ('PM_IMPORT_XLSX_WITH_RECONCILIATION', 'PM IMPORT XLSX WITH RECONCILIATION'), ('PM_EXPORT_XLSX_FOR_FSP', 'PM EXPORT XLSX FOR FSP'), ('PM_DOWNLOAD_XLSX_FOR_FSP', 'PM DOWNLOAD XLSX FOR FSP'), ('PM_MARK_PAYMENT_AS_FAILED', 'PM MARK PAYMENT AS FAILED'), ('PM_EXPORT_PDF_SUMMARY', 'PM EXPORT PDF SUMMARY'), ('PM_SEND_TO_PAYMENT_GATEWAY', 'PM SEND TO PAYMENT GATEWAY'), ('PM_VIEW_FSP_AUTH_CODE', 'PM VIEW FSP AUTH CODE'), ('PM_DOWNLOAD_MTCN', 'PM DOWNLOAD MTCN'), ('PM_DOWNLOAD_SUPPORTING_DOCUMENT', 'PM DOWNLOAD SUPPORTING DOCUMENT'), ('PM_UPLOAD_SUPPORTING_DOCUMENT', 'PM UPLOAD SUPPORTING DOCUMENT'), ('PM_DELETE_SUPPORTING_DOCUMENT', 'PM DELETE SUPPORTING DOCUMENT'), ('PM_ADMIN_FINANCIAL_SERVICE_PROVIDER_UPDATE', 'PM ADMIN FINANCIAL SERVICE PROVIDER UPDATE'), ('PM_PROGRAMME_CYCLE_VIEW_LIST', 'PM PROGRAMME CYCLE VIEW LIST'), ('PM_PROGRAMME_CYCLE_VIEW_DETAILS', 'PM PROGRAMME CYCLE VIEW DETAILS'), ('PM_PROGRAMME_CYCLE_CREATE', 'PM PROGRAMME CYCLE CREATE'), ('PM_PROGRAMME_CYCLE_UPDATE', 'PM PROGRAMME CYCLE UPDATE'), ('PM_PROGRAMME_CYCLE_DELETE', 'PM PROGRAMME CYCLE DELETE'), ('USER_MANAGEMENT_VIEW_LIST', 'USER MANAGEMENT VIEW LIST'), ('DASHBOARD_VIEW_COUNTRY', 'DASHBOARD VIEW COUNTRY'), ('DASHBOARD_EXPORT', 'DASHBOARD EXPORT'), ('GRIEVANCES_VIEW_LIST_EXCLUDING_SENSITIVE', 'GRIEVANCES VIEW LIST EXCLUDING SENSITIVE'), ('GRIEVANCES_VIEW_LIST_EXCLUDING_SENSITIVE_AS_CREATOR', 'GRIEVANCES VIEW LIST EXCLUDING SENSITIVE AS CREATOR'), ('GRIEVANCES_VIEW_LIST_EXCLUDING_SENSITIVE_AS_OWNER', 'GRIEVANCES VIEW LIST EXCLUDING SENSITIVE AS OWNER'), ('GRIEVANCES_VIEW_LIST_SENSITIVE', 'GRIEVANCES VIEW LIST SENSITIVE'), ('GRIEVANCES_VIEW_LIST_SENSITIVE_AS_CREATOR', 'GRIEVANCES VIEW LIST SENSITIVE AS CREATOR'), ('GRIEVANCES_VIEW_LIST_SENSITIVE_AS_OWNER', 'GRIEVANCES VIEW LIST SENSITIVE AS OWNER'), ('GRIEVANCES_VIEW_DETAILS_EXCLUDING_SENSITIVE', 'GRIEVANCES VIEW DETAILS EXCLUDING SENSITIVE'), ('GRIEVANCES_VIEW_DETAILS_EXCLUDING_SENSITIVE_AS_CREATOR', 'GRIEVANCES VIEW DETAILS EXCLUDING SENSITIVE AS CREATOR'), ('GRIEVANCES_VIEW_DETAILS_EXCLUDING_SENSITIVE_AS_OWNER', 'GRIEVANCES VIEW DETAILS EXCLUDING SENSITIVE AS OWNER'), ('GRIEVANCES_VIEW_DETAILS_SENSITIVE', 'GRIEVANCES VIEW DETAILS SENSITIVE'), ('GRIEVANCES_VIEW_DETAILS_SENSITIVE_AS_CREATOR', 'GRIEVANCES VIEW DETAILS SENSITIVE AS CREATOR'), ('GRIEVANCES_VIEW_DETAILS_SENSITIVE_AS_OWNER', 'GRIEVANCES VIEW DETAILS SENSITIVE AS OWNER'), ('GRIEVANCES_VIEW_HOUSEHOLD_DETAILS', 'GRIEVANCES VIEW HOUSEHOLD DETAILS'), ('GRIEVANCES_VIEW_HOUSEHOLD_DETAILS_AS_CREATOR', 'GRIEVANCES VIEW HOUSEHOLD DETAILS AS CREATOR'), ('GRIEVANCES_VIEW_HOUSEHOLD_DETAILS_AS_OWNER', 'GRIEVANCES VIEW HOUSEHOLD DETAILS AS OWNER'), ('GRIEVANCES_VIEW_INDIVIDUALS_DETAILS', 'GRIEVANCES VIEW INDIVIDUALS DETAILS'), ('GRIEVANCES_VIEW_INDIVIDUALS_DETAILS_AS_CREATOR', 'GRIEVANCES VIEW INDIVIDUALS DETAILS AS CREATOR'), ('GRIEVANCES_VIEW_INDIVIDUALS_DETAILS_AS_OWNER', 'GRIEVANCES VIEW INDIVIDUALS DETAILS AS OWNER'), ('GRIEVANCES_CREATE', 'GRIEVANCES CREATE'), ('GRIEVANCES_UPDATE', 'GRIEVANCES UPDATE'), ('GRIEVANCES_UPDATE_AS_CREATOR', 'GRIEVANCES UPDATE AS CREATOR'), ('GRIEVANCES_UPDATE_AS_OWNER', 'GRIEVANCES UPDATE AS OWNER'), ('GRIEVANCES_UPDATE_REQUESTED_DATA_CHANGE', 'GRIEVANCES UPDATE REQUESTED DATA CHANGE'), ('GRIEVANCES_UPDATE_REQUESTED_DATA_CHANGE_AS_CREATOR', 'GRIEVANCES UPDATE REQUESTED DATA CHANGE AS CREATOR'), ('GRIEVANCES_UPDATE_REQUESTED_DATA_CHANGE_AS_OWNER', 'GRIEVANCES UPDATE REQUESTED DATA CHANGE AS OWNER'), ('GRIEVANCES_ADD_NOTE', 'GRIEVANCES ADD NOTE'), ('GRIEVANCES_ADD_NOTE_AS_CREATOR', 'GRIEVANCES ADD NOTE AS CREATOR'), ('GRIEVANCES_ADD_NOTE_AS_OWNER', 'GRIEVANCES ADD NOTE AS OWNER'), ('GRIEVANCES_SET_IN_PROGRESS', 'GRIEVANCES SET IN PROGRESS'), ('GRIEVANCES_SET_IN_PROGRESS_AS_CREATOR', 'GRIEVANCES SET IN PROGRESS AS CREATOR'), ('GRIEVANCES_SET_IN_PROGRESS_AS_OWNER', 'GRIEVANCES SET IN PROGRESS AS OWNER'), ('GRIEVANCES_SET_ON_HOLD', 'GRIEVANCES SET ON HOLD'), ('GRIEVANCES_SET_ON_HOLD_AS_CREATOR', 'GRIEVANCES SET ON HOLD AS CREATOR'), ('GRIEVANCES_SET_ON_HOLD_AS_OWNER', 'GRIEVANCES SET ON HOLD AS OWNER'), ('GRIEVANCES_SEND_FOR_APPROVAL', 'GRIEVANCES SEND FOR APPROVAL'), ('GRIEVANCES_SEND_FOR_APPROVAL_AS_CREATOR', 'GRIEVANCES SEND FOR APPROVAL AS CREATOR'), ('GRIEVANCES_SEND_FOR_APPROVAL_AS_OWNER', 'GRIEVANCES SEND FOR APPROVAL AS OWNER'), ('GRIEVANCES_SEND_BACK', 'GRIEVANCES SEND BACK'), ('GRIEVANCES_SEND_BACK_AS_CREATOR', 'GRIEVANCES SEND BACK AS CREATOR'), ('GRIEVANCES_SEND_BACK_AS_OWNER', 'GRIEVANCES SEND BACK AS OWNER'), ('GRIEVANCES_APPROVE_DATA_CHANGE', 'GRIEVANCES APPROVE DATA CHANGE'), ('GRIEVANCES_APPROVE_DATA_CHANGE_AS_CREATOR', 'GRIEVANCES APPROVE DATA CHANGE AS CREATOR'), ('GRIEVANCES_APPROVE_DATA_CHANGE_AS_OWNER', 'GRIEVANCES APPROVE DATA CHANGE AS OWNER'), ('GRIEVANCES_CLOSE_TICKET_EXCLUDING_FEEDBACK', 'GRIEVANCES CLOSE TICKET EXCLUDING FEEDBACK'), ('GRIEVANCES_CLOSE_TICKET_EXCLUDING_FEEDBACK_AS_CREATOR', 'GRIEVANCES CLOSE TICKET EXCLUDING FEEDBACK AS CREATOR'), ('GRIEVANCES_CLOSE_TICKET_EXCLUDING_FEEDBACK_AS_OWNER', 'GRIEVANCES CLOSE TICKET EXCLUDING FEEDBACK AS OWNER'), ('GRIEVANCES_CLOSE_TICKET_FEEDBACK', 'GRIEVANCES CLOSE TICKET FEEDBACK'), ('GRIEVANCES_CLOSE_TICKET_FEEDBACK_AS_CREATOR', 'GRIEVANCES CLOSE TICKET FEEDBACK AS CREATOR'), ('GRIEVANCES_CLOSE_TICKET_FEEDBACK_AS_OWNER', 'GRIEVANCES CLOSE TICKET FEEDBACK AS OWNER'), ('GRIEVANCES_APPROVE_FLAG_AND_DEDUPE', 'GRIEVANCES APPROVE FLAG AND DEDUPE'), ('GRIEVANCES_APPROVE_FLAG_AND_DEDUPE_AS_CREATOR', 'GRIEVANCES APPROVE FLAG AND DEDUPE AS CREATOR'), ('GRIEVANCES_APPROVE_FLAG_AND_DEDUPE_AS_OWNER', 'GRIEVANCES APPROVE FLAG AND DEDUPE AS OWNER'), ('GRIEVANCES_APPROVE_PAYMENT_VERIFICATION', 'GRIEVANCES APPROVE PAYMENT VERIFICATION'), ('GRIEVANCES_APPROVE_PAYMENT_VERIFICATION_AS_CREATOR', 'GRIEVANCES APPROVE PAYMENT VERIFICATION AS CREATOR'), ('GRIEVANCES_APPROVE_PAYMENT_VERIFICATION_AS_OWNER', 'GRIEVANCES APPROVE PAYMENT VERIFICATION AS OWNER'), ('GRIEVANCE_ASSIGN', 'GRIEVANCE ASSIGN'), ('GRIEVANCE_DOCUMENTS_UPLOAD', 'GRIEVANCE DOCUMENTS UPLOAD'), ('GRIEVANCES_CROSS_AREA_FILTER', 'GRIEVANCES CROSS AREA FILTER'), ('GRIEVANCES_VIEW_BIOMETRIC_RESULTS', 'GRIEVANCES VIEW BIOMETRIC RESULTS'), ('GRIEVANCES_FEEDBACK_VIEW_CREATE', 'GRIEVANCES FEEDBACK VIEW CREATE'), ('GRIEVANCES_FEEDBACK_VIEW_LIST', 'GRIEVANCES FEEDBACK VIEW LIST'), ('GRIEVANCES_FEEDBACK_VIEW_DETAILS', 'GRIEVANCES FEEDBACK VIEW DETAILS'), ('GRIEVANCES_FEEDBACK_VIEW_UPDATE', 'GRIEVANCES FEEDBACK VIEW UPDATE'), ('GRIEVANCES_FEEDBACK_MESSAGE_VIEW_CREATE', 'GRIEVANCES FEEDBACK MESSAGE VIEW CREATE'), ('REPORTING_EXPORT', 'REPORTING EXPORT'), ('PDU_VIEW_LIST_AND_DETAILS', 'PDU VIEW LIST AND DETAILS'), ('PDU_TEMPLATE_CREATE', 'PDU TEMPLATE CREATE'), ('PDU_TEMPLATE_DOWNLOAD', 'PDU TEMPLATE DOWNLOAD'), ('PDU_UPLOAD', 'PDU UPLOAD'), ('ALL_VIEW_PII_DATA_ON_LISTS', 'ALL VIEW PII DATA ON LISTS'), ('ACTIVITY_LOG_VIEW', 'ACTIVITY LOG VIEW'), ('ACTIVITY_LOG_DOWNLOAD', 'ACTIVITY LOG DOWNLOAD'), ('UPLOAD_STORAGE_FILE', 'UPLOAD STORAGE FILE'), ('DOWNLOAD_STORAGE_FILE', 'DOWNLOAD STORAGE FILE'), ('ACCOUNTABILITY_COMMUNICATION_MESSAGE_VIEW_LIST', 'ACCOUNTABILITY COMMUNICATION MESSAGE VIEW LIST'), ('ACCOUNTABILITY_COMMUNICATION_MESSAGE_VIEW_DETAILS', 'ACCOUNTABILITY COMMUNICATION MESSAGE VIEW DETAILS'), ('ACCOUNTABILITY_COMMUNICATION_MESSAGE_VIEW_CREATE', 'ACCOUNTABILITY COMMUNICATION MESSAGE VIEW CREATE'), ('ACCOUNTABILITY_COMMUNICATION_MESSAGE_VIEW_DETAILS_AS_CREATOR', 'ACCOUNTABILITY COMMUNICATION MESSAGE VIEW DETAILS AS CREATOR'), ('ACCOUNTABILITY_SURVEY_VIEW_CREATE', 'ACCOUNTABILITY SURVEY VIEW CREATE'), ('ACCOUNTABILITY_SURVEY_VIEW_LIST', 'ACCOUNTABILITY SURVEY VIEW LIST'), ('ACCOUNTABILITY_SURVEY_VIEW_DETAILS', 'ACCOUNTABILITY SURVEY VIEW DETAILS'), ('GEO_VIEW_LIST', 'GEO VIEW LIST'), ('CAN_ADD_BUSINESS_AREA_TO_PARTNER', 'CAN ADD BUSINESS AREA TO PARTNER')], max_length=255), blank=True, null=True, size=None), + ), + ] diff --git a/src/hct_mis_api/apps/account/permissions.py b/src/hct_mis_api/apps/account/permissions.py index 3a5b197a25..ffee299ae4 100644 --- a/src/hct_mis_api/apps/account/permissions.py +++ b/src/hct_mis_api/apps/account/permissions.py @@ -109,6 +109,7 @@ def _generate_next_value_( # type: ignore # https://github.com/python/mypy/issu PM_EXPORT_PDF_SUMMARY = auto() PM_SEND_TO_PAYMENT_GATEWAY = auto() PM_VIEW_FSP_AUTH_CODE = auto() + PM_DOWNLOAD_MTCN = auto() # PaymentPlanSupportingDocument PM_DOWNLOAD_SUPPORTING_DOCUMENT = auto() diff --git a/src/hct_mis_api/apps/payment/celery_tasks.py b/src/hct_mis_api/apps/payment/celery_tasks.py index 2eac44d251..ae3c422875 100644 --- a/src/hct_mis_api/apps/payment/celery_tasks.py +++ b/src/hct_mis_api/apps/payment/celery_tasks.py @@ -140,7 +140,9 @@ def create_payment_plan_payment_list_xlsx(self: Any, payment_plan_id: str, user_ @app.task(bind=True, default_retry_delay=60, max_retries=3) @log_start_and_end @sentry_tags -def create_payment_plan_payment_list_xlsx_per_fsp(self: Any, payment_plan_id: str, user_id: str) -> None: +def create_payment_plan_payment_list_xlsx_per_fsp( + self: Any, payment_plan_id: str, user_id: str, fsp_xlsx_template_id: Optional[str] = None +) -> None: try: from hct_mis_api.apps.payment.models import PaymentPlan from hct_mis_api.apps.payment.xlsx.xlsx_payment_plan_export_per_fsp_service import ( @@ -153,7 +155,8 @@ def create_payment_plan_payment_list_xlsx_per_fsp(self: Any, payment_plan_id: st try: with transaction.atomic(): # regenerate always xlsx - service = XlsxPaymentPlanExportPerFspService(payment_plan) + service = XlsxPaymentPlanExportPerFspService(payment_plan, fsp_xlsx_template_id) + # TODO: check it service.export_per_fsp(user) payment_plan.background_action_status_none() payment_plan.save() diff --git a/src/hct_mis_api/apps/payment/models/payment.py b/src/hct_mis_api/apps/payment/models/payment.py index 78bf5fac2e..22ed717a38 100644 --- a/src/hct_mis_api/apps/payment/models/payment.py +++ b/src/hct_mis_api/apps/payment/models/payment.py @@ -355,6 +355,21 @@ class Meta: def __str__(self) -> str: return self.unicef_id or "" + @property + def can_create_xlsx_with_fsp_auth_code(self) -> bool: + """ + export MTCN file + xlsx file with password + """ + has_fsp_with_api = self.eligible_payments.filter( + financial_service_provider__communication_channel=FinancialServiceProvider.COMMUNICATION_CHANNEL_API + ).exists() + not_send_to_fsp_exists = self.eligible_payments.exclude(status=Payment.STATUS_SENT_TO_FSP).exists() + print("==>> can_create_xlsx_with_fsp_auth_code ", has_fsp_with_api and not not_send_to_fsp_exists) + # TODO: just for test + return has_fsp_with_api + # return has_fsp_with_api and not not_send_to_fsp_exists + @property def bank_reconciliation_success(self) -> int: return self.payment_items.filter(status__in=Payment.ALLOW_CREATE_VERIFICATION).count() @@ -847,17 +862,6 @@ def last_approval_process_date(self) -> Optional[datetime]: def last_approval_process_by(self) -> Optional[str]: return self._get_last_approval_process_data().modified_by - @property - def can_create_xlsx_with_fsp_auth_code(self) -> bool: - has_api_fsp = self.delivery_mechanisms.filter( - financial_service_provider__communication_channel=FinancialServiceProvider.COMMUNICATION_CHANNEL_API - ).exists() - not_send_to_fsp = self.eligible_payments.exclude(status=Payment.STATUS_SENT_TO_FSP).exists() - print("==>> ", has_api_fsp and not not_send_to_fsp) - # TODO: just for test - return has_api_fsp - # return has_api_fsp and not not_send_to_fsp - @property def can_send_to_payment_gateway(self) -> bool: status_accepted = self.status == PaymentPlan.Status.ACCEPTED diff --git a/src/hct_mis_api/apps/payment/mutations.py b/src/hct_mis_api/apps/payment/mutations.py index 17dcb03ecf..6742d25c2f 100644 --- a/src/hct_mis_api/apps/payment/mutations.py +++ b/src/hct_mis_api/apps/payment/mutations.py @@ -791,12 +791,14 @@ class ExportXLSXPaymentPlanPaymentListMutation(PermissionMutation): class Arguments: payment_plan_id = graphene.ID(required=True) + fsp_xlsx_template_id = graphene.ID() @classmethod - def export_action(cls, payment_plan: PaymentPlan, user_id: "UUID") -> PaymentPlan: + def export_action( + cls, payment_plan: PaymentPlan, user_id: "UUID", fsp_xlsx_template_id: Optional[str] = None + ) -> PaymentPlan: if payment_plan.status not in [PaymentPlan.Status.LOCKED]: msg = "You can only export Payment List for LOCKED Payment Plan" - logger.error(msg) raise GraphQLError(msg) return PaymentPlanService(payment_plan=payment_plan).export_xlsx(user_id=user_id) @@ -805,13 +807,16 @@ def export_action(cls, payment_plan: PaymentPlan, user_id: "UUID") -> PaymentPla @is_authenticated @transaction.atomic def mutate( - cls, root: Any, info: Any, payment_plan_id: str, **kwargs: Any + cls, root: Any, info: Any, payment_plan_id: str, fsp_xlsx_template_id: Optional[str], **kwargs: Any ) -> "ExportXLSXPaymentPlanPaymentListMutation": payment_plan = get_object_or_404(PaymentPlan, id=decode_id_string(payment_plan_id)) + fsp_xlsx_template_id_str: Optional[str] = decode_id_string(fsp_xlsx_template_id) cls.has_permission(info, Permissions.PM_VIEW_LIST, payment_plan.business_area) + if fsp_xlsx_template_id: + cls.has_permission(info, Permissions.PM_DOWNLOAD_MTCN, payment_plan.business_area) old_payment_plan = copy_model_object(payment_plan) - payment_plan = cls.export_action(payment_plan=payment_plan, user_id=info.context.user.pk) + payment_plan = cls.export_action(payment_plan, info.context.user.pk, fsp_xlsx_template_id_str) log_create( mapping=PaymentPlan.ACTIVITY_LOG_MAPPING, @@ -827,18 +832,23 @@ def mutate( class ExportXLSXPaymentPlanPaymentListPerFSPMutation(ExportXLSXPaymentPlanPaymentListMutation): @classmethod - def export_action(cls, payment_plan: PaymentPlan, user_id: "UUID") -> PaymentPlan: + def export_action( + cls, payment_plan: PaymentPlan, user_id: "UUID", fsp_xlsx_template_id: Optional[str] = None + ) -> PaymentPlan: if payment_plan.status not in [PaymentPlan.Status.ACCEPTED, PaymentPlan.Status.FINISHED]: - msg = "You can only export Payment List Per FSP for ACCEPTED or FINISHED Payment Plan" - logger.error(msg) + msg = "Payment List Per FSP export is only available for ACCEPTED or FINISHED Payment Plans." raise GraphQLError(msg) if not payment_plan.eligible_payments: - msg = "Export is not impossible because Payment list is empty" - logger.error(msg) + msg = "Export failed: The Payment List is empty." raise GraphQLError(msg) - return PaymentPlanService(payment_plan=payment_plan).export_xlsx_per_fsp(user_id=user_id) + if not payment_plan.can_create_xlsx_with_fsp_auth_code: + # TODO: ask Marek what is the status of PP if payments are in 'STATUS_SENT_TO_FSP' + msg = "Export failed: All Payments must have the status 'Sent to FSP' and FSP communication channel set to API." + raise GraphQLError(msg) + + return PaymentPlanService(payment_plan=payment_plan).export_xlsx_per_fsp(user_id, fsp_xlsx_template_id) class ChooseDeliveryMechanismsForPaymentPlanMutation(PermissionMutation): @@ -1245,6 +1255,7 @@ def mutate( class Mutations(graphene.ObjectType): + # PaymentVerification create_payment_verification_plan = CreateVerificationPlanMutation.Field() edit_payment_verification_plan = EditPaymentVerificationMutation.Field() @@ -1256,11 +1267,15 @@ class Mutations(graphene.ObjectType): invalid_payment_verification_plan = InvalidPaymentVerificationPlan.Field() delete_payment_verification_plan = DeletePaymentVerificationPlan.Field() update_payment_verification_status_and_received_amount = UpdatePaymentVerificationStatusAndReceivedAmount.Field() - mark_payment_as_failed = MarkPaymentAsFailedMutation.Field() - revert_mark_payment_as_failed = RevertMarkPaymentAsFailedMutation.Field() update_payment_verification_received_and_received_amount = ( UpdatePaymentVerificationReceivedAndReceivedAmount.Field() ) + + # Payment + mark_payment_as_failed = MarkPaymentAsFailedMutation.Field() + revert_mark_payment_as_failed = RevertMarkPaymentAsFailedMutation.Field() + + # Payment Plan action_payment_plan_mutation = ActionPaymentPlanMutation.Field() create_payment_plan = CreatePaymentPlanMutation.Field() create_follow_up_payment_plan = CreateFollowUpPaymentPlanMutation.Field() @@ -1270,10 +1285,12 @@ class Mutations(graphene.ObjectType): assign_fsp_to_delivery_mechanism = AssignFspToDeliveryMechanismMutation.Field() split_payment_plan = SplitPaymentPlanMutation.Field() + # Payment Plan XLSX export_xlsx_payment_plan_payment_list = ExportXLSXPaymentPlanPaymentListMutation.Field() export_xlsx_payment_plan_payment_list_per_fsp = ExportXLSXPaymentPlanPaymentListPerFSPMutation.Field() import_xlsx_payment_plan_payment_list = ImportXLSXPaymentPlanPaymentListMutation.Field() import_xlsx_payment_plan_payment_list_per_fsp = ImportXLSXPaymentPlanPaymentListPerFSPMutation.Field() + set_steficon_rule_on_payment_plan_payment_list = SetSteficonRuleOnPaymentPlanPaymentListMutation.Field() exclude_households = ExcludeHouseholdsMutation.Field() diff --git a/src/hct_mis_api/apps/payment/services/payment_plan_services.py b/src/hct_mis_api/apps/payment/services/payment_plan_services.py index 8cb36a605f..a1843ccfb6 100644 --- a/src/hct_mis_api/apps/payment/services/payment_plan_services.py +++ b/src/hct_mis_api/apps/payment/services/payment_plan_services.py @@ -520,11 +520,13 @@ def export_xlsx(self, user_id: "UUID") -> PaymentPlan: self.payment_plan.refresh_from_db(fields=["background_action_status"]) return self.payment_plan - def export_xlsx_per_fsp(self, user_id: "UUID") -> PaymentPlan: + def export_xlsx_per_fsp(self, user_id: "UUID", fsp_xlsx_template_id: Optional[str]) -> PaymentPlan: self.payment_plan.background_action_status_xlsx_exporting() self.payment_plan.save() - create_payment_plan_payment_list_xlsx_per_fsp.delay(self.payment_plan.pk, user_id) + create_payment_plan_payment_list_xlsx_per_fsp.delay( + str(self.payment_plan.pk), str(user_id), fsp_xlsx_template_id + ) self.payment_plan.refresh_from_db(fields=["background_action_status"]) return self.payment_plan diff --git a/src/hct_mis_api/apps/payment/xlsx/xlsx_payment_plan_export_per_fsp_service.py b/src/hct_mis_api/apps/payment/xlsx/xlsx_payment_plan_export_per_fsp_service.py index bba83cb8f5..499ebed8a8 100644 --- a/src/hct_mis_api/apps/payment/xlsx/xlsx_payment_plan_export_per_fsp_service.py +++ b/src/hct_mis_api/apps/payment/xlsx/xlsx_payment_plan_export_per_fsp_service.py @@ -1,7 +1,7 @@ import logging import zipfile from tempfile import NamedTemporaryFile -from typing import TYPE_CHECKING, List +from typing import TYPE_CHECKING, List, Optional from django.contrib.admin.options import get_content_type_for_model from django.core.files import File @@ -58,16 +58,18 @@ def generate_token_and_order_numbers(payment: Payment) -> Payment: class XlsxPaymentPlanExportPerFspService(XlsxExportBaseService): - def __init__(self, payment_plan: PaymentPlan): + def __init__(self, payment_plan: PaymentPlan, fsp_xlsx_template_id: Optional[str] = None): self.batch_size = 5000 self.payment_plan = payment_plan - self.is_social_worker_program = self.payment_plan.program.is_social_worker_program + self.is_social_worker_program = self.payment_plan.is_social_worker_program # TODO: in future will be per BA or program flag? self.payment_generate_token_and_order_numbers = True flexible_attributes = FlexibleAttribute.objects.all() self.flexible_attributes = { flexible_attribute.name: flexible_attribute for flexible_attribute in flexible_attributes } + self.export_fsp_auth_code = bool(fsp_xlsx_template_id) + self.fsp_xlsx_template_id = fsp_xlsx_template_id def open_workbook(self, title: str) -> tuple[Workbook, Worksheet]: wb = openpyxl.Workbook() @@ -206,12 +208,13 @@ def create_workbooks_per_fsp( self, delivery_mechanism_per_payment_plan_list: QuerySet["DeliveryMechanismPerPaymentPlan"], zip_file: zipfile.ZipFile, + fsp_xlsx_template: Optional["FinancialServiceProviderXlsxTemplate"] = None, ) -> None: for delivery_mechanism_per_payment_plan in delivery_mechanism_per_payment_plan_list: fsp: FinancialServiceProvider = delivery_mechanism_per_payment_plan.financial_service_provider delivery_mechanism: DeliveryMechanism = delivery_mechanism_per_payment_plan.delivery_mechanism wb, ws_fsp = self.open_workbook(fsp.name) - fsp_xlsx_template = self.get_template(fsp, delivery_mechanism) + fsp_xlsx_template = fsp_xlsx_template or self.get_template(fsp, delivery_mechanism) payment_ids = list( self.payment_plan.eligible_payments.filter(financial_service_provider=fsp) .order_by("unicef_id")