Преглед изворни кода

Amélioration fonction installation système de TVA #165

dev
Guillaume Bourgeois пре 4 година
родитељ
комит
7912a8fc80
3 измењених фајлова са 18 додато и 25 уклоњено
  1. +16
    -23
      backend/controllers/ProducerAdminController.php
  2. +1
    -1
      backend/views/product/index.php
  3. +1
    -1
      common/models/Product.php

+ 16
- 23
backend/controllers/ProducerAdminController.php Прегледај датотеку

@@ -186,33 +186,26 @@ class ProducerAdminController extends BackendController
$productsArray = Product::searchAll([
'id_producer' => $idProducer
]) ;

$connection = Yii::$app->getDb();
foreach($productsArray as $product) {
$product->price = $product->price / (1 + $product->taxRate->value) ;
$product->price = round($product->price / (1 + $product->taxRate->value), 2) ;
$product->save() ;

$command = $connection->createCommand("
UPDATE `product_order`
SET price = ROUND(price / (1 + :tax_value), 2)
WHERE id_product = :id_product",
[
':id_product' => $product->id,
':tax_value' => $product->taxRate->value
]);

$result = $command->query();
}
// product_order
$ordersArray = Order::searchAll([
'distribution.id_producer' => $idProducer
]) ;
foreach($ordersArray as $order) {
foreach($order->productOrder as $productOrder) {
$productOrder->price = $productOrder->price / (1 + $productOrder->taxRate->value) ;
$productOrder->save() ;
}
}
// product_subscription
$subscriptionsArray = Subscription::searchAll([
'subscription.id_producer' => $idProducer
]) ;
foreach($subscriptionsArray as $subscription) {
foreach($subscription->productSubscription as $productSubscription) {
$productSubscription->price = $productSubscription->price / (1 + $productSubscription->taxRate->value) ;
$productSubscription->save() ;
}
}

echo 'ok' ;
}

/**

+ 1
- 1
backend/views/product/index.php Прегледај датотеку

@@ -102,7 +102,7 @@ $this->addButton(['label' => 'Nouveau produit <span class="glyphicon glyphicon-p
'value' => function ($model) {
$return = '';
if ($model->price) {
$return = Price::format($model->price) . ' (' . Product::strUnit($model->unit, 'wording_unit', true) . ')';
$return = Price::format($model->getPriceWithTax()) . ' (' . Product::strUnit($model->unit, 'wording_unit', true) . ')';
}

return $return;

+ 1
- 1
common/models/Product.php Прегледај датотеку

@@ -118,7 +118,7 @@ class Product extends ActiveRecordCommon
public function rules()
{
return [
[['name', 'id_producer', 'id_tax_rate'], 'required'],
[['name', 'id_producer'], 'required'],
[['active', 'order', 'quantity_max', 'id_producer', 'id_tax_rate'], 'integer'],
[['monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday', 'sunday', 'unavailable', 'apply_distributions'], 'boolean'],
[['price', 'weight', 'step'], 'number'],

Loading…
Откажи
Сачувај