Commit 51ec173ca2eaf8b04146b9771a3b8c8a4455b952
Exists in
master
Merge branch 'tarefa-3822' of http://ferramentasgo.centralit.com.br:8080/scm/git…
…/cit-grp-almoxarifado into tarefa-3822
Showing
16 changed files
with
278 additions
and
134 deletions
Show diff stats
cit-almoxarifado-api/src/main/java/br/com/centralit/api/dao/MaterialEstoqueFIFOItemDao.java
1 | 1 | package br.com.centralit.api.dao; |
2 | 2 | |
3 | +import java.util.List; | |
4 | + | |
5 | +import br.com.centralit.api.model.MaterialEstoqueFIFOItem; | |
3 | 6 | import br.com.centralit.framework.dao.arquitetura.CitGenericDAO; |
4 | 7 | |
5 | 8 | public interface MaterialEstoqueFIFOItemDao extends CitGenericDAO { |
9 | + | |
10 | + List<MaterialEstoqueFIFOItem> findFIFOsByMaterial(long idMaterial); | |
6 | 11 | |
7 | 12 | } | ... | ... |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/dao/RequisicaoConsumoItemDao.java
... | ... | @@ -26,7 +26,7 @@ public interface RequisicaoConsumoItemDao extends CitGenericDAO { |
26 | 26 | * @param statusFinalizado |
27 | 27 | * @return |
28 | 28 | */ |
29 | - Long findRequisicaoAnteriorPorMaterial(MaterialConsumo materialConsumo, EstruturaOrganizacional unidadeRequisitante, Dominio statusFinalizado, Dominio statusParcialmenteAtendida, Dominio statusAtendida); | |
29 | + Long findRequisicaoAnteriorPorMaterial(MaterialConsumo materialConsumo, EstruturaOrganizacional unidadeRequisitante, Dominio statusFinalizado, Dominio statusParcialmenteAtendida); | |
30 | 30 | |
31 | 31 | List<RequisicaoConsumoItem> findItensRequisicaoPorMaterial(Long idRequisicao, Long idMaterial); |
32 | 32 | ... | ... |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/dao/impl/MaterialEstoqueFIFOItemDaoHibernate.java
1 | 1 | package br.com.centralit.api.dao.impl; |
2 | 2 | |
3 | +import java.util.List; | |
4 | + | |
3 | 5 | import org.springframework.stereotype.Repository; |
4 | 6 | |
7 | +import com.googlecode.genericdao.search.Sort; | |
8 | + | |
5 | 9 | import br.com.centralit.api.dao.MaterialEstoqueFIFOItemDao; |
6 | 10 | import br.com.centralit.api.model.MaterialEstoqueFIFOItem; |
7 | 11 | import br.com.centralit.framework.dao.arquitetura.CitGenericDAOImpl; |
12 | +import br.com.centralit.framework.dao.arquitetura.SearchSeven; | |
8 | 13 | |
9 | 14 | @Repository("materialEstoqueFIFOItemDao") |
10 | 15 | public class MaterialEstoqueFIFOItemDaoHibernate extends CitGenericDAOImpl implements MaterialEstoqueFIFOItemDao { |
... | ... | @@ -12,5 +17,17 @@ public class MaterialEstoqueFIFOItemDaoHibernate extends CitGenericDAOImpl imple |
12 | 17 | public MaterialEstoqueFIFOItemDaoHibernate() { |
13 | 18 | super(MaterialEstoqueFIFOItem.class); |
14 | 19 | } |
20 | + | |
21 | + @Override | |
22 | + public List<MaterialEstoqueFIFOItem> findFIFOsByMaterial(long idMaterial) { | |
23 | + | |
24 | + SearchSeven search = new SearchSeven(this.persistentClass); | |
25 | + | |
26 | + search.addFilterEqual("material.id", idMaterial); | |
27 | + | |
28 | + search.addSort(Sort.asc("id")); | |
29 | + | |
30 | + return this.search(search, this.persistentClass); | |
31 | + } | |
15 | 32 | |
16 | 33 | } | ... | ... |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/dao/impl/MovimentoEstoqueDaoHibernate.java
... | ... | @@ -288,7 +288,7 @@ public class MovimentoEstoqueDaoHibernate extends CitGenericDAOImpl implements M |
288 | 288 | SearchSeven search = new SearchSeven(); |
289 | 289 | |
290 | 290 | search.addFilterEqual("dominioClasseReferencia.id", classeReferencia.getId()); |
291 | - search.addFilterEqual("idClasseReferencia", idReferencia); | |
291 | + search.addFilterEqual("idClasseReferencia", null); | |
292 | 292 | |
293 | 293 | return search(search); |
294 | 294 | } | ... | ... |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/dao/impl/RequisicaoConsumoItemDaoHibernate.java
... | ... | @@ -158,13 +158,13 @@ public class RequisicaoConsumoItemDaoHibernate extends CitGenericDAOImpl impleme |
158 | 158 | * {@inheritDoc} |
159 | 159 | */ |
160 | 160 | @Override |
161 | - public Long findRequisicaoAnteriorPorMaterial(MaterialConsumo materialConsumo, EstruturaOrganizacional unidadeRequisitante, Dominio statusFinalizado, Dominio statusParcialmenteAtendida, Dominio statusAtendida) { | |
161 | + public Long findRequisicaoAnteriorPorMaterial(MaterialConsumo materialConsumo, EstruturaOrganizacional unidadeRequisitante, Dominio statusFinalizado, Dominio statusParcialmenteAtendida) { | |
162 | 162 | |
163 | 163 | StringBuilder str = new StringBuilder(); |
164 | 164 | str.append("select RequisicaoConsumo.id "); |
165 | 165 | str.append("from alm_rc_item as RequisicaoConsumoItem "); |
166 | 166 | str.append("inner join alm_requisicaoconsumo RequisicaoConsumo on RequisicaoConsumo.id = RequisicaoConsumoItem.requisicaoconsumo_id "); |
167 | - str.append("where (RequisicaoConsumo.tipostatusrequisicao_id = :dominioFinalizado OR RequisicaoConsumo.tipostatusrequisicao_id = :dominioParcialmenteAtendida OR RequisicaoConsumo.tipostatusrequisicao_id = :dominioAtendida) AND RequisicaoConsumoItem.materialConsumo_id = :idMaterial AND RequisicaoConsumo.unidaderequisitante_id = :idUnidadeRequisitante "); | |
167 | + str.append("where (RequisicaoConsumo.tipostatusrequisicao_id = :dominioFinalizado OR RequisicaoConsumo.tipostatusrequisicao_id = :dominioParcialmenteAtendida) AND RequisicaoConsumoItem.materialConsumo_id = :idMaterial AND RequisicaoConsumo.unidaderequisitante_id = :idUnidadeRequisitante "); | |
168 | 168 | str.append("order by RequisicaoConsumo.id desc"); |
169 | 169 | |
170 | 170 | Query query = em().createNativeQuery(str.toString()); |
... | ... | @@ -173,7 +173,6 @@ public class RequisicaoConsumoItemDaoHibernate extends CitGenericDAOImpl impleme |
173 | 173 | query.setParameter("idUnidadeRequisitante", unidadeRequisitante.getId()); |
174 | 174 | query.setParameter("dominioFinalizado", statusFinalizado.getId()); |
175 | 175 | query.setParameter("dominioParcialmenteAtendida", statusParcialmenteAtendida.getId()); |
176 | - query.setParameter("dominioAtendida", statusAtendida.getId()); | |
177 | 176 | |
178 | 177 | query.setMaxResults(1); |
179 | 178 | ... | ... |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/model/DominioAlmoxarifado.java
... | ... | @@ -25,17 +25,17 @@ public class DominioAlmoxarifado { |
25 | 25 | /** Atributo TIPO_STATUS_REQUISICAO. */ |
26 | 26 | public static final String TIPO_STATUS_REQUISICAO = "tipoStatusRequisicao"; |
27 | 27 | |
28 | - /** Atributo TIPO_STATUS_NAO_CONCLUIDA. */ | |
29 | - public static final Long TIPO_STATUS_NAO_CONCLUIDA = 1L; | |
30 | - | |
28 | + /** Atributo TIPO_STATUS_ATENDIDA_PARCIALMENTE. */ | |
29 | + public static final Long TIPO_STATUS_ATENDIDA_PARCIALMENTE = 1L; | |
30 | + | |
31 | 31 | /** Atributo TIPO_STATUS_PRONTA_PARA_ATENDIMENTO. */ |
32 | 32 | public static final Long TIPO_STATUS_PRONTA_PARA_ATENDIMENTO = 2L; |
33 | + | |
34 | + /** Atributo TIPO_STATUS_NAO_CONCLUIDA. */ | |
35 | + public static final Long TIPO_STATUS_NAO_CONCLUIDA = 3L; | |
33 | 36 | |
34 | - /** Atributo TIPO_STATUS_ATENDIDA_PARCIALMENTE. */ | |
35 | - public static final Long TIPO_STATUS_ATENDIDA_PARCIALMENTE = 3L; | |
36 | - | |
37 | - /** Atributo TIPO_STATUS_ATENDIDA. */ | |
38 | - public static final Long TIPO_STATUS_ATENDIDA = 4L; | |
37 | + /** Atributo TIPO_STATUS_DEVOLVIDA. */ | |
38 | + public static final Long TIPO_STATUS_DEVOLVIDA = 4L; | |
39 | 39 | |
40 | 40 | /** Atributo TIPO_STATUS_FINALIZADA. */ |
41 | 41 | public static final Long TIPO_STATUS_FINALIZADA = 5L; | ... | ... |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/model/MaterialEstoqueFIFOItem.java
... | ... | @@ -18,18 +18,30 @@ import br.com.centralit.framework.model.arquitetura.PersistentObjectAuditOrganiz |
18 | 18 | |
19 | 19 | /** |
20 | 20 | * |
21 | - * <p><img src="http://centralit.com.br/images/logo_central.png"></p> | |
21 | + * <p> | |
22 | + * <img src="http://centralit.com.br/images/logo_central.png"> | |
23 | + * </p> | |
22 | 24 | * |
23 | - * <p><b>Company: </b> Central IT - Governança Corporativa - </p> | |
25 | + * <p> | |
26 | + * <b>Company: </b> Central IT - Governança Corporativa - | |
27 | + * </p> | |
24 | 28 | * |
25 | - * <p><b>Title: </b></p> | |
29 | + * <p> | |
30 | + * <b>Title: </b> | |
31 | + * </p> | |
26 | 32 | * |
27 | - * <p><b>Description: </b></p> | |
33 | + * <p> | |
34 | + * <b>Description: </b> | |
35 | + * </p> | |
28 | 36 | * |
29 | - * <p><b>Iniciativa(s):</b> <a href="LINK_PORTAL">NUMERO_INICIATIVA</a></p> | |
37 | + * <p> | |
38 | + * <b>Iniciativa(s):</b> <a href="LINK_PORTAL">NUMERO_INICIATIVA</a> | |
39 | + * </p> | |
30 | 40 | * |
31 | - * <p><b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a></p> | |
32 | - * | |
41 | + * <p> | |
42 | + * <b>Regra(s) de negócio:</b> <a href="LINK_PORTAL">NUMERO_REGRA_DE_NEGOCIO</a> | |
43 | + * </p> | |
44 | + * | |
33 | 45 | * @since 29/04/2016 - 15:55:15 |
34 | 46 | * |
35 | 47 | * @version 1.0.0 |
... | ... | @@ -45,16 +57,16 @@ public class MaterialEstoqueFIFOItem extends PersistentObjectAuditOrganizacao { |
45 | 57 | /** Atributo serialVersionUID. */ |
46 | 58 | private static final long serialVersionUID = 1170228299223134768L; |
47 | 59 | private static int SCALE_DIVISOR_DECIMAL = 4; |
48 | - | |
60 | + | |
49 | 61 | /** Atributo id. */ |
50 | 62 | @Id |
51 | 63 | @GeneratedValue(strategy = GenerationType.AUTO) |
52 | 64 | private Long id; |
53 | - | |
65 | + | |
54 | 66 | /** Atributo material. */ |
55 | 67 | @ManyToOne(fetch = FetchType.LAZY, optional = false) |
56 | 68 | private MaterialConsumo material; |
57 | - | |
69 | + | |
58 | 70 | /** Atributo materialEstoque. */ |
59 | 71 | @ManyToOne(fetch = FetchType.LAZY, optional = true) |
60 | 72 | private MaterialEstoque materialEstoque; |
... | ... | @@ -62,7 +74,7 @@ public class MaterialEstoqueFIFOItem extends PersistentObjectAuditOrganizacao { |
62 | 74 | /** Atributo materialEstoqueInativo. */ |
63 | 75 | @ManyToOne(fetch = FetchType.LAZY, optional = true) |
64 | 76 | private MaterialEstoque materialEstoqueInativo; |
65 | - | |
77 | + | |
66 | 78 | /** Atributo quantidadeInicial. */ |
67 | 79 | @Column(precision = 20, scale = 4, nullable = false) |
68 | 80 | private BigDecimal quantidadeInicial; |
... | ... | @@ -70,7 +82,7 @@ public class MaterialEstoqueFIFOItem extends PersistentObjectAuditOrganizacao { |
70 | 82 | /** Atributo quantidadeRestante. */ |
71 | 83 | @Column(precision = 20, scale = 4, nullable = false) |
72 | 84 | private BigDecimal quantidadeRestante; |
73 | - | |
85 | + | |
74 | 86 | /** Atributo valorUnitario. */ |
75 | 87 | @Column(precision = 20, scale = 4, nullable = false) |
76 | 88 | private BigDecimal valorUnitario; |
... | ... | @@ -78,20 +90,23 @@ public class MaterialEstoqueFIFOItem extends PersistentObjectAuditOrganizacao { |
78 | 90 | /** Atributo valorSobra. */ |
79 | 91 | @Column(precision = 20, scale = 4, nullable = false) |
80 | 92 | private BigDecimal valorSobra; |
81 | - | |
93 | + | |
94 | + @Column(precision = 20, scale = 4, nullable = false) | |
95 | + private BigDecimal valorResto; | |
96 | + | |
82 | 97 | /** Atributo valorTotal. */ |
83 | 98 | @Column(precision = 20, scale = 4, nullable = false) |
84 | 99 | private BigDecimal valorTotal; |
85 | - | |
100 | + | |
86 | 101 | @ManyToOne(fetch = FetchType.EAGER, optional = false) |
87 | 102 | private EntradaAlmoxarifadoItem entradaItem; |
88 | - | |
89 | - | |
103 | + | |
90 | 104 | protected MaterialEstoqueFIFOItem() { |
91 | 105 | super(); |
92 | 106 | } |
93 | 107 | |
94 | - public MaterialEstoqueFIFOItem( MaterialEstoque materialEstoque, BigDecimal quantidadeInicial, BigDecimal valorTotal, EntradaAlmoxarifadoItem entradaItem ) { | |
108 | + public MaterialEstoqueFIFOItem(MaterialEstoque materialEstoque, BigDecimal quantidadeInicial, BigDecimal valorTotal, | |
109 | + EntradaAlmoxarifadoItem entradaItem) { | |
95 | 110 | super(); |
96 | 111 | this.material = materialEstoque.getMaterial(); |
97 | 112 | this.materialEstoque = materialEstoque; |
... | ... | @@ -99,7 +114,7 @@ public class MaterialEstoqueFIFOItem extends PersistentObjectAuditOrganizacao { |
99 | 114 | this.quantidadeRestante = quantidadeInicial; |
100 | 115 | this.valorTotal = valorTotal; |
101 | 116 | this.valorUnitario = valorTotal.divide(quantidadeInicial, SCALE_DIVISOR_DECIMAL, RoundingMode.CEILING); |
102 | - this.valorSobra = valorTotal.min(this.valorUnitario.multiply(quantidadeInicial)); | |
117 | + this.valorSobra = valorTotal.subtract(this.valorUnitario.multiply(quantidadeInicial)); | |
103 | 118 | this.entradaItem = entradaItem; |
104 | 119 | } |
105 | 120 | |
... | ... | @@ -123,70 +138,63 @@ public class MaterialEstoqueFIFOItem extends PersistentObjectAuditOrganizacao { |
123 | 138 | this.id = id; |
124 | 139 | } |
125 | 140 | |
126 | - | |
127 | 141 | /** |
128 | 142 | * Retorna o valor do atributo <code>material</code> |
129 | 143 | * |
130 | 144 | * @return <code>MaterialConsumo</code> |
131 | 145 | */ |
132 | 146 | public MaterialConsumo getMaterial() { |
133 | - | |
147 | + | |
134 | 148 | return material; |
135 | 149 | } |
136 | 150 | |
137 | - | |
138 | 151 | /** |
139 | 152 | * Define o valor do atributo <code>material</code>. |
140 | 153 | * |
141 | - * @param material | |
154 | + * @param material | |
142 | 155 | */ |
143 | 156 | public void setMaterial(MaterialConsumo material) { |
144 | - | |
157 | + | |
145 | 158 | this.material = material; |
146 | 159 | } |
147 | 160 | |
148 | - | |
149 | - | |
150 | 161 | /** |
151 | 162 | * Retorna o valor do atributo <code>materialEstoque</code> |
152 | 163 | * |
153 | 164 | * @return <code>MaterialEstoque</code> |
154 | 165 | */ |
155 | 166 | public MaterialEstoque getMaterialEstoque() { |
156 | - | |
167 | + | |
157 | 168 | return materialEstoque; |
158 | 169 | } |
159 | 170 | |
160 | - | |
161 | 171 | /** |
162 | 172 | * Define o valor do atributo <code>materialEstoque</code>. |
163 | 173 | * |
164 | - * @param materialEstoque | |
174 | + * @param materialEstoque | |
165 | 175 | */ |
166 | 176 | public void setMaterialEstoque(MaterialEstoque materialEstoque) { |
167 | - | |
177 | + | |
168 | 178 | this.materialEstoque = materialEstoque; |
169 | 179 | } |
170 | 180 | |
171 | - | |
172 | 181 | /** |
173 | 182 | * Retorna o valor do atributo <code>materialEstoqueInativo</code> |
174 | 183 | * |
175 | 184 | * @return <code>MaterialEstoque</code> |
176 | 185 | */ |
177 | 186 | public MaterialEstoque getMaterialEstoqueInativo() { |
178 | - | |
187 | + | |
179 | 188 | return materialEstoqueInativo; |
180 | 189 | } |
181 | 190 | |
182 | - | |
183 | 191 | /** |
184 | 192 | * Define o valor do atributo <code>materialEstoqueInativo</code>. |
185 | 193 | * |
186 | - * @param materialEstoqueInativo | |
194 | + * @param materialEstoqueInativo | |
187 | 195 | */ |
188 | 196 | public void setMaterialEstoqueInativo(MaterialEstoque materialEstoqueInativo) { |
189 | - | |
197 | + | |
190 | 198 | this.materialEstoqueInativo = materialEstoqueInativo; |
191 | 199 | } |
192 | 200 | |
... | ... | @@ -196,128 +204,117 @@ public class MaterialEstoqueFIFOItem extends PersistentObjectAuditOrganizacao { |
196 | 204 | * @return <code>BigDecimal</code> |
197 | 205 | */ |
198 | 206 | public BigDecimal getQuantidadeInicial() { |
199 | - | |
207 | + | |
200 | 208 | return quantidadeInicial; |
201 | 209 | } |
202 | 210 | |
203 | - | |
204 | 211 | /** |
205 | 212 | * Define o valor do atributo <code>quantidadeInicial</code>. |
206 | 213 | * |
207 | - * @param quantidadeInicial | |
214 | + * @param quantidadeInicial | |
208 | 215 | */ |
209 | 216 | public void setQuantidadeInicial(BigDecimal quantidadeInicial) { |
210 | - | |
217 | + | |
211 | 218 | this.quantidadeInicial = quantidadeInicial; |
212 | 219 | } |
213 | 220 | |
214 | - | |
215 | 221 | /** |
216 | 222 | * Retorna o valor do atributo <code>quantidadeRestante</code> |
217 | 223 | * |
218 | 224 | * @return <code>BigDecimal</code> |
219 | 225 | */ |
220 | 226 | public BigDecimal getQuantidadeRestante() { |
221 | - | |
227 | + | |
222 | 228 | return quantidadeRestante; |
223 | 229 | } |
224 | 230 | |
225 | - | |
226 | 231 | /** |
227 | 232 | * Define o valor do atributo <code>quantidadeRestante</code>. |
228 | 233 | * |
229 | - * @param quantidadeRestante | |
234 | + * @param quantidadeRestante | |
230 | 235 | */ |
231 | 236 | public void setQuantidadeRestante(BigDecimal quantidadeRestante) { |
232 | - | |
237 | + | |
233 | 238 | this.quantidadeRestante = quantidadeRestante; |
234 | 239 | } |
235 | 240 | |
236 | - | |
237 | 241 | /** |
238 | 242 | * Retorna o valor do atributo <code>valorUnitario</code> |
239 | 243 | * |
240 | 244 | * @return <code>BigDecimal</code> |
241 | 245 | */ |
242 | 246 | public BigDecimal getValorUnitario() { |
243 | - | |
247 | + | |
244 | 248 | return valorUnitario; |
245 | 249 | } |
246 | 250 | |
247 | - | |
248 | 251 | /** |
249 | 252 | * Define o valor do atributo <code>valorUnitario</code>. |
250 | 253 | * |
251 | - * @param valorUnitario | |
254 | + * @param valorUnitario | |
252 | 255 | */ |
253 | 256 | public void setValorUnitario(BigDecimal valorUnitario) { |
254 | - | |
257 | + | |
255 | 258 | this.valorUnitario = valorUnitario; |
256 | 259 | } |
257 | 260 | |
258 | - | |
259 | 261 | /** |
260 | 262 | * Retorna o valor do atributo <code>valorSobra</code> |
261 | 263 | * |
262 | 264 | * @return <code>BigDecimal</code> |
263 | 265 | */ |
264 | 266 | public BigDecimal getValorSobra() { |
265 | - | |
267 | + | |
266 | 268 | return valorSobra; |
267 | 269 | } |
268 | 270 | |
269 | - | |
270 | 271 | /** |
271 | 272 | * Define o valor do atributo <code>valorSobra</code>. |
272 | 273 | * |
273 | - * @param valorSobra | |
274 | + * @param valorSobra | |
274 | 275 | */ |
275 | 276 | public void setValorSobra(BigDecimal valorSobra) { |
276 | - | |
277 | + | |
277 | 278 | this.valorSobra = valorSobra; |
278 | 279 | } |
279 | 280 | |
280 | - | |
281 | 281 | /** |
282 | 282 | * Retorna o valor do atributo <code>valorTotal</code> |
283 | 283 | * |
284 | 284 | * @return <code>BigDecimal</code> |
285 | 285 | */ |
286 | 286 | public BigDecimal getValorTotal() { |
287 | - | |
287 | + | |
288 | 288 | return valorTotal; |
289 | 289 | } |
290 | 290 | |
291 | - | |
292 | 291 | /** |
293 | 292 | * Define o valor do atributo <code>valorTotal</code>. |
294 | 293 | * |
295 | - * @param valorTotal | |
294 | + * @param valorTotal | |
296 | 295 | */ |
297 | 296 | public void setValorTotal(BigDecimal valorTotal) { |
298 | - | |
297 | + | |
299 | 298 | this.valorTotal = valorTotal; |
300 | 299 | } |
301 | 300 | |
302 | - | |
303 | 301 | /** |
304 | 302 | * Retorna o valor do atributo <code>entradaItem</code> |
305 | 303 | * |
306 | 304 | * @return <code>EntradaAlmoxarifadoItem</code> |
307 | 305 | */ |
308 | 306 | public EntradaAlmoxarifadoItem getEntradaItem() { |
309 | - | |
307 | + | |
310 | 308 | return entradaItem; |
311 | 309 | } |
312 | 310 | |
313 | - | |
314 | 311 | /** |
315 | 312 | * Define o valor do atributo <code>entradaItem</code>. |
316 | 313 | * |
317 | - * @param entradaItem | |
314 | + * @param entradaItem | |
318 | 315 | */ |
319 | 316 | public void setEntradaItem(EntradaAlmoxarifadoItem entradaItem) { |
320 | - | |
317 | + | |
321 | 318 | this.entradaItem = entradaItem; |
322 | 319 | } |
323 | 320 | ... | ... |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/service/EntradaAlmoxarifadoItemService.java
... | ... | @@ -139,4 +139,6 @@ public interface EntradaAlmoxarifadoItemService extends GenericService<EntradaAl |
139 | 139 | public List<EntradaAlmoxarifadoItem> findItensPorEntradaId(Long idEntrada); |
140 | 140 | |
141 | 141 | Boolean existeItemVinculadoAMaterialLocalEstoque(Long idMaterialLocalEstoque); |
142 | + | |
143 | + public BigDecimal getValorFIFOPorMaterial(MaterialConsumo materialConsumo, BigDecimal quantidadeMovimentada); | |
142 | 144 | } | ... | ... |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/service/MaterialEstoqueFIFOItemService.java
1 | 1 | package br.com.centralit.api.service; |
2 | 2 | |
3 | +import java.util.List; | |
4 | + | |
3 | 5 | import br.com.centralit.api.model.MaterialEstoqueFIFOItem; |
4 | 6 | import br.com.centralit.framework.service.arquitetura.GenericService; |
5 | 7 | |
6 | 8 | public interface MaterialEstoqueFIFOItemService extends GenericService<MaterialEstoqueFIFOItem, Long> { |
9 | + | |
10 | + List<MaterialEstoqueFIFOItem> findFIFOsByMaterial(long idMaterial); | |
7 | 11 | |
8 | 12 | } | ... | ... |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/service/impl/AtendimentoRequisicaoConsumoItemServiceImpl.java
... | ... | @@ -164,8 +164,6 @@ public class AtendimentoRequisicaoConsumoItemServiceImpl extends GenericServiceI |
164 | 164 | idsDominiosTipoStatusRequisicao.add(statusFinalizado.getId()); |
165 | 165 | Dominio statusParcialmenteAtendida = this.dominioService.findByChaveAndCodigo(DominioAlmoxarifado.TIPO_STATUS_REQUISICAO, DominioAlmoxarifado.TIPO_STATUS_ATENDIDA_PARCIALMENTE); |
166 | 166 | idsDominiosTipoStatusRequisicao.add(statusParcialmenteAtendida.getId()); |
167 | - Dominio statusAtendida = this.dominioService.findByChaveAndCodigo(DominioAlmoxarifado.TIPO_STATUS_REQUISICAO, DominioAlmoxarifado.TIPO_STATUS_ATENDIDA); | |
168 | - idsDominiosTipoStatusRequisicao.add(statusAtendida.getId()); | |
169 | 167 | |
170 | 168 | RequisicaoConsumoItem requisicaoConsumoItem = this.requisicaoConsumoItemService.find(atendimentoRequisicaoConsumoItem.getRequisicaoConsumoItem().getId()); |
171 | 169 | ... | ... |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/service/impl/AtendimentoRequisicaoConsumoServiceImpl.java
... | ... | @@ -19,6 +19,7 @@ import br.com.centralit.api.model.AtendimentoRequisicaoConsumoItem; |
19 | 19 | import br.com.centralit.api.model.AtendimentoRequisicaoConsumoItemEndereco; |
20 | 20 | import br.com.centralit.api.model.DominioAlmoxarifado; |
21 | 21 | import br.com.centralit.api.model.MaterialLocalEstoque; |
22 | +import br.com.centralit.api.model.RequisicaoConsumoItem; | |
22 | 23 | import br.com.centralit.api.service.AtendimentoRequisicaoConsumoItemService; |
23 | 24 | import br.com.centralit.api.service.AtendimentoRequisicaoConsumoService; |
24 | 25 | import br.com.centralit.api.service.ConfiguracaoParametroSistemaService; |
... | ... | @@ -144,6 +145,11 @@ public class AtendimentoRequisicaoConsumoServiceImpl extends GenericServiceImpl< |
144 | 145 | |
145 | 146 | this.validarEntidade(entity, this.validator); |
146 | 147 | |
148 | + ValidacaoAtendimentoRequisicaoConsumoVH validacao = this.validarQuantidadesAtendidas(entity); | |
149 | + if(StringUtils.isNotBlank(validacao.getMensagemErro())){ | |
150 | + throw new BusinessException(validacao.getMensagemErro(), CodigoErro.REGRA_NEGOCIO.getValue()); | |
151 | + } | |
152 | + | |
147 | 153 | if (!UtilColecao.isVazio(entity.getAtendimentos())) { |
148 | 154 | |
149 | 155 | for (AtendimentoRequisicaoConsumo atendimento : entity.getAtendimentos()) { |
... | ... | @@ -289,8 +295,10 @@ public class AtendimentoRequisicaoConsumoServiceImpl extends GenericServiceImpl< |
289 | 295 | * @param entity |
290 | 296 | */ |
291 | 297 | private void atualizarStatusRquisicao(AtendimentoRequisicaoConsumo entity) { |
298 | + | |
299 | + entity.getRequisicaoConsumo().setTipoStatusRequisicao(this.dominioService.findByChaveAndCodigo(DominioAlmoxarifado.TIPO_STATUS_REQUISICAO, DominioAlmoxarifado.TIPO_STATUS_ATENDIDA_PARCIALMENTE)); | |
292 | 300 | |
293 | - Boolean atendidoCompletamente = Boolean.TRUE; | |
301 | + /*Boolean atendidoCompletamente = Boolean.TRUE; | |
294 | 302 | |
295 | 303 | for (AtendimentoRequisicaoConsumoItem atendimentoItem : entity.getAtendimentoRequisicaoConsumoItems()) { |
296 | 304 | |
... | ... | @@ -315,7 +323,7 @@ public class AtendimentoRequisicaoConsumoServiceImpl extends GenericServiceImpl< |
315 | 323 | |
316 | 324 | entity.getRequisicaoConsumo().setTipoStatusRequisicao(this.dominioService.findByChaveAndCodigo(DominioAlmoxarifado.TIPO_STATUS_REQUISICAO, DominioAlmoxarifado.TIPO_STATUS_ATENDIDA_PARCIALMENTE)); |
317 | 325 | |
318 | - } | |
326 | + }*/ | |
319 | 327 | |
320 | 328 | } |
321 | 329 | |
... | ... | @@ -329,8 +337,61 @@ public class AtendimentoRequisicaoConsumoServiceImpl extends GenericServiceImpl< |
329 | 337 | private void montarEntidade(AtendimentoRequisicaoConsumo entity) { |
330 | 338 | |
331 | 339 | entity.setRequisicaoConsumo(this.requisicaoConsumoService.find(entity.getRequisicaoConsumo().getId())); |
332 | - | |
333 | - List<AtendimentoRequisicaoConsumoItem> listaSemAtendimentosComQuantidadeZero = new ArrayList<AtendimentoRequisicaoConsumoItem>(); | |
340 | + | |
341 | + for (AtendimentoRequisicaoConsumoItem atendimentoItem : entity.getAtendimentoRequisicaoConsumoItems()) { | |
342 | + | |
343 | + RequisicaoConsumoItem requisicaoConsumoItem = this.requisicaoConsumoItemService.find(atendimentoItem.getRequisicaoConsumoItem().getId()); | |
344 | + requisicaoConsumoItem.setQuantidadeAtendida(atendimentoItem.getQuantidade()); | |
345 | + | |
346 | + atendimentoItem.setAtendimentoRequisicaoConsumo(entity); | |
347 | + atendimentoItem.setOrganizacao(getUsuario().getOrganizacao()); | |
348 | + atendimentoItem.setRequisicaoConsumoItem(requisicaoConsumoItem); | |
349 | + for (AtendimentoRequisicaoConsumoItemEndereco atendimentoRequisicaoConsumoItemEndereco : atendimentoItem.getAtendimentoRequisicaoConsumoItemEnderecos()) { | |
350 | + atendimentoRequisicaoConsumoItemEndereco.setAtendimentoRequisicaoConsumoItem(atendimentoItem); | |
351 | + } | |
352 | + | |
353 | + this.requisicaoConsumoItemService.merge(requisicaoConsumoItem); | |
354 | + } | |
355 | + | |
356 | + /*if(entity.getRequisicaoConsumo().getRequisicaoConsumoItens().size() > entity.getAtendimentoRequisicaoConsumoItems().size()){ | |
357 | + | |
358 | + List<AtendimentoRequisicaoConsumoItem> listaAtendimentoItem = new ArrayList<AtendimentoRequisicaoConsumoItem>(); | |
359 | + boolean addNovoAtendimentoItem = true; | |
360 | + | |
361 | + for (RequisicaoConsumoItem requisicaoConsumoItem : entity.getRequisicaoConsumo().getRequisicaoConsumoItens()) { | |
362 | + | |
363 | + for (AtendimentoRequisicaoConsumoItem atendimentoRequisicaoConsumoItem : entity.getAtendimentoRequisicaoConsumoItems()) { | |
364 | + | |
365 | + if(requisicaoConsumoItem.getMaterialConsumo().getId().doubleValue() == atendimentoRequisicaoConsumoItem.getMaterial().getId().doubleValue()){ | |
366 | + atendimentoRequisicaoConsumoItem.setAtendimentoRequisicaoConsumo(entity); | |
367 | + atendimentoRequisicaoConsumoItem.setOrganizacao(getUsuario().getOrganizacao()); | |
368 | + atendimentoRequisicaoConsumoItem.setRequisicaoConsumoItem(requisicaoConsumoItem); | |
369 | + atendimentoRequisicaoConsumoItem.setMaterial(this.materialConsumoService.find(atendimentoRequisicaoConsumoItem.getMaterial().getId())); | |
370 | + addNovoAtendimentoItem = false; | |
371 | + break; | |
372 | + } | |
373 | + } | |
374 | + | |
375 | + if(addNovoAtendimentoItem){ | |
376 | + AtendimentoRequisicaoConsumoItem item = new AtendimentoRequisicaoConsumoItem(); | |
377 | + item.setAtendimentoRequisicaoConsumo(entity); | |
378 | + item.setOrganizacao(getUsuario().getOrganizacao()); | |
379 | + item.setRequisicaoConsumoItem(requisicaoConsumoItem); | |
380 | + item.setMaterial(requisicaoConsumoItem.getMaterialConsumo()); | |
381 | + | |
382 | + AtendimentoRequisicaoConsumoItemEndereco atendimentoRequisicaoConsumoItemEndereco = new AtendimentoRequisicaoConsumoItemEndereco(); | |
383 | + atendimentoRequisicaoConsumoItemEndereco.setAtendimentoRequisicaoConsumoItem(item); | |
384 | + atendimentoRequisicaoConsumoItemEndereco.setQuantidade(new BigDecimal(0)); | |
385 | + | |
386 | + List<AtendimentoRequisicaoConsumoItemEndereco> listaAtendimentoRequisicaoConsumoItemEndereco = new ArrayList<AtendimentoRequisicaoConsumoItemEndereco>(); | |
387 | + listaAtendimentoRequisicaoConsumoItemEndereco.add(atendimentoRequisicaoConsumoItemEndereco); | |
388 | + item.setAtendimentoRequisicaoConsumoItemEnderecos(listaAtendimentoRequisicaoConsumoItemEndereco); | |
389 | + } | |
390 | + addNovoAtendimentoItem = true; | |
391 | + } | |
392 | + }*/ | |
393 | + | |
394 | + /*List<AtendimentoRequisicaoConsumoItem> listaSemAtendimentosComQuantidadeZero = new ArrayList<AtendimentoRequisicaoConsumoItem>(); | |
334 | 395 | |
335 | 396 | for (AtendimentoRequisicaoConsumoItem atendimentoItem : entity.getAtendimentoRequisicaoConsumoItems()) { |
336 | 397 | if(atendimentoItem.getQuantidade() == null){ |
... | ... | @@ -347,7 +408,7 @@ public class AtendimentoRequisicaoConsumoServiceImpl extends GenericServiceImpl< |
347 | 408 | atendimentoItem.setOrganizacao(getUsuario().getOrganizacao()); |
348 | 409 | atendimentoItem.setRequisicaoConsumoItem(this.requisicaoConsumoItemService.find(atendimentoItem.getRequisicaoConsumoItem().getId())); |
349 | 410 | |
350 | - atendimentoItem.setMaterial(this.materialConsumoService.find(atendimentoItem.getMaterial().getId())); | |
411 | + atendimentoItem.setMaterial(this.materialConsumoService.find(atendimentoItem.getMaterial().getId())); | |
351 | 412 | BigDecimal qtdMaterialEmEstoque = this.materialConsumoService.getQuantidadeAtualMaterial(atendimentoItem.getMaterial().getId(), getUsuario().getOrganizacao().getId()); |
352 | 413 | |
353 | 414 | if (!atendimentoItem.isNew()) { |
... | ... | @@ -371,14 +432,14 @@ public class AtendimentoRequisicaoConsumoServiceImpl extends GenericServiceImpl< |
371 | 432 | |
372 | 433 | } |
373 | 434 | |
374 | -// if (!UtilObjeto.isReferencia(atendimentoItem.getQuantidade()) || atendimentoItem.getQuantidade().doubleValue() <= 0) { | |
375 | -// | |
376 | -// throw new BusinessException(VALIDACAO_QUANTIDADE_ZERADA_NEGATIVA, CodigoErro.REGRA_NEGOCIO.getValue(), atendimentoItem.getMaterial().getDescricao()); | |
377 | -// } | |
435 | + if (!UtilObjeto.isReferencia(atendimentoItem.getQuantidade()) || atendimentoItem.getQuantidade().doubleValue() <= 0) { | |
436 | + | |
437 | + throw new BusinessException(VALIDACAO_QUANTIDADE_ZERADA_NEGATIVA, CodigoErro.REGRA_NEGOCIO.getValue(), atendimentoItem.getMaterial().getDescricao()); | |
438 | + } | |
378 | 439 | |
379 | 440 | entity.getAtendimentoRequisicaoConsumoItems().add(atendimentoItem); |
380 | 441 | |
381 | - } | |
442 | + }*/ | |
382 | 443 | |
383 | 444 | } |
384 | 445 | |
... | ... | @@ -494,20 +555,20 @@ public class AtendimentoRequisicaoConsumoServiceImpl extends GenericServiceImpl< |
494 | 555 | */ |
495 | 556 | private void configurarNumeroAtendimento(AtendimentoRequisicaoConsumo entity) { |
496 | 557 | |
497 | - if(entity.getOrganizacao() == null && entity.getRequisicaoConsumo() != null && entity.getRequisicaoConsumo().getOrganizacao() != null){ | |
498 | - entity.setOrganizacao(entity.getRequisicaoConsumo().getOrganizacao()); | |
499 | - } | |
500 | - | |
501 | - AtendimentoRequisicaoConsumo ultimoRegistro = | |
502 | - (AtendimentoRequisicaoConsumo) atendimentoRequisicaoConsumoDao.buscarUltimoRegistroComOrdenadoParametrizada("numeroAtendimento", entity.getOrganizacao().getId()); | |
503 | - | |
504 | - Long sequencial = null; | |
505 | - if (UtilObjeto.isReferencia(ultimoRegistro)) { | |
506 | - sequencial = ultimoRegistro.getNumeroAtendimento() == null ? null : Long.parseLong(ultimoRegistro.getNumeroAtendimento()); | |
507 | - } | |
508 | - String codigo = configuracaoParametroSistemaService.gerarNumeroIdentificacao(sequencial, entity.getOrganizacao()); | |
558 | +// if(entity.getOrganizacao() == null && entity.getRequisicaoConsumo() != null && entity.getRequisicaoConsumo().getOrganizacao() != null){ | |
559 | +// entity.setOrganizacao(entity.getRequisicaoConsumo().getOrganizacao()); | |
560 | +// } | |
561 | +// | |
562 | +// AtendimentoRequisicaoConsumo ultimoRegistro = | |
563 | +// (AtendimentoRequisicaoConsumo) atendimentoRequisicaoConsumoDao.buscarUltimoRegistroComOrdenadoParametrizada("numeroAtendimento", entity.getOrganizacao().getId()); | |
564 | +// | |
565 | +// Long sequencial = null; | |
566 | +// if (UtilObjeto.isReferencia(ultimoRegistro)) { | |
567 | +// sequencial = ultimoRegistro.getNumeroAtendimento() == null ? null : Long.parseLong(ultimoRegistro.getNumeroAtendimento()); | |
568 | +// } | |
569 | +// String codigo = configuracaoParametroSistemaService.gerarNumeroIdentificacao(sequencial, entity.getOrganizacao()); | |
509 | 570 | |
510 | - entity.setNumeroAtendimento(codigo); | |
571 | + entity.setNumeroAtendimento(entity.getRequisicaoConsumo().getNumeroRequisicao()); | |
511 | 572 | } |
512 | 573 | |
513 | 574 | @Override | ... | ... |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/service/impl/EntradaAlmoxarifadoItemServiceImpl.java
... | ... | @@ -15,12 +15,14 @@ import br.com.centralit.api.model.ContaContabilMovimento; |
15 | 15 | import br.com.centralit.api.model.EntradaAlmoxarifadoItem; |
16 | 16 | import br.com.centralit.api.model.EstruturaOrganizacional; |
17 | 17 | import br.com.centralit.api.model.MaterialConsumo; |
18 | +import br.com.centralit.api.model.MaterialEstoqueFIFOItem; | |
18 | 19 | import br.com.centralit.api.model.MovimentoEstoque; |
19 | 20 | import br.com.centralit.api.service.ConfiguracaoParametroSistemaService; |
20 | 21 | import br.com.centralit.api.service.ContaContabilMovimentoAlmoxarifadoService; |
21 | 22 | import br.com.centralit.api.service.EntradaAlmoxarifadoItemService; |
22 | 23 | import br.com.centralit.api.service.EstruturaOrganizacionalService; |
23 | 24 | import br.com.centralit.api.service.MaterialConsumoService; |
25 | +import br.com.centralit.api.service.MaterialEstoqueFIFOItemService; | |
24 | 26 | import br.com.centralit.api.service.MovimentoEstoqueService; |
25 | 27 | import br.com.centralit.framework.exception.BusinessException; |
26 | 28 | import br.com.centralit.framework.exception.CodigoErro; |
... | ... | @@ -76,6 +78,9 @@ public class EntradaAlmoxarifadoItemServiceImpl extends GenericServiceImpl<Entra |
76 | 78 | |
77 | 79 | @Autowired |
78 | 80 | private ContaContabilMovimentoAlmoxarifadoService contaContabilMovimentoAlmoxarifadoService; |
81 | + | |
82 | + @Autowired | |
83 | + private MaterialEstoqueFIFOItemService materialEstoqueFIFOItemService; | |
79 | 84 | |
80 | 85 | /** |
81 | 86 | * Responsável pela criação de novas instâncias desta classe. |
... | ... | @@ -208,6 +213,38 @@ public class EntradaAlmoxarifadoItemServiceImpl extends GenericServiceImpl<Entra |
208 | 213 | public Collection<EntradaAlmoxarifadoItem> obterEntradaItemComSaldoPorMaterial(Long idMaterial) { |
209 | 214 | return this.entradaAlmoxarifadoItemDao.obterEntradaItemComSaldoPorMaterial(idMaterial); |
210 | 215 | } |
216 | + | |
217 | + public BigDecimal getValorFIFOPorMaterial(MaterialConsumo materialConsumo, BigDecimal quantidadeMovimentada) { | |
218 | + BigDecimal retorno = BigDecimal.ZERO; | |
219 | + | |
220 | + List<MaterialEstoqueFIFOItem> fifOsByMaterial = this.materialEstoqueFIFOItemService.findFIFOsByMaterial(materialConsumo.getId()); | |
221 | + | |
222 | + for (MaterialEstoqueFIFOItem materialEstoqueFIFOItem : fifOsByMaterial) { | |
223 | + | |
224 | + if (materialEstoqueFIFOItem.getQuantidadeRestante().compareTo(quantidadeMovimentada) > 0) { | |
225 | + retorno = retorno.add(quantidadeMovimentada.multiply(materialEstoqueFIFOItem.getValorUnitario())); | |
226 | + materialEstoqueFIFOItem.setQuantidadeRestante(materialEstoqueFIFOItem.getQuantidadeRestante().subtract(quantidadeMovimentada)); | |
227 | + materialEstoqueFIFOItem.setValorSobra(materialEstoqueFIFOItem.getQuantidadeRestante().multiply(materialEstoqueFIFOItem.getValorUnitario())); | |
228 | + this.materialEstoqueFIFOItemService.merge(materialEstoqueFIFOItem); | |
229 | + break; | |
230 | + | |
231 | + } else if (materialEstoqueFIFOItem.getQuantidadeRestante().compareTo(quantidadeMovimentada) == 0) { | |
232 | + //TODO ERICK ADICIONAR VALOR RESTANTE | |
233 | + retorno = retorno.add(materialEstoqueFIFOItem.getValorSobra()).add(materialEstoqueFIFOItem.getValorSobra()); | |
234 | + materialEstoqueFIFOItem.setQuantidadeRestante(materialEstoqueFIFOItem.getQuantidadeRestante().subtract(quantidadeMovimentada)); | |
235 | + materialEstoqueFIFOItem.setValorSobra(materialEstoqueFIFOItem.getQuantidadeRestante().multiply(materialEstoqueFIFOItem.getValorUnitario())); | |
236 | + this.materialEstoqueFIFOItemService.merge(materialEstoqueFIFOItem); | |
237 | + break; | |
238 | + | |
239 | + } else { | |
240 | + retorno = retorno.add((materialEstoqueFIFOItem.getQuantidadeRestante().multiply(materialEstoqueFIFOItem.getValorUnitario()))).add(materialEstoqueFIFOItem.getValorSobra()); | |
241 | + quantidadeMovimentada = quantidadeMovimentada.subtract(materialEstoqueFIFOItem.getQuantidadeRestante()); | |
242 | + materialEstoqueFIFOItem.setQuantidadeRestante(BigDecimal.ZERO); | |
243 | + this.materialEstoqueFIFOItemService.merge(materialEstoqueFIFOItem); | |
244 | + } | |
245 | + } | |
246 | + return retorno; | |
247 | + } | |
211 | 248 | |
212 | 249 | /** |
213 | 250 | * {@inheritDoc} |
... | ... | @@ -217,24 +254,29 @@ public class EntradaAlmoxarifadoItemServiceImpl extends GenericServiceImpl<Entra |
217 | 254 | public BigDecimal realizaMovimentoSaida(MaterialConsumo materialConsumo, BigDecimal quantidadeMovimentada) { |
218 | 255 | BigDecimal retorno = BigDecimal.ZERO; |
219 | 256 | |
220 | - /*Collection<EntradaAlmoxarifadoItem> entradaAlmoxarifadoItems = this.obterEntradaItemComSaldoPorMaterial(materialConsumo.getId()); | |
257 | + /* Collection<EntradaAlmoxarifadoItem> entradaAlmoxarifadoItems = this.obterEntradaItemComSaldoPorMaterial(materialConsumo.getId()); | |
221 | 258 | |
222 | 259 | for (EntradaAlmoxarifadoItem itemEntrada : entradaAlmoxarifadoItems) { |
223 | - if (itemEntrada.getQuantidadeSaldo().compareTo(quantidadeMovimentada) > 0) { | |
260 | + | |
261 | + | |
262 | + if (itemEntrada.getMaterialLocalEstoque().getQuantidade().compareTo(quantidadeMovimentada) > 0) { | |
224 | 263 | retorno = retorno.add(quantidadeMovimentada.multiply(itemEntrada.getValorUnitario())); |
225 | - itemEntrada.setQuantidadeSaldo(itemEntrada.getQuantidadeSaldo().subtract(quantidadeMovimentada)); | |
264 | + itemEntrada.getMaterialLocalEstoque().setQuantidade(itemEntrada.getMaterialLocalEstoque().getQuantidade().subtract(quantidadeMovimentada)); | |
226 | 265 | this.save(itemEntrada); |
227 | 266 | break; |
228 | - } else if (itemEntrada.getQuantidadeSaldo().compareTo(quantidadeMovimentada) == 0) { | |
267 | + | |
268 | + } else if (itemEntrada.getMaterialLocalEstoque().getQuantidade().compareTo(quantidadeMovimentada) == 0) { | |
229 | 269 | retorno = retorno.add((quantidadeMovimentada.multiply(itemEntrada.getValorUnitario())).add(itemEntrada.getValorSobra())); |
230 | - itemEntrada.setQuantidadeSaldo(itemEntrada.getQuantidadeSaldo().subtract(quantidadeMovimentada)); | |
270 | + itemEntrada.getMaterialLocalEstoque().setQuantidade(itemEntrada.getMaterialLocalEstoque().getQuantidade().subtract(quantidadeMovimentada)); | |
231 | 271 | this.save(itemEntrada); |
232 | 272 | break; |
273 | + | |
233 | 274 | } else { |
234 | - retorno = retorno.add((itemEntrada.getQuantidadeSaldo().multiply(itemEntrada.getValorUnitario())).add(itemEntrada.getValorSobra())); | |
235 | - quantidadeMovimentada = quantidadeMovimentada.subtract(itemEntrada.getQuantidadeSaldo()); | |
236 | - itemEntrada.setQuantidadeSaldo(BigDecimal.ZERO); | |
275 | + retorno = retorno.add((itemEntrada.getMaterialLocalEstoque().getQuantidade().multiply(itemEntrada.getValorUnitario())).add(itemEntrada.getValorSobra())); | |
276 | + quantidadeMovimentada = quantidadeMovimentada.subtract(itemEntrada.getMaterialLocalEstoque().getQuantidade()); | |
277 | + itemEntrada.getMaterialLocalEstoque().setQuantidade(BigDecimal.ZERO); | |
237 | 278 | this.save(itemEntrada); |
279 | + | |
238 | 280 | } |
239 | 281 | }*/ |
240 | 282 | ... | ... |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/service/impl/MaterialEstoqueFIFOItemServiceImpl.java
1 | 1 | package br.com.centralit.api.service.impl; |
2 | 2 | |
3 | +import java.util.List; | |
4 | + | |
3 | 5 | import org.springframework.beans.factory.annotation.Autowired; |
4 | 6 | import org.springframework.beans.factory.annotation.Qualifier; |
5 | 7 | import org.springframework.stereotype.Service; |
... | ... | @@ -32,4 +34,9 @@ public class MaterialEstoqueFIFOItemServiceImpl extends GenericServiceImpl<Mater |
32 | 34 | return super.remove(fifoItem); |
33 | 35 | } |
34 | 36 | |
37 | + @Override | |
38 | + public List<MaterialEstoqueFIFOItem> findFIFOsByMaterial(long idMaterial) { | |
39 | + return materialEstoqueFIFOItemDao.findFIFOsByMaterial(idMaterial); | |
40 | + } | |
41 | + | |
35 | 42 | } | ... | ... |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/service/impl/MovimentoEstoqueServiceImpl.java
... | ... | @@ -19,6 +19,7 @@ import org.springframework.validation.Validator; |
19 | 19 | import br.com.centralit.api.dao.MovimentoEstoqueDao; |
20 | 20 | import br.com.centralit.api.model.AtendimentoRequisicaoConsumo; |
21 | 21 | import br.com.centralit.api.model.AtendimentoRequisicaoConsumoItem; |
22 | +import br.com.centralit.api.model.AtendimentoRequisicaoConsumoItemEndereco; | |
22 | 23 | import br.com.centralit.api.model.BaixaAlmoxarifado; |
23 | 24 | import br.com.centralit.api.model.BaixaAlmoxarifadoItem; |
24 | 25 | import br.com.centralit.api.model.Devolucao; |
... | ... | @@ -415,27 +416,37 @@ public class MovimentoEstoqueServiceImpl extends GenericServiceImpl<MovimentoEst |
415 | 416 | |
416 | 417 | for (AtendimentoRequisicaoConsumoItem atendimentoRequisicaoConsumoItem : atendimento.getAtendimentoRequisicaoConsumoItems()) { |
417 | 418 | |
418 | - BigDecimal valorMovimentoFIFO = this.entradaAlmoxarifadoItemService.realizaMovimentoSaida(atendimentoRequisicaoConsumoItem.getMaterial(), atendimentoRequisicaoConsumoItem.getQuantidade()); | |
419 | - BigDecimal valorMovimentoMediaMovel = BigDecimal.ZERO;//BigDecimal valorMovimentoMediaMovel = this.materialEstoqueSaldoMedioService.realizaMovimentoSaida(atendimentoRequisicaoConsumoItem.getMaterial(), atendimentoRequisicaoConsumoItem.getQuantidade()); | |
420 | - | |
421 | - MovimentoEstoque movimentoEstoque = new MovimentoEstoque(atendimento.getDataAtendimento(), atendimentoRequisicaoConsumoItem.getQuantidade().multiply(BigDecimal.valueOf(-1)), | |
422 | - valorMovimentoFIFO.multiply(BigDecimal.valueOf(-1)), valorMovimentoMediaMovel.multiply(BigDecimal.valueOf(-1)), tipoMovimento); //Movimentos negativos pois o valor esta saindo do estoque. | |
423 | - | |
424 | - //TODO Corrigir movimento de atendimento com versão nova | |
419 | + BigDecimal valorMovimentoFIFO = this.entradaAlmoxarifadoItemService.getValorFIFOPorMaterial(atendimentoRequisicaoConsumoItem.getMaterial(), atendimentoRequisicaoConsumoItem.getQuantidade()); | |
420 | + BigDecimal valorMovimentoMediaMovel = this.materialEstoqueService.findByIdMaterial(atendimentoRequisicaoConsumoItem.getMaterial().getId()).getValorUnitarioMedio(); | |
425 | 421 | |
426 | - /*movimentoEstoque.setAtendimentoRequisicaoConsumoItem(atendimentoRequisicaoConsumoItem); | |
427 | - movimentoEstoque.setLocalEstoque(this.materialLocalEstoqueService.find(getUsuario().getOrganizacao().getId())); | |
428 | - movimentoEstoque.setMaterial(atendimentoRequisicaoConsumoItem.getMaterial());*/ | |
429 | - | |
430 | - movimentos.add(movimentoEstoque); | |
431 | - | |
432 | - String tipoAvaliacao = this.configuracaoParametroSistemaService.getParametro("TIPO_AVALIACAO_MONETARIA_ESTOQUE", atendimento.getOrganizacao()).getValor(); | |
433 | - | |
434 | - if (DominioAlmoxarifado.TIPO_AVALIACAO_MONETARIA_FIFO_NOME == tipoAvaliacao) { //Realiza movimento de saida em conta contábil baseado em FIFO se estiver configurado como tal. | |
435 | - this.contaContabilMovimentoService.salvaMovimentoSaidaAtendimento(movimentoEstoque.getMaterial().getContaContabil(), valorMovimentoFIFO, classeReferenciaAtendimento, atendimentoRequisicaoConsumoItem.getId()); | |
436 | - } else { //Realiza movimento de saida em conta contábil baseado em Média Móvel (Padrão) | |
437 | - this.contaContabilMovimentoService.salvaMovimentoSaidaAtendimento(movimentoEstoque.getMaterial().getContaContabil(), valorMovimentoMediaMovel, classeReferenciaAtendimento, atendimentoRequisicaoConsumoItem.getId()); | |
422 | + for (AtendimentoRequisicaoConsumoItemEndereco atendimentoRequisicaoConsumoItemEndereco : atendimentoRequisicaoConsumoItem.getAtendimentoRequisicaoConsumoItemEnderecos()) { | |
423 | + | |
424 | + MovimentoEstoque movimentoEstoque = new MovimentoEstoque(atendimento.getDataAtendimento(), atendimentoRequisicaoConsumoItem.getQuantidade().multiply(BigDecimal.valueOf(-1)), | |
425 | + valorMovimentoFIFO.multiply(BigDecimal.valueOf(-1)), valorMovimentoMediaMovel.multiply(BigDecimal.valueOf(-1)), tipoMovimento); //Movimentos negativos pois o valor esta saindo do estoque. | |
426 | + | |
427 | + movimentoEstoque.setDominioClasseReferencia(classeReferenciaAtendimento); | |
428 | + movimentoEstoque.setIdClasseReferencia(atendimentoRequisicaoConsumoItem.getId()); | |
429 | + movimentoEstoque.setMaterialLocalEstoque(atendimentoRequisicaoConsumoItemEndereco.getMaterialLocalEstoque()); | |
430 | + movimentoEstoque.setMaterialEstoque(movimentoEstoque.getMaterialEstoque()); | |
431 | + movimentoEstoque.setMaterial(atendimentoRequisicaoConsumoItem.getMaterial()); | |
432 | + | |
433 | + String tipoAvaliacao = this.configuracaoParametroSistemaService.getParametro("TIPO_AVALIACAO_MONETARIA_ESTOQUE", atendimento.getOrganizacao()).getValor(); | |
434 | + | |
435 | + MaterialConsumo materialConsumo = this.materialConsumoService.find(movimentoEstoque.getMaterial().getId()); | |
436 | + | |
437 | + if (DominioAlmoxarifado.TIPO_AVALIACAO_MONETARIA_FIFO_NOME == tipoAvaliacao) { //Realiza movimento de saida em conta contábil baseado em FIFO se estiver configurado como tal. | |
438 | + this.contaContabilMovimentoService.salvaMovimentoSaidaAtendimento(materialConsumo.getContaContabil(), valorMovimentoFIFO, classeReferenciaAtendimento, atendimentoRequisicaoConsumoItem.getId()); | |
439 | + } else { //Realiza movimento de saida em conta contábil baseado em Média Móvel (Padrão) | |
440 | + this.contaContabilMovimentoService.salvaMovimentoSaidaAtendimento(materialConsumo.getContaContabil(), valorMovimentoMediaMovel, classeReferenciaAtendimento, atendimentoRequisicaoConsumoItem.getId()); | |
441 | + } | |
442 | + | |
443 | + MaterialLocalEstoque materialLocalEstoque = this.materialLocalEstoqueService.find(atendimentoRequisicaoConsumoItemEndereco.getMaterialLocalEstoque().getId()); | |
444 | + materialLocalEstoque.setQuantidade(materialLocalEstoque.getQuantidade().subtract(atendimentoRequisicaoConsumoItem.getQuantidade())); | |
445 | + this.materialLocalEstoqueService.merge(materialLocalEstoque); | |
446 | + | |
447 | + movimentos.add(movimentoEstoque); | |
438 | 448 | } |
449 | + | |
439 | 450 | } |
440 | 451 | |
441 | 452 | this.saveList(movimentos); |
... | ... | @@ -671,8 +682,10 @@ public class MovimentoEstoqueServiceImpl extends GenericServiceImpl<MovimentoEst |
671 | 682 | @Override |
672 | 683 | public Collection<MovimentoEstoque> findAllByEntradaItem(EntradaAlmoxarifadoItem entradaAlmoxarifadoItem) { |
673 | 684 | Dominio classeReferenciaEntradaItem = this.dominioService.findByChaveAndCodigo(DominioMaterial.CLASSE_REFERENCIA, DominioMaterial.REFERENCIA_ENTRADA_ALMOXARIFADO_ITEM); |
674 | - | |
675 | - return this.findAllByClasseReferencia(classeReferenciaEntradaItem, entradaAlmoxarifadoItem.getId()); | |
685 | + if(entradaAlmoxarifadoItem.getId() != null){ | |
686 | + return this.findAllByClasseReferencia(classeReferenciaEntradaItem, entradaAlmoxarifadoItem.getId()); | |
687 | + } | |
688 | + return new ArrayList<MovimentoEstoque>(); | |
676 | 689 | } |
677 | 690 | |
678 | 691 | } | ... | ... |
cit-almoxarifado-api/src/main/java/br/com/centralit/api/service/impl/RequisicaoConsumoItemServiceImpl.java
... | ... | @@ -142,10 +142,9 @@ public class RequisicaoConsumoItemServiceImpl extends GenericServiceImpl<Requisi |
142 | 142 | public Long findRequisicaoAnteriorPorMaterial(MaterialConsumo materialConsumo, EstruturaOrganizacional unidadeRequisitante) { |
143 | 143 | |
144 | 144 | Dominio statusFinalizado = this.dominioService.findByChaveAndCodigo(DominioAlmoxarifado.TIPO_STATUS_REQUISICAO, DominioAlmoxarifado.TIPO_STATUS_FINALIZADA); |
145 | - Dominio statusAtendida = this.dominioService.findByChaveAndCodigo(DominioAlmoxarifado.TIPO_STATUS_REQUISICAO, DominioAlmoxarifado.TIPO_STATUS_ATENDIDA); | |
146 | 145 | Dominio statusParcialmenteAtendida = this.dominioService.findByChaveAndCodigo(DominioAlmoxarifado.TIPO_STATUS_REQUISICAO, DominioAlmoxarifado.TIPO_STATUS_ATENDIDA_PARCIALMENTE); |
147 | 146 | |
148 | - return this.requisicaoConsumoItemDao.findRequisicaoAnteriorPorMaterial(materialConsumo, unidadeRequisitante, statusFinalizado, statusParcialmenteAtendida, statusAtendida); | |
147 | + return this.requisicaoConsumoItemDao.findRequisicaoAnteriorPorMaterial(materialConsumo, unidadeRequisitante, statusFinalizado, statusParcialmenteAtendida); | |
149 | 148 | } |
150 | 149 | |
151 | 150 | ... | ... |
cit-almoxarifado-web/src/main/webapp/assets/js/angular/custom/controller/AtendimentoRequisicaoConsumoController.js
... | ... | @@ -414,6 +414,7 @@ citApp.controller( 'AtendimentoRequisicaoConsumoController', |
414 | 414 | itemEndereco.$hasError = true; |
415 | 415 | } |
416 | 416 | }); |
417 | + | |
417 | 418 | }); |
418 | 419 | }); |
419 | 420 | }); |
... | ... | @@ -425,13 +426,12 @@ citApp.controller( 'AtendimentoRequisicaoConsumoController', |
425 | 426 | $scope.listaSelecionados = []; |
426 | 427 | $scope.showAlert("success", $translate.instant('MSG.REGISTRO_SALVO')); |
427 | 428 | $scope.atendimentoRequisicaoConsumoForm.$submitted = false; |
428 | - $scope.$modalInstance.dismiss('cancel'); | |
429 | 429 | angular.element('#searchAtendimentoRequisicaoConsumo').scope().fetchResult(); |
430 | 430 | $scope.resetForm(); |
431 | 431 | $scope.setLoading(false); |
432 | 432 | }); |
433 | 433 | } |
434 | - }); | |
434 | + }); | |
435 | 435 | } |
436 | 436 | } else { |
437 | 437 | $scope.showAlert('warning', $translate.instant('ALMOXARIFADO.MSG.ATENDA_AO_MENOS_UMA_REQUISICAO'), " ", false); | ... | ... |