Explorar el Código

Système compte prépayés

feature/export_comptable
Fab hace 4 años
padre
commit
bd34443690
Se han modificado 2 ficheros con 16 adiciones y 16 borrados
  1. +1
    -0
      ShopBundle/Resources/translations/lcshop.fr.yaml
  2. +15
    -16
      ShopBundle/Services/CreditUtils.php

+ 1
- 0
ShopBundle/Resources/translations/lcshop.fr.yaml Ver fichero

@@ -84,6 +84,7 @@ error:
credit:
notActive: Cet utilisateur n'a pas activé son compte prépayé
debited: Une erreur est survenue, le crédit n'a pas été débité
notEnoughCredit:
field:
default:
placeholder: Choisissez une option

+ 15
- 16
ShopBundle/Services/CreditUtils.php Ver fichero

@@ -88,16 +88,13 @@ class CreditUtils
}


public function isCreditActive(UserInterface $user, MerchantInterface $merchant = null){
public function isCreditActiveByUser(UserInterface $user, MerchantInterface $merchant = null){
$userMerchant = $this->getUserMerchant($user, $merchant);
if($userMerchant && $userMerchant->isCreditActive()) {
return true;
}else{
return false;
}

return $this->isCreditActive($userMerchant);
}

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

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

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

@@ -125,9 +122,9 @@ class CreditUtils
{
$merchant = isset($params['merchant']) ? $params['merchant'] : null ;
$userMerchant = $this->getUserMerchant($user, $merchant) ;
$checkCreditActive = $this->checkCreditActive($userMerchant) ;
$isCreditActive = $this->isCreditActive($userMerchant) ;

if($checkCreditActive) {
if($isCreditActive) {
$amount = isset($params['amount']) ? $params['amount'] : null ;
$meanPayment = isset($params['meanPayment']) ? $params['meanPayment'] : null ;
$reference = isset($params['reference']) ? $params['reference'] : null ;
@@ -158,9 +155,9 @@ class CreditUtils
{
if($creditHistory) {
$userMerchant = $creditHistory->getUserMerchant() ;
$checkCreditActive = $this->checkCreditActive($userMerchant) ;
$isCreditActive = $this->isCreditActive($userMerchant) ;

if($checkCreditActive) {
if($isCreditActive) {
$this->em->persist($creditHistory) ;
$this->em->flush() ;

@@ -170,11 +167,13 @@ class CreditUtils
elseif($creditHistory->getType() == CreditHistory::TYPE_DEBIT) {
$userMerchantAmount = $userMerchant->getCredit() - $creditHistory->getAmountInherited() ;
}
if(isset($userMerchantAmount)) {
if($this->isCreditSufficientToPay($userMerchant,$userMerchantAmount)) {
$this->updateCredit($userMerchant, $userMerchantAmount) ;
return true ;
}else{
$this->utils->addFlash('success', 'error.credit.notEnoughCredit');
return false ;
}

return true ;
}
}


Cargando…
Cancelar
Guardar