Skip to content

Instantly share code, notes, and snippets.

@ofelix03
Last active September 6, 2021 07:55
Show Gist options
  • Select an option

  • Save ofelix03/df6238736de88b6a10233db47a3a71e5 to your computer and use it in GitHub Desktop.

Select an option

Save ofelix03/df6238736de88b6a10233db47a3a71e5 to your computer and use it in GitHub Desktop.
Example: Table Joins With ON
SELECT ie.name "invoice_number",
pj.name "payment_journal",
apr.amount "reconciliation_amount"
FROM account_move_line iel --- invoice entry line
INNER JOIN account_move ie --- invoice entry
ON iel.move_id = ie.id
INNER JOIN account_partial_reconcile apr
ON apr.debit_move_id = iel.id
INNER JOIN account_move_line pel --- payment entry line
ON apr.credit_move_id = pel.id
INNER JOIN account_move pe --- payment entry
ON pel.move_id = pe.id
INNER JOIN account_journal pj --- journal
ON pj.id = pel.journal_id
WHERE ie.move_type = 'out_invoice'
AND iel.analytic_account_id = 2443
AND ie.name = 'INV/2021/2344'
ORDER BY ie.name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment