Syput

MUTASI GJ

Mar 26th, 2022 (edited)
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 28.94 KB | None | 0 0
  1. SELECT x.i_product_group as i_product, x.satuan, sum(x.saldoawal) as saldoawal,
  2. sum(x.git_sjint_kawal) as git_sjint_kawal, sum(x.git_sjint_rollkawal) as git_sjint_rollkawal,
  3. sum(x.git_retur_kawal) as git_retur_kawal,sum(x.git_manu_kawal )as git_manu_kawal,
  4. sum(x.git_sjint_awal) as git_sjint_awal, sum(x.git_sjint_rollawal) as git_sjint_rollawal,
  5. sum(x.git_retur_awal) as git_retur_awal,sum(x.git_manu_awal) as git_manu_awal,
  6. sum(x.sjint_in) as sjint_in, sum(x.sjint_inroll) as sjint_inroll,
  7. sum(x.retur_in) as retur_in, sum(x.n_manu_in) as n_manu_in,sum(x.convertion_in) as convertion_in,
  8. sum(x.convertion_out)as convertion_out, sum(x.sjint_out_roll) as sjint_out_roll,
  9. sum(x.sjint_out) as sjint_out,sum(x.manu_out) as manu_out, sum(x.retur) as retur,
  10. sum(x.git_sjint_out) as git_sjint_out, sum(x.git_sjint_outroll) as git_sjint_outroll,sum(x.git_manu) as git_manu,
  11. sum(x.git_retur) as git_retur, sum(x.stockopname) as stockopname,
  12. 'GJ' as n_store
  13.  
  14. from(
  15.  
  16. -- DO IN
  17. select a.i_product_group, b.e_satuan_name as satuan, sum(b.n_deliver) as do_in, 0 as convertion_in, 0 as convertion_out, 0 as sjint_out, 0 as retur, 0 as git_sjint_out, 0 as git_retur, 0 as git_sjint_kawal, 0 as git_retur_kawal, 0 as git_sjint_awal, 0 as git_retur_awal, 0 as saldoawal, 0 as stockopname, 0 as sjint_out_roll, 0 as git_sjint_rollkawal, 0 as git_sjint_rollawal, 0 as git_sjint_outroll, 0 as retur_in, 0 as sjint_in, 0 as sjint_inroll, 0 as n_manu_in, 0 as manu_out, 0 as git_manu,0 as git_manu_kawal, 0 as git_manu_awal
  18. from tr_product_stock_produksi a
  19. left join tm_do_item b on(a.i_product=b.i_product)
  20. left join tm_do c on(b.i_do=c.i_do)
  21. where to_char(b.d_do, 'yyyymm')='202203'
  22. and b.i_store='GJ'
  23. and c.f_do_cancel='f'
  24. group by a.i_product_group, b.e_satuan_name
  25.  
  26. union all -- RETUR IN
  27.  
  28. select a.i_product, d.e_satuan_name as satuan, 0 as do_in, 0 as convertion_in, 0 as sjint_out, 0 as convertion_out, 0 as retur, 0 as git_sjint_out, 0 as git_retur, 0 as git_sjint_kawal, 0 as git_retur_kawal, 0 as git_sjint_awal, 0 as git_retur_awal, 0 as saldoawal, 0 as stockopname, 0 as sjint_out_roll, 0 as git_sjint_rollkawal, 0 as git_sjint_rollawal, 0 as git_sjint_outroll, sum(b.n_quantity_int_receive) as retur_in, 0 as sjint_in, 0 as sjint_inroll, 0 as n_manu_in, 0 as manu_out, 0 as git_manu,0 as git_manu_kawal, 0 as git_manu_awal
  29. from tr_product_stock_produksi a
  30. left join tm_sj_int_item b on(a.i_product=b.i_product)
  31. left join tm_sj_int c on(b.i_sjint=c.i_sjint)
  32. left join tr_product_satuan d on(a.i_product=d.i_product)
  33. where c.f_sjint_cancel='f'
  34. and c.f_sjint_retur='t'
  35. and to_char(c.d_sjint_receive, 'yyyymm')='202203'
  36. and not c.d_sjint_receive isnull
  37. and a.f_product_cancel='f'
  38. and c.i_store_to='GJ'
  39.  
  40. group by a.i_product, d.e_satuan_name
  41.  
  42. union all -- SJINT IN
  43.  
  44. select a.i_product_group, d.e_satuan_name as satuan, 0 as do_in, 0 as convertion_in, 0 as convertion_out, 0 as sjint_out, 0 as retur, 0 as git_sjint_out, 0 as git_retur, 0 as git_sjint_kawal, 0 as git_retur_kawal, 0 as git_sjint_awal, 0 as git_retur_awal, 0 as saldoawal, 0 as stockopname, 0 as sjint_out_roll, 0 as git_sjint_rollkawal, 0 as git_sjint_rollawal, 0 as git_sjint_outroll, 0 as retur_in, sum(b.n_quantity_int_receive) as sjint_in, 0 as sjint_inroll, 0 as n_manu_in, 0 as manu_out, 0 as git_manu,0 as git_manu_kawal, 0 as git_manu_awal
  45. from tr_product_stock_produksi a
  46. left join tm_sj_int_item b on(a.i_product=b.i_product)
  47. left join tm_sj_int c on(b.i_sjint=c.i_sjint)
  48. left join tr_product_satuan d on(a.i_product=d.i_product)
  49. where c.f_sjint_cancel='f'
  50. and c.f_sjint_retur='f'
  51. and to_char(c.d_sjint_receive, 'yyyymm')='202203'
  52. and not c.d_sjint_receive isnull
  53. and a.f_product_cancel='f'
  54. and c.f_convertion_product='f'
  55. and c.i_store_to='GJ'
  56. group by a.i_product_group, d.e_satuan_name
  57.  
  58. union all -- SJINT ROLL IN
  59.  
  60. select a.i_product_group, d.e_satuan_name as satuan, 0 as do_in, 0 as convertion_in, 0 as convertion_out, 0 as sjint_out, 0 as retur, 0 as git_sjint_out, 0 as git_retur, 0 as git_sjint_kawal, 0 as git_retur_kawal, 0 as git_sjint_awal, 0 as git_retur_awal, 0 as saldoawal, 0 as stockopname, 0 as sjint_out_roll, 0 as git_sjint_rollkawal, 0 as git_sjint_rollawal, 0 as git_sjint_outroll, 0 as retur_in, 0 as sjint_in, sum(b.n_quantity_int_receive) as sjint_inroll, 0 as n_manu_in, 0 as manu_out, 0 as git_manu,0 as git_manu_kawal, 0 as git_manu_awal
  61. from tr_product_stock_produksi a
  62. left join tm_sj_int_item b on(a.i_product=b.i_product)
  63. left join tm_sj_int c on(b.i_sjint=c.i_sjint)
  64. left join tr_product_satuan d on(a.i_product=d.i_product)
  65. where c.f_sjint_cancel='f'
  66. and c.f_sjint_retur='f'
  67. and to_char(c.d_sjint_receive, 'yyyymm')='202203'
  68. and not c.d_sjint_receive isnull
  69. and a.f_product_cancel='f'
  70. and c.f_convertion_product='t'
  71. and c.i_store_to='GJ'
  72. group by a.i_product_group, d.e_satuan_name
  73.  
  74. union all --CONV IN
  75.  
  76. select a.i_product_group, b.e_satuan_name as satuan, 0 as do_in, sum(b.n_ic_convertion) as convertion_in, 0 as convertion_out, 0 as sjint_out, 0 as retur, 0 as git_sjint_out, 0 as git_retur, 0 as git_sjint_kawal, 0 as git_retur_kawal, 0 as git_sjint_awal, 0 as git_retur_awal, 0 as saldoawal, 0 as stockopname, 0 as sjint_out_roll, 0 as git_sjint_rollkawal, 0 as git_sjint_rollawal, 0 as git_sjint_outroll, 0 as retur_in, 0 as sjint_in, 0 as sjint_inroll, 0 as n_manu_in, 0 as manu_out, 0 as git_manu,0 as git_manu_kawal, 0 as git_manu_awal
  77. from tr_product_stock_produksi a
  78. left join tm_ic_convertionitem b on(a.i_product=b.i_product)
  79. left join tm_ic_convertion c on(b.i_ic_convertion=c.i_ic_convertion)
  80. where c.f_ic_convertioncancel='f'
  81. and a.f_product_cancel='f'
  82. and to_char(d_ic_convertion, 'yyyymm')='202203'
  83. and b.i_store='GJ'
  84. group by a.i_product_group, b.e_satuan_name
  85.  
  86.  
  87. union all -- CONV OUT
  88.  
  89. select a.i_product_group, b.e_satuan_name_from as satuan, 0 as do_in, 0 as convertion_in, sum(b.n_ic_convertion_from) as convertion_out, 0 as sjint_out, 0 as retur, 0 as git_sjint_out, 0 as git_retur, 0 as git_sjint_kawal, 0 as git_retur_kawal, 0 as git_sjint_awal, 0 as git_retur_awal, 0 as saldoawal, 0 as stockopname, 0 as sjint_out_roll, 0 as git_sjint_rollkawal, 0 as git_sjint_rollawal, 0 as git_sjint_outroll, 0 as retur_in, 0 as sjint_in, 0 as sjint_inroll, 0 as n_manu_in, 0 as manu_out, 0 as git_manu,0 as git_manu_kawal, 0 as git_manu_awal
  90. from tr_product_stock_produksi a
  91. left join tm_ic_convertionitem b on(a.i_product=b.i_product)
  92. left join tm_ic_convertion c on(b.i_ic_convertion=c.i_ic_convertion)
  93. where c.f_ic_convertioncancel='f'
  94. and a.f_product_cancel='f'
  95. and b.i_store='GJ'
  96. and to_char(d_ic_convertion, 'yyyymm')='202203'
  97. group by a.i_product_group, b.e_satuan_name_from
  98.  
  99. union all -- SJINT OUT
  100.  
  101. select a.i_product, d.e_satuan_name as satuan, 0 as do_in, 0 as convertion_in, 0 as convertion_out, sum(b.n_quantity_int_receive) as sjint_out, 0 as retur, 0 as git_sjint_out, 0 as git_retur, 0 as git_sjint_kawal, 0 as git_retur_kawal, 0 as git_sjint_awal, 0 as git_retur_awal, 0 as saldoawal, 0 as stockopname, 0 as sjint_out_roll, 0 as git_sjint_rollkawal, 0 as git_sjint_rollawal, 0 as git_sjint_outroll, 0 as retur_in, 0 as sjint_in, 0 as sjint_inroll, 0 as n_manu_in, 0 as manu_out, 0 as git_manu,0 as git_manu_kawal, 0 as git_manu_awal
  102. from tr_product_stock_produksi a
  103. left join tm_sj_int_item b on(a.i_product=b.i_product)
  104. left join tm_sj_int c on(b.i_sjint=c.i_sjint)
  105. left join tr_product_satuan d on(a.i_product=d.i_product)
  106. where c.f_sjint_cancel='f'
  107. and c.f_sjint_retur='f'
  108. and to_char(c.d_sjint_receive, 'yyyymm')='202203'
  109. and not c.d_sjint_receive isnull
  110. and a.f_product_cancel='f'
  111. and c.f_convertion_product='f'
  112. and c.i_store_from='GJ'
  113. group by a.i_product, d.e_satuan_name
  114.  
  115. union all -- SJINT ROLL OUT
  116.  
  117. select a.i_product_group, d.e_satuan_name as satuan, 0 as do_in, 0 as convertion_in, 0 as convertion_out, 0 as sjint_out, 0 as retur, 0 as git_sjint_out, 0 as git_retur, 0 as git_sjint_kawal, 0 as git_retur_kawal, 0 as git_sjint_awal, 0 as git_retur_awal, 0 as saldoawal, 0 as stockopname, sum(b.n_quantity_int_receive) as sjint_out_roll, 0 as git_sjint_rollkawal, 0 as git_sjint_rollawal, 0 as git_sjint_outroll, 0 as retur_in, 0 as sjint_in, 0 as sjint_inroll, 0 as n_manu_in, 0 as manu_out, 0 as git_manu,0 as git_manu_kawal, 0 as git_manu_awal
  118. from tr_product_stock_produksi a
  119. left join tm_sj_int_item b on(a.i_product=b.i_product)
  120. left join tm_sj_int c on(b.i_sjint=c.i_sjint)
  121. left join tr_product_satuan d on(a.i_product=d.i_product)
  122. where c.f_sjint_cancel='f'
  123. and c.f_sjint_retur='f'
  124. and to_char(c.d_sjint_receive, 'yyyymm')='202203'
  125. and not c.d_sjint_receive isnull
  126. and a.f_product_cancel='f'
  127. and c.i_store_from='GJ'
  128. and c.f_convertion_product='t'
  129. group by a.i_product_group, d.e_satuan_name
  130.  
  131.  
  132. union all -- RETUR
  133.  
  134. select a.i_product_group, d.e_satuan_name as satuan, 0 as do_in, 0 as convertion_in, 0 as sjint_out, 0 as convertion_out, sum(b.n_quantity_int_receive) as retur, 0 as git_sjint_out, 0 as git_retur, 0 as git_sjint_kawal, 0 as git_retur_kawal, 0 as git_sjint_awal, 0 as git_retur_awal, 0 as saldoawal, 0 as stockopname, 0 as sjint_out_roll, 0 as git_sjint_rollkawal, 0 as git_sjint_rollawal, 0 as git_sjint_outroll, 0 as retur_in, 0 as sjint_in, 0 as sjint_inroll, 0 as n_manu_in, 0 as manu_out, 0 as git_manu,0 as git_manu_kawal, 0 as git_manu_awal
  135. from tr_product_stock_produksi a
  136. left join tm_sj_int_item b on(a.i_product=b.i_product)
  137. left join tm_sj_int c on(b.i_sjint=c.i_sjint)
  138. left join tr_product_satuan d on(a.i_product=d.i_product)
  139. where c.f_sjint_cancel='f'
  140. and c.f_sjint_retur='t'
  141. and to_char(b.d_sjint, 'yyyymm')='202203'
  142. and not c.d_sjint_receive isnull
  143. and a.f_product_cancel='f'
  144. and c.i_store_from='GJ'
  145.  
  146. group by a.i_product_group, d.e_satuan_name
  147.  
  148.  
  149. union all -- GIT SJINT OUT
  150.  
  151. select a.i_product, d.e_satuan_name as satuan, 0 as do_in, 0 as convertion_in, 0 as sjint_out, 0 as convertion_out, 0 as retur, sum(b.n_quantity_int) as git_sjint_out, 0 as git_retur, 0 as git_sjint_kawal, 0 as git_retur_kawal, 0 as git_sjint_awal, 0 as git_retur_awal, 0 as saldoawal, 0 as stockopname, 0 as sjint_out_roll, 0 as git_sjint_rollkawal, 0 as git_sjint_rollawal, 0 as git_sjint_outroll, 0 as retur_in, 0 as sjint_in, 0 as sjint_inroll, 0 as n_manu_in, 0 as manu_out, 0 as git_manu,0 as git_manu_kawal, 0 as git_manu_awal
  152. from tr_product_stock_produksi a
  153. left join tm_sj_int_item b on(a.i_product=b.i_product)
  154. left join tm_sj_int c on(b.i_sjint=c.i_sjint)
  155. left join tr_product_satuan d on(a.i_product=d.i_product)
  156. where c.f_sjint_cancel ='f'
  157. and c.f_sjint_retur='f'
  158. and c.i_store_from='GJ'
  159. and c.f_convertion_product='f'
  160. --- tanggal receive null dan sj pada periode berjalan
  161. --- atau periode receive melebihi bulan berjalan dan tanggal sj periode sekarang
  162. and (
  163. (c.d_sjint_receive isnull and (to_char(c.d_sjint, 'yyyymm'::text)='202203'))
  164. or ((to_char(c.d_sjint_receive, 'yyyymm'::text)>'202203' and to_char(c.d_sjint, 'yyyymm'::text) = '202203'))
  165. )
  166.  
  167. group by a.i_product, d.e_satuan_name
  168.  
  169. union all -- GIT SJINT OUT ROLL
  170.  
  171. select a.i_product_group, d.e_satuan_name as satuan, 0 as do_in, 0 as convertion_in, 0 as sjint_out, 0 as convertion_out, 0 as retur, 0 as git_sjint_out, 0 as git_retur, 0 as git_sjint_kawal, 0 as git_retur_kawal, 0 as git_sjint_awal, 0 as git_retur_awal, 0 as saldoawal, 0 as stockopname, 0 as sjint_out_roll, 0 as git_sjint_rollkawal, 0 as git_sjint_rollawal, sum(b.n_quantity_int) as git_sjint_outroll, 0 as retur_in, 0 as sjint_in, 0 as sjint_inroll, 0 as n_manu_in, 0 as manu_out, 0 as git_manu,0 as git_manu_kawal, 0 as git_manu_awal
  172. from tr_product_stock_produksi a
  173. left join tm_sj_int_item b on(a.i_product=b.i_product)
  174. left join tm_sj_int c on(b.i_sjint=c.i_sjint)
  175. left join tr_product_satuan d on(a.i_product=d.i_product)
  176. where c.f_sjint_cancel ='f'
  177. and c.f_sjint_retur='f'
  178. and c.i_store_from='GJ'
  179. and c.f_convertion_product='t'
  180. --- tanggal receive null dan sj pada periode berjalan
  181. --- atau periode receive melebihi bulan berjalan dan tanggal sj periode sekarang
  182. and (
  183. (c.d_sjint_receive isnull and (to_char(c.d_sjint, 'yyyymm'::text)='202203'))
  184. or ((to_char(c.d_sjint_receive, 'yyyymm'::text)>'202203' and to_char(c.d_sjint, 'yyyymm'::text) = '202203'))
  185. )
  186.  
  187. group by a.i_product_group, d.e_satuan_name
  188.  
  189.  
  190. union all -- GIT RETUR
  191.  
  192. select a.i_product_group, d.e_satuan_name as satuan, 0 as do_in, 0 as convertion_in, 0 as sjint_out, 0 as convertion_out, 0 as retur, 0 as git_sjint_out, sum(b.n_quantity_int) as git_retur, 0 as git_sjint_kawal, 0 as git_retur_kawal, 0 as git_sjint_awal, 0 as git_retur_awal, 0 as saldoawal, 0 as stockopname, 0 as sjint_out_roll, 0 as git_sjint_rollkawal, 0 as git_sjint_rollawal, 0 as git_sjint_outroll, 0 as retur_in, 0 as sjint_in, 0 as sjint_inroll, 0 as n_manu_in, 0 as manu_out, 0 as git_manu,0 as git_manu_kawal, 0 as git_manu_awal
  193. from tr_product_stock_produksi a
  194. left join tm_sj_int_item b on(a.i_product=b.i_product)
  195. left join tm_sj_int c on(b.i_sjint=c.i_sjint)
  196. left join tr_product_satuan d on(a.i_product=d.i_product)
  197. where c.f_sjint_cancel ='f'
  198. and c.f_sjint_retur='t'
  199. and c.i_store_from='GJ'
  200. --- tanggal receive null dan sj pada periode berjalan
  201. --- atau periode receive melebihi bulan berjalan dan tanggal sj periode sekarang
  202. and (
  203. (c.d_sjint_receive isnull and (to_char(c.d_sjint, 'yyyymm'::text)='202203'))
  204. or ((to_char(c.d_sjint_receive, 'yyyymm'::text)>'202203' and to_char(c.d_sjint, 'yyyymm'::text) = '202203'))
  205. )
  206.  
  207. group by a.i_product_group, d.e_satuan_name
  208.  
  209.  
  210. union all -- GIT SJINT ROLL AWAL
  211.  
  212. select a.i_product_group, d.e_satuan_name as satuan, 0 as do_in, 0 as convertion_in, 0 as sjint_out, 0 as convertion_out, 0 as retur, 0 as git_sjint_out, 0 as git_retur, 0 as git_sjint_kawal, 0 as git_retur_kawal, 0 as git_sjint_awal, 0 as git_retur_awal, 0 as saldoawal, 0 as stockopname, 0 as sjint_out_roll, 0 as git_sjint_rollkawal, sum(b.n_quantity_int) as git_sjint_rollawal, 0 as git_sjint_outroll, 0 as retur_in, 0 as sjint_in, 0 as sjint_inroll, 0 as n_manu_in, 0 as manu_out, 0 as git_manu,0 as git_manu_kawal, 0 as git_manu_awal
  213. from tr_product_stock_produksi a
  214. left join tm_sj_int_item b on(a.i_product=b.i_product)
  215. left join tm_sj_int c on(b.i_sjint=c.i_sjint)
  216. left join tr_product_satuan d on(a.i_product=d.i_product)
  217. where c.f_sjint_cancel ='f'
  218. and c.f_sjint_retur='f'
  219. and c.i_store_from='GJ'
  220. and c.f_convertion_product='t'
  221. --- tanggal receive null dan sj periode sebelumnya
  222. --- atau periode receive melebihi bulan berjalan dan tanggal sj kurang dari periode sekarang
  223. and ((c.d_sjint_receive is null and to_char(c.d_sjint, 'yyyymm'::text) <'202203' )
  224. or
  225. ( to_char(c.d_sjint_receive, 'yyyymm'::text) > to_char(c.d_sjint, 'yyyymm'::text)
  226. --and to_char(c.d_sjint_receive, 'yyyymm'::text) < '202203'
  227. and to_char(c.d_sjint_receive, 'yyyymm'::text) = '202203')
  228. )
  229. group by a.i_product_group, d.e_satuan_name
  230.  
  231. union all -- GIT SJINT AWAL
  232.  
  233. select a.i_product, d.e_satuan_name as satuan, 0 as do_in, 0 as convertion_in, 0 as sjint_out, 0 as convertion_out, 0 as retur, 0 as git_sjint_out, 0 as git_retur, 0 as git_sjint_kawal, 0 as git_retur_kawal, sum(b.n_quantity_int) as git_sjint_awal, 0 as git_retur_awal, 0 as saldoawal, 0 as stockopname, 0 as sjint_out_roll, 0 as git_sjint_rollkawal, 0 as git_sjint_rollawal, 0 as git_sjint_outroll, 0 as retur_in, 0 as sjint_in, 0 as sjint_inroll, 0 as n_manu_in, 0 as manu_out, 0 as git_manu,0 as git_manu_kawal, 0 as git_manu_awal
  234. from tr_product_stock_produksi a
  235. left join tm_sj_int_item b on(a.i_product=b.i_product)
  236. left join tm_sj_int c on(b.i_sjint=c.i_sjint)
  237. left join tr_product_satuan d on(a.i_product=d.i_product)
  238. where c.f_sjint_cancel ='f'
  239. and c.f_sjint_retur='f'
  240. and c.i_store_from='GJ'
  241. and c.f_convertion_product='f'
  242. --- tanggal receive null dan sj periode sebelumnya
  243. --- atau periode receive melebihi bulan berjalan dan tanggal sj kurang dari periode sekarang
  244. and ((c.d_sjint_receive is null and to_char(c.d_sjint, 'yyyymm'::text) <'202203' )
  245. or
  246. ( to_char(c.d_sjint_receive, 'yyyymm'::text) > to_char(c.d_sjint, 'yyyymm'::text)
  247. --and to_char(c.d_sjint_receive, 'yyyymm'::text) < '202203'
  248. and to_char(c.d_sjint_receive, 'yyyymm'::text) = '202203')
  249. )
  250. group by a.i_product, d.e_satuan_name
  251.  
  252. union all -- GIT SJINT KELUAR AWAL
  253.  
  254. select a.i_product, d.e_satuan_name as satuan, 0 as do_in, 0 as convertion_in, 0 as sjint_out, 0 as convertion_out, 0 as retur, 0 as git_sjint_out, 0 as git_retur, sum(b.n_quantity_int) as git_sjint_kawal, 0 as git_retur_kawal, 0 as git_sjint_awal, 0 as git_retur_awal, 0 as saldoawal, 0 as stockopname, 0 as sjint_out_roll, 0 as git_sjint_rollkawal, 0 as git_sjint_rollawal, 0 as git_sjint_outroll, 0 as retur_in, 0 as sjint_in, 0 as sjint_inroll, 0 as n_manu_in, 0 as manu_out, 0 as git_manu,0 as git_manu_kawal, 0 as git_manu_awal
  255. from tr_product_stock_produksi a
  256. left join tm_sj_int_item b on(a.i_product=b.i_product)
  257. left join tm_sj_int c on(b.i_sjint=c.i_sjint)
  258. left join tr_product_satuan d on(a.i_product=d.i_product)
  259. where c.f_sjint_cancel ='f'
  260. and c.f_sjint_retur='f'
  261. and c.i_store_from='GJ'
  262. and c.f_convertion_product='f'
  263. --- tanggal receive null dan sj periode sebelumnya
  264. --- atau periode receive melebihi bulan berjalan dan tanggal sj kurang dari periode sekarang
  265. and ((c.d_sjint_receive is null and to_char(c.d_sjint, 'yyyymm'::text) <'202203' )
  266. or
  267. ( to_char(c.d_sjint_receive, 'yyyymm'::text) > '202203'
  268. and to_char(c.d_sjint, 'yyyymm'::text) < '202203')
  269. )
  270. group by a.i_product, d.e_satuan_name
  271.  
  272. union all -- GIT SJINT ROLL KELUAR AWAL
  273.  
  274. select a.i_product_group, d.e_satuan_name as satuan, 0 as do_in, 0 as convertion_in, 0 as sjint_out, 0 as convertion_out, 0 as retur, 0 as git_sjint_out, 0 as git_retur, 0 as git_sjint_kawal, 0 as git_retur_kawal, 0 as git_sjint_awal, 0 as git_retur_awal, 0 as saldoawal, 0 as stockopname, 0 as sjint_out_roll, sum(b.n_quantity_int) as git_sjint_rollkawal, 0 as git_sjint_rollawal, 0 as git_sjint_outroll, 0 as retur_in, 0 as sjint_in, 0 as sjint_inroll, 0 as n_manu_in, 0 as manu_out, 0 as git_manu,0 as git_manu_kawal, 0 as git_manu_awal
  275. from tr_product_stock_produksi a
  276. left join tm_sj_int_item b on(a.i_product=b.i_product)
  277. left join tm_sj_int c on(b.i_sjint=c.i_sjint)
  278. left join tr_product_satuan d on(a.i_product=d.i_product)
  279. where c.f_sjint_cancel ='f'
  280. and c.f_sjint_retur='f'
  281. and c.i_store_from='GJ'
  282. and c.f_convertion_product='t'
  283. --- tanggal receive null dan sj periode sebelumnya
  284. --- atau periode receive melebihi bulan berjalan dan tanggal sj kurang dari periode sekarang
  285. and ((c.d_sjint_receive is null and to_char(c.d_sjint, 'yyyymm'::text) <'202203' )
  286. or
  287. ( to_char(c.d_sjint_receive, 'yyyymm'::text) > '202203'
  288. and to_char(c.d_sjint, 'yyyymm'::text) < '202203')
  289. )
  290. group by a.i_product_group, d.e_satuan_name
  291.  
  292. union all -- GIT SJINT RETUR KELUAR AWAL
  293.  
  294. select a.i_product_group, d.e_satuan_name as satuan, 0 as do_in, 0 as convertion_in, 0 as sjint_out, 0 as convertion_out, 0 as retur, 0 as git_sjint_out, 0 as git_retur, 0 as git_sjint_kawal, sum(b.n_quantity_int) as git_retur_kawal, 0 as git_sjint_awal, 0 as git_retur_awal, 0 as saldoawal, 0 as stockopname, 0 as sjint_out_roll, 0 as git_sjint_rollkawal, 0 as git_sjint_rollawal, 0 as git_sjint_outroll, 0 as retur_in, 0 as sjint_in, 0 as sjint_inroll, 0 as n_manu_in, 0 as manu_out, 0 as git_manu,0 as git_manu_kawal, 0 as git_manu_awal
  295. from tr_product_stock_produksi a
  296. left join tm_sj_int_item b on(a.i_product=b.i_product)
  297. left join tm_sj_int c on(b.i_sjint=c.i_sjint)
  298. left join tr_product_satuan d on(a.i_product=d.i_product)
  299. where c.f_sjint_cancel ='f'
  300. and c.f_sjint_retur='t'
  301. and c.i_store_from='GJ'
  302. --- tanggal receive null dan sj periode sebelumnya
  303. --- atau periode receive melebihi bulan berjalan dan tanggal sj kurang dari periode sekarang
  304. and ((c.d_sjint_receive isnull and to_char(c.d_sjint, 'yyyymm'::text) <'202203' )
  305. or
  306. ( to_char(c.d_sjint_receive, 'yyyymm'::text) > '202203'
  307. and to_char(c.d_sjint, 'yyyymm'::text) < '202203')
  308. )
  309. group by a.i_product_group, d.e_satuan_name
  310.  
  311. union all -- GIT RETUR AWAL
  312.  
  313. select a.i_product_group, d.e_satuan_name as satuan, 0 as do_in, 0 as convertion_in, 0 as sjint_out, 0 as convertion_out, 0 as retur, 0 as git_sjint_out, 0 as git_retur, 0 as git_sjint_kawal, 0 as git_retur_kawal, 0 as git_sjint_awal, sum(b.n_quantity_int) as git_retur_awal, 0 as saldoawal, 0 as stockopname, 0 as sjint_out_roll, 0 as git_sjint_rollkawal, 0 as git_sjint_rollawal, 0 as git_sjint_outroll, 0 as retur_in, 0 as sjint_in, 0 as sjint_inroll, 0 as n_manu_in, 0 as manu_out, 0 as git_manu,0 as git_manu_kawal, 0 as git_manu_awal
  314. from tr_product_stock_produksi a
  315. left join tm_sj_int_item b on(a.i_product=b.i_product)
  316. left join tm_sj_int c on(b.i_sjint=c.i_sjint)
  317. left join tr_product_satuan d on(a.i_product=d.i_product)
  318. where c.f_sjint_cancel ='f'
  319. and c.f_sjint_retur='t'
  320. and c.i_store_from='GJ'
  321. --- tanggal receive null dan sj periode sebelumnya
  322. --- atau periode receive melebihi bulan berjalan dan tanggal sj kurang dari periode sekarang
  323. and ((c.d_sjint_receive isnull and to_char(c.d_sjint, 'yyyymm'::text) <'202203' )
  324. or
  325. ( to_char(c.d_sjint_receive, 'yyyymm'::text) > to_char(c.d_sjint, 'yyyymm'::text)
  326. --and to_char(c.d_sjint_receive, 'yyyymm'::text) < '202203'
  327. and to_char(c.d_sjint_receive, 'yyyymm'::text) = '202203')
  328. )
  329. group by a.i_product_group, d.e_satuan_name
  330.  
  331.  
  332. union all -- SALDO AWAL
  333.  
  334. select a.i_product, b.e_satuan_name as satuan, 0 as do_in, 0 as convertion_in, 0 as sjint_out, 0 as convertion_out, 0 as retur, 0 as git_sjint_out, 0 as git_retur, 0 as git_sjint_kawal, 0 as git_retur_kawal, 0 as git_sjint_awal, 0 as git_retur_awal, sum(b.n_saldo_awal) as saldoawal, 0 as stockopname, 0 as sjint_out_roll, 0 as git_sjint_rollkawal, 0 as git_sjint_rollawal, 0 as git_sjint_outroll, 0 as retur_in, 0 as sjint_in, 0 as sjint_inroll, 0 as n_manu_in, 0 as manu_out, 0 as git_manu,0 as git_manu_kawal, 0 as git_manu_awal
  335. from tr_product_stock_produksi a
  336. left join tm_mutasi_saldoawal b on(a.i_product=b.i_product)
  337. -- left join tr_product_satuan d on(a.i_product=d.i_product)
  338. where b.i_store='GJ'
  339. and b.i_store_location='00'
  340. and b.e_mutasi_periode='202203'
  341. group by a.i_product, b.e_satuan_name
  342.  
  343. union all -- STOCKOPNAME
  344.  
  345. select a.i_product, b.e_satuan_name as satuan, 0 as do_in, 0 as convertion_in, 0 as sjint_out, 0 as convertion_out, 0 as retur, 0 as git_sjint_out, 0 as git_retur, 0 as git_sjint_kawal, 0 as git_retur_kawal, 0 as git_sjint_awal, 0 as git_retur_awal, 0 as saldoawal, sum(b.n_stockopname) as stockopname, 0 as sjint_out_roll, 0 as git_sjint_rollkawal, 0 as git_sjint_rollawal, 0 as git_sjint_outroll, 0 as retur_in, 0 as sjint_in, 0 as sjint_inroll, 0 as n_manu_in, 0 as manu_out, 0 as git_manu,0 as git_manu_kawal, 0 as git_manu_awal
  346. from tr_product_stock_produksi a
  347. left join tm_stockopname_item b on(a.i_product=b.i_product)
  348. left join tm_stockopname c on(b.i_stockopname=c.i_stockopname)
  349. where c.i_store='GJ'
  350. and b.i_store_location='00'
  351. and b.e_mutasi_periode='202203'
  352. and c.f_stockopname_cancel='f'
  353. group by a.i_product, b.e_satuan_name
  354.  
  355. union all -- MANUFAKTUR IN
  356. select a.i_product, d.e_satuan_name as satuan, 0 as do_in, 0 as convertion_in, 0 as sjint_out, 0 as convertion_out, 0 as retur, 0 as git_sjint_out, 0 as git_retur, 0 as git_sjint_kawal, 0 as git_retur_kawal, 0 as git_sjint_awal, 0 as git_retur_awal, 0 as saldoawal, 0 as stockopname, 0 as sjint_out_roll, 0 as git_sjint_rollkawal, 0 as git_sjint_rollawal, 0 as git_sjint_outroll, 0 as retur_in, 0 as sjint_in, 0 as sjint_inroll, sum(n_manufacture_detailhasil_roll) as n_manu_in, 0 as manu_out, 0 as git_manu,0 as git_manu_kawal, 0 as git_manu_awal
  357. from tr_product_stock_produksi a
  358. left join tm_manufacturer_item b on(a.i_product=b.i_product)
  359. left join tm_manufacturer c on(b.i_manufacturer=c.i_manufacturer)
  360. left join tr_product_satuan d on(b.i_product=d.i_product)
  361. where b.i_store='GJ'
  362. and b.i_store_location='00'
  363. and to_char(c.d_manufacturer_finish, 'yyyymm')='202203'
  364. and c.f_manufacturer_cancel='f'
  365. group by a.i_product, d.e_satuan_name
  366.  
  367. union all -- MANUFAKTUR OUT
  368. select a.i_product_group, d.e_satuan_name as satuan, 0 as do_in, 0 as convertion_in, 0 as sjint_out, 0 as convertion_out, 0 as retur, 0 as git_sjint_out, 0 as git_retur, 0 as git_sjint_kawal, 0 as git_retur_kawal, 0 as git_sjint_awal, 0 as git_retur_awal, 0 as saldoawal, 0 as stockopname, 0 as sjint_out_roll, 0 as git_sjint_rollkawal, 0 as git_sjint_rollawal, 0 as git_sjint_outroll, 0 as retur_in, 0 as sjint_in, 0 as sjint_inroll, 0 as n_manu_in, sum(b.n_manufacture_bom) as manu_out, 0 as git_manu,0 as git_manu_kawal, 0 as git_manu_awal
  369. from tr_product_stock_produksi a
  370. left join tm_manufacturer_item b on(a.i_product=b.i_product_bom)
  371. left join tm_manufacturer c on(b.i_manufacturer=c.i_manufacturer)
  372. left join tr_product_satuan d on(b.i_product_bom=d.i_product)
  373. where b.i_store='GJ'
  374. and b.i_store_location='00'
  375. and to_char(c.d_manufacturer_finish, 'yyyymm')='202203'
  376. and c.f_manufacturer_cancel='f'
  377. group by a.i_product_group, d.e_satuan_name
  378.  
  379. union all -- GIT MANUFAKTUR
  380. select a.i_product_group, d.e_satuan_name as satuan, 0 as do_in, 0 as convertion_in, 0 as sjint_out, 0 as convertion_out, 0 as retur, 0 as git_sjint_out, 0 as git_retur, 0 as git_sjint_kawal, 0 as git_retur_kawal, 0 as git_sjint_awal, 0 as git_retur_awal, 0 as saldoawal, 0 as stockopname, 0 as sjint_out_roll, 0 as git_sjint_rollkawal, 0 as git_sjint_rollawal, 0 as git_sjint_outroll, 0 as retur_in, 0 as sjint_in, 0 as sjint_inroll, 0 as n_manu_in, 0 as manu_out, sum(b.n_manufacture_bom) as git_manu, 0 as git_manu_kawal, 0 as git_manu_awal
  381. from tr_product_stock_produksi a
  382. left join tm_manufacturer_item b on(a.i_product=b.i_product_bom)
  383. left join tm_manufacturer c on(b.i_manufacturer=c.i_manufacturer)
  384. left join tr_product_satuan d on(b.i_product_bom=d.i_product)
  385. where b.i_store='GJ'
  386. and b.i_store_location='00'
  387. --- tanggal finis null dan sj pada periode berjalan
  388. --- atau periode receive melebihi bulan berjalan dan tanggal sj periode sekarang
  389. and (
  390. (c.d_manufacturer_finish isnull and (to_char(c.d_manufacturer, 'yyyymm'::text)='202203'))
  391. or ((to_char(c.d_manufacturer_finish, 'yyyymm'::text)>'202203' and to_char(c.d_manufacturer, 'yyyymm'::text) = '202203'))
  392. )
  393. and c.f_manufacturer_cancel='f'
  394. group by a.i_product_group, d.e_satuan_name
  395.  
  396.  
  397. union all -- GIT MANUFAKTUR KELUAR AWAL
  398. select a.i_product_group, d.e_satuan_name as satuan, 0 as do_in, 0 as convertion_in, 0 as sjint_out, 0 as convertion_out, 0 as retur, 0 as git_sjint_out, 0 as git_retur, 0 as git_sjint_kawal, 0 as git_retur_kawal, 0 as git_sjint_awal, 0 as git_retur_awal, 0 as saldoawal, 0 as stockopname, 0 as sjint_out_roll, 0 as git_sjint_rollkawal, 0 as git_sjint_rollawal, 0 as git_sjint_outroll, 0 as retur_in, 0 as sjint_in, 0 as sjint_inroll, 0 as n_manu_in, 0 as manu_out, 0 as git_manu,sum(b.n_manufacture_bom) as git_manu_kawal, 0 as git_manu_awal
  399. from tr_product_stock_produksi a
  400. left join tm_manufacturer_item b on(a.i_product=b.i_product_bom)
  401. left join tm_manufacturer c on(b.i_manufacturer=c.i_manufacturer)
  402. left join tr_product_satuan d on(b.i_product_bom=d.i_product)
  403. where b.i_store='GJ'
  404. and b.i_store_location='00'
  405. --- tanggal finish null dan manufaktur periode sebelumnya
  406. --- atau periode finis melebihi bulan berjalan dan tanggal manufaktur kurang dari periode sekarang
  407. and ((c.d_manufacturer_finish isnull and to_char(c.d_manufacturer, 'yyyymm'::text) <'202203' )
  408. or
  409. ( to_char(c.d_manufacturer_finish, 'yyyymm'::text) > '202203'
  410. and to_char(c.d_manufacturer, 'yyyymm'::text) < '202203')
  411. )
  412. and c.f_manufacturer_cancel='f'
  413. group by a.i_product_group, d.e_satuan_name
  414.  
  415. union all -- GIT MANUFAKTUR AWAL
  416. select a.i_product_group, d.e_satuan_name as satuan, 0 as do_in, 0 as convertion_in, 0 as sjint_out, 0 as convertion_out, 0 as retur, 0 as git_sjint_out, 0 as git_retur, 0 as git_sjint_kawal, 0 as git_retur_kawal, 0 as git_sjint_awal, 0 as git_retur_awal, 0 as saldoawal, 0 as stockopname, 0 as sjint_out_roll, 0 as git_sjint_rollkawal, 0 as git_sjint_rollawal, 0 as git_sjint_outroll, 0 as retur_in, 0 as sjint_in, 0 as sjint_inroll, 0 as n_manu_in, 0 as manu_out, 0 as git_manu,0 as git_manu_kawal,sum(b.n_manufacture_bom) as git_manu_awal
  417. from tr_product_stock_produksi a
  418. left join tm_manufacturer_item b on(a.i_product=b.i_product_bom)
  419. left join tm_manufacturer c on(b.i_manufacturer=c.i_manufacturer)
  420. left join tr_product_satuan d on(b.i_product_bom=d.i_product)
  421. where b.i_store='GJ'
  422. and b.i_store_location='00'
  423. --- tanggal receive null dan sj periode sebelumnya
  424. --- atau periode receive melebihi bulan berjalan dan tanggal sj kurang dari periode sekarang
  425. and ((c.d_manufacturer_finish is null and to_char(c.d_manufacturer, 'yyyymm'::text) <'202203' )
  426. or
  427. ( to_char(c.d_manufacturer_finish, 'yyyymm'::text) > to_char(c.d_manufacturer, 'yyyymm'::text)
  428. --and to_char(c.d_sjint_receive, 'yyyymm'::text) < '202203'
  429. and to_char(c.d_manufacturer_finish, 'yyyymm'::text) = '202203')
  430. )
  431. and c.f_manufacturer_cancel='f'
  432. group by a.i_product_group, d.e_satuan_name
  433.  
  434.  
  435.  
  436.  
  437. ) as x
  438. group by i_product_group, satuan
  439. ORDER BY i_product_group
Add Comment
Please, Sign In to add comment