Exemplo n.º 1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $houses = House::where('status', '=', 'booked')->where('frequency', '=', 4)->get();
     foreach ($houses as $house) {
         $hid = $house->id;
         $rent = $house->rent;
         $water = $house->water;
         $garbage = $house->garbage;
         $frequency = $house->frequency;
         $tenant_id = $house->tenant;
         $tenant = Tenant::find($tenant_id);
         $t_name = $tenant->name;
         $t_agent = $tenant->agent_id;
         $balance = $rent + $water + $garbage;
         $invoice = new Invoice();
         $invoice->type = 'to tenant';
         $invoice->houseID = $hid;
         $invoice->recipient = $t_name;
         $invoice->agent_id = $t_agent;
         $invoice->balance = $balance;
         $invoice->duedate = '2015/03/21';
         $invoice->save();
         $invoicedetail = new Invoicedetail();
         $invoicedetail->rent = $rent;
         $invoicedetail->water = $water;
         $invoicedetail->garbage = $garbage;
         $invoice->invoicedetail()->save($invoicedetail);
     }
 }
Exemplo n.º 2
0
 public function refundStore()
 {
     $input = Input::all();
     $v = Validator::make(Input::All(), array('houseID' => 'required', 'tenant' => 'required', 'type' => 'required', 'rentD' => 'required', 'waterD' => 'required', 'electricityD' => 'required', 'grepairs' => 'required', 'Obills' => 'required', 'Tcost' => 'required', 'Sfees' => 'required', 'duedate' => 'required'));
     if ($v->passes()) {
         $balance = Input::get('rentD') + Input::get('waterD') + Input::get('grepairs') + Input::get('Obills') + Input::get('Tcost') + Input::get('Sfees') + Input::get('electricityD');
         $invoice = new Invoice();
         $invoice->type = Input::get('type');
         $invoice->houseID = Input::get('houseID');
         $invoice->recipient = Input::get('tenant');
         $invoice->balance = $balance;
         $invoice->duedate = Input::get('duedate');
         $invoice->save();
         $invoicedetail = new Invoicedetail();
         $invoicedetail->rentD = Input::get('rentD');
         $invoicedetail->waterD = Input::get('waterD');
         $invoicedetail->g_repairs = Input::get('grepairs');
         $invoicedetail->o_bills = Input::get('Obills');
         $invoicedetail->transport_cost = Input::get('Tcost');
         $invoicedetail->storage_fees = Input::get('Sfees');
         $invoicedetail->electricityD = Input::get('electricityD');
         $invoice->invoicedetail()->save($invoicedetail);
         return Redirect::intended('admin/invoice');
     }
     return Redirect::back()->withInput()->withErrors($v)->with('message', 'There were validation errors');
 }
Exemplo n.º 3
0
 public function refundStore()
 {
     $input = Input::all();
     $ed = Input::get('electricityD');
     $rd = Input::get('rentD');
     $wd = Input::get('waterD');
     $v = Validator::make(Input::All(), array('houseID' => 'required', 'tenant' => 'required', 'type' => 'required', 'rentD' => 'required|numeric|max:' . $rd, 'waterD' => 'required|numeric|max:' . $wd, 'electricityD' => 'required|numeric|max:' . $ed, 'grepairs' => 'required|numeric', 'Obills' => 'required|numeric', 'Tcost' => 'required|numeric', 'Sfees' => 'required|numeric'));
     if ($v->passes()) {
         $agent_id = Sentry::getUser()->id;
         $deposits = Input::get('rentD') + Input::get('waterD') + Input::get('electricityD');
         $others = Input::get('grepairs') + Input::get('Obills') + Input::get('Tcost') + Input::get('Sfees');
         $amountpaid = $deposits - $others;
         $Idate = date('Y-m-d H:i:s');
         $balance = 0;
         $hid = Input::get('houseID');
         $house = House::find($hid);
         $houseOccupaied = $house->name;
         $totalTo = $house->rentd + $house->waterd + $house->electricityd;
         if ($amountpaid > $totalTo) {
             return Redirect::back()->withFlashMessage('Sorry the Total Refund has exceeded the deposits, Please try again');
         } elseif ($amountpaid < 0) {
             return Redirect::back()->withFlashMessage('Sorry check on the  Total Deductions not to exceed the deposits');
         } else {
             $invoice = new Invoice();
             $invoice->type = Input::get('type');
             $invoice->houseID = $houseOccupaied;
             $invoice->recipient = Input::get('tenant');
             $invoice->agent_id = $agent_id;
             $invoice->amountpaid = 0;
             $invoice->balance = $amountpaid;
             $invoice->duedate = $Idate;
             $invoice->save();
             $invoicedetail = new Invoicedetail();
             $invoicedetail->rentD = Input::get('rentD');
             $invoicedetail->waterD = Input::get('waterD');
             $invoicedetail->g_repairs = Input::get('grepairs');
             $invoicedetail->o_bills = Input::get('Obills');
             $invoicedetail->transport_cost = Input::get('Tcost');
             $invoicedetail->storage_fees = Input::get('Sfees');
             $invoicedetail->electricityD = Input::get('electricityD');
             $invoice->invoicedetail()->save($invoicedetail);
             $properties = Property::where('agent_id', '=', Sentry::getUser()->id)->get();
             return Redirect::route('refunds', compact('amountpaid', 'properties'))->withFlashMessage('Refund processed successfully');
         }
     }
     return Redirect::back()->withInput()->withErrors($v)->with('message', 'There were validation errors');
 }
 /**
  * Store a newly created resource in storage.
  * POST /invoices
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::all();
     $v = Validator::make(Input::All(), array('houseID' => 'required', 'tenant' => 'required', 'type' => 'required', 'rent' => 'required', 'service' => 'required', 'garbage' => 'required', 'water' => 'required', 'security' => 'required', 'electricity' => 'required', 'duedate' => 'required'));
     //if validation passes create an invoice
     if ($v->passes()) {
         $balance = Input::get('rent') + Input::get('water') + Input::get('service') + Input::get('garbage') + Input::get('electricity') + Input::get('security');
         $agent_id = Sentry::getUser()->id;
         $hid = Input::get('houseID');
         $house = House::find($hid);
         $houseOccupaied = $house->name;
         $htenant = Input::get('tenant');
         $tenant_details = Tenant::where('name', $htenant)->get();
         foreach ($tenant_details as $tenant_detail) {
             $number = $tenant_detail->phone;
             $lname = $tenant_detail->lname;
         }
         $nams = $htenant . ' ' . $lname;
         $invoice = new Invoice();
         $invoice->type = Input::get('type');
         $invoice->houseID = $houseOccupaied;
         $invoice->recipient = $nams;
         $invoice->agent_id = $agent_id;
         $invoice->balance = $balance;
         $invoice->duedate = Input::get('duedate');
         $invoice->save();
         $invoicedetail = new Invoicedetail();
         $invoicedetail->rent = Input::get('rent');
         $invoicedetail->water = Input::get('water');
         $invoicedetail->service = Input::get('service');
         $invoicedetail->garbage = Input::get('garbage');
         $invoicedetail->electricity = Input::get('electricity');
         $invoicedetail->security = Input::get('security');
         $invoice->invoicedetail()->save($invoicedetail);
         #send an sms to the tenant
         $to = $number;
         $message = ' Hi ' . $htenant . 'Your invoivce for this month of amount: Ksh. ' . number_format($balance, 2) . ' is due, Please for detailed information login at real-estate.kenya.com';
         Queue::push('SendSMS', array('message' => $message, 'number' => $to));
         return Redirect::intended('admin/invoice');
     }
     return Redirect::back()->withInput()->withErrors($v)->with('message', 'There were validation errors');
 }
Exemplo n.º 5
0
 /**
  * Store a newly created resource in storage.
  * POST /invoices
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::all();
     $hinput = Input::only('status', 'tenant');
     $v = Validator::make(Input::All(), array('houseID' => 'required|max:50|unique:occupancies', 'tenant' => 'required', 'startdate' => 'required', 'enddate' => 'required', 'status' => 'required'));
     if ($v->passes()) {
         //get the id of the agent
         $agent_id = Sentry::getUser()->id;
         //update the occupancy status for the tenant
         $tname = Input::get('tenant');
         $tenant = Tenant::where('id', $tname)->first();
         $tenant->occupancy = 'true';
         $tenant->save();
         $tnames = Tenant::where('id', $tname)->get(array('name', 'lname', 'phone'));
         foreach ($tnames as $tname) {
             $names = $tname->name . ' ' . $tname->lname;
             $fname = $tname->name;
             $number = $tname->phone;
         }
         //update the occupancy status in the unit
         $hid = Input::get('houseID');
         $house = House::find($hid);
         $house->tenant = $names;
         $house->status = Input::get('status');
         $house->save();
         //Add a new occupancy
         $occupancy = new Occupancy();
         $occupancy->tenant = $names;
         $occupancy->startdate = Input::get('startdate');
         $occupancy->enddate = Input::get('enddate');
         $house->occupancy()->save($occupancy);
         //create an invoice for the new house
         $rent = $house->rent;
         $rentd = $house->rentd;
         $waterd = $house->waterd;
         $electricityd = $house->electricityd;
         $transportD = $house->transportD;
         $garbageD = $house->garbageD;
         $balance = $rent + $rentd + $waterd + $electricityd + $transportD + $garbageD;
         $invoice = new Invoice();
         $invoice->type = 'deposits';
         $invoice->houseID = $hid;
         $invoice->recipient = $fname;
         $invoice->agent_id = $agent_id;
         $invoice->balance = $balance;
         $invoice->duedate = '2015/03/21';
         $invoice->save();
         $invoicedetail = new Invoicedetail();
         $invoicedetail->rent = $rent;
         $invoicedetail->rentD = $rentd;
         $invoicedetail->waterD = $waterd;
         $invoicedetail->electricityD = $electricityd;
         $invoicedetail->transport_cost = $transportD;
         $invoicedetail->garbage = $garbageD;
         $invoice->invoicedetail()->save($invoicedetail);
         //send an sms to tenant of his occupancy status
         $houseName = $house->name;
         $to = $number;
         $message = ' Hi ' . $names . ', Your deposits of Ksh ' . number_format($balance, 2) . ' for ' . $houseName . ' has been received successfully. Welcome and Thank you for choosing us. ENJOY YOUR STAY';
         LaravelAtApi::sendMessage($to, $message);
         return Redirect::intended('admin/occupancy');
     }
     return Redirect::back()->withInput()->withErrors($v)->with('message', 'There were validation errors');
 }
 public function gerenateMonthly()
 {
     $input = Input::all();
     $v = Validator::make(Input::All(), array('houseID' => 'required', 'propertyid' => 'required', 'agent_id' => 'required'));
     if ($v->passes()) {
         $propertyidan = Input::get('propertyid');
         $houseID = Input::get('houseID');
         $startDate = time();
         $lastmonth = date('Y-m-d', strtotime('+5 day', $startDate));
         $ddate = date('d');
         $agent_id = Input::get('agent_id');
         $billedusr = User::find($agent_id);
         $hisBalance = $billedusr->credit_balance;
         $newBalance = $hisBalance - 3;
         $billedusr->credit_balance = $newBalance;
         $billedusr->save();
         $billstatement = new Statement();
         $billstatement->type = "Generating Invoice";
         $billstatement->amount = 3;
         $billstatement->save();
         if ($houseID === "All") {
             $houses = House::where('status', '=', 'booked')->where('frequency', '=', 1)->where('propertyID', $propertyidan)->get();
             foreach ($houses as $house) {
                 $hid = $house->id;
                 $houseName = $house->name;
                 $propid = $house->propertyID;
                 $propname = Property::where('id', $propid)->pluck('name');
                 $rent = $house->rent;
                 $water = $house->water;
                 $garbage = $house->garbage;
                 $electricity = $house->electricity;
                 $security = $house->security;
                 $frequency = $house->frequency;
                 $tenant_id = $house->tenant;
                 $tenantnames = strtok($tenant_id, " ");
                 $tenant = Tenant::where('name', $tenantnames)->first();
                 $t_name = $tenant->name;
                 $to = $tenant->phone;
                 $t_agent = $tenant->agent_id;
                 $balance = $rent + $water + $garbage + $electricity + $security;
                 $invoice = new Invoice();
                 $invoice->type = 'to tenant';
                 $invoice->houseID = $houseName;
                 $invoice->recipient = $t_name;
                 $invoice->agent_id = $t_agent;
                 $invoice->balance = $balance;
                 $invoice->propertyid = $propid;
                 $invoice->duedate = $lastmonth;
                 $invoice->save();
                 $invoicedetail = new Invoicedetail();
                 $invoicedetail->rent = $rent;
                 $invoicedetail->water = $water;
                 $invoicedetail->garbage = $garbage;
                 $invoicedetail->electricity = $electricity;
                 $invoicedetail->security = $security;
                 $invoice->invoicedetail()->save($invoicedetail);
                 $message = 'Dear ' . $t_name . ', your rent for this month of Ksh ' . number_format($balance, 2) . '  is due for payment. For inquiries contact 0700548168 Rehema House Ngong';
                 Queue::push('SendSMS', array('message' => $message, 'number' => $to));
             }
             $noteSuccesGen = array('error' => false, 'message' => "Monthly invoice(s) generated successfully");
             return $noteSuccesGen;
         } else {
             $house = House::where('name', '=', $houseID)->where('frequency', '=', 1)->first();
             $hid = $house->id;
             $houseName = $house->name;
             $propid = $house->propertyID;
             $propname = Property::where('id', $propid)->pluck('name');
             $rent = $house->rent;
             $water = $house->water;
             $garbage = $house->garbage;
             $electricity = $house->electricity;
             $security = $house->security;
             $frequency = $house->frequency;
             $tenant_id = $house->tenant;
             $tenantnames = strtok($tenant_id, " ");
             $tenant = Tenant::where('name', $tenantnames)->first();
             $t_name = $tenant->name;
             $to = $tenant->phone;
             $t_agent = $tenant->agent_id;
             $balance = $rent + $water + $garbage + $electricity + $security;
             $invoice = new Invoice();
             $invoice->type = 'to tenant';
             $invoice->houseID = $houseName;
             $invoice->recipient = $t_name;
             $invoice->agent_id = $t_agent;
             $invoice->balance = $balance;
             $invoice->propertyid = $propid;
             $invoice->duedate = $lastmonth;
             $invoice->save();
             $invoicedetail = new Invoicedetail();
             $invoicedetail->rent = $rent;
             $invoicedetail->water = $water;
             $invoicedetail->garbage = $garbage;
             $invoicedetail->electricity = $electricity;
             $invoicedetail->security = $security;
             $invoice->invoicedetail()->save($invoicedetail);
             $message = 'Dear ' . $t_name . ', your rent for this month of Ksh ' . number_format($balance, 2) . '  is due for payment.For inquiries contact 0700548168 Rehema House Ngong';
             Queue::push('SendSMS', array('message' => $message, 'number' => $to));
             $noteSuccesGen = array('error' => false, 'message' => "Monthly invoice(s) generated successfully");
             return $noteSuccesGen;
         }
     }
     $noteGenerate4 = array('error' => true, 'message' => $v->messages());
     return $noteGenerate4;
 }
Exemplo n.º 7
0
        $garbage = $house->garbage;
        $electricity = $house->electricity;
        $security = $house->security;
        $frequency = $house->frequency;
        $tenant_id = $house->tenant;
        $tenantnames = strtok($tenant_id, " ");
        $tenant = Tenant::where('name', $tenantnames)->first();
        $t_name = $tenant->name;
        $to = $tenant->phone;
        $t_agent = $tenant->agent_id;
        $balance = $rent + $water + $garbage + $electricity + $security;
        $invoice = new Invoice();
        $invoice->type = 'to tenant';
        $invoice->houseID = $hid;
        $invoice->recipient = $t_name;
        $invoice->agent_id = $t_agent;
        $invoice->balance = $balance;
        $invoice->duedate = $lastmonth;
        $invoice->save();
        $invoicedetail = new Invoicedetail();
        $invoicedetail->rent = $rent;
        $invoicedetail->water = $water;
        $invoicedetail->garbage = $garbage;
        $invoicedetail->electricity = $electricity;
        $invoicedetail->security = $security;
        $invoice->invoicedetail()->save($invoicedetail);
        $message = ' Hi ' . $t_name . ', this is to notify you that your invoice of Ksh ' . number_format($balance, 2) . ' for ' . $propname . ' unit ' . $houseName . '  is due on ' . $lastmonth . '.Thanks';
        Queue::push('SendSMS', array('message' => $message, 'number' => $to));
    }
    return 'Annual invoice(s) generated successfully';
});
 /**
  * Store a newly created resource in storage.
  * POST /invoices
  *
  * @return Response
  */
 public function store()
 {
     $input = Input::all();
     $hinput = Input::only('status', 'tenant');
     $v = Validator::make(Input::All(), array('houseID' => 'required|max:50|unique:occupancies', 'tenant' => 'required', 'startdate' => 'required', 'enddate' => 'required', 'status' => 'required'));
     if ($v->passes()) {
         //get current date
         $now = new DateTime();
         $todaysDate = $now->format('Y-m-d');
         //get the id of the agent
         $agent_id = Sentry::getUser()->id;
         //get the tenant type
         //update the occupancy status for the tenant
         $tname = Input::get('tenant');
         $tenant = Tenant::where('id', $tname)->first();
         $tenant->occupancy = 'true';
         $tenant->save();
         $tnames = Tenant::where('id', $tname)->get(array('name', 'lname', 'phone'));
         foreach ($tnames as $tname) {
             $names = $tname->name . ' ' . $tname->lname;
             $fname = $tname->name;
             $number = $tname->phone;
         }
         //update the occupancy status in the unit
         $hid = Input::get('houseID');
         $house = House::find($hid);
         $houseOccupaied = $house->name;
         $house->tenant = $names;
         $house->status = Input::get('status');
         $house->save();
         //Add a new occupancy
         $occupancy = new Occupancy();
         $occupancy->houseName = $houseOccupaied;
         $occupancy->tenant = $names;
         $occupancy->startdate = Input::get('startdate');
         $occupancy->enddate = Input::get('enddate');
         $house->occupancy()->save($occupancy);
         //create an invoice for the new house
         $rent = $house->rent;
         $rentd = $house->rent_deposit;
         $waterd = $house->water_deposit;
         $electricityd = $house->electricity_deposit;
         $transportD = $house->transport_deposit;
         $garbageD = $house->garbage_deposit;
         $balance = $rent + $rentd + $waterd + $electricityd + $transportD + $garbageD;
         $invoice = new Invoice();
         $invoice->type = 'deposits';
         $invoice->houseID = $houseOccupaied;
         $invoice->recipient = $names;
         $invoice->agent_id = $agent_id;
         $invoice->balance = $balance;
         $invoice->duedate = '2015/03/21';
         $invoice->save();
         $invoicedetail = new Invoicedetail();
         $invoicedetail->rent = $rent;
         $invoicedetail->rentD = $rentd;
         $invoicedetail->waterD = $waterd;
         $invoicedetail->electricityD = $electricityd;
         $invoicedetail->transport_cost = $transportD;
         $invoicedetail->garbage_deposit = $garbageD;
         $invoice->invoicedetail()->save($invoicedetail);
         //send an sms to tenant of his occupancy status
         $houseName = $house->name;
         $to = $number;
         $m2 = 'Dear ' . $fname . ',from November 1st we will be using Mteja to notify you on rent due and record payment.0700548168';
         $message = ' Dear ' . $fname . ', Your new occupancy for ' . $houseOccupaied . ' has been created successfuly, your Invoice deposits amounting to  ' . number_format($balance, 2) . ' is due on ' . $todaysDate . ' Thank you.';
         Queue::push('SendSMS', array('message' => $message, 'number' => $to));
         return Redirect::intended('admin/occupancy')->withFlashMessage(' Occupancy  has been created successfully ');
     }
     return Redirect::back()->withInput()->withErrors($v)->with('message', 'There were validation errors');
 }