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']);
|
$business->setWesite($params['website']);
|
||||||
if ($params['email'])
|
if ($params['email'])
|
||||||
$business->setEmail($params['email']);
|
$business->setEmail($params['email']);
|
||||||
if ($params['commodityUpdateBuyPriceAuto'])
|
if (array_key_exists('commodityUpdateBuyPriceAuto', $params)) {
|
||||||
$business->setCommodityUpdateBuyPriceAuto($params['commodityUpdateBuyPriceAuto']);
|
if ($params['commodityUpdateBuyPriceAuto'] == true) {
|
||||||
if ($params['commodityUpdateSellPriceAuto'])
|
$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']);
|
$business->setCommodityUpdateSellPriceAuto($params['commodityUpdateSellPriceAuto']);
|
||||||
if (array_key_exists('walletEnabled', $params)) {
|
if (array_key_exists('walletEnabled', $params)) {
|
||||||
if ($params['walletEnabled']) {
|
if ($params['walletEnabled']) {
|
||||||
|
|
|
@ -177,6 +177,12 @@ class BuyController extends AbstractController
|
||||||
$hesabdariRow->setCommodity($commodity);
|
$hesabdariRow->setCommodity($commodity);
|
||||||
$hesabdariRow->setCommdityCount($row['count']);
|
$hesabdariRow->setCommdityCount($row['count']);
|
||||||
$entityManager->persist($hesabdariRow);
|
$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
|
//set amount of document
|
||||||
$doc->setAmount($sumTax + $sumTotal - $params['discountAll'] + $params['transferCost']);
|
$doc->setAmount($sumTax + $sumTotal - $params['discountAll'] + $params['transferCost']);
|
||||||
|
|
|
@ -6,6 +6,7 @@ use App\Service\Log;
|
||||||
use App\Service\Access;
|
use App\Service\Access;
|
||||||
use App\Service\Explore;
|
use App\Service\Explore;
|
||||||
use App\Entity\Commodity;
|
use App\Entity\Commodity;
|
||||||
|
use App\Service\PluginService;
|
||||||
use App\Service\Provider;
|
use App\Service\Provider;
|
||||||
use App\Service\Extractor;
|
use App\Service\Extractor;
|
||||||
use App\Entity\HesabdariDoc;
|
use App\Entity\HesabdariDoc;
|
||||||
|
@ -16,6 +17,8 @@ use App\Entity\Person;
|
||||||
use App\Entity\PrintOptions;
|
use App\Entity\PrintOptions;
|
||||||
use App\Entity\StoreroomTicket;
|
use App\Entity\StoreroomTicket;
|
||||||
use App\Service\Printers;
|
use App\Service\Printers;
|
||||||
|
use App\Service\registryMGR;
|
||||||
|
use App\Service\SMS;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
@ -67,7 +70,7 @@ class SellController extends AbstractController
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/api/sell/mod', name: 'app_sell_mod')]
|
#[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 = [];
|
$params = [];
|
||||||
if ($content = $request->getContent()) {
|
if ($content = $request->getContent()) {
|
||||||
|
@ -87,7 +90,8 @@ class SellController extends AbstractController
|
||||||
'year' => $acc['year'],
|
'year' => $acc['year'],
|
||||||
'code' => $params['update']
|
'code' => $params['update']
|
||||||
]);
|
]);
|
||||||
if (!$doc) return $this->json($extractor->notFound());
|
if (!$doc)
|
||||||
|
return $this->json($extractor->notFound());
|
||||||
|
|
||||||
$rows = $entityManager->getRepository(HesabdariRow::class)->findBy([
|
$rows = $entityManager->getRepository(HesabdariRow::class)->findBy([
|
||||||
'doc' => $doc
|
'doc' => $doc
|
||||||
|
@ -104,7 +108,7 @@ class SellController extends AbstractController
|
||||||
$doc->setMoney($acc['bid']->getMoney());
|
$doc->setMoney($acc['bid']->getMoney());
|
||||||
$doc->setCode($provider->getAccountingCode($acc['bid'], 'accounting'));
|
$doc->setCode($provider->getAccountingCode($acc['bid'], 'accounting'));
|
||||||
}
|
}
|
||||||
if($params['transferCost'] != 0){
|
if ($params['transferCost'] != 0) {
|
||||||
$hesabdariRow = new HesabdariRow();
|
$hesabdariRow = new HesabdariRow();
|
||||||
$hesabdariRow->setDes('حمل و نقل کالا');
|
$hesabdariRow->setDes('حمل و نقل کالا');
|
||||||
$hesabdariRow->setBid($acc['bid']);
|
$hesabdariRow->setBid($acc['bid']);
|
||||||
|
@ -118,7 +122,7 @@ class SellController extends AbstractController
|
||||||
$hesabdariRow->setRef($ref);
|
$hesabdariRow->setRef($ref);
|
||||||
$entityManager->persist($hesabdariRow);
|
$entityManager->persist($hesabdariRow);
|
||||||
}
|
}
|
||||||
if($params['discountAll'] != 0){
|
if ($params['discountAll'] != 0) {
|
||||||
$hesabdariRow = new HesabdariRow();
|
$hesabdariRow = new HesabdariRow();
|
||||||
$hesabdariRow->setDes('تخفیف فاکتور');
|
$hesabdariRow->setDes('تخفیف فاکتور');
|
||||||
$hesabdariRow->setBid($acc['bid']);
|
$hesabdariRow->setBid($acc['bid']);
|
||||||
|
@ -162,6 +166,12 @@ class SellController extends AbstractController
|
||||||
$hesabdariRow->setCommodity($commodity);
|
$hesabdariRow->setCommodity($commodity);
|
||||||
$hesabdariRow->setCommdityCount($row['count']);
|
$hesabdariRow->setCommdityCount($row['count']);
|
||||||
$entityManager->persist($hesabdariRow);
|
$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
|
//set amount of document
|
||||||
$doc->setAmount($sumTax + $sumTotal - $params['discountAll'] + $params['transferCost']);
|
$doc->setAmount($sumTax + $sumTotal - $params['discountAll'] + $params['transferCost']);
|
||||||
|
@ -197,6 +207,36 @@ class SellController extends AbstractController
|
||||||
$request->headers->get('activeBid'),
|
$request->headers->get('activeBid'),
|
||||||
$doc
|
$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());
|
return $this->json($extractor->operationSuccess());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +256,8 @@ class SellController extends AbstractController
|
||||||
'code' => $params['label']['code'],
|
'code' => $params['label']['code'],
|
||||||
'type' => 'sell'
|
'type' => 'sell'
|
||||||
]);
|
]);
|
||||||
if (!$label) return $this->json($extractor->notFound());
|
if (!$label)
|
||||||
|
return $this->json($extractor->notFound());
|
||||||
}
|
}
|
||||||
foreach ($params['items'] as $item) {
|
foreach ($params['items'] as $item) {
|
||||||
$doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([
|
$doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([
|
||||||
|
@ -224,7 +265,8 @@ class SellController extends AbstractController
|
||||||
'year' => $acc['year'],
|
'year' => $acc['year'],
|
||||||
'code' => $item['code']
|
'code' => $item['code']
|
||||||
]);
|
]);
|
||||||
if (!$doc) return $this->json($extractor->notFound());
|
if (!$doc)
|
||||||
|
return $this->json($extractor->notFound());
|
||||||
if ($params['label'] != 'clear') {
|
if ($params['label'] != 'clear') {
|
||||||
$doc->setInvoiceLabel($label);
|
$doc->setInvoiceLabel($label);
|
||||||
$entityManager->persist($doc);
|
$entityManager->persist($doc);
|
||||||
|
@ -309,8 +351,10 @@ class SellController extends AbstractController
|
||||||
$temp['transferCost'] = $item->getBs();
|
$temp['transferCost'] = $item->getBs();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!array_key_exists('discountAll',$temp)) $temp['discountAll'] = 0;
|
if (!array_key_exists('discountAll', $temp))
|
||||||
if(!array_key_exists('transferCost',$temp)) $temp['transferCost'] = 0;
|
$temp['discountAll'] = 0;
|
||||||
|
if (!array_key_exists('transferCost', $temp))
|
||||||
|
$temp['transferCost'] = 0;
|
||||||
$dataTemp[] = $temp;
|
$dataTemp[] = $temp;
|
||||||
}
|
}
|
||||||
return $this->json($dataTemp);
|
return $this->json($dataTemp);
|
||||||
|
@ -325,13 +369,15 @@ class SellController extends AbstractController
|
||||||
}
|
}
|
||||||
|
|
||||||
$acc = $access->hasRole('sell');
|
$acc = $access->hasRole('sell');
|
||||||
if (!$acc) throw $this->createAccessDeniedException();
|
if (!$acc)
|
||||||
|
throw $this->createAccessDeniedException();
|
||||||
|
|
||||||
$doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([
|
$doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([
|
||||||
'bid' => $acc['bid'],
|
'bid' => $acc['bid'],
|
||||||
'code' => $params['code']
|
'code' => $params['code']
|
||||||
]);
|
]);
|
||||||
if (!$doc) throw $this->createNotFoundException();
|
if (!$doc)
|
||||||
|
throw $this->createNotFoundException();
|
||||||
$pdfPid = 0;
|
$pdfPid = 0;
|
||||||
if ($params['pdf']) {
|
if ($params['pdf']) {
|
||||||
$pdfPid = $provider->createPrint(
|
$pdfPid = $provider->createPrint(
|
||||||
|
@ -339,10 +385,10 @@ class SellController extends AbstractController
|
||||||
$this->getUser(),
|
$this->getUser(),
|
||||||
$this->renderView('pdf/posPrinters/sell.html.twig', [
|
$this->renderView('pdf/posPrinters/sell.html.twig', [
|
||||||
'bid' => $acc['bid'],
|
'bid' => $acc['bid'],
|
||||||
'doc'=>$doc,
|
'doc' => $doc,
|
||||||
'rows'=>$doc->getHesabdariRows(),
|
'rows' => $doc->getHesabdariRows(),
|
||||||
'printInvoice'=>$params['posPrint'],
|
'printInvoice' => $params['posPrint'],
|
||||||
'printcashdeskRecp'=>$params['posPrintRecp'],
|
'printcashdeskRecp' => $params['posPrintRecp'],
|
||||||
]),
|
]),
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
@ -388,13 +434,15 @@ class SellController extends AbstractController
|
||||||
}
|
}
|
||||||
|
|
||||||
$acc = $access->hasRole('sell');
|
$acc = $access->hasRole('sell');
|
||||||
if (!$acc) throw $this->createAccessDeniedException();
|
if (!$acc)
|
||||||
|
throw $this->createAccessDeniedException();
|
||||||
|
|
||||||
$doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([
|
$doc = $entityManager->getRepository(HesabdariDoc::class)->findOneBy([
|
||||||
'bid' => $acc['bid'],
|
'bid' => $acc['bid'],
|
||||||
'code' => $params['code']
|
'code' => $params['code']
|
||||||
]);
|
]);
|
||||||
if (!$doc) throw $this->createNotFoundException();
|
if (!$doc)
|
||||||
|
throw $this->createNotFoundException();
|
||||||
$person = null;
|
$person = null;
|
||||||
$discount = 0;
|
$discount = 0;
|
||||||
$transfer = 0;
|
$transfer = 0;
|
||||||
|
@ -411,35 +459,37 @@ class SellController extends AbstractController
|
||||||
if ($params['pdf']) {
|
if ($params['pdf']) {
|
||||||
$printOptions = [
|
$printOptions = [
|
||||||
'bidInfo' => true,
|
'bidInfo' => true,
|
||||||
'pays' =>true,
|
'pays' => true,
|
||||||
'taxInfo' =>true,
|
'taxInfo' => true,
|
||||||
'discountInfo' =>true,
|
'discountInfo' => true,
|
||||||
'note' =>true,
|
'note' => true,
|
||||||
'paper' =>'A4-L'
|
'paper' => 'A4-L'
|
||||||
];
|
];
|
||||||
if(array_key_exists('printOptions',$params)){
|
if (array_key_exists('printOptions', $params)) {
|
||||||
if(array_key_exists('bidInfo',$params['printOptions'])){
|
if (array_key_exists('bidInfo', $params['printOptions'])) {
|
||||||
$printOptions['bidInfo'] = $params['printOptions']['bidInfo'];
|
$printOptions['bidInfo'] = $params['printOptions']['bidInfo'];
|
||||||
}
|
}
|
||||||
if(array_key_exists('pays',$params['printOptions'])){
|
if (array_key_exists('pays', $params['printOptions'])) {
|
||||||
$printOptions['pays'] = $params['printOptions']['pays'];
|
$printOptions['pays'] = $params['printOptions']['pays'];
|
||||||
}
|
}
|
||||||
if(array_key_exists('taxInfo',$params['printOptions'])){
|
if (array_key_exists('taxInfo', $params['printOptions'])) {
|
||||||
$printOptions['taxInfo'] = $params['printOptions']['taxInfo'];
|
$printOptions['taxInfo'] = $params['printOptions']['taxInfo'];
|
||||||
}
|
}
|
||||||
if(array_key_exists('discountInfo',$params['printOptions'])){
|
if (array_key_exists('discountInfo', $params['printOptions'])) {
|
||||||
$printOptions['discountInfo'] = $params['printOptions']['discountInfo'];
|
$printOptions['discountInfo'] = $params['printOptions']['discountInfo'];
|
||||||
}
|
}
|
||||||
if(array_key_exists('note',$params['printOptions'])){
|
if (array_key_exists('note', $params['printOptions'])) {
|
||||||
$printOptions['note'] = $params['printOptions']['note'];
|
$printOptions['note'] = $params['printOptions']['note'];
|
||||||
}
|
}
|
||||||
if(array_key_exists('paper',$params['printOptions'])){
|
if (array_key_exists('paper', $params['printOptions'])) {
|
||||||
$printOptions['paper'] = $params['printOptions']['paper'];
|
$printOptions['paper'] = $params['printOptions']['paper'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$note = '';
|
$note = '';
|
||||||
$printSettings = $entityManager->getRepository(PrintOptions::class)->findOneBy(['bid'=>$acc['bid']]);
|
$printSettings = $entityManager->getRepository(PrintOptions::class)->findOneBy(['bid' => $acc['bid']]);
|
||||||
if($printSettings){$note = $printSettings->getSellNoteString();}
|
if ($printSettings) {
|
||||||
|
$note = $printSettings->getSellNoteString();
|
||||||
|
}
|
||||||
$pdfPid = $provider->createPrint(
|
$pdfPid = $provider->createPrint(
|
||||||
$acc['bid'],
|
$acc['bid'],
|
||||||
$this->getUser(),
|
$this->getUser(),
|
||||||
|
@ -451,8 +501,8 @@ class SellController extends AbstractController
|
||||||
'printInvoice' => $params['printers'],
|
'printInvoice' => $params['printers'],
|
||||||
'discount' => $discount,
|
'discount' => $discount,
|
||||||
'transfer' => $transfer,
|
'transfer' => $transfer,
|
||||||
'printOptions'=> $printOptions,
|
'printOptions' => $printOptions,
|
||||||
'note'=> $note
|
'note' => $note
|
||||||
]),
|
]),
|
||||||
false,
|
false,
|
||||||
$printOptions['paper']
|
$printOptions['paper']
|
||||||
|
|
Loading…
Reference in a new issue