【发布时间】:2021-06-29 17:36:26
【问题描述】:
如何选择 no_inv、total_unpaid、total_paid with order per month 和 sum(total_unpaid & total_paid)在 Laravel Query Builder 中获取更多信息,我正在使用 Laravel 8。
我对这个双重查询及其条件感到困惑
发票表:
no_inv | date_inv | total_unpaid | total_paid | note
INV-1 | 2021-01-01 | 100 | 50 | Half Payment of Invoice :
INV-2 | 2021-01-02 | 200 | 0 | Bill of :
INV-3 | 2021-01-03 | 300 | 200 | Half Payment of Invoice :
INV-4 | 2021-02-01 | 400 | 400 | Full Payment of Invoice :
INV-5 | 2015-02-02 | 500 | 400 | Half Payment of Invoice :
The results I expected :
2021-01-01 | Bill of INV-1 `before the total paid` | (-100) `total_unpaid`
2021-01-01 | Half Payment of Invoice : INV-1 `if total_paid > 0 will double column payment like this same as above` | (+50) `total_unpaid`
2021-01-02 | Bill of : INV-2 `if total_paid < 0 not double column as above` | (-200)
2021-01-03 | Bill of INV-3 | (-400) |
2021-01-03 | Bill of INV-3 | (+200) |
2021-02-01 | Bill of INV-4 | (-400) |
2021-02-01 | Full Payment of INV-4 | (+400) |
2015-02-02 | Bill of INV-5 | (-500)
2015-02-02 | Half Payment of INV-5 | (+500)
【问题讨论】: