Skip to content

[FIX] - issues in export and copy related to cash and inkind #556

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/rh/views/activity_plans.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,17 @@ def copy_activity_plan(request, pk):
new_activity_plan = get_object_or_404(ActivityPlan, pk=pk)

target_locations = TargetLocation.objects.filter(activity_plan=new_activity_plan)
cash_details = CashInKindDetail.objects.get(activity_plan=new_activity_plan)

new_activity_plan.id = None
new_activity_plan.state = "draft"

new_activity_plan.save()

cash_details.id = None
cash_details.activity_plan = new_activity_plan
cash_details.save()

for location in target_locations:
disagg_locations = DisaggregationLocation.objects.filter(
target_location=location,
Expand Down
27 changes: 18 additions & 9 deletions src/rh/views/exports.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ def single_project_export(request, pk, format):
{"header": "Unit Type", "type": "string", "width": 20},
{"header": "Units", "type": "string", "width": 20},
{"header": "No_of_Transfer", "type": "string", "width": 20},
{"header": "Ration Size", "type": "string", "width": 20},
{"header": "Ration Type", "type": "string", "width": 20},
{"header": "Grant Type", "type": "string", "width": 20},
{"header": "Transfer Category", "type": "string", "width": 20},
{"header": "Currency", "type": "string", "width": 20},
Expand Down Expand Up @@ -319,6 +321,7 @@ def single_project_export(request, pk, format):
plans = project.activityplan_set.all()
for plan in plans:
locations = plan.targetlocation_set.all()
cash_details = plan.cashinkinddetail_set.all().first()
for location in locations:
# Create a dictionary to hold disaggregation data
disaggregation_data = {}
Expand Down Expand Up @@ -365,15 +368,21 @@ def single_project_export(request, pk, format):
plan.beneficiary.name if plan.beneficiary else None,
plan.hrp_beneficiary.name if plan.hrp_beneficiary else None,
plan.description if plan.description else None,
plan.package_type.name if plan.package_type else None,
plan.unit_type.name if plan.unit_type else None,
plan.units if plan.units else None,
plan.no_of_transfers if plan.no_of_transfers else None,
plan.grant_type.name if plan.grant_type else None,
plan.transfer_category.name if plan.transfer_category else None,
plan.currency.name if plan.currency else None,
plan.transfer_mechanism_type.name if plan.transfer_mechanism_type else None,
plan.implement_modility_type.name if plan.implement_modility_type else None,
cash_details.package_type.name if cash_details and cash_details.package_type else None,
cash_details.unit_type.name if cash_details and cash_details.unit_type else None,
cash_details.units if cash_details and cash_details.units else None,
cash_details.no_of_transfers if cash_details and cash_details.no_of_transfers else None,
cash_details.ration_size.name if cash_details and cash_details.ration_size else None,
cash_details.ration_type.name if cash_details and cash_details.ration_type else None,
cash_details.grant_type.name if cash_details and cash_details.grant_type else None,
cash_details.transfer_category.name if cash_details and cash_details.transfer_category else None,
cash_details.currency.name if cash_details and cash_details.currency else None,
cash_details.transfer_mechanism_type.name
if cash_details and cash_details.transfer_mechanism_type
else None,
cash_details.implement_modality_type.name
if cash_details and cash_details.implement_modality_type
else None,
location.country.code if location.province else None,
location.country.name if location.province else None,
location.province.code if location.province else None,
Expand Down
Loading