SELECT DISTINCT A.* FROM (SELECT a.ACCOUNTNUM, CAST(a.TRANSDATE AS date) AS transdate, a.VOUCHER, a.INVOICE, a.CURRENCYCODE, a.TXT, c.NAME, CAST(a.DUEDATE AS date) AS duedate, d.CUSTGROUP, a.AMOUNTCUR, a.SETTLEAMOUNTCUR, a.SETTLEAMOUNTMST, a.SETTLEAMOUNTMST AS ORIGSETTELEMST, a.AMOUNTMST, d.CREDITMAX, a.LASTSETTLEVOUCHER, f.INVOICEID AS lastsettleinvoice, a.TRANSTYPE, a.EXCHADJUSTMENT AS SELISIHKURS, CASE WHEN A.AMOUNTMST < 0 THEN A.AMOUNTMST ELSE 0 END AS MSTCREDIT, CASE WHEN A.AMOUNTCUR < 0 THEN A.AMOUNTCUR ELSE 0 END AS CURCREDIT, CASE WHEN A.AMOUNTMST > 0 THEN A.AMOUNTMST ELSE 0 END AS MSTDEBET, CASE WHEN A.AMOUNTCUR > 0 THEN A.AMOUNTCUR ELSE 0 END AS CURDEBET, CASE WHEN a.AMOUNTMST - a.SETTLEAMOUNTMST <> 0 THEN a.AMOUNTMST - a.SETTLEAMOUNTMST + a.EXCHADJUSTMENT ELSE a.AMOUNTMST - a.SETTLEAMOUNTMST END AS SISA, CASE WHEN A.CURRENCYCODE <> 'AUD' THEN a.AMOUNTCUR - a.SETTLEAMOUNTCUR ELSE 0 END AS SISACUR, CASE WHEN LEFT(A.VOUCHER, 4) <> 'CINV' THEN A.VOUCHER ELSE '' END AS REFERENSI , CASE WHEN LEFT(A.INVOICE ,3) IN( 'FTX', 'CFT','NK/','ND/') and LEFT(A.INVOICE ,3) not IN( 'SCN') THEN 'FREETEXT' ELSE CASE WHEN SUBSTRING(A.INVOICE,2,2)='KR' THEN 'PAYMENT' ELSE CASE WHEN LEFT(A.INVOICE ,3) IN( 'SCN') THEN 'RETURN' ELSE CASE WHEN LEFT(A.VOUCHER ,4) IN ('15TM','16TM','ARME') THEN 'PAYMENT' ELSE CASE WHEN A.AMOUNTMST > 0 AND LEFT(A.INVOICE ,3)NOT IN( 'FTX', 'CFT', 'SCN','NK/','ND/') AND LEFT(A.VOUCHER ,4) NOT IN ('15TM','16TM','ARME') AND SUBSTRING(A.INVOICE,2,2)<>'KR' THEN 'PENJUALAN' --ELSE CASE WHEN A.AMOUNTMST > 0 AND LEFT(A.INVOICE ,3)NOT IN( 'FTX', 'CFT', 'SCN','NK/','ND/') AND LEFT(A.VOUCHER ,4) IN ('15TM','16TM','ARME') THEN 'PAYMENT' ELSE CASE WHEN A.AMOUNTMST < 0 AND LEFT(A.INVOICE ,3) NOT IN( 'FTX', 'CFT','SCN','NK/','ND/') THEN 'PAYMENT' END END END END END END REPORT_POST ,a.RECID FROM CUSTTRANS AS a LEFT OUTER JOIN CUSTTABLE AS b ON a.ACCOUNTNUM = b.ACCOUNTNUM LEFT OUTER JOIN DIRPARTYTABLE AS c ON b.PARTY = c.RECID LEFT OUTER JOIN CUSTTABLE AS d ON a.ACCOUNTNUM = d.ACCOUNTNUM LEFT OUTER JOIN CUSTINVOICEJOUR AS f ON a.LASTSETTLEVOUCHER = f.LEDGERVOUCHER LEFT OUTER JOIN)) AMsg 102, Level 15, State 1, Line 24
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Most Valuable Expert award recognizes technology experts who passionately share their knowledge with the community, demonstrate the core values of this platform, and go the extra mile in all aspects of their contributions. This award is based off of nominations by EE users and experts. Multiple MVEs may be awarded each year.
This award recognizes a member of Experts Exchange who has made outstanding contributions to the community within their first year as an expert. The Rookie of the Year is awarded to a new expert who has the highest number of quality contributions.