Search in sources :

Example 86 with Partner

use of com.axelor.apps.base.db.Partner in project axelor-open-suite by axelor.

the class BankOrderMoveServiceImpl method generateSenderMove.

protected Move generateSenderMove(BankOrderLine bankOrderLine) throws AxelorException {
    Partner partner = bankOrderLine.getPartner();
    Move senderMove = moveService.getMoveCreateService().createMove(journal, senderCompany, this.getCurrency(bankOrderLine), partner, this.getDate(bankOrderLine), paymentMode, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, MoveRepository.FUNCTIONAL_ORIGIN_PAYMENT);
    MoveLine bankMoveLine = moveService.getMoveLineService().createMoveLine(senderMove, partner, senderBankAccount, bankOrderLine.getBankOrderAmount(), !isDebit, senderMove.getDate(), 1, bankOrderLine.getReceiverReference(), bankOrderLine.getReceiverLabel());
    senderMove.addMoveLineListItem(bankMoveLine);
    MoveLine partnerMoveLine = moveService.getMoveLineService().createMoveLine(senderMove, partner, getPartnerAccount(partner, senderCompany, senderCompany), bankOrderLine.getBankOrderAmount(), isDebit, senderMove.getDate(), 2, bankOrderLine.getReceiverReference(), bankOrderLine.getReceiverLabel());
    senderMove.addMoveLineListItem(partnerMoveLine);
    return senderMove;
}
Also used : Move(com.axelor.apps.account.db.Move) MoveLine(com.axelor.apps.account.db.MoveLine) Partner(com.axelor.apps.base.db.Partner)

Example 87 with Partner

use of com.axelor.apps.base.db.Partner in project axelor-open-suite by axelor.

the class BankOrderMoveServiceImpl method generateReceiverMove.

protected Move generateReceiverMove(BankOrderLine bankOrderLine) throws AxelorException {
    Partner partner = bankOrderLine.getPartner();
    Company receiverCompany = bankOrderLine.getReceiverCompany();
    BankDetails receiverBankDetails = bankOrderLine.getReceiverBankDetails();
    Journal receiverJournal = paymentModeService.getPaymentModeJournal(paymentMode, receiverCompany, receiverBankDetails);
    Account receiverBankAccount = paymentModeService.getPaymentModeAccount(paymentMode, receiverCompany, receiverBankDetails);
    Move receiverMove = moveService.getMoveCreateService().createMove(receiverJournal, receiverCompany, this.getCurrency(bankOrderLine), partner, this.getDate(bankOrderLine), paymentMode, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, MoveRepository.FUNCTIONAL_ORIGIN_PAYMENT);
    MoveLine bankMoveLine = moveService.getMoveLineService().createMoveLine(receiverMove, partner, receiverBankAccount, bankOrderLine.getBankOrderAmount(), isDebit, receiverMove.getDate(), 1, bankOrderLine.getReceiverReference(), bankOrderLine.getReceiverLabel());
    receiverMove.addMoveLineListItem(bankMoveLine);
    MoveLine partnerMoveLine = moveService.getMoveLineService().createMoveLine(receiverMove, partner, getPartnerAccount(partner, receiverCompany, receiverMove.getCompany()), bankOrderLine.getBankOrderAmount(), !isDebit, receiverMove.getDate(), 2, bankOrderLine.getReceiverReference(), bankOrderLine.getReceiverLabel());
    receiverMove.addMoveLineListItem(partnerMoveLine);
    return receiverMove;
}
Also used : Account(com.axelor.apps.account.db.Account) Company(com.axelor.apps.base.db.Company) Move(com.axelor.apps.account.db.Move) BankDetails(com.axelor.apps.base.db.BankDetails) MoveLine(com.axelor.apps.account.db.MoveLine) Journal(com.axelor.apps.account.db.Journal) Partner(com.axelor.apps.base.db.Partner)

Example 88 with Partner

use of com.axelor.apps.base.db.Partner in project axelor-open-suite by axelor.

the class BankOrderServiceImpl method resetPartners.

private void resetPartners(BankOrder bankOrder) {
    if (bankOrder.getPartnerTypeSelect() == BankOrderRepository.PARTNER_TYPE_COMPANY) {
        for (BankOrderLine bankOrderLine : bankOrder.getBankOrderLineList()) {
            bankOrderLine.setPartner(null);
        }
        return;
    }
    for (BankOrderLine bankOrderLine : bankOrder.getBankOrderLineList()) {
        bankOrderLine.setReceiverCompany(null);
        Partner partner = bankOrderLine.getPartner();
        if (partner == null) {
            continue;
        }
        boolean keep;
        switch(bankOrder.getPartnerTypeSelect()) {
            case BankOrderRepository.PARTNER_TYPE_SUPPLIER:
                keep = partner.getIsSupplier();
                break;
            case BankOrderRepository.PARTNER_TYPE_EMPLOYEE:
                keep = partner.getIsEmployee();
                break;
            case BankOrderRepository.PARTNER_TYPE_CUSTOMER:
                keep = partner.getIsCustomer();
                break;
            default:
                keep = false;
        }
        if (!keep) {
            bankOrderLine.setPartner(null);
        }
    }
}
Also used : BankOrderLine(com.axelor.apps.bankpayment.db.BankOrderLine) Partner(com.axelor.apps.base.db.Partner) EbicsPartner(com.axelor.apps.bankpayment.db.EbicsPartner)

Example 89 with Partner

use of com.axelor.apps.base.db.Partner in project axelor-open-suite by axelor.

the class PurchaseOrderLineServiceImpl method fill.

public PurchaseOrderLine fill(PurchaseOrderLine line, PurchaseOrder purchaseOrder) throws AxelorException {
    Preconditions.checkNotNull(line, I18n.get("The line cannot be null."));
    Preconditions.checkNotNull(purchaseOrder, I18n.get("You need a purchase order associated to line."));
    Partner supplierPartner = purchaseOrder.getSupplierPartner();
    Product product = line.getProduct();
    String[] productSupplierInfos = getProductSupplierInfos(purchaseOrder, line);
    if (!line.getEnableFreezeFields()) {
        line.setProductName(productSupplierInfos[0]);
        line.setQty(getQty(purchaseOrder, line));
    }
    line.setProductCode(productSupplierInfos[1]);
    line.setUnit(getPurchaseUnit(line));
    if (appPurchaseService.getAppPurchase().getIsEnabledProductDescriptionCopy()) {
        line.setDescription(product.getDescription());
    }
    TaxLine taxLine = getTaxLine(purchaseOrder, line);
    line.setTaxLine(taxLine);
    BigDecimal price = getExTaxUnitPrice(purchaseOrder, line, taxLine);
    BigDecimal inTaxPrice = getInTaxUnitPrice(purchaseOrder, line, taxLine);
    if (price == null || inTaxPrice == null) {
        throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.PURCHASE_ORDER_LINE_NO_SUPPLIER_CATALOG));
    }
    TaxEquiv taxEquiv = accountManagementService.getProductTaxEquiv(product, purchaseOrder.getCompany(), supplierPartner.getFiscalPosition(), true);
    line.setTaxEquiv(taxEquiv);
    Map<String, Object> discounts = getDiscountsFromPriceLists(purchaseOrder, line, purchaseOrder.getInAti() ? inTaxPrice : price);
    if (discounts != null) {
        if (discounts.get("price") != null) {
            BigDecimal discountPrice = (BigDecimal) discounts.get("price");
            if (product.getInAti()) {
                inTaxPrice = discountPrice;
                price = this.convertUnitPrice(true, line.getTaxLine(), discountPrice);
            } else {
                price = discountPrice;
                inTaxPrice = this.convertUnitPrice(false, line.getTaxLine(), discountPrice);
            }
        }
        if (product.getInAti() != purchaseOrder.getInAti() && (Integer) discounts.get("discountTypeSelect") != PriceListLineRepository.AMOUNT_TYPE_PERCENT) {
            line.setDiscountAmount(this.convertUnitPrice(product.getInAti(), line.getTaxLine(), (BigDecimal) discounts.get("discountAmount")));
        } else {
            line.setDiscountAmount((BigDecimal) discounts.get("discountAmount"));
        }
        line.setDiscountTypeSelect((Integer) discounts.get("discountTypeSelect"));
    }
    if (!line.getEnableFreezeFields()) {
        line.setPrice(price);
    }
    line.setInTaxPrice(inTaxPrice);
    line.setMaxPurchasePrice(getPurchaseMaxPrice(purchaseOrder, line));
    return line;
}
Also used : AxelorException(com.axelor.exception.AxelorException) Product(com.axelor.apps.base.db.Product) Partner(com.axelor.apps.base.db.Partner) TaxEquiv(com.axelor.apps.account.db.TaxEquiv) BigDecimal(java.math.BigDecimal) TaxLine(com.axelor.apps.account.db.TaxLine)

Example 90 with Partner

use of com.axelor.apps.base.db.Partner in project axelor-open-suite by axelor.

the class PurchaseOrderLineServiceImpl method checkDifferentSupplier.

@Override
public void checkDifferentSupplier(PurchaseOrder purchaseOrder, PurchaseOrderLine purchaseOrderLine, ActionResponse response) {
    if (!appBaseService.getAppBase().getEnableTradingNamesManagement()) {
        return;
    }
    Product product = purchaseOrderLine.getProduct();
    TradingName tradingName = purchaseOrder.getTradingName();
    if (product == null || tradingName == null) {
        return;
    }
    Partner supplierOnPurchaseOrder = purchaseOrder.getSupplierPartner();
    Partner defaultSupplierOnProduct = product.getDefaultSupplierPartner();
    if (defaultSupplierOnProduct == null) {
        return;
    }
    if (supplierOnPurchaseOrder != defaultSupplierOnProduct) {
        String message = String.format(I18n.get(IExceptionMessage.DIFFERENT_SUPPLIER));
        String title = String.format("<span class='label %s'>%s</span>", ContextTool.SPAN_CLASS_WARNING, message);
        response.setAttr("differentSupplierLabel", "title", title);
        response.setAttr("differentSupplierLabel", "hidden", false);
    } else {
        response.setAttr("differentSupplierLabel", "hidden", true);
    }
}
Also used : Product(com.axelor.apps.base.db.Product) TradingName(com.axelor.apps.base.db.TradingName) Partner(com.axelor.apps.base.db.Partner)

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