1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

Prevent duplicate billing

This commit is contained in:
Hillel Coren 2017-04-16 17:22:07 +03:00
parent 6a648ad2c9
commit 403b784e17
2 changed files with 9 additions and 0 deletions

View File

@ -8,6 +8,7 @@ use App\Ninja\Mailers\ContactMailer as Mailer;
use App\Ninja\Repositories\AccountRepository;
use App\Services\PaymentService;
use Illuminate\Console\Command;
use Carbon;
/**
* Class ChargeRenewalInvoices.
@ -83,6 +84,11 @@ class ChargeRenewalInvoices extends Command
continue;
}
if (Carbon::parse($company->plan_expires)->isFuture()) {
$this->info('Skipping invoice ' . $invoice->invoice_number . ' [plan not expired]');
continue;
}
$this->info("Charging invoice {$invoice->invoice_number}");
if (! $this->paymentService->autoBillInvoice($invoice)) {
$this->info('Failed to auto-bill, emailing invoice');

View File

@ -356,6 +356,9 @@ class AccountRepository
$account->company_id = $company->id;
$account->save();
$emailSettings = new AccountEmailSettings();
$account->account_email_settings()->save($emailSettings);
$random = strtolower(str_random(RANDOM_KEY_LENGTH));
$user = new User();
$user->registered = true;