Quellcode durchsuchen

Paramètre producer non défini (Product::afterFind()) #1254

feature/souke
Guillaume Bourgeois vor 1 Jahr
Ursprung
Commit
e6a4e114d6
10 geänderte Dateien mit 39 neuen und 65 gelöschten Zeilen
  1. +3
    -2
      backend/controllers/CronController.php
  2. +5
    -2
      common/logic/Distribution/Distribution/Service/DistributionReportCsvGenerator.php
  3. +6
    -6
      common/logic/Document/Document/Service/DocumentBuilder.php
  4. +1
    -4
      common/logic/Document/Document/Service/DocumentUtils.php
  5. +8
    -20
      common/logic/Order/Order/Repository/OrderRepository.php
  6. +7
    -4
      common/logic/Order/Order/Service/OrderBuilder.php
  7. +4
    -4
      common/logic/Payment/Service/PaymentUtils.php
  8. +0
    -21
      common/logic/Producer/Producer/Repository/ProducerRepository.php
  9. +1
    -1
      common/logic/Product/Product/Model/Product.php
  10. +4
    -1
      common/logic/User/UserProducer/Service/UserProducerBuilder.php

+ 3
- 2
backend/controllers/CronController.php Datei anzeigen

@@ -38,6 +38,7 @@

namespace backend\controllers;

use common\helpers\GlobalParam;
use common\helpers\MeanPayment;
use common\logic\Order\Order\Model\Order;
use common\logic\User\User\Model\User;
@@ -156,7 +157,7 @@ class CronController extends BackendController
'conditions' => 'date_delete IS NULL'
]);

$configCredit = $producerManager->getConfig('credit', $producer->id);
$configCredit = $producerManager->getConfig('credit');

if ($arrayOrders && is_array($arrayOrders)) {
foreach ($arrayOrders as $order) {
@@ -174,7 +175,7 @@ class CronController extends BackendController
* Envoi des commandes par email au producteur
*/

if (!strlen($forceDate) && $producerManager->getConfig('option_notify_producer_order_summary', $producer->id)) {
if (!strlen($forceDate) && $producerManager->getConfig('option_notify_producer_order_summary')) {
$arrayOrders = Order::searchAll([
'distribution.date' => $date,
'distribution.id_producer' => $producer->id

+ 5
- 2
common/logic/Distribution/Distribution/Service/DistributionReportCsvGenerator.php Datei anzeigen

@@ -10,6 +10,7 @@ use common\logic\Order\Order\Service\OrderBuilder;
use common\logic\Order\Order\Service\OrderSolver;
use common\logic\PointSale\PointSale\Repository\PointSaleRepository;
use common\logic\Producer\Producer\Repository\ProducerRepository;
use common\logic\Producer\Producer\Service\ProducerSolver;
use common\logic\Product\Product\Model\Product;
use common\logic\Product\Product\Repository\ProductRepository;
use common\logic\Product\Product\Service\ProductSolver;
@@ -23,6 +24,7 @@ class DistributionReportCsvGenerator extends AbstractGenerator
protected OrderSolver $orderSolver;
protected PointSaleRepository $pointSaleRepository;
protected OrderBuilder $orderBuilder;
protected ProducerSolver $producerSolver;

public function loadDependencies(): void
{
@@ -33,6 +35,7 @@ class DistributionReportCsvGenerator extends AbstractGenerator
$this->orderSolver = $this->loadService(OrderSolver::class);
$this->pointSaleRepository = $this->loadService(PointSaleRepository::class);
$this->orderBuilder = $this->loadService(OrderBuilder::class);
$this->producerSolver = $this->loadService(ProducerSolver::class);
}

public function generateDistributionReportCsv(Distribution $distribution)
@@ -40,8 +43,8 @@ class DistributionReportCsvGenerator extends AbstractGenerator
$datas = [];
$ordersArray = $this->orderRepository->findOrdersByDistribution($distribution);
$productsArray = $this->productRepository->findProductsByDistribution($distribution);
$optionCsvExportAllProducts = $this->producerRepository->getConfig('option_csv_export_all_products');
$optionCsvExportByPiece = $this->producerRepository->getConfig('option_csv_export_by_piece');
$optionCsvExportAllProducts = $this->producerSolver->getConfig('option_csv_export_all_products');
$optionCsvExportByPiece = $this->producerSolver->getConfig('option_csv_export_by_piece');
$pointsSaleArray = $this->pointSaleRepository->findPointSales();
foreach ($pointsSaleArray as $pointSale) {
$this->orderBuilder->initPointSaleOrders($pointSale, $ordersArray);

+ 6
- 6
common/logic/Document/Document/Service/DocumentBuilder.php Datei anzeigen

@@ -6,19 +6,19 @@ use common\logic\AbstractBuilder;
use common\logic\Document\Document\Model\Document;
use common\logic\Document\Document\Model\DocumentInterface;
use common\logic\Document\Document\Repository\DocumentRepository;
use common\logic\Producer\Producer\Repository\ProducerRepository;
use common\logic\Producer\Producer\Service\ProducerSolver;

class DocumentBuilder extends AbstractBuilder
{
protected DocumentSolver $documentSolver;
protected DocumentRepository $documentRepository;
protected ProducerRepository $producerRepository;
protected ProducerSolver $producerSolver;

public function loadDependencies(): void
{
$this->documentSolver = $this->loadService(DocumentSolver::class);
$this->documentRepository = $this->loadService(DocumentRepository::class);
$this->producerRepository = $this->loadService(ProducerRepository::class);
$this->producerSolver = $this->loadService(ProducerSolver::class);
}

public function initDocumentProducer(Document $document): void
@@ -35,7 +35,7 @@ class DocumentBuilder extends AbstractBuilder
$classLower = 'delivery_note';
}

$prefix = $this->producerRepository->getConfig('document_' . $classLower . '_prefix');
$prefix = $this->producerSolver->getConfig('document_' . $classLower . '_prefix');
$oneDocumentExist = $classComplete::searchOne(['status' => Document::STATUS_VALID], ['orderby' => 'reference DESC']);

if ($oneDocumentExist) {
@@ -48,7 +48,7 @@ class DocumentBuilder extends AbstractBuilder

$reference = $prefix . $numReference;
} else {
$firstReference = $this->producerRepository->getConfig('document_' . $classLower . '_first_reference');
$firstReference = $this->producerSolver->getConfig('document_' . $classLower . '_first_reference');

if (strlen($firstReference) > 0) {
$reference = $firstReference;
@@ -79,7 +79,7 @@ class DocumentBuilder extends AbstractBuilder

public function initTaxCalculationMethod(DocumentInterface $document): void
{
$producerTaxCalculationMethod = $this->producerRepository->getConfig('option_tax_calculation_method');
$producerTaxCalculationMethod = $this->producerSolver->getConfig('option_tax_calculation_method');

if ($producerTaxCalculationMethod) {
$document->tax_calculation_method = $producerTaxCalculationMethod;

+ 1
- 4
common/logic/Document/Document/Service/DocumentUtils.php Datei anzeigen

@@ -5,7 +5,6 @@ namespace common\logic\Document\Document\Service;
use common\helpers\GlobalParam;
use common\logic\AbstractService;
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 kartik\mpdf\Pdf;
@@ -17,14 +16,12 @@ class DocumentUtils extends AbstractService implements UtilsInterface
protected DocumentSolver $documentSolver;
protected DocumentBuilder $documentBuilder;
protected ProducerSolver $producerSolver;
protected ProducerRepository $producerRepository;

public function loadDependencies(): void
{
$this->documentSolver = $this->loadService(DocumentSolver::class);
$this->documentBuilder = $this->loadService(DocumentBuilder::class);
$this->producerSolver = $this->loadService(ProducerSolver::class);
$this->producerRepository = $this->loadService(ProducerRepository::class);
}

public function generatePdf(DocumentInterface $document, string $destination): ?string
@@ -53,7 +50,7 @@ class DocumentUtils extends AbstractService implements UtilsInterface
$contentFooter .= '</div>';

$marginBottom = 10;
if (strlen($this->producerRepository->getConfig('document_infos_bottom')) > 0) {
if (strlen($this->producerSolver->getConfig('document_infos_bottom')) > 0) {
$marginBottom = 40;
}


+ 8
- 20
common/logic/Order/Order/Repository/OrderRepository.php Datei anzeigen

@@ -240,7 +240,7 @@ class OrderRepository extends AbstractRepository
public function getAmountSummary(Order $order): string
{
$html = '';
$creditActive = $this->producerRepository->getConfig('credit');
$creditActive = $this->producerSolver->getConfig('credit');
$html .= $this->orderSolver->getOrderAmountWithTax($order, Order::AMOUNT_TOTAL, true);

if ($creditActive) {
@@ -277,26 +277,14 @@ class OrderRepository extends AbstractRepository
$todayHour = date('G');
$dayDistribution = strtolower(date('l', strtotime($order->distribution->date)));

$orderDelay = $this->producerRepository->getConfig(
'order_delay',
$order->distribution->id_producer
);
$orderDelaySpecific = $this->producerRepository->getConfig(
'order_delay_' . $dayDistribution,
$order->distribution->id_producer
);
$orderDelay = $this->producerSolver->getConfig('order_delay');
$orderDelaySpecific = $this->producerSolver->getConfig('order_delay_' . $dayDistribution,);
if ($orderDelaySpecific) {
$orderDelay = $orderDelaySpecific;
}

$orderDeadline = $this->producerRepository->getConfig(
'order_deadline',
$order->distribution->id_producer
);
$orderDeadlineSpecific = $this->producerRepository->getConfig(
'order_deadline_' . $dayDistribution,
$order->distribution->id_producer
);
$orderDeadline = $this->producerSolver->getConfig('order_deadline',);
$orderDeadlineSpecific = $this->producerSolver->getConfig('order_deadline_' . $dayDistribution,);
if ($orderDeadlineSpecific) {
$orderDeadline = $orderDeadlineSpecific;
}
@@ -367,7 +355,7 @@ class OrderRepository extends AbstractRepository
if($pointSale) {
$creditFunctioning = $this->producerRepository->getPointSaleCreditFunctioning($pointSale);

if ($order->id_user && $this->producerRepository->getConfig('credit') && $pointSale->credit) {
if ($order->id_user && $this->producerSolver->getConfig('credit') && $pointSale->credit) {
if($order->mean_payment == MeanPayment::CREDIT || $creditFunctioning == Producer::CREDIT_FUNCTIONING_MANDATORY) {
return true;
}
@@ -388,7 +376,7 @@ class OrderRepository extends AbstractRepository

public function isCreditContext(Order $order)
{
if(!$this->producerRepository->getConfig('credit')) {
if(!$this->producerSolver->getConfig('credit')) {
return false;
}

@@ -397,7 +385,7 @@ class OrderRepository extends AbstractRepository

if($pointSale) {
$creditFunctioning = $this->producerRepository->getPointSaleCreditFunctioning($pointSale);
if ($order->id_user && $this->producerRepository->getConfig('credit') && $pointSale->credit) {
if ($order->id_user && $this->producerSolver->getConfig('credit') && $pointSale->credit) {
if($order->mean_payment == MeanPayment::CREDIT
|| $creditFunctioning == Producer::CREDIT_FUNCTIONING_MANDATORY
|| $creditFunctioning == Producer::CREDIT_FUNCTIONING_OPTIONAL) {

+ 7
- 4
common/logic/Order/Order/Service/OrderBuilder.php Datei anzeigen

@@ -31,6 +31,7 @@ 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\Producer\Producer\Service\ProducerSolver;
use common\logic\Product\Product\Service\ProductSolver;
use common\logic\Subscription\Subscription\Model\Subscription;
use common\logic\Subscription\Subscription\Service\SubscriptionBuilder;
@@ -64,6 +65,7 @@ class OrderBuilder extends AbstractBuilder
protected UserRepository $userRepository;
protected DeliveryNoteBuilder $deliveryNoteBuilder;
protected DocumentSolver $documentSolver;
protected ProducerSolver $producerSolver;

public function loadDependencies(): void
{
@@ -88,6 +90,7 @@ class OrderBuilder extends AbstractBuilder
$this->userRepository = $this->loadService(UserRepository::class);
$this->deliveryNoteBuilder = $this->loadService(DeliveryNoteBuilder::class);
$this->documentSolver = $this->loadService(DocumentSolver::class);
$this->producerSolver = $this->loadService(ProducerSolver::class);
}

public function instanciateOrder(Distribution $distribution): Order
@@ -260,7 +263,7 @@ class OrderBuilder extends AbstractBuilder

$order->auto_payment = 0;
if ($subscription->auto_payment == Subscription::AUTO_PAYMENT_DEDUCTED) {
if ($order->id_user && $this->producerRepository->getConfig('credit') && $pointSale->credit) {
if ($order->id_user && $this->producerSolver->getConfig('credit') && $pointSale->credit) {
if ($creditFunctioning == Producer::CREDIT_FUNCTIONING_OPTIONAL) {
$order->auto_payment = 0;
} elseif ($creditFunctioning == Producer::CREDIT_FUNCTIONING_MANDATORY) {
@@ -400,8 +403,8 @@ class OrderBuilder extends AbstractBuilder
$this->initOrder($order);

// delete
if ($this->producerRepository->getConfig('option_behavior_cancel_order') == Producer::BEHAVIOR_DELETE_ORDER_DELETE ||
($this->producerRepository->getConfig('option_behavior_cancel_order') == Producer::BEHAVIOR_DELETE_ORDER_STATUS && strlen($order->date_delete))
if ($this->producerSolver->getConfig('option_behavior_cancel_order') == Producer::BEHAVIOR_DELETE_ORDER_DELETE ||
($this->producerSolver->getConfig('option_behavior_cancel_order') == Producer::BEHAVIOR_DELETE_ORDER_STATUS && strlen($order->date_delete))
|| $force) {

$this->productOrderBuilder->deleteProductOrdersByOrder($order);
@@ -409,7 +412,7 @@ class OrderBuilder extends AbstractBuilder
$return = $this->delete($order);
}
// status 'delete'
elseif ($this->producerRepository->getConfig('option_behavior_cancel_order') == Producer::BEHAVIOR_DELETE_ORDER_STATUS) {
elseif ($this->producerSolver->getConfig('option_behavior_cancel_order') == Producer::BEHAVIOR_DELETE_ORDER_STATUS) {
$order->date_delete = date('Y-m-d H:i:s');
$return = $this->update($order);
}

+ 4
- 4
common/logic/Payment/Service/PaymentUtils.php Datei anzeigen

@@ -7,7 +7,7 @@ use common\logic\AbstractService;
use common\logic\Order\Order\Model\Order;
use common\logic\Order\Order\Service\OrderSolver;
use common\logic\Payment\Model\Payment;
use common\logic\Producer\Producer\Repository\ProducerRepository;
use common\logic\Producer\Producer\Service\ProducerSolver;
use common\logic\User\User\Model\User;
use common\logic\User\User\Repository\UserRepository;
use common\logic\UtilsInterface;
@@ -17,15 +17,15 @@ class PaymentUtils extends AbstractService implements UtilsInterface
{
protected PaymentBuilder $paymentBuilder;
protected OrderSolver $orderSolver;
protected ProducerRepository $producerRepository;
protected UserRepository $userRepository;
protected ProducerSolver $producerSolver;

public function loadDependencies(): void
{
$this->paymentBuilder = $this->loadService(PaymentBuilder::class);
$this->orderSolver = $this->loadService(OrderSolver::class);
$this->producerRepository = $this->loadService(ProducerRepository::class);
$this->userRepository = $this->loadService(UserRepository::class);
$this->producerSolver = $this->loadService(ProducerSolver::class);
}

public function creditUser(User $user, float $amount, string $meanPayment, User $userAction): void
@@ -91,7 +91,7 @@ class PaymentUtils extends AbstractService implements UtilsInterface
$amountRemaining = round($this->orderSolver->getOrderAmountWithTax($order, Order::AMOUNT_REMAINING), 2);

if($checkCreditLimit) {
$creditLimit = $this->producerRepository->getConfig('credit_limit');
$creditLimit = $this->producerSolver->getConfig('credit_limit');
$creditUser = $this->userRepository->getCredit($order->user);

if (!is_null($creditLimit) && $amountRemaining > $creditUser - $creditLimit) {

+ 0
- 21
common/logic/Producer/Producer/Repository/ProducerRepository.php Datei anzeigen

@@ -240,27 +240,6 @@ class ProducerRepository extends AbstractRepository
return $onlinePaymentMinimumAmount;
}

/**
* Retourne une configuration d'un producteur donné
*/
public function getConfig(string $config = '', int $idProducer = 0)
{
if (strlen($config)) {
if (!$idProducer) {
$producer = $this->getProducerContext();
}
else {
$producer = $this->findOneProducerById($idProducer);
}

if ($producer) {
return $this->producerSolver->getConfig($config, $producer);
}
}

return null;
}

public function getNameProducer(User $user): string
{
$producer = $this->findOneProducerById($user->id_producer);

+ 1
- 1
common/logic/Product/Product/Model/Product.php Datei anzeigen

@@ -178,7 +178,7 @@ class Product extends ActiveRecordCommon
public function afterFind()
{
if ($this->taxRate == null) {
if($this->id_producer == GlobalParam::getCurrentProducerId()) {
if(GlobalParam::getCurrentProducerId() && $this->id_producer == GlobalParam::getCurrentProducerId()) {
$producer = GlobalParam::getCurrentProducer();
}
else {

+ 4
- 1
common/logic/User/UserProducer/Service/UserProducerBuilder.php Datei anzeigen

@@ -11,6 +11,7 @@ use common\logic\Payment\Model\Payment;
use common\logic\Payment\Service\PaymentSolver;
use common\logic\Producer\Producer\Model\Producer;
use common\logic\Producer\Producer\Repository\ProducerRepository;
use common\logic\Producer\Producer\Service\ProducerSolver;
use common\logic\User\User\Model\User;
use common\logic\User\User\Repository\UserRepository;
use common\logic\User\UserProducer\Model\UserProducer;
@@ -24,6 +25,7 @@ class UserProducerBuilder extends AbstractBuilder
protected ProducerRepository $producerRepository;
protected OrderSolver $orderSolver;
protected UserRepository $userRepository;
protected ProducerSolver $producerSolver;

public function loadDependencies(): void
{
@@ -33,6 +35,7 @@ class UserProducerBuilder extends AbstractBuilder
$this->producerRepository = $this->loadService(ProducerRepository::class);
$this->orderSolver = $this->loadService(OrderSolver::class);
$this->userRepository = $this->loadService(UserRepository::class);
$this->producerSolver = $this->loadService(ProducerSolver::class);
}

public function instanciateUserProducer(User $user, Producer $producer, bool $bookmark = true, bool $newsletter = true)
@@ -143,7 +146,7 @@ class UserProducerBuilder extends AbstractBuilder

public function isCreditLimitCrossed($oldCredit, $newCredit)
{
$creditLimitReminder = $this->producerRepository->getConfig('credit_limit_reminder');
$creditLimitReminder = $this->producerSolver->getConfig('credit_limit_reminder');

return !is_null($creditLimitReminder) &&
$oldCredit > $creditLimitReminder

Laden…
Abbrechen
Speichern