mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 10:24:31 -04:00
Warn user when editing an ACH auto bill invoice
This commit is contained in:
parent
c701c5563c
commit
d19a3715f9
@ -54,20 +54,12 @@ class SendRecurringInvoices extends Command
|
|||||||
$invoice->account->auto_bill_on_due_date;
|
$invoice->account->auto_bill_on_due_date;
|
||||||
|
|
||||||
$autoBillLater = false;
|
$autoBillLater = false;
|
||||||
if ($invoice->account->auto_bill_on_due_date) {
|
if ($invoice->account->auto_bill_on_due_date || $this->paymentService->getClientRequiresDelayedAutoBill($invoice->client)) {
|
||||||
$autoBillLater = true;
|
$autoBillLater = true;
|
||||||
} elseif ($paymentMethod = $this->paymentService->getClientDefaultPaymentMethod($invoice->client)) {
|
|
||||||
if ($paymentMethod && $paymentMethod->requiresDelayedAutoBill()) {
|
|
||||||
$autoBillLater = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($autoBillLater) {
|
if($autoBillLater) {
|
||||||
if (empty($paymentMethod)) {
|
if($paymentMethod = $this->paymentService->getClientDefaultPaymentMethod($invoice->client)) {
|
||||||
$paymentMethod = $this->paymentService->getClientDefaultPaymentMethod($invoice->client);
|
|
||||||
}
|
|
||||||
|
|
||||||
if($paymentMethod) {
|
|
||||||
$invoice->autoBillPaymentMethod = $paymentMethod;
|
$invoice->autoBillPaymentMethod = $paymentMethod;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -93,15 +85,7 @@ class SendRecurringInvoices extends Command
|
|||||||
$billNow = false;
|
$billNow = false;
|
||||||
|
|
||||||
if ($autoBill && !$invoice->isPaid()) {
|
if ($autoBill && !$invoice->isPaid()) {
|
||||||
$billNow = $invoice->account->auto_bill_on_due_date;
|
$billNow = $invoice->account->auto_bill_on_due_date || $this->paymentService->getClientRequiresDelayedAutoBill($invoice->client);
|
||||||
|
|
||||||
if (!$billNow) {
|
|
||||||
$paymentMethod = $this->paymentService->getClientDefaultPaymentMethod($invoice->client);
|
|
||||||
|
|
||||||
if ($paymentMethod && $paymentMethod->requiresDelayedAutoBill()) {
|
|
||||||
$billNow = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->info('Processing Invoice '.$invoice->id.' - Should bill '.($billNow ? 'YES' : 'NO'));
|
$this->info('Processing Invoice '.$invoice->id.' - Should bill '.($billNow ? 'YES' : 'NO'));
|
||||||
|
@ -26,6 +26,7 @@ use App\Ninja\Repositories\InvoiceRepository;
|
|||||||
use App\Ninja\Repositories\ClientRepository;
|
use App\Ninja\Repositories\ClientRepository;
|
||||||
use App\Ninja\Repositories\DocumentRepository;
|
use App\Ninja\Repositories\DocumentRepository;
|
||||||
use App\Services\InvoiceService;
|
use App\Services\InvoiceService;
|
||||||
|
use App\Services\PaymentService;
|
||||||
use App\Services\RecurringInvoiceService;
|
use App\Services\RecurringInvoiceService;
|
||||||
|
|
||||||
use App\Http\Requests\InvoiceRequest;
|
use App\Http\Requests\InvoiceRequest;
|
||||||
@ -39,10 +40,11 @@ class InvoiceController extends BaseController
|
|||||||
protected $clientRepo;
|
protected $clientRepo;
|
||||||
protected $documentRepo;
|
protected $documentRepo;
|
||||||
protected $invoiceService;
|
protected $invoiceService;
|
||||||
|
protected $paymentService;
|
||||||
protected $recurringInvoiceService;
|
protected $recurringInvoiceService;
|
||||||
protected $entityType = ENTITY_INVOICE;
|
protected $entityType = ENTITY_INVOICE;
|
||||||
|
|
||||||
public function __construct(Mailer $mailer, InvoiceRepository $invoiceRepo, ClientRepository $clientRepo, InvoiceService $invoiceService, DocumentRepository $documentRepo, RecurringInvoiceService $recurringInvoiceService)
|
public function __construct(Mailer $mailer, InvoiceRepository $invoiceRepo, ClientRepository $clientRepo, InvoiceService $invoiceService, DocumentRepository $documentRepo, RecurringInvoiceService $recurringInvoiceService, PaymentService $paymentService)
|
||||||
{
|
{
|
||||||
// parent::__construct();
|
// parent::__construct();
|
||||||
|
|
||||||
@ -51,6 +53,7 @@ class InvoiceController extends BaseController
|
|||||||
$this->clientRepo = $clientRepo;
|
$this->clientRepo = $clientRepo;
|
||||||
$this->invoiceService = $invoiceService;
|
$this->invoiceService = $invoiceService;
|
||||||
$this->recurringInvoiceService = $recurringInvoiceService;
|
$this->recurringInvoiceService = $recurringInvoiceService;
|
||||||
|
$this->paymentService = $paymentService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
@ -196,6 +199,10 @@ class InvoiceController extends BaseController
|
|||||||
'lastSent' => $lastSent);
|
'lastSent' => $lastSent);
|
||||||
$data = array_merge($data, self::getViewModel($invoice));
|
$data = array_merge($data, self::getViewModel($invoice));
|
||||||
|
|
||||||
|
if ($invoice->isSent() && $invoice->getAutoBillEnabled() && !$invoice->isPaid()) {
|
||||||
|
$data['autoBillChangeWarning'] = $this->paymentService->getClientRequiresDelayedAutoBill($invoice->client);
|
||||||
|
}
|
||||||
|
|
||||||
if ($clone) {
|
if ($clone) {
|
||||||
$data['formIsChanged'] = true;
|
$data['formIsChanged'] = true;
|
||||||
}
|
}
|
||||||
|
@ -903,6 +903,12 @@ class PaymentService extends BaseService
|
|||||||
return $accountGatewayToken->default_payment_method;
|
return $accountGatewayToken->default_payment_method;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getClientRequiresDelayedAutoBill($client) {
|
||||||
|
$defaultPaymentMethod = $this->getClientDefaultPaymentMethod($client);
|
||||||
|
|
||||||
|
return $defaultPaymentMethod?$defaultPaymentMethod->requiresDelayedAutoBill():null;
|
||||||
|
}
|
||||||
|
|
||||||
public function getDatatable($clientPublicId, $search)
|
public function getDatatable($clientPublicId, $search)
|
||||||
{
|
{
|
||||||
$datatable = new PaymentDatatable( ! $clientPublicId, $clientPublicId);
|
$datatable = new PaymentDatatable( ! $clientPublicId, $clientPublicId);
|
||||||
|
@ -1325,6 +1325,7 @@ $LANG = array(
|
|||||||
|
|
||||||
'auto_bill_on_due_date' => 'Auto bill on due date instead of send date',
|
'auto_bill_on_due_date' => 'Auto bill on due date instead of send date',
|
||||||
'auto_bill_ach_date_help' => 'ACH auto bill will always happen on the due date',
|
'auto_bill_ach_date_help' => 'ACH auto bill will always happen on the due date',
|
||||||
|
'warn_change_auto_bill' => 'Due to NACHA rules, changes to this invoice may prevent ACH auto bill.',
|
||||||
);
|
);
|
||||||
|
|
||||||
return $LANG;
|
return $LANG;
|
||||||
|
@ -1200,6 +1200,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onSaveClick() {
|
function onSaveClick() {
|
||||||
|
@if(!empty($autoBillChangeWarning))
|
||||||
|
if(!confirm("{!! trans('texts.warn_change_auto_bill') !!}"))return;
|
||||||
|
@endif
|
||||||
|
|
||||||
if (model.invoice().is_recurring()) {
|
if (model.invoice().is_recurring()) {
|
||||||
// warn invoice will be emailed when saving new recurring invoice
|
// warn invoice will be emailed when saving new recurring invoice
|
||||||
if ({{ $invoice->exists() ? 'false' : 'true' }}) {
|
if ({{ $invoice->exists() ? 'false' : 'true' }}) {
|
||||||
@ -1324,6 +1328,10 @@
|
|||||||
|
|
||||||
@if ($invoice->id)
|
@if ($invoice->id)
|
||||||
function onPaymentClick() {
|
function onPaymentClick() {
|
||||||
|
@if(!empty($autoBillChangeWarning))
|
||||||
|
if(!confirm("{!! trans('texts.warn_change_auto_bill') !!}"))return;
|
||||||
|
@endif
|
||||||
|
|
||||||
window.location = '{{ URL::to('payments/create/' . $invoice->client->public_id . '/' . $invoice->public_id ) }}';
|
window.location = '{{ URL::to('payments/create/' . $invoice->client->public_id . '/' . $invoice->public_id ) }}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user