use of com.axelor.apps.supplychain.db.PartnerSupplychainLink 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);
}
}
use of com.axelor.apps.supplychain.db.PartnerSupplychainLink in project axelor-open-suite by axelor.
the class StockMoveServiceSupplychainImpl method setDefaultInvoicedPartner.
@Override
public void setDefaultInvoicedPartner(StockMove stockMove) {
if (stockMove != null && stockMove.getPartner() != null && stockMove.getPartner().getId() != null) {
Partner partner = Beans.get(PartnerRepository.class).find(stockMove.getPartner().getId());
if (partner != null) {
if (!CollectionUtils.isEmpty(partner.getPartner1SupplychainLinkList())) {
List<PartnerSupplychainLink> partnerSupplychainLinkList = partner.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());
// If there is only one, then it is the default one
if (partnerSupplychainLinkInvoicedByList.size() == 1) {
PartnerSupplychainLink partnerSupplychainLinkInvoicedBy = partnerSupplychainLinkInvoicedByList.get(0);
stockMove.setInvoicedPartner(partnerSupplychainLinkInvoicedBy.getPartner2());
} else if (partnerSupplychainLinkInvoicedByList.size() == 0) {
stockMove.setInvoicedPartner(partner);
} else {
stockMove.setInvoicedPartner(null);
}
} else {
stockMove.setInvoicedPartner(partner);
}
}
}
}
Aggregations