Browse Source

Merge branch 'refactoring' of https://forge.laclic.fr/Laclic/Opendistrib into refactoring

refactoring
Guillaume Bourgeois 1 year ago
parent
commit
d97c070485
14 changed files with 92 additions and 38 deletions
  1. +3
    -3
      backend/controllers/DistributionController.php
  2. +5
    -0
      backend/controllers/OrderController.php
  3. +6
    -7
      backend/views/distribution/index.php
  4. +2
    -2
      backend/views/document/download.php
  5. +22
    -12
      backend/web/css/screen.css
  6. +2
    -1
      backend/web/js/vuejs/distribution-index.js
  7. +9
    -0
      backend/web/sass/distribution/_index.scss
  8. +4
    -4
      common/helpers/Tiller.php
  9. +1
    -0
      common/logic/Document/Document/Service/DocumentUtils.php
  10. +7
    -4
      common/logic/Order/Order/Service/OrderBuilder.php
  11. +1
    -1
      common/logic/Product/Product/Repository/ProductRepository.php
  12. +7
    -1
      common/logic/Product/ProductCategory/Repository/ProductCategoryRepository.php
  13. +18
    -1
      producer/controllers/OrderController.php
  14. +5
    -2
      producer/controllers/SiteController.php

+ 3
- 3
backend/controllers/DistributionController.php View File

'quantity' => $productOrder->quantity * Product::$unitsArray[$productOrder->unit]['coefficient'], 'quantity' => $productOrder->quantity * Product::$unitsArray[$productOrder->unit]['coefficient'],
'unit' => $productOrder->unit, 'unit' => $productOrder->unit,
'price' => number_format($productOrder->price, 3), 'price' => number_format($productOrder->price, 3),
'invoice_price' => number_format($productOrder->invoice_price, 2),
'invoice_price' => number_format($productOrder->invoice_price, 3),
'price_with_tax' => Price::getPriceWithTax($productOrder->price, $productOrder->taxRate->value), 'price_with_tax' => Price::getPriceWithTax($productOrder->price, $productOrder->taxRate->value),
]; ];
} }
foreach ($order->productOrder as $productOrder) { foreach ($order->productOrder as $productOrder) {
if ($productOrder->id_product == $product['id']) { if ($productOrder->id_product == $product['id']) {
if ($productOrder->invoice_price) { if ($productOrder->invoice_price) {
$invoicePrice = number_format($productOrder->invoice_price, 2);
$invoicePrice = number_format($productOrder->invoice_price, 3);
} else { } else {
$invoicePrice = number_format($productOrder->price, 3); $invoicePrice = number_format($productOrder->price, 3);
} }
'type' => $typePaymentTiller, 'type' => $typePaymentTiller,
'amount' => $orderManager->getOrderAmountWithTax( 'amount' => $orderManager->getOrderAmountWithTax(
$order, $order,
Order::AMOUNT_TOTAL
Order::AMOUNT_PAID
) * 100, ) * 100,
'status' => 'ACCEPTED', 'status' => 'ACCEPTED',
'date' => $strDate 'date' => $strDate

+ 5
- 0
backend/controllers/OrderController.php View File

if ($productOrder) { if ($productOrder) {
$productOrder->quantity = $quantity; $productOrder->quantity = $quantity;
$productOrder->price = $dataProductOrder->price; $productOrder->price = $dataProductOrder->price;

if($dataProductOrder->invoice_price && $dataProductOrder->invoice_price != $dataProductOrder->price) {
//die('invoice price : '.$dataProductOrder->invoice_price);
$productOrder->invoice_price = $dataProductOrder->invoice_price;
}
} else { } else {
$product = Product::findOne($key); $product = Product::findOne($key);



+ 6
- 7
backend/views/distribution/index.php View File

<input type="text" v-model="order.productOrder[product.id].price_with_tax" class="form-control input-sm" @change="productPriceChange" :data-with-tax="true" :data-id-product="product.id" /> <input type="text" v-model="order.productOrder[product.id].price_with_tax" class="form-control input-sm" @change="productPriceChange" :data-with-tax="true" :data-id-product="product.id" />
<span class="input-group-addon" id="basic-addon2">€ TTC</span> <span class="input-group-addon" id="basic-addon2">€ TTC</span>
</div> </div>
<div v-if="(order.id_invoice || order.id_delivery_note || order.id_quotation) && order.productOrder[product.id].quantity > 0">
<span class="label label-default">
Facturé
<template v-if="order.productOrder[product.id].invoice_price != null">{{ order.productOrder[product.id].invoice_price }}</template>
<template v-else>{{ order.productOrder[product.id].price }}</template>
€ HT
</span>
<div class="invoice-price" v-show="vatMode == 'all'" v-if="(order.id_invoice || order.id_delivery_note || order.id_quotation) && order.productOrder[product.id].quantity > 0">
<span class="label-invoice-price">Prix facturé</span><br />
<div class="input-group">
<input type="text" v-model="order.productOrder[product.id].invoice_price" class="form-control input-sm" :data-id-product="product.id" />
<span class="input-group-addon" id="basic-addon2">€ HT</span>
</div>
</div> </div>
</td> </td>
<td class="quantity"> <td class="quantity">

+ 2
- 2
backend/views/document/download.php View File

<?php if (strlen($document->reference)) : ?> <?php if (strlen($document->reference)) : ?>
<?= $documentManager->getType($document); ?> N°<?= $document->reference; ?> <?= $documentManager->getType($document); ?> N°<?= $document->reference; ?>
<?php else: ?> <?php else: ?>
<div class="block-is-draft"><?= $document->getType(); ?> non
validé<?= ($document->getType() == 'Facture') ? 'e' : '' ?></div>
<div class="block-is-draft"><?= $documentManager->getType($document); ?> non
validé<?= ($documentManager->getType($document) == 'Facture') ? 'e' : '' ?></div>
<?php endif; ?> <?php endif; ?>
</div> </div>
<div class="name"> <div class="name">

+ 22
- 12
backend/web/css/screen.css View File

.distribution-index .modal-form-order table.table-products td.price .input-group-addon { .distribution-index .modal-form-order table.table-products td.price .input-group-addon {
background-color: #eee; background-color: #eee;
} }
/* line 396, ../sass/distribution/_index.scss */
/* line 395, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.price .invoice-price {
margin-top: 8px;
}
/* line 397, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.price .invoice-price .label-invoice-price {
font-size: 11px;
font-weight: bold;
color: gray;
}
/* line 405, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity { .distribution-index .modal-form-order table.table-products td.quantity {
width: 165px; width: 165px;
} }
/* line 399, ../sass/distribution/_index.scss */
/* line 408, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity input { .distribution-index .modal-form-order table.table-products td.quantity input {
text-align: center; text-align: center;
color: black; color: black;
} }
/* line 404, ../sass/distribution/_index.scss */
/* line 413, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity .form-control { .distribution-index .modal-form-order table.table-products td.quantity .form-control {
border-right: 0px none; border-right: 0px none;
padding-right: 4px; padding-right: 4px;
} }
/* line 409, ../sass/distribution/_index.scss */
/* line 418, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity .input-group-addon { .distribution-index .modal-form-order table.table-products td.quantity .input-group-addon {
padding: 5px; padding: 5px;
padding-left: 0px; padding-left: 0px;
border-left: 0px none; border-left: 0px none;
border-right: 0px none; border-right: 0px none;
} }
/* line 418, ../sass/distribution/_index.scss */
/* line 427, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity-remaining { .distribution-index .modal-form-order table.table-products td.quantity-remaining {
text-align: right; text-align: right;
} }
/* line 421, ../sass/distribution/_index.scss */
/* line 430, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity-remaining.quantity-remaining, .distribution-index .modal-form-order table.table-products td.quantity-remaining.infinite { .distribution-index .modal-form-order table.table-products td.quantity-remaining.quantity-remaining, .distribution-index .modal-form-order table.table-products td.quantity-remaining.infinite {
color: #00A65A; color: #00A65A;
} }
/* line 425, ../sass/distribution/_index.scss */
/* line 434, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity-remaining.negative { .distribution-index .modal-form-order table.table-products td.quantity-remaining.negative {
color: #DD4B39; color: #DD4B39;
} }
/* line 429, ../sass/distribution/_index.scss */
/* line 438, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity-remaining.infinite, .distribution-index .modal-form-order table.table-products td.quantity-remaining.empty { .distribution-index .modal-form-order table.table-products td.quantity-remaining.infinite, .distribution-index .modal-form-order table.table-products td.quantity-remaining.empty {
font-size: 18px; font-size: 18px;
} }
/* line 436, ../sass/distribution/_index.scss */
/* line 445, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .actions-form button { .distribution-index .modal-form-order .actions-form button {
margin-left: 15px; margin-left: 15px;
} }
/* line 444, ../sass/distribution/_index.scss */
/* line 453, ../sass/distribution/_index.scss */
.distribution-index .modal-payment .info-box .info-box-icon { .distribution-index .modal-payment .info-box .info-box-icon {
width: 50px; width: 50px;
} }
/* line 447, ../sass/distribution/_index.scss */
/* line 456, ../sass/distribution/_index.scss */
.distribution-index .modal-payment .info-box .info-box-icon i { .distribution-index .modal-payment .info-box .info-box-icon i {
font-size: 30px; font-size: 30px;
} }
/* line 452, ../sass/distribution/_index.scss */
/* line 461, ../sass/distribution/_index.scss */
.distribution-index .modal-payment .info-box .info-box-content { .distribution-index .modal-payment .info-box .info-box-content {
margin-left: 50px; margin-left: 50px;
} }

+ 2
- 1
backend/web/js/vuejs/distribution-index.js View File

productOrderArrayRequest[key] = { productOrderArrayRequest[key] = {
quantity: this.order.productOrder[key].quantity, quantity: this.order.productOrder[key].quantity,
unit: this.order.productOrder[key].unit, unit: this.order.productOrder[key].unit,
price: this.order.productOrder[key].price
price: this.order.productOrder[key].price,
invoice_price: this.order.productOrder[key].invoice_price
}; };
} }
return JSON.stringify(productOrderArrayRequest); return JSON.stringify(productOrderArrayRequest);

+ 9
- 0
backend/web/sass/distribution/_index.scss View File

.input-group-addon { .input-group-addon {
background-color: #eee; background-color: #eee;
} }

.invoice-price {
margin-top: 8px;
.label-invoice-price {
font-size: 11px;
font-weight: bold;
color: gray;
}
}
} }


td.quantity { td.quantity {

+ 4
- 4
common/helpers/Tiller.php View File

if (isset($ordersTiller->orders)) { if (isset($ordersTiller->orders)) {
foreach ($ordersTiller->orders as $orderTiller) { foreach ($ordersTiller->orders as $orderTiller) {
if ($orderOpendistrib->tiller_external_id == $orderTiller->id) { if ($orderOpendistrib->tiller_external_id == $orderTiller->id) {
$amountTotalOrderOpendistrib = (int)round(
$orderManager->getOrderAmountWithTax($orderOpendistrib, Order::AMOUNT_TOTAL) * 100
$amountTotalPaidOrderOpendistrib = (int)round(
$orderManager->getOrderAmountWithTax($orderOpendistrib, Order::AMOUNT_PAID) * 100
); );
if ($amountTotalOrderOpendistrib >= (int)$orderTiller->currentPayedAmount
|| $amountTotalOrderOpendistrib >= (int)$orderTiller->currentBill) {
if ($amountTotalPaidOrderOpendistrib >= (int)$orderTiller->currentPayedAmount
|| $amountTotalPaidOrderOpendistrib >= (int)$orderTiller->currentBill) {
$ordersOpendistribSynchro[$orderOpendistrib->id] = true; $ordersOpendistribSynchro[$orderOpendistrib->id] = true;
} }
} }

+ 1
- 0
common/logic/Document/Document/Service/DocumentUtils.php View File

$aliasDirectoryBase = $this->documentSolver->getAliasDirectoryBase($document); $aliasDirectoryBase = $this->documentSolver->getAliasDirectoryBase($document);
$directoryPdf = \Yii::getAlias($aliasDirectoryBase); $directoryPdf = \Yii::getAlias($aliasDirectoryBase);
if (!file_exists($directoryPdf)) { if (!file_exists($directoryPdf)) {
//die('dir : '.$directoryPdf);
mkdir($directoryPdf, 0755); mkdir($directoryPdf, 0755);
} }
} }

+ 7
- 4
common/logic/Order/Order/Service/OrderBuilder.php View File

*/ */
public function initOrderPaidAmount(Order $order): void public function initOrderPaidAmount(Order $order): void
{ {
if (isset($order->creditHistory)) {
// Attention : $order->creditHistory pas à jour si un paiement vient d'avoir lieu
/*if (isset($order->creditHistory)) {
$history = $order->creditHistory; $history = $order->creditHistory;
} else { } else {
$history = $this->creditHistoryRepository->getByOrder($order); $history = $this->creditHistoryRepository->getByOrder($order);
}
}*/

$history = $this->creditHistoryRepository->getByOrder($order);


$order->paid_amount = 0; $order->paid_amount = 0;


if (!is_null($synchroTiller)) { if (!is_null($synchroTiller)) {
$order->tiller_synchronization = $synchroTiller; $order->tiller_synchronization = $synchroTiller;
} else { } else {
$paymentStatus = $this->orderSolver->getPaymentStatus($order);
$amountPaid = $this->orderSolver->getOrderAmount($order, Order::AMOUNT_PAID);


if ($paymentStatus == Order::PAYMENT_PAID) {
if ($amountPaid >= 0.01) {
$order->tiller_synchronization = 1; $order->tiller_synchronization = 1;
} else { } else {
$order->tiller_synchronization = 0; $order->tiller_synchronization = 0;

+ 1
- 1
common/logic/Product/Product/Repository/ProductRepository.php View File

{ {
return Product::find() return Product::find()
->andWhere([ ->andWhere([
'id_producer' => $productCategory->id_producer,
'id_producer' => $this->getProducerContext()->id,
'active' => true, 'active' => true,
]) ])
->andWhere( ->andWhere(

+ 7
- 1
common/logic/Product/ProductCategory/Repository/ProductCategoryRepository.php View File



public function findProductCategories() public function findProductCategories()
{ {
return ProductCategory::searchAll([], ['orderby' => 'product_category.position ASC']);
return ProductCategory::searchAll([
'id_producer' => $this->getProducerContext()->id
],
[
'orderby' => 'product_category.position ASC'
]
);
} }


public function findProductCategoriesAsArray() public function findProductCategoriesAsArray()

+ 18
- 1
producer/controllers/OrderController.php View File

use DateTime; use DateTime;
use yii\base\UserException; use yii\base\UserException;
use yii\data\ActiveDataProvider; use yii\data\ActiveDataProvider;
use yii\filters\AccessControl;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;


class OrderController extends ProducerBaseController class OrderController extends ProducerBaseController


public function behaviors() public function behaviors()
{ {
return [];
return [
'access' => [
'class' => AccessControl::class,
'only' => [
'history',
'remove-producer',
'cancel'
],
'rules' => [
[
'allow' => true,
'roles' => ['@']
]
],
],
];
} }


public function actionOrder(int $id = 0, $date = '') public function actionOrder(int $id = 0, $date = '')
} }
} }


$orderManager->initOrder($order);
$orderManager->updateOrderTillerSynchronization($order); $orderManager->updateOrderTillerSynchronization($order);
} }



+ 5
- 2
producer/controllers/SiteController.php View File

*/ */
public function actionIndex() public function actionIndex()
{ {
$productManager = $this->getProductManager();
$pointSaleManager = $this->getPointSaleManager();

$dataProviderPointsSale = new ActiveDataProvider([ $dataProviderPointsSale = new ActiveDataProvider([
'query' => $this->getPointSaleManager()->queryPointSalesPublic($this->getProducerCurrent()),
'query' => $pointSaleManager->queryPointSalesPublic($this->getProducerCurrent()),
'pagination' => [ 'pagination' => [
'pageSize' => 50, 'pageSize' => 50,
], ],
$dataProviderProductsByCategories = []; $dataProviderProductsByCategories = [];
foreach ($productCategoryArray as $productCategory) { foreach ($productCategoryArray as $productCategory) {
$dataProviderProductsByCategories[$productCategory->id] = new ActiveDataProvider([ $dataProviderProductsByCategories[$productCategory->id] = new ActiveDataProvider([
'query' => $this->getProductManager()->queryProductsByProductCategory($productCategory),
'query' => $productManager->queryProductsByProductCategory($productCategory),
'pagination' => [ 'pagination' => [
'pageSize' => 500, 'pageSize' => 500,
], ],

Loading…
Cancel
Save