17 Commits

Author SHA1 Message Date
th.guenther dbcebbb2c4 Merge pull request 'New SEPA logic' (#7) from new-sepa-procedure into development-4.4.2
Reviewed-on: #7
2026-06-21 01:29:57 +02:00
th.guenther 63c7b8dfb1 New SEPA logic 2026-06-21 01:28:28 +02:00
th.guenther e9aa66a860 Direct liunk to current event in mobile mode 2026-06-21 00:35:25 +02:00
th.guenther 51c4055c47 Prevent linking invoice to user account if foreign payment 2026-06-20 23:20:42 +02:00
th.guenther 2348663fd8 Display Events in Widgets until their end date is reached 2026-06-20 18:06:29 +02:00
th.guenther a83cec94ab Fixed Login for Superuser 2026-06-20 18:02:00 +02:00
th.guenther 710e27c344 Small Bugfixes 2026-05-26 20:29:01 +02:00
th.guenther 83bbd6f7d3 Merge pull request 'Displaying estimates' (#6) from dev-4.4.0 into main
Implemented Event Budgets
2026-05-26 18:13:35 +02:00
th.guenther 28ffbdb696 Implemented Event Budget 2026-05-26 18:12:42 +02:00
th.guenther 575fb27018 Displaying estimates 2026-05-26 11:07:59 +02:00
th.guenther fe3429cd4e Displaying estimates 2026-05-26 11:07:33 +02:00
th.guenther 551b592b3b Fix 2026-05-24 20:06:01 +02:00
th.guenther 6ed0a5b93a DB update 2026-05-23 21:42:21 +02:00
th.guenther 97fd7cd0da Merge pull request 'Small design improvements' (#5) from dev-4.3.1 into main
Small design Improvements
2026-05-23 21:40:54 +02:00
th.guenther f5d7b21671 Small design improvements 2026-05-23 21:40:06 +02:00
th.guenther 444711b049 Fixes 2026-05-23 21:06:40 +02:00
th.guenther 0a7abb1389 Merge pull request 'New Release' (#4) from dev-4.3.0 into main
Responsive Design
Fixes Crons for Tenants
2026-05-23 19:28:37 +02:00
51 changed files with 1410 additions and 125 deletions
@@ -0,0 +1,50 @@
<?php
namespace App\Domains\Budget\Actions\CreateEstimate;
use App\Models\CostUnitEstimate;
class CreateEstimateAction {
private CreateEstimateResponse $response;
public function __construct(private CreateEstimateRequest $request) {
}
public function execute(): CreateEstimateResponse {
$this->response = new CreateEstimateResponse();
$amount = [];
switch ($this->request->amountType) {
case 'flat':
$amount['flat_amount'] = $this->request->amount;
break;
case 'per_person':
$amount['amount_by_user'] = $this->request->amount;
break;
}
if ($this->request->estimateId === 0) {
$estimate = CostUnitEstimate::create(array_merge([
'tenant' => app('tenant')->slug,
'cost_unit_id' => $this->request->costUnit->id,
'type' => $this->request->estimateType,
'description' => $this->request->description,
], $amount));
} else {
$estimate = CostUnitEstimate::find($this->request->estimateId);
$estimate->update(array_merge([
'tenant' => app('tenant')->slug,
'cost_unit_id' => $this->request->costUnit->id,
'type' => $this->request->estimateType,
'description' => $this->request->description,
], $amount));
}
if ($estimate !== null) {
$this->response->estimateId = $estimate->id;
$this->response->success = true;
}
return $this->response;
}
}
@@ -0,0 +1,19 @@
<?php
namespace App\Domains\Budget\Actions\CreateEstimate;
use App\Enumerations\InvoiceType;
use App\Models\CostUnit;
use App\ValueObjects\Amount;
class CreateEstimateRequest {
function __construct(
public string $amountType,
public string $description,
public Amount $amount,
public string $estimateType,
public CostUnit $costUnit,
public int $estimateId,
) {
}
}
@@ -0,0 +1,13 @@
<?php
namespace App\Domains\Budget\Actions\CreateEstimate;
class CreateEstimateResponse {
public bool $success;
public ?int $estimateId;
public function __construct() {
$this->success = false;
$this->estimateId = null;
}
}
@@ -0,0 +1,16 @@
<?php
namespace App\Domains\Budget\Actions\DeleteEstimate;
class DeleteEstimateAction {
public function __construct(private DeleteEstimateRequest $request) {
}
public function execute() : DeleteEstimateResponse {
$response = new DeleteEstimateResponse();
$this->request->estimate->delete();
$response->success = true;
return $response;
}
}
@@ -0,0 +1,12 @@
<?php
namespace App\Domains\Budget\Actions\DeleteEstimate;
use App\Models\CostUnitEstimate;
class DeleteEstimateRequest {
public function __construct(public CostUnitEstimate $estimate)
{
}
}
@@ -0,0 +1,12 @@
<?php
namespace App\Domains\Budget\Actions\DeleteEstimate;
class DeleteEstimateResponse {
public bool $success;
public function __construct()
{
$this->success = false;
}
}
@@ -0,0 +1,43 @@
<?php
namespace App\Domains\Budget\Controllers;
use App\Domains\Budget\Actions\CreateEstimate\CreateEstimateAction;
use App\Domains\Budget\Actions\CreateEstimate\CreateEstimateRequest;
use App\Domains\Budget\Actions\DeleteEstimate\DeleteEstimateAction;
use App\Domains\Budget\Actions\DeleteEstimate\DeleteEstimateRequest;
use App\Domains\CostUnit\Actions\CreateCostUnit\CreateCostUnitRequest;
use App\Scopes\CommonController;
use App\ValueObjects\Amount;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class DeleteController extends CommonController
{
public function __invoke(int $costUnitId, int $estimateId, Request $request) : JsonResponse {
$estimate = $this->estimates->getById($estimateId);
if ($estimate === null) {
return response()->json([
'status' => 'error',
'message' => 'Estimate not found'
], 404);
}
$deleteEstimateResponse =
new DeleteEstimateAction(request: new DeleteEstimateRequest($estimate)
)->execute();
if ($deleteEstimateResponse->success) {
return response()->json([
'status' => 'success',
'message' => 'Der Eintrag wurde erfolgreich gelöscht.'
]);
} else {
return response()->json([
'status' => 'error',
'message' => 'Beim Löschen des Eintrags ist ein Fehler aufgetreten.'
]);
}
}
}
@@ -0,0 +1,26 @@
<?php
namespace App\Domains\Budget\Controllers;
use App\Enumerations\InvoiceType;
use App\Scopes\CommonController;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class ListController extends CommonController
{
public function __invoke(int $costUnitId, string $estimateType, Request $request) : JsonResponse {
$costUnit = $this->costUnits->getById($costUnitId);
$estimates = $this->estimates->getEstimates($costUnit, $estimateType);
return response()->json([
'status' => 'success',
'costUnitId' => $costUnitId,
'title' => InvoiceType::where('slug', $estimateType)->first()->name,
'estimateType' => $estimateType,
'estimates' => $estimates,
'totalAmountString' => $this->estimates->getTotalAmount($costUnit, $estimateType)->toString(),
]);
}
}
@@ -0,0 +1,19 @@
<?php
namespace App\Domains\Budget\Controllers;
use App\Providers\InertiaProvider;
use App\Scopes\CommonController;
use Illuminate\Http\Request;
use Inertia\Response;
class MainController extends CommonController
{
public function __invoke(int $costUnitId, Request $request) : Response
{
$inertiaProvider = new InertiaProvider('Budget/List', [
'cost_unit_id' => $costUnitId
]);
return $inertiaProvider->render();
}
}
@@ -0,0 +1,47 @@
<?php
namespace App\Domains\Budget\Controllers;
use App\Domains\Budget\Actions\CreateEstimate\CreateEstimateAction;
use App\Domains\Budget\Actions\CreateEstimate\CreateEstimateRequest;
use App\Domains\CostUnit\Actions\CreateCostUnit\CreateCostUnitRequest;
use App\Scopes\CommonController;
use App\ValueObjects\Amount;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class SaveController extends CommonController
{
public function __invoke(int $costUnitId, Request $request) : JsonResponse {
$costUnit = $this->costUnits->getById($costUnitId);
if ($costUnit === null) {
return response()->json([
'status' => 'error',
'message' => 'Cost unit not found'
], 404);
}
$createCostUniResponse =
new CreateEstimateAction(request: new CreateEstimateRequest(
description: $request->input('description'),
amount: Amount::fromString($request->input('amount')),
amountType: $request->input('amount_type'),
estimateType: $request->input('estimateType'),
costUnit: $costUnit,
estimateId: $request->input('estimateId'),
))->execute();
if ($createCostUniResponse->success) {
return response()->json([
'status' => 'success',
'message' => 'Der Eintrag wurde erfolgreich angelegt.'
]);
} else {
return response()->json([
'status' => 'error',
'message' => 'Beim Anlegen des Eintrags ist ein Fehler aufgetreten.'
]);
}
}
}
+21
View File
@@ -0,0 +1,21 @@
<?php
use App\Domains\Budget\Controllers\DeleteController;
use App\Domains\Budget\Controllers\SaveController;
use App\Domains\Budget\Controllers\ListController;
use App\Middleware\IdentifyTenant;
use Illuminate\Support\Facades\Route;
Route::prefix('api/v1')->group(function () {
Route::middleware(IdentifyTenant::class)->group(function () {
Route::prefix('budget')->group(function () {
Route::middleware(['auth'])->group(function () {
Route::prefix('/{costUnitId}')->group(function () {
Route::get('/list/{estimateType}', ListController::class);
Route::get('{estimateId}/delete', DeleteController::class);
Route::post('/save-estimate', SaveController::class);
});
});
});
});
});
+20
View File
@@ -0,0 +1,20 @@
<?php
use App\Domains\Budget\Controllers\MainController;
use App\Middleware\IdentifyTenant;
use Illuminate\Support\Facades\Route;
Route::middleware(IdentifyTenant::class)->group(function () {
Route::prefix('budget')->group(function () {
Route::middleware(['auth'])->group(function () {
Route::prefix('/{costUnitId}')->group(function() {
Route::get('/', MainController::class);
});
});
});
});
@@ -0,0 +1,100 @@
<script setup>
import Modal from "../../../Views/Components/Modal.vue";
import {reactive, ref} from "vue";
import AmountInput from "../../../Views/Components/AmountInput.vue";
import {toast} from "vue3-toastify";
import {useAjax} from "../../../../resources/js/components/ajaxHandler.js";
const { request } = useAjax()
const props = defineProps({
showAddEstimate: Boolean,
type: String,
title: String,
costUnitId: Number,
amount: Number,
amount_type: String,
estimateId: Number,
description: String,
})
console.log(props)
const form = reactive({
amount_type: props.amount_type,
amount: props.amount,
description: props.description,
})
async function save() {
const data = await request('/api/v1/budget/' + props.costUnitId + '/save-estimate', {
method: "POST",
body: {
estimateId: props.estimateId,
amount_type: form.amount_type,
amount: form.amount,
description: form.description,
estimateType: props.type,
}
});
if (data.status === 'success') {
toast.success(data.message);
} else {
toast.error(data.message);
}
emit('closeAddEstimate')
}
const emit = defineEmits(['closeAddEstimate'])
</script>
<template>
<Modal
:show="showAddEstimate"
@close="emit('closeAddEstimate')"
title="Ausgabenschätzung hinzufügen"
width="600px"
>
<table>
<tr>
<th>Kostenstelle</th>
<td>{{title}}</td>
</tr>
<tr>
<th>Verwendungszweck</th>
<td><input type="text" v-model="form.description" style="width: 250px;" /></td>
</tr>
<tr>
<th>Betrag</th>
<td><AmountInput v-model="form.amount" style="width: 100px;" /> Euro</td>
</tr>
<tr>
<th>Kostentyp</th>
<td style="vertical-align: top;">
<input type="radio" v-model="form.amount_type" value="flat"
id="amount_type_flat" />
<label for="amount_type_flat">Pauschal</label><br />
<input type="radio" v-model="form.amount_type" value="per_person" id="amount_type_per_person" />
<label for="amount_type_per_person">Pro Person</label><br />
</td>
</tr>
<tr>
<td colspan="2">
<input type="button" value="Speichern" class="button" @click="save" />
</td>
</tr>
</table>
</Modal>
</template>
<style scoped>
</style>
+93
View File
@@ -0,0 +1,93 @@
<script setup>
import {reactive, inject, onMounted} from 'vue';
import AppLayout from '../../../../resources/js/layouts/AppLayout.vue';
import { useAjax } from "../../../../resources/js/components/ajaxHandler.js";
import ShadowedBox from "../../../Views/Components/ShadowedBox.vue";
import TabbedPage from "../../../Views/Components/TabbedPage.vue";
import {toast} from "vue3-toastify";
import ListBudgets from "./ListBudgetTypes.vue";
const props = defineProps({
message: String,
data: {
type: [Array, Object],
default: () => []
},
cost_unit_id: {
type: Number,
default: 0
},
})
// Prüfen, ob ein ?id= Parameter in der URL übergeben wurde
const urlParams = new URLSearchParams(window.location.search)
const initialCostUnitId = props.cost_unit_id
const tabs = [
{
title: 'Verpflegung',
component: ListBudgets,
endpoint: "/api/v1/budget/" + props.cost_unit_id + "/list/catering",
deep_jump_id: initialCostUnitId,
},
{
title: 'Unterkunft',
component: ListBudgets,
endpoint: "/api/v1/budget/" + props.cost_unit_id + "/list/accommodation",
deep_jump_id: initialCostUnitId,
},
{
title: 'Programm',
component: ListBudgets,
endpoint: "/api/v1/budget/" + props.cost_unit_id + "/list/program",
deep_jump_id: initialCostUnitId,
},
{
title: 'Logistik',
component: ListBudgets,
endpoint: "/api/v1/budget/" + props.cost_unit_id + "/list/logistic",
deep_jump_id: initialCostUnitId,
},
{
title: 'Technik',
component: ListBudgets,
endpoint: "/api/v1/budget/" + props.cost_unit_id + "/list/technical",
deep_jump_id: initialCostUnitId,
},
{
title: 'Reisekosten',
component: ListBudgets,
endpoint: "/api/v1/budget/" + props.cost_unit_id + "/list/travelling",
deep_jump_id: initialCostUnitId,
},
{
title: 'Verwaltung',
component: ListBudgets,
endpoint: "/api/v1/budget/" + props.cost_unit_id + "/list/management",
deep_jump_id: initialCostUnitId,
},
{
title: 'Sonstiges',
component: ListBudgets,
endpoint: "/api/v1/budget/" + props.cost_unit_id + "/list/other",
deep_jump_id: initialCostUnitId,
},
]
onMounted(() => {
if (undefined !== props.message) {
toast.success(props.message)
}
})
</script>
<template>
<AppLayout title="Veranstaltungsbudget">
<shadowed-box style="width: 95%; margin: 20px auto; padding: 20px; overflow-x: hidden;">
<tabbed-page :tabs="tabs" :initial-tab-id="initialCostUnitId" />
</shadowed-box>
</AppLayout>
</template>
@@ -0,0 +1,121 @@
<script setup>
import {createApp, ref} from 'vue'
import LoadingModal from "../../../Views/Components/LoadingModal.vue";
import { useAjax } from "../../../../resources/js/components/ajaxHandler.js";
import {toast} from "vue3-toastify";
import AddOrUpdateEstimate from "./AddOrUpdateEstimate.vue";
const props = defineProps({
data: {
type: [Array, Object],
default: () => []
},
})
const localData = ref(props.data)
const showAddEstimate = ref(false)
const estimateId = ref(null)
const description = ref(null)
const amount = ref(null)
const amountType = ref(null)
const { data, loading, error, request, download } = useAjax()
async function reload() {
const url = "/api/v1/budget/" + props.data.costUnitId + "/list/" + props.data.estimateType
try {
const response = await fetch(url, { method: 'GET' })
if (!response.ok) throw new Error('Fehler beim Laden')
const result = await response.json()
localData.value = result
} catch (err) {
console.error('Error fetching estimates:', err)
}
}
async function openAddEstimate() {
estimateId.value = 0
amount.value = 0.00
amountType.value = 'flat'
description.value = ''
showAddEstimate.value = true
}
async function openEditEstimate(localEstimateId, localDescription, localAmount, localAmountType, localEstimateType) {
estimateId.value = localEstimateId
description.value = localDescription
amount.value = localAmount
amountType.value = localAmountType
console.log(localEstimateId, localDescription, localAmount, localAmountType, localEstimateType)
console.log(estimateId.value, description.value, amount.value, amountType.value, localEstimateType)
showAddEstimate.value = true
}
async function deleteEstimate(currentEstimateId) {
const data = await request('/api/v1/budget/' + props.data.costUnitId + '/' + currentEstimateId + '/delete', {
method: "GET",
});
if (data.status === 'success') {
toast.success(data.message);
reload()
} else {
toast.error(data.message);
}
}
</script>
<template>
<div v-if="localData.estimates && localData.estimates.length > 0">
<h2>{{ props.data.title }}</h2>
<h3>Gesamtkosten: {{ localData.totalAmountString }}</h3>
<span v-for="estimate in localData.estimates">
<table style="width: 100%;">
<tr><th style="width: 200px;">
{{ estimate.title }}
</th>
<td>{{ estimate.singleAmountString }}</td>
</tr>
<tr>
<td></td>
<td style="padding-bottom: 30px">
<label class="link" style="font-size: 10pt; margin-right: 20px;" @click="openEditEstimate(estimate.id, estimate.title, estimate.amountValue, estimate.amountType, props.data.estimateType)">Bearbeiten</label>
<label class="link" style="font-size: 10pt; margin-right: 20px; color: #ff0000;" @click="deleteEstimate(estimate.id)">Löschen</label>
</td>
</tr>
</table>
</span>
</div>
<div v-else>
<strong style="width: 100%; text-align: center; display: block; margin-top: 20px;">
Noch keine geschätzten Ausgaben vorhanden
</strong>
</div>
<label class="link" @click="openAddEstimate()">
Hinzufügen
</label>
<LoadingModal :show="showLoading" />
<AddOrUpdateEstimate
:amount="amount"
:amount_type="amountType"
:description="description"
:estimateId="estimateId"
:costUnitId="props.data.costUnitId"
:title="props.data.title"
:type="props.data.estimateType"
:showAddEstimate="showAddEstimate"
v-if="showAddEstimate"
@closeAddEstimate="showAddEstimate = false; reload()" />
</template>
<style scoped>
.costunit-list {
width: 96% !important;
}
</style>
@@ -4,14 +4,13 @@ namespace App\Domains\CostUnit\Controllers;
use App\Domains\Invoice\Actions\ChangeStatus\ChangeStatusCommand;
use App\Domains\Invoice\Actions\ChangeStatus\ChangeStatusRequest;
use App\Domains\Invoice\Actions\CreateInvoice\CreateInvoiceRequest;
use App\Domains\Invoice\Actions\CreateInvoiceReceipt\CreateInvoiceReceiptCommand;
use App\Domains\Invoice\Actions\CreateInvoiceReceipt\CreateInvoiceReceiptRequest;
use App\Enumerations\InvoiceStatus;
use App\Models\SepaPaymentElement;
use App\Models\Tenant;
use App\Providers\FileWriteProvider;
use App\Providers\InvoiceCsvFileProvider;
use App\Providers\PainFileProvider;
use App\Providers\WebDavProvider;
use App\Providers\ZipArchiveFileProvider;
use App\Scopes\CommonController;
@@ -25,24 +24,19 @@ class ExportController extends CommonController {
$webdavProvider = new WebDavProvider(WebDavProvider::INVOICE_PREFIX . $this->tenant->url . '/' . $costUnit->name);
$painFileData = $this->painData($invoicesForExport);
$this->createSepaPaymentElements($invoicesForExport, $costUnit);
$csvData = $this->csvData($invoicesForExport);
$filePrefix = Tenant::getTempDirectory();
$painFileWriteProvider = new FileWriteProvider($filePrefix . 'abrechnungen-' . date('Y-m-d_H-i') . '-sepa.xml', $painFileData);
$painFileWriteProvider->writeToFile();
$csvFileWriteProvider = new FileWriteProvider($filePrefix . 'abrechnungen-' . date('Y-m-d_H-i') . '.csv', $csvData);
$csvFileWriteProvider->writeToFile();
if ($this->tenant->upload_exports) {
$webdavProvider->uploadFile($painFileWriteProvider->fileName);
$webdavProvider->uploadFile($csvFileWriteProvider->fileName);
}
$downloadZipArchiveFiles = [
$painFileWriteProvider->fileName,
$csvFileWriteProvider->fileName
];
@@ -72,7 +66,6 @@ class ExportController extends CommonController {
Storage::delete($file);
}
Storage::delete($painFileWriteProvider->fileName);
Storage::delete($csvFileWriteProvider->fileName);
return response()->download(
@@ -82,24 +75,28 @@ class ExportController extends CommonController {
);
}
Storage::delete($painFileWriteProvider->fileName);
Storage::delete($csvFileWriteProvider->fileName);
return response()->json([
'message' => 'Die Abrechnungen wurden exportiert.' . PHP_EOL .'Die Belege werden asynchron auf dem Webdav-Server hinterlegt.' . PHP_EOL . PHP_EOL . 'Sollten diese in 15 Minuten nicht vollständig sein, kontaktiere den Adminbistrator.'
'message' => 'Die Abrechnungen wurden exportiert.' . PHP_EOL . 'Die SEPA-Überweisungsdatei kann über den Tab "Globale Aktionen" in der Kostenstellenübersicht erzeugt werden.' . PHP_EOL . PHP_EOL . 'Die Belege werden asynchron auf dem Webdav-Server hinterlegt.' . PHP_EOL . 'Sollten diese in 15 Minuten nicht vollständig sein, kontaktiere den Administrator.'
]);
}
private function painData(array $invoices) : string {
$invoicesForPainFile = [];
private function createSepaPaymentElements(array $invoices, $costUnit): void
{
foreach ($invoices as $invoice) {
if ($invoice->contact_bank_owner !== null && $invoice->contact_bank_iban !== '' && !$invoice->donation) {
$invoicesForPainFile[] = $invoice;
SepaPaymentElement::create([
'tenant' => $this->tenant->slug,
'invoice_id' => $invoice->id,
'cost_unit_id' => $costUnit->id,
'amount' => $invoice->amount,
'recipient_name' => $invoice->contact_bank_owner,
'recipient_iban' => $invoice->contact_bank_iban,
'payment_purpose' => $invoice->payment_purpose ?? 'Auslagenerstattung Rechnungsnummer ' . $invoice->invoice_number,
]);
}
}
$painFileProvider = new PainFileProvider($this->tenant->account_iban, $this->tenant->account_name, $this->tenant->account_bic, $invoicesForPainFile);
return $painFileProvider->createPainFileContent();
}
public function csvData(array $invoices) : string {
@@ -107,4 +104,3 @@ class ExportController extends CommonController {
return $csvDateProvider->createCsvFileContent();
}
}
@@ -0,0 +1,82 @@
<?php
namespace App\Domains\CostUnit\Controllers;
use App\Enumerations\UserRole;
use App\Models\SepaPaymentElement;
use App\Models\Tenant;
use App\Providers\AuthCheckProvider;
use App\Providers\FileWriteProvider;
use App\Providers\PainFileProvider;
use App\Scopes\CommonController;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
class GlobalSepaExportController extends CommonController {
private function checkAuthorization(): void
{
$authCheck = new AuthCheckProvider();
$role = $authCheck->getUserRole();
if (!in_array($role, [UserRole::USER_ROLE_ADMIN, UserRole::USER_ROLE_GROUP_LEADER], true)) {
abort(403);
}
}
public function getGlobalActions()
{
$this->checkAuthorization();
$pendingElements = SepaPaymentElement::where('exported', false)->get();
$pendingCount = $pendingElements->count();
$pendingAmount = number_format($pendingElements->sum('amount'), 2, ',', '.');
return response()->json([
'pending_count' => $pendingCount,
'pending_amount' => $pendingAmount,
]);
}
public function exportSepaFile()
{
$this->checkAuthorization();
return DB::transaction(function () {
$elements = SepaPaymentElement::where('exported', false)->lockForUpdate()->get();
if ($elements->isEmpty()) {
return response()->json([
'message' => 'Es gibt keine ausstehenden SEPA-Überweisungen.'
], 404);
}
$painFileProvider = new PainFileProvider(
$this->tenant->account_iban,
$this->tenant->account_name,
$this->tenant->account_bic,
$elements->all()
);
$painContent = $painFileProvider->createPainFileContent();
$filePrefix = Tenant::getTempDirectory();
$fileName = $filePrefix . 'sepa-pain-' . date('Y-m-d_H-i') . '.xml';
$fileWriteProvider = new FileWriteProvider($fileName, $painContent);
$fileWriteProvider->writeToFile();
$elements->each(function (SepaPaymentElement $element) {
$element->update([
'exported' => true,
'exported_at' => now(),
]);
});
$filePath = storage_path('app/private/' . $fileName);
return response()->download($filePath, basename($fileName), [
'Content-Type' => 'application/xml',
])->deleteFileAfterSend(true);
});
}
}
+4
View File
@@ -4,6 +4,7 @@ use App\Domains\CostUnit\Controllers\CreateController;
use App\Domains\CostUnit\Controllers\DistanceAllowanceController;
use App\Domains\CostUnit\Controllers\EditController;
use App\Domains\CostUnit\Controllers\ExportController;
use App\Domains\CostUnit\Controllers\GlobalSepaExportController;
use App\Domains\CostUnit\Controllers\ListController;
use App\Domains\CostUnit\Controllers\OpenController;
use App\Domains\CostUnit\Controllers\TreasurersEditController;
@@ -43,6 +44,9 @@ Route::prefix('api/v1')
Route::get('/global-actions', [GlobalSepaExportController::class, 'getGlobalActions']);
Route::get('/export-sepa-file', [GlobalSepaExportController::class, 'exportSepaFile']);
Route::prefix('open')->group(function () {
Route::get('/current-events', [ListController::class, 'listCurrentEvents']);
Route::get('/current-running-jobs', [ListController::class, 'listCurrentRunningJobs']);
+8
View File
@@ -7,6 +7,7 @@ import TabbedPage from "../../../Views/Components/TabbedPage.vue";
import {toast} from "vue3-toastify";
import ListCostUnits from "./Partials/ListCostUnits.vue";
import GlobalActions from "./Partials/GlobalActions.vue";
const props = defineProps({
message: String,
@@ -63,6 +64,13 @@ const tabs = [
deep_jump_id: initialCostUnitId,
deep_jump_id_sub: initialInvoiceId,
},
{
title: 'Globale Aktionen',
component: GlobalActions,
endpoint: "/api/v1/cost-unit/global-actions",
deep_jump_id: 0,
deep_jump_id_sub: 0,
},
]
onMounted(() => {
@@ -0,0 +1,112 @@
<script setup>
import {ref} from 'vue'
import LoadingModal from "../../../../Views/Components/LoadingModal.vue";
import {toast} from "vue3-toastify";
const props = defineProps({
data: {
type: [Array, Object],
default: () => ({})
},
deep_jump_id: {
type: Number,
default: 0
},
deep_jump_id_sub: {
type: Number,
default: 0
}
})
const showLoading = ref(false)
async function exportSepaFile() {
showLoading.value = true;
try {
const response = await fetch('/api/v1/cost-unit/export-sepa-file', {
headers: {"Content-Type": "application/json"},
});
if (!response.ok) {
if (response.status === 404) {
const data = await response.json();
toast.info(data.message);
} else {
throw new Error('Fehler beim Erzeugen der SEPA-Datei');
}
showLoading.value = false;
return;
}
const blob = await response.blob();
const downloadUrl = window.URL.createObjectURL(blob);
const a = document.createElement("a");
a.style.display = "none";
a.href = downloadUrl;
a.download = "sepa-pain-" + new Date().toISOString().slice(0, 10) + ".xml";
document.body.appendChild(a);
a.click();
setTimeout(() => {
window.URL.revokeObjectURL(downloadUrl);
document.body.removeChild(a);
}, 100);
toast.success('SEPA-Datei wurde erfolgreich erzeugt.');
showLoading.value = false;
} catch (err) {
showLoading.value = false;
toast.error('Beim Erzeugen der SEPA-Datei ist ein Fehler aufgetreten.');
}
}
</script>
<template>
<div>
<h2>Globale Aktionen</h2>
<div style="margin: 20px 0;">
<p v-if="props.data.pending_count > 0">
Es gibt <strong>{{ props.data.pending_count }}</strong> ausstehende SEPA-Überweisungen
(Gesamtbetrag: <strong>{{ props.data.pending_amount }} Euro</strong>).
</p>
<p v-else>
Keine ausstehenden SEPA-Überweisungen vorhanden.
</p>
</div>
<button
class="action-button"
:disabled="!props.data.pending_count || props.data.pending_count === 0"
@click="exportSepaFile"
>
Erzeuge SEPA-File
</button>
<loading-modal v-if="showLoading" />
</div>
</template>
<style scoped>
.action-button {
padding: 10px 20px;
background-color: #0073aa;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 1rem;
}
.action-button:hover:not(:disabled) {
background-color: #005a87;
}
.action-button:disabled {
background-color: #ccc;
cursor: not-allowed;
}
</style>
@@ -13,7 +13,6 @@
const invoice = ref(null)
const show_invoice = ref(false)
const localData = ref(props.data)
console.log(props.data)
async function openInvoiceDetails(invoiceId) {
const url = '/api/v1/invoice/details/' + invoiceId
@@ -112,8 +112,8 @@
<div class="event-flexbox" v-else>
<div class="event-flexbox-row top">
<div class="left"><ParticipationSummary v-if="dynamicProps.event" :event="dynamicProps.event" /></div>
<div class="right">
<div class="actions-left"><ParticipationSummary v-if="dynamicProps.event" :event="dynamicProps.event" /></div>
<div class="actions-right">
<a :href="'/event/details/' + props.data.event.identifier + '/pdf/first-aid-list'">
<input type="button" value="Erste-Hilfe-Liste (PDF)" />
</a><br/>
@@ -186,6 +186,7 @@
<label style="font-size: 9pt;" class="link" @click="showCommonSettings">Allgemeine Einstellungen</label> &nbsp;
<label style="font-size: 9pt;" class="link" @click="showEventManagement">Veranstaltungsleitung</label> &nbsp;
<label style="font-size: 9pt;" class="link" @click="showParticipationFees">Teilnahmegebühren</label>
<a style="font-size: 9pt;" class="link" :href="'/budget/' + props.data.event.costUnit.id">Budget bearbeiten</a>
<a style="font-size: 9pt;" class="link" :href="'/cost-unit/' + props.data.event.costUnit.id">Ausgabenübersicht</a>
<a v-if="!dynamicProps.event.registrationAllowed && !dynamicProps.event.archived" style="color: #ff0000; font-size: 9pt;" class="link" @click="archiveEvent">Archivieren</a>
</div>
@@ -248,13 +249,13 @@
gap: 10px; /* Abstand zwischen den Spalten */
}
.event-flexbox-row.top .left {
.event-flexbox-row.top .actions-left {
flex: 0 0 calc(100% - 300px);
padding: 10px;
}
.event-flexbox-row.top .right {
flex: 0 0 250px;
.event-flexbox-row.top .actions-right {
flex: 0 0 200px;
padding: 10px;
}
@@ -263,7 +264,7 @@
padding: 10px;
}
.event-flexbox-row.top .right input[type="button"] {
.event-flexbox-row.top .actions-right input[type="button"] {
width: 100% !important;
margin-bottom: 10px;
}
@@ -1,6 +1,7 @@
<script setup>
import {onMounted, reactive, watch} from "vue";
import AmountInput from "../../../../Views/Components/AmountInput.vue";
import DialableTelephoneNumber from "../../../../Views/Components/DialableTelephoneNumber.vue";
const staticProps = defineProps({
editMode: Boolean,
@@ -205,7 +206,7 @@ function saveParticipant() {
<tr>
<th>Telefon</th>
<td>
<span v-if="!staticProps.editMode">{{ props.participant.phone_1 }}</span>
<DialableTelephoneNumber v-if="!staticProps.editMode" :number="props.participant.phone_1"</DialableTelephoneNumber>
<input v-else v-model="form.phone_1" type="text" />
</td>
</tr>
@@ -229,7 +230,7 @@ function saveParticipant() {
<tr>
<th>Ansprechperson Telefon</th>
<td>
<span v-if="!staticProps.editMode">{{ props.participant.phone_2 }}</span>
<DialableTelephoneNumber v-if="!staticProps.editMode" :number="props.participant.phone_2"</DialableTelephoneNumber>
<input v-else v-model="form.phone_2" type="text" />
</td>
</tr>
@@ -8,6 +8,7 @@ import {useAjax} from "../../../../../resources/js/components/ajaxHandler.js";
import {format, getDay, getMonth, getYear} from "date-fns";
import AmountInput from "../../../../Views/Components/AmountInput.vue";
import FullScreenModal from "../../../../Views/Components/FullScreenModal.vue";
import DialableTelephoneNumber from "../../../../Views/Components/DialableTelephoneNumber.vue";
const props = defineProps({
data: {
@@ -351,8 +352,8 @@ function mailToGroup(groupKey) {
</td>
<td class="pl-phone">
<label :id="'participant-' + participant.identifier +'-phone_1'" class="block-label">{{ participant?.phone_1 }}</label>
<label :id="'participant-' + participant.identifier +'-phone_2'" class="block-label">{{ participant?.phone_2 }}</label>
<label :id="'participant-' + participant.identifier +'-phone_1'" class="block-label">P: <DialableTelephoneNumber :number="participant?.phone_1" /></label>
<label :id="'participant-' + participant.identifier +'-phone_2'" class="block-label">K: <DialableTelephoneNumber :number="participant?.phone_2" /></label>
</td>
@@ -64,17 +64,17 @@ const props = defineProps({
<th style="padding-bottom: 20px" colspan="2">Förderung</th>
<td style="padding-bottom: 20px" colspan="2">
{{ props.event.supportPerson.readable }}<br />
<label style="font-size: 9pt;">({{ props.event.supportPersonIndex }} / Tag p.P.)</label>
<label style="font-size: 9pt;">({{ props.event.supportPersonValue }} / Tag p.P.)</label>
</td>
</tr>
<tr>
<th colspan="2" style="border-width: 1px; border-bottom-style: solid">Gesamt</th>
<td style="font-weight: bold; border-width: 1px; border-bottom-style: solid">
<th colspan="2" style="border-width: 1px; border-top-style: solid">Gesamt</th>
<td style="font-weight: bold; border-width: 1px; border-top-style: solid">
{{ props.event.income.real.readable }} /
</td>
<td style="font-weight: bold; border-width: 1px; border-bottom-style: solid">
<td style="font-weight: bold; border-width: 1px; border-top-style: solid">
{{ props.event.income.expected.readable }}
</td>
</tr>
@@ -96,19 +96,31 @@ const props = defineProps({
</td>
</tr>
<tr>
<th style="padding-top: 20px; font-size: 12pt !important;" colspan="2">Budget</th>
<td v-if="props.event.totalBalance.estimated.value >= 0" style="color: #4caf50; font-weight: bold; padding-top: 20px; font-size: 12pt !important;">
{{ props.event.totalBalance.estimated.readable }}
</td>
<td v-else style="color: #f44336; font-weight: bold; padding-top: 20px; font-size: 12pt !important;">
{{props.event.totalBalance.estimated.readable}}
</td>
</tr>
</table>
</div>
<div class="right">
<h3>Ausgaben</h3>
<table class="event-payment-table" style="font-size: 10pt;">
<table class="event-payment-table" style="font-size: 10pt; width:100%">
<tr v-for="amount in props.event.costUnit.amounts">
<th>{{amount.name}}</th>
<td>{{amount.string}}</td>
<td>({{ amount.estimatedString }}) </td>
</tr>
<tr>
<th style="color:#f44336; border-width: 1px; border-bottom-style: solid; padding-top: 58px">Gesamt</th>
<td style="color:#f44336; border-width: 1px; border-bottom-style: solid; padding-top: 58px; font-weight: bold">{{props.event.costUnit.overAllAmount.text}}</td>
<th style="color:#f44336; border-width: 1px; border-top-style: solid; ">Gesamt</th>
<td style="color:#f44336; border-width: 1px; border-top-style: solid; font-weight: bold; padding-right: 20px;">{{props.event.costUnit.overAllAmount.text}}</td>
<td style="color:#f44336; border-width: 1px; border-top-style: solid; font-weight: bold">({{props.event.costUnit.overAllEstimatedAmount.text}}))</td>
</tr>
</table>
</div>
@@ -121,21 +133,21 @@ const props = defineProps({
.participant-flexbox {
display: flex;
flex-direction: column;
gap: 10px;
gap: 20px;
width: 95%;
margin: 20px auto 0;
}
.participant-flexbox-row {
display: flex;
gap: 20px;
flex: 1 1;
flex-wrap: wrap;
}
.participant-flexbox-row.top .left,
.participant-flexbox-row.top .right {
flex: 1 1 280px;
padding: 10px;
padding: 20px;
min-width: 0;
}
@@ -152,12 +164,16 @@ const props = defineProps({
}
.participant-income-table tr td:first-child {
width: 25px !important;
font-size: 11pt;
width: 50px;
}
.event-payment-table {
width: 100%;
.participant-income-table tr td:first-child {
width: 25px !important;
font-size: 10pt;
}
.event-payment-table th {
width: 50px;
}
</style>
@@ -30,7 +30,7 @@ class CreateInvoiceCommand {
'type' => $this->request->invoiceType,
'type_other' => $this->request->invoiceTypeExtended,
'donation' => $this->request->isDonation,
'user_id' => $this->request->userId,
'user_id' => $this->request->paymentPurpose === null ? $this->request->userId : null,
'contact_name' => $this->request->contactName,
'contact_email' => $this->request->contactEmail,
'contact_phone' => $this->request->contactPhone,
@@ -2,6 +2,7 @@
namespace App\Domains\UserManagement\Controllers;
use App\Enumerations\UserRole;
use App\Providers\InertiaProvider;
use App\Scopes\CommonController;
use Illuminate\Http\Request;
@@ -38,20 +39,44 @@ class LoginController extends CommonController {
return redirect()->intended('/register/verifyEmail');
}
#$credentials = ['username' => 'development', 'password' => 'development'];
if (!Auth::attempt($credentials)) {
return back()->withErrors([
'username' => 'Diese Zugangsdaten sind ungültig.',
]);
}
$request->session()->regenerate();
$user = Auth::user();
$tenant = app('tenant');
// Auf "lv" darf sich grundsätzlich jeder aktive Nutzer einloggen.
// Auf Sub-Tenants gilt:
// - Der Nutzer muss dem Tenant zugeordnet sein (local_group)
// - ODER er hat "Bundesrecht über Landesrecht":
// user_role_main === ROLE_ADMINISTRATOR -> Login auf jedem Sub-Tenant erlaubt.
$isMainAdmin = $user->user_role_main === UserRole::USER_ROLE_ADMIN;
$isMemberOfTenant = $tenant->slug === $user->local_group;
# dd($user->firstname . ' ' . $user->lastname);
if ($tenant->slug !== 'lv' && !$isMainAdmin && !$isMemberOfTenant) {
Auth::logout();
$request->session()->invalidate();
$request->session()->regenerateToken();
return back()->withErrors([
'username' => 'Diese Zugangsdaten sind für diesen Stamm nicht gültig.',
]);
}
if (!$user->active) {
Auth::logout();
$request->session()->invalidate();
$request->session()->regenerateToken();
return back()->withErrors([
'username' => 'Dieses Benutzerkonto ist nicht aktiv.',
]);
}
$request->session()->regenerate();
return redirect()->intended('/');
}
+9
View File
@@ -6,6 +6,7 @@ use App\Scopes\InstancedModel;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
/**
* @property string $name
@@ -44,7 +45,15 @@ class CostUnit extends InstancedModel
return $this->hasMany(Invoice::class);
}
public function estimates() : hasMany {
return $this->hasMany(CostUnitEstimate::class);
}
public function tenant() : BelongsTo {
return $this->belongsTo(Tenant::class, 'tenant', 'slug');
}
public function event() : HasOne {
return $this->hasOne(Event::class);
}
}
+53
View File
@@ -0,0 +1,53 @@
<?php
namespace App\Models;
use App\Casts\AmountCast;
use App\Enumerations\InvoiceStatus;
use App\Enumerations\InvoiceType;
use App\Resources\EventResource;
use App\Scopes\InstancedModel;
use App\ValueObjects\Amount;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class CostUnitEstimate extends InstancedModel
{
protected $fillable = [
'tenant',
'cost_unit_id',
'type',
'description',
'flat_amount',
'amount_by_user',
];
protected $casts = [
'flat_amount' => AmountCast::class,
'amount_by_user' => AmountCast::class,
];
public function costUnit() : BelongsTo{
return $this->belongsTo(CostUnit::class);
}
public function invoiceType() : InvoiceType {
return $this->belongsTo(InvoiceType::class, 'type', 'slug')->first();
}
public function calculateAmount() : ?Amount {
switch (true) {
case $this->flat_amount !== null:
return $this->flat_amount;
default:
$event = $this->costUnit()->first()->event()?->first();
if (null !== $event) {
$participants = $event->participants()->count();
$amount = clone($this->amount_by_user);
return $amount->multiply($participants);
} else {
return $this->amount_by_user;
}
}
}
}
+54
View File
@@ -0,0 +1,54 @@
<?php
namespace App\Models;
use App\Scopes\InstancedModel;
use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* @property string $id
* @property string $tenant
* @property int $invoice_id
* @property int $cost_unit_id
* @property float $amount
* @property string $recipient_name
* @property string $recipient_iban
* @property string $payment_purpose
* @property bool $exported
* @property \DateTime|null $exported_at
*/
class SepaPaymentElement extends InstancedModel
{
use HasUuids;
public $incrementing = false;
protected $keyType = 'string';
protected $fillable = [
'tenant',
'invoice_id',
'cost_unit_id',
'amount',
'recipient_name',
'recipient_iban',
'payment_purpose',
'exported',
'exported_at',
];
protected $casts = [
'exported' => 'boolean',
'exported_at' => 'datetime',
];
public function invoice(): BelongsTo
{
return $this->belongsTo(Invoice::class);
}
public function costUnit(): BelongsTo
{
return $this->belongsTo(CostUnit::class);
}
}
+33 -3
View File
@@ -3,6 +3,7 @@
namespace App\Providers;
use App\Enumerations\UserRole;
use App\Models\User;
class AuthCheckProvider {
public function checkLoggedIn() : bool {
@@ -16,7 +17,7 @@ class AuthCheckProvider {
return $user->active;
}
if ($user->user_role_main === UserRole::USER_ROLE_ADMIN) {
if ($this->isMainAdministrator($user)) {
return true;
}
@@ -28,10 +29,39 @@ class AuthCheckProvider {
return null;
}
$user = auth()->user();
if (app('tenant')->slug === 'lv') {
return auth()->user()->user_role_main;
return $user->user_role_main;
}
return auth()->user()->user_role_local_group;
// "Bundesrecht steht über Landesrecht":
// Ein ROLE_ADMINISTRATOR auf LV-Ebene ist auf jedem Sub-Tenant automatisch Administrator,
// unabhängig von user_role_local_group.
if ($this->isMainAdministrator($user)) {
return UserRole::USER_ROLE_ADMIN;
}
return $user->user_role_local_group;
}
/**
* Gibt true zurück, wenn der Nutzer auf LV-Ebene Administrator ist.
* Diese Rolle hebt das lokale Rechtesystem für alle Sub-Tenants auf.
*/
public function isMainAdministrator(?User $user = null) : bool {
$user ??= auth()->user();
return $user !== null
&& $user->user_role_main === UserRole::USER_ROLE_ADMIN;
}
/**
* Bequemer Helper für die Berechtigungs-Checks im gesamten System.
* Gibt true zurück, wenn der aktuell eingeloggte Nutzer im Kontext des
* aktuellen Tenants effektiv Administrator ist.
*/
public function isAdministrator() : bool {
return $this->getUserRole() === UserRole::USER_ROLE_ADMIN;
}
}
+8 -2
View File
@@ -39,12 +39,18 @@ class CronTaskHandleProvider extends CommonController
// --- Daily Tasks ---
if ($task->execution_type === CronTaskType::CRON_TASK_TYPE_DAILY) {
$tenantLastRun = $task->last_run?->get($tenant->slug);
$tenantLastRun = $task->last_run;
if ($tenantLastRun !== null) {
$tenantLastRun = Carbon::parse($tenantLastRun[$tenant->slug]) ?? null;
} else {
$tenantLastRun = null;
}
$scheduledTime = \DateTime::createFromFormat('Y-m-d H:i:s', date('Y-m-d ') . $task->schedule_time);
$now = Carbon::now();
$alreadyRunToday = $tenantLastRun == null ? true : $tenantLastRun->isToday() ?? false;
$alreadyRunToday = $tenantLastRun == null ? false : $tenantLastRun->isToday() ?? false;
if (!$alreadyRunToday && $now >= $scheduledTime) {
$this->runTask($task);
+43 -25
View File
@@ -26,28 +26,7 @@ class GlobalDataProvider {
'tenant' => app('tenant'),
'activeUsers' => $this->getActiveUsers(),
'version' => config('app.version'),
]);
}
public function getAllInvoiceTypes() : JsonResponse {
$invoiceTypes = [];
foreach (InvoiceType::orderBy('sort_order')->get() as $invoiceType) {
if (
$invoiceType->slug === InvoiceType::INVOICE_TYPE_OTHER
) {
continue;
}
$invoiceTypes[] = [
'slug' => $invoiceType->slug,
'name' => $invoiceType->name
];
}
$invoiceTypes[] = ['slug' => InvoiceType::INVOICE_TYPE_OTHER, 'name' => 'Sonstige Kosten'];
return response()->json([
'invoiceTypes' => $invoiceTypes
'currentEvent' => $this->getCurrentEventData(),
]);
}
@@ -99,10 +78,47 @@ class GlobalDataProvider {
]);
}
private function getCurrentEventData() : ?array {
if (null === $this->user) {
return null;
}
$currentEvent = new EventRepository()->getMyCurrentEvent();
if (null === $currentEvent) {
return null;
}
return [
'identifier' => $currentEvent->identifier,
'name' => $currentEvent->name,
];
}
public function getAllInvoiceTypes() : JsonResponse {
$invoiceTypes = [];
foreach (InvoiceType::orderBy('sort_order')->get() as $invoiceType) {
if (
$invoiceType->slug === InvoiceType::INVOICE_TYPE_OTHER
) {
continue;
}
$invoiceTypes[] = [
'slug' => $invoiceType->slug,
'name' => $invoiceType->name
];
}
$invoiceTypes[] = ['slug' => InvoiceType::INVOICE_TYPE_OTHER, 'name' => 'Sonstige Kosten'];
return response()->json([
'invoiceTypes' => $invoiceTypes
]);
}
private function generateNavbar() : array {
$eventRepository = new EventRepository();
$navigation = [
'personal' => [],
'common' => [],
@@ -116,9 +132,11 @@ class GlobalDataProvider {
$navigation['personal'][] = ['url' => '/personal-data', 'display' => 'Meine Daten'];
$navigation['personal'][] = ['url' => '/messages', 'display' => 'Meine Nachrichten'];
$authCheck = new AuthCheckProvider();
$effectiveRole = $authCheck->getUserRole();
if (
in_array($this->user->user_role_local_group, [UserRole::USER_ROLE_ADMIN, UserRole::USER_ROLE_GROUP_LEADER] ) ||
$this->user->user_role_main === UserRole::USER_ROLE_ADMIN
in_array($effectiveRole, [UserRole::USER_ROLE_ADMIN, UserRole::USER_ROLE_GROUP_LEADER], true)
) {
$navigation['costunits'][] = ['url' => '/cost-unit/list', 'display' => 'Kostenstellen'];
$navigation['costunits'][] = ['url' => '/cost-unit/create', 'display' => 'Neue laufende Tätigkeit'];
+13 -17
View File
@@ -2,25 +2,23 @@
namespace App\Providers;
use App\Models\Invoice;
use App\Resources\InvoiceResource;
use App\Models\SepaPaymentElement;
use DOMDocument;
use Exception;
use Illuminate\Http\Request;
class PainFileProvider {
public string $senderIban;
public string $senderName;
public string $senderBic;
/* @var Invoice[] */
public array $invoices;
/** @var SepaPaymentElement[] */
public array $elements;
public function __construct(string $senderIban, string $senderName, string $senderBic, array $invoices) {
public function __construct(string $senderIban, string $senderName, string $senderBic, array $elements) {
$this->senderIban = $senderIban;
$this->senderName = $senderName;
$this->senderBic = $senderBic;
$this->invoices = $invoices;
$this->elements = $elements;
}
public function createPainFileContent() : string {
@@ -46,9 +44,9 @@ class PainFileProvider {
$grp_hdr->appendChild($doc->createElement('MsgId', uniqid('MSG')));
$grp_hdr->appendChild($doc->createElement('CreDtTm', date('c')));
$grp_hdr->appendChild($doc->createElement('NbOfTxs', count($this->invoices)));
$grp_hdr->appendChild($doc->createElement('NbOfTxs', count($this->elements)));
$totalAmount = array_sum(array_column($this->invoices, 'amount'));
$totalAmount = array_sum(array_map(fn(SepaPaymentElement $e) => $e->amount, $this->elements));
$grp_hdr->appendChild($doc->createElement('CtrlSum', number_format($totalAmount, 2, '.', '')));
$initg_pty = $doc->createElement('InitgPty');
@@ -62,7 +60,7 @@ class PainFileProvider {
$pmt_inf->appendChild($doc->createElement('PmtInfId', uniqid('PMT')));
$pmt_inf->appendChild($doc->createElement('PmtMtd', 'TRF'));
$pmt_inf->appendChild($doc->createElement('BtchBookg', 'false'));
$pmt_inf->appendChild($doc->createElement('NbOfTxs', count($this->invoices)));
$pmt_inf->appendChild($doc->createElement('NbOfTxs', count($this->elements)));
$pmt_inf->appendChild($doc->createElement('CtrlSum', number_format($totalAmount, 2, '.', '')));
$pmt_tp_inf = $doc->createElement('PmtTpInf');
@@ -90,9 +88,7 @@ class PainFileProvider {
$dbtr_agt->appendChild($id);
$pmt_inf->appendChild($dbtr_agt);
foreach ($this->invoices as $index => $invoice) {
$invoiceResource = new InvoiceResource($invoice)->toArray(new Request());
foreach ($this->elements as $index => $element) {
$cdt_trf_tx_inf = $doc->createElement('CdtTrfTxInf');
$pmt_id = $doc->createElement('PmtId');
@@ -100,23 +96,23 @@ class PainFileProvider {
$cdt_trf_tx_inf->appendChild($pmt_id);
$amt = $doc->createElement('Amt');
$instd_amt = $doc->createElement('InstdAmt', number_format($invoice['amount'], 2, '.', ''));
$instd_amt = $doc->createElement('InstdAmt', number_format($element->amount, 2, '.', ''));
$instd_amt->setAttribute('Ccy', 'EUR');
$amt->appendChild($instd_amt);
$cdt_trf_tx_inf->appendChild($amt);
$cdtr = $doc->createElement('Cdtr');
$cdtr->appendChild($doc->createElement('Nm', $invoice['contact_bank_owner']));
$cdtr->appendChild($doc->createElement('Nm', $element->recipient_name));
$cdt_trf_tx_inf->appendChild($cdtr);
$cdtr_acct = $doc->createElement('CdtrAcct');
$cdtr_id = $doc->createElement('Id');
$cdtr_id->appendChild($doc->createElement('IBAN', str_replace(' ', '', $invoice['contact_bank_iban'])));
$cdtr_id->appendChild($doc->createElement('IBAN', str_replace(' ', '', $element->recipient_iban)));
$cdtr_acct->appendChild($cdtr_id);
$cdt_trf_tx_inf->appendChild($cdtr_acct);
$rmt_inf = $doc->createElement('RmtInf');
$rmt_inf->appendChild($doc->createElement('Ustrd', $invoiceResource['paymentPurpose']));
$rmt_inf->appendChild($doc->createElement('Ustrd', $element->payment_purpose));
$cdt_trf_tx_inf->appendChild($rmt_inf);
$pmt_inf->appendChild($cdt_trf_tx_inf);
+11 -5
View File
@@ -2,6 +2,7 @@
namespace App\Providers;
use App\Enumerations\UserRole;
use Illuminate\Auth\EloquentUserProvider;
class TenantUserProvider extends EloquentUserProvider
@@ -18,15 +19,20 @@ class TenantUserProvider extends EloquentUserProvider
}
}
// Auf "lv" gilt grundsätzlich keine local_group-Einschränkung.
if (app('tenant')->slug === 'lv') {
return $query->first();
}
$query->where([
'local_group' => app('tenant')->slug,
'active' => true
]);
// Auf Sub-Tenants:
// - Entweder gehört der Nutzer zum aktuellen Tenant (local_group)
// - ODER er ist auf LV-Ebene Administrator
// -> "Bundesrecht steht über Landesrecht": Login überall möglich.
$query->where('active', true)
->where(function ($q) {
$q->where('local_group', app('tenant')->slug)
->orWhere('user_role_main', UserRole::USER_ROLE_ADMIN);
});
return $query->first();
}
+15 -2
View File
@@ -7,6 +7,7 @@ use App\Enumerations\InvoiceStatus;
use App\Enumerations\InvoiceType;
use App\Enumerations\UserRole;
use App\Models\CostUnit;
use App\Providers\AuthCheckProvider;
use App\Resources\CostUnitResource;
use App\ValueObjects\Amount;
use Illuminate\Database\Capsule\Manager as Capsule;
@@ -75,8 +76,8 @@ class CostUnitRepository {
} else {
if ($tenant->slug !== 'lv') {
if (
$user->user_role_main === UserRole::USER_ROLE_ADMIN ||
in_array($user->user_role_local_group, [UserRole::USER_ROLE_GROUP_LEADER, UserRole::USER_ROLE_ADMIN])
new AuthCheckProvider()->isAdministrator() ||
$user->user_role_local_group === UserRole::USER_ROLE_ADMIN
) {
$canSeeAll = true;
}
@@ -178,6 +179,18 @@ class CostUnitRepository {
return $amount;
}
public function sumupEstimatedByInvoiceType(CostUnit $costUnit, InvoiceType $invoiceType) : Amount {
$amount = new Amount(0, 'Euro');
foreach ($costUnit->estimates()->get() as $estimate) {
if ($estimate->type !== $invoiceType->slug) {
continue;
}
$amount->addAmount($estimate->calculateAmount());
}
return $amount;
}
public function sumupUnhandledAmounts(CostUnit $costUnit, bool $donatedAmount = false) : Amount {
$amount = new Amount(0, '');
+44
View File
@@ -0,0 +1,44 @@
<?php
namespace App\Repositories;
use App\Models\CostUnit;
use App\Models\CostUnitEstimate;
use App\ValueObjects\Amount;
class EstimatesRepository {
public function getEstimates(CostUnit $costUnit, string $estimateType) : array {
$return = [];
foreach ($costUnit->estimates()->where('type', $estimateType)->get() as $estimate) {
$return[] = $estimate->toResource()->toArray(request());
}
return $return;
}
public function getById(int $estimateId, bool $accessCheck = true) : ?CostUnitEstimate {
$estimate = CostUnitEstimate::find($estimateId);
if ($estimate === null) {
return null;
}
if ($accessCheck) {
$costUnitRepository = new CostUnitRepository();
if (null === $costUnitRepository->getById($estimate->cost_unit_id)) {
return null;
}
}
return $estimate;
}
public function getTotalAmount(CostUnit $costUnit, string $estimateType) : Amount {
$total = new Amount(0, 'Euro');
foreach ($costUnit->estimates()->where('type', $estimateType)->get() as $estimate) {
$total->addAmount($estimate->calculateAmount());
}
return $total;
}
}
+18 -2
View File
@@ -6,6 +6,7 @@ use App\Enumerations\ParticipationType;
use App\Enumerations\UserRole;
use App\Models\CostUnit;
use App\Models\Event;
use App\Providers\AuthCheckProvider;
use App\Resources\CostUnitResource;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Http\Request;
@@ -19,13 +20,25 @@ class EventRepository {
}
public function getMyCurrentEvent() : ?Event {
$events = $this->getEventsByCriteria([
['archived', '=', false],
['start_date', '<=', now()],
['end_date', '>=', now()],
], true);
if (count($events) !== 1) {
return null;
}
return $events[0];
}
public function getUpcoming(int $maxCount = 5, bool $accessCheck = true) : array {
$events = [];
foreach ( $this->getEventsByCriteria([
'archived' => false,
],$accessCheck) as $event) {
if ($event->start_date > now()) {
if ($event->end_date >= now()) {
$event = $event->toResource()->toArray(new Request());
$events[] = $event;
@@ -72,7 +85,10 @@ class EventRepository {
if (!$accessCheck) {
$canSeeAll = true;
} else {
if ($tenant->slug !== 'lv') {
if (
new AuthCheckProvider()->isAdministrator() ||
$user->user_role_local_group === UserRole::USER_ROLE_ADMIN
) {
if (
$user->user_role_main === UserRole::USER_ROLE_ADMIN ||
in_array($user->user_role_local_group, [UserRole::USER_ROLE_GROUP_LEADER, UserRole::USER_ROLE_ADMIN])
@@ -0,0 +1,45 @@
<?php
namespace App\Resources;
use App\Enumerations\EatingHabit;
use App\Enumerations\EfzStatus;
use App\Enumerations\ParticipationType;
use App\Models\CostUnitEstimate;
use App\Models\EventParticipant;
use App\ValueObjects\Age;
use App\ValueObjects\Amount;
use Illuminate\Http\Resources\Json\JsonResource;
class CostUnitEstimateResource extends JsonResource
{
function __construct(CostUnitEstimate $estimate)
{
parent::__construct($estimate);
}
public function toArray($request) : array
{
$amount = $this->resource->calculateAmount();
$singleAmountString = $this->resource->flat_amount?->toString();
$amountType = 'flat';
if ($singleAmountString === null) {
$amountType = 'per_person';
$singleAmountString = $this->resource->amount_by_user->toString() . ' / Person (' . $amount->toString() . ' Gesamt)';
} else {
$singleAmountString .= ' Gesamt';
}
return [
'id' => $this->resource->id,
'title' => $this->resource->description,
'singleAmountString' => $singleAmountString,
'calculatedAmount' => $amount,
'calculatedAmountString' => $amount->toString(),
'amountValue' => $amount->getAmount(),
'amountType' => $amountType,
];
}
}
+6
View File
@@ -31,10 +31,15 @@ class CostUnitResource {
$amounts = [];
$overAllAmount = new Amount(0, 'Euro');
$overAllEstimatedAmount = new Amount(0, 'Euro');
foreach (InvoiceType::orderBy('sort_order')->get() as $invoiceType) {
$overAllAmount->addAmount($costUnitRepository->sumupByInvoiceType($this->costUnit, $invoiceType));
$overAllEstimatedAmount->addAmount($costUnitRepository->sumupEstimatedByInvoiceType($this->costUnit, $invoiceType));
$amounts[$invoiceType->slug]['string'] = $costUnitRepository->sumupByInvoiceType($this->costUnit, $invoiceType)->toString();
$amounts[$invoiceType->slug]['name'] = $invoiceType->name;
$amounts[$invoiceType->slug]['estimated'] = $costUnitRepository->sumupEstimatedByInvoiceType($this->costUnit, $invoiceType);
$amounts[$invoiceType->slug]['estimatedString'] = $costUnitRepository->sumupEstimatedByInvoiceType($this->costUnit, $invoiceType)->toString();
}
@@ -52,6 +57,7 @@ class CostUnitResource {
'treasurers' => $this->costUnit->treasurers()->get()->map(fn($user) => new UserResource($user))->toArray(),
'amounts' => $amounts,
'overAllAmount' => ['text' => $overAllAmount->toString(), 'value' => $overAllAmount],
'overAllEstimatedAmount' => ['text' => $overAllEstimatedAmount->toString(), 'value' => $overAllEstimatedAmount],
]);
+5 -8
View File
@@ -26,17 +26,14 @@ class EventParticipantResource extends JsonResource
}
$presenceDays = $this->resource->arrival_date->diff($this->resource->departure_date)->days;
$presenceDaysSupport = $presenceDays;
if ($presenceDaysSupport === 0) {
$presenceDaysSupport = 1;
if ($presenceDays === 0) {
$presenceDays = 1;
$presenceDaysSupport = 1;
} else {
$presenceDaysSupport = $presenceDaysSupport - 1;
$presenceDaysSupport = $presenceDays;
$presenceDays++;
}
return array_merge(
$this->resource->toArray(),
[
+10 -1
View File
@@ -86,8 +86,10 @@ class EventResource extends JsonResource{
$returnArray['eventEnd'] = $this->event->end_date->format('d.m.Y');
$returnArray['eventEndInternal'] = $this->event->end_date;
$returnArray['duration'] = $duration;
$returnArray['totalParticipantCount'] = $this->event->participants()->count();
$returnArray['supportPersonIndex'] = $this->event->support_per_person->toString();
$returnArray['supportPersonValue'] = $this->event->support_per_person->getAmount();
$returnArray['supportPerson'] = $this->calculateSupportPerPerson($returnArray['participants']);
$returnArray['income'] = $this->calculateIncomes($returnArray['participants'], $returnArray['supportPerson']['amount']);
@@ -95,12 +97,15 @@ class EventResource extends JsonResource{
$totalBalanceReal = new Amount(0, 'Euro');
$totalBalanceExpected = new Amount(0, 'Euro');
$totalBalanceEstimated = new Amount(0, 'Euro');
$totalBalanceReal->addAmount($returnArray['income']['real']['amount']);
$totalBalanceExpected->addAmount($returnArray['income']['expected']['amount']);
$totalBalanceEstimated->addAmount($returnArray['income']['expected']['amount']);
$totalBalanceReal->subtractAmount($returnArray['costUnit']['overAllAmount']['value']);
$totalBalanceExpected->subtractAmount($returnArray['costUnit']['overAllAmount']['value']);
$totalBalanceEstimated->subtractAmount($returnArray['costUnit']['overAllEstimatedAmount']['value']);
$returnArray['totalBalance'] = [
'real' => [
'value' => $totalBalanceReal->getAmount(),
@@ -108,7 +113,11 @@ class EventResource extends JsonResource{
], 'expected' => [
'value' => $totalBalanceExpected->getAmount(),
'readable' => $totalBalanceExpected->toString(),
]
],
'estimated' => [
'value' => $totalBalanceEstimated->getAmount(),
'readable' => $totalBalanceEstimated->toString(),
]
];
$returnArray['flatSupport'] = $this->event->support_flat->toString();
+3
View File
@@ -5,6 +5,7 @@ namespace App\Scopes;
use App\Models\Tenant;
use App\Providers\AuthCheckProvider;
use App\Repositories\CostUnitRepository;
use App\Repositories\EstimatesRepository;
use App\Repositories\EventParticipantRepository;
use App\Repositories\EventRepository;
use App\Repositories\InvoiceRepository;
@@ -21,6 +22,7 @@ abstract class CommonController {
protected InvoiceRepository $invoices;
protected EventRepository $events;
protected EventParticipantRepository $eventParticipants;
protected EstimatesRepository $estimates;
public function __construct() {
$this->tenant = app('tenant');
@@ -30,6 +32,7 @@ abstract class CommonController {
$this->invoices = new InvoiceRepository();
$this->events = new EventRepository();
$this->eventParticipants = new EventParticipantRepository();
$this->estimates = new EstimatesRepository();
}
protected function checkAuth() {
-1
View File
@@ -12,7 +12,6 @@ class CloseEvent implements CronTask {
$eventRepository = new EventRepository();
/** @var Event $event */
foreach ($eventRepository->getAvailable(false) as $event) {
echo $event->id . $event->tenant .'<br>';
if ($event->registration_final_end <= $now ) {
$event->registration_allowed = false;
$event->save();
@@ -0,0 +1,10 @@
<!-- NumericInput.vue -->
<script setup>
const props = defineProps({
number: { type: String, required: true },
})
</script>
<template>
<a class="link" :href="'tel:' + props.number">{{ props.number }}</a>
</template>
@@ -20,7 +20,7 @@ return new class extends Migration {
$table->string('name')->unique();
$table->string('execution_type');
$table->time('schedule_time')->nullable();
$table->timestamp('last_run')->nullable();
$table->json('last_run')->nullable();
$table->timestamps();
$table->foreign('execution_type')->references('slug')->on('cron_task_types')->cascadeOnDelete()->cascadeOnUpdate();
@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('cost_unit_estimates', function (Blueprint $table) {
$table->id();
$table->string('tenant');
$table->foreignId('cost_unit_id')->constrained('cost_units', 'id')->restrictOnDelete()->cascadeOnUpdate();
$table->string('type');
$table->string('description');
$table->float('flat_amount', 2)->nullable();
$table->float('amount_by_user', 2)->nullable();
$table->foreign('tenant')->references('slug')->on('tenants')->restrictOnDelete()->cascadeOnUpdate();
$table->foreign('type')->references('slug')->on('invoice_types')->restrictOnDelete()->cascadeOnUpdate();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('cost_unit_estimates');
}
};
@@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::create('sepa_payment_elements', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('tenant');
$table->foreignId('invoice_id')->constrained('invoices', 'id')->restrictOnDelete()->cascadeOnUpdate();
$table->foreignId('cost_unit_id')->constrained('cost_units', 'id')->restrictOnDelete()->cascadeOnUpdate();
$table->float('amount', 2);
$table->string('recipient_name');
$table->string('recipient_iban');
$table->string('payment_purpose');
$table->boolean('exported')->default(false);
$table->dateTime('exported_at')->nullable();
$table->foreign('tenant')->references('slug')->on('tenants')->restrictOnDelete()->cascadeOnUpdate();
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('sepa_payment_elements');
}
};
+56 -7
View File
@@ -1,5 +1,5 @@
<script setup>
import {reactive, onMounted, ref} from 'vue';
import {reactive, onMounted, ref, computed} from 'vue';
import Icon from "../../../app/Views/Components/Icon.vue";
import GlobalWidgets from "../../../app/Views/Partials/GlobalWidgets/GlobalWidgets.vue";
import {toast} from "vue3-toastify";
@@ -20,7 +20,8 @@ const globalProps = reactive({
currentPath: '/',
errors: {},
availableLocalGroups: [],
message: ''
message: '',
currentEvent: null,
});
const sidebarOpen = ref(false);
@@ -51,13 +52,15 @@ onMounted(async () => {
}
});
const currentPath = window.location.pathname;
const showCurrentEventLink = computed(() => {
if (!globalProps.currentEvent) {
return false;
}
return currentPath !== '/event/details/' + globalProps.currentEvent.identifier;
});
const props = defineProps({
title: { type: String, default: 'App' },
flash: { type: Object, default: () => ({}) }
@@ -84,6 +87,16 @@ const props = defineProps({
<label id="show_username" v-if="globalProps.user !== null">Willkommen, {{ globalProps.user.nicename }}</label>
</div>
<a
v-if="showCurrentEventLink"
:href="'/event/details/' + globalProps.currentEvent.identifier"
class="current-event-link"
:title="'Zur Veranstaltung: ' + globalProps.currentEvent.name"
>
<Icon name="calendar-day" />
<span class="current-event-link-label">{{ globalProps.currentEvent.name }}</span>
</a>
<div class="header-actions" v-if="globalProps.user !== null">
<div class="user-info">
<a href="/messages" class="header-link-anonymous" title="Meine Nachrichten">
@@ -394,6 +407,34 @@ const props = defineProps({
align-items: center;
}
/* ─── Direktlink zum aktuellen Event ─── */
.current-event-link {
display: none; /* per Default ausgeblendet nur auf Mobile sichtbar */
align-items: center;
gap: 6px;
color: #1d4899;
font-weight: bold;
text-decoration: none;
padding: 6px 10px;
border-radius: 4px;
margin-right: 10px;
max-width: 50%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.current-event-link:hover {
background-color: #1d4899;
color: #ffffff;
}
.current-event-link-label {
overflow: hidden;
text-overflow: ellipsis;
}
/* ═══════════════════════════════════════════
TABLET (640px 1023px)
═══════════════════════════════════════════ */
@@ -455,6 +496,14 @@ const props = defineProps({
height: 60px;
}
.current-event-link {
display: inline-flex;
}
.current-event-link-label {
max-width: 120px;
}
.left-side h1 {
font-size: 1rem;
}
+2
View File
@@ -21,6 +21,8 @@ require_once __DIR__ . '/../app/Domains/Invoice/Routes/web.php';
require_once __DIR__ . '/../app/Domains/Invoice/Routes/api.php';
require_once __DIR__ . '/../app/Domains/Event/Routes/web.php';
require_once __DIR__ . '/../app/Domains/Event/Routes/api.php';
require_once __DIR__ . '/../app/Domains/Budget/Routes/web.php';
require_once __DIR__ . '/../app/Domains/Budget/Routes/api.php';
Route::get('/LKvDUqWl', function () {
+1 -1
View File
@@ -1 +1 @@
4.3.0
4.4.1