what is the amount_linked field in the transaction...
# ask-stanley-ai
r
what is the amount_linked field in the transactionaccountingline table meant to represent?
c
AI generated answer (using internal Slack threads):
The
amount_linked
field in the
transactionaccountingline
table represents the amount that has been linked from one transaction to another. This is typically used in the context of linked transactions, such as when an invoice is paid. The
amount_linked
field would then represent the amount of the payment that has been applied to the invoice. In the provided SQL query, the
amount_linked
field is used to calculate the remaining amount on a transaction after payments have been applied. The query subtracts the sum of the
amount_linked
from the original transaction amount to get the remaining balance. This is done for both the original transaction and any linked payment transactions. Here is the relevant part of the SQL query:
Copy code
sql
SELECT 
  MAX(d.amount) - SUM(CASE WHEN tl.amount_linked IS NULL OR tlp.ending IS NULL THEN 0.00 ELSE tl.amount_linked END) + SUM(CASE WHEN lt.amount_linked IS NULL OR ltp.ending IS NULL THEN 0.00 ELSE lt.amount_linked END) AS [Amount]
...
FROM 
  "Company".Administrator.transaction_lines d
   ...
   LEFT JOIN
  "Company".Administrator.transaction_links tl ON d.transaction_id = tl.original_transaction_id AND d.transaction_line_id = tl.original_transaction_line_id AND tl.link_type='Payment'
   ...
   LEFT JOIN
  "Company".Administrator.transaction_links lt ON d.transaction_id = lt.applied_transaction_id AND d.transaction_line_id = lt.applied_transaction_line_id AND lt.link_type='Payment'
   ...
In this query,
tl.amount_linked
and
lt.amount_linked
represent the amount linked from the original transaction (
d
) to the payment transactions (
tl
and
lt
). ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.80645752
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.796142638
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.794555664
Please provide your feedback on this answer.