Mention in the invoice notification that the invoice will be auto billed on the due date

This commit is contained in:
Joshua Dwire 2016-05-24 23:14:19 -04:00
parent a5fdb88d79
commit 9d4b42a514
5 changed files with 52 additions and 2 deletions

View File

@ -51,6 +51,28 @@ class SendRecurringInvoices extends Command
$invoice = $this->invoiceRepo->createRecurringInvoice($recurInvoice); $invoice = $this->invoiceRepo->createRecurringInvoice($recurInvoice);
if ($invoice && !$invoice->isPaid()) { if ($invoice && !$invoice->isPaid()) {
$invoice->account->auto_bill_on_due_date;
$autoBillLater = false;
if ($invoice->account->auto_bill_on_due_date) {
$autoBillLater = true;
} elseif ($paymentMethod = $this->paymentService->getClientDefaultPaymentMethod($invoice->client)) {
if ($paymentMethod && $paymentMethod->requiresDelayedAutoBill()) {
$autoBillLater = true;
}
}
if($autoBillLater) {
if (empty($paymentMethod)) {
$paymentMethod = $this->paymentService->getClientDefaultPaymentMethod($invoice->client);
}
if($paymentMethod) {
$invoice->autoBillPaymentMethod = $paymentMethod;
}
}
$this->info('Sending Invoice'); $this->info('Sending Invoice');
$this->mailer->sendInvoice($invoice); $this->mailer->sendInvoice($invoice);
} }
@ -74,7 +96,7 @@ class SendRecurringInvoices extends Command
$billNow = $invoice->account->auto_bill_on_due_date; $billNow = $invoice->account->auto_bill_on_due_date;
if (!$billNow) { if (!$billNow) {
$paymentMethod = $this->invoiceService->getClientDefaultPaymentMethod($invoice->client); $paymentMethod = $this->paymentService->getClientDefaultPaymentMethod($invoice->client);
if ($paymentMethod && $paymentMethod->requiresDelayedAutoBill()) { if ($paymentMethod && $paymentMethod->requiresDelayedAutoBill()) {
$billNow = true; $billNow = true;

View File

@ -30,6 +30,7 @@ class ContactMailer extends Mailer
'viewButton', 'viewButton',
'paymentLink', 'paymentLink',
'paymentButton', 'paymentButton',
'autoBill',
]; ];
public function __construct(TemplateService $templateService) public function __construct(TemplateService $templateService)
@ -106,6 +107,20 @@ class ContactMailer extends Mailer
return $response; return $response;
} }
private function createAutoBillNotifyString($paymentMethod) {
if ($paymentMethod->payment_type_id == PAYMENT_TYPE_DIRECT_DEBIT) {
$paymentMethodString = trans('texts.auto_bill_payment_method_bank', ['bank'=>$paymentMethod->getBankName(), 'last4'=>$paymentMethod->last4]);
} elseif ($paymentMethod->payment_type_id == PAYMENT_TYPE_ID_PAYPAL) {
$paymentMethodString = trans('texts.auto_bill_payment_method_paypal', ['email'=>$paymentMethod->email]);
} else {
$code = str_replace(' ', '', strtolower($paymentMethod->payment_type->name));
$cardType = trans("texts.card_" . $code);
$paymentMethodString = trans('texts.auto_bill_payment_method_credit_card', ['type'=>$cardType,'last4'=>$paymentMethod->last4]);
}
return trans('texts.auto_bill_notification', ['payment_method'=>$paymentMethodString]);
}
private function sendInvitation($invitation, $invoice, $body, $subject, $pdfString, $documentStrings) private function sendInvitation($invitation, $invoice, $body, $subject, $pdfString, $documentStrings)
{ {
$client = $invoice->client; $client = $invoice->client;
@ -137,6 +152,11 @@ class ContactMailer extends Mailer
'amount' => $invoice->getRequestedAmount() 'amount' => $invoice->getRequestedAmount()
]; ];
if ($invoice->autoBillPaymentMethod) {
// Let the client know they'll be billed later
$variables['autobill'] = $this->createAutoBillNotifyString($invoice->autoBillPaymentMethod);
}
if (empty($invitation->contact->password) && $account->hasFeature(FEATURE_CLIENT_PORTAL_PASSWORD) && $account->enable_portal_password && $account->send_portal_password) { if (empty($invitation->contact->password) && $account->hasFeature(FEATURE_CLIENT_PORTAL_PASSWORD) && $account->enable_portal_password && $account->send_portal_password) {
// The contact needs a password // The contact needs a password
$variables['password'] = $password = $this->generatePassword(); $variables['password'] = $password = $this->generatePassword();

View File

@ -51,6 +51,7 @@ class TemplateService
'$customInvoice1' => $account->custom_invoice_text_label1, '$customInvoice1' => $account->custom_invoice_text_label1,
'$customInvoice2' => $account->custom_invoice_text_label2, '$customInvoice2' => $account->custom_invoice_text_label2,
'$documents' => $documentsHTML, '$documents' => $documentsHTML,
'$autoBill' => empty($data['autobill'])?'':$data['autobill'],
]; ];
// Add variables for available payment types // Add variables for available payment types

View File

@ -1314,7 +1314,13 @@ $LANG = array(
'view_dashboard' => 'View Dashboard', 'view_dashboard' => 'View Dashboard',
'client_session_expired' => 'Session Expired', 'client_session_expired' => 'Session Expired',
'client_session_expired_message' => 'Your session has expired. Please click the link in your email again.' 'client_session_expired_message' => 'Your session has expired. Please click the link in your email again.',
'auto_bill_notification' => 'This invoice will automatically be billed to :payment_method on the due date.',
'auto_bill_payment_method_bank' => 'your :bank account ending in :last4',
'auto_bill_payment_method_credit_card' => 'your :type card ending in :last4',
'auto_bill_payment_method_paypal' => 'your PayPal account (:email)',
'auto_bill_notification_placeholder' => 'This invoice will automatically be billed to your Visa card ending in 4242 on the due date.'
); );
return $LANG; return $LANG;

View File

@ -266,6 +266,7 @@
'{!! Form::flatButton('view_invoice', '#0b4d78') !!}$password', '{!! Form::flatButton('view_invoice', '#0b4d78') !!}$password',
"{{ URL::to('/payment/...') }}$password", "{{ URL::to('/payment/...') }}$password",
'{!! Form::flatButton('pay_now', '#36c157') !!}$password', '{!! Form::flatButton('pay_now', '#36c157') !!}$password',
'{{ trans('texts.auto_bill_notification_placeholder') }}',
]; ];
// Add blanks for custom values // Add blanks for custom values