以下是一个SQL查询的结果,该查询包含某些客户(CustomerID,CustomerName)和特定项目(projectid)的发票和定金。发票进行(借方)交易,并进行(贷方)交易。
因此,使用FIFO方法,我需要选择已付款,部分付款和未付款的发票。
例如对于Projectid 196500,INV-00866已付款,INV-00668已部分付款,而INV-00618未付款。
PROJECTID CUSTOMERID CUSTOMERNAME TYPE TRNDOCNO DEBIT CREDIT PROGRESSIVELY TRNDATE RANK
197386 23572 CustName A Deposit EIX-1-00654 0 730,36 0 24-JUN-19 1
197386 23572 CustName A Invoice INV-00980 730,36 0 730,36 06-MAY-19 2
197386 23572 CustName A Invoice INV-00924 3100 0 3100 02-MAY-19 3
196500 23572 CustName B Deposit EIX-1-00579 0 1600 1300 24-JUN-19 1
196500 23572 CustName B Deposit EIX-1-00565 400 2900 06-MAY-19 2
196500 23572 CustName B Deposit EIX-1-00566 0 500 3300 06-MAY-19 3
196500 23572 CustName B Invoice INV-00866 1800 0 3800 03-MAY-19 4
196500 23572 CustName B Deposit EIX-1-00558 0 500 2000 02-MAY-19 5
196500 23572 CustName B Invoice INV-00668 1500 0 2500 24-APR-19 6
196500 23572 CustName B Invoice INV-00618 1000 0 1000 22-APR-19 7