Browse Source

Refactoring services #885

refactoring
Guillaume 1 year ago
parent
commit
8b9984b3cd
100 changed files with 501 additions and 468 deletions
  1. +1
    -5
      backend/controllers/AccessController.php
  2. +3
    -3
      backend/controllers/BackendController.php
  3. +1
    -1
      backend/controllers/CommunicateAdminController.php
  4. +10
    -6
      backend/controllers/CronController.php
  5. +1
    -3
      backend/controllers/DeliveryNoteController.php
  6. +11
    -14
      backend/controllers/DistributionController.php
  7. +9
    -8
      backend/controllers/DocumentController.php
  8. +2
    -3
      backend/controllers/InvoiceController.php
  9. +14
    -14
      backend/controllers/OrderController.php
  10. +5
    -5
      backend/controllers/PointSaleController.php
  11. +3
    -3
      backend/controllers/ProducerAdminController.php
  12. +2
    -2
      backend/controllers/ProducerController.php
  13. +1
    -1
      backend/controllers/ProducerPriceRangeAdminController.php
  14. +2
    -2
      backend/controllers/ProductCategoryController.php
  15. +8
    -8
      backend/controllers/ProductController.php
  16. +2
    -2
      backend/controllers/QuotationController.php
  17. +0
    -1
      backend/controllers/ReportController.php
  18. +5
    -5
      backend/controllers/SiteController.php
  19. +0
    -1
      backend/controllers/StatsController.php
  20. +2
    -2
      backend/controllers/SubscriptionController.php
  21. +7
    -8
      backend/controllers/UserController.php
  22. +2
    -2
      backend/controllers/UserGroupController.php
  23. +3
    -3
      backend/views/layouts/header.php
  24. +6
    -5
      common/components/ActiveRecordCommon.php
  25. +1
    -24
      common/components/BusinessLogic.php
  26. +46
    -46
      common/components/BusinessLogicTrait.php
  27. +1
    -1
      common/config/main.php
  28. +1
    -1
      common/controllers/CommonController.php
  29. +2
    -2
      common/forms/LoginForm.php
  30. +2
    -2
      common/helpers/GlobalParam.php
  31. +7
    -3
      common/helpers/Tiller.php
  32. +11
    -0
      common/logic/Distribution/Distribution/Event/DistributionActiveEvent.php
  33. +6
    -6
      common/logic/Distribution/Distribution/Model/Distribution.php
  34. +8
    -6
      common/logic/Distribution/Distribution/Repository/DistributionRepository.php
  35. +1
    -1
      common/logic/Distribution/Distribution/Repository/DistributionRepositoryQuery.php
  36. +17
    -16
      common/logic/Distribution/Distribution/Service/DistributionBuilder.php
  37. +2
    -1
      common/logic/Distribution/Distribution/Service/DistributionSolver.php
  38. +5
    -1
      common/logic/Distribution/Distribution/Wrapper/DistributionContainer.php
  39. +4
    -0
      common/logic/Distribution/Distribution/Wrapper/DistributionManager.php
  40. +2
    -2
      common/logic/Distribution/PointSaleDistribution/Model/PointSaleDistribution.php
  41. +3
    -2
      common/logic/Distribution/PointSaleDistribution/Repository/PointSaleDistributionRepository.php
  42. +1
    -1
      common/logic/Distribution/PointSaleDistribution/Repository/PointSaleDistributionRepositoryQuery.php
  43. +7
    -6
      common/logic/Distribution/PointSaleDistribution/Service/PointSaleDistributionBuilder.php
  44. +4
    -1
      common/logic/Distribution/PointSaleDistribution/Wrapper/PointSaleDistributionContainer.php
  45. +3
    -1
      common/logic/Distribution/PointSaleDistribution/Wrapper/PointSaleDistributionManager.php
  46. +2
    -2
      common/logic/Distribution/ProductDistribution/Model/ProductDistribution.php
  47. +3
    -2
      common/logic/Distribution/ProductDistribution/Repository/ProductDistributionRepository.php
  48. +1
    -1
      common/logic/Distribution/ProductDistribution/Repository/ProductDistributionRepositoryQuery.php
  49. +7
    -6
      common/logic/Distribution/ProductDistribution/Service/ProductDistributionBuilder.php
  50. +4
    -1
      common/logic/Distribution/ProductDistribution/Wrapper/ProductDistributionContainer.php
  51. +3
    -1
      common/logic/Distribution/ProductDistribution/Wrapper/ProductDistributionManager.php
  52. +1
    -1
      common/logic/Document/DeliveryNote/Model/DeliveryNote.php
  53. +2
    -2
      common/logic/Document/DeliveryNote/Model/DeliveryNoteSearch.php
  54. +2
    -1
      common/logic/Document/DeliveryNote/Repository/DeliveryNoteRepository.php
  55. +1
    -1
      common/logic/Document/DeliveryNote/Repository/DeliveryNoteRepositoryQuery.php
  56. +2
    -1
      common/logic/Document/DeliveryNote/Service/DeliveryNoteBuilder.php
  57. +2
    -1
      common/logic/Document/DeliveryNote/Service/DeliveryNoteSolver.php
  58. +4
    -1
      common/logic/Document/DeliveryNote/Wrapper/DeliveryNoteContainer.php
  59. +4
    -2
      common/logic/Document/DeliveryNote/Wrapper/DeliveryNoteManager.php
  60. +0
    -8
      common/logic/Document/Document/DocumentInterface.php
  61. +5
    -8
      common/logic/Document/Document/Model/Document.php
  62. +8
    -0
      common/logic/Document/Document/Model/DocumentInterface.php
  63. +4
    -2
      common/logic/Document/Document/Service/DocumentBuilder.php
  64. +3
    -1
      common/logic/Document/Document/Service/DocumentSolver.php
  65. +5
    -4
      common/logic/Document/Document/Service/DocumentUtils.php
  66. +5
    -1
      common/logic/Document/Document/Wrapper/DocumentContainer.php
  67. +1
    -1
      common/logic/Document/Document/Wrapper/DocumentManager.php
  68. +0
    -17
      common/logic/Document/Invoice/InvoiceManager.php
  69. +2
    -2
      common/logic/Document/Invoice/Model/Invoice.php
  70. +2
    -2
      common/logic/Document/Invoice/Model/InvoiceSearch.php
  71. +2
    -1
      common/logic/Document/Invoice/Repository/InvoiceRepository.php
  72. +1
    -1
      common/logic/Document/Invoice/Repository/InvoiceRepositoryQuery.php
  73. +3
    -2
      common/logic/Document/Invoice/Service/InvoiceBuilder.php
  74. +5
    -2
      common/logic/Document/Invoice/Wrapper/InvoiceContainer.php
  75. +19
    -0
      common/logic/Document/Invoice/Wrapper/InvoiceManager.php
  76. +2
    -2
      common/logic/Document/Quotation/Model/Quotation.php
  77. +2
    -2
      common/logic/Document/Quotation/Model/QuotationSearch.php
  78. +0
    -19
      common/logic/Document/Quotation/QuotationManager.php
  79. +2
    -2
      common/logic/Document/Quotation/Repository/QuotationRepository.php
  80. +1
    -1
      common/logic/Document/Quotation/Repository/QuotationRepositoryQuery.php
  81. +2
    -1
      common/logic/Document/Quotation/Service/QuotationBuilder.php
  82. +5
    -5
      common/logic/Document/Quotation/Wrapper/QuotationContainer.php
  83. +19
    -0
      common/logic/Document/Quotation/Wrapper/QuotationManager.php
  84. +11
    -11
      common/logic/Order/Order/Model/Order.php
  85. +2
    -1
      common/logic/Order/Order/Model/OrderSearch.php
  86. +0
    -27
      common/logic/Order/Order/OrderManager.php
  87. +12
    -10
      common/logic/Order/Order/Repository/OrderRepository.php
  88. +1
    -1
      common/logic/Order/Order/Repository/OrderRepositoryQuery.php
  89. +44
    -46
      common/logic/Order/Order/Service/OrderBuilder.php
  90. +14
    -17
      common/logic/Order/Order/Service/OrderSolver.php
  91. +1
    -1
      common/logic/Order/Order/Service/OrderUtils.php
  92. +6
    -1
      common/logic/Order/Order/Wrapper/OrderContainer.php
  93. +21
    -0
      common/logic/Order/Order/Wrapper/OrderManager.php
  94. +3
    -3
      common/logic/Order/OrderStatusHistory/Model/OrderStatusHistory.php
  95. +1
    -1
      common/logic/Order/OrderStatusHistory/Repository/OrderStatusHistoryRepository.php
  96. +1
    -1
      common/logic/Order/OrderStatusHistory/Repository/OrderStatusHistoryRepositoryQuery.php
  97. +5
    -4
      common/logic/Order/OrderStatusHistory/Service/OrderStatusHistoryBuilder.php
  98. +4
    -2
      common/logic/Order/OrderStatusHistory/Wrapper/OrderStatusHistoryContainer.php
  99. +3
    -2
      common/logic/Order/OrderStatusHistory/Wrapper/OrderStatusHistoryManager.php
  100. +2
    -3
      common/logic/Order/ProductOrder/Model/ProductOrder.php

+ 1
- 5
backend/controllers/AccessController.php View File



namespace backend\controllers; namespace backend\controllers;


use common\helpers\GlobalParam;
use backend\models\AccessUserProducerForm; use backend\models\AccessUserProducerForm;
use common\logic\Document\DeliveryNote\DeliveryNoteManager;
use common\logic\Producer\Producer\ProducerManager;
use common\logic\User\User\User;
use common\logic\User\User\UserSearch;
use common\logic\User\User\Model\UserSearch;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;



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



namespace backend\controllers; namespace backend\controllers;


use common\logic\PointSale\PointSale\PointSale;
use common\logic\Producer\Producer\Producer;
use common\logic\Product\Product\Product;
use common\controllers\CommonController; use common\controllers\CommonController;
use common\logic\PointSale\PointSale\Model\PointSale;
use common\logic\Producer\Producer\Model\Producer;
use common\logic\Product\Product\Model\Product;


class BackendController extends CommonController class BackendController extends CommonController
{ {

+ 1
- 1
backend/controllers/CommunicateAdminController.php View File

namespace backend\controllers; namespace backend\controllers;


use backend\models\MailForm; use backend\models\MailForm;
use common\logic\User\User\User;
use common\logic\User\User\Model\User;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;

+ 10
- 6
backend/controllers/CronController.php View File



namespace backend\controllers; namespace backend\controllers;


use common\logic\Order\Order\Order;
use common\logic\PointSale\PointSale\PointSale;
use common\logic\User\CreditHistory\CreditHistory;
use common\logic\User\User\User;
use common\logic\Order\Order\Model\Order;
use common\logic\PointSale\PointSale\Model\PointSale;
use common\logic\User\CreditHistory\Model\CreditHistory;
use common\logic\User\User\Model\User;
use Yii; use Yii;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
use yii\filters\AccessControl; use yii\filters\AccessControl;
public function actionInitDemo($key = '') public function actionInitDemo($key = '')
{ {
if ($key == '45432df6e842ac71aa0b5bb6b9f25d44') { if ($key == '45432df6e842ac71aa0b5bb6b9f25d44') {

$producerManager = $this->getProducerManager(); $producerManager = $this->getProducerManager();
$distributionManager = $this->getDistributionManager();

$producer = $producerManager->findOneProducerDemoAccount(); $producer = $producerManager->findOneProducerDemoAccount();
$producerManager->setProducerContext($producer);
$distributionManager->setProducerContext($producer);


if ($producer) { if ($producer) {
// initialisation de la distribution à J+7 // initialisation de la distribution à J+7
} }


if ($activeDistribution) { if ($activeDistribution) {
$distributionManager = $this->getDistributionManager();
$distribution = $distributionManager->createDistributionIfNotExist($producer, date('Y-m-d', $dateTime));
$distribution = $distributionManager->createDistributionIfNotExist(date('Y-m-d', $dateTime));
$distributionManager->activeDistribution($distribution); $distributionManager->activeDistribution($distribution);
} }
} }

+ 1
- 3
backend/controllers/DeliveryNoteController.php View File



namespace backend\controllers; namespace backend\controllers;


use common\logic\Document\DeliveryNote\DeliveryNoteSearch;
use common\logic\Document\DeliveryNote\Model\DeliveryNoteSearch;
use Yii; use Yii;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;



class DeliveryNoteController extends DocumentController class DeliveryNoteController extends DocumentController
{ {
public function behaviors() public function behaviors()
'dataProvider' => $dataProvider, 'dataProvider' => $dataProvider,
]); ]);
} }

} }

+ 11
- 14
backend/controllers/DistributionController.php View File

use common\helpers\Password; use common\helpers\Password;
use common\helpers\Price; use common\helpers\Price;
use common\helpers\Tiller; use common\helpers\Tiller;
use common\logic\Distribution\Distribution\Distribution;
use common\logic\Distribution\PointSaleDistribution\PointSaleDistribution;
use common\logic\Distribution\ProductDistribution\ProductDistribution;
use common\logic\Document\DeliveryNote\DeliveryNote;
use common\logic\Document\Document\Document;
use common\logic\Order\Order\Order;
use common\logic\PointSale\PointSale\PointSale;
use common\logic\Product\Product\Product;
use common\logic\User\User\User;
use common\logic\User\UserProducer\UserProducer;
use common\logic\Distribution\Distribution\Model\Distribution;
use common\logic\Document\DeliveryNote\Model\DeliveryNote;
use common\logic\Document\Document\Model\Document;
use common\logic\Order\Order\Model\Order;
use common\logic\PointSale\PointSale\Model\PointSale;
use common\logic\Product\Product\Model\Product;
use common\logic\User\UserProducer\Model\UserProducer;
use DateTime; use DateTime;
use kartik\mpdf\Pdf; use kartik\mpdf\Pdf;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use yii\web\User;


class DistributionController extends BackendController class DistributionController extends BackendController
{ {

public function behaviors() public function behaviors()
{ {
return [ return [
$json['distributions'] = $distributionsArray; $json['distributions'] = $distributionsArray;


if ($dateObject && $dateObject->format($format) === $date) { if ($dateObject && $dateObject->format($format) === $date) {
$distribution = $distributionManager->createDistributionIfNotExist($producer, $date);
$distribution = $distributionManager->createDistributionIfNotExist($date);
$json['distribution'] = [ $json['distribution'] = [
'id' => $distribution->id, 'id' => $distribution->id,
'active' => $distribution->active, 'active' => $distribution->active,
$format = 'Y-m-d'; $format = 'Y-m-d';
$dateObject = DateTime::createFromFormat($format, $date); $dateObject = DateTime::createFromFormat($format, $date);
if ($dateObject && $dateObject->format($format) === $date) { if ($dateObject && $dateObject->format($format) === $date) {
$distribution = $distributionManager->createDistributionIfNotExist($producerCurrent, $date);
$distribution = $distributionManager->createDistributionIfNotExist($date);
} }


if ($distribution) { if ($distribution) {
$user = $userManager->findOneUserById($deliveryNote->id_user); $user = $userManager->findOneUserById($deliveryNote->id_user);
$userProducer = $userProducerManager->findOneUserProducer($user, $producerCurrent); $userProducer = $userProducerManager->findOneUserProducer($user, $producerCurrent);
} else { } else {
$user = new User;
$user = new User();
$user->type = User::TYPE_LEGAL_PERSON; $user->type = User::TYPE_LEGAL_PERSON;
$user->name_legal_person = $firstOrder->pointSale->name; $user->name_legal_person = $firstOrder->pointSale->name;
$user->address = $firstOrder->pointSale->address; $user->address = $firstOrder->pointSale->address;

+ 9
- 8
backend/controllers/DocumentController.php View File



use common\helpers\CSV; use common\helpers\CSV;
use common\helpers\GlobalParam; use common\helpers\GlobalParam;
use common\logic\Document\DeliveryNote\DeliveryNote;
use common\logic\Document\Document\Document;
use common\logic\Document\Invoice\Invoice;
use common\logic\Document\Quotation\Quotation;
use common\logic\Order\Order\Order;
use common\logic\Order\ProductOrder\ProductOrder;
use common\logic\Product\Product\Product;
use common\logic\Document\DeliveryNote\Model\DeliveryNote;
use common\logic\Document\Document\Model\Document;
use common\logic\Document\Invoice\Model\Invoice;
use common\logic\Document\Quotation\Model\Quotation;
use common\logic\Order\Order\Model\Order;
use common\logic\Order\ProductOrder\Model\ProductOrder;
use common\logic\Product\Product\Model\Product;
use kartik\mpdf\Pdf; use kartik\mpdf\Pdf;
use yii\base\UserException; use yii\base\UserException;
use yii; use yii;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use yii\web\NotFoundHttpException;
use yii\helpers\Html;


class DocumentController extends BackendController class DocumentController extends BackendController
{ {
throw new NotFoundHttpException('The requested page does not exist.'); throw new NotFoundHttpException('The requested page does not exist.');
} }
} }

} }

+ 2
- 3
backend/controllers/InvoiceController.php View File



namespace backend\controllers; namespace backend\controllers;


use common\logic\Document\Invoice\InvoiceSearch;
use common\logic\Order\Order\Order;
use Yii;
use common\logic\Document\Invoice\Model\InvoiceSearch;
use common\logic\Order\Order\Model\Order;


class InvoiceController extends DocumentController class InvoiceController extends DocumentController
{ {

+ 14
- 14
backend/controllers/OrderController.php View File

use common\forms\SubscriptionForm; use common\forms\SubscriptionForm;
use common\helpers\CSV; use common\helpers\CSV;
use common\helpers\GlobalParam; use common\helpers\GlobalParam;
use common\logic\Distribution\Distribution\Distribution;
use common\logic\Distribution\PointSaleDistribution\PointSaleDistribution;
use common\logic\Distribution\ProductDistribution\ProductDistribution;
use common\logic\Order\Order\Order;
use common\logic\Order\ProductOrder\ProductOrder;
use common\logic\PointSale\PointSale\PointSale;
use common\logic\Product\Product\Product;
use common\logic\User\CreditHistory\CreditHistory;
use common\logic\User\User\User;
use common\logic\User\UserProducer\UserProducer;
use common\logic\Distribution\Distribution\Model\Distribution;
use common\logic\Distribution\PointSaleDistribution\Model\PointSaleDistribution;
use common\logic\Distribution\ProductDistribution\Model\ProductDistribution;
use common\logic\Order\Order\Model\Order;
use common\logic\Order\ProductOrder\Model\ProductOrder;
use common\logic\PointSale\PointSale\Model\PointSale;
use common\logic\Product\Product\Model\Product;
use common\logic\User\CreditHistory\Model\CreditHistory;
use common\logic\User\User\Model\User;
use common\logic\User\UserProducer\Model\UserProducer;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use yii\helpers\Html; use yii\helpers\Html;


$date = \Yii::$app->getRequest()->post('date_order_point_sale_' . $point->id, 0); $date = \Yii::$app->getRequest()->post('date_order_point_sale_' . $point->id, 0);
$oneProduct = false; $oneProduct = false;
foreach ($products as $product) { foreach ($products as $product) {
$quantity = Yii::$app->getRequest()->post('product_point_sale_' . $point->id . '_' . $product->id, 0);
$quantity = \Yii::$app->getRequest()->post('product_point_sale_' . $point->id . '_' . $product->id, 0);
if ($quantity) { if ($quantity) {
$oneProduct = true; $oneProduct = true;
} }
foreach ($products as $product) { foreach ($products as $product) {
$quantity = \Yii::$app->getRequest()->post('product_point_sale_' . $point->id . '_' . $product->id, 0); $quantity = \Yii::$app->getRequest()->post('product_point_sale_' . $point->id . '_' . $product->id, 0);
if ($quantity) { if ($quantity) {
$productOrder = new ProductOrder;
$productOrder = new ProductOrder();
$productOrder->id_order = $order->id; $productOrder->id_order = $order->id;
$productOrder->id_product = $product->id; $productOrder->id_product = $product->id;
$productOrder->quantity = $quantity; $productOrder->quantity = $quantity;
$arrayUsers[$user->id] = $user->name . ' ' . $user->lastname; $arrayUsers[$user->id] = $user->name . ' ' . $user->lastname;
} }


$distribution = $distributionManager->createDistributionIfNotExist($this->getProducerCurrent(), $date);
$distribution = $distributionManager->createDistributionIfNotExist($date);


if ($distribution) { if ($distribution) {
$arrayPointsSale = PointSale::find() $arrayPointsSale = PointSale::find()
public function actionChangeState(string $date, bool $active, bool $redirect = true) public function actionChangeState(string $date, bool $active, bool $redirect = true)
{ {
$distributionManager = $this->getDistributionManager(); $distributionManager = $this->getDistributionManager();
$distribution = $distributionManager->createDistributionIfNotExist($this->getProducerCurrent(), $date);
$distribution = $distributionManager->createDistributionIfNotExist($date);
$distributionManager->activeDistribution($distribution, $active); $distributionManager->activeDistribution($distribution, $active);


if ($redirect) { if ($redirect) {

+ 5
- 5
backend/controllers/PointSaleController.php View File

namespace backend\controllers; namespace backend\controllers;


use common\helpers\GlobalParam; use common\helpers\GlobalParam;
use common\logic\Distribution\PointSaleDistribution\PointSaleDistribution;
use common\logic\Order\Order\Order;
use common\logic\PointSale\PointSale\PointSale;
use common\logic\PointSale\PointSale\PointSaleSearch;
use common\logic\PointSale\UserPointSale\UserPointSale;
use common\logic\Distribution\PointSaleDistribution\Model\PointSaleDistribution;
use common\logic\Order\Order\Model\Order;
use common\logic\PointSale\PointSale\Model\PointSale;
use common\logic\PointSale\PointSale\Model\PointSaleSearch;
use common\logic\PointSale\UserPointSale\Model\UserPointSale;
use Yii; use Yii;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;

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



namespace backend\controllers; namespace backend\controllers;


use common\logic\Order\Order\Order;
use common\logic\Producer\Producer\Producer;
use common\logic\Product\Product\Product;
use common\logic\Order\Order\Model\Order;
use common\logic\Producer\Producer\Model\Producer;
use common\logic\Product\Product\Model\Product;
use Yii; use Yii;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;

+ 2
- 2
backend/controllers/ProducerController.php View File

namespace backend\controllers; namespace backend\controllers;


use common\helpers\GlobalParam; use common\helpers\GlobalParam;
use common\logic\Producer\Producer\Producer;
use common\logic\Producer\ProducerPriceRange\ProducerPriceRange;
use common\logic\Producer\Producer\Model\Producer;
use common\logic\Producer\ProducerPriceRange\Model\ProducerPriceRange;
use Yii; use Yii;
use yii\data\ActiveDataProvider; use yii\data\ActiveDataProvider;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;

+ 1
- 1
backend/controllers/ProducerPriceRangeAdminController.php View File



namespace backend\controllers; namespace backend\controllers;


use common\logic\Producer\ProducerPriceRange\ProducerPriceRange;
use common\logic\Producer\ProducerPriceRange\Model\ProducerPriceRange;
use Yii; use Yii;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter; use yii\filters\VerbFilter;

+ 2
- 2
backend/controllers/ProductCategoryController.php View File

namespace backend\controllers; namespace backend\controllers;


use common\helpers\GlobalParam; use common\helpers\GlobalParam;
use common\logic\Product\Product\Product;
use common\logic\Product\ProductCategory\ProductCategorySearch;
use common\logic\Product\Product\Model\Product;
use common\logic\Product\ProductCategory\Model\ProductCategorySearch;
use Yii; use Yii;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;

+ 8
- 8
backend/controllers/ProductController.php View File

namespace backend\controllers; namespace backend\controllers;


use common\helpers\GlobalParam; use common\helpers\GlobalParam;
use common\logic\Distribution\ProductDistribution\ProductDistribution;
use common\logic\PointSale\PointSale\PointSale;
use common\logic\Product\Product\Product;
use common\logic\Product\Product\ProductSearch;
use common\logic\Product\ProductPointSale\ProductPointSale;
use common\logic\Product\ProductPrice\ProductPrice;
use common\logic\Product\ProductPrice\ProductPriceSearch;
use common\logic\User\UserProducer\UserProducer;
use common\logic\Distribution\ProductDistribution\Model\ProductDistribution;
use common\logic\PointSale\PointSale\Model\PointSale;
use common\logic\Product\Product\Model\Product;
use common\logic\Product\Product\Model\ProductSearch;
use common\logic\Product\ProductPointSale\Model\ProductPointSale;
use common\logic\Product\ProductPrice\Model\ProductPrice;
use common\logic\Product\ProductPrice\Model\ProductPriceSearch;
use common\logic\User\UserProducer\Model\UserProducer;
use Yii; use Yii;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use yii\helpers\Html; use yii\helpers\Html;

+ 2
- 2
backend/controllers/QuotationController.php View File

namespace backend\controllers; namespace backend\controllers;


use common\helpers\GlobalParam; use common\helpers\GlobalParam;
use common\logic\Document\Quotation\QuotationSearch;
use common\logic\Order\Order\Order;
use common\logic\Document\Quotation\Model\QuotationSearch;
use common\logic\Order\Order\Model\Order;
use Yii; use Yii;
use yii\base\UserException; use yii\base\UserException;
use yii\filters\AccessControl; use yii\filters\AccessControl;

+ 0
- 1
backend/controllers/ReportController.php View File



use common\helpers\GlobalParam; use common\helpers\GlobalParam;
use common\helpers\Price; use common\helpers\Price;
use common\logic\Distribution\Distribution\Distribution;
use Yii; use Yii;
use yii\filters\AccessControl; use yii\filters\AccessControl;



+ 5
- 5
backend/controllers/SiteController.php View File

namespace backend\controllers; namespace backend\controllers;


use common\helpers\GlobalParam; use common\helpers\GlobalParam;
use common\logic\Distribution\Distribution\Distribution;
use common\logic\Order\Order\Order;
use common\logic\PointSale\PointSale\PointSale;
use common\logic\Product\Product\Product;
use common\logic\User\User\User;
use common\logic\Distribution\Distribution\Model\Distribution;
use common\logic\Order\Order\Model\Order;
use common\logic\PointSale\PointSale\Model\PointSale;
use common\logic\Product\Product\Model\Product;
use common\logic\User\User\Model\User;
use Yii; use Yii;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use common\forms\LoginForm; use common\forms\LoginForm;

+ 0
- 1
backend/controllers/StatsController.php View File



class StatsController extends BackendController class StatsController extends BackendController
{ {

public function behaviors() public function behaviors()
{ {
return [ return [

+ 2
- 2
backend/controllers/SubscriptionController.php View File



use common\forms\SubscriptionForm; use common\forms\SubscriptionForm;
use common\helpers\GlobalParam; use common\helpers\GlobalParam;
use common\logic\Product\Product\Product;
use common\logic\Subscription\Subscription\SubscriptionSearch;
use common\logic\Product\Product\Model\Product;
use common\logic\Subscription\Subscription\Model\SubscriptionSearch;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;



+ 7
- 8
backend/controllers/UserController.php View File

use common\helpers\Mailjet; use common\helpers\Mailjet;
use backend\models\MailForm; use backend\models\MailForm;
use common\helpers\Password; use common\helpers\Password;
use common\logic\Distribution\Distribution\Distribution;
use common\logic\Order\Order\OrderSearch;
use common\logic\PointSale\PointSale\PointSale;
use common\logic\PointSale\UserPointSale\UserPointSale;
use common\logic\User\CreditHistory\CreditHistory;
use common\logic\User\User\UserSearch;
use common\logic\User\UserProducer\UserProducer;
use common\logic\User\UserUserGroup\UserUserGroup;
use common\logic\Order\Order\Model\OrderSearch;
use common\logic\PointSale\PointSale\Model\PointSale;
use common\logic\PointSale\UserPointSale\Model\UserPointSale;
use common\logic\User\CreditHistory\Model\CreditHistory;
use common\logic\User\User\Model\UserSearch;
use common\logic\User\UserProducer\Model\UserProducer;
use common\logic\User\UserUserGroup\Model\UserUserGroup;
use yii\base\UserException; use yii\base\UserException;
use yii\debug\models\search\User; use yii\debug\models\search\User;
use yii\filters\AccessControl; use yii\filters\AccessControl;

+ 2
- 2
backend/controllers/UserGroupController.php View File

namespace backend\controllers; namespace backend\controllers;


use common\helpers\GlobalParam; use common\helpers\GlobalParam;
use common\logic\User\UserGroup\UserGroupSearch;
use common\logic\User\UserUserGroup\UserUserGroup;
use common\logic\User\UserGroup\Model\UserGroupSearch;
use common\logic\User\UserUserGroup\Model\UserUserGroup;
use Yii; use Yii;
use yii\filters\AccessControl; use yii\filters\AccessControl;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;

+ 3
- 3
backend/views/layouts/header.php View File

use yii\helpers\Html; use yii\helpers\Html;
use common\helpers\GlobalParam; use common\helpers\GlobalParam;


use common\logic\Distribution\Distribution\Distribution;
use common\logic\Producer\Producer\Producer;
use common\logic\User\User\User;
use common\logic\Distribution\Distribution\Model\Distribution;
use common\logic\Producer\Producer\Model\Producer;
use common\logic\User\User\Model\User;


$userManager = $this->getUserManager(); $userManager = $this->getUserManager();
$producerManager = $this->getProducerManager(); $producerManager = $this->getProducerManager();

+ 6
- 5
common/components/ActiveRecordCommon.php View File

public static function searchBy($params = [], $options = []) public static function searchBy($params = [], $options = [])
{ {
$class = get_called_class(); $class = get_called_class();
$repositoryClass = $class.'Repository';
$repositoryClass = str_replace('\\Model\\', '\\Repository\\', $class).'Repository';
$repository = $repositoryClass::getInstance();


if (is_callable([$repositoryClass, 'getDefaultOptionsSearch'])) {
$repository = $repositoryClass::getInstance();
if(method_exists($repository , 'getDefaultOptionsSearch')) {
$default_options = $repository->getDefaultOptionsSearch(); $default_options = $repository->getDefaultOptionsSearch();
} else { } else {
throw new \ErrorException('La méthode "getDefaultOptionsSearch" n\'est ' throw new \ErrorException('La méthode "getDefaultOptionsSearch" n\'est '
. 'pas définie dans la classe "' . $class . '"');
. 'pas définie dans la classe "' . $repositoryClass . '"');
} }


$options = array_merge($default_options, $options); $options = array_merge($default_options, $options);
$pk = $class::tableName() . '.' . $pk[0]; $pk = $class::tableName() . '.' . $pk[0];


if (isset($options['attribute_id_producer']) && strlen($options['attribute_id_producer']) if (isset($options['attribute_id_producer']) && strlen($options['attribute_id_producer'])
&& !isset($params[$options['attribute_id_producer']]) && !\Yii::$app->user->isGuest) {
&& !isset($params[$options['attribute_id_producer']]) && !\Yii::$app->user->isGuest
) {
$params[$options['attribute_id_producer']] = GlobalParam::getCurrentProducerId(); $params[$options['attribute_id_producer']] = GlobalParam::getCurrentProducerId();
} }



+ 1
- 24
common/components/BusinessLogic.php View File



namespace common\components; namespace common\components;


use common\logic\Config\TaxRate\TaxRateContainer;
use common\logic\Distribution\Distribution\DistributionContainer;
use common\logic\Distribution\PointSaleDistribution\PointSaleDistributionContainer;
use common\logic\Distribution\ProductDistribution\ProductDistributionContainer;
use common\logic\Document\Document\DocumentContainer;
use common\logic\Order\Order\OrderContainer;
use common\logic\Order\Order\OrderManager;
use common\logic\Order\OrderStatusHistory\OrderStatusHistoryContainer;
use common\logic\Order\ProductOrder\ProductOrderContainer;
use common\logic\PointSale\PointSale\PointSaleContainer;
use common\logic\Producer\Producer\Producer;
use common\logic\Producer\Producer\ProducerContainer;
use common\logic\Producer\ProducerPriceRange\ProducerPriceRangeContainer;
use common\logic\Product\Product\ProductContainer;
use common\logic\Product\ProductCategory\ProductCategoryContainer;
use common\logic\Product\ProductPointSale\ProductPointSaleContainer;
use common\logic\Product\ProductPrice\ProductPriceContainer;
use common\logic\Subscription\ProductSubscription\ProductSubscriptionContainer;
use common\logic\Subscription\Subscription\SubscriptionContainer;
use common\logic\User\CreditHistory\CreditHistoryContainer;
use common\logic\User\User\UserContainer;
use common\logic\User\UserGroup\UserGroupContainer;
use common\logic\User\UserProducer\UserProducerContainer;
use common\logic\User\UserUserGroup\UserUserGroupContainer;
use common\logic\Producer\Producer\Model\Producer;
use yii\base\ErrorException; use yii\base\ErrorException;


class BusinessLogic class BusinessLogic

+ 46
- 46
common/components/BusinessLogicTrait.php View File



use common\logic\Config\TaxRate\TaxRateContainer; use common\logic\Config\TaxRate\TaxRateContainer;
use common\logic\Config\TaxRate\TaxRateManager; use common\logic\Config\TaxRate\TaxRateManager;
use common\logic\Distribution\Distribution\DistributionContainer;
use common\logic\Distribution\Distribution\DistributionManager; use common\logic\Distribution\Distribution\DistributionManager;
use common\logic\Distribution\PointSaleDistribution\PointSaleDistributionContainer;
use common\logic\Distribution\PointSaleDistribution\PointSaleDistributionManager;
use common\logic\Distribution\ProductDistribution\ProductDistributionContainer;
use common\logic\Distribution\ProductDistribution\ProductDistributionManager;
use common\logic\Document\DeliveryNote\DeliveryNoteManager;
use common\logic\Document\Document\DocumentContainer;
use common\logic\Document\Document\DocumentManager;
use common\logic\Document\Invoice\InvoiceManager;
use common\logic\Document\Invoice\QuotationManager;
use common\logic\Order\Order\OrderContainer;
use common\logic\Order\Order\OrderManager;
use common\logic\Order\OrderStatusHistory\OrderStatusHistoryContainer;
use common\logic\Order\OrderStatusHistory\OrderStatusHistoryManager;
use common\logic\Order\ProductOrder\ProductOrderContainer;
use common\logic\Order\ProductOrder\ProductOrderManager;
use common\logic\PointSale\PointSale\PointSaleContainer;
use common\logic\PointSale\PointSale\PointSaleManager;
use common\logic\PointSale\UserPointSale\UserPointSaleContainer;
use common\logic\PointSale\UserPointSale\UserPointSaleManager;
use common\logic\Producer\Producer\ProducerContainer;
use common\logic\Producer\Producer\ProducerManager;
use common\logic\Producer\ProducerPriceRange\ProducerPriceRangeContainer;
use common\logic\Producer\ProducerPriceRange\ProducerPriceRangeManager;
use common\logic\Product\Product\ProductContainer;
use common\logic\Product\Product\ProductManager;
use common\logic\Product\ProductCategory\ProductCategoryContainer;
use common\logic\Product\ProductCategory\ProductCategoryManager;
use common\logic\Product\ProductPointSale\ProductPointSaleContainer;
use common\logic\Product\ProductPointSale\ProductPointSaleManager;
use common\logic\Product\ProductPrice\ProductPriceContainer;
use common\logic\Product\ProductPrice\ProductPriceManager;
use common\logic\Subscription\ProductSubscription\ProductSubscriptionContainer;
use common\logic\Subscription\ProductSubscription\ProductSubscriptionManager;
use common\logic\Subscription\Subscription\SubscriptionContainer;
use common\logic\Subscription\Subscription\SubscriptionManager;
use common\logic\User\CreditHistory\CreditHistoryContainer;
use common\logic\User\CreditHistory\CreditHistoryManager;
use common\logic\User\User\UserContainer;
use common\logic\User\User\UserManager;
use common\logic\User\UserGroup\UserGroupContainer;
use common\logic\User\UserGroup\UserGroupManager;
use common\logic\User\UserProducer\UserProducerContainer;
use common\logic\User\UserProducer\UserProducerManager;
use common\logic\User\UserUserGroup\UserUserGroupContainer;
use common\logic\User\UserUserGroup\UserUserGroupManager;
use common\logic\Distribution\Distribution\Wrapper\DistributionContainer;
use common\logic\Distribution\PointSaleDistribution\Wrapper\PointSaleDistributionContainer;
use common\logic\Distribution\PointSaleDistribution\Wrapper\PointSaleDistributionManager;
use common\logic\Distribution\ProductDistribution\Wrapper\ProductDistributionContainer;
use common\logic\Distribution\ProductDistribution\Wrapper\ProductDistributionManager;
use common\logic\Document\DeliveryNote\Wrapper\DeliveryNoteManager;
use common\logic\Document\Document\Wrapper\DocumentContainer;
use common\logic\Document\Document\Wrapper\DocumentManager;
use common\logic\Document\Invoice\Wrapper\InvoiceManager;
use common\logic\Document\Invoice\Wrapper\QuotationManager;
use common\logic\Order\Order\Wrapper\OrderContainer;
use common\logic\Order\Order\Wrapper\OrderManager;
use common\logic\Order\OrderStatusHistory\Wrapper\OrderStatusHistoryContainer;
use common\logic\Order\OrderStatusHistory\Wrapper\OrderStatusHistoryManager;
use common\logic\Order\ProductOrder\Wrapper\ProductOrderContainer;
use common\logic\Order\ProductOrder\Wrapper\ProductOrderManager;
use common\logic\PointSale\PointSale\Wrapper\PointSaleContainer;
use common\logic\PointSale\PointSale\Wrapper\PointSaleManager;
use common\logic\PointSale\UserPointSale\Wrapper\UserPointSaleContainer;
use common\logic\PointSale\UserPointSale\Wrapper\UserPointSaleManager;
use common\logic\Producer\Producer\Wrapper\ProducerContainer;
use common\logic\Producer\Producer\Wrapper\ProducerManager;
use common\logic\Producer\ProducerPriceRange\Wrapper\ProducerPriceRangeContainer;
use common\logic\Producer\ProducerPriceRange\Wrapper\ProducerPriceRangeManager;
use common\logic\Product\Product\Wrapper\ProductContainer;
use common\logic\Product\Product\Wrapper\ProductManager;
use common\logic\Product\ProductCategory\Wrapper\ProductCategoryContainer;
use common\logic\Product\ProductCategory\Wrapper\ProductCategoryManager;
use common\logic\Product\ProductPointSale\Wrapper\ProductPointSaleContainer;
use common\logic\Product\ProductPointSale\Wrapper\ProductPointSaleManager;
use common\logic\Product\ProductPrice\Wrapper\ProductPriceContainer;
use common\logic\Product\ProductPrice\Wrapper\ProductPriceManager;
use common\logic\Subscription\ProductSubscription\Wrapper\ProductSubscriptionContainer;
use common\logic\Subscription\ProductSubscription\Wrapper\ProductSubscriptionManager;
use common\logic\Subscription\Subscription\Wrapper\SubscriptionContainer;
use common\logic\Subscription\Subscription\Wrapper\SubscriptionManager;
use common\logic\User\CreditHistory\Wrapper\CreditHistoryContainer;
use common\logic\User\CreditHistory\Wrapper\CreditHistoryManager;
use common\logic\User\User\Wrapper\UserContainer;
use common\logic\User\User\Wrapper\UserManager;
use common\logic\User\UserGroup\Wrapper\UserGroupContainer;
use common\logic\User\UserGroup\Wrapper\UserGroupManager;
use common\logic\User\UserProducer\Wrapper\UserProducerContainer;
use common\logic\User\UserProducer\Wrapper\UserProducerManager;
use common\logic\User\UserUserGroup\Wrapper\UserUserGroupContainer;
use common\logic\User\UserUserGroup\Wrapper\UserUserGroupManager;


trait BusinessLogicTrait trait BusinessLogicTrait
{ {

+ 1
- 1
common/config/main.php View File

], ],
'user' => [ 'user' => [
'class' => 'yii\web\User', 'class' => 'yii\web\User',
'identityClass' => 'common\logic\User\User\User',
'identityClass' => 'common\logic\User\User\Model\User',
'enableAutoLogin' => true, 'enableAutoLogin' => true,
'identityCookie' => [ 'identityCookie' => [
'name' => 'distrib', 'name' => 'distrib',

+ 1
- 1
common/controllers/CommonController.php View File



use common\components\BusinessLogic; use common\components\BusinessLogic;
use common\components\BusinessLogicTrait; use common\components\BusinessLogicTrait;
use common\logic\User\User\User;
use common\logic\User\User\Model\User;
use yii; use yii;


class CommonController extends \yii\web\Controller class CommonController extends \yii\web\Controller

+ 2
- 2
common/forms/LoginForm.php View File



namespace common\forms; namespace common\forms;


use common\logic\Producer\Producer\Producer;
use common\logic\User\User\User;
use common\logic\Producer\Producer\Model\Producer;
use common\logic\User\User\Model\User;
use Yii; use Yii;
use yii\base\Model; use yii\base\Model;



+ 2
- 2
common/helpers/GlobalParam.php View File



namespace common\helpers; namespace common\helpers;


use common\logic\Producer\Producer\Producer;
use common\logic\User\User\UserSolver;
use common\logic\Producer\Producer\Model\Producer;
use common\logic\User\User\Service\UserSolver;


class GlobalParam class GlobalParam
{ {

+ 7
- 3
common/helpers/Tiller.php View File



namespace common\helpers; namespace common\helpers;


use common\logic\Order\Order\Order;
use common\logic\Producer\Producer\Producer; use common\logic\Producer\Producer\Producer;
use common\logic\Producer\Producer\ProducerManager;
use linslin\yii2\curl; use linslin\yii2\curl;


class Tiller class Tiller


public function __construct() public function __construct()
{ {
$producerManager = ProducerManager::getInstance();

$this->curl = new curl\Curl(); $this->curl = new curl\Curl();
$this->producer_tiller = Producer::getConfig('tiller');
$this->provider_token = Producer::getConfig('tiller_provider_token');
$this->restaurant_token = Producer::getConfig('tiller_restaurant_token');
$this->producer_tiller = $producerManager->getConfig('tiller');
$this->provider_token = $producerManager->getConfig('tiller_provider_token');
$this->restaurant_token = $producerManager->getConfig('tiller_restaurant_token');
} }


public function getOrders($date) public function getOrders($date)

+ 11
- 0
common/logic/Distribution/Distribution/Event/DistributionActiveEvent.php View File

<?php

namespace common\logic\Distribution\Distribution\Event;

use common\logic\Distribution\Distribution\Model\Distribution;
use yii\base\Event;

class DistributionActiveEvent extends Event
{
public Distribution $distribution;
}

common/logic/Distribution/Distribution/Distribution.php → common/logic/Distribution/Distribution/Model/Distribution.php View File

* termes. * termes.
*/ */


namespace common\logic\Distribution\Distribution;
namespace common\logic\Distribution\Distribution\Model;


use common\logic\Distribution\PointSaleDistribution\PointSaleDistribution;
use common\logic\Distribution\ProductDistribution\ProductDistribution;
use common\logic\Order\Order\Order;
use common\logic\Producer\Producer\Producer;
use common\components\ActiveRecordCommon; use common\components\ActiveRecordCommon;
use common\logic\Subscription\Subscription\SubscriptionEventSubscriber;
use common\logic\Distribution\PointSaleDistribution\Model\PointSaleDistribution;
use common\logic\Distribution\ProductDistribution\Model\ProductDistribution;
use common\logic\Order\Order\Model\Order;
use common\logic\Producer\Producer\Model\Producer;
use common\logic\Subscription\Subscription\Event\SubscriptionEventSubscriber;


class Distribution extends ActiveRecordCommon class Distribution extends ActiveRecordCommon
{ {

common/logic/Distribution/Distribution/DistributionRepository.php → common/logic/Distribution/Distribution/Repository/DistributionRepository.php View File

<?php <?php


namespace common\logic\Distribution\Distribution;
namespace common\logic\Distribution\Distribution\Repository;


use common\helpers\GlobalParam; use common\helpers\GlobalParam;
use common\logic\AbstractRepository; use common\logic\AbstractRepository;
use common\logic\Producer\Producer\Producer;
use common\logic\Subscription\Subscription\Subscription;
use common\logic\Subscription\Subscription\SubscriptionSolver;
use common\logic\Distribution\Distribution\Model\Distribution;
use common\logic\Distribution\Distribution\Service\DistributionSolver;
use common\logic\Producer\Producer\Model\Producer;
use common\logic\Subscription\Subscription\Model\Subscription;
use common\logic\Subscription\Subscription\Service\SubscriptionSolver;


class DistributionRepository extends AbstractRepository class DistributionRepository extends AbstractRepository
{ {


$incomingDistributions->params($params); $incomingDistributions->params($params);
$incomingDistributionsArray = $incomingDistributions->all(); $incomingDistributionsArray = $incomingDistributions->all();
$this->subscriptionSolver->filterDistributionsByDateDelay($incomingDistributionsArray);
$this->distributionSolver->filterDistributionsByDateDelay($incomingDistributionsArray);


$matchedIncomingDistributionsArray = []; $matchedIncomingDistributionsArray = [];
foreach ($incomingDistributionsArray as $incomingDistribution) { foreach ($incomingDistributionsArray as $incomingDistribution) {
if ($this->subscriptionSolver->matchWith($subscription, $incomingDistribution->date)) {
if ($this->subscriptionSolver->isSubscriptionMatchWith($subscription, $incomingDistribution->date)) {
$matchedIncomingDistributionsArray[] = $incomingDistribution; $matchedIncomingDistributionsArray[] = $incomingDistribution;
} }
} }

common/logic/Distribution/Distribution/DistributionRepositoryQuery.php → common/logic/Distribution/Distribution/Repository/DistributionRepositoryQuery.php View File

<?php <?php


namespace common\logic\Distribution\Distribution;
namespace common\logic\Distribution\Distribution\Repository;


use common\logic\AbstractRepositoryQuery; use common\logic\AbstractRepositoryQuery;



common/logic/Distribution/Distribution/DistributionBuilder.php → common/logic/Distribution/Distribution/Service/DistributionBuilder.php View File

<?php <?php


namespace common\logic\Distribution\Distribution;
namespace common\logic\Distribution\Distribution\Service;


use common\logic\AbstractBuilder; use common\logic\AbstractBuilder;
use common\logic\Distribution\PointSaleDistribution\PointSaleDistribution;
use common\logic\Distribution\PointSaleDistribution\PointSaleDistributionBuilder;
use common\logic\Distribution\PointSaleDistribution\PointSaleDistributionRepository;
use common\logic\Distribution\ProductDistribution\ProductDistribution;
use common\logic\Distribution\ProductDistribution\ProductDistributionBuilder;
use common\logic\Distribution\ProductDistribution\ProductDistributionRepository;
use common\logic\Order\Order\OrderRepository;
use common\logic\Order\ProductOrder\ProductOrderBuilder;
use common\logic\PointSale\PointSale\PointSale;
use common\logic\Producer\Producer\Producer;
use common\logic\Product\Product\Product;
use common\logic\Product\Product\ProductRepository;
use common\logic\User\UserProducer\UserProducerRepository;
use yii\base\Event;
use common\logic\Distribution\Distribution\Event\DistributionActiveEvent;
use common\logic\Distribution\Distribution\Model\Distribution;
use common\logic\Distribution\Distribution\Repository\DistributionRepository;
use common\logic\Distribution\PointSaleDistribution\Repository\PointSaleDistributionRepository;
use common\logic\Distribution\PointSaleDistribution\Service\PointSaleDistributionBuilder;
use common\logic\Distribution\ProductDistribution\Repository\ProductDistributionRepository;
use common\logic\Distribution\ProductDistribution\Service\ProductDistributionBuilder;
use common\logic\Order\Order\Repository\OrderRepository;
use common\logic\Order\ProductOrder\Service\ProductOrderBuilder;
use common\logic\Product\Product\Repository\ProductRepository;
use common\logic\User\UserProducer\Repository\UserProducerRepository;


class DistributionBuilder extends AbstractBuilder class DistributionBuilder extends AbstractBuilder
{ {
$this->pointSaleDistributionBuilder = $this->loadService(PointSaleDistributionBuilder::class); $this->pointSaleDistributionBuilder = $this->loadService(PointSaleDistributionBuilder::class);
$this->productRepository = $this->loadService(ProductRepository::class); $this->productRepository = $this->loadService(ProductRepository::class);
$this->productDistributionRepository = $this->loadService(ProductDistributionRepository::class); $this->productDistributionRepository = $this->loadService(ProductDistributionRepository::class);
$this->productDistributionBuilder = $this->loadService(ProductDistributionBuilder::class);
$this->orderRepository = $this->loadService(OrderRepository::class); $this->orderRepository = $this->loadService(OrderRepository::class);
$this->userProducerRepository = $this->loadService(UserProducerRepository::class); $this->userProducerRepository = $this->loadService(UserProducerRepository::class);
$this->productOrderBuilder = $this->loadService(ProductOrderBuilder::class); $this->productOrderBuilder = $this->loadService(ProductOrderBuilder::class);
$this->saveUpdate($distribution); $this->saveUpdate($distribution);


if ($active) { if ($active) {
$distribution->trigger(Distribution::EVENT_ACTIVE, new Event(['distribution' => $distribution]));
$distributionActiveEvent = new DistributionActiveEvent();
$distributionActiveEvent->distribution = $distribution;

$distribution->trigger(Distribution::EVENT_ACTIVE, $distributionActiveEvent);
} }
} }
} }

common/logic/Distribution/Distribution/DistributionSolver.php → common/logic/Distribution/Distribution/Service/DistributionSolver.php View File

<?php <?php


namespace common\logic\Distribution\Distribution;
namespace common\logic\Distribution\Distribution\Service;


use common\helpers\GlobalParam; use common\helpers\GlobalParam;
use common\logic\AbstractService; use common\logic\AbstractService;
use common\logic\Distribution\Distribution\Model\Distribution;
use common\logic\PointSale\PointSale\PointSale; use common\logic\PointSale\PointSale\PointSale;
use common\logic\Product\Product\Product; use common\logic\Product\Product\Product;
use common\logic\SolverInterface; use common\logic\SolverInterface;

common/logic/Distribution/Distribution/DistributionContainer.php → common/logic/Distribution/Distribution/Wrapper/DistributionContainer.php View File

<?php <?php


namespace common\logic\Distribution\Distribution;
namespace common\logic\Distribution\Distribution\Wrapper;


use common\logic\AbstractContainer; use common\logic\AbstractContainer;
use common\logic\Distribution\Distribution\Model\Distribution;
use common\logic\Distribution\Distribution\Repository\DistributionRepository;
use common\logic\Distribution\Distribution\Service\DistributionBuilder;
use common\logic\Distribution\Distribution\Service\DistributionSolver;


class DistributionContainer extends AbstractContainer class DistributionContainer extends AbstractContainer
{ {

common/logic/Distribution/Distribution/DistributionManager.php → common/logic/Distribution/Distribution/Wrapper/DistributionManager.php View File

namespace common\logic\Distribution\Distribution; namespace common\logic\Distribution\Distribution;


use common\logic\AbstractManager; use common\logic\AbstractManager;
use common\logic\Distribution\Distribution\Repository\DistributionRepository;
use common\logic\Distribution\Distribution\Service\DistributionBuilder;
use common\logic\Distribution\Distribution\Service\DistributionSolver;
use common\logic\Distribution\Distribution\Wrapper\DistributionContainer;


/** /**
* @mixin DistributionSolver * @mixin DistributionSolver

common/logic/Distribution/PointSaleDistribution/PointSaleDistribution.php → common/logic/Distribution/PointSaleDistribution/Model/PointSaleDistribution.php View File

termes. termes.
*/ */


namespace common\logic\Distribution\PointSaleDistribution;
namespace common\logic\Distribution\PointSaleDistribution\Model;


use common\components\ActiveRecordCommon ; use common\components\ActiveRecordCommon ;
use common\logic\Distribution\Distribution\Distribution;
use common\logic\Distribution\Distribution\Model\Distribution;
use common\logic\PointSale\PointSale\PointSale; use common\logic\PointSale\PointSale\PointSale;


class PointSaleDistribution extends ActiveRecordCommon class PointSaleDistribution extends ActiveRecordCommon

common/logic/Distribution/PointSaleDistribution/PointSaleDistributionRepository.php → common/logic/Distribution/PointSaleDistribution/Repository/PointSaleDistributionRepository.php View File

<?php <?php


namespace common\logic\Distribution\PointSaleDistribution;
namespace common\logic\Distribution\PointSaleDistribution\Repository;


use common\logic\AbstractRepository; use common\logic\AbstractRepository;
use common\logic\Distribution\Distribution\Distribution;
use common\logic\Distribution\Distribution\Model\Distribution;
use common\logic\Distribution\PointSaleDistribution\Model\PointSaleDistribution;
use common\logic\PointSale\PointSale\PointSale; use common\logic\PointSale\PointSale\PointSale;


class PointSaleDistributionRepository extends AbstractRepository class PointSaleDistributionRepository extends AbstractRepository

common/logic/Distribution/PointSaleDistribution/PointSaleDistributionRepositoryQuery.php → common/logic/Distribution/PointSaleDistribution/Repository/PointSaleDistributionRepositoryQuery.php View File

<?php <?php


namespace common\logic\Distribution\PointSaleDistribution;
namespace common\logic\Distribution\PointSaleDistribution\Repository;


use common\logic\AbstractRepositoryQuery; use common\logic\AbstractRepositoryQuery;



common/logic/Distribution/PointSaleDistribution/PointSaleDistributionBuilder.php → common/logic/Distribution/PointSaleDistribution/Service/PointSaleDistributionBuilder.php View File

<?php <?php


namespace common\logic\Distribution\PointSaleDistribution;
namespace common\logic\Distribution\PointSaleDistribution\Service;


use common\logic\AbstractBuilder; use common\logic\AbstractBuilder;
use common\logic\Distribution\Distribution\Distribution;
use common\logic\Distribution\Distribution\DistributionRepository;
use common\logic\PointSale\PointSale\PointSale;
use common\logic\PointSale\PointSale\PointSaleRepository;
use common\logic\Distribution\Distribution\Model\Distribution;
use common\logic\Distribution\Distribution\Repository\DistributionRepository;
use common\logic\Distribution\PointSaleDistribution\Model\PointSaleDistribution;
use common\logic\Distribution\PointSaleDistribution\Repository\PointSaleDistributionRepository;
use common\logic\PointSale\PointSale\Repository\PointSaleRepository;


class PointSaleDistributionBuilder extends AbstractBuilder class PointSaleDistributionBuilder extends AbstractBuilder
{ {
// setAll // setAll
public function createAllPointSaleDistributions(Distribution $distribution, bool $delivery): void public function createAllPointSaleDistributions(Distribution $distribution, bool $delivery): void
{ {
$pointSaleArray = $this->pointSaleRepository->findPointSaleDistributionsByDistribution($distribution);
$pointSaleArray = $this->pointSaleDistributionRepository->findPointSaleDistributionsByDistribution($distribution);
foreach ($pointSaleArray as $pointSale) { foreach ($pointSaleArray as $pointSale) {
if (!$pointSale->pointSaleDistribution) { if (!$pointSale->pointSaleDistribution) {
$this->createPointSaleDistribution($distribution, $pointSale); $this->createPointSaleDistribution($distribution, $pointSale);

common/logic/Distribution/PointSaleDistribution/PointSaleDistributionContainer.php → common/logic/Distribution/PointSaleDistribution/Wrapper/PointSaleDistributionContainer.php View File

<?php <?php


namespace common\logic\Distribution\PointSaleDistribution;
namespace common\logic\Distribution\PointSaleDistribution\Wrapper;


use common\logic\AbstractContainer; use common\logic\AbstractContainer;
use common\logic\Distribution\PointSaleDistribution\Model\PointSaleDistribution;
use common\logic\Distribution\PointSaleDistribution\Repository\PointSaleDistributionRepository;
use common\logic\Distribution\PointSaleDistribution\Service\PointSaleDistributionBuilder;


class PointSaleDistributionContainer extends AbstractContainer class PointSaleDistributionContainer extends AbstractContainer
{ {

common/logic/Distribution/PointSaleDistribution/PointSaleDistributionManager.php → common/logic/Distribution/PointSaleDistribution/Wrapper/PointSaleDistributionManager.php View File

<?php <?php


namespace common\logic\Distribution\PointSaleDistribution;
namespace common\logic\Distribution\PointSaleDistribution\Wrapper;


use common\logic\AbstractManager; use common\logic\AbstractManager;
use common\logic\Distribution\PointSaleDistribution\Repository\PointSaleDistributionRepository;
use common\logic\Distribution\PointSaleDistribution\Service\PointSaleDistributionBuilder;


/** /**
* @mixin PointSaleDistributionRepository * @mixin PointSaleDistributionRepository

common/logic/Distribution/ProductDistribution/ProductDistribution.php → common/logic/Distribution/ProductDistribution/Model/ProductDistribution.php View File

termes. termes.
*/ */


namespace common\logic\Distribution\ProductDistribution;
namespace common\logic\Distribution\ProductDistribution\Model;


use common\components\ActiveRecordCommon ; use common\components\ActiveRecordCommon ;
use common\logic\Distribution\Distribution\Distribution;
use common\logic\Distribution\Distribution\Model\Distribution;
use common\logic\Product\Product\Product; use common\logic\Product\Product\Product;


class ProductDistribution extends ActiveRecordCommon class ProductDistribution extends ActiveRecordCommon

common/logic/Distribution/ProductDistribution/ProductDistributionRepository.php → common/logic/Distribution/ProductDistribution/Repository/ProductDistributionRepository.php View File

<?php <?php


namespace common\logic\Distribution\ProductDistribution;
namespace common\logic\Distribution\ProductDistribution\Repository;


use common\logic\AbstractRepository; use common\logic\AbstractRepository;
use common\logic\Distribution\Distribution\Distribution;
use common\logic\Distribution\Distribution\Model\Distribution;
use common\logic\Distribution\ProductDistribution\Model\ProductDistribution;
use common\logic\Product\Product\Product; use common\logic\Product\Product\Product;


class ProductDistributionRepository extends AbstractRepository class ProductDistributionRepository extends AbstractRepository

common/logic/Distribution/ProductDistribution/ProductDistributionRepositoryQuery.php → common/logic/Distribution/ProductDistribution/Repository/ProductDistributionRepositoryQuery.php View File

<?php <?php


namespace common\logic\Distribution\ProductDistribution;
namespace common\logic\Distribution\ProductDistribution\Repository;


use common\logic\AbstractRepositoryQuery; use common\logic\AbstractRepositoryQuery;



common/logic/Distribution/ProductDistribution/ProductDistributionBuilder.php → common/logic/Distribution/ProductDistribution/Service/ProductDistributionBuilder.php View File

<?php <?php


namespace common\logic\Distribution\ProductDistribution;
namespace common\logic\Distribution\ProductDistribution\Service;


use common\logic\AbstractBuilder; use common\logic\AbstractBuilder;
use common\logic\BuilderInterface;
use common\logic\Distribution\Distribution\Distribution;
use common\logic\Distribution\Distribution\DistributionSolver;
use common\logic\Product\Product\Product;
use common\logic\Product\Product\ProductSolver;
use common\logic\Distribution\Distribution\Model\Distribution;
use common\logic\Distribution\Distribution\Service\DistributionSolver;
use common\logic\Distribution\ProductDistribution\Model\ProductDistribution;
use common\logic\Distribution\ProductDistribution\Repository\ProductDistributionRepository;
use common\logic\Product\Product\Model\Product;
use common\logic\Product\Product\Service\ProductSolver;


class ProductDistributionBuilder extends AbstractBuilder class ProductDistributionBuilder extends AbstractBuilder
{ {

common/logic/Distribution/ProductDistribution/ProductDistributionContainer.php → common/logic/Distribution/ProductDistribution/Wrapper/ProductDistributionContainer.php View File

<?php <?php


namespace common\logic\Distribution\ProductDistribution;
namespace common\logic\Distribution\ProductDistribution\Wrapper;


use common\logic\AbstractContainer; use common\logic\AbstractContainer;
use common\logic\Distribution\ProductDistribution\Model\ProductDistribution;
use common\logic\Distribution\ProductDistribution\Repository\ProductDistributionRepository;
use common\logic\Distribution\ProductDistribution\Service\ProductDistributionBuilder;


class ProductDistributionContainer extends AbstractContainer class ProductDistributionContainer extends AbstractContainer
{ {

common/logic/Distribution/ProductDistribution/ProductDistributionManager.php → common/logic/Distribution/ProductDistribution/Wrapper/ProductDistributionManager.php View File

<?php <?php


namespace common\logic\Distribution\ProductDistribution;
namespace common\logic\Distribution\ProductDistribution\Wrapper;


use common\logic\AbstractManager; use common\logic\AbstractManager;
use common\logic\Distribution\ProductDistribution\Repository\ProductDistributionRepository;
use common\logic\Distribution\ProductDistribution\Service\ProductDistributionBuilder;


/** /**
* @mixin ProductDistributionRepository * @mixin ProductDistributionRepository

common/logic/Document/DeliveryNote/DeliveryNote.php → common/logic/Document/DeliveryNote/Model/DeliveryNote.php View File

* termes. * termes.
*/ */


namespace common\logic\Document\DeliveryNote;
namespace common\logic\Document\DeliveryNote\Model;


use common\logic\Document\Document\Document; use common\logic\Document\Document\Document;



common/logic/Document/DeliveryNote/DeliveryNoteSearch.php → common/logic/Document/DeliveryNote/Model/DeliveryNoteSearch.php View File

* termes. * termes.
*/ */


namespace common\logic\Document\DeliveryNote;
namespace common\logic\Document\DeliveryNote\Model;


use common\helpers\GlobalParam; use common\helpers\GlobalParam;
use common\logic\PointSale\PointSale\DeliveryNoteRepository;
use common\logic\Document\DeliveryNote\Repository\DeliveryNoteRepository;
use yii\data\ActiveDataProvider; use yii\data\ActiveDataProvider;


class DeliveryNoteSearch extends DeliveryNote class DeliveryNoteSearch extends DeliveryNote

common/logic/Document/DeliveryNote/DeliveryNoteRepository.php → common/logic/Document/DeliveryNote/Repository/DeliveryNoteRepository.php View File

<?php <?php


namespace common\logic\Document\DeliveryNote;
namespace common\logic\Document\DeliveryNote\Repository;


use common\logic\AbstractRepository; use common\logic\AbstractRepository;
use common\logic\Document\DeliveryNote\Model\DeliveryNote;


class DeliveryNoteRepository extends AbstractRepository class DeliveryNoteRepository extends AbstractRepository
{ {

common/logic/Document/DeliveryNote/DeliveryNoteRepositoryQuery.php → common/logic/Document/DeliveryNote/Repository/DeliveryNoteRepositoryQuery.php View File

<?php <?php


namespace common\logic\Document\DeliveryNote;
namespace common\logic\Document\DeliveryNote\Repository;


use common\logic\AbstractRepositoryQuery; use common\logic\AbstractRepositoryQuery;



common/logic/Document/DeliveryNote/DeliveryNoteBuilder.php → common/logic/Document/DeliveryNote/Service/DeliveryNoteBuilder.php View File

<?php <?php


namespace common\logic\Document\DeliveryNote;
namespace common\logic\Document\DeliveryNote\Service;


use common\logic\Document\DeliveryNote\Model\DeliveryNote;
use common\logic\Document\Document\DocumentBuilder; use common\logic\Document\Document\DocumentBuilder;


class DeliveryNoteBuilder extends DocumentBuilder class DeliveryNoteBuilder extends DocumentBuilder

common/logic/Document/DeliveryNote/DeliveryNoteSolver.php → common/logic/Document/DeliveryNote/Service/DeliveryNoteSolver.php View File

<?php <?php


namespace common\logic\Document\DeliveryNote;
namespace common\logic\Document\DeliveryNote\Service;


use common\logic\Document\DeliveryNote\Model\DeliveryNote;
use common\logic\Document\Document\DocumentSolver; use common\logic\Document\Document\DocumentSolver;
use common\logic\Document\Invoice\Invoice; use common\logic\Document\Invoice\Invoice;
use common\logic\SolverInterface; use common\logic\SolverInterface;

common/logic/Document/DeliveryNote/DeliveryNoteContainer.php → common/logic/Document/DeliveryNote/Wrapper/DeliveryNoteContainer.php View File

<?php <?php


namespace common\logic\Document\DeliveryNote;
namespace common\logic\Document\DeliveryNote\Wrapper;


use common\logic\AbstractContainer; use common\logic\AbstractContainer;
use common\logic\Document\DeliveryNote\Model\DeliveryNote;
use common\logic\Document\DeliveryNote\Service\DeliveryNoteBuilder;
use common\logic\Document\DeliveryNote\Service\DeliveryNoteSolver;


class DeliveryNoteContainer extends AbstractContainer class DeliveryNoteContainer extends AbstractContainer
{ {

common/logic/Document/DeliveryNote/DeliveryNoteManager.php → common/logic/Document/DeliveryNote/Wrapper/DeliveryNoteManager.php View File

<?php <?php


namespace common\logic\Document\DeliveryNote;
namespace common\logic\Document\DeliveryNote\Wrapper;


use common\logic\Document\DeliveryNote\Repository\DeliveryNoteRepository;
use common\logic\Document\DeliveryNote\Service\DeliveryNoteBuilder;
use common\logic\Document\DeliveryNote\Service\DeliveryNoteSolver;
use common\logic\Document\Document\DocumentManager; use common\logic\Document\Document\DocumentManager;
use common\logic\PointSale\PointSale\DeliveryNoteRepository;


/** /**
* @mixin DeliveryNoteSolver * @mixin DeliveryNoteSolver

+ 0
- 8
common/logic/Document/Document/DocumentInterface.php View File

<?php

namespace common\logic\Document\Document;

interface DocumentInterface
{

}

common/logic/Document/Document/Document.php → common/logic/Document/Document/Model/Document.php View File

* termes. * termes.
*/ */


namespace common\logic\Document\Document;
namespace common\logic\Document\Document\Model;


use common\components\ActiveRecordCommon; use common\components\ActiveRecordCommon;
use common\helpers\GlobalParam;
use common\logic\Order\Order\Order;
use common\logic\Order\Order\OrderRepository;
use common\logic\Producer\Producer\Producer;
use common\logic\User\User\User;
use kartik\mpdf\Pdf;
use yii\base\ErrorException;
use common\logic\Order\Order\Model\Order;
use common\logic\Order\Order\Repository\OrderRepository;
use common\logic\Producer\Producer\Model\Producer;
use common\logic\User\User\Model\User;


class Document extends ActiveRecordCommon implements DocumentInterface class Document extends ActiveRecordCommon implements DocumentInterface
{ {

+ 8
- 0
common/logic/Document/Document/Model/DocumentInterface.php View File

<?php

namespace common\logic\Document\Document\Model;

interface DocumentInterface
{

}

common/logic/Document/Document/DocumentBuilder.php → common/logic/Document/Document/Service/DocumentBuilder.php View File

<?php <?php


namespace common\logic\Document\Document;
namespace common\logic\Document\Document\Service;


use common\logic\AbstractBuilder; use common\logic\AbstractBuilder;
use common\logic\Producer\Producer\ProducerRepository;
use common\logic\Document\Document\Model\Document;
use common\logic\Document\Document\Model\DocumentInterface;
use common\logic\Producer\Producer\Repository\ProducerRepository;


class DocumentBuilder extends AbstractBuilder class DocumentBuilder extends AbstractBuilder
{ {

common/logic/Document/Document/DocumentSolver.php → common/logic/Document/Document/Service/DocumentSolver.php View File

<?php <?php


namespace common\logic\Document\Document;
namespace common\logic\Document\Document\Service;


use common\helpers\Price; use common\helpers\Price;
use common\logic\AbstractService; use common\logic\AbstractService;
use common\logic\Document\Document\Model\Document;
use common\logic\Document\Document\Model\DocumentInterface;
use common\logic\Order\Order\Order; use common\logic\Order\Order\Order;
use common\logic\PointSale\PointSale\PointSale; use common\logic\PointSale\PointSale\PointSale;
use common\logic\SolverInterface; use common\logic\SolverInterface;

common/logic/Document/Document/DocumentUtils.php → common/logic/Document/Document/Service/DocumentUtils.php View File

<?php <?php


namespace common\logic\Document\Document;
namespace common\logic\Document\Document\Service;


use common\helpers\GlobalParam; use common\helpers\GlobalParam;
use common\logic\AbstractService; use common\logic\AbstractService;
use common\logic\Producer\Producer\ProducerRepository;
use common\logic\Producer\Producer\ProducerSolver;
use common\logic\Document\Document\Model\DocumentInterface;
use common\logic\Producer\Producer\Repository\ProducerRepository;
use common\logic\Producer\Producer\Service\ProducerSolver;
use common\logic\UtilsInterface; use common\logic\UtilsInterface;
use kartik\mpdf\Pdf; use kartik\mpdf\Pdf;
use yii\base\ErrorException; use yii\base\ErrorException;
->setFrom([$producer->getEmailOpendistrib() => $producer->name]) ->setFrom([$producer->getEmailOpendistrib() => $producer->name])
->setSubject('[' . $producer->name . '] ' . $subjectEmail); ->setSubject('[' . $producer->name . '] ' . $subjectEmail);


$this->documentBuilder->generatePdf($document, Pdf::DEST_FILE);
$this->generatePdf($document, Pdf::DEST_FILE);
$email->attach($this->documentSolver->getFilenameComplete($document)); $email->attach($this->documentSolver->getFilenameComplete($document));


return $email->send(); return $email->send();

common/logic/Document/Document/DocumentContainer.php → common/logic/Document/Document/Wrapper/DocumentContainer.php View File

<?php <?php


namespace common\logic\Document\Document;
namespace common\logic\Document\Document\Wrapper;


use common\logic\AbstractContainer; use common\logic\AbstractContainer;
use common\logic\Document\Document\Model\Document;
use common\logic\Document\Document\Service\DocumentBuilder;
use common\logic\Document\Document\Service\DocumentSolver;
use common\logic\Document\Document\Service\DocumentUtils;


class DocumentContainer extends AbstractContainer class DocumentContainer extends AbstractContainer
{ {

common/logic/Document/Document/DocumentManager.php → common/logic/Document/Document/Wrapper/DocumentManager.php View File

<?php <?php


namespace common\logic\Document\Document;
namespace common\logic\Document\Document\Wrapper;


use common\logic\AbstractManager; use common\logic\AbstractManager;



+ 0
- 17
common/logic/Document/Invoice/InvoiceManager.php View File

<?php

namespace common\logic\Document\Invoice;

use common\logic\Document\Document\DocumentManager;

/**
* @mixin InvoiceRepository
* @mixin InvoiceBuilder
*/
class InvoiceManager extends DocumentManager
{
public function getContainerFqcn(): string
{
return InvoiceContainer::class;
}
}

common/logic/Document/Invoice/Invoice.php → common/logic/Document/Invoice/Model/Invoice.php View File

* termes. * termes.
*/ */


namespace common\logic\Document\Invoice;
namespace common\logic\Document\Invoice\Model;


use common\logic\Document\Document\Document;
use common\logic\Document\Document\Model\Document;


/** /**
* This is the model class for table "invoice". * This is the model class for table "invoice".

common/logic/Document/Invoice/InvoiceSearch.php → common/logic/Document/Invoice/Model/InvoiceSearch.php View File

* termes. * termes.
*/ */


namespace common\logic\Document\Invoice;
namespace common\logic\Document\Invoice\Model;


use common\helpers\GlobalParam; use common\helpers\GlobalParam;
use common\logic\PointSale\PointSale\InvoiceRepository;
use common\logic\Document\Invoice\Repository\InvoiceRepository;
use yii\data\ActiveDataProvider; use yii\data\ActiveDataProvider;


class InvoiceSearch extends Invoice class InvoiceSearch extends Invoice

common/logic/Document/Invoice/InvoiceRepository.php → common/logic/Document/Invoice/Repository/InvoiceRepository.php View File

<?php <?php


namespace common\logic\Document\Invoice;
namespace common\logic\Document\Invoice\Repository;


use common\logic\AbstractRepository; use common\logic\AbstractRepository;
use common\logic\Document\Invoice\Model\Invoice;


class InvoiceRepository extends AbstractRepository class InvoiceRepository extends AbstractRepository
{ {

common/logic/Document/Invoice/InvoiceRepositoryQuery.php → common/logic/Document/Invoice/Repository/InvoiceRepositoryQuery.php View File

<?php <?php


namespace common\logic\Document\Invoice;
namespace common\logic\Document\Invoice\Repository;


use common\logic\AbstractRepositoryQuery; use common\logic\AbstractRepositoryQuery;



common/logic/Document/Invoice/InvoiceBuilder.php → common/logic/Document/Invoice/Service/InvoiceBuilder.php View File

<?php <?php


namespace common\logic\Document\Invoice;
namespace common\logic\Document\Invoice\Service;


use common\logic\Document\Document\DocumentBuilder;
use common\logic\Document\Document\Service\DocumentBuilder;
use common\logic\Document\Invoice\Model\Invoice;


class InvoiceBuilder extends DocumentBuilder class InvoiceBuilder extends DocumentBuilder
{ {

common/logic/Document/Invoice/InvoiceContainer.php → common/logic/Document/Invoice/Wrapper/InvoiceContainer.php View File

<?php <?php


namespace common\logic\Document\Invoice;
namespace common\logic\Document\Invoice\Wrapper;


use common\logic\AbstractContainer; use common\logic\AbstractContainer;
use common\logic\Document\Document\DocumentSolver;
use common\logic\Document\Document\Service\DocumentSolver;
use common\logic\Document\Invoice\Model\Invoice;
use common\logic\Document\Invoice\Repository\InvoiceRepository;
use common\logic\Document\Invoice\Service\InvoiceBuilder;


class InvoiceContainer extends AbstractContainer class InvoiceContainer extends AbstractContainer
{ {

+ 19
- 0
common/logic/Document/Invoice/Wrapper/InvoiceManager.php View File

<?php

namespace common\logic\Document\Invoice\Wrapper;

use common\logic\Document\Document\Wrapper\DocumentManager;
use common\logic\Document\Invoice\Repository\InvoiceRepository;
use common\logic\Document\Invoice\Service\InvoiceBuilder;

/**
* @mixin InvoiceRepository
* @mixin InvoiceBuilder
*/
class InvoiceManager extends DocumentManager
{
public function getContainerFqcn(): string
{
return InvoiceContainer::class;
}
}

common/logic/Document/Quotation/Quotation.php → common/logic/Document/Quotation/Model/Quotation.php View File

* termes. * termes.
*/ */


namespace common\logic\Document\Quotation;
namespace common\logic\Document\Quotation\Model;


use common\logic\Document\Document\Document;
use common\logic\Document\Document\Model\Document;


/** /**
* This is the model class for table "quotation". * This is the model class for table "quotation".

common/logic/Document/Quotation/QuotationSearch.php → common/logic/Document/Quotation/Model/QuotationSearch.php View File

* termes. * termes.
*/ */


namespace common\logic\Document\Quotation;
namespace common\logic\Document\Quotation\Model;


use common\helpers\GlobalParam; use common\helpers\GlobalParam;
use common\logic\PointSale\PointSale\QuotationRepository;
use common\logic\PointSale\PointSale\Repository\QuotationRepository;
use yii\data\ActiveDataProvider; use yii\data\ActiveDataProvider;


class QuotationSearch extends Quotation class QuotationSearch extends Quotation

+ 0
- 19
common/logic/Document/Quotation/QuotationManager.php View File

<?php

namespace common\logic\Document\Invoice;

use common\logic\Document\Document\DocumentManager;
use common\logic\Document\Quotation\QuotationBuilder;
use common\logic\PointSale\PointSale\QuotationRepository;

/**
* @mixin QuotationRepository
* @mixin QuotationBuilder
*/
class QuotationManager extends DocumentManager
{
public function getContainerFqcn(): string
{
return QuotationContainer::class;
}
}

common/logic/Document/Quotation/QuotationRepository.php → common/logic/Document/Quotation/Repository/QuotationRepository.php View File

<?php <?php


namespace common\logic\PointSale\PointSale;
namespace common\logic\PointSale\PointSale\Repository;


use common\logic\AbstractRepository; use common\logic\AbstractRepository;
use common\logic\Document\Quotation\QuotationRepositoryQuery;
use common\logic\Document\Quotation\Repository\QuotationRepositoryQuery;


class QuotationRepository extends AbstractRepository class QuotationRepository extends AbstractRepository
{ {

common/logic/Document/Quotation/QuotationRepositoryQuery.php → common/logic/Document/Quotation/Repository/QuotationRepositoryQuery.php View File

<?php <?php


namespace common\logic\Document\Quotation;
namespace common\logic\Document\Quotation\Repository;


use common\logic\AbstractRepositoryQuery; use common\logic\AbstractRepositoryQuery;



common/logic/Document/Quotation/QuotationBuilder.php → common/logic/Document/Quotation/Service/QuotationBuilder.php View File

<?php <?php


namespace common\logic\Document\Quotation;
namespace common\logic\Document\Quotation\Service;


use common\logic\AbstractBuilder; use common\logic\AbstractBuilder;
use common\logic\Document\Quotation\Model\Quotation;


class QuotationBuilder extends AbstractBuilder class QuotationBuilder extends AbstractBuilder
{ {

common/logic/Document/Quotation/QuotationContainer.php → common/logic/Document/Quotation/Wrapper/QuotationContainer.php View File

<?php <?php


namespace common\logic\Document\Invoice;
namespace common\logic\Document\Invoice\Wrapper;


use common\logic\AbstractContainer; use common\logic\AbstractContainer;
use common\logic\Document\Document\DocumentSolver;
use common\logic\Document\Quotation\QuotationBuilder;
use common\logic\Document\Quotation\Quotation;
use common\logic\PointSale\PointSale\QuotationRepository;
use common\logic\Document\Document\Service\DocumentSolver;
use common\logic\Document\Quotation\Model\Quotation;
use common\logic\Document\Quotation\Service\QuotationBuilder;
use common\logic\PointSale\PointSale\Repository\QuotationRepository;


class QuotationContainer extends AbstractContainer class QuotationContainer extends AbstractContainer
{ {

+ 19
- 0
common/logic/Document/Quotation/Wrapper/QuotationManager.php View File

<?php

namespace common\logic\Document\Invoice\Wrapper;

use common\logic\Document\Document\Wrapper\DocumentManager;
use common\logic\Document\Quotation\Service\QuotationBuilder;
use common\logic\PointSale\PointSale\Repository\QuotationRepository;

/**
* @mixin QuotationRepository
* @mixin QuotationBuilder
*/
class QuotationManager extends DocumentManager
{
public function getContainerFqcn(): string
{
return QuotationContainer::class;
}
}

common/logic/Order/Order/Order.php → common/logic/Order/Order/Model/Order.php View File

* termes. * termes.
*/ */


namespace common\logic\Order\Order;
use common\logic\Distribution\Distribution\Distribution;
use common\logic\Document\DeliveryNote\DeliveryNote;
use common\logic\Document\Invoice\Invoice;
use common\logic\Document\Quotation\Quotation;
use common\logic\Order\ProductOrder\ProductOrder;
use common\logic\PointSale\PointSale\PointSale;
use common\logic\Subscription\Subscription\Subscription;
use common\logic\User\CreditHistory\CreditHistory;
use common\logic\User\User\User;
namespace common\logic\Order\Order\Model;
use common\logic\Distribution\Distribution\Model\Distribution;
use common\logic\Document\DeliveryNote\Model\DeliveryNote;
use common\logic\Document\Invoice\Model\Invoice;
use common\logic\Document\Quotation\Model\Quotation;
use common\logic\Order\ProductOrder\Model\ProductOrder;
use common\logic\PointSale\PointSale\Model\PointSale;
use common\logic\Subscription\Subscription\Model\Subscription;
use common\logic\User\CreditHistory\Model\CreditHistory;
use common\logic\User\User\Model\User;
use common\components\ActiveRecordCommon; use common\components\ActiveRecordCommon;


/** /**

common/logic/Order/Order/OrderSearch.php → common/logic/Order/Order/Model/OrderSearch.php View File

termes. termes.
*/ */


namespace common\logic\Order\Order ;
namespace common\logic\Order\Order\Model;


use common\logic\Order\Order\Repository\OrderRepository;
use yii\data\ActiveDataProvider; use yii\data\ActiveDataProvider;


class OrderSearch extends Order class OrderSearch extends Order

+ 0
- 27
common/logic/Order/Order/OrderManager.php View File

<?php

namespace common\logic\Order\Order;

use common\logic\AbstractManager;
use common\logic\Config\TaxRate\TaxRate;
use common\logic\Distribution\Distribution\Distribution;
use common\logic\Document\Document\Document;
use common\logic\Order\ProductOrder\ProductOrder;
use common\logic\Producer\Producer\Producer;
use common\logic\Product\Product\Product;
use common\logic\Subscription\Subscription\Subscription;
use common\logic\User\User\User;
use yii\db\Query;

/**
* @mixin OrderSolver
* @mixin OrderRepository
* @mixin OrderBuilder
*/
class OrderManager extends AbstractManager
{
public function getContainerFqcn(): string
{
return OrderContainer::class;
}
}

common/logic/Order/Order/OrderRepository.php → common/logic/Order/Order/Repository/OrderRepository.php View File

<?php <?php


namespace common\logic\Order\Order;
namespace common\logic\Order\Order\Repository;


use common\logic\AbstractRepository; use common\logic\AbstractRepository;
use common\logic\Distribution\Distribution\Distribution;
use common\logic\Distribution\ProductDistribution\ProductDistributionRepository;
use common\logic\Order\ProductOrder\ProductOrderRepository;
use common\logic\Producer\Producer\Producer;
use common\logic\Producer\Producer\ProducerRepository;
use common\logic\Product\Product\Product;
use common\logic\User\User\User;
use common\logic\Distribution\Distribution\Model\Distribution;
use common\logic\Distribution\ProductDistribution\Repository\ProductDistributionRepository;
use common\logic\Order\Order\Model\Order;
use common\logic\Order\Order\Service\OrderSolver;
use common\logic\Order\ProductOrder\Repository\ProductOrderRepository;
use common\logic\Producer\Producer\Model\Producer;
use common\logic\Producer\Producer\Repository\ProducerRepository;
use common\logic\Product\Product\Model\Product;
use common\logic\User\User\Model\User;
use yii\helpers\Html; use yii\helpers\Html;


class OrderRepository extends AbstractRepository class OrderRepository extends AbstractRepository
public function getCartSummary(Order $order, $htmlFormat = true): string public function getCartSummary(Order $order, $htmlFormat = true): string
{ {
if (!isset($order->productOrder)) { if (!isset($order->productOrder)) {
$order->productOrder = $this->productOrderRepository->getByOrder($order);
$order->productOrder = $this->productOrderRepository->findProductOrdersByOrder($order);
} }


$html = ''; $html = '';
{ {
$html = ''; $html = '';
$creditActive = $this->producerRepository->getConfig('credit'); $creditActive = $this->producerRepository->getConfig('credit');
$html .= $this->orderSolver->getAmountWithTax($order, Order::AMOUNT_TOTAL, true);
$html .= $this->orderSolver->getOrderAmountWithTax($order, Order::AMOUNT_TOTAL, true);


if ($creditActive) { if ($creditActive) {
$html .= '<br />'; $html .= '<br />';

common/logic/Order/Order/OrderRepositoryQuery.php → common/logic/Order/Order/Repository/OrderRepositoryQuery.php View File

<?php <?php


namespace common\logic\Order\Order;
namespace common\logic\Order\Order\Repository;


use common\logic\AbstractRepositoryQuery; use common\logic\AbstractRepositoryQuery;



common/logic/Order/Order/OrderBuilder.php → common/logic/Order/Order/Service/OrderBuilder.php View File

<?php <?php


namespace common\logic\Order\Order;
namespace common\logic\Order\Order\Service;


use common\helpers\GlobalParam; use common\helpers\GlobalParam;
use common\helpers\MeanPayment; use common\helpers\MeanPayment;
use common\helpers\Price; use common\helpers\Price;
use common\logic\AbstractBuilder; use common\logic\AbstractBuilder;
use common\logic\AbstractService;
use common\logic\BuilderInterface;
use common\logic\Config\TaxRate\TaxRate; use common\logic\Config\TaxRate\TaxRate;
use common\logic\Distribution\Distribution\Distribution;
use common\logic\Distribution\Distribution\DistributionRepository;
use common\logic\Document\Document\Document;
use common\logic\Order\OrderStatusHistory\OrderStatusHistoryBuilder;
use common\logic\Order\ProductOrder\ProductOrder;
use common\logic\Order\ProductOrder\ProductOrderBuilder;
use common\logic\Order\ProductOrder\ProductOrderSolver;
use common\logic\PointSale\PointSale\PointSaleBuilder;
use common\logic\PointSale\PointSale\PointSaleRepository;
use common\logic\PointSale\UserPointSale\UserPointSaleRepository;
use common\logic\Producer\Producer\Producer;
use common\logic\Producer\Producer\ProducerRepository;
use common\logic\Subscription\Subscription\Subscription;
use common\logic\Subscription\Subscription\SubscriptionBuilder;
use common\logic\Subscription\Subscription\SubscriptionRepository;
use common\logic\Subscription\Subscription\SubscriptionSolver;
use common\logic\User\CreditHistory\CreditHistory;
use common\logic\User\CreditHistory\CreditHistoryBuilder;
use common\logic\User\CreditHistory\CreditHistoryRepository;
use common\logic\User\User\User;
use common\logic\User\User\UserSolver;
use common\logic\User\UserProducer\UserProducerRepository;
use common\logic\Distribution\Distribution\Repository\DistributionRepository;
use common\logic\Document\Document\Model\Document;
use common\logic\Order\Order\Model\Order;
use common\logic\Order\Order\Repository\OrderRepository;
use common\logic\Order\OrderStatusHistory\Service\OrderStatusHistoryBuilder;
use common\logic\Order\ProductOrder\Model\ProductOrder;
use common\logic\Order\ProductOrder\Service\ProductOrderBuilder;
use common\logic\Order\ProductOrder\Service\ProductOrderSolver;
use common\logic\PointSale\PointSale\Service\PointSaleBuilder;
use common\logic\PointSale\PointSale\Repository\PointSaleRepository;
use common\logic\PointSale\UserPointSale\Repository\UserPointSaleRepository;
use common\logic\Producer\Producer\Model\Producer;
use common\logic\Producer\Producer\Repository\ProducerRepository;
use common\logic\Subscription\Subscription\Model\Subscription;
use common\logic\Subscription\Subscription\Service\SubscriptionBuilder;
use common\logic\Subscription\Subscription\Repository\SubscriptionRepository;
use common\logic\Subscription\Subscription\Service\SubscriptionSolver;
use common\logic\User\CreditHistory\Model\CreditHistory;
use common\logic\User\CreditHistory\Service\CreditHistoryBuilder;
use common\logic\User\CreditHistory\Repository\CreditHistoryRepository;
use common\logic\User\User\Service\UserSolver;
use common\logic\User\UserProducer\Repository\UserProducerRepository;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;


class OrderBuilder extends AbstractBuilder class OrderBuilder extends AbstractBuilder
{ {
$now = date('Y-m-d'); $now = date('Y-m-d');
$distributionDate = date('Y-m-d', strtotime($date)); $distributionDate = date('Y-m-d', strtotime($date));
$distribution = $this->distributionRepository->getOneByDate($distributionDate);
$distribution = $this->distributionRepository->findOneDistributionByDate($distributionDate);


if ($distribution if ($distribution
&& $distribution->active && $distribution->active
public function createAllOrdersFromSubscriptions(string $date, bool $force = false): array public function createAllOrdersFromSubscriptions(string $date, bool $force = false): array
{ {
$orderArray = []; $orderArray = [];
$distribution = $this->distributionRepository->getOneByDate(date('Y-m-d', strtotime($date)));
$distribution = $this->distributionRepository->findOneDistributionByDate(date('Y-m-d', strtotime($date)));


if ($distribution) { if ($distribution) {
$orderArray = $this->orderRepository->getByDistribution($distribution);
$subscriptionArray = $this->subscriptionRepository->getByDate($date);
$orderArray = $this->orderRepository->findOrdersByDistribution($distribution);
$subscriptionArray = $this->subscriptionRepository->findSubscriptionsByDate($date);
foreach ($subscriptionArray as $subscription) { foreach ($subscriptionArray as $subscription) {
if (!$this->subscriptionSolver->hasOrderAlreadyExist($subscription, $orderArray)) { if (!$this->subscriptionSolver->hasOrderAlreadyExist($subscription, $orderArray)) {
$this->createOrderFromSubscription($subscription, $date, $force); $this->createOrderFromSubscription($subscription, $date, $force);
public function updateOrdersIncomingDistributionsFromSubscription(Subscription $subscription, $update = false): array public function updateOrdersIncomingDistributionsFromSubscription(Subscription $subscription, $update = false): array
{ {
$orderArray = []; $orderArray = [];
$matchedDistributionsArray = $this->distributionRepository->searchMatchedIncomingDistributions($subscription);
$matchedDistributionsArray = $this->distributionRepository->findDistributionsIncomingMatchWithSubscrtiption($subscription);


if ($update) { if ($update) {
$this->deleteOrdersIncomingDistributionsFromSubscription($subscription); $this->deleteOrdersIncomingDistributionsFromSubscription($subscription);
if ($ordersArray && count($ordersArray)) { if ($ordersArray && count($ordersArray)) {
foreach ($ordersArray as $order) { foreach ($ordersArray as $order) {


$theOrder = $this->orderRepository->getOneById($order->id);
$theOrder = $this->orderRepository->findOneOrderById($order->id);


// remboursement de la commande // remboursement de la commande
if ($theOrder->id_user && $theOrder->getAmount(Order::AMOUNT_PAID) && $configCredit) { if ($theOrder->id_user && $theOrder->getAmount(Order::AMOUNT_PAID) && $configCredit) {


$this->creditHistoryBuilder->create(
$this->creditHistoryBuilder->createCreditHistory(
CreditHistory::TYPE_REFUND, CreditHistory::TYPE_REFUND,
$theOrder->getAmount(Order::AMOUNT_PAID), $theOrder->getAmount(Order::AMOUNT_PAID),
$theOrder->distribution->producer, $theOrder->distribution->producer,
$user = $subscription->user ?? null; $user = $subscription->user ?? null;
foreach ($subscription->productSubscription as $productSubscription) { foreach ($subscription->productSubscription as $productSubscription) {


$this->productOrderBuilder->create(
$this->productOrderBuilder->createProductOrder(
$order, $order,
$productSubscription->product, $productSubscription->product,
$productSubscription->quantity, $productSubscription->quantity,
$order->auto_payment = 1; $order->auto_payment = 1;
} elseif ($creditFunctioning == Producer::CREDIT_FUNCTIONING_USER) { } elseif ($creditFunctioning == Producer::CREDIT_FUNCTIONING_USER) {


$userProducer = $this->userProducerRepository->getOne($order->user, $order->producer);
$userProducer = $this->userProducerRepository->findOneUserProducer($order->user, $order->producer);


if ($userProducer) { if ($userProducer) {
$order->auto_payment = $userProducer->credit_active; $order->auto_payment = $userProducer->credit_active;
public function initOrderCommentPointSale(Order $order): void public function initOrderCommentPointSale(Order $order): void
{ {
if($order->user && $order->pointSale) { if($order->user && $order->pointSale) {
$userPointSale = $this->userPointSaleRepository->getOne($order->user, $order->pointSale);
$userPointSale = $this->userPointSaleRepository->findOneUserPointSale($order->user, $order->pointSale);


if ($userPointSale && strlen($userPointSale->comment)) { if ($userPointSale && strlen($userPointSale->comment)) {
$order->comment_point_sale = $userPointSale->comment; $order->comment_point_sale = $userPointSale->comment;
public function deleteOrder(Order $order, bool $force = false): bool public function deleteOrder(Order $order, bool $force = false): bool
{ {
// remboursement si l'utilisateur a payé pour cette commande // remboursement si l'utilisateur a payé pour cette commande
$amountPaid = $this->orderSolver->getAmount($order, Order::AMOUNT_PAID);
$amountPaid = $this->orderSolver->getOrderAmount($order, Order::AMOUNT_PAID);


if ($amountPaid >= 0.01) { if ($amountPaid >= 0.01) {
$this->creditHistoryBuilder->create(
$this->creditHistoryBuilder->createCreditHistory(
CreditHistory::TYPE_REFUND, CreditHistory::TYPE_REFUND,
$amountPaid, $amountPaid,
GlobalParam::getCurrentProducer(), GlobalParam::getCurrentProducer(),
($this->producerRepository->getConfig('option_behavior_cancel_order') == Producer::BEHAVIOR_DELETE_ORDER_STATUS && strlen($order->date_delete)) ($this->producerRepository->getConfig('option_behavior_cancel_order') == Producer::BEHAVIOR_DELETE_ORDER_STATUS && strlen($order->date_delete))
|| $force) { || $force) {


$this->productOrderBuilder->deleteByOrder($order);
$this->productOrderBuilder->deleteProductOrdersByOrder($order);


return $this->delete($order); return $this->delete($order);
} }
return; return;
} elseif ($paymentStatus == Order::PAYMENT_SURPLUS) { } elseif ($paymentStatus == Order::PAYMENT_SURPLUS) {
$type = CreditHistory::TYPE_REFUND; $type = CreditHistory::TYPE_REFUND;
$amount = $this->orderSolver->getAmount($order, Order::AMOUNT_SURPLUS);
$amount = $this->orderSolver->getOrderAmount($order, Order::AMOUNT_SURPLUS);
} elseif ($paymentStatus == Order::PAYMENT_UNPAID) { } elseif ($paymentStatus == Order::PAYMENT_UNPAID) {
$type = CreditHistory::TYPE_PAYMENT; $type = CreditHistory::TYPE_PAYMENT;
$amount = $this->orderSolver->getAmount($order, Order::AMOUNT_REMAINING);
$amount = $this->orderSolver->getOrderAmount($order, Order::AMOUNT_REMAINING);
} }


$this->creditHistoryBuilder->create(
$this->creditHistoryBuilder->createCreditHistory(
$type, $type,
$amount, $amount,
GlobalParam::getCurrentProducer(), GlobalParam::getCurrentProducer(),


switch ($newStatus) { switch ($newStatus) {
case 'new-order' : case 'new-order' :
$this->orderStatusHistoryBuilder->create($order, $userCurrent, $newStatus, $origin);
$this->orderStatusHistoryBuilder->createOrderStatusHistory($order, $userCurrent, $newStatus, $origin);
$order->status = $newStatus; $order->status = $newStatus;
$order->save(); $order->save();
break; break;
case 'refunded': case 'refunded':
case 'cancel': case 'cancel':
if (in_array($newStatus, $orderStatusArray[$order->status]['nextStatusAllow'])) { if (in_array($newStatus, $orderStatusArray[$order->status]['nextStatusAllow'])) {
$this->orderStatusHistoryBuilder->create($order, $userCurrent, $newStatus, $origin);
$this->orderStatusHistoryBuilder->createOrderStatusHistory($order, $userCurrent, $newStatus, $origin);
$order->status = $newStatus; $order->status = $newStatus;
$order->save(); $order->save();
} }
// generateReference // generateReference
public function generateOrderReference(Order $order): void public function generateOrderReference(Order $order): void
{ {
$producer = $order->producer;
$producer = $this->producerRepository->findOneProducerById($order->id_producer);


if (!$order->reference && $producer->option_order_reference_type == Producer::ORDER_REFERENCE_TYPE_YEARLY) { if (!$order->reference && $producer->option_order_reference_type == Producer::ORDER_REFERENCE_TYPE_YEARLY) {
$lastOrder = $this->orderRepository->getOneLastOfYear($producer);
$lastOrder = $this->orderRepository->findOneOrderLastOfYear($producer);


if ($lastOrder && $lastOrder->reference && strlen($lastOrder->reference) > 0) { if ($lastOrder && $lastOrder->reference && strlen($lastOrder->reference) > 0) {
$pattern = '#A([0-9]+)C([0-9]+)#'; $pattern = '#A([0-9]+)C([0-9]+)#';
{ {
foreach ($order->productOrder as $productOrder) { foreach ($order->productOrder as $productOrder) {
if ($productOrder->product) { if ($productOrder->product) {
$this->productOrderBuilder->updateInvoicePrice($productOrder, $params);
$this->productOrderBuilder->updateProductOrderInvoicePrice($productOrder, $params);
} }
} }
} }

common/logic/Order/Order/OrderSolver.php → common/logic/Order/Order/Service/OrderSolver.php View File

<?php <?php


namespace common\logic\Order\Order;
namespace common\logic\Order\Order\Service;


use common\helpers\GlobalParam;
use common\helpers\Price; use common\helpers\Price;
use common\logic\AbstractService; use common\logic\AbstractService;
use common\logic\Document\Document\Document;
use common\logic\Document\Document\DocumentSolver;
use common\logic\Order\ProductOrder\ProductOrder;
use common\logic\Producer\Producer\Producer;
use common\logic\Product\Product\Product;
use common\logic\Document\Document\Service\DocumentSolver;
use common\logic\Order\Order\Model\Order;
use common\logic\Product\Product\Model\Product;
use common\logic\SolverInterface; use common\logic\SolverInterface;
use common\logic\User\User\User;
use common\logic\User\User\UserSolver;
use common\logic\User\User\Model\User;
use common\logic\User\User\Service\UserSolver;
use yii\helpers\Html; use yii\helpers\Html;




public function getPaymentStatus(Order $order): ?string public function getPaymentStatus(Order $order): ?string
{ {
// payé // payé
if ($this->getAmountWithtax($order) - $this->getAmount($order, Order::AMOUNT_PAID) < 0.01 &&
$this->getAmountWithtax($order) - $this->getAmount($order, Order::AMOUNT_PAID) > -0.01) {
if ($this->getOrderAmountWithtax($order) - $this->getOrderAmount($order, Order::AMOUNT_PAID) < 0.01 &&
$this->getOrderAmountWithtax($order) - $this->getOrderAmount($order, Order::AMOUNT_PAID) > -0.01) {
return Order::PAYMENT_PAID; return Order::PAYMENT_PAID;
} // à rembourser } // à rembourser
elseif ($this->getAmountWithtax($order) - $this->getAmount($order, Order::AMOUNT_PAID) <= -0.01) {
elseif ($this->getOrderAmountWithtax($order) - $this->getOrderAmount($order, Order::AMOUNT_PAID) <= -0.01) {
return Order::PAYMENT_SURPLUS; return Order::PAYMENT_SURPLUS;
} // reste à payer } // reste à payer
elseif ($this->getAmountWithtax($order) - $this->getAmount($order, Order::AMOUNT_PAID) >= 0.01) {
elseif ($this->getOrderAmountWithtax($order) - $this->getOrderAmount($order, Order::AMOUNT_PAID) >= 0.01) {
return Order::PAYMENT_UNPAID; return Order::PAYMENT_UNPAID;
} }


$amount = $order->paid_amount; $amount = $order->paid_amount;
break; break;
case Order::AMOUNT_REMAINING : case Order::AMOUNT_REMAINING :
$amount = $this->getAmountWithTax($order, Order::AMOUNT_TOTAL)
- $this->getAmountWithTax($order,Order::AMOUNT_PAID);
$amount = $this->getOrderAmountWithTax($order, Order::AMOUNT_TOTAL)
- $this->getOrderAmountWithTax($order,Order::AMOUNT_PAID);
break; break;
case Order::AMOUNT_SURPLUS : case Order::AMOUNT_SURPLUS :
$amount = $this->getAmountWithTax($order,Order::AMOUNT_PAID)
- $this->getAmountWithTax($order,Order::AMOUNT_TOTAL);
$amount = $this->getOrderAmountWithTax($order,Order::AMOUNT_PAID)
- $this->getOrderAmountWithTax($order,Order::AMOUNT_TOTAL);
break; break;
} }



common/logic/Order/Order/OrderUtils.php → common/logic/Order/Order/Service/OrderUtils.php View File

<?php <?php


namespace common\logic\Order\Order;
namespace common\logic\Order\Order\Service;


use common\logic\AbstractService; use common\logic\AbstractService;
use common\logic\UtilsInterface; use common\logic\UtilsInterface;

common/logic/Order/Order/OrderContainer.php → common/logic/Order/Order/Wrapper/OrderContainer.php View File

<?php <?php


namespace common\logic\Order\Order;
namespace common\logic\Order\Order\Wrapper;


use common\logic\AbstractContainer; use common\logic\AbstractContainer;
use common\logic\Order\Order\Model\Order;
use common\logic\Order\Order\Repository\OrderRepository;
use common\logic\Order\Order\Service\OrderBuilder;
use common\logic\Order\Order\Service\OrderSolver;
use common\logic\Order\Order\Service\OrderUtils;


class OrderContainer extends AbstractContainer class OrderContainer extends AbstractContainer
{ {

+ 21
- 0
common/logic/Order/Order/Wrapper/OrderManager.php View File

<?php

namespace common\logic\Order\Order\Wrapper;

use common\logic\AbstractManager;
use common\logic\Order\Order\Repository\OrderRepository;
use common\logic\Order\Order\Service\OrderBuilder;
use common\logic\Order\Order\Service\OrderSolver;

/**
* @mixin OrderSolver
* @mixin OrderRepository
* @mixin OrderBuilder
*/
class OrderManager extends AbstractManager
{
public function getContainerFqcn(): string
{
return OrderContainer::class;
}
}

common/logic/Order/OrderStatusHistory/OrderStatusHistory.php → common/logic/Order/OrderStatusHistory/Model/OrderStatusHistory.php View File

<?php <?php


namespace common\logic\Order\OrderStatusHistory;
namespace common\logic\Order\OrderStatusHistory\Model;


use common\components\ActiveRecordCommon; use common\components\ActiveRecordCommon;
use common\logic\Order\Order\Order;
use common\logic\User\User\User;
use common\logic\Order\Order\Model\Order;
use common\logic\User\User\Model\User;


/** /**
* This is the model class for table "order_status_history". * This is the model class for table "order_status_history".

common/logic/Order/OrderStatusHistory/OrderStatusHistoryRepository.php → common/logic/Order/OrderStatusHistory/Repository/OrderStatusHistoryRepository.php View File

<?php <?php


namespace common\logic\Order\OrderStatusHistory;
namespace common\logic\Order\OrderStatusHistory\Repository;


use common\logic\AbstractRepository; use common\logic\AbstractRepository;



common/logic/Order/OrderStatusHistory/OrderStatusHistoryRepositoryQuery.php → common/logic/Order/OrderStatusHistory/Repository/OrderStatusHistoryRepositoryQuery.php View File

<?php <?php


namespace common\logic\Order\OrderStatusHistory;
namespace common\logic\Order\OrderStatusHistory\Repository;


use common\logic\AbstractRepositoryQuery; use common\logic\AbstractRepositoryQuery;



common/logic/Order/OrderStatusHistory/OrderStatusHistoryBuilder.php → common/logic/Order/OrderStatusHistory/Service/OrderStatusHistoryBuilder.php View File

<?php <?php


namespace common\logic\Order\OrderStatusHistory;
namespace common\logic\Order\OrderStatusHistory\Service;


use common\logic\AbstractBuilder; use common\logic\AbstractBuilder;
use common\logic\Order\Order\Order;
use common\logic\User\User\User;
use common\logic\User\User\UserSolver;
use common\logic\Order\Order\Model\Order;
use common\logic\Order\OrderStatusHistory\Model\OrderStatusHistory;
use common\logic\User\User\Model\User;
use common\logic\User\User\Service\UserSolver;


class OrderStatusHistoryBuilder extends AbstractBuilder class OrderStatusHistoryBuilder extends AbstractBuilder
{ {

common/logic/Order/OrderStatusHistory/OrderStatusHistoryContainer.php → common/logic/Order/OrderStatusHistory/Wrapper/OrderStatusHistoryContainer.php View File

<?php <?php


namespace common\logic\Order\OrderStatusHistory;
namespace common\logic\Order\OrderStatusHistory\Wrapper;


use common\logic\AbstractContainer; use common\logic\AbstractContainer;
use common\logic\PointSale\PointSale\OrderStatusHistoryRepository;
use common\logic\Order\OrderStatusHistory\Model\OrderStatusHistory;
use common\logic\Order\OrderStatusHistory\Repository\OrderStatusHistoryRepository;
use common\logic\Order\OrderStatusHistory\Service\OrderStatusHistoryBuilder;


class OrderStatusHistoryContainer extends AbstractContainer class OrderStatusHistoryContainer extends AbstractContainer
{ {

common/logic/Order/OrderStatusHistory/OrderStatusHistoryManager.php → common/logic/Order/OrderStatusHistory/Wrapper/OrderStatusHistoryManager.php View File

<?php <?php


namespace common\logic\Order\OrderStatusHistory;
namespace common\logic\Order\OrderStatusHistory\Wrapper;


use common\logic\AbstractManager; use common\logic\AbstractManager;
use common\logic\PointSale\PointSale\OrderStatusHistoryRepository;
use common\logic\Order\OrderStatusHistory\Repository\OrderStatusHistoryRepository;
use common\logic\Order\OrderStatusHistory\Service\OrderStatusHistoryBuilder;


/** /**
* @mixin OrderStatusHistoryRepository * @mixin OrderStatusHistoryRepository

common/logic/Order/ProductOrder/ProductOrder.php → common/logic/Order/ProductOrder/Model/ProductOrder.php View File

* termes. * termes.
*/ */


namespace common\logic\Order\ProductOrder;
namespace common\logic\Order\ProductOrder\Model;


use common\helpers\GlobalParam; use common\helpers\GlobalParam;
use common\helpers\Price;
use common\components\ActiveRecordCommon; use common\components\ActiveRecordCommon;
use common\logic\Config\TaxRate\TaxRate; use common\logic\Config\TaxRate\TaxRate;
use common\logic\Order\Order\Order;
use common\logic\Order\Order\Model\Order;
use common\logic\Product\Product\Product; use common\logic\Product\Product\Product;


/** /**

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save