Skip to content

Commit

Permalink
improvement: separated invoice postitions for assignments (#506)
Browse files Browse the repository at this point in the history
  • Loading branch information
chilek authored Mar 20, 2018
1 parent 36673f0 commit 151880a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions bin/lms-payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,8 @@ function get_period($period) {
FROM assignments a
JOIN customers c ON (a.customerid = c.id)
JOIN (
SELECT ROUND(sum(price), 2) AS value, va.ownerid AS customerid
SELECT ROUND(sum(price), 2) AS value, va.ownerid AS customerid,
a2.id AS assignmentid
FROM voip_cdr vc
JOIN voipaccounts va ON vc.callervoipaccountid = va.id
JOIN voip_numbers vn ON vn.voip_account_id = va.id AND vn.phone = vc.caller
Expand All @@ -419,8 +420,8 @@ function get_period($period) {
WHEN ' . MONTHLY . ' THEN ' . mktime(0, 0, 0, $month, 0, $year) . '
WHEN ' . DISPOSABLE . ' THEN ' . ($currtime + 86400) . "
END)
GROUP BY va.ownerid
) voipcost ON voipcost.customerid = a.customerid
GROUP BY va.ownerid, a2.id
) voipcost ON voipcost.customerid = a.customerid AND voipcost.assignmentid = a.id
LEFT JOIN tariffs t ON (a.tariffid = t.id)
LEFT JOIN divisions d ON (d.id = c.divisionid)
WHERE
Expand Down

0 comments on commit 151880a

Please sign in to comment.