Feature: Parzellenspezifische Kostenpositionsenzuweisung

- Neue Tabelle wp_kgvvm_parcel_cost_assignments für 1:N Zuordnungen
- CostRepository erweitert: get_assigned_entry_ids(), get_entry_ids_with_assignments(), assign_to_parcel(), unassign_from_parcel(), delete_assignments_for_entry()
- Admin: Neue POST-Action toggle_parcel_cost_assignment() mit Nonce-Sicherung
- Jahresabrechnung Parzelle: Rechte Seitenleiste zeigt alle Kostenpositions mit Zuordnungsstatus (✓ zugeordnet, ✗ nicht zugeordnet, – alle Parzellen)
- Berechnung: Kostenposten mit Beschränkung werden nur berechnet wenn Parzelle zugeordnet ist
- DataTransfer.php: parcel_cost_assignments in table_keys integriert für Export/Import
- DELETE-Handler bereinigt Zuordnungen beim Löschen einer Kostenposition
This commit is contained in:
2026-04-17 16:55:09 +02:00
parent a1e6c52eaf
commit 1a6b1199cd
4 changed files with 287 additions and 2 deletions

View File

@@ -36,8 +36,9 @@ class Schema {
'cost_entries' => $wpdb->prefix . 'kgvvm_cost_entries',
'work_jobs' => $wpdb->prefix . 'kgvvm_work_jobs',
'work_year_config' => $wpdb->prefix . 'kgvvm_work_year_config',
'work_logs' => $wpdb->prefix . 'kgvvm_work_logs',
'work_log_members' => $wpdb->prefix . 'kgvvm_work_log_members',
'work_logs' => $wpdb->prefix . 'kgvvm_work_logs',
'work_log_members' => $wpdb->prefix . 'kgvvm_work_log_members',
'parcel_cost_assignments' => $wpdb->prefix . 'kgvvm_parcel_cost_assignments',
);
return isset( $map[ $key ] ) ? $map[ $key ] : '';
@@ -254,6 +255,14 @@ class Schema {
KEY log_id (log_id)
) {$charset_collate};";
$sql[] = "CREATE TABLE " . self::table( 'parcel_cost_assignments' ) . " (
parcel_id BIGINT UNSIGNED NOT NULL,
cost_entry_id BIGINT UNSIGNED NOT NULL,
created_at DATETIME NOT NULL,
PRIMARY KEY (parcel_id, cost_entry_id),
KEY cost_entry_id (cost_entry_id)
) {$charset_collate};";
foreach ( $sql as $statement ) {
dbDelta( $statement );
}
@@ -283,6 +292,7 @@ class Schema {
self::table( 'work_year_config' ),
self::table( 'work_logs' ),
self::table( 'work_log_members' ),
self::table( 'parcel_cost_assignments' ),
);
foreach ( $tables as $table ) {
@@ -301,6 +311,7 @@ class Schema {
global $wpdb;
$tables = array(
self::table( 'parcel_cost_assignments' ),
self::table( 'work_log_members' ),
self::table( 'work_logs' ),
self::table( 'work_year_config' ),