/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { // $ventas = ventas::with('clientes', 'tiendas', 'factura_remision')->where('remision', 1)->get(); //dd($ventas); return view('app.ventas.ventas_index', compact('ventas')); }
public static function requestXfactura($request) { foreach ($request->pagos as $pago) { $valor = $pago['valor']; foreach ($request->items as $factura) { $venta = ventas::find($factura['id']); $residual = $venta->venta - $venta->pagado; if ($residual == 0) { continue; } if ($venta->remision == 1) { $facturas[] = ['factura' => $venta->factura, 'nombre' => 'remision']; } else { $facturas[] = ['factura' => $venta->factura, 'nombre' => 'venta']; } if ($valor <= $residual) { $venta->pagado = $venta->pagado + $valor; $venta->save(); ingresos::IngresoXfactura($venta->id, $venta->remision, $pago['id'], $valor); break; } else { $valor = $valor - $residual; $venta->pagado = $venta->pagado + $residual; $venta->save(); ingresos::IngresoXfactura($venta->id, $venta->remision, $pago['id'], $residual); } } } caja::IngresoCajaXfactura($request->pagos, $facturas); }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { //primero verificamos que este abierta la caja $caja_abierta = caja::CajaAbierta(); if (!isset($caja_abierta)) { Session::flash('mensaje', 'Primero debe abrir al caja para Agregar un pago a la venta'); return redirect('caja'); } $ventas = ventas::with('clientes')->whereraw('venta > pagado')->get(); return view('app.ingresos.ingresos_create', compact('ventas')); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { // $tipo = facturacion::find($id); if (!$tipo->venta_id == 0) { $venta = ventas::with('venta_detalle.productos_configurables', 'clientes', 'tiendas.company', 'user')->find($tipo->venta_id); } if (!$tipo->remision_id == 0) { $remision = ventas::with('venta_detalle.productos_configurables', 'clientes', 'tiendas.company', 'user')->find($tipo->remision_id); } //dd($remision); return view('app/ventas/ventas_pos_invoice', compact('venta', 'remision')); }
public static function pagar($id, $request) { $venta = ventas::find($id); $valor = 0; foreach ($request->pagos as $pago) { $valor += $pago['valor']; } $venta->pagado = $venta->pagado + $valor; $venta->save(); if ($venta->remision == 1) { $lastid['venta'] = ""; $lastid['remision'] = ['id' => $venta->id, 'factura' => $venta->factura]; } else { $lastid['remision'] = ""; $lastid['venta'] = ['id' => $venta->id, 'factura' => $venta->factura]; } return $lastid; }
public function chart(Request $request) { //cargar graficos de estadisticas $top_ventas = ventas::top_ventas($request->id); return response()->json($top_ventas); }
public function mail(Request $request, $id) { $pdf = ventas::crear_pdf($id); Mail::send('app.ventas.ventas_email', compact(['request']), function ($message) use($pdf, $request) { $message->to($request->email_address)->subject('Envio de factura de venta '); $message->attachData($pdf->output(), "invoice.pdf"); }); Session::flash('mensaje', 'factura enviada con exito'); return back(); }