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'); }
/** * 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 destroy($id) { House::find($id)->delete(); Invoice::find($id)->delete(); return Redirect::route('invoice'); }
/** * Remove the specified resource from storage. * DELETE /accountreceivables/{id} * * @param int $id * @return Response */ public function destroy($id) { $occupancy = Occupancy::find($id); $hrname = $occupancy->tenant; $hrid = $occupancy->houseID; $value = $hrname; $fname = strtok($value, " "); $tenant = Tenant::where('name', $fname)->first(); $tenant->occupancy = 'false'; $tenant->save(); $house = House::find($hrid); $house->tenant = ''; $house->status = ''; $house->save(); $occupancy->delete(); return Redirect::route('occupancy'); }