use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.
the class SaleOrderComputeServiceImpl method _computeSaleOrder.
/**
* Compute the sale order total amounts
*
* @param saleOrder
* @throws AxelorException
*/
@Override
public void _computeSaleOrder(SaleOrder saleOrder) throws AxelorException {
saleOrder.setExTaxTotal(BigDecimal.ZERO);
saleOrder.setCompanyExTaxTotal(BigDecimal.ZERO);
saleOrder.setTaxTotal(BigDecimal.ZERO);
saleOrder.setInTaxTotal(BigDecimal.ZERO);
for (SaleOrderLine saleOrderLine : saleOrder.getSaleOrderLineList()) {
// skip title lines in computing total amounts
if (saleOrderLine.getTypeSelect() != SaleOrderLineRepository.TYPE_NORMAL) {
continue;
}
saleOrder.setExTaxTotal(saleOrder.getExTaxTotal().add(saleOrderLine.getExTaxTotal()));
// In the company accounting currency
saleOrder.setCompanyExTaxTotal(saleOrder.getCompanyExTaxTotal().add(saleOrderLine.getCompanyExTaxTotal()));
}
for (SaleOrderLineTax saleOrderLineVat : saleOrder.getSaleOrderLineTaxList()) {
// In the sale order currency
saleOrder.setTaxTotal(saleOrder.getTaxTotal().add(saleOrderLineVat.getTaxTotal()));
}
saleOrder.setInTaxTotal(saleOrder.getExTaxTotal().add(saleOrder.getTaxTotal()));
saleOrder.setAdvanceTotal(computeTotalAdvancePayment(saleOrder));
logger.debug("Montant de la facture: HTT = {}, HT = {}, Taxe = {}, TTC = {}", new Object[] { saleOrder.getExTaxTotal(), saleOrder.getTaxTotal(), saleOrder.getInTaxTotal() });
}
use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.
the class SaleOrderCreateServiceImpl method attachToNewSaleOrder.
// Attachment of all sale order lines to new sale order
protected void attachToNewSaleOrder(List<SaleOrder> saleOrderList, SaleOrder saleOrderMerged) {
for (SaleOrder saleOrder : saleOrderList) {
int countLine = 1;
for (SaleOrderLine saleOrderLine : saleOrder.getSaleOrderLineList()) {
saleOrderLine.setSequence(countLine * 10);
saleOrderMerged.addSaleOrderLineListItem(saleOrderLine);
countLine++;
}
}
}
use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.
the class SaleOrderLineServiceImpl method createStartOfPackAndEndOfPackTypeSaleOrderLine.
@Override
public SaleOrderLine createStartOfPackAndEndOfPackTypeSaleOrderLine(Pack pack, SaleOrder saleOrder, BigDecimal packqty, PackLine packLine, Integer typeSelect, Integer sequence) {
SaleOrderLine saleOrderLine = new SaleOrderLine();
saleOrderLine.setTypeSelect(typeSelect);
switch(typeSelect) {
case SaleOrderLineRepository.TYPE_START_OF_PACK:
saleOrderLine.setProductName(packLine == null ? pack.getName() : packLine.getProductName());
saleOrderLine.setQty(packLine != null && packLine.getQuantity() != null ? packLine.getQuantity().multiply(packqty).setScale(appBaseService.getNbDecimalDigitForQty(), RoundingMode.HALF_EVEN) : packqty);
break;
case SaleOrderLineRepository.TYPE_END_OF_PACK:
saleOrderLine.setProductName(packLine == null ? I18n.get(ITranslation.SALE_ORDER_LINE_END_OF_PACK) : packLine.getProductName());
saleOrderLine.setIsShowTotal(pack.getIsShowTotal());
saleOrderLine.setIsHideUnitAmounts(pack.getIsHideUnitAmounts());
break;
default:
return null;
}
saleOrderLine.setSaleOrder(saleOrder);
saleOrderLine.setSequence(sequence);
return saleOrderLine;
}
use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.
the class SaleOrderLineServiceImpl method manageComplementaryProductSaleOrderLine.
@Override
public List<SaleOrderLine> manageComplementaryProductSaleOrderLine(SaleOrderLine saleOrderLine, SaleOrder saleOrder, List<ComplementaryProduct> complementaryProducts) throws AxelorException {
List<SaleOrderLine> newComplementarySOLines = new ArrayList<>();
if (saleOrderLine.getComplementarySaleOrderLineList() == null) {
saleOrderLine.setComplementarySaleOrderLineList(new ArrayList<>());
}
for (ComplementaryProduct complementaryProduct : complementaryProducts) {
Product product = complementaryProduct.getProduct();
if (product == null) {
continue;
}
SaleOrderLine complementarySOLine;
Optional<SaleOrderLine> complementarySOLineOpt = saleOrderLine.getComplementarySaleOrderLineList().stream().filter(line -> line.getMainSaleOrderLine() != null && line.getProduct().equals(product)).findFirst();
if (complementarySOLineOpt.isPresent()) {
complementarySOLine = complementarySOLineOpt.get();
} else {
complementarySOLine = new SaleOrderLine();
complementarySOLine.setSequence(saleOrderLine.getSequence());
complementarySOLine.setProduct(complementaryProduct.getProduct());
saleOrderLine.addComplementarySaleOrderLineListItem(complementarySOLine);
newComplementarySOLines.add(complementarySOLine);
}
complementarySOLine.setQty(complementaryProduct.getQty());
this.computeProductInformation(complementarySOLine, saleOrder);
this.computeValues(saleOrder, complementarySOLine);
saleOrderLineRepo.save(complementarySOLine);
}
return newComplementarySOLines;
}
use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.
the class SaleOrderLineServiceImpl method createNonStandardSOLineFromPack.
@Override
public List<SaleOrderLine> createNonStandardSOLineFromPack(Pack pack, SaleOrder saleOrder, BigDecimal packQty, List<SaleOrderLine> saleOrderLineList, Integer sequence) {
SaleOrderLine saleOrderLine;
Set<Integer> packLineTypeSet = getPackLineTypes(pack.getComponents());
int typeSelect = SaleOrderLineRepository.TYPE_START_OF_PACK;
for (int i = 0; i < 2; i++) {
if (packLineTypeSet == null || !packLineTypeSet.contains(typeSelect)) {
saleOrderLine = this.createStartOfPackAndEndOfPackTypeSaleOrderLine(pack, saleOrder, packQty, null, typeSelect, sequence);
saleOrderLineList.add(saleOrderLine);
}
if (typeSelect == SaleOrderLineRepository.TYPE_START_OF_PACK) {
sequence += pack.getComponents().size() + 1;
typeSelect = SaleOrderLineRepository.TYPE_END_OF_PACK;
}
}
return saleOrderLineList;
}
Aggregations