generatesTransactionBillNumber = $generatesTransactionBillNumber; $this->createPurchaseOrderTransactionProcessor = $createPurchaseOrderTransactionProcessor; $this->updatesTransactionStatus = $updatesTransactionStatus; $this->createInvoiceTransactionProcessor = $createInvoiceTransactionProcessor; } public function execute(Booking $booking){ $billNumber = $this->generatesTransactionBillNumber->execute('PO-'); $products = [ [ 'description' => 'please refer to the attachment below', 'quantity' => 1, 'stockCode' => '', 'unit_price' => $booking->fix_amount ] ]; $total = collect($products)->sum(function($product){ return $product['quantity'] * floatval(str_replace(',', '', $product['unit_price'])); }); $object = new TransactionObject($billNumber, TransactionType::PURCHASE_ORDER, $booking->company->id, 1, 1, PaymentMethodType::CASH, $total, $total, $booking->fix_currency_id, $booking->fix_currency_id, 1, 0, 0, null, ApprovalStatus::PENDING_SUBMISSION, $products); $purchaseOrder = $this->createPurchaseOrderTransactionProcessor->execute($booking, $object); $this->updatesTransactionStatus->execute($purchaseOrder, ApprovalStatus::APPROVED); $this->createInvoiceTransactionProcessor->execute($booking); } }