Browse Source

Système compte prépayés

feature/export_comptable
Fab 4 years ago
parent
commit
0bd1b6c734
3 changed files with 9 additions and 7 deletions
  1. +3
    -2
      ShopBundle/Controller/Backend/UserMerchantController.php
  2. +2
    -2
      ShopBundle/Model/CreditHistory.php
  3. +4
    -3
      ShopBundle/Services/CreditUtils.php

+ 3
- 2
ShopBundle/Controller/Backend/UserMerchantController.php View File

$addCreditHistoryForm = $this->createForm(CreditHistoryType::class, $creditHistory); $addCreditHistoryForm = $this->createForm(CreditHistoryType::class, $creditHistory);
$addCreditHistoryForm->handleRequest($this->request); $addCreditHistoryForm->handleRequest($this->request);
if ($addCreditHistoryForm->isSubmitted() && $addCreditHistoryForm->isValid()) { if ($addCreditHistoryForm->isSubmitted() && $addCreditHistoryForm->isValid()) {

if($this->creditUtils->saveCreditHistory()){
$creditHistory->setUserMerchant($userMerchant);
dump($creditHistory);
if($this->creditUtils->saveCreditHistory($creditHistory)){
$this->utils->addFlash('warning', 'success.credit.added'); $this->utils->addFlash('warning', 'success.credit.added');
}else{ }else{
$this->utils->addFlash('warning', 'error.credit.notAdded'); $this->utils->addFlash('warning', 'error.credit.notAdded');

+ 2
- 2
ShopBundle/Model/CreditHistory.php View File

return $this->type; return $this->type;
} }


public function setType(string $meanPayment): self
public function setType(string $type): self
{ {
$this->meanPayment = $meanPayment;
$this->type = $type;


return $this; return $this;
} }

+ 4
- 3
ShopBundle/Services/CreditUtils.php View File

use Lc\ShopBundle\Context\MerchantUtilsInterface; use Lc\ShopBundle\Context\MerchantUtilsInterface;
use Lc\ShopBundle\Context\UserInterface; use Lc\ShopBundle\Context\UserInterface;
use Lc\ShopBundle\Context\UserMerchantInterface; use Lc\ShopBundle\Context\UserMerchantInterface;
use Lc\ShopBundle\Model\CreditHistory;


class CreditUtils class CreditUtils
{ {
{ {
if($creditHistory) { if($creditHistory) {
$userMerchant = $creditHistory->getUserMerchant() ; $userMerchant = $creditHistory->getUserMerchant() ;
$checkCreditActive = $this->checkCreditActive() ;
$checkCreditActive = $this->checkCreditActive($userMerchant) ;


if($checkCreditActive) { if($checkCreditActive) {
$this->em->persist($creditHistory) ; $this->em->persist($creditHistory) ;
return false ; return false ;
} }


public function updateCredit($userMerchant, $amount, $merchant = null)
public function updateCredit($userMerchant, $amount)
{ {
$userMerchant->setAmount($amount) ;
$userMerchant->setCredit($amount) ;
$this->em->persist($userMerchant) ; $this->em->persist($userMerchant) ;
$this->em->flush() ; $this->em->flush() ;
} }

Loading…
Cancel
Save