<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use DB;
class DepositModel extends Model
{
    protected $table = "nso007_deposit";
    public function remainbalance(){
        $salestock = SaleStockModel::find($this->deposit_saleid);
        $previousdeposit = DepositModel::select(DB::raw('SUM(deposit_amount) As deposit_amount'))->where([['id','<',$this->id],['deposit_saleid',$this->deposit_saleid]])->first();
        return $salestock->sale_amount-$previousdeposit->deposit_amount-$this->deposit_amount;
    }
}