Feature: is_mandatory Flag für Kostenpositionstypen

- Neue Spalte wp_kgvvm_cost_entries.is_mandatory (TINYINT, default 1)
- Kostenposten können jetzt als 'verpflichtend' oder 'manuell/optional' gekennzeichnet werden
- Validator: sanitize_cost_entry() und validate_cost_entry() aktualisiert
- CostRepository.save(): is_mandatory wird gespeichert
- Admin: Checkbox 'Verpflichtende Position' in der Kostenposten-Form hinzugefügt
- Datenbank: ALTER TABLE durchgeführt für existierende Instanzen
This commit is contained in:
2026-04-17 17:02:13 +02:00
parent 6602a56a1c
commit 1e739cfd3f
4 changed files with 16 additions and 2 deletions

View File

@@ -93,11 +93,12 @@ class CostRepository extends AbstractRepository {
'distribution_type' => isset( $data['distribution_type'] ) ? $data['distribution_type'] : 'parcel',
'unit_amount' => isset( $data['unit_amount'] ) ? (float) $data['unit_amount'] : 0,
'total_cost' => (float) $data['total_cost'],
'is_mandatory' => isset( $data['is_mandatory'] ) ? (int) (bool) $data['is_mandatory'] : 1,
'note' => $data['note'],
'updated_at' => $this->now(),
);
$formats = array( '%d', '%s', '%s', '%f', '%f', '%s', '%s' );
$formats = array( '%d', '%s', '%s', '%f', '%f', '%d', '%s', '%s' );
$this->ensure_year( $payload['entry_year'] );
@@ -107,7 +108,7 @@ class CostRepository extends AbstractRepository {
}
$payload['created_at'] = $this->now();
$this->wpdb->insert( $this->table, $payload, array( '%d', '%s', '%s', '%f', '%f', '%s', '%s', '%s' ) );
$this->wpdb->insert( $this->table, $payload, array( '%d', '%s', '%s', '%f', '%f', '%d', '%s', '%s', '%s' ) );
return $this->wpdb->insert_id;
}