@@ -38,8 +38,9 @@ class UserMerchantController extends AdminController | |||
$addCreditHistoryForm = $this->createForm(CreditHistoryType::class, $creditHistory); | |||
$addCreditHistoryForm->handleRequest($this->request); | |||
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'); | |||
}else{ | |||
$this->utils->addFlash('warning', 'error.credit.notAdded'); |
@@ -87,9 +87,9 @@ abstract class CreditHistory extends AbstractEntity implements PayoffInterface | |||
return $this->type; | |||
} | |||
public function setType(string $meanPayment): self | |||
public function setType(string $type): self | |||
{ | |||
$this->meanPayment = $meanPayment; | |||
$this->type = $type; | |||
return $this; | |||
} |
@@ -8,6 +8,7 @@ use Lc\ShopBundle\Context\MerchantInterface; | |||
use Lc\ShopBundle\Context\MerchantUtilsInterface; | |||
use Lc\ShopBundle\Context\UserInterface; | |||
use Lc\ShopBundle\Context\UserMerchantInterface; | |||
use Lc\ShopBundle\Model\CreditHistory; | |||
class CreditUtils | |||
{ | |||
@@ -126,7 +127,7 @@ class CreditUtils | |||
{ | |||
if($creditHistory) { | |||
$userMerchant = $creditHistory->getUserMerchant() ; | |||
$checkCreditActive = $this->checkCreditActive() ; | |||
$checkCreditActive = $this->checkCreditActive($userMerchant) ; | |||
if($checkCreditActive) { | |||
$this->em->persist($creditHistory) ; | |||
@@ -149,9 +150,9 @@ class CreditUtils | |||
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->flush() ; | |||
} |