feat(orders): implement order ingestion pipeline, review ratings schema, and [Family] exclusion
This commit is contained in:
@@ -71,12 +71,19 @@ export const myShare = (participant = "$1") => `COALESCE(
|
||||
export const mySplitOf = (base: string, participant = "$1") =>
|
||||
`((${base}) * ${myShare(participant)} / 100)`;
|
||||
|
||||
export const NON_BUDGET_TAGS = ['family'];
|
||||
|
||||
export const EXCLUDE_NON_BUDGET_TAGS = `NOT EXISTS (
|
||||
SELECT 1 FROM transaction_tags tt JOIN tags tg ON tg.id = tt.tag_id
|
||||
WHERE tt.transaction_id = t.id AND tg.name = ANY(ARRAY['family'])
|
||||
)`;
|
||||
|
||||
/**
|
||||
* Predicate excluding categories that are not spend.
|
||||
* Predicate excluding categories and tags that are not spend.
|
||||
* The COALESCE matters: a bare `category NOT IN (...)` evaluates to NULL for
|
||||
* uncategorised rows, which silently drops them from spend totals.
|
||||
*/
|
||||
export const EXCLUDE_NON_SPEND = `${EFFECTIVE_CATEGORY} NOT IN ('transfers', 'investment', 'income')`;
|
||||
export const EXCLUDE_NON_SPEND = `${EFFECTIVE_CATEGORY} NOT IN ('transfers', 'investment', 'income') AND ${EXCLUDE_NON_BUDGET_TAGS}`;
|
||||
|
||||
/**
|
||||
* Rows that count towards NET spend — outgoings plus the refunds that cancel
|
||||
|
||||
Reference in New Issue
Block a user