fix bug Mass Suppl. Stock Move Invoicing
regler le probleme de facturations en mass pour BR , relier la facture et le bon de recepetion
This commit is contained in:
@@ -523,13 +523,16 @@ public class StockMoveMultiInvoiceServiceImpl implements StockMoveMultiInvoiceSe
|
|||||||
} else {
|
} else {
|
||||||
stockMoveList.forEach(
|
stockMoveList.forEach(
|
||||||
stockMove -> {
|
stockMove -> {
|
||||||
if (stockMove.getInvoiceSet() != null) {
|
|
||||||
stockMove.getInvoiceSet().add(invoice);
|
|
||||||
} else {
|
|
||||||
Set<Invoice> invoiceSet = new HashSet<>();
|
Set<Invoice> invoiceSet = new HashSet<>();
|
||||||
invoiceSet.add(invoice);
|
invoiceSet.add(invoice);
|
||||||
stockMove.setInvoiceSet(invoiceSet);
|
stockMove.setInvoiceSet(invoiceSet);
|
||||||
}
|
|
||||||
|
String sqlString = String.format("INSERT INTO public.account_invoice_stock_move_set( invoice_set, stock_move_set) VALUES (:invoiceSet, :stockMoveSet)");
|
||||||
|
javax.persistence.Query query = JPA.em().createNativeQuery(sqlString);
|
||||||
|
query.setParameter("invoiceSet", invoice.getId());
|
||||||
|
query.setParameter("stockMoveSet", stockMove.getId());
|
||||||
|
JPA.runInTransaction(query::executeUpdate);
|
||||||
});
|
});
|
||||||
return Optional.of(invoice);
|
return Optional.of(invoice);
|
||||||
}
|
}
|
||||||
@@ -676,14 +679,8 @@ public class StockMoveMultiInvoiceServiceImpl implements StockMoveMultiInvoiceSe
|
|||||||
/** This method will throw an exception if the given stock move is already invoiced. */
|
/** This method will throw an exception if the given stock move is already invoiced. */
|
||||||
protected void checkIfAlreadyInvoiced(StockMove stockMove) throws AxelorException {
|
protected void checkIfAlreadyInvoiced(StockMove stockMove) throws AxelorException {
|
||||||
if (stockMove.getInvoiceSet() != null
|
if (stockMove.getInvoiceSet() != null
|
||||||
&& stockMove
|
&& stockMove.getInvoiceSet().stream()
|
||||||
.getStockMoveLineList()
|
.anyMatch(invoice -> invoice.getStatusSelect() != InvoiceRepository.STATUS_CANCELED)) {
|
||||||
.stream()
|
|
||||||
.map(StockMoveLine::getQtyInvoiced)
|
|
||||||
.reduce(BigDecimal::add)
|
|
||||||
.orElse(BigDecimal.ZERO)
|
|
||||||
.compareTo(BigDecimal.ZERO)
|
|
||||||
== 0) {
|
|
||||||
String templateMessage;
|
String templateMessage;
|
||||||
if (stockMove.getTypeSelect() == StockMoveRepository.TYPE_OUTGOING) {
|
if (stockMove.getTypeSelect() == StockMoveRepository.TYPE_OUTGOING) {
|
||||||
templateMessage = IExceptionMessage.OUTGOING_STOCK_MOVE_INVOICE_EXISTS;
|
templateMessage = IExceptionMessage.OUTGOING_STOCK_MOVE_INVOICE_EXISTS;
|
||||||
|
|||||||
Reference in New Issue
Block a user