use of com.axelor.apps.base.db.Partner in project axelor-open-suite by axelor.
the class SaleOrderSupplychainRepository method remove.
@Override
public void remove(SaleOrder order) {
Partner partner = order.getClientPartner();
super.remove(order);
try {
Beans.get(AccountingSituationSupplychainService.class).updateUsedCredit(partner);
} catch (AxelorException e) {
e.printStackTrace();
}
}
use of com.axelor.apps.base.db.Partner in project axelor-open-suite by axelor.
the class ProjectBusinessServiceImpl method generateQuotation.
@Override
@Transactional(rollbackOn = { Exception.class })
public SaleOrder generateQuotation(Project project) throws AxelorException {
SaleOrder order = Beans.get(SaleOrderCreateService.class).createSaleOrder(project.getCompany());
Partner clientPartner = project.getClientPartner();
Partner contactPartner = project.getContactPartner();
if (contactPartner == null && clientPartner.getContactPartnerSet().size() == 1) {
contactPartner = clientPartner.getContactPartnerSet().iterator().next();
}
Company company = project.getCompany();
order.setProject(projectRepo.find(project.getId()));
order.setClientPartner(clientPartner);
order.setContactPartner(contactPartner);
order.setCompany(company);
order.setMainInvoicingAddress(partnerService.getInvoicingAddress(clientPartner));
order.setMainInvoicingAddressStr(addressService.computeAddressStr(order.getMainInvoicingAddress()));
order.setDeliveryAddress(partnerService.getDeliveryAddress(clientPartner));
order.setDeliveryAddressStr(addressService.computeAddressStr(order.getDeliveryAddress()));
order.setIsNeedingConformityCertificate(clientPartner.getIsNeedingConformityCertificate());
order.setCompanyBankDetails(Beans.get(AccountingSituationService.class).getCompanySalesBankDetails(company, clientPartner));
if (project.getCurrency() != null) {
order.setCurrency(project.getCurrency());
} else if (clientPartner.getCurrency() != null) {
order.setCurrency(clientPartner.getCurrency());
} else {
order.setCurrency(company.getCurrency());
}
if (project.getPriceList() != null) {
order.setPriceList(project.getPriceList());
} else {
order.setPriceList(Beans.get(PartnerPriceListService.class).getDefaultPriceList(clientPartner, PriceListRepository.TYPE_SALE));
}
if (order.getPriceList() != null) {
order.setHideDiscount(order.getPriceList().getHideDiscount());
}
if (clientPartner.getPaymentCondition() != null) {
order.setPaymentCondition(clientPartner.getPaymentCondition());
} else {
if (company != null && company.getAccountConfig() != null) {
order.setPaymentCondition(company.getAccountConfig().getDefPaymentCondition());
}
}
if (clientPartner.getInPaymentMode() != null) {
order.setPaymentMode(clientPartner.getInPaymentMode());
} else {
if (company != null && company.getAccountConfig() != null) {
order.setPaymentMode(company.getAccountConfig().getInPaymentMode());
}
}
AppSupplychain appSupplychain = Beans.get(AppSupplychainService.class).getAppSupplychain();
if (appSupplychain != null) {
order.setShipmentMode(clientPartner.getShipmentMode());
order.setFreightCarrierMode(clientPartner.getFreightCarrierMode());
if (clientPartner.getFreightCarrierMode() != null) {
order.setCarrierPartner(clientPartner.getFreightCarrierMode().getCarrierPartner());
}
Boolean interco = appSupplychain.getIntercoFromSale() && !order.getCreatedByInterco() && clientPartner != null && Beans.get(CompanyRepository.class).all().filter("self.partner = ?", clientPartner).fetchOne() != null;
order.setInterco(interco);
// Automatic invoiced and delivered partners set in case of partner delegations
if (appSupplychain.getActivatePartnerRelations()) {
Beans.get(SaleOrderSupplychainService.class).setDefaultInvoicedAndDeliveredPartnersAndAddresses(order);
}
}
return Beans.get(SaleOrderRepository.class).save(order);
}
use of com.axelor.apps.base.db.Partner in project axelor-open-suite by axelor.
the class CampaignController method markPartnerPresent.
public void markPartnerPresent(ActionRequest request, ActionResponse response) {
Campaign campaign = request.getContext().getParent().asType(Campaign.class);
Partner partner = request.getContext().asType(Partner.class);
partner = Beans.get(PartnerRepository.class).find(partner.getId());
try {
Beans.get(CampaignService.class).markPartnerPresent(Beans.get(CampaignRepository.class).find(campaign.getId()), partner);
response.setReload(true);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.base.db.Partner in project axelor-open-suite by axelor.
the class SaleOrderServiceSupplychainImpl method getClientInformations.
public SaleOrder getClientInformations(SaleOrder saleOrder) {
Partner client = saleOrder.getClientPartner();
PartnerService partnerService = Beans.get(PartnerService.class);
if (client != null) {
saleOrder.setPaymentCondition(client.getPaymentCondition());
saleOrder.setPaymentMode(client.getInPaymentMode());
saleOrder.setMainInvoicingAddress(partnerService.getInvoicingAddress(client));
this.computeAddressStr(saleOrder);
saleOrder.setDeliveryAddress(partnerService.getDeliveryAddress(client));
saleOrder.setPriceList(Beans.get(PartnerPriceListService.class).getDefaultPriceList(client, PriceListRepository.TYPE_SALE));
}
return saleOrder;
}
use of com.axelor.apps.base.db.Partner in project axelor-open-suite by axelor.
the class SaleOrderServiceSupplychainImpl method setDefaultInvoicedAndDeliveredPartners.
protected void setDefaultInvoicedAndDeliveredPartners(SaleOrder saleOrder, Partner clientPartner) {
if (!CollectionUtils.isEmpty(clientPartner.getPartner1SupplychainLinkList())) {
List<PartnerSupplychainLink> partnerSupplychainLinkList = clientPartner.getPartner1SupplychainLinkList();
// Retrieve all Invoiced by Type
List<PartnerSupplychainLink> partnerSupplychainLinkInvoicedByList = partnerSupplychainLinkList.stream().filter(partnerSupplychainLink -> PartnerSupplychainLinkTypeRepository.TYPE_SELECT_INVOICED_BY.equals(partnerSupplychainLink.getPartnerSupplychainLinkType().getTypeSelect())).collect(Collectors.toList());
// Retrieve all Delivered by Type
List<PartnerSupplychainLink> partnerSupplychainLinkDeliveredByList = partnerSupplychainLinkList.stream().filter(partnerSupplychainLink -> PartnerSupplychainLinkTypeRepository.TYPE_SELECT_DELIVERED_BY.equals(partnerSupplychainLink.getPartnerSupplychainLinkType().getTypeSelect())).collect(Collectors.toList());
// If there is only one, then it is the default one
if (partnerSupplychainLinkInvoicedByList.size() == 1) {
PartnerSupplychainLink partnerSupplychainLinkInvoicedBy = partnerSupplychainLinkInvoicedByList.get(0);
saleOrder.setInvoicedPartner(partnerSupplychainLinkInvoicedBy.getPartner2());
} else if (partnerSupplychainLinkInvoicedByList.size() == 0) {
saleOrder.setInvoicedPartner(clientPartner);
} else {
saleOrder.setInvoicedPartner(null);
}
if (partnerSupplychainLinkDeliveredByList.size() == 1) {
PartnerSupplychainLink partnerSupplychainLinkDeliveredBy = partnerSupplychainLinkDeliveredByList.get(0);
saleOrder.setDeliveredPartner(partnerSupplychainLinkDeliveredBy.getPartner2());
} else if (partnerSupplychainLinkDeliveredByList.size() == 0) {
saleOrder.setDeliveredPartner(clientPartner);
} else {
saleOrder.setDeliveredPartner(null);
}
} else {
saleOrder.setInvoicedPartner(clientPartner);
saleOrder.setDeliveredPartner(clientPartner);
}
}
Aggregations