Last active
June 25, 2019 02:35
-
-
Save ovnicraft/43c71b819511cd579a7f4f0853014909 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select pp.default_code, pt.name, sloc.name, sum(product_qty) filter (where spt.code = 'incoming') as incoming, sum(product_qty) filter ( where spt.code = 'outgoing') as outgoing, spt.code | |
from stock_move sm | |
inner join stock_picking_type spt on sm.picking_type_id = spt.id | |
left join stock_location sloc on sm.location_id = sloc.id | |
left join stock_location slocd on sm.location_dest_id = slocd.id | |
inner join product_product pp on pp.id = sm.product_id | |
inner join product_template pt on pt.id = pp.product_tmpl_id | |
where sm.state = 'done' | |
and inventory_id is null | |
and sm.location_id = 15 or sm.location_dest_id = 15 and sm.date_expected >= '2019-03-01: 00:00:00' and sm.date_expected <= '2019-03-31 00:00:00' | |
group by product_id, sloc.name, spt.code, pt.name, pp.default_code; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
default_code | name | name | incoming | outgoing | code | |
--------------+-----------------------------------------------------------------------------+---------+----------+----------+---------- | |
3 | ACETAMINOFEN 100MG/ML*30ML GOTAS | CLINICA | | 24.0 | outgoing | |
4 | ACETAMINOFEN 150MG/5ML*60ML JARABE | CLINICA | | 182.0 | outgoing | |
2 | ACETAMINOFEN 500 MG TABLETAS | CLINICA | | 13656.0 | outgoing | |
169 | ACETILCISTEINA 200 MG SOBRES | CLINICA | | 161.0 | outgoing | |
170 | ACETILCISTEINA 300 MG AMPOLLAS | CLINICA | | 265.0 | outgoing | |
7 | ACICLOVIR 15GR /5% UNGÜENTO | CLINICA | | 21.0 | outgoing | |
5 | ACICLOVIR 200 MG TABLETAS | CLINICA | | 105.0 | outgoing | |
6 | ACICLOVIR 800 MG TABLETAS | CLINICA | | 257.0 | outgoing | |
46 | ACIDO ACETILSALICILICO 100 MG TABLETAS | CLINICA | | 10.0 | outgoing | |
10 | ACIDO FUSIDICO 2% 15GR CREMA | CLINICA | | 23.0 | outgoing | |
10 | ACIDO FUSIDICO 2% 15GR CREMA | Vendors | 6.0 | | incoming |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment