mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-07 18:54:30 -04:00
- Added account selection by passing a parameter to the command
- Added an success message
This commit is contained in:
parent
790766c028
commit
5146fab45d
@ -15,6 +15,7 @@ class ResetInvoiceSchemaCounter extends Command
|
|||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $signature = 'ninja:reset-invoice-schema-counter
|
protected $signature = 'ninja:reset-invoice-schema-counter
|
||||||
|
{account : The ID of the account}
|
||||||
{--force : Force setting the counter back to "1", regardless if the year changed}';
|
{--force : Force setting the counter back to "1", regardless if the year changed}';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -24,11 +25,6 @@ class ResetInvoiceSchemaCounter extends Command
|
|||||||
*/
|
*/
|
||||||
protected $description = 'Reset the invoice schema counter at the turn of the year.';
|
protected $description = 'Reset the invoice schema counter at the turn of the year.';
|
||||||
|
|
||||||
/**
|
|
||||||
* @var Account
|
|
||||||
*/
|
|
||||||
protected $account;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Invoice
|
* @var Invoice
|
||||||
*/
|
*/
|
||||||
@ -37,13 +33,11 @@ class ResetInvoiceSchemaCounter extends Command
|
|||||||
/**
|
/**
|
||||||
* Create a new command instance.
|
* Create a new command instance.
|
||||||
*
|
*
|
||||||
* @param Account $account
|
|
||||||
* @param Invoice $invoice
|
* @param Invoice $invoice
|
||||||
*/
|
*/
|
||||||
public function __construct(Account $account, Invoice $invoice)
|
public function __construct(Invoice $invoice)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->account = $account;
|
|
||||||
$this->invoice = $invoice;
|
$this->invoice = $invoice;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,8 +52,10 @@ class ResetInvoiceSchemaCounter extends Command
|
|||||||
$invoiceYear = Carbon::parse($latestInvoice->created_at)->year;
|
$invoiceYear = Carbon::parse($latestInvoice->created_at)->year;
|
||||||
|
|
||||||
if(Carbon::now()->year > $invoiceYear || $this->option('force')) {
|
if(Carbon::now()->year > $invoiceYear || $this->option('force')) {
|
||||||
$this->account->invoice_number_counter = 1;
|
$account = Account::find($this->argument('account'))->first();
|
||||||
$this->account->update();
|
$account->invoice_number_counter = 1;
|
||||||
|
$account->update();
|
||||||
|
$this->info('The counter has been resetted successfully.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user