@@ -88,7 +88,7 @@ class TaxRateAdminController extends BackendController | |||
public function actionCreate() | |||
{ | |||
$model = $this-> getTaxRateModule()->instanciateTaxRate(); | |||
$model = $this->getTaxRateModule()->getBuilder()->instanciateTaxRate(); | |||
if ($model->load(\Yii::$app->request->post()) && $model->save()) { | |||
$this->setFlash('success', 'Taxe créée.'); | |||
@@ -116,19 +116,15 @@ class TaxRateAdminController extends BackendController | |||
public function actionDelete(int $id) | |||
{ | |||
$taxRateModule = $this-> getTaxRateModule(); | |||
$taxRate = $this->findModel($id); | |||
$taxRateModule->delete($taxRate); | |||
$taxRate->delete(); | |||
$this->setFlash('success', 'Taxe supprimé'); | |||
return $this->redirect(['tax-rate-admin/index']); | |||
} | |||
protected function findModel($id) | |||
{ | |||
$taxRateModule = $this-> getTaxRateModule(); | |||
if (($taxRate = $taxRateModule->findOneTaxRateById($id)) !== null) { | |||
if (($taxRate = $this->getTaxRateModule()->getRepository()->findOneTaxRateById($id)) !== null) { | |||
return $taxRate; | |||
} else { | |||
throw new NotFoundHttpException('The requested page does not exist.'); |
@@ -173,7 +173,7 @@ $documentPriceDecimals = (int) $producerModule->getConfig('option_document_price | |||
</tr> | |||
<?php | |||
$taxRateArray = $this-> getTaxRateModule()->findTaxRatesAsArray(); | |||
$taxRateArray = $this-> getTaxRateModule()->getRepository()->findTaxRatesAsArray(); | |||
foreach ($documentModule->getTotalVatArray($document, $typeAmount) as $idTaxRate => $totalVat): ?> | |||
<tr> | |||
<td class="align-right" colspan="4"> |
@@ -6,17 +6,11 @@ use common\components\ActiveRecordCommon; | |||
class TaxRate extends ActiveRecordCommon | |||
{ | |||
/** | |||
* @inheritdoc | |||
*/ | |||
public static function tableName() | |||
{ | |||
return 'tax_rate'; | |||
} | |||
/** | |||
* @inheritdoc | |||
*/ | |||
public function rules() | |||
{ | |||
return [ | |||
@@ -25,9 +19,6 @@ class TaxRate extends ActiveRecordCommon | |||
]; | |||
} | |||
/** | |||
* @inheritdoc | |||
*/ | |||
public function attributeLabels() | |||
{ | |||
return [ | |||
@@ -36,4 +27,33 @@ class TaxRate extends ActiveRecordCommon | |||
'value' => 'Valeur (0.2 pour 20%)', | |||
]; | |||
} | |||
/* Getters / Setters */ | |||
public function getId(): ?int | |||
{ | |||
return $this->id; | |||
} | |||
public function getName(): ?string | |||
{ | |||
return $this->name; | |||
} | |||
public function setName(?string $name): self | |||
{ | |||
$this->name = $name; | |||
return $this; | |||
} | |||
public function getValue(): ?float | |||
{ | |||
return $this->value; | |||
} | |||
public function setValue(?float $value): self | |||
{ | |||
$this->value = $value; | |||
return $this; | |||
} | |||
} |
@@ -12,13 +12,4 @@ class TaxRateBuilder extends AbstractBuilder | |||
return $taxRate; | |||
} | |||
public function createTaxRate(): TaxRate | |||
{ | |||
$taxRate = $this->instanciateTaxRate(); | |||
$this->saveCreate($taxRate); | |||
return $taxRate; | |||
} | |||
} |
@@ -0,0 +1,24 @@ | |||
<?php | |||
namespace domain\Config\TaxRate; | |||
use domain\_\AbstractManager; | |||
class TaxRateManager extends AbstractManager | |||
{ | |||
protected TaxRateBuilder $taxRateBuilder; | |||
public function loadDependencies(): void | |||
{ | |||
$this->taxRateBuilder = $this->loadService(TaxRateBuilder::class); | |||
} | |||
public function createTaxRate(string $name, float $value): TaxRate | |||
{ | |||
$taxRate = $this->taxRateBuilder->instanciateTaxRate(); | |||
$taxRate->setName($name); | |||
$taxRate->setValue($value); | |||
$taxRate->save(); | |||
return $taxRate; | |||
} | |||
} |