diff --git a/app/Models/Traits/HasWorkdays.php b/app/Models/Traits/HasWorkdays.php index 6d88e4685..4bbe6204d 100644 --- a/app/Models/Traits/HasWorkdays.php +++ b/app/Models/Traits/HasWorkdays.php @@ -15,7 +15,7 @@ trait HasWorkdays { public static function bootHasWorkdays() { - collect([static::WORKDAY_COLLECTIONS['paid'], static::WORKDAY_COLLECTIONS['volunteer']]) + collect([static::WORKDAY_COLLECTIONS['paid'], static::WORKDAY_COLLECTIONS['volunteer'], static::WORKDAY_COLLECTIONS['finance']]) ->flatten() ->each(function ($collection) { self::resolveRelationUsing( @@ -72,7 +72,7 @@ public function setOtherWorkdaysDescriptionAttribute(?string $value): void protected function sumTotalWorkdaysAmounts(array $collections): int { - // Assume that the types are balanced, and just return the value from `gender` + // Gender is considered the canonical total value for all current types of workdays, so just pull and sum gender. return WorkdayDemographic::whereIn( 'workday_id', $this->workdays()->visible()->collections($collections)->select('id') diff --git a/app/Models/V2/Projects/ProjectReport.php b/app/Models/V2/Projects/ProjectReport.php index f3b2172df..762b370ec 100644 --- a/app/Models/V2/Projects/ProjectReport.php +++ b/app/Models/V2/Projects/ProjectReport.php @@ -206,6 +206,10 @@ class ProjectReport extends Model implements MediaModel, AuditableContract, Repo Workday::COLLECTION_PROJECT_PAID_OTHER, Workday::COLLECTION_PROJECT_VOLUNTEER_OTHER, ], + 'finance' => [ + Workday::COLLECTION_PROJECT_DIRECT, + Workday::COLLECTION_PROJECT_CONVERGENCE, + ], ]; public function registerMediaConversions(Media $media = null): void diff --git a/app/Models/V2/Sites/SiteReport.php b/app/Models/V2/Sites/SiteReport.php index acf4951ca..2902a3aca 100644 --- a/app/Models/V2/Sites/SiteReport.php +++ b/app/Models/V2/Sites/SiteReport.php @@ -170,6 +170,10 @@ class SiteReport extends Model implements MediaModel, AuditableContract, ReportM Workday::COLLECTION_SITE_PAID_OTHER, Workday::COLLECTION_SITE_VOLUNTEER_OTHER, ], + 'finance' => [ + Workday::COLLECTION_PROJECT_DIRECT, + Workday::COLLECTION_PROJECT_CONVERGENCE, + ], ]; public function registerMediaConversions(Media $media = null): void diff --git a/app/Models/V2/Workdays/Workday.php b/app/Models/V2/Workdays/Workday.php index e33d8de37..da36f0fc8 100644 --- a/app/Models/V2/Workdays/Workday.php +++ b/app/Models/V2/Workdays/Workday.php @@ -53,6 +53,8 @@ class Workday extends Model implements HandlesLinkedFieldSync public const COLLECTION_PROJECT_VOLUNTEER_NURSERY_OPERATIONS = 'volunteer-nursery-operations'; public const COLLECTION_PROJECT_VOLUNTEER_PROJECT_MANAGEMENT = 'volunteer-project-management'; public const COLLECTION_PROJECT_VOLUNTEER_OTHER = 'volunteer-other-activities'; + public const COLLECTION_PROJECT_DIRECT = 'direct'; + public const COLLECTION_PROJECT_CONVERGENCE = 'convergence'; public const PROJECT_COLLECTION = [ self::COLLECTION_PROJECT_PAID_NURSERY_OPERATIONS => 'Paid Nursery Operations', diff --git a/app/Models/V2/Workdays/WorkdayDemographic.php b/app/Models/V2/Workdays/WorkdayDemographic.php index 7acd120c5..77f6322bb 100644 --- a/app/Models/V2/Workdays/WorkdayDemographic.php +++ b/app/Models/V2/Workdays/WorkdayDemographic.php @@ -25,6 +25,7 @@ class WorkdayDemographic extends Model public const GENDER = 'gender'; public const AGE = 'age'; public const ETHNICITY = 'ethnicity'; + public const CASTE = 'caste'; public function workday(): BelongsTo { @@ -60,4 +61,9 @@ public function scopeIsEthnicity(Builder $query, string $ethnicity, string $name { return $query->where(['type' => self::ETHNICITY, 'subtype' => $ethnicity, 'name' => $name]); } + + public function scopeCaste(Builder $query): Builder + { + return $query->where('type', self::CASTE); + } } diff --git a/config/wri/linked-fields.php b/config/wri/linked-fields.php index 34691b18f..4a8bc66e1 100644 --- a/config/wri/linked-fields.php +++ b/config/wri/linked-fields.php @@ -512,6 +512,20 @@ 'collection' => 'volunteer-other-activities', 'option_list_key' => 'workdays-ethnicity', ], + 'pro-rep-direct-workdays' => [ + 'property' => 'workdaysDirect', + 'label' => 'Direct Workday', + 'resource' => 'App\Http\Resources\V2\Workdays\WorkdayResource', + 'input_type' => 'workdays', + 'collection' => 'direct', + ], + 'pro-rep-convergence-workdays' => [ + 'property' => 'workdaysConvergence', + 'label' => 'Convergence Workday', + 'resource' => 'App\Http\Resources\V2\Workdays\WorkdayResource', + 'input_type' => 'workdays', + 'collection' => 'convergence', + ], ], 'file-collections' => [ 'pro-rep-col-media' => ['property' => 'media', 'label' => 'Media', 'input_type' => 'file', 'multichoice' => true], @@ -745,6 +759,20 @@ 'collection' => 'volunteer-other-activities', 'option_list_key' => 'workdays-ethnicity', ], + 'site-rep-direct-workdays' => [ + 'property' => 'workdaysDirect', + 'label' => 'Direct Workday', + 'resource' => 'App\Http\Resources\V2\Workdays\WorkdayResource', + 'input_type' => 'workdays', + 'collection' => 'direct', + ], + 'site-rep-convergence-workdays' => [ + 'property' => 'workdaysConvergence', + 'label' => 'Convergence Workday', + 'resource' => 'App\Http\Resources\V2\Workdays\WorkdayResource', + 'input_type' => 'workdays', + 'collection' => 'convergence', + ], ], ], 'nursery' => [