Search in sources :

Example 91 with Partner

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);
}
Also used : Partner(com.axelor.apps.base.db.Partner) Transactional(com.google.inject.persist.Transactional)

Example 92 with Partner

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);
    }
}
Also used : AxelorException(com.axelor.exception.AxelorException) Company(com.axelor.apps.base.db.Company) Blocking(com.axelor.apps.base.db.Blocking) BlockingService(com.axelor.apps.base.service.BlockingService) Partner(com.axelor.apps.base.db.Partner) Transactional(com.google.inject.persist.Transactional)

Example 93 with Partner

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);
    }
}
Also used : Context(com.axelor.rpc.Context) AppProject(com.axelor.apps.base.db.AppProject) Project(com.axelor.apps.project.db.Project) AxelorException(com.axelor.exception.AxelorException) Partner(com.axelor.apps.base.db.Partner) ProjectTemplate(com.axelor.apps.project.db.ProjectTemplate) ProjectTemplateRepository(com.axelor.apps.project.db.repo.ProjectTemplateRepository)

Example 94 with Partner

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);
}
Also used : PurchaseOrderLine(com.axelor.apps.purchase.db.PurchaseOrderLine) AxelorException(com.axelor.exception.AxelorException) Company(com.axelor.apps.base.db.Company) Partner(com.axelor.apps.base.db.Partner) Transactional(com.google.inject.persist.Transactional)

Example 95 with Partner

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);
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) Partner(com.axelor.apps.base.db.Partner) Transactional(com.google.inject.persist.Transactional)

Aggregations

Partner (com.axelor.apps.base.db.Partner)199 AxelorException (com.axelor.exception.AxelorException)68 Company (com.axelor.apps.base.db.Company)67 Transactional (com.google.inject.persist.Transactional)54 BigDecimal (java.math.BigDecimal)43 ArrayList (java.util.ArrayList)34 MoveLine (com.axelor.apps.account.db.MoveLine)32 Move (com.axelor.apps.account.db.Move)30 PaymentMode (com.axelor.apps.account.db.PaymentMode)26 LocalDate (java.time.LocalDate)26 Account (com.axelor.apps.account.db.Account)25 Invoice (com.axelor.apps.account.db.Invoice)24 BankDetails (com.axelor.apps.base.db.BankDetails)24 List (java.util.List)22 PartnerService (com.axelor.apps.base.service.PartnerService)18 Map (java.util.Map)18 Journal (com.axelor.apps.account.db.Journal)17 Address (com.axelor.apps.base.db.Address)14 Currency (com.axelor.apps.base.db.Currency)14 AccountConfig (com.axelor.apps.account.db.AccountConfig)13