本文整理汇总了PHP中Invoice::with方法的典型用法代码示例。如果您正苦于以下问题:PHP Invoice::with方法的具体用法?PHP Invoice::with怎么用?PHP Invoice::with使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Invoice
的用法示例。
在下文中一共展示了Invoice::with方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: show
/**
* Display the specified resource.
* GET /accountreceivables/{id}
*
* @param int $id
* @return Response
*/
public function show($id)
{
$invoices = Invoice::with('invoicedetail')->find($id);
if ($invoices->type === "to tenant") {
$total = $invoices->invoicedetail->rent + $invoices->invoicedetail->water + $invoices->invoicedetail->electricity + $invoices->invoicedetail->security + $invoices->invoicedetail->service + $invoices->invoicedetail->garbage;
} elseif ($invoices->type === "refund") {
$total = $invoices->invoicedetail->rentD + $invoices->invoicedetail->waterD + $invoices->invoicedetail->electricityD + $invoices->invoicedetail->g_repairs + $invoices->invoicedetail->transport_cost + $invoices->invoicedetail->o_bills + $invoices->invoicedetail->storage_fees + $invoices->invoicedetail->fixed_unit;
} elseif ($invoices->type === "deposits") {
$total = $invoices->invoicedetail->rentD + $invoices->invoicedetail->waterD + $invoices->invoicedetail->electricityD + $invoices->invoicedetail->g_repairs + $invoices->invoicedetail->transport_cost + $invoices->invoicedetail->o_bills + $invoices->invoicedetail->storage_fees + $invoices->invoicedetail->fixed_unit + $invoices->invoicedetail->rent;
}
$houseid = $invoices->id;
$hid = $invoices->houseID;
$housename = House::where('id', $hid)->pluck('name');
$propertyid = House::where('id', $hid)->pluck('propertyID');
$propertyname = Property::where('id', $propertyid)->pluck('name');
$allbal = Invoice::where('houseID', $hid)->sum('balance');
if ($invoices->amountpaid <= 0) {
$outstandingbal = $allbal;
} else {
$outstandingbal = $allbal - $invoices->balance;
}
$balance = $invoices->balance;
if ($outstandingbal == $invoices->balance) {
$amountdue = $invoices->balance;
} else {
$amountdue = $invoices->balance + $outstandingbal;
}
$title = "Print Invoice";
return View::make('backend.code.invoice.show', compact('invoices', 'housename', 'title', 'outstandingbal', 'propertyname', 'invoicedetails', 'total', 'balance', 'amountdue'));
}
示例2: create
/**
* Show the form for creating a new resource.
* GET /payments/create
*
* @return Response
*/
public function create($id)
{
$invoices = Invoice::with('invoicedetail')->find($id);
$paymenttypes = Paymenttype::all();
$total = $invoices->invoicedetail->rent + $invoices->invoicedetail->water + $invoices->invoicedetail->electricity + $invoices->invoicedetail->security;
$houseid = $invoices->houseID;
$balance = Payment::where('houseID', $houseid)->sum('balance');
return View::make('backend.code.payment.create', compact('invoices', 'invoicedetail', 'total', 'balance'));
}
示例3: fire
public function fire()
{
$this->info(date('Y-m-d') . ' Running SendRecurringInvoices...');
$today = new DateTime();
$invoices = Invoice::with('account.timezone', 'invoice_items', 'client')->whereRaw('is_deleted IS FALSE AND deleted_at IS NULL AND is_recurring IS TRUE AND start_date <= ? AND (end_date IS NULL OR end_date >= ?)', array($today, $today))->get();
$this->info(count($invoices) . ' recurring invoice(s) found');
foreach ($invoices as $recurInvoice) {
if ($recurInvoice->client->deleted_at) {
continue;
}
date_default_timezone_set($recurInvoice->account->getTimezone());
$this->info('Processing Invoice ' . $recurInvoice->id . ' - Should send ' . ($recurInvoice->shouldSendToday() ? 'YES' : 'NO'));
if (!$recurInvoice->shouldSendToday()) {
continue;
}
$invoice = Invoice::createNew($recurInvoice);
$invoice->client_id = $recurInvoice->client_id;
$invoice->recurring_invoice_id = $recurInvoice->id;
$invoice->invoice_number = 'R' . $recurInvoice->account->getNextInvoiceNumber();
$invoice->amount = $recurInvoice->amount;
$invoice->balance = $recurInvoice->amount;
$invoice->invoice_date = date_create()->format('Y-m-d');
$invoice->discount = $recurInvoice->discount;
$invoice->po_number = $recurInvoice->po_number;
$invoice->public_notes = $recurInvoice->public_notes;
$invoice->terms = $recurInvoice->terms;
$invoice->tax_name = $recurInvoice->tax_name;
$invoice->tax_rate = $recurInvoice->tax_rate;
$invoice->invoice_design_id = $recurInvoice->invoice_design_id;
if ($invoice->client->payment_terms) {
$invoice->due_date = date_create()->modify($invoice->client->payment_terms . ' day')->format('Y-m-d');
}
$invoice->save();
foreach ($recurInvoice->invoice_items as $recurItem) {
$item = InvoiceItem::createNew($recurItem);
$item->product_id = $recurItem->product_id;
$item->qty = $recurItem->qty;
$item->cost = $recurItem->cost;
$item->notes = Utils::processVariables($recurItem->notes);
$item->product_key = Utils::processVariables($recurItem->product_key);
$item->tax_name = $recurItem->tax_name;
$item->tax_rate = $recurItem->tax_rate;
$invoice->invoice_items()->save($item);
}
foreach ($recurInvoice->invitations as $recurInvitation) {
$invitation = Invitation::createNew($recurInvitation);
$invitation->contact_id = $recurInvitation->contact_id;
$invitation->invitation_key = str_random(RANDOM_KEY_LENGTH);
$invoice->invitations()->save($invitation);
}
$this->mailer->sendInvoice($invoice);
$recurInvoice->last_sent_date = Carbon::now()->toDateTimeString();
$recurInvoice->save();
}
$this->info('Done');
}
示例4: getDetail
public function getDetail($id)
{
$invoices = Invoice::with('invoicedetail')->find($id);
if ($invoices->type === "to tenant") {
$total = $invoices->invoicedetail->rent + $invoices->invoicedetail->water + $invoices->invoicedetail->electricity + $invoices->invoicedetail->security + $invoices->invoicedetail->service + $invoices->invoicedetail->garbage;
} elseif ($invoices->type === "refund") {
$deposits = $invoices->invoicedetail->rentD + $invoices->invoicedetail->waterD + $invoices->invoicedetail->electricityD;
$others = $invoices->invoicedetail->g_repairs + $invoices->invoicedetail->transport_cost + $invoices->invoicedetail->o_bills + $invoices->invoicedetail->storage_fees + $invoices->invoicedetail->fixed_unit;
$total = $deposits - $others;
} elseif ($invoices->type === "deposits") {
$total = $invoices->invoicedetail->rentD + $invoices->invoicedetail->waterD + $invoices->invoicedetail->electricityD + $invoices->invoicedetail->g_repairs + $invoices->invoicedetail->transport_cost + $invoices->invoicedetail->o_bills + $invoices->invoicedetail->storage_fees + $invoices->invoicedetail->fixed_unit + $invoices->invoicedetail->rent;
}
$houseid = $invoices->id;
$hid = $invoices->houseID;
$housename = $hid;
$propertyid = House::where('name', $hid)->pluck('propertyID');
$propertyname = Property::where('id', $propertyid)->pluck('name');
$allbal = Invoice::where('houseID', $hid)->sum('balance');
if ($invoices->amountpaid < 0) {
$outstandingbal = $allbal;
} else {
$outstandingbal = $allbal - $invoices->balance;
}
$balance = $invoices->balance;
if ($invoices->type === "refund") {
if ($outstandingbal == $invoices->balance) {
$amountdue = $invoices->balance;
}
$amountdue = $outstandingbal - $invoices->balance;
} else {
if ($outstandingbal == $invoices->balance) {
$amountdue = $invoices->balance;
}
$amountdue = $invoices->balance + $outstandingbal;
}
if ($balance <= 0) {
$title = "Print Receipt";
$mdeposits = "Receipt for Rent Payment";
$mtenant = "Receipt for Deposits Payment";
} else {
$title = "Print Invoice";
$mdeposits = "Invoice for Rent Payment";
$mtenant = "Invoice for Deposits Payment";
}
return Response::json(array('mdeposits' => $mdeposits, 'mtenant' => $mtenant, 'invoices' => $invoices, 'housename' => $housename, 'title' => $title, 'outstandingbal' => $outstandingbal, 'propertyname' => $propertyname, 'total' => $total, 'balance' => $balance, 'amountdue' => $amountdue));
}
示例5: showSpeReceipts
public function showSpeReceipts($id)
{
$invoices = Invoice::with('invoicedetail')->find($id);
if ($invoices->type === "to tenant") {
$total = $invoices->invoicedetail->rent + $invoices->invoicedetail->water + $invoices->invoicedetail->electricity + $invoices->invoicedetail->security + $invoices->invoicedetail->service + $invoices->invoicedetail->garbage;
} elseif ($invoices->type === "refund") {
$total = $invoices->invoicedetail->rentD + $invoices->invoicedetail->waterD + $invoices->invoicedetail->electricityD + $invoices->invoicedetail->g_repairs + $invoices->invoicedetail->transport_cost + $invoices->invoicedetail->o_bills + $invoices->invoicedetail->storage_fees + $invoices->invoicedetail->fixed_unit;
} elseif ($invoices->type === "deposits") {
$total = $invoices->invoicedetail->rentD + $invoices->invoicedetail->waterD + $invoices->invoicedetail->electricityD + $invoices->invoicedetail->g_repairs + $invoices->invoicedetail->transport_cost + $invoices->invoicedetail->o_bills + $invoices->invoicedetail->storage_fees + $invoices->invoicedetail->fixed_unit + $invoices->invoicedetail->rent;
}
$houseid = $invoices->id;
$hid = $invoices->houseID;
$housename = House::where('id', $hid)->pluck('name');
$tenantname = House::where('id', $hid)->pluck('tenant');
$propertyid = House::where('id', $hid)->pluck('propertyID');
$propertyname = Property::where('id', $propertyid)->pluck('name');
$allbal = Invoice::where('houseID', $hid)->sum('balance');
if ($invoices->amountpaid <= 0) {
$outstandingbal = $allbal;
} else {
$outstandingbal = $allbal - $invoices->balance;
}
$balance = $invoices->balance;
if ($outstandingbal == $invoices->balance) {
$amountdue = $invoices->balance;
} else {
$amountdue = $invoices->balance + $outstandingbal;
}
$title = "Print Receipt";
/*
$emailcontent = array (
'propertyname'=> $propertyname,
'housename'=> $housename,
'tenant'=> $tenantname,
'tfname'=> $invoices->recipient,
'invoiceid'=> $invoices->id,
'created_at'=> $invoices->created_at,
'invoicetype'=> $invoices->type,
'rent'=> $invoices->invoicedetail->rent,
'water'=> $invoices->invoicedetail->water,
'electricity'=> $invoices->invoicedetail->electricity,
'security'=> $invoices->invoicedetail->security,
'service'=> $invoices->invoicedetail->service,
'garbage'=> $invoices->invoicedetail->garbage,
'rentD'=> $invoices->invoicedetail->rentD,
'rent'=> $invoices->invoicedetail->rent,
'waterD'=> $invoices->invoicedetail->waterD,
'electricityD'=> $invoices->invoicedetail->electricityD,
'garbage'=> $invoices->invoicedetail->garbage,
'transport_cost'=> $invoices->invoicedetail->transport_cost,
'g_repairs'=> $invoices->invoicedetail->g_repairs,
'o_bills'=> $invoices->invoicedetail->o_bills,
'storage_fees'=> $invoices->invoicedetail->storage_fees,
'total'=> $total,
'amountpaid'=> $invoices->amountpaid,
'balance'=> $balance,
'outstandingbal'=> $outstandingbal,
'amountdue'=> $amountdue,
'duedate'=> $invoices->duedate
);
Mail::send('emails.receipts', $emailcontent, function($message)
{
$message->to('jeremiyteki@gmail.com')
->subject('Receipts');
});
*/
return View::make('backend.code.invoice.show', compact('invoices', 'title', 'housename', 'outstandingbal', 'propertyname', 'invoicedetails', 'total', 'balance', 'amountdue'));
}
示例6: bulk
public function bulk()
{
$action = Input::get('action');
if ($action == 'convert') {
$invoice = Invoice::with('invoice_items')->scope(Input::get('id'))->firstOrFail();
$clone = $this->invoiceRepo->cloneInvoice($invoice, $invoice->id);
Session::flash('message', trans('texts.converted_to_invoice'));
return Redirect::to('invoices/' . $clone->public_id);
}
$statusId = Input::get('statusId');
$ids = Input::get('id') ? Input::get('id') : Input::get('ids');
$count = $this->invoiceRepo->bulk($ids, $action, $statusId);
if ($count > 0) {
$key = $action == 'mark' ? "updated_quote" : "{$action}d_quote";
$message = Utils::pluralize($key, $count);
Session::flash('message', $message);
}
return Redirect::to('quotes');
}
示例7: convertQuote
public function convertQuote($publicId)
{
$invoice = Invoice::with('invoice_items')->scope($publicId)->firstOrFail();
$clone = $this->invoiceRepo->cloneInvoice($invoice, $invoice->id);
Session::flash('message', trans('texts.converted_to_invoice'));
return Redirect::to('invoices/' . $clone->public_id);
}
示例8: updateInvoice
public static function updateInvoice($invoice)
{
$client = $invoice->client;
if ($invoice->is_deleted && !$invoice->getOriginal('is_deleted')) {
if (!$invoice->is_quote && !$invoice->is_recurring) {
$client->balance = $client->balance - $invoice->balance;
$client->paid_to_date = $client->paid_to_date - ($invoice->amount - $invoice->balance);
$client->save();
}
$activity = Activity::getBlank();
$activity->client_id = $invoice->client_id;
$activity->invoice_id = $invoice->id;
$activity->activity_type_id = $invoice->is_quote ? ACTIVITY_TYPE_DELETE_QUOTE : ACTIVITY_TYPE_DELETE_INVOICE;
$activity->message = Utils::encodeActivity(Auth::user(), 'deleted', $invoice);
$activity->balance = $invoice->client->balance;
$activity->adjustment = $invoice->is_quote ? 0 : $invoice->balance * -1;
$activity->save();
} else {
$diff = floatval($invoice->amount) - floatval($invoice->getOriginal('amount'));
if ($diff == 0) {
return;
}
$backupInvoice = Invoice::with('invoice_items', 'client.account', 'client.contacts')->find($invoice->id);
if (!$invoice->is_quote && !$invoice->is_recurring) {
$client->balance = $client->balance + $diff;
$client->save();
}
$activity = Activity::getBlank($invoice);
$activity->client_id = $invoice->client_id;
$activity->invoice_id = $invoice->id;
$activity->activity_type_id = $invoice->is_quote ? ACTIVITY_TYPE_UPDATE_QUOTE : ACTIVITY_TYPE_UPDATE_INVOICE;
$activity->message = Utils::encodeActivity(Auth::user(), 'updated', $invoice);
$activity->balance = $client->balance;
$activity->adjustment = $invoice->is_quote || $invoice->is_recurring ? 0 : $diff;
$activity->json_backup = $backupInvoice->hidePrivateFields()->toJSON();
$activity->save();
}
}
示例9: find
public function find($id)
{
$invoice = Invoice::with(["customer", "order", "customer.customerType", "employee", "business"])->whereId($id)->get();
return Response::json($invoice);
}
示例10: fire
public function fire()
{
$this->info(date('Y-m-d') . ' Cargando SendRecurringInvoices...');
$today = new DateTime();
$invoices = Invoice::with('account.timezone', 'invoice_items', 'client')->whereRaw('is_deleted IS FALSE AND deleted_at IS NULL AND is_recurring IS TRUE AND start_date <= ? AND (end_date IS NULL OR end_date >= ?)', array($today, $today))->get();
$this->info(count($invoices) . ' facturas recurrentes encontradas');
foreach ($invoices as $recurInvoice) {
if ($recurInvoice->client->deleted_at) {
continue;
}
if (!$recurInvoice->user->confirmed) {
continue;
}
date_default_timezone_set($recurInvoice->account->getTimezone());
$this->info('Procesando la factura con el id ' . $recurInvoice->id . ($recurInvoice->shouldSendToday() ? ' si se enviará' : ' no se enviará'));
// if (!$recurInvoice->shouldSendToday())
// {
// continue;
// }
$branch_id = $recurInvoice->branch_id;
$branch = DB::table('branches')->where('id', $branch_id)->first();
$account_id = $recurInvoice->account_id;
$account = DB::table('accounts')->where('id', $account_id)->first();
if (strtotime($branch->deadline) < strtotime('now')) {
continue;
}
$invoice = Invoice::createNew($recurInvoice);
$invoice->client_id = $recurInvoice->client_id;
$invoice->recurring_invoice_id = $recurInvoice->id;
$invoice->branch_id = $recurInvoice->branch_id;
$invoiceNumber = $branch->invoice_number_counter;
$invoice->invoice_number = $branch->invoice_number_counter;
$invoice->amount = $recurInvoice->amount;
$invoice->subtotal = $recurInvoice->subtotal;
$invoice->balance = $recurInvoice->amount;
$invoice->invoice_date = date_create()->format('Y-m-d');
$invoice->discount = $recurInvoice->discount;
$invoice->po_number = $recurInvoice->po_number;
$invoice->public_notes = $recurInvoice->public_notes;
$invoice->terms = $recurInvoice->terms;
// $invoice->tax_name = $recurInvoice->tax_name;
// $invoice->tax_rate = $recurInvoice->tax_rate;
$invoice->invoice_design_id = $recurInvoice->invoice_design_id;
$invoice->account_name = $recurInvoice->account_name;
$invoice->account_nit = $recurInvoice->account_nit;
$invoice->branch_name = $branch->name;
$invoice->address1 = $branch->address1;
$invoice->address2 = $branch->address2;
$invoice->phone = $branch->postal_code;
$invoice->city = $branch->city;
$invoice->state = $branch->state;
$invoice->number_autho = $branch->number_autho;
$invoice->deadline = $branch->deadline;
$invoice->key_dosage = $branch->key_dosage;
$invoice->client_nit = $recurInvoice->client_nit;
$invoice->client_name = $recurInvoice->client_name;
$invoice->activity_pri = $branch->activity_pri;
$invoice->activity_sec1 = $branch->activity_sec1;
$invoice->law = $branch->law;
$invoice_dateCC = date("Ymd", strtotime($invoice->invoice_date));
$invoice_date_limitCC = date("d/m/Y", strtotime($branch->deadline));
require_once app_path() . '/includes/control_code.php';
$cod_control = codigoControl($invoice->invoice_number, $invoice->client_nit, $invoice_dateCC, $invoice->amount, $branch->number_autho, $branch->key_dosage);
$invoice->control_code = $cod_control;
$invoice_date = date("d/m/Y", strtotime($invoice->invoice_date));
require_once app_path() . '/includes/BarcodeQR.php';
// $ice = $invoice->amount-$invoice->fiscal;
$desc = $invoice->subtotal - $invoice->amount;
$subtotal = number_format($invoice->subtotal, 2, '.', '');
$amount = number_format($invoice->amount, 2, '.', '');
$fiscal = number_format($invoice->fiscal, 2, '.', '');
// $icef = number_format($ice, 2, '.', '');
$descf = number_format($desc, 2, '.', '');
// if($icef=="0.00"){
// $icef = 0;
// }
if ($descf == "0.00") {
$descf = 0;
}
$icef = 0;
$qr = new BarcodeQR();
$datosqr = $invoice->account_nit . '|' . $invoice->invoice_number . '|' . $invoice->number_autho . '|' . $invoice_date . '|' . $subtotal . '|' . $amount . '|' . $invoice->control_code . '|' . $invoice->client_nit . '|' . $icef . '|0|0|' . $descf;
$qr->text($datosqr);
$qr->draw(150, 'public/qr/' . $account->account_key . '_' . $branch->name . '_' . $invoice->invoice_number . '.png');
$input_file = 'public/qr/' . $account->account_key . '_' . $branch->name . '_' . $invoice->invoice_number . '.png';
$output_file = 'public/qr/' . $account->account_key . '_' . $branch->name . '_' . $invoice->invoice_number . '.jpg';
$inputqr = imagecreatefrompng($input_file);
list($width, $height) = getimagesize($input_file);
$output = imagecreatetruecolor($width, $height);
$white = imagecolorallocate($output, 255, 255, 255);
imagefilledrectangle($output, 0, 0, $width, $height, $white);
imagecopy($output, $inputqr, 0, 0, 0, 0, $width, $height);
imagejpeg($output, $output_file);
$invoice->qr = HTML::image_data('qr/' . $account->account_key . '_' . $branch->name . '_' . $invoice->invoice_number . '.jpg');
if ($invoice->client->payment_terms) {
$invoice->due_date = date_create()->modify($invoice->client->payment_terms . ' day')->format('Y-m-d');
}
$invoice->save();
foreach ($recurInvoice->invoice_items as $recurItem) {
$item = InvoiceItem::createNew($recurItem);
//.........这里部分代码省略.........