Search in sources :

Example 26 with Expense

use of com.axelor.apps.hr.db.Expense in project axelor-open-suite by axelor.

the class BankOrderServiceHRImpl method cancelPayment.

@Override
@Transactional(rollbackOn = { Exception.class })
public void cancelPayment(BankOrder bankOrder) throws AxelorException {
    super.cancelPayment(bankOrder);
    if (!Beans.get(AppService.class).isApp("employee")) {
        return;
    }
    List<Expense> expenseList = Beans.get(ExpenseRepository.class).all().filter("self.bankOrder.id = ?", bankOrder.getId()).fetch();
    for (Expense expense : expenseList) {
        if (expense != null && expense.getPaymentStatusSelect() != InvoicePaymentRepository.STATUS_CANCELED) {
            expenseService.cancelPayment(expense);
        }
    }
}
Also used : Expense(com.axelor.apps.hr.db.Expense) ExpenseRepository(com.axelor.apps.hr.db.repo.ExpenseRepository) Transactional(com.google.inject.persist.Transactional)

Example 27 with Expense

use of com.axelor.apps.hr.db.Expense in project axelor-open-suite by axelor.

the class PayrollPreparationService method computeExpenseAmount.

public BigDecimal computeExpenseAmount(PayrollPreparation payrollPreparation) {
    BigDecimal expenseAmount = BigDecimal.ZERO;
    List<Expense> expenseList = Beans.get(ExpenseRepository.class).all().filter("self.user.employee = ?1 " + "AND self.statusSelect = ?2 " + "AND (self.payrollPreparation IS NULL OR self.payrollPreparation.id = ?3) " + "AND self.companyCbSelect = ?4 " + "AND self.validationDate BETWEEN ?5 AND ?6", payrollPreparation.getEmployee(), ExpenseRepository.STATUS_VALIDATED, payrollPreparation.getId(), ExpenseRepository.COMPANY_CB_PAYMENT_NO, payrollPreparation.getPeriod().getFromDate(), payrollPreparation.getPeriod().getToDate()).fetch();
    for (Expense expense : expenseList) {
        expenseAmount = expenseAmount.add(expense.getInTaxTotal());
        payrollPreparation.addExpenseListItem(expense);
    }
    return expenseAmount;
}
Also used : Expense(com.axelor.apps.hr.db.Expense) ExpenseRepository(com.axelor.apps.hr.db.repo.ExpenseRepository) BigDecimal(java.math.BigDecimal)

Aggregations

Expense (com.axelor.apps.hr.db.Expense)27 AxelorException (com.axelor.exception.AxelorException)14 ExpenseService (com.axelor.apps.hr.service.expense.ExpenseService)12 ExpenseLine (com.axelor.apps.hr.db.ExpenseLine)7 Transactional (com.google.inject.persist.Transactional)7 ExpenseRepository (com.axelor.apps.hr.db.repo.ExpenseRepository)6 BigDecimal (java.math.BigDecimal)5 MessageServiceBaseImpl (com.axelor.apps.base.service.message.MessageServiceBaseImpl)4 IExceptionMessage (com.axelor.apps.hr.exception.IExceptionMessage)4 Message (com.axelor.apps.message.db.Message)4 User (com.axelor.auth.db.User)4 ArrayList (java.util.ArrayList)4 Product (com.axelor.apps.base.db.Product)3 Employee (com.axelor.apps.hr.db.Employee)3 BankOrder (com.axelor.apps.bankpayment.db.BankOrder)2 Company (com.axelor.apps.base.db.Company)2 AccountingBatch (com.axelor.apps.account.db.AccountingBatch)1 Move (com.axelor.apps.account.db.Move)1 BankDetails (com.axelor.apps.base.db.BankDetails)1 Period (com.axelor.apps.base.db.Period)1