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;
}
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;
}
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);
}
}
}
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;
}
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);
}
}
Aggregations