Code improvements
This commit is contained in:
@@ -22,7 +22,7 @@ class ChangeStatusCommand {
|
||||
switch ($this->request->status) {
|
||||
case InvoiceStatus::INVOICE_STATUS_APPROVED:
|
||||
$this->request->invoice->status = InvoiceStatus::INVOICE_STATUS_APPROVED;
|
||||
$this->request->invoice->approved_by = auth()->user()->id;
|
||||
$this->request->invoice->approved_by = currentUserOrFail()->id;
|
||||
$this->request->invoice->approved_at = now();
|
||||
|
||||
if ($this->request->invoice->contact_email !== null) {
|
||||
@@ -35,7 +35,7 @@ class ChangeStatusCommand {
|
||||
|
||||
case InvoiceStatus::INVOICE_STATUS_DENIED:
|
||||
$this->request->invoice->status = InvoiceStatus::INVOICE_STATUS_DENIED;
|
||||
$this->request->invoice->denied_by = auth()->user()->id;
|
||||
$this->request->invoice->denied_by = currentUserOrFail()->id;
|
||||
$this->request->invoice->denied_at = now();
|
||||
$this->request->invoice->denied_reason = $this->request->comment;
|
||||
if ($this->request->invoice->contact_email !== null) {
|
||||
|
||||
@@ -24,7 +24,7 @@ class CreateInvoiceCommand {
|
||||
}
|
||||
|
||||
$invoice = Invoice::create([
|
||||
'tenant' => app('tenant')->slug,
|
||||
'tenant' => currentTenant()->slug,
|
||||
'cost_unit_id' => $this->request->costUnit->id,
|
||||
'invoice_number' => $this->generateInvoiceNumber(),
|
||||
'status' => InvoiceStatus::INVOICE_STATUS_NEW,
|
||||
@@ -61,7 +61,7 @@ class CreateInvoiceCommand {
|
||||
}
|
||||
|
||||
if ($this->request->costUnit->mail_on_new) {
|
||||
$recipients = [app('tenant')->email_finance];
|
||||
$recipients = [currentTenant()->email_finance];
|
||||
|
||||
foreach ($this->request->costUnit->treasurers()->get() as $treasurer) {
|
||||
if (!in_array($treasurer->email, $recipients)) {
|
||||
@@ -83,7 +83,7 @@ class CreateInvoiceCommand {
|
||||
|
||||
private function generateInvoiceNumber() : string {
|
||||
$lastInvoiceNumber = Invoice::query()
|
||||
->where('tenant', app('tenant')->slug)
|
||||
->where('tenant', currentTenant()->slug)
|
||||
->whereYear('created_at', date('Y'))
|
||||
->count();
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ class UploadInvoiceCommand {
|
||||
$uploadDir = sprintf(
|
||||
'%1$s%2$s/%3$s',
|
||||
WebDavProvider::INVOICE_PREFIX,
|
||||
app('tenant')->url,
|
||||
currentTenant()->url,
|
||||
$this->request->invoice->costUnit()->first()->name
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user