use of com.axelor.apps.purchase.db.PurchaseOrderLine in project axelor-open-suite by axelor.
the class PurchaseOrderLinePurchaseRepository method populate.
@Override
public Map<String, Object> populate(Map<String, Object> json, Map<String, Object> context) {
if (context.get("_model") != null && context.get("_model").toString().contains("PurchaseOrder") && context.get("id") != null) {
Long id = (Long) json.get("id");
if (id != null) {
PurchaseOrderLine purchaseOrderLine = find(id);
PurchaseOrder purchaseOrder = purchaseOrderLine.getPurchaseOrder();
Product product = purchaseOrderLine.getProduct();
json.put("$hasWarning", purchaseOrder != null && product != null && product.getDefaultSupplierPartner() != null && purchaseOrder.getSupplierPartner() != null && product.getDefaultSupplierPartner() != purchaseOrder.getSupplierPartner());
}
}
return super.populate(json, context);
}
use of com.axelor.apps.purchase.db.PurchaseOrderLine in project axelor-open-suite by axelor.
the class PurchaseOrderServiceImpl method _computePurchaseOrder.
/**
* Compute the purchase order total amounts
*
* @param purchaseOrder
* @throws AxelorException
*/
@Override
public void _computePurchaseOrder(PurchaseOrder purchaseOrder) throws AxelorException {
purchaseOrder.setExTaxTotal(BigDecimal.ZERO);
purchaseOrder.setCompanyExTaxTotal(BigDecimal.ZERO);
purchaseOrder.setTaxTotal(BigDecimal.ZERO);
purchaseOrder.setInTaxTotal(BigDecimal.ZERO);
for (PurchaseOrderLine purchaseOrderLine : purchaseOrder.getPurchaseOrderLineList()) {
purchaseOrder.setExTaxTotal(purchaseOrder.getExTaxTotal().add(purchaseOrderLine.getExTaxTotal()));
// In the company accounting currency
purchaseOrder.setCompanyExTaxTotal(purchaseOrder.getCompanyExTaxTotal().add(purchaseOrderLine.getCompanyExTaxTotal()));
}
for (PurchaseOrderLineTax purchaseOrderLineVat : purchaseOrder.getPurchaseOrderLineTaxList()) {
// In the purchase order currency
purchaseOrder.setTaxTotal(purchaseOrder.getTaxTotal().add(purchaseOrderLineVat.getTaxTotal()));
}
purchaseOrder.setInTaxTotal(purchaseOrder.getExTaxTotal().add(purchaseOrder.getTaxTotal()));
logger.debug("Montant de la facture: HTT = {}, HT = {}, TVA = {}, TTC = {}", new Object[] { purchaseOrder.getExTaxTotal(), purchaseOrder.getTaxTotal(), purchaseOrder.getInTaxTotal() });
}
use of com.axelor.apps.purchase.db.PurchaseOrderLine in project axelor-open-suite by axelor.
the class PurchaseOrderManagementRepository method copy.
@Override
public PurchaseOrder copy(PurchaseOrder entity, boolean deep) {
PurchaseOrder copy = super.copy(entity, deep);
copy.setStatusSelect(PurchaseOrderRepository.STATUS_DRAFT);
copy.setPurchaseOrderSeq(null);
copy.setVersionNumber(1);
copy.setDeliveryDate(null);
copy.setValidatedByUser(null);
copy.setValidationDate(null);
if (copy.getPurchaseOrderLineList() != null) {
for (PurchaseOrderLine purchaseOrderLine : copy.getPurchaseOrderLineList()) {
purchaseOrderLine.setDesiredDelivDate(null);
purchaseOrderLine.setEstimatedDelivDate(null);
}
}
return copy;
}
use of com.axelor.apps.purchase.db.PurchaseOrderLine in project axelor-open-suite by axelor.
the class PurchaseOrderSupplierLineService method accept.
@Transactional(rollbackOn = { Exception.class })
public void accept(PurchaseOrderSupplierLine purchaseOrderSupplierLine) throws AxelorException {
PurchaseOrderLine purchaseOrderLine = purchaseOrderSupplierLine.getPurchaseOrderLine();
purchaseOrderLine.setEstimatedDelivDate(purchaseOrderSupplierLine.getEstimatedDelivDate());
Partner supplierPartner = purchaseOrderSupplierLine.getSupplierPartner();
Company company = purchaseOrderLine.getPurchaseOrder().getCompany();
if (Beans.get(BlockingService.class).getBlocking(supplierPartner, company, BlockingRepository.PURCHASE_BLOCKING) != null) {
throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.SUPPLIER_BLOCKED), supplierPartner);
}
purchaseOrderLine.setSupplierPartner(supplierPartner);
purchaseOrderLine.setPrice(purchaseOrderSupplierLine.getPrice());
purchaseOrderLine.setExTaxTotal(PurchaseOrderLineServiceImpl.computeAmount(purchaseOrderLine.getQty(), purchaseOrderLine.getPrice()));
purchaseOrderSupplierLine.setStateSelect(PurchaseOrderSupplierLineRepository.STATE_ACCEPTED);
poSupplierLineRepo.save(purchaseOrderSupplierLine);
}
use of com.axelor.apps.purchase.db.PurchaseOrderLine in project axelor-open-suite by axelor.
the class PurchaseOrderLineController method generateSuppliersRequests.
public void generateSuppliersRequests(ActionRequest request, ActionResponse response) {
PurchaseOrderLine purchaseOrderLine = Beans.get(PurchaseOrderLineRepository.class).find(request.getContext().asType(PurchaseOrderLine.class).getId());
try {
if (purchaseOrderLine.getPurchaseOrder() == null) {
PurchaseOrder purchaseOrder = request.getContext().getParent().asType(PurchaseOrder.class);
Beans.get(PurchaseOrderSupplierService.class).generateSuppliersRequests(purchaseOrderLine, purchaseOrder);
} else {
Beans.get(PurchaseOrderSupplierService.class).generateSuppliersRequests(purchaseOrderLine);
}
response.setReload(true);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations