Overview
Comment:Same view as in schema
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | templates
Files: files | file ages | folders
SHA3-256: fdd813f663bdac4f469ec5cce97da143489c298ee163f932304a135d324e7a26
User & Date: bohwaz on 2021-12-21 01:34:20
Other Links: branch diff | manifest | tags
Context
2021-12-21
01:54
Fix upgrade check-in: 2074137b44 user: bohwaz tags: templates
01:34
Same view as in schema check-in: fdd813f663 user: bohwaz tags: templates
01:33
Remove old stuff check-in: e3dc7d4a92 user: bohwaz tags: templates
Changes

Modified src/include/data/1.2.0_migration.sql from [e2dba85b78] to [5ff21685b0].

11
12
13
14
15
16
17
18
19
20
21
22

-- Balance des comptes par exercice
CREATE VIEW IF NOT EXISTS acc_accounts_sums
AS
    SELECT t.id_year, a.id, a.label, a.code, a.position,
        SUM(l.credit) AS credit,
        SUM(l.debit) AS debit,
        SUM(l.credit - l.debit) AS balance
    FROM acc_accounts a
    LEFT JOIN acc_transactions_lines l ON l.id_account = a.id
    LEFT JOIN acc_transactions t ON t.id = l.id_transaction
    GROUP BY t.id_year, a.id;







|




11
12
13
14
15
16
17
18
19
20
21
22

-- Balance des comptes par exercice
CREATE VIEW IF NOT EXISTS acc_accounts_sums
AS
    SELECT t.id_year, a.id, a.label, a.code, a.position,
        SUM(l.credit) AS credit,
        SUM(l.debit) AS debit,
        CASE WHEN a.position IN (4, 1) THEN SUM (l.debit - l.credit) ELSE SUM(l.credit - l.debit)  END AS balance
    FROM acc_accounts a
    LEFT JOIN acc_transactions_lines l ON l.id_account = a.id
    LEFT JOIN acc_transactions t ON t.id = l.id_transaction
    GROUP BY t.id_year, a.id;