|
|
@@ -18,7 +18,7 @@ public function getActive(): Collection
|
|
|
{
|
|
|
$today = now()->toDateString();
|
|
|
|
|
|
- return FranchiseeContract::with(['unit', 'inhabitantClassification'])
|
|
|
+ return FranchiseeContract::with(['unit', 'municipalitySize'])
|
|
|
->whereNotNull('start_date')
|
|
|
->whereNotNull('end_date')
|
|
|
->where('start_date', '<=', $today)
|
|
|
@@ -34,7 +34,7 @@ public function findById(int $id): ?FranchiseeContract
|
|
|
|
|
|
public function getByUnitId(int $unitId): Collection
|
|
|
{
|
|
|
- return FranchiseeContract::with('inhabitantClassification')
|
|
|
+ return FranchiseeContract::with(['municipalitySize'])
|
|
|
->where('unit_id', $unitId)
|
|
|
->orderBy('created_at', 'desc')
|
|
|
->orderBy('id', 'desc')
|
|
|
@@ -62,7 +62,7 @@ public function update(int $id, array $data): ?FranchiseeContract
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- $taxFields = ['inhabitant_classification_id', 'tbr_fixed_value', 'tbr_fixed_value_percentage', 'marketing_fund_percentage', 'maintance_tax_percentage'];
|
|
|
+ $taxFields = ['municipality_size_id', 'tbr_fixed_value', 'tbr_fixed_value_percentage', 'marketing_fund_percentage', 'maintance_tax_percentage'];
|
|
|
$hasTaxChange = collect($taxFields)->contains(fn($field) => array_key_exists($field, $data));
|
|
|
|
|
|
if ($hasTaxChange) {
|
|
|
@@ -70,12 +70,12 @@ public function update(int $id, array $data): ?FranchiseeContract
|
|
|
|
|
|
if (!$hasHistory) {
|
|
|
FranchiseeContractTaxHistory::create([
|
|
|
- 'franchisee_contract_id' => $model->id,
|
|
|
- 'inhabitant_classification_id' => $model->inhabitant_classification_id,
|
|
|
- 'tbr_fixed_value' => $model->tbr_fixed_value,
|
|
|
- 'tbr_fixed_value_percentage' => $model->tbr_fixed_value_percentage,
|
|
|
- 'marketing_fund_percentage' => $model->marketing_fund_percentage,
|
|
|
- 'maintance_tax_percentage' => $model->maintance_tax_percentage,
|
|
|
+ 'franchisee_contract_id' => $model->id,
|
|
|
+ 'municipality_size_id' => $model->municipality_size_id,
|
|
|
+ 'tbr_fixed_value' => $model->tbr_fixed_value,
|
|
|
+ 'tbr_fixed_value_percentage' => $model->tbr_fixed_value_percentage,
|
|
|
+ 'marketing_fund_percentage' => $model->marketing_fund_percentage,
|
|
|
+ 'maintance_tax_percentage' => $model->maintance_tax_percentage,
|
|
|
]);
|
|
|
}
|
|
|
}
|
|
|
@@ -84,12 +84,12 @@ public function update(int $id, array $data): ?FranchiseeContract
|
|
|
|
|
|
if ($hasTaxChange) {
|
|
|
FranchiseeContractTaxHistory::create([
|
|
|
- 'franchisee_contract_id' => $model->id,
|
|
|
- 'inhabitant_classification_id' => $model->inhabitant_classification_id,
|
|
|
- 'tbr_fixed_value' => $model->tbr_fixed_value,
|
|
|
- 'tbr_fixed_value_percentage' => $model->tbr_fixed_value_percentage,
|
|
|
- 'marketing_fund_percentage' => $model->marketing_fund_percentage,
|
|
|
- 'maintance_tax_percentage' => $model->maintance_tax_percentage,
|
|
|
+ 'franchisee_contract_id' => $model->id,
|
|
|
+ 'municipality_size_id' => $model->municipality_size_id,
|
|
|
+ 'tbr_fixed_value' => $model->tbr_fixed_value,
|
|
|
+ 'tbr_fixed_value_percentage' => $model->tbr_fixed_value_percentage,
|
|
|
+ 'marketing_fund_percentage' => $model->marketing_fund_percentage,
|
|
|
+ 'maintance_tax_percentage' => $model->maintance_tax_percentage,
|
|
|
]);
|
|
|
}
|
|
|
|
|
|
@@ -98,7 +98,7 @@ public function update(int $id, array $data): ?FranchiseeContract
|
|
|
|
|
|
public function getTaxHistory(int $id): Collection
|
|
|
{
|
|
|
- return FranchiseeContractTaxHistory::with('inhabitantClassification')
|
|
|
+ return FranchiseeContractTaxHistory::with(['municipalitySize'])
|
|
|
->where('franchisee_contract_id', $id)
|
|
|
->orderBy('created_at', 'desc')
|
|
|
->orderBy('id', 'desc')
|