当前位置: 首页>>代码示例>>PHP>>正文


PHP Invoice::next_invoice_number方法代码示例

本文整理汇总了PHP中Invoice::next_invoice_number方法的典型用法代码示例。如果您正苦于以下问题:PHP Invoice::next_invoice_number方法的具体用法?PHP Invoice::next_invoice_number怎么用?PHP Invoice::next_invoice_number使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Invoice的用法示例。


在下文中一共展示了Invoice::next_invoice_number方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: renew

 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');
 }
开发者ID:urashima82,项目名称:intranet,代码行数:38,代码来源:SubscriptionController.php

示例2: invoice

 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');
 }
开发者ID:urashima82,项目名称:intranet,代码行数:69,代码来源:PastTimeController.php

示例3: validate

 /**
  * Validate a quotation
  */
 public function validate($id)
 {
     /** @var Invoice $invoice */
     $invoice = $this->dataExist($id, 'invoice_list');
     $invoice_comment = new InvoiceComment();
     $invoice_comment->invoice_id = $invoice->id;
     $invoice_comment->user_id = Auth::user()->id;
     $invoice_comment->content = sprintf('Devis %s validé', $invoice->ident);
     $invoice_comment->save();
     $invoice->created_at = new \DateTime();
     $invoice->type = 'F';
     $invoice->days = date('Ym');
     $invoice->number = Invoice::next_invoice_number('F', $invoice->days);
     $invoice->date_invoice = new DateTime();
     if ($invoice->save()) {
         return Redirect::route('invoice_modify', $invoice->id)->with('mSuccess', 'La facture a bien été générée');
     } else {
         return Redirect::route('invoice_modify', $invoice->id)->with('mError', 'Impossible de générer la facture');
     }
 }
开发者ID:urashima82,项目名称:intranet,代码行数:23,代码来源:InvoiceController.php


注:本文中的Invoice::next_invoice_number方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。