use of com.axelor.apps.account.db.Move 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.Move in project axelor-open-suite by axelor.
the class FixedAssetLineMoveServiceImpl method generateDisposalMove.
@Override
@Transactional(rollbackOn = { Exception.class })
public void generateDisposalMove(FixedAssetLine fixedAssetLine) throws AxelorException {
FixedAsset fixedAsset = fixedAssetLine.getFixedAsset();
Journal journal = fixedAsset.getJournal();
Company company = fixedAsset.getCompany();
Partner partner = fixedAsset.getPartner();
LocalDate date = fixedAssetLine.getDepreciationDate();
// Creating move
Move move = moveCreateService.createMove(journal, company, company.getCurrency(), partner, date, null, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, MoveRepository.FUNCTIONAL_ORIGIN_FIXED_ASSET);
if (move != null) {
List<MoveLine> moveLines = new ArrayList<MoveLine>();
String origin = fixedAsset.getReference();
Account chargeAccount = fixedAsset.getFixedAssetCategory().getChargeAccount();
Account depreciationAccount = fixedAsset.getFixedAssetCategory().getDepreciationAccount();
Account purchaseAccount = fixedAsset.getPurchaseAccount();
BigDecimal chargeAmount = fixedAssetLine.getResidualValue();
BigDecimal cumulativeDepreciationAmount = fixedAssetLine.getCumulativeDepreciation();
// Creating accounting debit move line for charge account
MoveLine chargeAccountDebitMoveLine = new MoveLine(move, partner, chargeAccount, date, null, 1, chargeAmount, BigDecimal.ZERO, fixedAsset.getName(), origin, null, BigDecimal.ZERO, date);
moveLines.add(chargeAccountDebitMoveLine);
this.addAnalyticToMoveLine(fixedAsset.getAnalyticDistributionTemplate(), chargeAccountDebitMoveLine);
// Creating accounting debit move line for deprecation account
MoveLine deprecationAccountDebitMoveLine = new MoveLine(move, partner, depreciationAccount, date, null, 1, cumulativeDepreciationAmount, BigDecimal.ZERO, fixedAsset.getName(), origin, null, BigDecimal.ZERO, date);
moveLines.add(deprecationAccountDebitMoveLine);
this.addAnalyticToMoveLine(fixedAsset.getAnalyticDistributionTemplate(), deprecationAccountDebitMoveLine);
// Creating accounting credit move line
MoveLine creditMoveLine = new MoveLine(move, partner, purchaseAccount, date, null, 2, BigDecimal.ZERO, fixedAsset.getGrossValue(), fixedAsset.getName(), origin, null, BigDecimal.ZERO, date);
moveLines.add(creditMoveLine);
this.addAnalyticToMoveLine(fixedAsset.getAnalyticDistributionTemplate(), creditMoveLine);
move.getMoveLineList().addAll(moveLines);
}
moveRepo.save(move);
fixedAsset.setDisposalMove(move);
}
use of com.axelor.apps.account.db.Move in project axelor-open-suite by axelor.
the class SubrogationReleaseController method displayMoveLines.
public void displayMoveLines(ActionRequest request, ActionResponse response) {
try {
SubrogationRelease subrogationRelease = request.getContext().asType(SubrogationRelease.class);
List<Long> moveLineIdList = new ArrayList<Long>();
for (Move move : subrogationRelease.getMoveList()) {
for (MoveLine moveLine : move.getMoveLineList()) {
moveLineIdList.add(moveLine.getId());
}
}
response.setView(ActionView.define("MoveLines").model(MoveLine.class.getName()).add("grid", "move-line-grid").add("form", "move-line-form").param("search-filters", "move-line-filters").domain("self.id in (" + Joiner.on(",").join(moveLineIdList) + ")").map());
} catch (Exception e) {
response.setError(e.getMessage());
TraceBackService.trace(e);
}
}
use of com.axelor.apps.account.db.Move in project axelor-open-suite by axelor.
the class InvoicePaymentController method cancelInvoicePayment.
public void cancelInvoicePayment(ActionRequest request, ActionResponse response) {
InvoicePayment invoicePayment = request.getContext().asType(InvoicePayment.class);
invoicePayment = Beans.get(InvoicePaymentRepository.class).find(invoicePayment.getId());
try {
Move move = invoicePayment.getMove();
Beans.get(InvoicePaymentCancelService.class).cancel(invoicePayment);
if (ObjectUtils.notEmpty(move)) {
Beans.get(MoveCustAccountService.class).updateCustomerAccount(move);
}
} catch (Exception e) {
TraceBackService.trace(response, e);
}
response.setReload(true);
}
use of com.axelor.apps.account.db.Move in project axelor-open-suite by axelor.
the class ImportMove method importFECMove.
@Transactional(rollbackOn = { AxelorException.class, Exception.class })
public Object importFECMove(Object bean, Map<String, Object> values) throws AxelorException {
assert bean instanceof MoveLine;
MoveLine moveLine = (MoveLine) bean;
try {
moveLine.setCounter(1);
if (values.get("EcritureNum") == null) {
return null;
}
String moveReference = values.get("EcritureNum").toString();
MoveLine mvLine = moveLineRepo.all().filter("self.name LIKE '" + moveReference + "-%'").order("-counter").fetchOne();
if (mvLine != null) {
int counter = mvLine.getCounter() + 1;
moveLine.setCounter(counter);
}
if (values.get("EcritureDate") != null) {
LocalDate moveLineDate = LocalDate.parse(values.get("EcritureDate").toString(), DateTimeFormatter.BASIC_ISO_DATE);
moveLine.setDate(moveLineDate);
}
Move move = moveRepository.all().filter("self.reference = ?", moveReference).fetchOne();
if (move == null) {
move = new Move();
move.setReference(moveReference);
if (values.get("ValidDate") != null) {
move.setStatusSelect(MoveRepository.STATUS_VALIDATED);
move.setValidationDate(LocalDate.parse(values.get("ValidDate").toString(), DateTimeFormatter.BASIC_ISO_DATE));
} else {
move.setStatusSelect(MoveRepository.STATUS_ACCOUNTED);
}
move.setCompany(getCompany(values));
move.setCompanyCurrency(move.getCompany().getCurrency());
move.setDate(LocalDate.parse(values.get("EcritureDate").toString(), DateTimeFormatter.BASIC_ISO_DATE));
move.setPeriod(Beans.get(PeriodService.class).getPeriod(move.getDate(), move.getCompany(), YearRepository.TYPE_FISCAL));
if (values.get("Idevise") != null) {
move.setCurrency(Beans.get(CurrencyRepository.class).findByCode(values.get("Idevise").toString()));
move.setCurrencyCode(values.get("Idevise").toString());
}
if (values.get("JournalCode") != null) {
Journal journal = Beans.get(JournalRepository.class).all().filter("self.code = ?1 AND self.company.id = ?2", values.get("JournalCode").toString(), move.getCompany().getId()).fetchOne();
move.setJournal(journal);
}
if (values.get("CompAuxNum") != null) {
Partner partner = Beans.get(PartnerRepository.class).all().filter("self.partnerSeq = ?", values.get("CompAuxNum").toString()).fetchOne();
move.setPartner(partner);
}
moveRepository.save(move);
}
if (values.get("CompteNum") != null) {
Account account = Beans.get(AccountRepository.class).all().filter("self.code = ?1 AND self.company.id = ?2", values.get("CompteNum").toString(), move.getCompany().getId()).fetchOne();
moveLine.setAccount(account);
}
moveLine.setMove(move);
} catch (Exception e) {
TraceBackService.trace(e);
throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, e.getMessage());
}
return moveLine;
}
Aggregations