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


PHP Invoice::shouldSendToday方法代码示例

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


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

示例1: createRecurringInvoice

 /**
  * @param Invoice $recurInvoice
  * @return mixed
  */
 public function createRecurringInvoice(Invoice $recurInvoice)
 {
     $recurInvoice->load('account.timezone', 'invoice_items', 'client', 'user');
     if ($recurInvoice->client->deleted_at) {
         return false;
     }
     if (!$recurInvoice->user->confirmed) {
         return false;
     }
     if (!$recurInvoice->shouldSendToday()) {
         return false;
     }
     $invoice = Invoice::createNew($recurInvoice);
     $invoice->invoice_type_id = INVOICE_TYPE_STANDARD;
     $invoice->client_id = $recurInvoice->client_id;
     $invoice->recurring_invoice_id = $recurInvoice->id;
     $invoice->invoice_number = $recurInvoice->account->getNextInvoiceNumber($invoice);
     $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 = Utils::processVariables($recurInvoice->public_notes);
     $invoice->terms = Utils::processVariables($recurInvoice->terms);
     $invoice->invoice_footer = Utils::processVariables($recurInvoice->invoice_footer);
     $invoice->tax_name1 = $recurInvoice->tax_name1;
     $invoice->tax_rate1 = $recurInvoice->tax_rate1;
     $invoice->tax_name2 = $recurInvoice->tax_name2;
     $invoice->tax_rate2 = $recurInvoice->tax_rate2;
     $invoice->invoice_design_id = $recurInvoice->invoice_design_id;
     $invoice->custom_value1 = $recurInvoice->custom_value1 ?: 0;
     $invoice->custom_value2 = $recurInvoice->custom_value2 ?: 0;
     $invoice->custom_taxes1 = $recurInvoice->custom_taxes1 ?: 0;
     $invoice->custom_taxes2 = $recurInvoice->custom_taxes2 ?: 0;
     $invoice->custom_text_value1 = Utils::processVariables($recurInvoice->custom_text_value1);
     $invoice->custom_text_value2 = Utils::processVariables($recurInvoice->custom_text_value2);
     $invoice->is_amount_discount = $recurInvoice->is_amount_discount;
     $invoice->due_date = $recurInvoice->getDueDate();
     $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_name1 = $recurItem->tax_name1;
         $item->tax_rate1 = $recurItem->tax_rate1;
         $item->tax_name2 = $recurItem->tax_name2;
         $item->tax_rate2 = $recurItem->tax_rate2;
         $item->custom_value1 = Utils::processVariables($recurItem->custom_value1);
         $item->custom_value2 = Utils::processVariables($recurItem->custom_value2);
         $invoice->invoice_items()->save($item);
     }
     foreach ($recurInvoice->documents as $recurDocument) {
         $document = $recurDocument->cloneDocument();
         $invoice->documents()->save($document);
     }
     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);
     }
     $recurInvoice->last_sent_date = date('Y-m-d');
     $recurInvoice->save();
     if ($recurInvoice->getAutoBillEnabled() && !$recurInvoice->account->auto_bill_on_due_date) {
         // autoBillInvoice will check for ACH, so we're not checking here
         if ($this->paymentService->autoBillInvoice($invoice)) {
             // update the invoice reference to match its actual state
             // this is to ensure a 'payment received' email is sent
             $invoice->invoice_status_id = INVOICE_STATUS_PAID;
         }
     }
     return $invoice;
 }
开发者ID:rafaelsisweb,项目名称:invoice-ninja,代码行数:80,代码来源:InvoiceRepository.php


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