diff --git a/app/Console/Commands/OneOff/MigrateBeneficiariesToDemographics.php b/app/Console/Commands/OneOff/MigrateBeneficiariesToDemographics.php new file mode 100644 index 000000000..7236fb94b --- /dev/null +++ b/app/Console/Commands/OneOff/MigrateBeneficiariesToDemographics.php @@ -0,0 +1,198 @@ + [ + 'gender' => [ + 'male' => 'beneficiaries_men', + 'female' => 'beneficiaries_women', + 'non-binary' => 'beneficiaries_other', + ], + 'age' => [ + 'youth' => 'beneficiaries_youth', + 'non-youth' => 'beneficiaries_non_youth', + ], + 'farmer' => [ + 'smallholder' => 'beneficiaries_smallholder', + 'large-scale' => 'beneficiaries_large_scale', + 'marginalized' => 'beneficiaries_scstobc_farmers', + ], + 'caste' => [ + 'marginalized' => 'beneficiaries_scstobc', + ], + 'total' => ['beneficiaries', 'total_community_partners'], + ], + ]; + + protected const TRAINING_MAPPING = [ + 'training' => [ + 'gender' => [ + 'male' => 'beneficiaries_training_men', + 'female' => 'beneficiaries_training_women', + 'non-binary' => 'beneficiaries_training_other', + ], + 'age' => [ + 'youth' => 'beneficiaries_training_youth', + 'non-youth' => 'beneficiaries_training_non_youth', + ], + 'total' => 'beneficiaries_skills_knowledge_increase', + ], + ]; + + protected const MIGRATION_MAPPING = [ + 'all-beneficiaries' => self::ALL_MAPPING, + 'training-beneficiaries' => self::TRAINING_MAPPING, + ]; + + /** + * Execute the console command. + */ + public function handle() + { + $this->info('Moving project report beneficiaries data to Demographics...'); + $this->withProgressBar(ProjectReport::count(), function ($progressBar) { + ProjectReport::chunkById(100, function ($projectReports) use ($progressBar) { + foreach ($projectReports as $projectReport) { + $this->convertJobs($projectReport); + $progressBar->advance(); + } + }); + }); + + $this->info("\n\nCompleted moving project report beneficiaries data to Demographics."); + } + + private function convertJobs(ProjectReport $projectReport): void + { + foreach (self::MIGRATION_MAPPING as $demographicType => $mapping) { + foreach ($mapping as $collection => $types) { + /** @var Demographic $demographic */ + $demographic = null; + foreach ($types as $type => $subtypes) { + if ($type == 'total') { + $fields = is_array($subtypes) ? $subtypes : [$subtypes]; + // Make sure gender / age demographics are balanced and reach at least to the "_total" field + // for this type of job from the original report. Pad gender and age demographics with an + // "unknown" if needed. + $genderTotal = $demographic?->entries()->gender()->sum('amount') ?? 0; + $ageTotal = $demographic?->entries()->age()->sum('amount') ?? 0; + + $totals = [$genderTotal, $ageTotal]; + foreach ($fields as $field) { + $totals[] = $projectReport[$field]; + } + $targetTotal = max($totals); + + if ($demographic == null && $targetTotal > 0) { + $demographic = $projectReport->demographics()->create([ + 'type' => $demographicType, + 'collection' => $collection, + 'hidden' => false, + ]); + } + + if ($genderTotal < $targetTotal) { + $demographic->entries()->create([ + 'type' => 'gender', + 'subtype' => 'unknown', + 'amount' => $targetTotal - $genderTotal, + ]); + } + if ($ageTotal < $targetTotal) { + $demographic->entries()->create([ + 'type' => 'age', + 'subtype' => 'unknown', + 'amount' => $targetTotal - $ageTotal, + ]); + } + } else { + // If none of the fields for this type exist, skip + $fields = collect(array_values($subtypes)); + if ($fields->first(fn ($field) => $projectReport[$field] > 0) == null) { + continue; + } + + if ($demographic == null) { + $demographic = $projectReport->demographics()->create([ + 'type' => $demographicType, + 'collection' => $collection, + 'hidden' => false, + ]); + } + foreach ($subtypes as $subtype => $field) { + $value = $projectReport[$field]; + if ($value > 0) { + $demographic->entries()->create([ + 'type' => $type, + 'subtype' => $subtype, + 'amount' => $value, + ]); + } + } + } + } + } + } + + if ($projectReport->trainingBeneficiariesTotal > $projectReport->allBeneficiariesTotal) { + // in this case, the training data had a greater gender total than the "all" gender total, so we want + // to pad "all" so that they're equal. + $padValue = $projectReport->trainingBeneficiariesTotal - $projectReport->allBeneficiariesTotal; + + $all = $projectReport->allBeneficiaries()->first(); + if ($all == null) { + $all = $projectReport->demographics()->create([ + 'type' => Demographic::ALL_BENEFICIARIES_TYPE, + 'collection' => 'all', + 'hidden' => false, + ]); + } + + // We can assume that gender / age have already been balanced and just add the pad value to both + $gender = $all->entries()->where(['type' => 'gender', 'subtype' => 'unknown'])->first(); + if ($gender == null) { + $all->entries()->create([ + 'type' => 'gender', + 'subtype' => 'unknown', + 'amount' => $padValue, + ]); + } else { + $gender->amount += $padValue; + $gender->save(); + } + + $age = $all->entries()->where(['type' => 'age', 'subtype' => 'unknown'])->first(); + if ($age == null) { + $all->entries()->create([ + 'type' => 'age', + 'subtype' => 'unknown', + 'amount' => $padValue, + ]); + } else { + $age->amount += $padValue; + $age->save(); + } + } + } +} diff --git a/app/Exports/V2/BaseExportFormSubmission.php b/app/Exports/V2/BaseExportFormSubmission.php index 823190a10..644e8b6df 100644 --- a/app/Exports/V2/BaseExportFormSubmission.php +++ b/app/Exports/V2/BaseExportFormSubmission.php @@ -72,13 +72,14 @@ protected function getAnswer(array $field, array $answers, ?string $frameworkKey case 'restorationPartners': case 'jobs': case 'volunteers': + case 'beneficiaries': $list = []; $demographic = $answer->first(); if ($demographic == null) { return ''; } - $types = ['gender' => [], 'age' => [], 'ethnicity' => [], 'caste' => []]; + $types = ['gender' => [], 'age' => [], 'ethnicity' => [], 'farmer' => [], 'caste' => []]; foreach ($demographic->entries as $entry) { $value = match ($entry->type) { 'ethnicity' => [$entry->amount, $entry->subtype, $entry->name], @@ -88,6 +89,9 @@ protected function getAnswer(array $field, array $answers, ?string $frameworkKey } $list[] = 'gender:(' . implode(')(', $types['gender']) . ')'; $list[] = 'age:(' . implode(')(', $types['age']) . ')'; + if ($demographic->type == 'beneficiaries' && $demographic->collection == 'all') { + $list[] = 'farmer:(' . implode(')(', $types['farmer']) . ')'; + } if ($frameworkKey == 'hbf') { $list[] = 'caste:(' . implode(')(', $types['caste']) . ')'; } elseif ($field['input_type'] == 'workdays' || $field['input_type'] == 'restorationPartners') { diff --git a/app/Http/Resources/V2/Demographics/DemographicResource.php b/app/Http/Resources/V2/Demographics/DemographicResource.php index 8383a6def..6ed2d8b2a 100644 --- a/app/Http/Resources/V2/Demographics/DemographicResource.php +++ b/app/Http/Resources/V2/Demographics/DemographicResource.php @@ -11,7 +11,6 @@ public function toArray($request) return [ 'uuid' => $this->uuid, 'collection' => $this->collection, - 'readable_collection' => $this->readable_collection, 'demographics' => empty($this->entries) ? [] : DemographicEntryResource::collection($this->entries), ]; } diff --git a/app/Http/Resources/V2/ProjectReports/ProjectReportResource.php b/app/Http/Resources/V2/ProjectReports/ProjectReportResource.php index b8c42e2cf..f3a0823e6 100644 --- a/app/Http/Resources/V2/ProjectReports/ProjectReportResource.php +++ b/app/Http/Resources/V2/ProjectReports/ProjectReportResource.php @@ -52,17 +52,8 @@ public function toArray($request) 'planted_trees' => $this->planted_trees, 'new_jobs_description' => $this->new_jobs_description, 'volunteers_work_description' => $this->volunteers_work_description, - 'beneficiaries' => $this->beneficiaries, 'beneficiaries_description' => $this->beneficiaries_description, - 'beneficiaries_women' => $this->beneficiaries_women, - 'beneficiaries_men' => $this->beneficiaries_men, - 'beneficiaries_non_youth' => $this->beneficiaries_non_youth, - 'beneficiaries_youth' => $this->beneficiaries_youth, - 'beneficiaries_smallholder' => $this->beneficiaries_smallholder, - 'beneficiaries_large_scale' => $this->beneficiaries_large_scale, - 'beneficiaries_income_increase' => $this->beneficiaries_income_increase, 'beneficiaries_income_increase_description' => $this->beneficiaries_income_increase_description, - 'beneficiaries_skills_knowledge_increase' => $this->beneficiaries_skills_knowledge_increase, 'beneficiaries_skills_knowledge_increase_description' => $this->beneficiaries_skills_knowledge_increase_description, 'organisation' => new OrganisationLiteResource($this->organisation), 'project' => new ProjectLiteResource($this->project), @@ -93,22 +84,13 @@ public function toArray($request) 'convergence_schemes' => $this->convergence_schemes, 'convergence_amount' => $this->convergence_amount, 'community_partners_assets_description' => $this->community_partners_assets_description, - 'beneficiaries_scstobc_farmers' => $this->beneficiaries_scstobc_farmers, - 'beneficiaries_scstobc' => $this->beneficiaries_scstobc, 'people_knowledge_skills_increased' => $this->people_knowledge_skills_increased, 'indirect_beneficiaries' => $this->indirect_beneficiaries, 'indirect_beneficiaries_description' => $this->indirect_beneficiaries_description, 'workdays_direct_total' => $this->workdays_direct_total, 'workdays_convergence_total' => $this->workdays_convergence_total, 'non_tree_total' => $this->non_tree_total, - 'total_community_partners' => $this->total_community_partners, 'business_milestones' => $this->business_milestones, - 'beneficiaries_other' => $this->beneficiaries_other, - 'beneficiaries_training_women' => $this->beneficiaries_training_women, - 'beneficiaries_training_men' => $this->beneficiaries_training_men, - 'beneficiaries_training_other' => $this->beneficiaries_training_other, - 'beneficiaries_training_youth' => $this->beneficiaries_training_youth, - 'beneficiaries_training_non_youth' => $this->beneficiaries_training_non_youth, ]; return $this->appendFilesToResource($data); diff --git a/app/Models/Traits/HasDemographics.php b/app/Models/Traits/HasDemographics.php index cdbf52cb6..eef2560ec 100644 --- a/app/Models/Traits/HasDemographics.php +++ b/app/Models/Traits/HasDemographics.php @@ -18,7 +18,9 @@ trait HasDemographics 'indirectRestorationPartners' => ['type' => Demographic::RESTORATION_PARTNER_TYPE, 'collections' => 'indirect'], 'jobsFullTimeTotal' => ['type' => Demographic::JOBS_TYPE, 'collections' => 'full-time'], 'jobsPartTimeTotal' => ['type' => Demographic::JOBS_TYPE, 'collections' => 'part-time'], - 'volunteersTotal' => ['type' => Demographic::VOLUNTEERS_TYPE, 'collections' => 'volunteer'], + 'volunteersTotal' => ['type' => Demographic::VOLUNTEERS_TYPE], + 'allBeneficiariesTotal' => ['type' => Demographic::ALL_BENEFICIARIES_TYPE], + 'trainingBeneficiariesTotal' => ['type' => Demographic::TRAINING_BENEFICIARIES_TYPE], ]; public static function bootHasDemographics() @@ -47,19 +49,22 @@ public static function bootHasDemographics() $collectionSets['full-time'], $collectionSets['part-time'], ])->flatten(), - Demographic::VOLUNTEERS_TYPE => collect([ - $collectionSets['volunteer'], - ])->flatten(), + // These three define a single collection each, and simply rely on the type level relation above + Demographic::VOLUNTEERS_TYPE, + Demographic::ALL_BENEFICIARIES_TYPE, + Demographic::TRAINING_BENEFICIARIES_TYPE => null, default => throw new InternalErrorException("Unrecognized demographic type: $demographicType"), }; - $collections->each(function ($collection) use ($attributePrefix) { - self::resolveRelationUsing( - $attributePrefix . Str::studly($collection), - function ($entity) use ($attributePrefix, $collection) { - return $entity->$attributePrefix()->collection($collection); - } - ); - }); + if (! empty($collections)) { + $collections->each(function ($collection) use ($attributePrefix) { + self::resolveRelationUsing( + $attributePrefix . Str::studly($collection), + function ($entity) use ($attributePrefix, $collection) { + return $entity->$attributePrefix()->collection($collection); + } + ); + }); + } }); } @@ -79,7 +84,9 @@ public function getAttribute($key) if (array_key_exists($keyNormalized, self::DEMOGRAPHIC_ATTRIBUTES)) { $definition = self::DEMOGRAPHIC_ATTRIBUTES[$keyNormalized]; $type = $definition['type']; - $collections = self::DEMOGRAPHIC_COLLECTIONS[$type][$definition['collections']]; + $collections = is_string(self::DEMOGRAPHIC_COLLECTIONS[$type]) + ? [self::DEMOGRAPHIC_COLLECTIONS[$type]] + : self::DEMOGRAPHIC_COLLECTIONS[$type][$definition['collections']]; return $this->sumTotalDemographicAmounts(Str::camel($type), $collections); } diff --git a/app/Models/Traits/UsesLinkedFields.php b/app/Models/Traits/UsesLinkedFields.php index 0cb84bd80..d91a9ae04 100644 --- a/app/Models/Traits/UsesLinkedFields.php +++ b/app/Models/Traits/UsesLinkedFields.php @@ -266,6 +266,7 @@ private function syncRelation(string $property, string $inputType, $data, bool $ 'restorationPartners', 'jobs', 'volunteers', + 'beneficiaries', 'stratas', 'invasive', 'seedings', diff --git a/app/Models/V2/Demographics/Demographic.php b/app/Models/V2/Demographics/Demographic.php index 59d75f5d8..8f527ed83 100644 --- a/app/Models/V2/Demographics/Demographic.php +++ b/app/Models/V2/Demographics/Demographic.php @@ -5,8 +5,6 @@ use App\Models\Interfaces\HandlesLinkedFieldSync; use App\Models\Traits\HasUuid; use App\Models\V2\EntityModel; -use App\Models\V2\Projects\ProjectReport; -use App\Models\V2\Sites\SiteReport; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; @@ -35,8 +33,17 @@ class Demographic extends Model implements HandlesLinkedFieldSync public const RESTORATION_PARTNER_TYPE = 'restoration-partners'; public const JOBS_TYPE = 'jobs'; public const VOLUNTEERS_TYPE = 'volunteers'; - - public const VALID_TYPES = [self::WORKDAY_TYPE, self::RESTORATION_PARTNER_TYPE, self::JOBS_TYPE, self::VOLUNTEERS_TYPE]; + public const ALL_BENEFICIARIES_TYPE = 'all-beneficiaries'; + public const TRAINING_BENEFICIARIES_TYPE = 'training-beneficiaries'; + + public const VALID_TYPES = [ + self::WORKDAY_TYPE, + self::RESTORATION_PARTNER_TYPE, + self::JOBS_TYPE, + self::VOLUNTEERS_TYPE, + self::ALL_BENEFICIARIES_TYPE, + self::TRAINING_BENEFICIARIES_TYPE, + ]; // In TM-1681 we moved several "name" values to "subtype". This check helps make sure that both in-flight // work at the time of release, and updates from update requests afterward honor that change. @@ -176,35 +183,4 @@ public function scopeVisible($query): Builder { return $query->where('hidden', false); } - - public function getReadableCollectionAttribute(): ?string - { - if (empty($this->collection)) { - return 'Unknown'; - } - - $collections = match ($this->type) { - self::RESTORATION_PARTNER_TYPE => match ($this->demographical_type) { - ProjectReport::class => DemographicCollections::RESTORATION_PARTNERS_PROJECT_COLLECTIONS, - default => null - }, - self::WORKDAY_TYPE => match ($this->demographical_type) { - ProjectReport::class => DemographicCollections::WORKDAYS_PROJECT_COLLECTIONS, - SiteReport::class => DemographicCollections::WORKDAYS_SITE_COLLECTIONS, - default => null - }, - self::JOBS_TYPE => match ($this->demographical_type) { - ProjectReport::class => DemographicCollections::JOBS_PROJECT_COLLECTIONS, - }, - self::VOLUNTEERS_TYPE => match ($this->demographical_type) { - ProjectReport::class => DemographicCollections::VOLUNTEERS_PROJECT_COLLECTIONS, - }, - default => null - }; - if (empty($collections)) { - return 'Unknown'; - } - - return data_get($collections, $this->collection, 'Unknown'); - } } diff --git a/app/Models/V2/Demographics/DemographicCollections.php b/app/Models/V2/Demographics/DemographicCollections.php index fd8dcdc49..1d9372428 100644 --- a/app/Models/V2/Demographics/DemographicCollections.php +++ b/app/Models/V2/Demographics/DemographicCollections.php @@ -4,6 +4,7 @@ class DemographicCollections { + // workdays public const PAID_NURSERY_OPERATIONS = 'paid-nursery-operations'; public const PAID_PROJECT_MANAGEMENT = 'paid-project-management'; public const PAID_OTHER = 'paid-other-activities'; @@ -21,30 +22,7 @@ class DemographicCollections public const VOLUNTEER_SITE_MAINTENANCE = 'volunteer-site-maintenance'; public const VOLUNTEER_SITE_MONITORING = 'volunteer-site-monitoring'; - public const WORKDAYS_PROJECT_COLLECTIONS = [ - self::PAID_NURSERY_OPERATIONS => 'Paid Nursery Operations', - self::PAID_PROJECT_MANAGEMENT => 'Paid Project Management', - self::PAID_OTHER => 'Paid Other Activities', - self::VOLUNTEER_NURSERY_OPERATIONS => 'Volunteer Nursery Operations', - self::VOLUNTEER_PROJECT_MANAGEMENT => 'Volunteer Project Management', - self::VOLUNTEER_OTHER => 'Volunteer Other Activities', - self::DIRECT => 'Direct Workdays', - self::CONVERGENCE => 'Convergence Workdays', - ]; - - public const WORKDAYS_SITE_COLLECTIONS = [ - self::PAID_SITE_ESTABLISHMENT => 'Paid Site Establishment', - self::PAID_PLANTING => 'Paid Planting', - self::PAID_SITE_MAINTENANCE => 'Paid Site Maintenance', - self::PAID_SITE_MONITORING => 'Paid Site Monitoring', - self::PAID_OTHER => 'Paid Other Activities', - self::VOLUNTEER_SITE_ESTABLISHMENT => 'Volunteer Site Establishment', - self::VOLUNTEER_PLANTING => 'Volunteer Planting', - self::VOLUNTEER_SITE_MAINTENANCE => 'Volunteer Site Maintenance', - self::VOLUNTEER_SITE_MONITORING => 'Volunteer Site Monitoring', - self::VOLUNTEER_OTHER => 'Volunteer Other Activities', - ]; - + // restoration-partners public const DIRECT_INCOME = 'direct-income'; public const INDIRECT_INCOME = 'indirect-income'; public const DIRECT_BENEFITS = 'direct-benefits'; @@ -66,40 +44,16 @@ class DemographicCollections public const DIRECT_OTHER = 'direct-other'; public const INDIRECT_OTHER = 'indirect-other'; - public const RESTORATION_PARTNERS_PROJECT_COLLECTIONS = [ - self::DIRECT_INCOME => 'Direct Income', - self::INDIRECT_INCOME => 'Indirect Income', - self::DIRECT_BENEFITS => 'Direct In-kind Benefits', - self::INDIRECT_BENEFITS => 'Indirect In-kind Benefits', - self::DIRECT_CONSERVATION_PAYMENTS => 'Direct Conservation Agreement Payments', - self::INDIRECT_CONSERVATION_PAYMENTS => 'Indirect Conservation Agreement Payments', - self::DIRECT_MARKET_ACCESS => 'Direct Increased Market Access', - self::INDIRECT_MARKET_ACCESS => 'Indirect Increased Market Access', - self::DIRECT_CAPACITY => 'Direct Increased Capacity', - self::INDIRECT_CAPACITY => 'Indirect Increased Capacity', - self::DIRECT_TRAINING => 'Direct Training', - self::INDIRECT_TRAINING => 'Indirect Training', - self::DIRECT_LAND_TITLE => 'Direct Newly Secured Land Title', - self::INDIRECT_LAND_TITLE => 'Indirect Newly Secured Land Title', - self::DIRECT_LIVELIHOODS => 'Direct Traditional Livelihoods or Customer Rights', - self::INDIRECT_LIVELIHOODS => 'Indirect Traditional Livelihoods or Customer Rights', - self::DIRECT_PRODUCTIVITY => 'Direct Increased Productivity', - self::INDIRECT_PRODUCTIVITY => 'Indirect Increased Productivity', - self::DIRECT_OTHER => 'Direct Other', - self::INDIRECT_OTHER => 'Indirect Other', - ]; - + // jobs public const FULL_TIME = 'full-time'; public const PART_TIME = 'part-time'; - public const JOBS_PROJECT_COLLECTIONS = [ - self::FULL_TIME => 'Full-time', - self::PART_TIME => 'Part-time', - ]; - + // volunteers public const VOLUNTEER = 'volunteer'; - public const VOLUNTEERS_PROJECT_COLLECTIONS = [ - self::VOLUNTEER => 'Volunteer', - ]; + // all-beneficiaries + public const ALL = 'all'; + + // training-beneficiaries + public const TRAINING = 'training'; } diff --git a/app/Models/V2/Projects/ProjectReport.php b/app/Models/V2/Projects/ProjectReport.php index 30894316f..ec7b0c358 100644 --- a/app/Models/V2/Projects/ProjectReport.php +++ b/app/Models/V2/Projects/ProjectReport.php @@ -270,11 +270,9 @@ class ProjectReport extends Model implements MediaModel, AuditableContract, Repo DemographicCollections::PART_TIME, ], ], - Demographic::VOLUNTEERS_TYPE => [ - 'volunteer' => [ - DemographicCollections::VOLUNTEER, - ], - ], + Demographic::VOLUNTEERS_TYPE => DemographicCollections::VOLUNTEER, + Demographic::ALL_BENEFICIARIES_TYPE => DemographicCollections::ALL, + Demographic::TRAINING_BENEFICIARIES_TYPE => DemographicCollections::TRAINING, ]; public function registerMediaConversions(Media $media = null): void diff --git a/config/wri/linked-fields.php b/config/wri/linked-fields.php index d654391eb..72b28e4eb 100644 --- a/config/wri/linked-fields.php +++ b/config/wri/linked-fields.php @@ -697,11 +697,25 @@ 'collection' => 'part-time' ], 'pro-rep-volunteers' => [ - 'property' => 'volunteersVolunteer', + 'property' => 'volunteers', 'label' => 'Volunteers', 'resource' => 'App\Http\Resources\V2\Demographics\DemographicResource', 'input_type' => 'volunteers', 'collection' => 'volunteer' + ], + 'pro-rep-beneficiaries-all' => [ + 'property' => 'allBeneficiaries', + 'label' => 'All Beneficiaries', + 'resource' => 'App\Http\Resources\V2\Demographics\DemographicResource', + 'input_type' => 'allBeneficiaries', + 'collection' => 'all' + ], + 'pro-rep-beneficiaries-training' => [ + 'property' => 'trainingBeneficiaries', + 'label' => 'Training Beneficiaries', + 'resource' => 'App\Http\Resources\V2\Demographics\DemographicResource', + 'input_type' => 'trainingBeneficiaries', + 'collection' => 'training' ] ], 'file-collections' => [ diff --git a/database/factories/V2/Demographics/DemographicFactory.php b/database/factories/V2/Demographics/DemographicFactory.php index 794bb06dd..6d9f559ae 100644 --- a/database/factories/V2/Demographics/DemographicFactory.php +++ b/database/factories/V2/Demographics/DemographicFactory.php @@ -3,7 +3,6 @@ namespace Database\Factories\V2\Demographics; use App\Models\V2\Demographics\Demographic; -use App\Models\V2\Demographics\DemographicCollections; use App\Models\V2\Projects\ProjectReport; use App\Models\V2\Sites\SiteReport; use Illuminate\Database\Eloquent\Factories\Factory; @@ -22,7 +21,7 @@ public function definition() 'demographical_type' => SiteReport::class, 'demographical_id' => SiteReport::factory()->create(), 'type' => Demographic::WORKDAY_TYPE, - 'collection' => $this->faker->randomElement(array_keys(DemographicCollections::WORKDAYS_SITE_COLLECTIONS)), + 'collection' => $this->faker->randomElement(collect(array_values(SiteReport::DEMOGRAPHIC_COLLECTIONS[Demographic::WORKDAY_TYPE]))->flatten()), ]; } @@ -33,7 +32,7 @@ public function projectReportWorkdays(): Factory 'demographical_type' => ProjectReport::class, 'demographical_id' => ProjectReport::factory()->create(), 'type' => Demographic::WORKDAY_TYPE, - 'collection' => $this->faker->randomElement(array_keys(DemographicCollections::WORKDAYS_PROJECT_COLLECTIONS)), + 'collection' => $this->faker->randomElement(collect(array_values(ProjectReport::DEMOGRAPHIC_COLLECTIONS[Demographic::WORKDAY_TYPE]))->flatten()), ]; }); } @@ -45,7 +44,7 @@ public function projectReportRestorationPartners(): Factory 'demographical_type' => ProjectReport::class, 'demographical_id' => ProjectReport::factory()->create(), 'type' => Demographic::RESTORATION_PARTNER_TYPE, - 'collection' => $this->faker->randomElement(array_keys(DemographicCollections::RESTORATION_PARTNERS_PROJECT_COLLECTIONS)), + 'collection' => $this->faker->randomElement(collect(array_values(ProjectReport::DEMOGRAPHIC_COLLECTIONS[Demographic::RESTORATION_PARTNER_TYPE]))->flatten()), ]; }); } diff --git a/openapi-src/V2/definitions/ProjectReportRead.yml b/openapi-src/V2/definitions/ProjectReportRead.yml index db70c203f..19ea90a0d 100644 --- a/openapi-src/V2/definitions/ProjectReportRead.yml +++ b/openapi-src/V2/definitions/ProjectReportRead.yml @@ -57,28 +57,10 @@ properties: type: integer volunteers_work_description: type: string - beneficiaries: - type: integer beneficiaries_description: type: string - beneficiaries_women: - type: integer - beneficiaries_men: - type: integer - beneficiaries_non_youth: - type: integer - beneficiaries_youth: - type: integer - beneficiaries_smallholder: - type: integer - beneficiaries_large_scale: - type: integer - beneficiaries_income_increase: - type: integer beneficiaries_income_increase_description: type: string - beneficiaries_skills_knowledge_increase: - type: integer beneficiaries_skills_knowledge_increase_description: type: string ethnic_indigenous_1: diff --git a/resources/docs/swagger-v2.yml b/resources/docs/swagger-v2.yml index 2b06cbf61..b0c678512 100644 --- a/resources/docs/swagger-v2.yml +++ b/resources/docs/swagger-v2.yml @@ -40229,28 +40229,10 @@ definitions: type: integer volunteers_work_description: type: string - beneficiaries: - type: integer beneficiaries_description: type: string - beneficiaries_women: - type: integer - beneficiaries_men: - type: integer - beneficiaries_non_youth: - type: integer - beneficiaries_youth: - type: integer - beneficiaries_smallholder: - type: integer - beneficiaries_large_scale: - type: integer - beneficiaries_income_increase: - type: integer beneficiaries_income_increase_description: type: string - beneficiaries_skills_knowledge_increase: - type: integer beneficiaries_skills_knowledge_increase_description: type: string ethnic_indigenous_1: