Search in sources :

Example 26 with Account

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));
    }
}
Also used : Account(com.axelor.apps.account.db.Account) AxelorException(com.axelor.exception.AxelorException) InvoiceService(com.axelor.apps.account.service.invoice.InvoiceService)

Example 27 with Account

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;
}
Also used : Account(com.axelor.apps.account.db.Account) AccountRepository(com.axelor.apps.account.db.repo.AccountRepository)

Example 28 with Account

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;
}
Also used : Account(com.axelor.apps.account.db.Account) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) AccountManagement(com.axelor.apps.account.db.AccountManagement)

Example 29 with Account

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;
}
Also used : Account(com.axelor.apps.account.db.Account) Company(com.axelor.apps.base.db.Company) Move(com.axelor.apps.account.db.Move) BankDetails(com.axelor.apps.base.db.BankDetails) MoveLine(com.axelor.apps.account.db.MoveLine) Journal(com.axelor.apps.account.db.Journal) Partner(com.axelor.apps.base.db.Partner)

Example 30 with Account

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);
}
Also used : Account(com.axelor.apps.account.db.Account) BankReconciliation(com.axelor.apps.bankpayment.db.BankReconciliation)

Aggregations

Account (com.axelor.apps.account.db.Account)59 MoveLine (com.axelor.apps.account.db.MoveLine)27 Company (com.axelor.apps.base.db.Company)26 BigDecimal (java.math.BigDecimal)26 Partner (com.axelor.apps.base.db.Partner)25 Move (com.axelor.apps.account.db.Move)21 AxelorException (com.axelor.exception.AxelorException)20 Journal (com.axelor.apps.account.db.Journal)18 Transactional (com.google.inject.persist.Transactional)18 AccountConfig (com.axelor.apps.account.db.AccountConfig)14 LocalDate (java.time.LocalDate)12 AnalyticMoveLine (com.axelor.apps.account.db.AnalyticMoveLine)10 ArrayList (java.util.ArrayList)10 TaxLine (com.axelor.apps.account.db.TaxLine)8 Invoice (com.axelor.apps.account.db.Invoice)7 Reconcile (com.axelor.apps.account.db.Reconcile)7 InvoiceLine (com.axelor.apps.account.db.InvoiceLine)6 BankDetails (com.axelor.apps.base.db.BankDetails)6 PaymentMode (com.axelor.apps.account.db.PaymentMode)5 Product (com.axelor.apps.base.db.Product)5