use of com.axelor.apps.base.db.BankDetails in project axelor-open-suite by axelor.
the class ReimbursementExportService method updatePartnerCurrentRIB.
/**
* Procédure permettant de mettre à jour la liste des RIBs du tiers
*
* @param reimbursement Un remboursement
*/
@Transactional
public void updatePartnerCurrentRIB(Reimbursement reimbursement) {
BankDetails bankDetails = reimbursement.getBankDetails();
Partner partner = reimbursement.getPartner();
BankDetails defaultBankDetails = partnerService.getDefaultBankDetails(partner);
if (partner != null && bankDetails != null && !bankDetails.equals(defaultBankDetails)) {
bankDetails.setIsDefault(true);
defaultBankDetails.setIsDefault(false);
partner.addBankDetailsListItem(bankDetails);
partnerRepository.save(partner);
}
}
use of com.axelor.apps.base.db.BankDetails in project axelor-open-suite by axelor.
the class ReimbursementService method updatePartnerCurrentRIB.
/**
* Procédure permettant de mettre à jour la liste des RIBs du tiers
*
* @param reimbursement Un remboursement
*/
@Transactional
public void updatePartnerCurrentRIB(Reimbursement reimbursement) {
BankDetails bankDetails = reimbursement.getBankDetails();
Partner partner = reimbursement.getPartner();
BankDetails defaultBankDetails = partnerService.getDefaultBankDetails(partner);
if (bankDetails != null && partner != null && !bankDetails.equals(defaultBankDetails)) {
defaultBankDetails.setIsDefault(false);
bankDetails.setIsDefault(true);
partner.addBankDetailsListItem(bankDetails);
partnerRepository.save(partner);
}
}
use of com.axelor.apps.base.db.BankDetails in project axelor-open-suite by axelor.
the class BankDetailsServiceAccountImpl method createCompanyBankDetailsDomainFromFactorPartner.
private List<BankDetails> createCompanyBankDetailsDomainFromFactorPartner(Company company) throws AxelorException {
AccountConfig accountConfig = Beans.get(AccountConfigService.class).getAccountConfig(company);
List<BankDetails> bankDetailsList = accountConfig.getFactorPartner().getBankDetailsList();
return bankDetailsList.stream().filter(bankDetails -> bankDetails.getActive()).collect(Collectors.toList());
}
use of com.axelor.apps.base.db.BankDetails in project axelor-open-suite by axelor.
the class BankDetailsServiceAccountImpl method createCompanyBankDetailsDomain.
/**
* In this implementation, we use the O2M in payment mode.
*
* @param company
* @param paymentMode
* @return
* @throws AxelorException
*/
@Override
public String createCompanyBankDetailsDomain(Partner partner, Company company, PaymentMode paymentMode, Integer operationTypeSelect) throws AxelorException {
AppAccountService appAccountService = Beans.get(AppAccountService.class);
if (!appAccountService.isApp("account") || !appAccountService.getAppBase().getManageMultiBanks()) {
return super.createCompanyBankDetailsDomain(partner, company, paymentMode, operationTypeSelect);
} else {
if (partner != null) {
partner = Beans.get(PartnerRepository.class).find(partner.getId());
}
List<BankDetails> authorizedBankDetails = new ArrayList<>();
if (partner != null && partner.getFactorizedCustomer() && operationTypeSelect != null && (operationTypeSelect.intValue() == InvoiceRepository.OPERATION_TYPE_CLIENT_SALE || operationTypeSelect.intValue() == InvoiceRepository.OPERATION_TYPE_CLIENT_REFUND)) {
authorizedBankDetails = createCompanyBankDetailsDomainFromFactorPartner(company);
} else {
if (paymentMode == null) {
return "self.id IN (0)";
}
List<AccountManagement> accountManagementList = paymentMode.getAccountManagementList();
authorizedBankDetails = new ArrayList<>();
for (AccountManagement accountManagement : accountManagementList) {
if (accountManagement.getCompany() != null && accountManagement.getCompany().equals(company)) {
authorizedBankDetails.add(accountManagement.getBankDetails());
}
}
}
if (authorizedBankDetails.isEmpty()) {
return "self.id IN (0)";
} else {
return "self.id IN (" + StringTool.getIdListString(authorizedBankDetails) + ") AND self.active = true";
}
}
}
use of com.axelor.apps.base.db.BankDetails in project axelor-open-suite by axelor.
the class BankDetailsServiceAccountImpl method getDefaultCompanyBankDetails.
/**
* Find a default bank details.
*
* @param company
* @param paymentMode
* @param partner
* @return the default bank details in accounting situation if it is active and allowed by the
* payment mode, or an authorized bank details if he is the only one authorized.
* @throws AxelorException
*/
@Override
public BankDetails getDefaultCompanyBankDetails(Company company, PaymentMode paymentMode, Partner partner, Integer operationTypeSelect) throws AxelorException {
AppAccountService appAccountService = Beans.get(AppAccountService.class);
if (!appAccountService.isApp("account") || !appAccountService.getAppBase().getManageMultiBanks()) {
return super.getDefaultCompanyBankDetails(company, paymentMode, partner, operationTypeSelect);
} else {
if (partner != null && partner.getFactorizedCustomer() && operationTypeSelect != null && (operationTypeSelect.intValue() == InvoiceRepository.OPERATION_TYPE_CLIENT_SALE || operationTypeSelect.intValue() == InvoiceRepository.OPERATION_TYPE_CLIENT_REFUND)) {
return getDefaultCompanyBankDetailsFromFactorPartner(company);
} else {
if (paymentMode == null) {
return null;
}
BankDetails candidateBankDetails = getDefaultCompanyBankDetailsFromPartner(company, paymentMode, partner);
List<BankDetails> authorizedBankDetails = Beans.get(PaymentModeService.class).getCompatibleBankDetailsList(paymentMode, company);
if (candidateBankDetails != null && authorizedBankDetails.contains(candidateBankDetails) && candidateBankDetails.getActive()) {
return candidateBankDetails;
} else // we did not find a bank details in accounting situation
{
if (authorizedBankDetails.size() == 1) {
return authorizedBankDetails.get(0);
}
}
}
return null;
}
}
Aggregations