Knowee
Questions
Features
Study Tools

public function createInvoice(Request $request) { if (\Session::has('shoping_card')){ \Session::remove('shoping_card'); \Session::save(); }else{ return redirect()->route('customer')->with(['message' => __('The order is duplicate please check invoices list')]); } $dis = Discount::where('code',\request('discount') ); if ($dis->count() > 0){ $invData['discount_id']= $dis->firstOrFail()->id; $…alt = $request->address_alt; } // fix problem if (!isset($discountAmount)){ $discountAmount = 0; } $invoice->total_price = $invoice->total_price - $discountAmount; if ($request->has('transport_id')){ $t = Transport::whereId($request->transport_id)->first(); $invoice->total_price += $t->price; $invoice->transport_price = $t->price; } $invoice->save();// dd($invoice);//

Question

public function createInvoice(Request request) { if (\Session::has('shoping_card')){ \Session::remove('shoping_card'); \Session::save(); }else{ return redirect()->route('customer')->with(['message' => __('The order is duplicate please check invoices list')]); } dis = Discount::where('code',\request('discount') ); if (dis->count() > 0){ invData['discount_id']= dis>firstOrFail()>id;dis->firstOrFail()->id; …alt = request->address_alt; } // fix problem if (!isset(discountAmount)){ discountAmount = 0; } invoice->total_price = invoice>totalpriceinvoice->total_price - discountAmount; if (request->has('transport_id')){ t = Transport::whereId(request>transportid)>first();request->transport_id)->first(); invoice->total_price += t>price;t->price; invoice->transport_price = t->price; } invoice->save();// dd($invoice);//

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

This is a PHP function named createInvoice which is used to create an invoice. It takes a Request object as an argument.

Here's a step-by-step explanation:

  1. The function first checks if there is a 'shoping_card' session. If it exists, it removes the session and saves the changes. If it doesn't exist, it redirects to the 'customer' route with a message saying "The order is duplicate please check invoices list".

  2. It then checks if there is a discount code in the request. If there is, it fetches the discount from the Discount model where the code matches the one in the request. If a discount is found, it sets the discount_id in the invData array to the id of the discount.

  3. It then sets the address_alt in the invData array to the address_alt from the request.

  4. It checks if the discountAmount is set. If it's not, it sets it to 0.

  5. It then calculates the total price of the invoice by subtracting the discountAmount from the total_price.

  6. If there is a transport_id in the request, it fetches the transport from the Transport model where the id matches the one in the request. It then adds the price of the transport to the total price of the invoice and sets the transport_price to the price of the transport.

  7. Finally, it saves the invoice.

This problem has been solved

Similar Questions

In the revenue and receipts cycle, a new customer wishes to purchase inventory on credit, at your shop. Select the first step that you will insist should be followed by your staff. a.Request a valid purchase order from the customer before processing the order.b.Create a correct purchase order, signed by the customer.c.Request that a credit application form be completed by the customer.d.Set up an accounts receivable account for the customer in the accounts receivable ledger.

You want to offer a new customer a 5 percent discount on the customer's first order. If there are three items on the invoice, how will you apply the discount?Select an answer:Total the invoice items, and then enter Discount 5% below the total.Subtotal the invoice items, and then enter Discount 5% below the subtotal.Enter Discount 5 below the last item on the invoice.Enter Discount 5% below the last item on the invoice.

A cash discount is provided on:Question 8Answera.Cash purchasesb.Purchasesc.Salesd.Prompt payment

Matching QuestionJuice Drinks sold merchandise on December 1 at a $500 invoice price, net $495, with terms of 1/10,n/30 and received cash payment on December 4, within the discount period. Determine its entry to record this sale and the subsequent receipt of cash under both the gross method and the net methods by matching the action on the left with the method on the right. (Assume a perpetual inventory system.)InstructionsDrag and drop application.Sales Discounts would be debited for $5 on December 4.Sales Discounts would be debited for $5 on December 4. drop zone empty.Accounts Receivable would be debited for $495 on December 1.Accounts Receivable would be debited for $495 on December 1. drop zone empty.Cash would be debited for $495 on December 4.Cash would be debited for $495 on December 4. drop zone empty.AnswerOur bot hasn't seen this question yet. The answer will be stored the next time it appears.Net methodBoth methodsGross method

A cash discount is provided on:Question 2Answera.Salesb.Prompt paymentc.Cash purchasesd.Purchases

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.