mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Do not mark a 0 draft invoice as paid automatically
This commit is contained in:
parent
e22967f10d
commit
7d896e843b
@ -92,7 +92,7 @@ class ClientContact extends Authenticatable implements HasLocalePreference
|
||||
'custom_value4',
|
||||
'email',
|
||||
'is_primary',
|
||||
// 'client_id',
|
||||
'send_email',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -113,25 +113,26 @@ class BaseRepository
|
||||
* @param $action
|
||||
*
|
||||
* @return int
|
||||
* @deprecated - this doesn't appear to be used anywhere?
|
||||
*/
|
||||
public function bulk($ids, $action)
|
||||
{
|
||||
if (! $ids) {
|
||||
return 0;
|
||||
}
|
||||
// public function bulk($ids, $action)
|
||||
// {
|
||||
// if (! $ids) {
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
$ids = $this->transformKeys($ids);
|
||||
// $ids = $this->transformKeys($ids);
|
||||
|
||||
$entities = $this->findByPublicIdsWithTrashed($ids);
|
||||
// $entities = $this->findByPublicIdsWithTrashed($ids);
|
||||
|
||||
foreach ($entities as $entity) {
|
||||
if (auth()->user()->can('edit', $entity)) {
|
||||
$this->$action($entity);
|
||||
}
|
||||
}
|
||||
// foreach ($entities as $entity) {
|
||||
// if (auth()->user()->can('edit', $entity)) {
|
||||
// $this->$action($entity);
|
||||
// }
|
||||
// }
|
||||
|
||||
return count($entities);
|
||||
}
|
||||
// return count($entities);
|
||||
// }
|
||||
|
||||
/* Returns an invoice if defined as a key in the $resource array*/
|
||||
public function getInvitation($invitation, $resource)
|
||||
|
@ -134,9 +134,9 @@ class InvoiceService
|
||||
*
|
||||
* @return InvoiceService Parent class object
|
||||
*/
|
||||
public function updateBalance($balance_adjustment)
|
||||
public function updateBalance($balance_adjustment, bool $is_draft = false)
|
||||
{
|
||||
$this->invoice = (new UpdateBalance($this->invoice, $balance_adjustment))->run();
|
||||
$this->invoice = (new UpdateBalance($this->invoice, $balance_adjustment, $is_draft))->run();
|
||||
|
||||
if ((int)$this->invoice->balance == 0) {
|
||||
$this->invoice->next_send_date = null;
|
||||
|
@ -47,7 +47,7 @@ class MarkSent extends AbstractService
|
||||
->service()
|
||||
->applyNumber()
|
||||
->setDueDate()
|
||||
->updateBalance($this->invoice->amount)
|
||||
->updateBalance($this->invoice->amount, true)
|
||||
->deletePdf()
|
||||
->setReminder()
|
||||
->save();
|
||||
|
@ -20,10 +20,13 @@ class UpdateBalance extends AbstractService
|
||||
|
||||
public $balance_adjustment;
|
||||
|
||||
public function __construct($invoice, $balance_adjustment)
|
||||
private $is_draft;
|
||||
|
||||
public function __construct($invoice, $balance_adjustment, bool $is_draft)
|
||||
{
|
||||
$this->invoice = $invoice;
|
||||
$this->balance_adjustment = $balance_adjustment;
|
||||
$this->is_draft = $is_draft;
|
||||
}
|
||||
|
||||
public function run()
|
||||
@ -34,7 +37,7 @@ class UpdateBalance extends AbstractService
|
||||
|
||||
$this->invoice->balance += floatval($this->balance_adjustment);
|
||||
|
||||
if ($this->invoice->balance == 0) {
|
||||
if ($this->invoice->balance == 0 && !$this->is_draft) {
|
||||
$this->invoice->status_id = Invoice::STATUS_PAID;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user