38 lines
1.1 KiB
SQL
38 lines
1.1 KiB
SQL
SELECT
|
|
txn.id,
|
|
txn.timestamp,
|
|
txn.added_at,
|
|
txn.amount,
|
|
txn.currency,
|
|
txn.description,
|
|
txn.internal_transfer,
|
|
|
|
txn.vendor_id,
|
|
vendor.name,
|
|
|
|
txn.category_id,
|
|
category.name,
|
|
category.color,
|
|
|
|
account_credit.id,
|
|
account_credit.name,
|
|
account_credit.type,
|
|
account_credit.number_suffix,
|
|
|
|
account_debit.id,
|
|
account_debit.name,
|
|
account_debit.type,
|
|
account_debit.number_suffix,
|
|
|
|
GROUP_CONCAT(tags.tag)
|
|
FROM "transaction" txn
|
|
LEFT JOIN transaction_vendor vendor ON vendor.id = txn.vendor_id
|
|
LEFT JOIN transaction_category category ON category.id = txn.category_id
|
|
LEFT JOIN account_journal_entry j_credit
|
|
ON j_credit.transaction_id = txn.id AND UPPER(j_credit.type) = 'CREDIT'
|
|
LEFT JOIN account account_credit ON account_credit.id = j_credit.account_id
|
|
LEFT JOIN account_journal_entry j_debit
|
|
ON j_debit.transaction_id = txn.id AND UPPER(j_debit.type) = 'DEBIT'
|
|
LEFT JOIN account account_debit ON account_debit.id = j_debit.account_id
|
|
LEFT JOIN transaction_tag tags ON tags.transaction_id = txn.id
|
|
GROUP BY txn.id |