Search in sources :

Example 31 with Partner

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

the class PartnerBaseRepository method populate.

@Override
public Map<String, Object> populate(Map<String, Object> json, Map<String, Object> context) {
    if (!context.containsKey("json-enhance")) {
        return json;
    }
    try {
        Long id = (Long) json.get("id");
        Partner partner = find(id);
        json.put("address", Beans.get(PartnerService.class).getDefaultAddress(partner));
    } catch (Exception e) {
        e.printStackTrace();
    }
    return json;
}
Also used : Partner(com.axelor.apps.base.db.Partner) PersistenceException(javax.persistence.PersistenceException)

Example 32 with Partner

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

the class PartnerBaseRepository method copy.

@Override
public Partner copy(Partner partner, boolean deep) {
    Partner copy = super.copy(partner, deep);
    copy.setPartnerSeq(null);
    copy.setEmailAddress(null);
    PartnerAddressRepository partnerAddressRepository = Beans.get(PartnerAddressRepository.class);
    List<PartnerAddress> partnerAddressList = Lists.newArrayList();
    if (deep && copy.getPartnerAddressList() != null) {
        for (PartnerAddress partnerAddress : copy.getPartnerAddressList()) {
            partnerAddressList.add(partnerAddressRepository.copy(partnerAddress, deep));
        }
    }
    copy.setPartnerAddressList(partnerAddressList);
    copy.setBlockingList(null);
    copy.setBankDetailsList(null);
    return copy;
}
Also used : PartnerAddress(com.axelor.apps.base.db.PartnerAddress) Partner(com.axelor.apps.base.db.Partner)

Example 33 with Partner

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

the class UserBaseRepository method remove.

@Override
public void remove(User user) {
    if (user.getPartner() != null) {
        PartnerBaseRepository partnerRepo = Beans.get(PartnerBaseRepository.class);
        Partner partner = partnerRepo.find(user.getPartner().getId());
        if (partner != null) {
            partner.setLinkedUser(null);
            partnerRepo.save(partner);
        }
    }
    super.remove(user);
}
Also used : Partner(com.axelor.apps.base.db.Partner)

Example 34 with Partner

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

the class EmployeeController method setContactSocialNetworkUrl.

public void setContactSocialNetworkUrl(ActionRequest request, ActionResponse response) {
    Partner partnerContact = request.getContext().asType(Partner.class);
    Map<String, String> urlMap = Beans.get(EmployeeService.class).getSocialNetworkUrl(partnerContact.getName(), partnerContact.getFirstName());
    response.setAttr("facebookLabel", "title", urlMap.get("facebook"));
    response.setAttr("twitterLabel", "title", urlMap.get("twitter"));
    response.setAttr("linkedinLabel", "title", urlMap.get("linkedin"));
    response.setAttr("youtubeLabel", "title", urlMap.get("youtube"));
}
Also used : Partner(com.axelor.apps.base.db.Partner) EmployeeService(com.axelor.apps.hr.service.employee.EmployeeService)

Example 35 with Partner

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

the class CampaignServiceImpl method generateEvents.

@Transactional
public void generateEvents(Campaign campaign) {
    LocalDateTime eventStartDateTime = campaign.getEventStartDateTime();
    LocalDateTime eventEndDateTime = campaign.getEventEndDateTime();
    Long duration = campaign.getDuration();
    for (Partner partner : campaign.getPartnerSet()) {
        Event event = new Event();
        if (partner.getIsContact()) {
            event.setContactPartner(partner);
        } else {
            event.setPartner(partner);
        }
        event.setUser(campaign.getGenerateEventPerPartnerOrLead() ? partner.getUser() : campaign.getEventUser());
        event.setSubject(campaign.getSubject());
        event.setTypeSelect(campaign.getEventTypeSelect());
        event.setStartDateTime(eventStartDateTime);
        event.setEndDateTime(eventEndDateTime);
        event.setDuration(duration);
        event.setTeam(campaign.getGenerateEventPerPartnerOrLead() ? partner.getTeam() : campaign.getTeam());
        event.setCampaign(campaign);
        event.setStatusSelect(1);
        eventRepo.save(event);
    }
    for (Lead lead : campaign.getLeadSet()) {
        Event event = new Event();
        event.setLead(lead);
        event.setUser(campaign.getGenerateEventPerPartnerOrLead() ? lead.getUser() : campaign.getEventUser());
        event.setSubject(campaign.getSubject());
        event.setTypeSelect(campaign.getEventTypeSelect());
        event.setStartDateTime(eventStartDateTime);
        event.setEndDateTime(eventEndDateTime);
        event.setDuration(duration);
        event.setTeam(campaign.getGenerateEventPerPartnerOrLead() ? lead.getTeam() : campaign.getTeam());
        event.setCampaign(campaign);
        event.setStatusSelect(1);
        eventRepo.save(event);
    }
}
Also used : LocalDateTime(java.time.LocalDateTime) Lead(com.axelor.apps.crm.db.Lead) Event(com.axelor.apps.crm.db.Event) 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