diff --git a/app/Casts/AmountCast.php b/app/Casts/AmountCast.php new file mode 100644 index 0000000..cda19ca --- /dev/null +++ b/app/Casts/AmountCast.php @@ -0,0 +1,34 @@ +getAmount(); + } + + return (float) $value; + } +} diff --git a/app/Domains/CostUnit/Actions/CreateCostUnit/CreateCostUnitCommand.php b/app/Domains/CostUnit/Actions/CreateCostUnit/CreateCostUnitCommand.php index 319193e..35bef58 100644 --- a/app/Domains/CostUnit/Actions/CreateCostUnit/CreateCostUnitCommand.php +++ b/app/Domains/CostUnit/Actions/CreateCostUnit/CreateCostUnitCommand.php @@ -22,8 +22,13 @@ class CreateCostUnitCommand { 'mail_on_new' => $this->request->mailOnNew, 'allow_new' => true, 'archived' => false, - ]); + + if (null !== $costUnit) { + $response->costUnit = $costUnit; + $response->success = true; + } + return $response; } } diff --git a/app/Domains/CostUnit/Actions/CreateCostUnit/CreateCostUnitResponse.php b/app/Domains/CostUnit/Actions/CreateCostUnit/CreateCostUnitResponse.php index c58891d..3a44e14 100644 --- a/app/Domains/CostUnit/Actions/CreateCostUnit/CreateCostUnitResponse.php +++ b/app/Domains/CostUnit/Actions/CreateCostUnit/CreateCostUnitResponse.php @@ -2,6 +2,14 @@ namespace App\Domains\CostUnit\Actions\CreateCostUnit; -class CreateCostUnitResponse { +use App\Models\CostUnit; +class CreateCostUnitResponse { + public bool $success; + public ?CostUnit $costUnit; + + public function __construct() { + $this->success = false; + $this->costUnit = null; + } } diff --git a/app/Domains/CostUnit/Controllers/OpenController.php b/app/Domains/CostUnit/Controllers/OpenController.php index a72567f..8f3ada2 100644 --- a/app/Domains/CostUnit/Controllers/OpenController.php +++ b/app/Domains/CostUnit/Controllers/OpenController.php @@ -8,8 +8,11 @@ use Illuminate\Http\JsonResponse; class OpenController extends CommonController { public function __invoke(int $costUnitId) { + $costUnit = $this->costUnits->getById($costUnitId); + + $inertiaProvider = new InertiaProvider('CostUnit/Open', [ - 'costUnitId' => $costUnitId + 'costUnit' => $costUnit ]); return $inertiaProvider->render(); } diff --git a/app/Domains/CostUnit/Views/Open.vue b/app/Domains/CostUnit/Views/Open.vue index 77d4f04..4a28351 100644 --- a/app/Domains/CostUnit/Views/Open.vue +++ b/app/Domains/CostUnit/Views/Open.vue @@ -8,11 +8,11 @@ import ListInvoices from "./Partials/ListInvoices.vue"; const props = defineProps({ - costUnitId: Number + costUnit: Object }) const urlParams = new URLSearchParams(window.location.search) - const initialCostUnitId = props.cost_unit_id + const initialCostUnitId = props.costUnit.id const initialInvoiceId = props.invoice_id @@ -22,7 +22,7 @@ { title: 'Neue Abrechnungen', component: ListInvoices, - endpoint: "/api/v1/cost-unit/" + props.costUnitId + "/invoice-list/new", + endpoint: "/api/v1/cost-unit/" + props.costUnit.id + "/invoice-list/new", deep_jump_id: initialCostUnitId, deep_jump_id_sub: initialInvoiceId, @@ -30,21 +30,21 @@ { title: 'Nichtexportierte Abrechnungen', component: ListInvoices, - endpoint: "/api/v1/cost-unit/" + props.costUnitId + "/invoice-list/approved", + endpoint: "/api/v1/cost-unit/" + props.costUnit.id + "/invoice-list/approved", deep_jump_id: initialCostUnitId, deep_jump_id_sub: initialInvoiceId, }, { title: 'Exportierte Abrechnungen', component: ListInvoices, - endpoint: "/api/v1/cost-unit/" + props.costUnitId + "/invoice-list/exported", + endpoint: "/api/v1/cost-unit/" + props.costUnit.id + "/invoice-list/exported", deep_jump_id: initialCostUnitId, deep_jump_id_sub: initialInvoiceId, }, { title: 'Abgelehnte Abrechnungen', component: ListInvoices, - endpoint: "/api/v1/cost-unit/" + props.costUnitId + "/invoice-list/denied", + endpoint: "/api/v1/cost-unit/" + props.costUnit.id + "/invoice-list/denied", deep_jump_id: initialCostUnitId, deep_jump_id_sub: initialInvoiceId, }, @@ -58,7 +58,7 @@