add sms to sell invoices and auto update prices
This commit is contained in:
parent
2b2abff420
commit
928f77866d
|
@ -221,9 +221,20 @@ class BusinessController extends AbstractController
|
|||
$business->setWesite($params['website']);
|
||||
if ($params['email'])
|
||||
$business->setEmail($params['email']);
|
||||
if ($params['commodityUpdateBuyPriceAuto'])
|
||||
$business->setCommodityUpdateBuyPriceAuto($params['commodityUpdateBuyPriceAuto']);
|
||||
if ($params['commodityUpdateSellPriceAuto'])
|
||||
if (array_key_exists('commodityUpdateBuyPriceAuto', $params)) {
|
||||
if ($params['commodityUpdateBuyPriceAuto'] == true) {
|
||||
$business->setCommodityUpdateBuyPriceAuto(true);
|
||||
} else {
|
||||
$business->setCommodityUpdateBuyPriceAuto(false);
|
||||
}
|
||||
}
|
||||
if (array_key_exists('commodityUpdateSellPriceAuto', $params)) {
|
||||
if ($params['commodityUpdateSellPriceAuto'] == true) {
|
||||
$business->setCommodityUpdateSellPriceAuto(true);
|
||||
} else {
|
||||
$business->setCommodityUpdateSellPriceAuto(false);
|
||||
}
|
||||
}
|
||||
$business->setCommodityUpdateSellPriceAuto($params['commodityUpdateSellPriceAuto']);
|
||||
if (array_key_exists('walletEnabled', $params)) {
|
||||
if ($params['walletEnabled']) {
|
||||
|
|
|
@ -177,6 +177,12 @@ class BuyController extends AbstractController
|
|||
$hesabdariRow->setCommodity($commodity);
|
||||
$hesabdariRow->setCommdityCount($row['count']);
|
||||
$entityManager->persist($hesabdariRow);
|
||||
|
||||
//update commodity price for auto update price option
|
||||
if($acc['bid']->isCommodityUpdateBuyPriceAuto() == true && $commodity->getPriceBuy() != $row['price']){
|
||||
$commodity->setPriceBuy($row['price']);
|
||||
$entityManager->persist($commodity);
|
||||
}
|
||||
}
|
||||
//set amount of document
|
||||
$doc->setAmount($sumTax + $sumTotal - $params['discountAll'] + $params['transferCost']);
|
||||
|
|
|
@ -6,6 +6,7 @@ use App\Service\Log;
|
|||
use App\Service\Access;
|
||||
use App\Service\Explore;
|
||||
use App\Entity\Commodity;
|
||||
use App\Service\PluginService;
|
||||
use App\Service\Provider;
|
||||
use App\Service\Extractor;
|
||||
use App\Entity\HesabdariDoc;
|
||||
|
@ -16,6 +17,8 @@ use App\Entity\Person;
|
|||
use App\Entity\PrintOptions;
|
||||
use App\Entity\StoreroomTicket;
|
||||
use App\Service\Printers;
|
||||
use App\Service\registryMGR;
|
||||
use App\Service\SMS;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
@ -67,7 +70,7 @@ class SellController extends AbstractController
|
|||
}
|
||||
|
||||
#[Route('/api/sell/mod', name: 'app_sell_mod')]
|
||||
public function app_sell_mod(Provider $provider, Extractor $extractor, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse
|
||||
public function app_sell_mod(registryMGR $registryMGR,PluginService $pluginService,SMS $SMS,Provider $provider, Extractor $extractor, Request $request, Access $access, Log $log, EntityManagerInterface $entityManager): JsonResponse
|
||||
{
|
||||
$params = [];
|
||||
if ($content = $request->getContent()) {
|
||||
|
@ -87,7 +90,8 @@ class SellController extends AbstractController
|
|||
'year' => $acc['year'],
|
||||
'code' => $params['update']
|
||||
]);
|
||||
if (!$doc) return $this->json($extractor->notFound());
|
||||
if (!$doc)
|
||||
return $this->json($extractor->notFound());
|
||||
|
||||
$rows = $entityManager->getRepository(HesabdariRow::class)->findBy([
|
||||
'doc' => $doc
|
||||
|
@ -162,6 +166,12 @@ class SellController extends AbstractController
|
|||
$hesabdariRow->setCommodity($commodity);
|
||||
$hesabdariRow->setCommdityCount($row['count']);
|
||||
$entityManager->persist($hesabdariRow);
|
||||
|
||||
//update commodity price for auto update price option
|
||||
if ($acc['bid']->isCommodityUpdateSellPriceAuto() == true && $commodity->getPriceSell() != $row['price']) {
|
||||
$commodity->setPriceSell($row['price']);
|
||||
$entityManager->persist($commodity);
|
||||
}
|
||||
}
|
||||
//set amount of document
|
||||
$doc->setAmount($sumTax + $sumTotal - $params['discountAll'] + $params['transferCost']);
|
||||
|
@ -197,6 +207,36 @@ class SellController extends AbstractController
|
|||
$request->headers->get('activeBid'),
|
||||
$doc
|
||||
);
|
||||
//send sms to customer
|
||||
if (array_key_exists('sms', $params)) {
|
||||
if ($params['sms'] == true) {
|
||||
if ($pluginService->isActive('accpro', $acc['bid']) && $person->getMobile() != '' && $acc['bid']->getTel()) {
|
||||
return $this->json([
|
||||
'result' =>
|
||||
$SMS->sendByBalance(
|
||||
[$person->getnikename(), 'sell/' . $acc['bid']->getId() . '/' . $doc->getShortLink() , $acc['bid']->getName(), $acc['bid']->getTel()],
|
||||
$registryMGR->get('sms', 'plugAccproSharefaktor'),
|
||||
$person->getMobile(),
|
||||
$acc['bid'],
|
||||
$this->getUser(),
|
||||
3
|
||||
)
|
||||
]);
|
||||
} else {
|
||||
return $this->json([
|
||||
'result' =>
|
||||
$SMS->sendByBalance(
|
||||
[$acc['bid']->getName(), 'sell/' . $acc['bid']->getId() . '/' . $doc->getShortLink()],
|
||||
$registryMGR->get('sms', 'sharefaktor'),
|
||||
$person->getMobile(),
|
||||
$acc['bid'],
|
||||
$this->getUser(),
|
||||
3
|
||||
)
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->json($extractor->operationSuccess());
|
||||
}
|
||||
|
||||
|
@ -216,7 +256,8 @@ class SellController extends AbstractController
|
|||
'code' => $params['label']['code'],
|
||||
'type' => 'sell'
|
||||
]);
|
||||
if (!$label) return $this->json($extractor->notFound());
|
||||
if (!$label)
|
||||
return $this->json($extractor->notFound());
|
||||
}
|
||||
foreach ($params['items'] as $item) {
|
||||
$doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([
|
||||
|
@ -224,7 +265,8 @@ class SellController extends AbstractController
|
|||
'year' => $acc['year'],
|
||||
'code' => $item['code']
|
||||
]);
|
||||
if (!$doc) return $this->json($extractor->notFound());
|
||||
if (!$doc)
|
||||
return $this->json($extractor->notFound());
|
||||
if ($params['label'] != 'clear') {
|
||||
$doc->setInvoiceLabel($label);
|
||||
$entityManager->persist($doc);
|
||||
|
@ -309,8 +351,10 @@ class SellController extends AbstractController
|
|||
$temp['transferCost'] = $item->getBs();
|
||||
}
|
||||
}
|
||||
if(!array_key_exists('discountAll',$temp)) $temp['discountAll'] = 0;
|
||||
if(!array_key_exists('transferCost',$temp)) $temp['transferCost'] = 0;
|
||||
if (!array_key_exists('discountAll', $temp))
|
||||
$temp['discountAll'] = 0;
|
||||
if (!array_key_exists('transferCost', $temp))
|
||||
$temp['transferCost'] = 0;
|
||||
$dataTemp[] = $temp;
|
||||
}
|
||||
return $this->json($dataTemp);
|
||||
|
@ -325,13 +369,15 @@ class SellController extends AbstractController
|
|||
}
|
||||
|
||||
$acc = $access->hasRole('sell');
|
||||
if (!$acc) throw $this->createAccessDeniedException();
|
||||
if (!$acc)
|
||||
throw $this->createAccessDeniedException();
|
||||
|
||||
$doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([
|
||||
'bid' => $acc['bid'],
|
||||
'code' => $params['code']
|
||||
]);
|
||||
if (!$doc) throw $this->createNotFoundException();
|
||||
if (!$doc)
|
||||
throw $this->createNotFoundException();
|
||||
$pdfPid = 0;
|
||||
if ($params['pdf']) {
|
||||
$pdfPid = $provider->createPrint(
|
||||
|
@ -388,13 +434,15 @@ class SellController extends AbstractController
|
|||
}
|
||||
|
||||
$acc = $access->hasRole('sell');
|
||||
if (!$acc) throw $this->createAccessDeniedException();
|
||||
if (!$acc)
|
||||
throw $this->createAccessDeniedException();
|
||||
|
||||
$doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([
|
||||
'bid' => $acc['bid'],
|
||||
'code' => $params['code']
|
||||
]);
|
||||
if (!$doc) throw $this->createNotFoundException();
|
||||
if (!$doc)
|
||||
throw $this->createNotFoundException();
|
||||
$person = null;
|
||||
$discount = 0;
|
||||
$transfer = 0;
|
||||
|
@ -439,7 +487,9 @@ class SellController extends AbstractController
|
|||
}
|
||||
$note = '';
|
||||
$printSettings = $entityManager->getRepository(PrintOptions::class)->findOneBy(['bid' => $acc['bid']]);
|
||||
if($printSettings){$note = $printSettings->getSellNoteString();}
|
||||
if ($printSettings) {
|
||||
$note = $printSettings->getSellNoteString();
|
||||
}
|
||||
$pdfPid = $provider->createPrint(
|
||||
$acc['bid'],
|
||||
$this->getUser(),
|
||||
|
|
Loading…
Reference in a new issue