SAP Business One SDK Support

How to get Net Balance of A/R Down Payment Invoice?

Down payment  available net value can be fetch from  DPI15 A/R DP - Drawn Dpm Applied Table; Check the column [DpApplNet] - Dpm Appl Net LC;

Once linked to invoice level, Document Line table 9(eg. INV9) have the details of Down payment linked Invoice. Filed
DrawnSum have the down payment value used in the Invoice. So if user minus the value from the 
DocTotal of Down paymnet and DrawSum, will get the net amount in the Down Payment.
 
SELECT 
  T0.DocNum,
  T0.DocDueDate,
  T0.CardName,
  T1.Dscription,
  T0.DocTotal,
  T2.BaseAbs,
  T2.DrawnSum + T3.DiscSum AS DrawnSum,
  T3.DocDate,
  T3.DocEntry,
  T6.DocNum as DocCheck,
  T5.DocDueDate as DateCheck,
  T6.CheckNum
FROM
  dbo.ODPI T0
  INNER JOIN dbo.DPI1 T1 ON (T0.DocEntry = T1.DocEntry)
  LEFT OUTER JOIN dbo.INV9 T2 ON (T1.DocEntry = T2.BaseAbs)
  LEFT OUTER JOIN dbo.OINV T3 ON (T2.DocEntry = T3.DocEntry)
  LEFT OUTER JOIN dbo.INV1 T4 ON (T3.DocEntry = T4.DocEntry)
  LEFT OUTER JOIN dbo.OVPM T5 ON (T3.ReceiptNum = T5.DocNum)
  LEFT OUTER JOIN dbo.VPM1 T6 ON (T5.DocNum = T6.DocNum)
WHERE
  T0.CardName = [%0] AND 
  T0.DocDueDate BETWEEN [%1] AND [%2] AND 
 (T4.TargetType = -1 OR T4.TargetType IS NULL)  AND T1.TargetType <> 19

GROUP BY
  T0.DocNum,
  T0.DocDueDate,
  T0.CardName,
  T1.Dscription,
  T0.DocTotal,
  T2.BaseAbs,
  T2.DrawnSum,
  T3.DocDate,
  T3.DocEntry,
  T6.DocNum,
  T5.DocDueDate,
  T6.CheckNum,
  T3.DiscSum
  
  ORDER BY 
   T0.DocNum,
   T3.DocEntry
Source : SCN.SDK 

No comments: