Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT
- nv.id as nota_venta_id,
- fc.id as factura_id,
- nv.num_numero_completo,
- fc.num_numero_completo,
- nv.date_order,
- fc.date_invoice,
- nv.valor_cuota as cuota_nv,
- (SELECT debit FROM account_move_line WHERE move_id = fc.move_id AND name like 'Cuota 1%' LIMIT 1) as cuota_fc
- FROM
- sale_order nv
- LEFT JOIN sale_order_invoice_rel nv_fc_rel ON nv_fc_rel.order_id = nv.id
- LEFT JOIN account_invoice fc ON nv_fc_rel.invoice_id = fc.id
- WHERE
- fc.state = 'open'
- AND nv.valor_cuota IS NOT NULL
- AND nv.valor_cuota != 0
- AND nv.valor_cuota != (SELECT debit FROM account_move_line WHERE move_id = fc.move_id AND name like 'Cuota 1%' LIMIT 1)
- AND nv.subcompania_id = 2
- AND nv.date_order >= '2016-01-01'
- order by date_invoice desc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement