Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. SELECT
  2. nv.id as nota_venta_id,
  3. fc.id as factura_id,
  4. nv.num_numero_completo,
  5. fc.num_numero_completo,
  6. nv.date_order,
  7. fc.date_invoice,
  8. nv.valor_cuota as cuota_nv,
  9. (SELECT debit FROM account_move_line WHERE move_id = fc.move_id AND name like 'Cuota 1%' LIMIT 1) as cuota_fc
  10. FROM
  11. sale_order nv
  12. LEFT JOIN sale_order_invoice_rel nv_fc_rel ON nv_fc_rel.order_id = nv.id
  13. LEFT JOIN account_invoice fc ON nv_fc_rel.invoice_id = fc.id
  14. WHERE
  15. fc.state = 'open'
  16. AND nv.valor_cuota IS NOT NULL
  17. AND nv.valor_cuota != 0
  18. AND nv.valor_cuota != (SELECT debit FROM account_move_line WHERE move_id = fc.move_id AND name like 'Cuota 1%' LIMIT 1)
  19. AND nv.subcompania_id = 2
  20. AND nv.date_order >= '2016-01-01'
  21. order by date_invoice desc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement