1 Commits

Author SHA1 Message Date
zakaria.hachem
da686191fc fix invoice line creation 2026-02-18 09:20:04 +01:00
4 changed files with 63 additions and 135 deletions

View File

@@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<domain-models xmlns="http://axelor.com/xml/ns/domain-models" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://axelor.com/xml/ns/domain-models http://axelor.com/xml/ns/domain-models/domain-models_5.2.xsd">
<module name="base" package="com.axelor.apps.base.db" />
<entity name="Address" lang="java">
<many-to-one name="state" ref="com.axelor.apps.crm.db.StateAdministration" title="State" />
</entity>
</domain-models>

View File

@@ -1,46 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<domain-models xmlns="http://axelor.com/xml/ns/domain-models"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://axelor.com/xml/ns/domain-models http://axelor.com/xml/ns/domain-models/domain-models_5.2.xsd">
<module name="crm" package="com.axelor.apps.crm.db"/>
<entity name="StateAdministration" lang="java">
<string name="name" title="Name" required="true"/>
<string name="typeSelect" title="Type" selection="state.administration.type.select" required="true"/>
<many-to-one name="parent" ref="com.axelor.apps.crm.db.StateAdministration"/>
<string name="fullName" namecolumn="true" title="Full name">
<![CDATA[
String fullName = "";
com.axelor.apps.crm.db.StateAdministration current = this;
while (current != null && current.getName() != null) {
if (current == current.getParent()) {
break;
}
if (fullName.isEmpty()) {
fullName = current.getName();
} else {
fullName = current.getName() + " - " + fullName;
}
current = current.getParent();
}
return fullName;
]]>
</string>
</entity>
</domain-models>

View File

@@ -143,11 +143,4 @@
<option value="1">Some user groups</option> <option value="1">Some user groups</option>
</selection> </selection>
<selection name="state.administration.type.select">
<option value="0">Region</option>
<option value="1">Sub Region</option>
<option value="2">Wilaya</option>
<option value="3">Commune</option>
</selection>
</object-views> </object-views>

View File

@@ -130,8 +130,7 @@ public class StockMoveInvoiceServiceImpl implements StockMoveInvoiceService {
if (StockMoveRepository.ORIGIN_SALE_ORDER.equals(stockMove.getOriginTypeSelect())) { if (StockMoveRepository.ORIGIN_SALE_ORDER.equals(stockMove.getOriginTypeSelect())) {
invoice = createInvoiceFromSaleOrder(stockMove, saleOrderRepo.find(origin), qtyToInvoiceMap); invoice = createInvoiceFromSaleOrder(stockMove, saleOrderRepo.find(origin), qtyToInvoiceMap);
} else if (StockMoveRepository.ORIGIN_PURCHASE_ORDER.equals(stockMove.getOriginTypeSelect())) { } else if (StockMoveRepository.ORIGIN_PURCHASE_ORDER.equals(stockMove.getOriginTypeSelect())) {
invoice = invoice = createInvoiceFromPurchaseOrder(
createInvoiceFromPurchaseOrder(
stockMove, purchaseOrderRepo.find(origin), qtyToInvoiceMap); stockMove, purchaseOrderRepo.find(origin), qtyToInvoiceMap);
} else { } else {
invoice = createInvoiceFromOrderlessStockMove(stockMove, qtyToInvoiceMap); invoice = createInvoiceFromOrderlessStockMove(stockMove, qtyToInvoiceMap);
@@ -147,8 +146,7 @@ public class StockMoveInvoiceServiceImpl implements StockMoveInvoiceService {
for (StockMoveLine subLine : stockMoveLine.getSubLineList()) { for (StockMoveLine subLine : stockMoveLine.getSubLineList()) {
BigDecimal qty = BigDecimal.ZERO; BigDecimal qty = BigDecimal.ZERO;
if (stockMoveLine.getQty().compareTo(BigDecimal.ZERO) != 0) { if (stockMoveLine.getQty().compareTo(BigDecimal.ZERO) != 0) {
qty = qty = qtyToInvoiceItem
qtyToInvoiceItem
.multiply(subLine.getQty()) .multiply(subLine.getQty())
.divide(stockMoveLine.getQty(), 2, RoundingMode.HALF_EVEN); .divide(stockMoveLine.getQty(), 2, RoundingMode.HALF_EVEN);
} }
@@ -164,8 +162,8 @@ public class StockMoveInvoiceServiceImpl implements StockMoveInvoiceService {
StockMove stockMove, SaleOrder saleOrder, Map<Long, BigDecimal> qtyToInvoiceMap) StockMove stockMove, SaleOrder saleOrder, Map<Long, BigDecimal> qtyToInvoiceMap)
throws AxelorException { throws AxelorException {
InvoiceGenerator invoiceGenerator = InvoiceGenerator invoiceGenerator = saleOrderInvoiceService.createInvoiceGenerator(saleOrder,
saleOrderInvoiceService.createInvoiceGenerator(saleOrder, stockMove.getIsReversion()); stockMove.getIsReversion());
Invoice invoice = invoiceGenerator.generate(); Invoice invoice = invoiceGenerator.generate();
@@ -215,8 +213,7 @@ public class StockMoveInvoiceServiceImpl implements StockMoveInvoiceService {
StockMove stockMove, PurchaseOrder purchaseOrder, Map<Long, BigDecimal> qtyToInvoiceMap) StockMove stockMove, PurchaseOrder purchaseOrder, Map<Long, BigDecimal> qtyToInvoiceMap)
throws AxelorException { throws AxelorException {
InvoiceGenerator invoiceGenerator = InvoiceGenerator invoiceGenerator = purchaseOrderInvoiceService.createInvoiceGenerator(
purchaseOrderInvoiceService.createInvoiceGenerator(
purchaseOrder, stockMove.getIsReversion()); purchaseOrder, stockMove.getIsReversion());
Invoice invoice = invoiceGenerator.generate(); Invoice invoice = invoiceGenerator.generate();
@@ -274,8 +271,7 @@ public class StockMoveInvoiceServiceImpl implements StockMoveInvoiceService {
} }
} }
InvoiceGenerator invoiceGenerator = InvoiceGenerator invoiceGenerator = new InvoiceGeneratorSupplyChain(stockMove, invoiceOperationType) {
new InvoiceGeneratorSupplyChain(stockMove, invoiceOperationType) {
@Override @Override
public Invoice generate() throws AxelorException { public Invoice generate() throws AxelorException {
@@ -340,12 +336,10 @@ public class StockMoveInvoiceServiceImpl implements StockMoveInvoiceService {
Long id = stockMoveLine.getId(); Long id = stockMoveLine.getId();
if (qtyToInvoiceMap != null) { if (qtyToInvoiceMap != null) {
if (qtyToInvoiceMap.containsKey(id)) { if (qtyToInvoiceMap.containsKey(id)) {
invoiceLineListCreated = invoiceLineListCreated = this.createInvoiceLine(invoice, stockMoveLine, qtyToInvoiceMap.get(id));
this.createInvoiceLine(invoice, stockMoveLine, qtyToInvoiceMap.get(id));
} }
} else { } else {
invoiceLineListCreated = invoiceLineListCreated = this.createInvoiceLine(
this.createInvoiceLine(
invoice, invoice,
stockMoveLine, stockMoveLine,
stockMoveLine.getRealQty().subtract(stockMoveLine.getQtyInvoiced())); stockMoveLine.getRealQty().subtract(stockMoveLine.getQtyInvoiced()));
@@ -424,8 +418,7 @@ public class StockMoveInvoiceServiceImpl implements StockMoveInvoiceService {
stockMoveLine.getStockMove().getStockMoveSeq()); stockMoveLine.getStockMove().getStockMoveSeq());
} }
InvoiceLineGenerator invoiceLineGenerator = InvoiceLineGenerator invoiceLineGenerator = new InvoiceLineGeneratorSupplyChain(
new InvoiceLineGeneratorSupplyChain(
invoice, invoice,
product, product,
stockMoveLine.getProductName(), stockMoveLine.getProductName(),
@@ -465,7 +458,8 @@ public class StockMoveInvoiceServiceImpl implements StockMoveInvoiceService {
} }
/** /**
* Get a list of stock move lines consolidated by parent line (sale or purchase order). * Get a list of stock move lines consolidated by parent line (sale or purchase
* order).
* *
* @param stockMoveLineList * @param stockMoveLineList
* @return * @return
@@ -496,7 +490,9 @@ public class StockMoveInvoiceServiceImpl implements StockMoveInvoiceService {
stockMoveLinePurchaseMap.put(stockMoveLine.getPurchaseOrderLine(), list); stockMoveLinePurchaseMap.put(stockMoveLine.getPurchaseOrderLine(), list);
} }
list.add(stockMoveLine); list.add(stockMoveLine);
} else { // if the stock move line does not have a parent line (sale or purchase order line) resultList.add(stockMoveLine);
} else { // if the stock move line does not have a parent line (sale or purchase order
// line)
resultList.add(stockMoveLine); resultList.add(stockMoveLine);
} }
} }
@@ -544,14 +540,12 @@ public class StockMoveInvoiceServiceImpl implements StockMoveInvoiceService {
stockMove = Beans.get(StockMoveRepository.class).find(stockMove.getId()); stockMove = Beans.get(StockMoveRepository.class).find(stockMove.getId());
if (stockMove.getInvoiceSet() != null && !stockMove.getInvoiceSet().isEmpty()) { if (stockMove.getInvoiceSet() != null && !stockMove.getInvoiceSet().isEmpty()) {
Double totalInvoicedQty = Double totalInvoicedQty = stockMove
stockMove
.getStockMoveLineList() .getStockMoveLineList()
.stream() .stream()
.mapToDouble(sml -> Double.parseDouble(sml.getQtyInvoiced().toString())) .mapToDouble(sml -> Double.parseDouble(sml.getQtyInvoiced().toString()))
.sum(); .sum();
Double totalRealQty = Double totalRealQty = stockMove
stockMove
.getStockMoveLineList() .getStockMoveLineList()
.stream() .stream()
.mapToDouble(sml -> Double.parseDouble(sml.getRealQty().toString())) .mapToDouble(sml -> Double.parseDouble(sml.getRealQty().toString()))