Skip to content

Commit 1634ed8

Browse files
authored
Merge pull request #556 from iMMAP/iMMap/fix/export_and_copy_plans
[FIX] - issues in export and copy related to cash and inkind
2 parents eaed8d2 + 07ce779 commit 1634ed8

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

src/rh/views/activity_plans.py

+5
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,17 @@ def copy_activity_plan(request, pk):
184184
new_activity_plan = get_object_or_404(ActivityPlan, pk=pk)
185185

186186
target_locations = TargetLocation.objects.filter(activity_plan=new_activity_plan)
187+
cash_details = CashInKindDetail.objects.get(activity_plan=new_activity_plan)
187188

188189
new_activity_plan.id = None
189190
new_activity_plan.state = "draft"
190191

191192
new_activity_plan.save()
192193

194+
cash_details.id = None
195+
cash_details.activity_plan = new_activity_plan
196+
cash_details.save()
197+
193198
for location in target_locations:
194199
disagg_locations = DisaggregationLocation.objects.filter(
195200
target_location=location,

src/rh/views/exports.py

+18-9
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ def single_project_export(request, pk, format):
256256
{"header": "Unit Type", "type": "string", "width": 20},
257257
{"header": "Units", "type": "string", "width": 20},
258258
{"header": "No_of_Transfer", "type": "string", "width": 20},
259+
{"header": "Ration Size", "type": "string", "width": 20},
260+
{"header": "Ration Type", "type": "string", "width": 20},
259261
{"header": "Grant Type", "type": "string", "width": 20},
260262
{"header": "Transfer Category", "type": "string", "width": 20},
261263
{"header": "Currency", "type": "string", "width": 20},
@@ -319,6 +321,7 @@ def single_project_export(request, pk, format):
319321
plans = project.activityplan_set.all()
320322
for plan in plans:
321323
locations = plan.targetlocation_set.all()
324+
cash_details = plan.cashinkinddetail_set.all().first()
322325
for location in locations:
323326
# Create a dictionary to hold disaggregation data
324327
disaggregation_data = {}
@@ -365,15 +368,21 @@ def single_project_export(request, pk, format):
365368
plan.beneficiary.name if plan.beneficiary else None,
366369
plan.hrp_beneficiary.name if plan.hrp_beneficiary else None,
367370
plan.description if plan.description else None,
368-
plan.package_type.name if plan.package_type else None,
369-
plan.unit_type.name if plan.unit_type else None,
370-
plan.units if plan.units else None,
371-
plan.no_of_transfers if plan.no_of_transfers else None,
372-
plan.grant_type.name if plan.grant_type else None,
373-
plan.transfer_category.name if plan.transfer_category else None,
374-
plan.currency.name if plan.currency else None,
375-
plan.transfer_mechanism_type.name if plan.transfer_mechanism_type else None,
376-
plan.implement_modility_type.name if plan.implement_modility_type else None,
371+
cash_details.package_type.name if cash_details and cash_details.package_type else None,
372+
cash_details.unit_type.name if cash_details and cash_details.unit_type else None,
373+
cash_details.units if cash_details and cash_details.units else None,
374+
cash_details.no_of_transfers if cash_details and cash_details.no_of_transfers else None,
375+
cash_details.ration_size.name if cash_details and cash_details.ration_size else None,
376+
cash_details.ration_type.name if cash_details and cash_details.ration_type else None,
377+
cash_details.grant_type.name if cash_details and cash_details.grant_type else None,
378+
cash_details.transfer_category.name if cash_details and cash_details.transfer_category else None,
379+
cash_details.currency.name if cash_details and cash_details.currency else None,
380+
cash_details.transfer_mechanism_type.name
381+
if cash_details and cash_details.transfer_mechanism_type
382+
else None,
383+
cash_details.implement_modality_type.name
384+
if cash_details and cash_details.implement_modality_type
385+
else None,
377386
location.country.code if location.province else None,
378387
location.country.name if location.province else None,
379388
location.province.code if location.province else None,

0 commit comments

Comments
 (0)