@@ -7,7 +7,7 @@ |
||
| 7 | 7 | use ControleOnline\Entity\Status; |
| 8 | 8 | use Doctrine\ORM\EntityManagerInterface; |
| 9 | 9 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface |
| 10 | - AS Security; |
|
| 10 | + AS Security; |
|
| 11 | 11 | |
| 12 | 12 | class OrderInvoiceService |
| 13 | 13 | { |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | private StatusService $statusService, |
| 23 | 23 | RequestStack $requestStack |
| 24 | 24 | ) { |
| 25 | - $this->request = $requestStack->getCurrentRequest(); |
|
| 25 | + $this->request = $requestStack->getCurrentRequest(); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | public function calculateOrderPrice(Order $order) |
@@ -79,17 +79,21 @@ discard block |
||
| 79 | 79 | $order = $orderProduct->getOrder(); |
| 80 | 80 | $product = $orderProduct->getProduct(); |
| 81 | 81 | |
| 82 | - if ($order->getOrderType() == 'sale' && !$orderProduct->getOutInventory()) |
|
| 83 | - $orderProduct->setOutInventory($product->getDefaultOutInventory()); |
|
| 82 | + if ($order->getOrderType() == 'sale' && !$orderProduct->getOutInventory()) { |
|
| 83 | + $orderProduct->setOutInventory($product->getDefaultOutInventory()); |
|
| 84 | + } |
|
| 84 | 85 | |
| 85 | - if ($order->getOrderType() == 'purchase' && !$orderProduct->getInInventory()) |
|
| 86 | - $orderProduct->setInInventory($product->getDefaultInInventory()); |
|
| 86 | + if ($order->getOrderType() == 'purchase' && !$orderProduct->getInInventory()) { |
|
| 87 | + $orderProduct->setInInventory($product->getDefaultInInventory()); |
|
| 88 | + } |
|
| 87 | 89 | } |
| 88 | 90 | |
| 89 | 91 | public function postPersist(OrderProduct $orderProduct) |
| 90 | 92 | { |
| 91 | 93 | |
| 92 | - if (!self::$mainProduct || !$this->request) return; |
|
| 94 | + if (!self::$mainProduct || !$this->request) { |
|
| 95 | + return; |
|
| 96 | + } |
|
| 93 | 97 | self::$mainProduct = false; |
| 94 | 98 | |
| 95 | 99 | $json = json_decode($this->request->getContent(), true); |
@@ -107,7 +111,9 @@ discard block |
||
| 107 | 111 | public function preRemove(OrderProduct $orderProduct) |
| 108 | 112 | { |
| 109 | 113 | |
| 110 | - if (!self::$mainProduct) return; |
|
| 114 | + if (!self::$mainProduct) { |
|
| 115 | + return; |
|
| 116 | + } |
|
| 111 | 117 | self::$mainProduct = false; |
| 112 | 118 | $order = $orderProduct->getOrder(); |
| 113 | 119 | $this->manager->persist($order->setPrice(0)); |
@@ -116,8 +122,9 @@ discard block |
||
| 116 | 122 | 'parentProduct' => $orderProduct->getProduct(), |
| 117 | 123 | ]); |
| 118 | 124 | |
| 119 | - foreach ($parentProducts as $parentProduct) |
|
| 120 | - $this->manager->remove($parentProduct); |
|
| 125 | + foreach ($parentProducts as $parentProduct) { |
|
| 126 | + $this->manager->remove($parentProduct); |
|
| 127 | + } |
|
| 121 | 128 | $this->manager->flush(); |
| 122 | 129 | |
| 123 | 130 | self::$calculateBefore[] = $order; |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | $this->request = $this->requestStack->getCurrentRequest(); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - public function addOrderProduct(Order $order, Product $product, $quantity, $price, ?ProductGroup $productGroup = null, ?Product $parentProduct = null, ?OrderProduct $orderProductParent = null): OrderProduct |
|
| 35 | + public function addOrderProduct(Order $order, Product $product, $quantity, $price, ?ProductGroup $productGroup = null, ?Product $parentProduct = null, ?OrderProduct $orderProductParent = null): OrderProduct |
|
| 36 | 36 | { |
| 37 | 37 | $OProduct = new OrderProduct(); |
| 38 | 38 | $OProduct->setOrder($order); |
@@ -74,10 +74,10 @@ discard block |
||
| 74 | 74 | $this->orderProductQueueService->addProductToQueue($OProduct); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - private function checkInventory(OrderProduct &$orderProduct) |
|
| 77 | + private function checkInventory(OrderProduct & $orderProduct) |
|
| 78 | 78 | { |
| 79 | 79 | $order = $orderProduct->getOrder(); |
| 80 | - $product = $orderProduct->getProduct(); |
|
| 80 | + $product = $orderProduct->getProduct(); |
|
| 81 | 81 | |
| 82 | 82 | if ($order->getOrderType() == 'sale' && !$orderProduct->getOutInventory()) |
| 83 | 83 | $orderProduct->setOutInventory($product->getDefaultOutInventory()); |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | $this->checkInventory($orderProduct); |
| 98 | 98 | foreach ($subProducts as $subproduct) { |
| 99 | 99 | $product = $this->manager->getRepository(Product::class)->find($subproduct['product']); |
| 100 | - $productGroup = $this->manager->getRepository(ProductGroup::class)->find($subproduct['productGroup']); |
|
| 100 | + $productGroup = $this->manager->getRepository(ProductGroup::class)->find($subproduct['productGroup']); |
|
| 101 | 101 | $this->addSubproduct($orderProduct, $product, $productGroup, $subproduct['quantity']); |
| 102 | 102 | } |
| 103 | 103 | $this->orderProductQueueService->addProductToQueue($orderProduct); |
@@ -63,8 +63,8 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | $quantity = $orderProduct->getQuantity(); |
| 65 | 65 | $this->printService->addLine( |
| 66 | - $indent . $quantity . ' X ' . $product->getProduct(), |
|
| 67 | - " R$ " . number_format($orderProduct->getTotal(), 2, ',', '.'), |
|
| 66 | + $indent.$quantity.' X '.$product->getProduct(), |
|
| 67 | + " R$ ".number_format($orderProduct->getTotal(), 2, ',', '.'), |
|
| 68 | 68 | '.' |
| 69 | 69 | ); |
| 70 | 70 | } |
@@ -82,10 +82,10 @@ discard block |
||
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | foreach ($groupedChildren as $groupName => $orderProductChildren) { |
| 85 | - $this->printService->addLine(strtoupper($groupName) . ":"); |
|
| 85 | + $this->printService->addLine(strtoupper($groupName).":"); |
|
| 86 | 86 | foreach ($orderProductChildren as $orderProductChild) { |
| 87 | 87 | $product = $orderProductChild->getProduct(); |
| 88 | - $this->printService->addLine(" - " . $product->getProduct()); |
|
| 88 | + $this->printService->addLine(" - ".$product->getProduct()); |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | $this->printService->addLine('', '', '-'); |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | foreach ($queues as $queueName => $orderProducts) { |
| 113 | 113 | $parentOrderProducts = array_filter($orderProducts, fn($orderProduct) => $orderProduct->getOrderProduct() === null); |
| 114 | 114 | if (!empty($parentOrderProducts)) { |
| 115 | - $this->printService->addLine(strtoupper($queueName) . ":"); |
|
| 115 | + $this->printService->addLine(strtoupper($queueName).":"); |
|
| 116 | 116 | $this->printQueueProducts($orderProducts); |
| 117 | 117 | $this->printService->addLine('', '', ' '); |
| 118 | 118 | } |
@@ -122,11 +122,11 @@ discard block |
||
| 122 | 122 | public function generatePrintData(Order $order, Device $device, ?array $aditionalData = []): Spool |
| 123 | 123 | { |
| 124 | 124 | |
| 125 | - $this->printService->addLine("PEDIDO #" . $order->getId()); |
|
| 125 | + $this->printService->addLine("PEDIDO #".$order->getId()); |
|
| 126 | 126 | $this->printService->addLine($order->getOrderDate()->format('d/m/Y H:i')); |
| 127 | 127 | $client = $order->getClient(); |
| 128 | 128 | $this->printService->addLine(($client !== null ? $client->getName() : 'Não informado')); |
| 129 | - $this->printService->addLine("R$ " . number_format($order->getPrice(), 2, ',', '.')); |
|
| 129 | + $this->printService->addLine("R$ ".number_format($order->getPrice(), 2, ',', '.')); |
|
| 130 | 130 | $this->printService->addLine("", "", "-"); |
| 131 | 131 | $queues = $this->getQueues($order); |
| 132 | 132 | |
@@ -47,14 +47,17 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | public function printOrder(Order $order, ?array $devices = []) |
| 49 | 49 | { |
| 50 | - if (empty($devices)) |
|
| 51 | - $devices = $this->configService->getConfig($order->getProvider(), 'order-print-devices', true); |
|
| 50 | + if (empty($devices)) { |
|
| 51 | + $devices = $this->configService->getConfig($order->getProvider(), 'order-print-devices', true); |
|
| 52 | + } |
|
| 52 | 53 | |
| 53 | - if ($devices) |
|
| 54 | - $devices = $this->deviceService->findDevices($devices); |
|
| 54 | + if ($devices) { |
|
| 55 | + $devices = $this->deviceService->findDevices($devices); |
|
| 56 | + } |
|
| 55 | 57 | |
| 56 | - foreach ($devices as $device) |
|
| 57 | - $this->generatePrintData($order, $device); |
|
| 58 | + foreach ($devices as $device) { |
|
| 59 | + $this->generatePrintData($order, $device); |
|
| 60 | + } |
|
| 58 | 61 | } |
| 59 | 62 | |
| 60 | 63 | private function printProduct($orderProduct, $indent = "- ") |
@@ -100,8 +103,9 @@ discard block |
||
| 100 | 103 | $this->printProduct($parentOrderProduct); |
| 101 | 104 | |
| 102 | 105 | $childs = $parentOrderProduct->getOrderProductComponents(); |
| 103 | - if (!empty($childs)) |
|
| 104 | - $this->printChildren($childs); |
|
| 106 | + if (!empty($childs)) { |
|
| 107 | + $this->printChildren($childs); |
|
| 108 | + } |
|
| 105 | 109 | |
| 106 | 110 | $this->printService->addLine('', '', '-'); |
| 107 | 111 | } |