use of com.axelor.apps.purchase.db.PurchaseOrderLine in project axelor-open-suite by axelor.
the class PurchaseOrderSupplierService method splitBySupplierPartner.
public Map<Partner, List<PurchaseOrderLine>> splitBySupplierPartner(List<PurchaseOrderLine> purchaseOrderLineList) throws AxelorException {
Map<Partner, List<PurchaseOrderLine>> purchaseOrderLinesBySupplierPartner = new HashMap<>();
for (PurchaseOrderLine purchaseOrderLine : purchaseOrderLineList) {
Partner supplierPartner = purchaseOrderLine.getSupplierPartner();
if (supplierPartner == null) {
throw new AxelorException(purchaseOrderLine, TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.SO_PURCHASE_1), purchaseOrderLine.getProductName());
}
if (!purchaseOrderLinesBySupplierPartner.containsKey(supplierPartner)) {
purchaseOrderLinesBySupplierPartner.put(supplierPartner, new ArrayList<PurchaseOrderLine>());
}
purchaseOrderLinesBySupplierPartner.get(supplierPartner).add(purchaseOrderLine);
}
return purchaseOrderLinesBySupplierPartner;
}
use of com.axelor.apps.purchase.db.PurchaseOrderLine in project axelor-open-suite by axelor.
the class PurchaseOrderSupplychainRepository method copy.
@Override
public PurchaseOrder copy(PurchaseOrder entity, boolean deep) {
PurchaseOrder copy = super.copy(entity, deep);
if (!appService.isApp("supplychain")) {
return copy;
}
copy.setReceiptState(PurchaseOrderRepository.STATE_NOT_RECEIVED);
copy.setAmountInvoiced(null);
if (copy.getPurchaseOrderLineList() != null) {
for (PurchaseOrderLine purchaseOrderLine : copy.getPurchaseOrderLineList()) {
purchaseOrderLine.setReceiptState(null);
purchaseOrderLine.setReceivedQty(null);
purchaseOrderLine.setAmountInvoiced(null);
purchaseOrderLine.setInvoiced(null);
}
}
return copy;
}
use of com.axelor.apps.purchase.db.PurchaseOrderLine in project axelor-open-suite by axelor.
the class PurchaseOrderSupplierLineController method supplierPartnerDomain.
/**
* Called on supplier partner select. Set the domain for the field supplierPartner
*
* @param request
* @param response
*/
public void supplierPartnerDomain(ActionRequest request, ActionResponse response) {
PurchaseOrderSupplierLine purchaseOrderSupplierLine = request.getContext().asType(PurchaseOrderSupplierLine.class);
PurchaseOrderLine purchaseOrderLine = purchaseOrderSupplierLine.getPurchaseOrderLine();
if (purchaseOrderLine == null) {
purchaseOrderLine = request.getContext().getParent().asType(PurchaseOrderLine.class);
}
PurchaseOrder purchaseOrder = request.getContext().getParent().getParent().asType(PurchaseOrder.class);
if (purchaseOrder.getId() != null) {
purchaseOrder = purchaseOrderLine.getPurchaseOrder();
}
Company company = purchaseOrder.getCompany();
String domain = "";
if (Beans.get(AppPurchaseService.class).getAppPurchase().getManageSupplierCatalog() && purchaseOrderLine.getProduct() != null && !purchaseOrderLine.getProduct().getSupplierCatalogList().isEmpty()) {
domain += "self.id != " + company.getPartner().getId() + " AND self.id IN " + purchaseOrderLine.getProduct().getSupplierCatalogList().stream().map(s -> s.getSupplierPartner().getId()).collect(Collectors.toList()).toString().replace('[', '(').replace(']', ')');
String blockedPartnerQuery = Beans.get(BlockingService.class).listOfBlockedPartner(company, BlockingRepository.PURCHASE_BLOCKING);
if (!Strings.isNullOrEmpty(blockedPartnerQuery)) {
domain += String.format(" AND self.id NOT in (%s)", blockedPartnerQuery);
}
} else {
domain += "self.id = 0";
}
domain += " AND " + company.getId() + " in (SELECT id FROM self.companySet)";
response.setAttr("supplierPartner", "domain", domain);
}
use of com.axelor.apps.purchase.db.PurchaseOrderLine in project axelor-open-suite by axelor.
the class WorkflowVentilationProjectServiceImpl method afterVentilation.
@Override
@Transactional(rollbackOn = { Exception.class })
public void afterVentilation(Invoice invoice) throws AxelorException {
super.afterVentilation(invoice);
if (!Beans.get(AppBusinessProjectService.class).isApp("business-project")) {
return;
}
InvoicingProject invoicingProject = invoicingProjectRepo.all().filter("self.invoice.id = ?", invoice.getId()).fetchOne();
if (invoicingProject != null) {
for (SaleOrderLine saleOrderLine : invoicingProject.getSaleOrderLineSet()) {
saleOrderLine.setInvoiced(true);
}
for (PurchaseOrderLine purchaseOrderLine : invoicingProject.getPurchaseOrderLineSet()) {
purchaseOrderLine.setInvoiced(true);
}
for (TimesheetLine timesheetLine : invoicingProject.getLogTimesSet()) {
timesheetLine.setInvoiced(true);
if (timesheetLine.getProjectTask() == null) {
continue;
}
timesheetLine.getProjectTask().setInvoiced(this.checkInvoicedTimesheetLines(timesheetLine.getProjectTask()));
}
for (ExpenseLine expenseLine : invoicingProject.getExpenseLineSet()) {
expenseLine.setInvoiced(true);
}
for (ProjectTask projectTask : invoicingProject.getProjectTaskSet()) {
projectTask.setInvoiced(true);
}
for (Project project : invoicingProject.getProjectSet()) {
project.setInvoiced(true);
}
invoicingProject.setStatusSelect(InvoicingProjectRepository.STATUS_VENTILATED);
invoicingProjectRepo.save(invoicingProject);
}
}
use of com.axelor.apps.purchase.db.PurchaseOrderLine in project axelor-open-suite by axelor.
the class ProjectAnalyticMoveLineServiceImpl method updateLines.
@Override
@Transactional(rollbackOn = Exception.class)
public PurchaseOrder updateLines(PurchaseOrder purchaseOrder) {
for (PurchaseOrderLine orderLine : purchaseOrder.getPurchaseOrderLineList()) {
orderLine.setProject(purchaseOrder.getProject());
for (AnalyticMoveLine analyticMoveLine : orderLine.getAnalyticMoveLineList()) {
analyticMoveLine.setProject(purchaseOrder.getProject());
analyticMoveLineRepository.save(analyticMoveLine);
}
}
return purchaseOrder;
}
Aggregations