use of com.axelor.apps.account.db.Account in project axelor-open-suite by axelor.
the class VentilateState method setPartnerAccount.
protected void setPartnerAccount() throws AxelorException {
// Partner account is actually set upon validation but we keep this for backward compatibility
if (invoice.getPartnerAccount() == null) {
Account account = Beans.get(InvoiceService.class).getPartnerAccount(invoice);
if (account == null) {
throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.VENTILATE_STATE_5));
}
if (invoice.getPartner() != null) {
account = Beans.get(FiscalPositionAccountService.class).getAccount(invoice.getPartner().getFiscalPosition(), account);
}
invoice.setPartnerAccount(account);
}
Account partnerAccount = invoice.getPartnerAccount();
if (!partnerAccount.getReconcileOk() || !partnerAccount.getUseForPartnerBalance()) {
throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.ACCOUNT_RECONCILABLE_USE_FOR_PARTNER_BALANCE));
}
}
use of com.axelor.apps.account.db.Account in project axelor-open-suite by axelor.
the class BankReconciliationService method getCashAccount.
public Account getCashAccount(BankReconciliation bankReconciliation) {
Account cashAccount = null;
String cashAccountIds = String.join(",", getAccountManagementCashAccounts(bankReconciliation));
if (bankReconciliation.getBankDetails().getBankAccount() != null) {
cashAccount = bankReconciliation.getBankDetails().getBankAccount();
} else if (!Strings.isNullOrEmpty(cashAccountIds) && (cashAccountIds.split(",").length) == 1) {
cashAccount = Beans.get(AccountRepository.class).find(Long.parseLong(cashAccountIds));
}
return cashAccount;
}
use of com.axelor.apps.account.db.Account in project axelor-open-suite by axelor.
the class BankReconciliationService method getAccountManagementJournals.
protected Set<String> getAccountManagementJournals(BankReconciliation bankReconciliation) {
Set<String> journalIdSet = new HashSet<String>();
Account cashAccount = bankReconciliation.getCashAccount();
List<AccountManagement> accountManagementList = new ArrayList<>();
if (cashAccount != null) {
accountManagementList = accountManagementRepository.all().filter("self.bankDetails = ?1 and self.cashAccount = ?2", bankReconciliation.getBankDetails(), cashAccount).fetch();
} else {
accountManagementList = accountManagementRepository.all().filter("self.bankDetails = ?1", bankReconciliation.getBankDetails()).fetch();
}
for (AccountManagement accountManagement : accountManagementList) {
if (accountManagement.getJournal() != null) {
journalIdSet.add(accountManagement.getJournal().getId().toString());
}
}
return journalIdSet;
}
use of com.axelor.apps.account.db.Account in project axelor-open-suite by axelor.
the class BankOrderMoveServiceImpl method generateReceiverMove.
protected Move generateReceiverMove(BankOrderLine bankOrderLine) throws AxelorException {
Partner partner = bankOrderLine.getPartner();
Company receiverCompany = bankOrderLine.getReceiverCompany();
BankDetails receiverBankDetails = bankOrderLine.getReceiverBankDetails();
Journal receiverJournal = paymentModeService.getPaymentModeJournal(paymentMode, receiverCompany, receiverBankDetails);
Account receiverBankAccount = paymentModeService.getPaymentModeAccount(paymentMode, receiverCompany, receiverBankDetails);
Move receiverMove = moveService.getMoveCreateService().createMove(receiverJournal, receiverCompany, this.getCurrency(bankOrderLine), partner, this.getDate(bankOrderLine), paymentMode, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, MoveRepository.FUNCTIONAL_ORIGIN_PAYMENT);
MoveLine bankMoveLine = moveService.getMoveLineService().createMoveLine(receiverMove, partner, receiverBankAccount, bankOrderLine.getBankOrderAmount(), isDebit, receiverMove.getDate(), 1, bankOrderLine.getReceiverReference(), bankOrderLine.getReceiverLabel());
receiverMove.addMoveLineListItem(bankMoveLine);
MoveLine partnerMoveLine = moveService.getMoveLineService().createMoveLine(receiverMove, partner, getPartnerAccount(partner, receiverCompany, receiverMove.getCompany()), bankOrderLine.getBankOrderAmount(), !isDebit, receiverMove.getDate(), 2, bankOrderLine.getReceiverReference(), bankOrderLine.getReceiverLabel());
receiverMove.addMoveLineListItem(partnerMoveLine);
return receiverMove;
}
use of com.axelor.apps.account.db.Account in project axelor-open-suite by axelor.
the class BankReconciliationController method setCashAccount.
public void setCashAccount(ActionRequest request, ActionResponse response) {
BankReconciliation bankReconciliation = request.getContext().asType(BankReconciliation.class);
Account cashAccount = null;
if (EntityHelper.getEntity(bankReconciliation).getBankDetails() != null) {
cashAccount = Beans.get(BankReconciliationService.class).getCashAccount(bankReconciliation);
}
response.setValue("cashAccount", cashAccount);
}
Aggregations