Invoice PAIN & CSV can be uploaded
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Domains\Invoice\Actions\UpdateInvoice;
|
||||
use App\Domains\Invoice\Actions\ChangeStatus\ChangeStatusCommand;
|
||||
use App\Domains\Invoice\Actions\ChangeStatus\ChangeStatusRequest;
|
||||
use App\Enumerations\InvoiceStatus;
|
||||
use App\ValueObjects\Amount;
|
||||
|
||||
class UpdateInvoiceCommand {
|
||||
private UpdateInvoiceRequest $request;
|
||||
@@ -15,11 +16,26 @@ class UpdateInvoiceCommand {
|
||||
|
||||
public function execute() : UpdateInvoiceResponse {
|
||||
$response = new UpdateInvoiceResponse();
|
||||
$changes = $this->request->invoice->changes ?? '';
|
||||
|
||||
if ($this->request->invoice->amount !== $this->request->amount->getAmount()) {
|
||||
$changes .= 'Betrag geändert von ' . Amount::fromString($this->request->invoice->amount)->toString() . ' auf ' . Amount::fromString($this->request->amount->getAmount())->toString() . '.<br />';
|
||||
$this->request->invoice->amount = $this->request->amount->getAmount();
|
||||
}
|
||||
|
||||
if ($this->request->invoice->invoiceType()->slug !== $this->request->invoiceType->slug) {
|
||||
$changes .= 'Abrechnungstyp geändert von ' . $this->request->invoice->invoiceType()->name . ' auf ' . $this->request->invoiceType->name . '.<br />';
|
||||
$this->request->invoice->type = $this->request->invoiceType->slug;
|
||||
}
|
||||
|
||||
if ($this->request->invoice->costUnit()->first()->id !== $this->request->costUnit->id) {
|
||||
$changes .= 'Kostenstelle geändert von ' . $this->request->invoice->costUnit()->first()->name . ' auf ' . $this->request->costUnit->name . '.<br />';
|
||||
$this->request->invoice->cost_unit_id = $this->request->costUnit->id;
|
||||
}
|
||||
|
||||
|
||||
$this->request->invoice->amount = $this->request->amount->getAmount();
|
||||
$this->request->invoice->cost_unit_id = $this->request->costUnit->id;
|
||||
$this->request->invoice->type = $this->request->invoiceType;
|
||||
$this->request->invoice->comment = $this->request->comment;
|
||||
$this->request->invoice->changes = $changes;
|
||||
|
||||
$this->request->invoice->save();
|
||||
|
||||
@@ -29,5 +45,4 @@ class UpdateInvoiceCommand {
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user