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']= …alt = request->address_alt; } // fix problem if (!isset(discountAmount)){ discountAmount = 0; } invoice->total_price = discountAmount; if (request->has('transport_id')){ t = Transport::whereId(invoice->total_price += invoice->transport_price = t->price; } invoice->save();// dd($invoice);//
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:
-
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".
-
It then checks if there is a discount code in the request. If there is, it fetches the discount from the
Discountmodel where the code matches the one in the request. If a discount is found, it sets thediscount_idin theinvDataarray to the id of the discount. -
It then sets the
address_altin theinvDataarray to theaddress_altfrom the request. -
It checks if the
discountAmountis set. If it's not, it sets it to 0. -
It then calculates the total price of the invoice by subtracting the
discountAmountfrom thetotal_price. -
If there is a
transport_idin the request, it fetches the transport from theTransportmodel 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 thetransport_priceto the price of the transport. -
Finally, it saves the invoice.
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
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.