use of com.axelor.apps.crm.service.ConvertLeadWizardService in project axelor-open-suite by axelor.
the class ConvertLeadWizardController method createContactData.
@SuppressWarnings("unchecked")
private Partner createContactData(Context context, Partner partner) throws AxelorException {
Partner contactPartner = null;
Integer leadToContactSelect = (Integer) context.get("leadToContactSelect");
ConvertLeadWizardService convertLeadWizardService = Beans.get(ConvertLeadWizardService.class);
if (leadToContactSelect == null) {
return null;
}
if (leadToContactSelect == LeadRepository.CONVERT_LEAD_CREATE_CONTACT && partner.getPartnerTypeSelect() != PartnerRepository.PARTNER_TYPE_INDIVIDUAL) {
Address primaryAddress = convertLeadWizardService.createPrimaryAddress(context);
if (primaryAddress != null && (primaryAddress.getAddressL6() == null || primaryAddress.getAddressL7Country() == null)) {
throw new AxelorException(TraceBackRepository.CATEGORY_MISSING_FIELD, I18n.get(IExceptionMessage.LEAD_CONTACT_MISSING_ADDRESS));
}
contactPartner = convertLeadWizardService.createPartner((Map<String, Object>) context.get("contactPartner"), primaryAddress);
contactPartner.setIsContact(true);
// TODO check all required fields...
} else if (leadToContactSelect == LeadRepository.CONVERT_LEAD_SELECT_CONTACT && partner.getPartnerTypeSelect() != PartnerRepository.PARTNER_TYPE_INDIVIDUAL) {
Map<String, Object> selectContactContext = (Map<String, Object>) context.get("selectContact");
contactPartner = Beans.get(PartnerRepository.class).find(((Integer) selectContactContext.get("id")).longValue());
}
return contactPartner;
}
use of com.axelor.apps.crm.service.ConvertLeadWizardService in project axelor-open-suite by axelor.
the class ConvertLeadWizardController method createPartnerData.
@SuppressWarnings("unchecked")
private Partner createPartnerData(Context context) throws AxelorException {
Integer leadToPartnerSelect = (Integer) context.get("leadToPartnerSelect");
ConvertLeadWizardService convertLeadWizardService = Beans.get(ConvertLeadWizardService.class);
Partner partner = null;
if (leadToPartnerSelect == LeadRepository.CONVERT_LEAD_CREATE_PARTNER) {
Address primaryAddress = convertLeadWizardService.createPrimaryAddress(context);
if (primaryAddress != null && (primaryAddress.getAddressL6() == null || primaryAddress.getAddressL7Country() == null)) {
throw new AxelorException(TraceBackRepository.CATEGORY_MISSING_FIELD, I18n.get(IExceptionMessage.LEAD_PARTNER_MISSING_ADDRESS));
}
partner = convertLeadWizardService.createPartner((Map<String, Object>) context.get("partner"), primaryAddress);
// TODO check all required fields...
} else if (leadToPartnerSelect == LeadRepository.CONVERT_LEAD_SELECT_PARTNER) {
Map<String, Object> selectPartnerContext = (Map<String, Object>) context.get("selectPartner");
partner = Beans.get(PartnerRepository.class).find(((Integer) selectPartnerContext.get("id")).longValue());
if (!partner.getIsCustomer()) {
partner.setIsProspect(true);
}
}
return partner;
}
Aggregations