Exemplo n.º 1
0
 public function getPartydue($invoiceId)
 {
     $totalPrice = 0;
     $totalAmount = 0;
     $sale = Sale::where('invoice_id', '=', $invoiceId)->first();
     $saleDetails = SAleDetail::where('invoice_id', '=', $invoiceId)->get();
     $transactions = Transaction::where('invoice_id', '=', $invoiceId)->where('payment_method', '=', 'Check')->where('type', '=', 'Receive')->where('cheque_status', '=', 1)->get();
     foreach ($saleDetails as $saleDetail) {
         $totalPrice = $totalPrice + $saleDetail->price * $saleDetail->quantity;
     }
     $totalPrice -= $sale->discount_percentage;
     foreach ($transactions as $transaction) {
         $totalAmount = $totalAmount + $transaction->amount;
     }
     $transactions2 = Transaction::where('invoice_id', '=', $invoiceId)->where('type', '=', 'Receive')->where('payment_method', '!=', 'Check')->get();
     foreach ($transactions2 as $transaction) {
         $totalAmount = $totalAmount + $transaction->amount;
     }
     $due = $totalPrice - $totalAmount;
     if ($due > 0) {
         return "Due is {$due}";
     } else {
         return 'No due';
     }
 }
Exemplo n.º 2
0
 public function getSale($invoice_id)
 {
     $saleDetails = SAleDetail::where('invoice_id', '=', $invoice_id)->get();
     $sale = Sale::where('invoice_id', '=', $invoice_id)->get();
     foreach ($saleDetails as $saleDetail) {
         $stock = new Stock();
         $stock->branch_id = $saleDetail->branch_id;
         $stock->product_id = $saleDetail->product_id;
         $stock->product_type = $saleDetail->product_type;
         $stock->product_quantity = $saleDetail->quantity;
         $stock->entry_type = "StockOut";
         $stock->remarks = $saleDetail->remarks;
         $stock->user_id = Session::get('user_id');
         $stock->stock_info_id = $saleDetail->stock_info_id;
         $stock->status = "Activate";
         $stockCount = StockCount::where('product_id', '=', $saleDetail->product_id)->where('stock_info_id', '=', $saleDetail->stock_info_id)->get();
         if (!empty($stockCount[0])) {
             if ($stockCount[0]->product_quantity >= $saleDetail->quantity) {
                 $stockCount[0]->product_quantity = $stockCount[0]->product_quantity - $saleDetail->quantity;
                 $stock->save();
                 $stockCount[0]->save();
                 $sale[0]->is_sale = 1;
                 $sale[0]->save();
                 Session::flash('message', 'Stock  has been Successfully Balanced.');
             } else {
                 Session::flash('message', 'You Dont have enough products in Stock');
             }
         } else {
             Session::flash('message', 'You Dont have This products in This Stock');
         }
     }
     return Redirect::to('sales/index');
 }
Exemplo n.º 3
0
                                        @endif


                                    </td>

                                </tr>
                                <?php 
$sl++;
?>
                            @endif
                        @endforeach

                    @else
                        @foreach($sales as $sale )
                            <?php 
$hasDetails = \App\SAleDetail::where('invoice_id', '=', $sale->invoice_id)->get();
?>
                            @if(count($hasDetails) > 0)
                                <tr class="odd gradeX">
                                    <td><?php 
echo $sl;
?>
</td>
                                    <td>{{$sale->invoice_id}}</td>
                                    <td>{{$sale->party->name}}</td>
                                    @if($sale->status == 'Activate')
                                        <td><span class="label label-sm label-danger">Due</span></td>
                                    @elseif($sale->status == 'Partial')
                                        <td><span class="label label-sm label-warning">Partial</span></td>
                                    @elseif($sale->status == 'Completed')
                                        <td><span class="label label-sm label-success">Completed</span></td>
Exemplo n.º 4
0
@section('styles')
    <link rel="stylesheet" type="text/css" href="{{ URL::asset('assets/plugins/select2/select2_metro.css') }}"/>

@stop
@section('content')
    <div class="row">

        <div class="col-xs-2 invoice-block" style="margin-left: 880px;">
            <a class="btn btn-sm blue hidden-print" onclick="javascript:window.print();">Print <i class="fa fa-print"></i></a>
        </div>
    </div>
    <div class="invoice">
        <div class="row invoice-logo">
            <div class="col-xs-12 invoice-logo-space">
                <?php 
$sale22 = \App\SAleDetail::where('invoice_id', '=', $transaction->invoice_id)->first();
?>
                @if($sale22->branch_id == 1)
                    <img src="../../assets/img/pad/cemon-vc.jpg" style="width: 100%;"  alt="" />
                @elseif($sale22->branch_id == 2)
                    <img src="../../assets/img/pad/fst-vc.jpg" style="width: 100%;"  alt="" />
                @elseif($sale22->branch_id == 3)
                    <img src="../../assets/img/pad/cemon-vc.jpg" style="width: 100%;"  alt="" />
                @elseif($sale22->branch_id == 4)
                    <img src="../../assets/img/pad/cemon-vc.jpg" style="width: 100%;"  alt="" />
                @elseif($sale22->branch_id == 5)
                    <img src="../../assets/img/pad/sun-vc.jpg" style="width: 100%;"  alt="" />
                @elseif($sale22->branch_id == 6)
                    <img src="../../assets/img/pad/olympic-vc.jpg" style="width: 100%;"  alt="" />
                @elseif($sale22->branch_id == 7)
                    <img src="../../assets/img/pad/keyon1.jpg" style="width: 100%;"  alt="" />
Exemplo n.º 5
0
 public function postSaveSalesReturn()
 {
     $ruless = array('party_id' => 'required');
     $validate = Validator::make(Input::all(), $ruless);
     if ($validate->fails()) {
         return json_encode($validate);
     } else {
         $salesreturn = new SalesReturnInvoice();
         $this->setSalesReturnData($salesreturn);
         $salesReturnDetails = new SalesReturnDetail();
         $salesReturnDetails->product_type = Input::get('product_type');
         $salesReturnDetails->product_id = Input::get('product_id');
         $salesReturnDetails->quantity = Input::get('quantity');
         $salesReturnDetails->unit_price = Input::get('unit_price');
         $salesReturnDetails->return_amount = $salesReturnDetails->quantity * $salesReturnDetails->unit_price - $salesReturnDetails->quantity * $salesReturnDetails->unit_price * ((double) Input::get('discount_percentage') / 100);
         $salesReturnDetails->consignment_name = Input::get('consignment_name');
         $salesReturnDetails->invoice_id = Input::get('invoice_id');
         $salesReturnDetails->save();
         //automatically reduce sales payment starts
         $unit_price = Input::get('unit_price');
         $remaining_amount = $salesReturnDetails->return_amount;
         //var_dump($remaining_amount);
         $partyId = Input::get('party_id');
         if ($remaining_amount > 0) {
             $invoiceId = Sale::where('party_id', '=', $partyId)->where('is_sale', '=', 1)->get();
             foreach ($invoiceId as $invid) {
                 $price = SAleDetail::where('invoice_id', '=', $invid->invoice_id)->get();
                 $detailsPrice = 0;
                 foreach ($price as $prc) {
                     $detailsPrice = $detailsPrice + $prc->price * $prc->quantity;
                 }
                 //var_dump($detailsPrice);
                 $amount = Transaction::where('invoice_id', '=', $invid->invoice_id)->where('type', '=', 'Receive')->get();
                 $paid = 0;
                 foreach ($amount as $amnt) {
                     $paid = $paid + $amnt->amount;
                 }
                 $difference = $detailsPrice - $paid;
                 if ($difference > 0) {
                     //echo 'greater than 0 difference';
                     if ($remaining_amount <= $difference) {
                         if ($remaining_amount > 0) {
                             $sale = Sale::find($invid->id);
                             if ($remaining_amount < $difference) {
                                 $sale->status = "Partial";
                             } elseif ($remaining_amount == $difference) {
                                 $sale->status = "Completed";
                             }
                             $transaction = new Transaction();
                             $transaction->invoice_id = $invid->invoice_id;
                             $transaction->amount = $remaining_amount;
                             $transaction->type = 'Receive';
                             $transaction->payment_method = 'Sales Return';
                             $transaction->account_category_id = 7;
                             $transaction->remarks = Input::get('invoice_id');
                             $transaction->account_name_id = 8;
                             $transaction->user_id = Session::get('user_id');
                             $transaction->cheque_no = '';
                             $branch = SAleDetail::where('invoice_id', '=', $invid->invoice_id)->first();
                             $transaction->branch_id = $branch->branch_id;
                             $transaction->save();
                             $remaining_amount = 0;
                         }
                     } elseif ($remaining_amount > $difference) {
                         if ($remaining_amount > 0) {
                             $sale = Sale::find($invid->id);
                             $sale->status = "Completed";
                             $toBePaid = $remaining_amount - $difference;
                             $transaction = new Transaction();
                             $transaction->invoice_id = $invid->invoice_id;
                             $transaction->amount = $difference;
                             $transaction->type = 'Receive';
                             $transaction->payment_method = 'Sales Return';
                             $transaction->account_category_id = 7;
                             $transaction->remarks = Input::get('invoice_id');
                             $transaction->account_name_id = 8;
                             $transaction->user_id = Session::get('user_id');
                             $transaction->cheque_no = '';
                             $branch = SAleDetail::where('invoice_id', '=', $invid->invoice_id)->first();
                             $transaction->branch_id = $branch->branch_id;
                             $transaction->save();
                             $remaining_amount = $toBePaid;
                         }
                     }
                     $sale->save();
                 }
             }
         }
         /*if($remaining_amount>0)
           {
               echo "How come its possible! Consult with DEVELOPERS!!!";
           }*/
         //automatically reduce sales payment ends
         return $this->saleReturnDetailConvertToArray($salesReturnDetails);
     }
 }
Exemplo n.º 6
0
    $('.modal-backdrop').hide();*/
    $("#sale").modal('hide').on('hidden.bs.modal', functionThatEndsUpDestroyingTheDOM);
    $('.modal-backdrop').hide();
}
</script>
<div class="modal-dialog shape">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" onclick="closeModal()" class="close" data-dismiss="modal" aria-hidden="true"></button>
            <?php 
$party = new \App\Party();
$partyName = \App\Party::find($sale->party_id);
?>
            <h3>Sales Detail for {{$partyName->name}}</h3>
            <?php 
$saledetails = \App\SAleDetail::where('invoice_id', '=', $sale->invoice_id)->first();
$branchname = \App\Branch::find($saledetails->branch_id);
?>
            <h3>Branch Name : <?php 
echo $branchname->name;
?>
</h3>
            <p>Invoice Id : <?php 
echo $sale->invoice_id;
?>
</p>
            <p>Date : <?php 
echo \App\Transaction::convertDate($sale->created_at);
?>
</p>
 public function postSaveSalesReturn()
 {
     $ruless = array('party_id' => 'required', 'cus_ref_no' => 'required', 'branch_id' => 'required', 'product_type' => 'required', 'product_id' => 'required', 'quantity' => 'required', 'return_amount' => 'required', 'consignment_name' => 'required');
     $validate = Validator::make(Input::all(), $ruless);
     if ($validate->fails()) {
         return Redirect::to('salesreturn/create')->withErrors($validate);
     } else {
         $salesreturn = new SalesReturn();
         $this->setSalesReturnData($salesreturn);
         //automatically reduce sales payment starts
         $return_amount = Input::get('return_amount');
         $remaining_amount = $return_amount;
         //var_dump($remaining_amount);
         $partyId = Input::get('party_id');
         if ($remaining_amount > 0) {
             $invoiceId = Sale::where('party_id', '=', $partyId)->get();
             foreach ($invoiceId as $invid) {
                 $price = SAleDetail::where('invoice_id', '=', $invid->invoice_id)->get();
                 $detailsPrice = 0;
                 foreach ($price as $prc) {
                     $detailsPrice = $detailsPrice + $prc->price * $prc->quantity;
                 }
                 var_dump($detailsPrice);
                 $amount = Transaction::where('invoice_id', '=', $invid->invoice_id)->where('type', '=', 'Receive')->get();
                 $paid = 0;
                 foreach ($amount as $amnt) {
                     $paid = $paid + $amnt->amount;
                 }
                 $difference = $detailsPrice - $paid;
                 if ($difference > 0) {
                     echo 'greater than 0 difference';
                     if ($remaining_amount <= $difference) {
                         $transaction = new Transaction();
                         $transaction->invoice_id = $invid->invoice_id;
                         $transaction->amount = $remaining_amount;
                         $transaction->type = 'Receive';
                         $transaction->payment_method = 'Sales Return';
                         $transaction->account_category_id = 7;
                         $transaction->remarks = 'Sales Return';
                         $transaction->account_name_id = 8;
                         $transaction->user_id = Session::get('user_id');
                         $transaction->cheque_no = '';
                         $branch = SAleDetail::where('invoice_id', '=', $invid->invoice_id)->first();
                         $transaction->branch_id = $branch->branch_id;
                         $transaction->save();
                         $remaining_amount = 0;
                     } elseif ($remaining_amount > $difference) {
                         $toBePaid = $remaining_amount - $difference;
                         $transaction = new Transaction();
                         $transaction->invoice_id = $invid->invoice_id;
                         $transaction->amount = $difference;
                         $transaction->type = 'Receive';
                         $transaction->payment_method = 'Sales Return';
                         $transaction->account_category_id = 7;
                         $transaction->remarks = 'Sales Return';
                         $transaction->account_name_id = 8;
                         $transaction->user_id = Session::get('user_id');
                         $transaction->cheque_no = '';
                         $branch = SAleDetail::where('invoice_id', '=', $invid->invoice_id)->first();
                         $transaction->branch_id = $branch->branch_id;
                         $transaction->save();
                         $remaining_amount = $toBePaid;
                     }
                 }
             }
         }
         /*if($remaining_amount>0)
           {
               echo "How come its possible! Consult with DEVELOPERS!!!";
           }*/
         //automatically reduce sales payment ends
         return Redirect::to('salesreturn/create');
     }
 }
Exemplo n.º 8
0
 public function postSaveReceiveAll()
 {
     $transactionId = 0;
     $ruless = array('party_id' => 'required', 'branch_id' => 'required', 'account_category_id' => 'required', 'account_name_id' => 'required', 'payment_method' => 'required', 'amount' => 'required');
     $validate = Validator::make(Input::all(), $ruless);
     if ($validate->fails()) {
         return Redirect::to('sales/index/')->withErrors($validate);
     } else {
         //$this->setReceiveSalePaymentAll();
         //return Redirect::to('sales/index');
         //$salesreturn = new SalesReturn();
         //$this->setSalesReturnData($salesreturn);
         //automatically reduce sales payment starts
         $return_amount = Input::get('amount');
         $remaining_amount = $return_amount;
         //var_dump($remaining_amount);
         $partyId = Input::get('party_id');
         if ($remaining_amount > 0) {
             $invoiceId = Sale::where('party_id', '=', $partyId)->where('is_sale', '=', 1)->get();
             foreach ($invoiceId as $invid) {
                 $detailsPrice = 0;
                 $paid = 0;
                 $saleDetails = SAleDetail::where('invoice_id', '=', $invid->invoice_id)->get();
                 $transactions = Transaction::where('invoice_id', '=', $invid->invoice_id)->where('payment_method', '=', 'Check')->where('type', '=', 'Receive')->where('cheque_status', '=', 1)->get();
                 $salef = Sale::find($invid->id);
                 foreach ($saleDetails as $saleDetail) {
                     $salePriceCalculated = $saleDetail->price * $saleDetail->quantity;
                     $detailsPrice = $detailsPrice + $salePriceCalculated;
                 }
                 $detailsPrice -= $invid->discount_percentage;
                 foreach ($transactions as $transaction) {
                     $paid = $paid + $transaction->amount;
                 }
                 $transactions2 = Transaction::where('invoice_id', '=', $invid->invoice_id)->where('type', '=', 'Receive')->where('payment_method', '!=', 'Check')->get();
                 foreach ($transactions2 as $transaction) {
                     $paid = $paid + $transaction->amount;
                 }
                 $difference = $detailsPrice - $paid;
                 //echo $difference; die();
                 if ($difference > 0) {
                     //echo 'greater than 0 difference';
                     if ($remaining_amount <= $difference) {
                         if ($remaining_amount > 0) {
                             $sale = Sale::find($invid->id);
                             if ($remaining_amount < $difference) {
                                 $sale->status = "Partial";
                             } elseif ($remaining_amount == $difference) {
                                 $sale->status = "Completed";
                             }
                             $transaction = new Transaction();
                             $transaction->invoice_id = $invid->invoice_id;
                             $transaction->amount = $remaining_amount;
                             $transaction->type = 'Receive';
                             $transaction->payment_method = Input::get('payment_method');
                             $transaction->account_category_id = Input::get('account_category_id');
                             $transaction->remarks = Input::get('remarks');
                             $transaction->account_name_id = Input::get('account_name_id');
                             $transaction->user_id = Session::get('user_id');
                             $transaction->cheque_no = Input::get('cheque_no');
                             $branch = SAleDetail::where('invoice_id', '=', $invid->invoice_id)->first();
                             $transaction->branch_id = $branch->branch_id;
                             $transaction->cheque_date = Input::get('cheque_date');
                             $transaction->cheque_bank = Input::get('cheque_bank');
                             if ($transaction->payment_method != "Check") {
                                 $accountPayment = NameOfAccount::find(Input::get('account_name_id'));
                                 $accountPayment->opening_balance = $accountPayment->opening_balance + $remaining_amount;
                                 $accountPayment->save();
                             }
                             $transaction->save();
                             $transactionId = $transaction->id;
                             $remaining_amount = 0;
                         }
                     } elseif ($remaining_amount > $difference) {
                         if ($remaining_amount > 0) {
                             $sale = Sale::find($invid->id);
                             $sale->status = "Completed";
                             $toBePaid = $remaining_amount - $difference;
                             $transaction = new Transaction();
                             $transaction->invoice_id = $invid->invoice_id;
                             $transaction->amount = $difference;
                             $transaction->type = 'Receive';
                             $transaction->payment_method = Input::get('payment_method');
                             $transaction->account_category_id = Input::get('account_category_id');
                             $transaction->remarks = Input::get('remarks');
                             $transaction->account_name_id = Input::get('account_name_id');
                             $transaction->user_id = Session::get('user_id');
                             $transaction->cheque_no = Input::get('cheque_no');
                             $branch = SAleDetail::where('invoice_id', '=', $invid->invoice_id)->first();
                             $transaction->branch_id = $branch->branch_id;
                             $transaction->cheque_date = Input::get('cheque_date');
                             $transaction->cheque_bank = Input::get('cheque_bank');
                             if ($transaction->payment_method != "Check") {
                                 $accountPayment = NameOfAccount::find(Input::get('account_name_id'));
                                 $accountPayment->opening_balance = $accountPayment->opening_balance + $difference;
                                 $accountPayment->save();
                             }
                             $transaction->save();
                             $transactionId = $transaction->id;
                             $remaining_amount = $toBePaid;
                         }
                     }
                     $sale->save();
                 }
             }
         }
         /*if($remaining_amount>0)
           {
               echo "How come its possible! Consult with DEVELOPERS!!!";
           }*/
         //automatically reduce sales payment ends
         return Redirect::to('sales/voucher/' . $transactionId);
     }
 }