Advertisement
Guest User

Untitled

a guest
May 17th, 2013
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. SELECT ai.id, $3,
  2. asset_dep__straight_line_base(
  3. ai.usable_life, -- years
  4. ai.usable_life -
  5. get_fractional_year(coalesce(max(report_date),
  6. start_depreciation,
  7. purchase_date),
  8. coalesce(start_depreciation,
  9. purchase_date)),
  10. get_fractional_year(coalesce(max(report_date),
  11. start_depreciation,
  12. purchase_date),
  13. $2),
  14. purchase_value - salvage_value,
  15. coalesce(sum(l.amount), 0)),
  16. ai.department_id, ai.location_id
  17. FROM asset_item ai
  18. LEFT JOIN asset_report_line l ON (l.asset_id = ai.id)
  19. LEFT JOIN asset_report r ON (l.report_id = r.id)
  20. WHERE ai.id = ANY($1)
  21. GROUP BY ai.id, ai.start_depreciation, ai.purchase_date, ai.purchase_value,
  22. ai.salvage_value, ai.department_id, ai.location_id, ai.usable_life;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement