use of com.axelor.apps.base.db.Partner in project axelor-open-suite by axelor.
the class CampaignServiceImpl method addNotParticipatingTargets.
@Override
@Transactional
public void addNotParticipatingTargets(Campaign campaign, Campaign campaignContext) {
for (Partner partner : campaignContext.getInvitedPartnerSet()) {
if (partner.isSelected()) {
campaign.addNotParticipatingPartnerSetItem(partner);
campaign.removeInvitedPartnerSetItem(partner);
}
}
for (Lead lead : campaignContext.getInvitedLeadSet()) {
if (lead.isSelected()) {
campaign.addNotParticipatingLeadSetItem(lead);
campaign.removeInvitedLeadSetItem(lead);
}
}
Beans.get(CampaignRepository.class).save(campaign);
}
use of com.axelor.apps.base.db.Partner in project axelor-open-suite by axelor.
the class CampaignServiceImpl method inviteAllTargets.
@Override
@Transactional
public void inviteAllTargets(Campaign campaign) {
Set<Partner> partners = campaign.getPartners();
Set<Partner> notParticipatingPartnerSet = campaign.getNotParticipatingPartnerSet();
for (Partner partner : campaign.getPartnerSet()) {
if (!partners.contains(partner) && !notParticipatingPartnerSet.contains(partner)) {
campaign.addInvitedPartnerSetItem(partner);
}
}
Set<Lead> leads = campaign.getLeads();
Set<Lead> notParticipatingLeadSet = campaign.getNotParticipatingLeadSet();
for (Lead lead : campaign.getLeadSet()) {
if (!leads.contains(lead) && !notParticipatingLeadSet.contains(lead)) {
campaign.addInvitedLeadSetItem(lead);
}
}
Beans.get(CampaignRepository.class).save(campaign);
}
use of com.axelor.apps.base.db.Partner in project axelor-open-suite by axelor.
the class ManufOrderWorkflowService method setPurchaseOrderSupplierDetails.
private PurchaseOrder setPurchaseOrderSupplierDetails(PurchaseOrder purchaseOrder) throws AxelorException {
Partner supplierPartner = purchaseOrder.getSupplierPartner();
if (supplierPartner != null) {
purchaseOrder.setCurrency(supplierPartner.getCurrency());
purchaseOrder.setShipmentMode(supplierPartner.getShipmentMode());
purchaseOrder.setFreightCarrierMode(supplierPartner.getFreightCarrierMode());
purchaseOrder.setNotes(supplierPartner.getPurchaseOrderComments());
if (supplierPartner.getPaymentCondition() != null) {
purchaseOrder.setPaymentCondition(supplierPartner.getPaymentCondition());
} else {
purchaseOrder.setPaymentCondition(purchaseOrder.getCompany().getAccountConfig().getDefPaymentCondition());
}
if (supplierPartner.getOutPaymentMode() != null) {
purchaseOrder.setPaymentMode(supplierPartner.getOutPaymentMode());
} else {
purchaseOrder.setPaymentMode(purchaseOrder.getCompany().getAccountConfig().getOutPaymentMode());
}
if (supplierPartner.getContactPartnerSet().size() == 1) {
purchaseOrder.setContactPartner(supplierPartner.getContactPartnerSet().iterator().next());
}
purchaseOrder.setCompanyBankDetails(Beans.get(BankDetailsService.class).getDefaultCompanyBankDetails(purchaseOrder.getCompany(), purchaseOrder.getPaymentMode(), purchaseOrder.getSupplierPartner(), null));
purchaseOrder.setPriceList(Beans.get(PartnerPriceListService.class).getDefaultPriceList(purchaseOrder.getSupplierPartner(), PriceListRepository.TYPE_PURCHASE));
if (Beans.get(AppSupplychainService.class).isApp("supplychain") && Beans.get(AppSupplychainService.class).getAppSupplychain().getIntercoFromPurchase() && !purchaseOrder.getCreatedByInterco() && (Beans.get(CompanyRepository.class).all().filter("self.partner = ?", supplierPartner).fetchOne() != null)) {
purchaseOrder.setInterco(true);
}
}
return purchaseOrder;
}
use of com.axelor.apps.base.db.Partner in project axelor-open-suite by axelor.
the class CostSheetLineServiceImpl method getComponentCostPrice.
protected BigDecimal getComponentCostPrice(Product product, int componentsValuationMethod, Company company) throws AxelorException {
BigDecimal price = null;
Currency companyCurrency = company.getCurrency();
if (componentsValuationMethod == ProductRepository.COMPONENTS_VALUATION_METHOD_AVERAGE) {
price = weightedAveragePriceService.computeAvgPriceForCompany(product, company);
if (price == null || price.compareTo(BigDecimal.ZERO) == 0) {
price = (BigDecimal) productCompanyService.get(product, "costPrice", company);
}
} else if (componentsValuationMethod == ProductRepository.COMPONENTS_VALUATION_METHOD_COST) {
price = (BigDecimal) productCompanyService.get(product, "costPrice", company);
if (price == null || price.compareTo(BigDecimal.ZERO) == 0) {
price = weightedAveragePriceService.computeAvgPriceForCompany(product, company);
}
}
if (product.getPurchasable() && (price == null || price.compareTo(BigDecimal.ZERO) == 0)) {
price = (BigDecimal) productCompanyService.get(product, "purchasePrice", company);
price = unitConversionService.convert(product.getUnit(), product.getPurchasesUnit() != null ? product.getPurchasesUnit() : product.getUnit(), price, appProductionService.getNbDecimalDigitForUnitPrice(), product);
BigDecimal shippingCoef = shippingCoefService.getShippingCoef(product, (Partner) productCompanyService.get(product, "defaultSupplierPartner", company), company, new BigDecimal(9999999));
price = price.multiply(shippingCoef);
if (productCompanyService.get(product, "purchaseCurrency", company) == null) {
throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.MISSING_PRODUCT_PURCHASE_CURRENCY), product.getFullName());
}
price = currencyService.getAmountCurrencyConvertedAtDate((Currency) productCompanyService.get(product, "purchaseCurrency", company), companyCurrency, price, appProductionService.getTodayDate(company));
if (price == null || price.compareTo(BigDecimal.ZERO) == 0) {
@SuppressWarnings("unchecked") List<SupplierCatalog> supplierCatalogList = (List<SupplierCatalog>) productCompanyService.get(product, "supplierCatalogList", company);
for (SupplierCatalog supplierCatalog : supplierCatalogList) {
if (BigDecimal.ZERO.compareTo(supplierCatalog.getPrice()) < 0) {
price = unitConversionService.convert(product.getUnit(), product.getPurchasesUnit() != null ? product.getPurchasesUnit() : product.getUnit(), supplierCatalog.getPrice(), appProductionService.getNbDecimalDigitForUnitPrice(), product);
Partner supplierPartner = supplierCatalog.getSupplierPartner();
if (supplierPartner != null) {
shippingCoef = shippingCoefService.getShippingCoef(product, supplierPartner, company, new BigDecimal(9999999));
price = price.multiply(shippingCoef);
price = currencyService.getAmountCurrencyConvertedAtDate(supplierPartner.getCurrency(), companyCurrency, price, appProductionService.getTodayDate(company));
}
break;
}
}
}
}
return price;
}
use of com.axelor.apps.base.db.Partner in project axelor-open-suite by axelor.
the class InvoiceController method fillCompanyBankDetails.
/**
* Called on load and in partner, company or payment mode change. Fill the bank details with a
* default value.
*
* @param request
* @param response
* @throws AxelorException
*/
public void fillCompanyBankDetails(ActionRequest request, ActionResponse response) throws AxelorException {
Invoice invoice = request.getContext().asType(Invoice.class);
PaymentMode paymentMode = invoice.getPaymentMode();
Company company = invoice.getCompany();
Partner partner = invoice.getPartner();
if (company == null) {
return;
}
if (partner != null) {
partner = Beans.get(PartnerRepository.class).find(partner.getId());
}
BankDetails defaultBankDetails = Beans.get(BankDetailsService.class).getDefaultCompanyBankDetails(company, paymentMode, partner, invoice.getOperationTypeSelect());
response.setValue("companyBankDetails", defaultBankDetails);
}
Aggregations