use of com.axelor.apps.account.db.AccountingBatch in project axelor-open-suite by axelor.
the class AccountingBatchService method run.
@Override
public Batch run(Model batchModel) throws AxelorException {
Batch batch;
AccountingBatch accountingBatch = (AccountingBatch) batchModel;
switch(accountingBatch.getActionSelect()) {
case AccountingBatchRepository.ACTION_REIMBURSEMENT:
if (accountingBatch.getReimbursementTypeSelect() == AccountingBatchRepository.REIMBURSEMENT_TYPE_EXPORT) {
batch = reimbursementExport(accountingBatch);
} else if (accountingBatch.getReimbursementTypeSelect() == AccountingBatchRepository.REIMBURSEMENT_TYPE_IMPORT) {
batch = reimbursementImport(accountingBatch);
}
batch = null;
break;
case AccountingBatchRepository.ACTION_DEBT_RECOVERY:
batch = debtRecovery(accountingBatch);
break;
case AccountingBatchRepository.ACTION_DOUBTFUL_CUSTOMER:
batch = doubtfulCustomer(accountingBatch);
break;
case AccountingBatchRepository.ACTION_ACCOUNT_CUSTOMER:
batch = accountCustomer(accountingBatch);
break;
case AccountingBatchRepository.ACTION_MOVE_LINE_EXPORT:
batch = moveLineExport(accountingBatch);
break;
case AccountingBatchRepository.ACTION_CREDIT_TRANSFER:
batch = creditTransfer(accountingBatch);
break;
case AccountingBatchRepository.ACTION_REALIZE_FIXED_ASSET_LINES:
batch = realizeFixedAssetLines(accountingBatch);
break;
default:
throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.BASE_BATCH_1), accountingBatch.getActionSelect(), accountingBatch.getCode());
}
return batch;
}
use of com.axelor.apps.account.db.AccountingBatch in project axelor-open-suite by axelor.
the class BatchCloseAnnualAccounts method process.
protected void process() {
if (!end) {
AccountingBatch accountingBatch = batch.getAccountingBatch();
boolean allocatePerPartner = accountingBatch.getAllocatePerPartner();
boolean closeYear = accountingBatch.getCloseYear();
boolean openYear = accountingBatch.getOpenYear();
Year year = accountingBatch.getYear();
LocalDate endOfYearDate = year.getToDate();
LocalDate reportedBalanceDate = year.getReportedBalanceDate();
String origin = accountingBatch.getCode();
String moveDescription = accountingBatch.getMoveDescription();
List<Long> accountIdList = accountingCloseAnnualService.getAllAccountOfYear(accountingBatch.getAccountSet(), year);
List<Pair<Long, Long>> accountAndPartnerPairList = accountingCloseAnnualService.assignPartner(accountIdList, year, allocatePerPartner);
Account account = null;
Partner partner = null;
for (Pair<Long, Long> accountAndPartnerPair : accountAndPartnerPairList) {
try {
account = accountRepository.find(accountAndPartnerPair.getLeft());
if (accountAndPartnerPair.getRight() != null) {
partner = partnerRepository.find(accountAndPartnerPair.getRight());
} else {
partner = null;
}
List<Move> generateMoves = accountingCloseAnnualService.generateCloseAnnualAccount(yearRepository.find(year.getId()), account, partner, endOfYearDate, reportedBalanceDate, origin, moveDescription, closeYear, openYear, allocatePerPartner);
if (generateMoves != null && !generateMoves.isEmpty()) {
updateAccount(account);
for (Move move : generateMoves) {
updateAccountMove(move, false);
}
}
} catch (AxelorException e) {
TraceBackService.trace(new AxelorException(e, e.getCategory(), I18n.get("Account") + " %s", account.getCode()), null, batch.getId());
incrementAnomaly();
break;
} catch (Exception e) {
TraceBackService.trace(new Exception(String.format(I18n.get("Account") + " %s", account.getCode()), e), null, batch.getId());
incrementAnomaly();
LOG.error("Anomaly generated for the account {}", account.getCode());
break;
} finally {
JPA.clear();
}
}
}
}
use of com.axelor.apps.account.db.AccountingBatch in project axelor-open-suite by axelor.
the class AccountingBatchAccountRepository method copy.
@Override
public AccountingBatch copy(AccountingBatch entity, boolean deep) {
AccountingBatch copy = super.copy(entity, deep);
copy.setBatchList(null);
return copy;
}
use of com.axelor.apps.account.db.AccountingBatch in project axelor-open-suite by axelor.
the class BatchCreditTransferExpensePaymentHR method processExpenses.
/**
* Process expenses that need to be paid.
*
* @return
*/
protected List<Expense> processExpenses() {
List<Expense> doneList = new ArrayList<>();
// Can't pass an empty collection to the query
List<Long> anomalyList = Lists.newArrayList(0L);
AccountingBatch accountingBatch = batch.getAccountingBatch();
boolean manageMultiBanks = appAccountService.getAppBase().getManageMultiBanks();
String filter = "self.ventilated = true " + "AND self.paymentStatusSelect = :paymentStatusSelect " + "AND self.company = :company " + "AND self.user.partner.outPaymentMode = :paymentMode " + "AND self.id NOT IN (:anomalyList)";
if (manageMultiBanks) {
filter += " AND self.bankDetails IN (:bankDetailsSet)";
}
Query<Expense> query = expenseRepo.all().filter(filter).bind("paymentStatusSelect", InvoicePaymentRepository.STATUS_DRAFT).bind("company", accountingBatch.getCompany()).bind("paymentMode", accountingBatch.getPaymentMode()).bind("anomalyList", anomalyList);
if (manageMultiBanks) {
Set<BankDetails> bankDetailsSet = Sets.newHashSet(accountingBatch.getBankDetails());
if (accountingBatch.getIncludeOtherBankAccounts()) {
bankDetailsSet.addAll(accountingBatch.getCompany().getBankDetailsList());
}
query.bind("bankDetailsSet", bankDetailsSet);
}
for (List<Expense> expenseList; !(expenseList = query.fetch(FETCH_LIMIT)).isEmpty(); JPA.clear()) {
for (Expense expense : expenseList) {
try {
addPayment(expense, accountingBatch.getBankDetails());
doneList.add(expense);
incrementDone();
} catch (Exception ex) {
incrementAnomaly();
anomalyList.add(expense.getId());
query.bind("anomalyList", anomalyList);
TraceBackService.trace(ex, ExceptionOriginRepository.CREDIT_TRANSFER, batch.getId());
ex.printStackTrace();
log.error(String.format("Credit transfer batch for expense payment: anomaly for expense %s", expense.getExpenseSeq()));
break;
}
}
}
return doneList;
}
use of com.axelor.apps.account.db.AccountingBatch in project axelor-open-suite by axelor.
the class AccountingBatchController method actionMoveLineExport.
/**
* Lancer le batch de calcul du compte client
*
* @param request
* @param response
*/
public void actionMoveLineExport(ActionRequest request, ActionResponse response) {
AccountingBatch accountingBatch = request.getContext().asType(AccountingBatch.class);
Batch batch = null;
batch = Beans.get(AccountingBatchService.class).moveLineExport(Beans.get(AccountingBatchRepository.class).find(accountingBatch.getId()));
if (batch != null)
response.setFlash(batch.getComments());
response.setReload(true);
}
Aggregations