use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.
the class SaleOrderLineController method emptyLine.
public void emptyLine(ActionRequest request, ActionResponse response) {
SaleOrderLine saleOrderLine = request.getContext().asType(SaleOrderLine.class);
if (saleOrderLine.getTypeSelect() != SaleOrderLineRepository.TYPE_NORMAL) {
Map<String, Object> newSaleOrderLine = Mapper.toMap(new SaleOrderLine());
newSaleOrderLine.put("qty", BigDecimal.ZERO);
newSaleOrderLine.put("id", saleOrderLine.getId());
newSaleOrderLine.put("version", saleOrderLine.getVersion());
newSaleOrderLine.put("typeSelect", saleOrderLine.getTypeSelect());
if (saleOrderLine.getTypeSelect() == SaleOrderLineRepository.TYPE_END_OF_PACK) {
newSaleOrderLine.put("productName", I18n.get(ITranslation.SALE_ORDER_LINE_END_OF_PACK));
}
response.setValues(newSaleOrderLine);
}
}
use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.
the class SaleOrderLineController method computeSubMargin.
public void computeSubMargin(ActionRequest request, ActionResponse response) throws AxelorException {
Context context = request.getContext();
SaleOrderLine saleOrderLine = context.asType(SaleOrderLine.class);
SaleOrderLineService saleOrderLineService = Beans.get(SaleOrderLineService.class);
SaleOrder saleOrder = saleOrderLineService.getSaleOrder(context);
saleOrderLine.setSaleOrder(saleOrder);
Map<String, BigDecimal> map = saleOrderLineService.computeSubMargin(saleOrder, saleOrderLine);
response.setValues(map);
}
use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.
the class SaleOrderLineController method updatePrice.
/**
* Update the ex. tax unit price of an invoice line from its in. tax unit price.
*
* @param request
* @param response
*/
public void updatePrice(ActionRequest request, ActionResponse response) {
Context context = request.getContext();
SaleOrderLine saleOrderLine = context.asType(SaleOrderLine.class);
try {
BigDecimal inTaxPrice = saleOrderLine.getInTaxPrice();
TaxLine taxLine = saleOrderLine.getTaxLine();
response.setValue("price", Beans.get(SaleOrderLineService.class).convertUnitPrice(true, taxLine, inTaxPrice));
} catch (Exception e) {
response.setFlash(e.getMessage());
}
}
use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.
the class SaleOrderLineServiceImpl method createSaleOrderLine.
@Override
public SaleOrderLine createSaleOrderLine(PackLine packLine, SaleOrder saleOrder, BigDecimal packQty, BigDecimal conversionRate, Integer sequence) {
if (packLine.getTypeSelect() == PackLineRepository.TYPE_START_OF_PACK || packLine.getTypeSelect() == PackLineRepository.TYPE_END_OF_PACK) {
return createStartOfPackAndEndOfPackTypeSaleOrderLine(packLine.getPack(), saleOrder, packQty, packLine, packLine.getTypeSelect(), sequence);
}
if (packLine.getProductName() != null) {
SaleOrderLine soLine = new SaleOrderLine();
Product product = packLine.getProduct();
soLine.setProduct(product);
soLine.setProductName(packLine.getProductName());
if (packLine.getQuantity() != null) {
soLine.setQty(packLine.getQuantity().multiply(packQty).setScale(appBaseService.getNbDecimalDigitForQty(), RoundingMode.HALF_UP));
}
soLine.setUnit(packLine.getUnit());
soLine.setTypeSelect(packLine.getTypeSelect());
soLine.setSequence(sequence);
if (packLine.getPrice() != null) {
soLine.setPrice(packLine.getPrice().multiply(conversionRate));
}
if (product != null) {
if (appSaleService.getAppSale().getIsEnabledProductDescriptionCopy()) {
soLine.setDescription(product.getDescription());
}
try {
this.fillPriceFromPackLine(soLine, saleOrder);
this.computeValues(saleOrder, soLine);
} catch (AxelorException e) {
TraceBackService.trace(e);
}
}
return soLine;
}
return null;
}
use of com.axelor.apps.sale.db.SaleOrderLine in project axelor-open-suite by axelor.
the class SaleOrderLineTaxService method createsSaleOrderLineTax.
/**
* Créer les lignes de TVA du devis. La création des lignes de TVA se basent sur les lignes de
* devis ainsi que les sous-lignes de devis de celles-ci. Si une ligne de devis comporte des
* sous-lignes de devis, alors on se base uniquement sur celles-ci.
*
* @param invoice La facture.
* @param invoiceLines Les lignes de facture.
* @param invoiceLineTaxes Les lignes des taxes de la facture.
* @return La liste des lignes de taxe de la facture.
*/
public List<SaleOrderLineTax> createsSaleOrderLineTax(SaleOrder saleOrder, List<SaleOrderLine> saleOrderLineList) {
List<SaleOrderLineTax> saleOrderLineTaxList = new ArrayList<SaleOrderLineTax>();
Map<TaxLine, SaleOrderLineTax> map = new HashMap<TaxLine, SaleOrderLineTax>();
Set<String> specificNotes = new HashSet<String>();
boolean customerSpecificNote = false;
if (saleOrder.getClientPartner().getFiscalPosition() != null) {
customerSpecificNote = saleOrder.getClientPartner().getFiscalPosition().getCustomerSpecificNote();
}
if (saleOrderLineList != null && !saleOrderLineList.isEmpty()) {
LOG.debug("Création des lignes de tva pour les lignes de factures.");
for (SaleOrderLine saleOrderLine : saleOrderLineList) {
TaxLine taxLine = saleOrderLine.getTaxLine();
if (taxLine != null) {
LOG.debug("Tax {}", taxLine);
if (map.containsKey(taxLine)) {
SaleOrderLineTax saleOrderLineTax = map.get(taxLine);
saleOrderLineTax.setExTaxBase(saleOrderLineTax.getExTaxBase().add(saleOrderLine.getExTaxTotal()));
} else {
SaleOrderLineTax saleOrderLineTax = new SaleOrderLineTax();
saleOrderLineTax.setSaleOrder(saleOrder);
saleOrderLineTax.setExTaxBase(saleOrderLine.getExTaxTotal());
saleOrderLineTax.setTaxLine(taxLine);
map.put(taxLine, saleOrderLineTax);
}
}
if (!customerSpecificNote) {
TaxEquiv taxEquiv = saleOrderLine.getTaxEquiv();
if (taxEquiv != null && taxEquiv.getSpecificNote() != null) {
specificNotes.add(taxEquiv.getSpecificNote());
}
}
}
}
for (SaleOrderLineTax saleOrderLineTax : map.values()) {
// Dans la devise de la facture
BigDecimal exTaxBase = saleOrderLineTax.getExTaxBase();
BigDecimal taxTotal = BigDecimal.ZERO;
if (saleOrderLineTax.getTaxLine() != null) {
taxTotal = saleOrderToolService.computeAmount(exTaxBase, saleOrderLineTax.getTaxLine().getValue());
saleOrderLineTax.setTaxTotal(taxTotal);
}
saleOrderLineTax.setInTaxTotal(exTaxBase.add(taxTotal));
saleOrderLineTaxList.add(saleOrderLineTax);
LOG.debug("Ligne de TVA : Total TVA => {}, Total HT => {}", new Object[] { saleOrderLineTax.getTaxTotal(), saleOrderLineTax.getInTaxTotal() });
}
if (!customerSpecificNote) {
saleOrder.setSpecificNotes(Joiner.on('\n').join(specificNotes));
} else {
saleOrder.setSpecificNotes(saleOrder.getClientPartner().getSpecificTaxNote());
}
return saleOrderLineTaxList;
}
Aggregations