File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -913,6 +913,18 @@ def get_instances_from_dataframe(
913913 # to the list, provided that it has at least one Livelihood Activity where there is some income,
914914 # expediture or consumption. This excludes empty activities that only contain attributes for,
915915 # for example, 'type_of_milk_sold_or_other_uses'.
916+ # For MeatProduction, if animals_slaughtered is null/0 or carcass_weight is null/0, then a
917+ # percentage_kcals of 0 is not meaningful (it results from the BSS formula evaluating to 0
918+ # because there are no animals or no carcass weight). Set it to None so that the activity is
919+ # treated as empty and not saved to the database.
920+ if livelihood_strategy and livelihood_strategy ["strategy_type" ] == "MeatProduction" :
921+ for livelihood_activity in livelihood_activities_for_strategy :
922+ if (
923+ not livelihood_activity .get ("animals_slaughtered" )
924+ or not livelihood_activity .get ("carcass_weight" )
925+ ) and livelihood_activity .get ("percentage_kcals" ) == 0 :
926+ livelihood_activity ["percentage_kcals" ] = None
927+
916928 # Also ignore any livelihood activities that don't have a Wealth Category component to the Wealth Group
917929 # natural key. These are from blank columns between Wealth Category groups in the BSS, which sometimes
918930 # contain data where values or formulae have been copied across all the columns in a row.
You can’t perform that action at this time.
0 commit comments