/**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create($id)
 {
     $venda = Venda::find($id);
     $total = $venda->totalVenda($id);
     $entradas = Lancamento::where('venda_id', $id)->where('tipo', 'en')->get();
     $descontos = Lancamento::where('venda_id', $id)->where('tipo', 'dc')->get();
     $boletos = Lancamento::with('boleto')->where('venda_id', $id)->where('tipo', 'bo')->get();
     $cheques = Lancamento::where('venda_id', $id)->where('tipo', 'ch')->leftJoin('cheques', 'cheques.lancamento_id', '=', 'lancamentos.id')->leftJoin('bancos', 'cheques.banco_id', '=', 'bancos.id')->select('lancamentos.id', 'lancamentos.valor', 'lancamentos.descricao', 'lancamentos.data_vencimento', 'lancamentos.tipo', 'cheques.id as cheque_id', 'cheques.banco_id', 'cheques.numero', 'cheques.nome as nome_cheque', 'bancos.nome as nome_banco')->get();
     $bancos = Banco::with('cheques')->orderBy('nome')->select('nome', 'id')->get();
     return view('lancamentos.create', compact('venda', 'total', 'entradas', 'boletos', 'cheques', 'bancos', 'descontos'));
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $venda = Venda::find($id);
     $total = 0;
     foreach ($venda->venda_itens as $itens) {
         $total += $itens->quantidade * $itens->preco_venda;
     }
     $entradas = \App\Models\Lancamento::where('venda_id', $id)->where('tipo', 'en')->get();
     $boletos = \App\Models\Lancamento::with('boleto')->where('venda_id', $id)->where('tipo', 'bo')->get();
     $cheques = \App\Models\Lancamento::with('cheque')->where('venda_id', $id)->where('tipo', 'ch')->get();
     return view('vendas.show', compact('venda', 'total', 'entradas', 'boletos', 'cheques'));
 }
Example #3
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $lancamentos = Lancamento::where('data_vencimento', date('Y-m-d'))->where('status', 1)->orderBy('descricao')->get();
     return view('home.index', compact('lancamentos'));
 }
Example #4
0
 public static function getTotalDescontoVenda($id)
 {
     $desconto = Lancamento::where('venda_id', $id)->sum('desconto');
     return $desconto;
 }
Example #5
0
 public static function getEntradasVenda($id)
 {
     return Lancamento::where('venda_id', $id)->where('tipo', 'en')->get();
 }
 private function getValorTotalLancamentos($venda_id)
 {
     $venda = Venda::find($venda_id);
     $total_venda = VendaItem::where('venda_id', $venda_id);
     $total_venda->select(DB::raw('sum(quantidade * preco_venda) as total'));
     $total_venda = $total_venda->get();
     $retorno = Lancamento::where('venda_id', $venda_id);
     $total = $total_venda[0]->total;
     $saldo = $retorno->sum('valor');
     return ['total_geral' => $total, 'saldo' => $saldo, 'descontos' => $retorno->sum('desconto')];
 }