use of com.axelor.apps.base.db.Partner in project axelor-open-suite by axelor.
the class PurchaseOrderServiceImpl method validateSupplier.
@Override
@Transactional
public Partner validateSupplier(PurchaseOrder purchaseOrder) {
Partner supplierPartner = partnerRepo.find(purchaseOrder.getSupplierPartner().getId());
supplierPartner.setIsSupplier(true);
return partnerRepo.save(supplierPartner);
}
use of com.axelor.apps.base.db.Partner in project axelor-open-suite by axelor.
the class PurchaseOrderServiceImpl method requestPurchaseOrder.
@Override
@Transactional(rollbackOn = { Exception.class })
public void requestPurchaseOrder(PurchaseOrder purchaseOrder) throws AxelorException {
purchaseOrder.setStatusSelect(PurchaseOrderRepository.STATUS_REQUESTED);
Partner partner = purchaseOrder.getSupplierPartner();
Company company = purchaseOrder.getCompany();
Blocking blocking = Beans.get(BlockingService.class).getBlocking(partner, company, BlockingRepository.PURCHASE_BLOCKING);
if (blocking != null) {
String reason = blocking.getBlockingReason() != null ? blocking.getBlockingReason().getName() : "";
throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.SUPPLIER_BLOCKED) + " " + reason, partner);
}
if (purchaseOrder.getVersionNumber() == 1 && sequenceService.isEmptyOrDraftSequenceNumber(purchaseOrder.getPurchaseOrderSeq())) {
purchaseOrder.setPurchaseOrderSeq(this.getSequence(purchaseOrder.getCompany()));
}
purchaseOrderRepo.save(purchaseOrder);
if (appPurchaseService.getAppPurchase().getManagePurchaseOrderVersion()) {
this.savePurchaseOrderPDFAsAttachment(purchaseOrder);
}
}
use of com.axelor.apps.base.db.Partner in project axelor-open-suite by axelor.
the class ProjectTemplateController method createProjectFromWizard.
@SuppressWarnings("unchecked")
public void createProjectFromWizard(ActionRequest request, ActionResponse response) {
Context context = request.getContext();
String projectTemplateId = ((LinkedHashMap<String, Object>) context.get("_projectTemplate")).get("id").toString();
ProjectTemplate projectTemplate = Beans.get(ProjectTemplateRepository.class).find(Long.parseLong(projectTemplateId));
String projectCode = (String) context.get("code");
Object clientPartnerContext = context.get("clientPartner");
Partner clientPartner = null;
if (clientPartnerContext != null) {
String clientPartnerId = ((LinkedHashMap<String, Object>) clientPartnerContext).get("id").toString();
clientPartner = Beans.get(PartnerRepository.class).find(Long.parseLong(clientPartnerId));
}
Project project;
try {
project = Beans.get(ProjectService.class).createProjectFromTemplate(projectTemplate, projectCode, clientPartner);
response.setCanClose(true);
response.setView(ActionView.define(I18n.get("Project")).model(Project.class.getName()).add("form", "project-form").add("grid", "project-grid").param("search-filters", "project-filters").context("_showRecord", project.getId()).map());
} catch (AxelorException e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.base.db.Partner 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.base.db.Partner in project axelor-open-suite by axelor.
the class PurchaseOrderSupplierService method generateSuppliersPurchaseOrder.
@Transactional(rollbackOn = { Exception.class })
public void generateSuppliersPurchaseOrder(PurchaseOrder purchaseOrder) throws AxelorException {
if (purchaseOrder.getPurchaseOrderLineList() == null) {
return;
}
Map<Partner, List<PurchaseOrderLine>> purchaseOrderLinesBySupplierPartner = this.splitBySupplierPartner(purchaseOrder.getPurchaseOrderLineList());
for (Partner supplierPartner : purchaseOrderLinesBySupplierPartner.keySet()) {
this.createPurchaseOrder(supplierPartner, purchaseOrderLinesBySupplierPartner.get(supplierPartner), purchaseOrder);
}
poRepo.save(purchaseOrder);
}
Aggregations