v1.14: Steuermodul - umlegbare und nicht umlegbare Kosten nach Haus und Wohnung
This commit is contained in:
+18
-1
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
const { pool } = require('./db')
|
||||
const { users, registrationCodes, tickets, documents, threads, announcements, meters, buildings } = require('./seed-data')
|
||||
const { users, registrationCodes, tickets, documents, threads, announcements, meters, buildings, kosten } = require('./seed-data')
|
||||
const generated = require('../seed/generated.json')
|
||||
|
||||
async function seed() {
|
||||
@@ -141,3 +141,20 @@ async function seedeHaeuser() {
|
||||
}
|
||||
|
||||
module.exports = { seed, seedeZaehler, seedeHaeuser }
|
||||
|
||||
/** Kosten-Demo-Daten: idempotent – füllt die costs-Tabelle nur, wenn sie
|
||||
* leer ist (auch nachträglich auf bestehenden Datenbanken, z. B. v1.14). */
|
||||
async function seedeKosten() {
|
||||
const { rows } = await pool.query('SELECT COUNT(*)::int AS n FROM costs')
|
||||
if (rows[0].n > 0) return false
|
||||
for (const k of kosten) {
|
||||
await pool.query(
|
||||
`INSERT INTO costs (id, building, unit_id, jahr, kostenart, betrag, umlegbar, notiz, erfasst_am)
|
||||
VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9)`,
|
||||
[k.id, k.building, k.unit_id, k.jahr, k.kostenart, k.betrag, k.umlegbar, k.notiz, k.erfasst_am],
|
||||
)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
module.exports = { seed, seedeZaehler, seedeHaeuser, seedeKosten }
|
||||
|
||||
Reference in New Issue
Block a user