Переглянути джерело

Système de compte prépayé

feature/export_comptable
Guillaume 4 роки тому
джерело
коміт
19a4c1f2ef
3 змінених файлів з 25 додано та 4 видалено
  1. +9
    -0
      ShopBundle/Repository/CreditHistoryRepository.php
  2. +10
    -1
      ShopBundle/Services/CreditUtils.php
  3. +6
    -3
      ShopBundle/Services/Order/OrderUtils.php

+ 9
- 0
ShopBundle/Repository/CreditHistoryRepository.php Переглянути файл

@@ -17,4 +17,13 @@ class CreditHistoryRepository extends BaseRepository implements DefaultRepositor
{
return CreditHistoryInterface::class;
}

public function findAllByUserMerchant($userMerchant)
{
return $this->createQueryBuilder('e')
->andWhere('e.userMerchant = :userMerchant')
->setParameter('userMerchant', $userMerchant)
->addOrderBy('e.createdAt', 'DESC')
->getQuery()->getResult();
}
}

+ 10
- 1
ShopBundle/Services/CreditUtils.php Переглянути файл

@@ -97,7 +97,7 @@ class CreditUtils
}
}

public function checkCreditActive(UserMerchantInterface $userMerchant){
public function checkCreditActive(UserMerchantInterface $userMerchant = null){

if(!$userMerchant || ($userMerchant && !$userMerchant->isCreditActive())) {
return false ;
@@ -106,6 +106,15 @@ class CreditUtils
return true ;
}

public function checkCreditSufficientToPay($userMerchant, $amount)
{
if($this->checkCreditActive($userMerchant) && $userMerchant->getCredit() >= $amount) {
return true ;
}

return false;
}

public function createCreditHistory($type, $user, $params = [])
{
$creditHistory = $this->initCreditHistory($type, $user, $params) ;

+ 6
- 3
ShopBundle/Services/Order/OrderUtils.php Переглянути файл

@@ -270,7 +270,6 @@ class OrderUtils

public function getOrderDatas($order = null)
{

$data = [];
if (!$order) {
$order = $this->getCartCurrent();
@@ -384,16 +383,18 @@ class OrderUtils
return $orderProductsByProductFamily;
}

public function createOrderPayment($orderShop, $type, $amount, $reference = null, $comment = null, $paidAt = null)
public function createOrderPayment($orderShop, $meanPayment, $amount, $reference = null, $comment = null, $paidAt = null)
{
$classOrderPayment = $this->em->getClassMetadata(OrderPaymentInterface::class)->getName();
$orderPayment = new $classOrderPayment;

$orderPayment->setOrderShop($orderShop);
$orderPayment->setType($type);
$orderPayment->setMeanPayment($meanPayment);
$orderPayment->setAmount($amount);
$orderPayment->setReference($reference);
$orderPayment->setComment($comment);
$orderPayment->setEditable(false);

if ($paidAt) {
$orderPayment->setPaidAt($paidAt);
} else {
@@ -402,6 +403,8 @@ class OrderUtils

$this->em->persist($orderPayment);
$this->em->flush();

return $orderPayment ;
}

public function isOrderPaid($order)

Завантаження…
Відмінити
Зберегти