mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-04 00:34:36 -04:00
Add option to lock invoices at the end of the month - accrual accounting
This commit is contained in:
parent
0427f6c317
commit
a9c1357689
@ -29,7 +29,7 @@ class CompanySettings extends BaseSettings
|
|||||||
|
|
||||||
public $besr_id = ''; //@implemented
|
public $besr_id = ''; //@implemented
|
||||||
|
|
||||||
public $lock_invoices = 'off'; //off,when_sent,when_paid //@implemented
|
public $lock_invoices = 'off'; //off,when_sent,when_paid,end_of_month //@implemented
|
||||||
|
|
||||||
public $enable_client_portal_tasks = false; //@ben to implement
|
public $enable_client_portal_tasks = false; //@ben to implement
|
||||||
|
|
||||||
|
@ -408,7 +408,7 @@ class InvoiceController extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($invoice->isLocked()) {
|
if ($invoice->isLocked()) {
|
||||||
return response()->json(['message' => ctrans('texts.locked_invoice')], 422);
|
return response()->json(['message' => '', 'errors' => ['number' => ctrans('texts.locked_invoice')]], 422);
|
||||||
}
|
}
|
||||||
|
|
||||||
$old_invoice = $invoice->line_items;
|
$old_invoice = $invoice->line_items;
|
||||||
|
@ -16,6 +16,7 @@ use Illuminate\Contracts\Validation\Rule;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Class LockedInvoiceRule.
|
* Class LockedInvoiceRule.
|
||||||
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
class LockedInvoiceRule implements Rule
|
class LockedInvoiceRule implements Rule
|
||||||
{
|
{
|
||||||
@ -67,6 +68,13 @@ class LockedInvoiceRule implements Rule
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
//if now is greater than the end of month the invoice was dated - do not modify
|
||||||
|
case 'end_of_month':
|
||||||
|
if(\Carbon\Carbon::setTimezone($this->invoice->company->timezone()->name)->parse($this->invoice->date)->endOfMonth()->lte(now()))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
default:
|
default:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -563,6 +563,8 @@ class Invoice extends BaseModel
|
|||||||
return $this->status_id == self::STATUS_SENT;
|
return $this->status_id == self::STATUS_SENT;
|
||||||
case 'when_paid':
|
case 'when_paid':
|
||||||
return $this->status_id == self::STATUS_PAID || $this->status_id == self::STATUS_PARTIAL;
|
return $this->status_id == self::STATUS_PAID || $this->status_id == self::STATUS_PARTIAL;
|
||||||
|
case 'end_of_month':
|
||||||
|
return \Carbon\Carbon::parse($this->date)->setTimezone($this->company->timezone()->name)->endOfMonth()->lte(now());
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -5334,6 +5334,7 @@ $lang = array(
|
|||||||
'btcpay_refund_body' => 'A refund intended for you has been issued. To claim it via BTCPay, please click on this link:',
|
'btcpay_refund_body' => 'A refund intended for you has been issued. To claim it via BTCPay, please click on this link:',
|
||||||
'currency_mauritanian_ouguiya' => 'Mauritanian Ouguiya',
|
'currency_mauritanian_ouguiya' => 'Mauritanian Ouguiya',
|
||||||
'currency_bhutan_ngultrum' => 'Bhutan Ngultrum',
|
'currency_bhutan_ngultrum' => 'Bhutan Ngultrum',
|
||||||
|
'end_of_month' => 'End Of Month'
|
||||||
);
|
);
|
||||||
|
|
||||||
return $lang;
|
return $lang;
|
@ -31,6 +31,29 @@ class DatesTest extends TestCase
|
|||||||
// $this->makeTestData();
|
// $this->makeTestData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testDateNotGreaterThanMonthsEnd()
|
||||||
|
{
|
||||||
|
$this->travelTo(now()->createFromDate(2024, 6, 20));
|
||||||
|
$date = '2024-05-20';
|
||||||
|
|
||||||
|
$this->assertTrue(\Carbon\Carbon::parse($date)->endOfMonth()->lte(now()));
|
||||||
|
|
||||||
|
$this->travelBack();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDatLessThanMonthsEnd()
|
||||||
|
{
|
||||||
|
$this->travelTo(now()->createFromDate(2024, 5, 30));
|
||||||
|
$date = '2024-05-20';
|
||||||
|
|
||||||
|
$this->assertFalse(\Carbon\Carbon::parse($date)->endOfMonth()->lte(now()));
|
||||||
|
|
||||||
|
$this->travelBack();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testLastFinancialYear3()
|
public function testLastFinancialYear3()
|
||||||
{
|
{
|
||||||
$this->travelTo(now()->createFromDate(2020, 6, 30));
|
$this->travelTo(now()->createFromDate(2020, 6, 30));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user