/**
  * This function is likely never returns
  * but anyway handle result and exceptions
  * @return Am_Paysystem_Result
  */
 function process()
 {
     $err = $this->invoice->validate();
     if ($err) {
         throw new Am_Exception_InputError($err[0]);
     }
     $this->invoice->save();
     $plugin = Am_Di::getInstance()->plugins_payment->loadGet($this->invoice->paysys_id);
     $this->result = new Am_Paysystem_Result();
     $plugin->processInvoice($this->invoice, $this->controller->getRequest(), $this->result);
     if ($this->result->isSuccess() || $this->result->isFailure()) {
         if ($transaction = $this->result->getTransaction()) {
             $transaction->setInvoice($this->invoice);
             $transaction->process();
         }
     }
     if ($this->result->isSuccess()) {
         $url = REL_ROOT_URL . "/thanks?id=" . $this->invoice->getSecureId('THANKS');
         $this->callback($this->onSuccess);
         $this->controller->redirectLocation($url, ___("Invoice processed"), ___("Invoice processed successfully"));
         // no return Am_Exception_Redirect
     } elseif ($this->result->isAction()) {
         $this->callback($this->onAction);
         $this->result->getAction()->process($this->controller);
         // no return Am_Exception_Redirect
     } else {
         //  ($result->isFailure()) {
         $this->callback($this->onFailure);
     }
     return $this->result;
 }
예제 #2
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);
     }
 }
예제 #3
0
 /**
  * Store a newly created resource in storage.
  * POST /invoice
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make(Input::all(), Invoice::$rules);
     if ($validator->fails()) {
         return Redirect::to('invoice')->withErrors($validator)->withInput(Input::all());
     } else {
         $invoice = new Invoice();
         $invoice->no_inv = Input::get('no_inv');
         $invoice->tgl_inv = Input::get('tgl_inv');
         $invoice->no_PO = Input::get('no_PO');
         $invoice->ship_by = Input::get('ship_by');
         $invoice->pay_method = Input::get('pay_method');
         $invoice->no_rek = Input::get('no_rek');
         $invoice->pelabuhan = Input::get('pelabuhan');
         $invoice->carrier = Input::get('carrier');
         $invoice->save();
         $SPPB = Barang::join('detil_SPPB', 'barang.kode_barang', '=', 'detil_SPPB.kode_barang')->join('SPPB', 'detil_SPPB.no_SPPB', '=', 'SPPB.no_SPPB')->join('PO', 'SPPB.no_SPPB', '=', 'PO.no_SPPB')->where('no_PO', Input::get('no_PO'))->selectRaw('barang.kode_barang as barang, jml_pesan as pesan')->get();
         foreach ($SPPB as $key => $value) {
             $barang = Barang::find($value->barang);
             $barang->jml_barang = $barang->jml_barang - $value->pesan;
             $barang->save();
         }
         Session::flash('message', 'Successfully created invoice!');
         return Redirect::to('invoice');
     }
 }
예제 #4
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Invoice();
     $modelCustomer = new Customer();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Invoice'])) {
         $model->attributes = $_POST['Invoice'];
         // Si creamos un nuevo Customer hay que guardarlo
         if (strlen($model->CustomerID) == 0) {
             $modelCustomer->attributes = $_POST['Customer'];
             if ($modelCustomer->save()) {
                 $model->CustomerID = $modelCustomer->ID;
             }
         } else {
             $modelCustomer = Customer::model()->findByPK($model->CustomerID);
             $modelCustomer->attributes = $_POST['Customer'];
             $modelCustomer->save();
         }
         if ($model->save()) {
             $this->redirect(array('admin'));
         }
     }
     $this->render('create', array('model' => $model, 'modelCustomer' => $modelCustomer));
 }
 /**
  * Update existing payment
  *
  * @param void
  * @return null
  */
 function edit()
 {
     if ($this->active_payment->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     $payment_data = $this->request->post('payment');
     if (!is_array($payment_data)) {
         $payment_data = array('invoice_id' => $this->active_payment->getInvoiceId(), 'amount' => $this->active_payment->getAmount(), 'comment' => $this->active_payment->getComment());
     }
     // if
     $this->smarty->assign('payment_data', $payment_data);
     if ($this->request->isSubmitted()) {
         $this->active_invoice->setAttributes($payment_data);
         $save = $this->active_payment->save();
         if ($save && !is_error($save)) {
             flash_success('Payment has been updated');
             $this->redirectTo('invoices');
         } else {
             $this->smarty->assign('errors', $save);
         }
         // if
     }
     // if
 }
예제 #6
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');
 }
 /**
  *
  * @param type $data
  *
  * $data = array(
  *                'header' => 'Header Text',
  *                'invoice_no' => 'Invoice number auto generate',
  *                'invoice_of' => 'Invoice type. e.g. quote, po',
  *                'ref_id' => 'id of the invoice_of',
  *                'ref_number' => 'number the invoice_of',
  *                'gst' => 'GST',
  *                'items' => array(
  *                                  [] => array(
  *                                               'id' => 'db row id of the item',
  *                                               'number' => 'Unique Number of the item',
  *                                               'desc' => 'Description',
  *                                               'qty' => 'Quantity',
  *                                               'price' => 'Each Price',
  *                                               'total' => 'Total',  // NULL in case of autocalculate
  *                                             ),
  *                                ),
  *                'customer' => array(  // null to empty
  *                                     'id' => 'Customer ID',
  *                                     'name' => 'Name',
  *                                     'address' => 'Address',
  *                                     'city' => 'City',
  *                                     'postal-code' => 'Postal Code',
  *                                     'province' => 'Province',
  *                                     'country' => 'Country',
  *                                     'email' => 'Email',
  *                                     'phone' => 'Phone',
  *                                   ),
  *                'supplier' => array(  // null to empty
  *                                     'id' => 'Customer ID',
  *                                     'name' => 'Name',
  *                                     'address' => 'Address',
  *                                     'city' => 'City',
  *                                     'postal-code' => 'Postal Code',
  *                                     'province' => 'Province',
  *                                     'country' => 'Country',
  *                                     'email' => 'Email',
  *                                     'phone' => 'Phone',
  *                                   ),
  *                'total' => 'GST',
  *                'sales-person' => 'Sales Person',
  *                'ship-date' => 'Ship Date',
  *              );
  */
 function createInvoice($data)
 {
     App::import('Model', 'InvoiceManager.Invoice');
     $invoice = new Invoice();
     $data_json = json_encode($data);
     $invoice_data['Invoice'] = array('invoice_no' => $data['invoice_no'], 'invoice_of' => $data['invoice_of'], 'ref_id' => $data['ref_id'], 'data_set' => $data_json, 'total' => $data['total'], 'invoice_status_id' => $data['invoice_status_id']);
     $invoice_data['InvoiceLog'] = array('invoice_status_id' => $data['invoice_status_id']);
     $invoice->create();
     $flag = $invoice->save($invoice_data);
     return $flag;
 }
예제 #8
0
 public function actionInvoice()
 {
     $model = new Invoice();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         /** @var \robokassa\Merchant $merchant */
         $merchant = Yii::$app->get('robokassa');
         return $merchant->payment($model->sum, $model->id, \skeeks\cms\shop\Module::t('app', 'Refill'), null, Yii::$app->user->identity->email);
     } else {
         return $this->render('invoice', ['model' => $model]);
     }
 }
예제 #9
0
 public function _process(Invoice $invoice, Am_Request $request, Am_Paysystem_Result $result)
 {
     $a = new Am_Paysystem_Action_Form(self::URL);
     $params = array('jp_item_type' => 'cart', 'jp_item_name' => $invoice->getLineDescription(), 'order_id' => $invoice->public_id, 'jp_business' => $this->getConfig('business'), 'jp_payee' => $invoice->getEmail(), 'jp_shipping' => '', 'jp_amount_1' => $invoice->currency == 'KES' ? $invoice->first_total : $this->exchange($invoice->first_total), 'jp_amount_2' => 0, 'jp_amount_5' => $invoice->currency == 'USD' ? $invoice->first_total : 0, 'jp_rurl' => $this->getPluginUrl('thanks'), 'jp_furl' => $this->getCancelUrl(), 'jp_curl' => $this->getCancelUrl());
     $invoice->data()->set('jambopay-terms-KES', $params['jp_amount_1']);
     $invoice->data()->set('jambopay-terms-USD', $params['jp_amount_5']);
     $invoice->save();
     foreach ($params as $k => $v) {
         $a->addParam($k, $v);
     }
     $result->setAction($a);
 }
예제 #10
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');
 }
예제 #11
0
 /**
  * Store a newly created resource in storage.
  * POST /invoices
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Invoice::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $user = Auth::user();
     $this->invoice->biller_id = Input::get('biller_id');
     $this->invoice->client_id = Input::get('client_id');
     $this->invoice->currency_id = Input::get('currency_id');
     $this->invoice->number = Input::get('number');
     $this->invoice->subtotal = floatval(Input::get('subtotal'));
     $this->invoice->tax_rate_id = Input::get('tax_rate');
     $this->invoice->tax_total = floatval(Input::get('invoice_total_tax'));
     $this->invoice->total = floatval(Input::get('total'));
     $this->invoice->paid = floatval(Input::get('invoice_total_paid'));
     $total = floatval(Input::get('total'));
     $paid = floatval(Input::get('invoice_total_paid'));
     $this->invoice->balance = $total - $paid;
     $this->invoice->user_id = $user->id;
     $this->note = Input::get('note');
     if (Input::has('date')) {
         $this->invoice->date = Input::get('date');
     }
     if (Input::has('due_date')) {
         $this->invoice->due_date = Input::get('due_date');
     }
     if ($this->invoice->save()) {
         $item_id = Input::get('item_id');
         $name = Input::get('item_name');
         $description = Input::get('item_description');
         $price = Input::get('item_price');
         $quantity = Input::get('item_qty');
         $keys = array('item_id', 'name', 'description', 'price', 'quantity');
         $items = array();
         foreach (array_map(null, $item_id, $name, $description, $price, $quantity) as $key => $value) {
             $items[] = array_combine($keys, $value);
         }
         foreach ($items as $item) {
             $itemRecord = array('invoice_id' => $this->invoice->id, 'name' => $item['name'], 'description' => $item['description'], 'price' => floatval($item['price']), 'quantity' => floatval($item['quantity']), 'total' => floatval($item['price']) * floatval($item['quantity']));
             Item::create($itemRecord);
         }
         return Redirect::to('invoices/' . $this->invoice->id . '/edit')->with('success', Lang::get('invoices.message.success.create'));
     }
 }
예제 #12
0
 /**
  * @covers Moneybird\Invoice_Service::getSyncList
  */
 public function testGetSyncList()
 {
     $revision = $this->object->revision;
     $this->assertNotNull($revision, 'Invoice ' . self::$invoiceId . ' not in synclist');
     $this->object->setData(array('firstname' => 'Test' . time()));
     $this->object->save($this->service);
     sleep(1);
     $newRevision = null;
     $syncList = $this->service->getSyncList();
     $this->assertInstanceOf('Moneybird\\Invoice_Array', $syncList);
     foreach ($syncList as $sync) {
         if ($sync->id == self::$invoiceId) {
             $newRevision = $sync->revision;
         }
     }
     $this->assertNotNull($newRevision, 'Invoice ' . self::$invoiceId . ' not in synclist');
     $this->assertGreaterThan($revision, $newRevision);
 }
 /**
  * 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');
 }
예제 #14
0
 function testSendEmail()
 {
     $company = new Company();
     $company->set(array('name' => 'Test Company'));
     $company->save();
     $contact = new Contact();
     $contact->set(array('first_name' => 'Testy', 'last_name' => 'test', 'email' => '*****@*****.**', 'is_billing_contact' => true, 'company_id' => $company->id));
     $contact->save();
     $i = new Invoice();
     $i->set(array('company_id' => $company->id, 'start_date' => '2010-01-01', 'end_date' => '2010-03-31'));
     $i->execute();
     $i->save();
     # here i test sending my invoice
     require_once 'controller/InvoiceController.php';
     $invoice_controller = new InvoiceController();
     $invoice_controller->disableRedirect();
     $invoice_controller->execute('email', array('id' => $i->id));
     $msg = Render::_dumpMessages();
     $this->assertPattern('/Email Sent/', $msg);
 }
예제 #15
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'show' page.
  */
 public function actionCreate()
 {
     $model = new Invoice($this->action->id);
     if (isset($_POST['Invoice'])) {
         // collect user input data
         $model->attributes = $_POST['Invoice'];
         // validate with the current action as scenario and save without validation
         if (($validated = $model->validate()) !== false && ($saved = $model->save(false)) !== false) {
             // set success message
             MUserFlash::setTopSuccess(Yii::t('hint', 'The new invoice record number "{invoiceNumber}" has been successfully created.', array('{invoiceNumber}' => MHtml::wrapInTag($model->id, 'strong'))));
             // go to the 'show' page
             $this->redirect(array('show', 'id' => $model->id));
         }
     } else {
         // pre-assigned attributes (default values for a new record)
         if (isset($_GET['companyId'])) {
             // company is known
             $model->companyId = $_GET['companyId'];
         }
     }
     $this->render($this->action->id, array('model' => $model));
 }
 /**
  * Change invoice status to CANCELED
  *
  * @param void
  * @return null
  */
 function cancel()
 {
     if ($this->active_invoice->isNew()) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     if (!$this->active_invoice->canCancel($this->logged_user)) {
         $this->httpError(HTTP_ERR_FORBIDDEN);
     }
     // if
     if ($this->request->isSubmitted()) {
         db_begin_work();
         $this->active_invoice->setStatus(INVOICE_STATUS_CANCELED, $this->logged_user, new DateTimeValue());
         $save = $this->active_invoice->save();
         if ($save && !is_error($save)) {
             db_commit();
             $issued_to_user = $this->active_invoice->getIssuedTo();
             if (instance_of($issued_to_user, 'User')) {
                 $notify_users = array($issued_to_user);
                 if ($issued_to_user->getId() != $this->logged_user->getId()) {
                     $notify_users[] = $this->logged_user;
                 }
                 // if
                 ApplicationMailer::send($notify_users, 'invoicing/cancel', array('closed_by_name' => $this->logged_user->getDisplayName(), 'closed_by_url' => $this->logged_user->getViewUrl(), 'invoice_number' => $this->active_invoice->getNumber(), 'invoice_url' => $this->active_invoice->getCompanyViewUrl()));
             }
             // if
             flash_success('Invoice #:number has been canceled', array('number' => $this->active_invoice->getName($short)));
         } else {
             db_rollback();
             flash_error('Failed to cancel invoice #:number', array('number' => $this->active_invoice->getName($short)));
         }
         // if
         $this->redirectToUrl($this->active_invoice->getViewUrl());
     } else {
         $this->httpError(HTTP_ERR_BAD_REQUEST);
     }
     // if
 }
예제 #17
0
 /**
  * @covers Moneybird\Invoice::settle
  */
 public function testSettle()
 {
     $this->assertEquals(4.16, $this->object->totalUnpaid);
     $details = new Invoice\Detail\ArrayObject();
     $details->append(new Invoice\Detail(array('amount' => -1, 'description' => 'My credit line', 'price' => 2.5, 'taxRateId' => self::$taxRateId)));
     $invoice = new Invoice(array('poNumber' => 'PO Number', 'details' => $details, 'pricesAreInclTax' => true), self::$contact);
     $invoice->save($this->service);
     $invoice->markAsSent($this->service);
     $this->object->settle($this->service, $invoice);
     $this->assertEquals(1.66, $this->object->totalUnpaid);
     $this->assertEquals(0, $invoice->totalUnpaid);
     $invoice->delete($this->service);
 }
 public function executeGenerateInvoice(sfWebRequest $request)
 {
     $purchase = Doctrine_Query::create()->from('Purchase p')->where('p.id = ' . $request->getParameter('id'))->fetchOne();
     //create purchase
     $invoice = new Invoice();
     $invoice->setInvno(date('h:i:s a'));
     $invoice->setCustomerId(2);
     //cash
     $invoice->setIsTemporary(2);
     //new
     $invoice->setDate(date("Y-m-d"));
     $invoice->save();
     //create purchase details
     foreach ($purchase->getPurchasedetail() as $purchdetail) {
         $invdetail = new InvoiceDetail();
         $invdetail->setInvoiceId($invoice->getId());
         $invdetail->setProductId($purchdetail->getProductId());
         $invdetail->setDescription($purchdetail->getProduct()->getName());
         $invdetail->setQty($purchdetail->getQty());
         $invdetail->setPrice(0);
         $invdetail->setTotal(0);
         $invdetail->setUnittotal(0);
         $invdetail->save();
         $invdetail->updateStockentry();
     }
     $this->redirect("invoice/view?id=" . $invoice->getId());
 }
예제 #19
0
function process_payment($invoice_id = null, $params)
{
    $success = false;
    $invoice = PackageInvoice::find_by_id($invoice_id);
    // process payment
    $clint = Employer::find_by_id($invoice->fk_employer_id);
    if ($invoice->cv_views == "Y") {
        $clint->cv_qty = $invoice->posts_quantity;
        $clint->add_cvs();
        $success = true;
    }
    if ($invoice->spotlight == "Y") {
        $clint->spotlight_qty = $invoice->posts_quantity;
        $clint->add_more_spotlight_job_post();
        $success = true;
    }
    if ($invoice->standard == "Y") {
        $clint->job_qty = $invoice->posts_quantity;
        $clint->add_more_job_post();
        $success = true;
    } else {
    }
    if ($success) {
        $invoice->package_status = 'Completed';
        $invoice->processed_date = date("Y-m-d H:i:s", time());
        $invoice->update_package_status();
        $invoice_item = new Invoice();
        /* start **/
        /**		
        		$param['payment_status'] = ""; //what is the status of the payment
        		$param['amount'] = ""; // how much was paid for this total amount for each item
        		$param['currency'] = ""; //what currecy they used to pay for this
        		$param['receiver_id'] = ""; // what is the id of person who is paying
        		$param['payment_email']; // what email have they used to pay
        		$param['txn_id'] = ""; // txt id
        		$param['txn_type'] = ""; // how are they pay for this web or ext.
        		$param['payer_status'] = ""; //is user verfied by the method they pay from
        		$param['residence_country'] = ""; //which country does user belogn to
        		//$param['origin'] = ""; //where is the payment come from
        		$param['payment_method'] = ""; // what methoid of payment they used e.g. paypal, ccbill
        		$param['payment_vars'] = ""; //get all var which are return from online site.
        		$param['payment_type'] = ""; //how they pay for this
        		$param['reason'] = ""; // if they cancel then tell user why
        **/
        $invoice_item->fk_invoice_id = $invoice_id;
        $invoice_item->payment_status = $params['payment_status'];
        $invoice_item->payment_type = $params['payment_type'];
        $invoice_item->amount = $params['amount'];
        $invoice_item->currency = $params['currency'];
        $invoice_item->receiver_id = $params['receiver_id'];
        $invoice_item->payment_email = $params['payment_email'];
        $invoice_item->txn_id = $params['txn_id'];
        $invoice_item->txn_type = $params['txn_type'];
        $invoice_item->payer_status = $params['payer_status'];
        $invoice_item->residence_country = $params['residence_country'];
        $invoice_item->payment_date = date("Y-m-d H:i:s", time());
        $invoice_item->reason = $params['reason'];
        $invoice_item->origin = $params['payment_method'];
        $invoice_item->payment_vars = $params['payment_vars'];
        if ($invoice_item->save()) {
            /** EMAIL TEXT **/
            $email_template = get_lang('email_template', 'confirm_order');
            $subject = str_replace("#SiteName#", SITE_NAME, $email_template['email_subject']);
            $body = $email_template['email_text'];
            $body = str_replace("#FullName#", $clint->full_name(), $body);
            $body = str_replace("#SiteName#", SITE_NAME, $body);
            $body = str_replace("#InvoiceId#", $invoice_id, $body);
            $body = str_replace("#Qty#", $invoice->posts_quantity, $body);
            $body = str_replace("#Amount#", $invoice->amount, $body);
            $body = str_replace("#PayMethod#", 'None', $body);
            $body = str_replace("#Domain#", $_SERVER['HTTP_HOST'], $body);
            $body = str_replace("#ContactUs#", ADMIN_EMAIL, $body);
            $body = str_replace("#Link#", BASE_URL, $body);
            $to = array("email" => $clint->email_address, "name" => $clint->full_name());
            $from = array("email" => NO_REPLY_EMAIL, "name" => SITE_NAME);
            /** end email text **/
            $mail = send_mail($body, $subject, $to, $from, "", "");
            //redirect_to(BASE_URL."employer/credits/");
            //die;
            return $mail;
        }
    }
    return false;
}
 protected function _addPendingInvoiceAndSend(Invoice $invoice, Am_Form $form, $vars)
 {
     if ($vars['paysys_id']) {
         try {
             $invoice->setPaysystem($vars['paysys_id'], false);
         } catch (Am_Exception_InputError $e) {
             $form->setError($e->getMessage());
             return false;
         }
     }
     $errors = $invoice->validate();
     if ($errors) {
         $form->setError(current($errors));
         return false;
     }
     $invoice->data()->set('added-by-admin', $this->getDi()->authAdmin->getUserId());
     $invoice->due_date = $vars['tm_due'];
     $invoice->save();
     $et = Am_Mail_Template::load('invoice_pay_link', $invoice->getUser()->lang ? $invoice->getUser()->lang : null);
     $et->setUser($invoice->getUser());
     $et->setUrl(ROOT_SURL . sprintf('/pay/%s', $invoice->getSecureId('payment-link')));
     $et->setMessage($vars['message']);
     $et->setInvoice($invoice);
     $et->setInvoice_text($invoice->render());
     $et->send($invoice->getUser());
     return true;
 }
예제 #21
0
파일: PInvoice.php 프로젝트: uzerpllp/uzerp
 public function save()
 {
     $pi_line = DataObjectFactory::Factory('PInvoiceLine');
     $cc = new ConstraintChain();
     $cc->add(new Constraint('invoice_id', '=', $this->id));
     $totals = $pi_line->getSumFields(array('gross_value', 'tax_value', 'net_value', 'twin_gross_value', 'twin_tax_value', 'twin_net_value', 'base_Gross_value', 'base_tax_value', 'base_net_value'), $cc, 'pi_lines');
     unset($totals['numrows']);
     // set the correct totals back to the invoice header
     foreach ($totals as $field => $value) {
         $this->{$field} = empty($value) ? '0.00' : bcadd($value, 0);
     }
     if ($this->settlement_discount == 0) {
         $this->settlement_discount = bcadd($this->getSettlementDiscount(), 0);
     }
     return parent::save();
 }
 public function actionWrite()
 {
     if (isset($_POST['Invoice'])) {
         $messages = $this->ValidateData(array());
         if ($messages == '') {
             if ((int) $_POST['Invoice']['invoiceid'] > 0) {
                 $model = $this->loadModel($_POST['Invoice']['invoiceid']);
                 $model->addressbookid = $_POST['Invoice']['addressbookid'];
                 $model->invoiceno = $_POST['Invoice']['invoiceno'];
                 $model->pono = $_POST['Invoice']['pono'];
                 $model->amount = $_POST['Invoice']['amount'];
                 $model->currencyid = $_POST['Invoice']['currencyid'];
                 $model->taxid = $_POST['Invoice']['taxid'];
                 $model->rate = $_POST['Invoice']['rate'];
                 $model->invoicedate = $_POST['Invoice']['invoicedate'];
                 $model->paymentmethodid = $_POST['Invoice']['paymentmethodid'];
                 $model->headernote = $_POST['Invoice']['headernote'];
             } else {
                 $model = new Invoice();
                 $model->attributes = $_POST['Invoice'];
             }
             try {
                 if ($model->save()) {
                     $this->DeleteLock($this->menuname, $_POST['Invoice']['invoiceid']);
                     $this->GetSMessage('insertsuccess');
                 } else {
                     $this->GetMessage($model->getErrors());
                 }
             } catch (Exception $e) {
                 $this->GetMessage($e->getMessage());
             }
         }
     }
 }
예제 #23
0
 public function invoice()
 {
     $items = PastTime::query()->whereIn('id', Input::get('items'))->where('invoice_id', 0)->orderBy('ressource_id', 'ASC')->orderBy('time_start', 'ASC')->get();
     $lines = array();
     $ressources = array();
     $users = array();
     $user = null;
     foreach ($items as $item) {
         $ressources[$item->ressource_id] = $item->ressource()->getResults();
         $lines[$item->ressource_id][] = $item;
         $users[$item->user_id] = true;
         if (null == $user) {
             /** @var User $user */
             $user = $item->user()->getResults();
         }
     }
     if (count($users) > 1) {
         return Redirect::route('pasttime_list')->with('mError', 'Impossible de générer la facture pour plusieurs utilisateurs à la fois');
     }
     if (count($users) == 0) {
         return Redirect::route('pasttime_list');
     }
     $organisation = $user->organisations->first();
     $invoice = new Invoice();
     $invoice->user_id = $user->id;
     $invoice->created_at = new \DateTime();
     $invoice->organisation_id = $organisation->id;
     $invoice->type = 'F';
     $invoice->days = date('Ym');
     $invoice->number = $invoice->next_invoice_number($invoice->type, $invoice->days);
     $invoice->address = $organisation->fulladdress;
     $invoice->date_invoice = new \DateTime();
     $invoice->deadline = new \DateTime(date('Y-m-d', strtotime('+1 month')));
     $invoice->save();
     $vat = VatType::where('value', 20)->first();
     $orderIndex = 0;
     foreach ($lines as $ressource_id => $line) {
         $ressource = $ressources[$ressource_id];
         $invoice_line = new InvoiceItem();
         $invoice_line->invoice_id = $invoice->id;
         $invoice_line->amount = 0;
         $invoice_line->order_index = $orderIndex++;
         if ($ressource_id == Ressource::TYPE_COWORKING) {
             $invoice_line->text = 'Coworking';
             $sum_duration = 0;
             foreach ($line as $item) {
                 $duration = ceil((strtotime($item->time_end) - strtotime($item->time_start)) / 3600 / self::COWORKING_HALF_DAY_MAX_DURATION);
                 $sum_duration += $duration;
                 $invoice_line->text .= sprintf("\n - %s de %s à %s (%s demi journée%s)", date('d/m/Y', strtotime($item->time_start)), date('H:i', strtotime($item->time_start)), date('H:i', strtotime($item->time_end)), $duration, $duration > 1 ? 's' : '');
                 $invoice_line->amount += $duration * (self::COWORKING_HALF_DAY_PRICING / 1.2);
                 $item->invoice_id = $invoice->id;
                 $item->save();
             }
             $invoice_line->text .= sprintf("\nTotal : %s demi journée%s", $sum_duration, $sum_duration > 1 ? 's' : '');
         } else {
             $invoice_line->text = sprintf('Location d\'espace de réunion - %s', $ressource->name);
             foreach ($line as $item) {
                 $invoice_line->text .= sprintf("\n - %s de %s à %s", date('d/m/Y', strtotime($item->time_start)), date('H:i', strtotime($item->time_start)), date('H:i', strtotime($item->time_end)));
                 $invoice_line->amount += min(7, (strtotime($item->time_end) - strtotime($item->time_start)) / 3600) * $ressource->amount;
                 $item->invoice_id = $invoice->id;
                 $item->save();
             }
         }
         $invoice_line->vat_types_id = $vat->id;
         $invoice_line->ressource_id = $item->ressource_id;
         $invoice_line->save();
     }
     return Redirect::route('invoice_modify', $invoice->id)->with('mSuccess', 'La facture a bien été générée');
 }
예제 #24
0
 $invoice->column_fields["subject"] = $isubj_array[$i];
 $invoice->column_fields["invoicestatus"] = $istatus_array[$i];
 $invoice->column_fields["hdnGrandTotal"] = $itotal_array[$i];
 $invoice->column_fields["bill_street"] = $street_address_array[rand(0, $street_address_count - 1)];
 $invoice->column_fields["bill_city"] = $city_array[rand(0, $city_array_count - 1)];
 $invoice->column_fields["bill_state"] = "CA";
 $invoice->column_fields["bill_code"] = rand(10000, 99999);
 $invoice->column_fields["bill_country"] = 'USA';
 $invoice->column_fields["ship_street"] = $account->column_fields["bill_street"];
 $invoice->column_fields["ship_city"] = $account->column_fields["bill_city"];
 $invoice->column_fields["ship_state"] = $account->column_fields["bill_state"];
 $invoice->column_fields["ship_code"] = $account->column_fields["bill_code"];
 $invoice->column_fields["ship_country"] = $account->column_fields["bill_country"];
 $invoice->column_fields["currency_id"] = '1';
 $invoice->column_fields["conversion_rate"] = '1';
 $invoice->save("Invoice");
 $invoice_ids[] = $invoice->id;
 if ($i > 3) {
     $freetag = $adb->getUniqueId('vtiger_freetags');
     $query = "insert into vtiger_freetags values (?,?,?)";
     $qparams = array($freetag, $cloudtag[0], $cloudtag[0]);
     $res_inv = $adb->pquery($query, $qparams);
     $date = $adb->formatDate(date('YmdHis'), true);
     $query_tag = "insert into vtiger_freetagged_objects values (?,?,?,?,?)";
     $tag_params = array($freetag, 1, $invoice->id, $date, 'Invoice');
     $result_inv = $adb->pquery($query_tag, $tag_params);
 }
 $product_key = array_rand($product_ids);
 $productid = $product_ids[$product_key];
 //set the inventory product details in request then just call the saveInventoryProductDetails function
 $_REQUEST['totalProductCount'] = 1;
예제 #25
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');
 }
예제 #26
0
 public function actionGenerate()
 {
     $names = file(getcwd() . "/protected/tests/names.txt");
     $streets = file(getcwd() . "/protected/tests/streets.txt");
     $name_arr = array();
     $street_arr = array();
     foreach ($names as $line) {
         $name = explode(" ", $line);
         $name_arr[] = trim($name[0]);
     }
     foreach ($streets as $line) {
         $street = explode(" ", $line);
         if (count($street) == 3) {
             $name1 = trim($street[0]);
             $name2 = trim($street[1]);
             $name3 = trim($street[2]);
             $street_arr[] = $name1 . " " . $name2 . " " . $name3 . ", Toronto";
         }
     }
     $limit = 1000000;
     for ($i = 0; $i < $limit; $i++) {
         set_time_limit(0);
         // resetting the MySQL timeout
         echo "Creating an invoice #{$i} <br/>";
         $invoice = new Invoice();
         $invoice->name = $name_arr[rand(0, count($name_arr) - 1)];
         $invoice->address = rand(1, 5000) . " " . $street_arr[rand(0, count($street_arr) - 1)];
         $y = 2012;
         //rand(2006,2012);
         if ($y < 2012) {
             $m = rand(1, 12);
         } else {
             $m = rand(1, 11);
         }
         $m = 11;
         $d = rand(1, 2);
         $invoice->date = date($y . '-' . $m . '-' . $d);
         $invoice->delivery_date = date($y . '-' . $m . '-' . $d);
         $invoice->phone1 = "647" . rand(1, 9) . rand(1, 9) . rand(1, 9) . rand(1, 9) . rand(1, 9) . rand(1, 9) . rand(1, 9);
         $invoice->delivery_date = date($y . '-' . $m . '-' . $d);
         $invoice->delivery_cost = rand(10, 50);
         if ($invoice->save()) {
             $number_of_items = rand(3, 9);
             for ($j = 0; $j < $number_of_items; $j++) {
                 $entry = new Entry();
                 $entry->invoice = $invoice->id;
                 $entry->inventory = rand(3, 2709);
                 $inventory = Inventory::model()->findByPk($entry->inventory);
                 if ($inventory) {
                     $entry->item = $inventory->name . " #" . $inventory->model;
                     $entry->quantity = rand(1, $inventory->quantity);
                     $entry->price = round($inventory->in * 1.3);
                     $entry->amount = round($entry->price * 0.9 * $entry->quantity);
                     if ($entry->save()) {
                         echo "--Entry Created! <br/>";
                         $inventory->quantity = $inventory->quantity - $entry->quantity;
                         if ($inventory->save()) {
                             echo "---Inventory Updated! <br/>";
                         } else {
                             $entry->delete();
                             echo "***Inventory Error! Failed to update <br/>";
                         }
                     } else {
                         echo "***Entry Error!  <br/>";
                         print_r($entry->getErrors());
                         echo "<br/>";
                     }
                 } else {
                     echo "*Inventory Error! (invalid randomed inventory id) <br/>";
                 }
             }
             if ($invoice->Amount > 0) {
                 echo "Invoice Created! id=>" . $invoice->id . "<br/>";
             } else {
                 echo "Invoice has no entries! Deleting id=>" . $invoice->id . "<br/>";
                 $invoice->delete();
             }
         } else {
             echo "Invoice Error! <br/>";
             print_r($invoice->getError());
             echo "<br/>";
         }
         echo "<hr/>";
     }
 }
예제 #27
0
$payment_record = $user->find_by_sql($sql);
if (empty($payment_record)) {
    redirect_to('select_form.php');
}
$student_status = $user->get_student_status();
$database = new MYSQLDatabase();
$sqlprogrammedetails = "SELECT * FROM personal_details p, department d, faculty f WHERE p.applicant_id=" . $session->applicant_id . " AND p.programme_applied_id=d.department_id AND d.faculty_id=f.faculty_id";
$programmedetails = $database->fetch_array($database->query($sqlprogrammedetails));
$sessiondetails = $database->fetch_array($database->query("SELECT session FROM application_status WHERE id=1"));
$paymentdetails = $database->fetch_array($database->query("SELECT * FROM adm_access_code WHERE jamb_rem_no='" . $programmedetails['form_id'] . "'"));
$invoice = new Invoice();
$invoice->db_fields = array('applicant_id', 'date', 'amount');
$invoice->applicant_id = $session->applicant_id;
$invoice->date = date('Y-m-d H:i:s', time());
$invoice->amount = $paymentdetails['amount'];
$invoice->save();
$invoicedetails = $database->fetch_array($database->query("SELECT * FROM invoice WHERE applicant_id='" . $session->applicant_id . "'"));
//set it to writable location, a place for temp generated PNG files
// $PNG_TEMP_DIR = dirname(__FILE__).DIRECTORY_SEPARATOR.'temp'.DIRECTORY_SEPARATOR;
$PNG_TEMP_DIR = 'inc/qrcode/temp/';
//html PNG location prefix
$PNG_WEB_DIR = 'inc/qrcode/temp/';
include "inc/qrcode/qrlib.php";
//ofcourse we need rights to create temp dir
if (!file_exists($PNG_TEMP_DIR)) {
    mkdir($PNG_TEMP_DIR);
}
$filename = $PNG_TEMP_DIR . 'test.png';
//processing form input
//remember to sanitize user input in real-life solution !!!
$errorCorrectionLevel = 'H';
예제 #28
0
 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;
 }
예제 #29
0
파일: index.php 프로젝트: prtsoft/php-sdk
    $description = "item description";
    $qty = 1;
    $rate = 100;
    $taxes = ["VAT", "10%", 3];
    # You can specify a tax name (will search the DB), a percentage (will be created if none exists), or the tax's ID.
    $discount = 0;
    $invoice->addStandardLineItem($name, $qty, $rate, $taxes, $description, $discount);
    $invoice->addFlatRateLineItem($name, $rate, $taxes, $description, $discount);
    $invoice->addFixedDiscountLineItem($name, 5);
    $invoice->addPercentageDiscountLineItem($name, 10);
    $invoice->addFile("http://i.28hours.org/files/APIEndpoints.pdf");
    # Pass a URL...
    $invoice->addFile("LICENSE.txt");
    # Or a filename.
    $invoice->addFileFromContents("this is my test file", "filename.txt");
    # You can provide your file's contents here and give it a filename.
    # Will always create a new record; it can't update existing records.
    $result = $invoice->save();
    echo "Created Invoice #{$result['unique_id']}.";
} catch (ApiException $e) {
    # You can use getRequest() and getResponse() to get details on what went wrong.
    $request = $e->getRequest();
    $response = $e->getResponse();
    # Response can be an array (which means Pancake's API replied with an error message), or a blob of HTML (which indicates problems like a Pancake-side error).
    if (is_array($response)) {
        echo "<pre>";
        var_dump($response);
    } else {
        echo $response;
    }
}
예제 #30
0
 public function renew($id)
 {
     $subscription = $this->dataExist($id);
     $invoice = new Invoice();
     $invoice->type = 'F';
     $invoice->user_id = $subscription->user_id;
     $invoice->organisation_id = $subscription->organisation_id;
     $invoice->days = date('Ym');
     $invoice->date_invoice = date('Y-m-d');
     $invoice->number = Invoice::next_invoice_number($invoice->type, $invoice->days);
     $invoice->address = $subscription->organisation->fulladdress;
     $date = new DateTime($invoice->date_invoice);
     $date->modify('+1 month');
     $invoice->deadline = $date->format('Y-m-d');
     $invoice->save();
     $invoice_line = new InvoiceItem();
     $invoice_line->invoice_id = $invoice->id;
     $invoice_line->ressource_id = Ressource::TYPE_COWORKING;
     $invoice_line->amount = $subscription->kind->price;
     $date = new \DateTime($subscription->renew_at);
     $date2 = new \DateTime($subscription->renew_at);
     $invoice_line->subscription_from = $date->format('Y-m-d');
     $date2->modify('next month');
     $invoice_line->subscription_to = $date2->format('Y-m-d');
     $invoice_line->subscription_hours_quota = $subscription->kind->hours_quota;
     // update invoices_items set subscription_to = date_add(subscription_from, interval 1 MONTH) where subscription_from <> '0000-00-00 00:00:00'
     $date2->modify('-1 day');
     $invoice_line->text = sprintf("%s - %s\nDu %s au %s", $subscription->kind->name, $subscription->user->fullname, $date->format('d/m/Y'), $date2->format('d/m/Y'));
     $invoice_line->vat_types_id = VatType::whereValue(20)->first()->id;
     $invoice_line->ressource_id = Ressource::TYPE_COWORKING;
     $invoice_line->save();
     $invoice_line->order_index = 1;
     $date = new DateTime($subscription->renew_at);
     $date->modify('+1 month');
     $subscription->renew_at = $date->format('Y-m-d');
     $subscription->save();
     return Redirect::route('invoice_modify', $invoice->id)->with('mSuccess', 'La facture a été créée');
 }