use of com.axelor.apps.account.db.MoveLine in project axelor-open-suite by axelor.
the class BatchReimbursementImport method validateMove.
public void validateMove(Move move, LocalDate rejectDate, int seq) {
try {
if (seq != 1) {
MoveLine oppositeMoveLine = reimbursementImportService.createOppositeRejectMoveLine(moveRepo.find(move.getId()), seq, rejectDate);
reimbursementImportService.validateMove(moveRepo.find(move.getId()));
this.totalAmount = this.totalAmount.add(moveLineRepo.find(oppositeMoveLine.getId()).getDebit());
} else {
reimbursementImportService.deleteMove(moveRepo.find(move.getId()));
}
} catch (AxelorException e) {
TraceBackService.trace(new AxelorException(e, e.getCategory(), I18n.get(IExceptionMessage.BATCH_REIMBURSEMENT_6), batch.getId()), ExceptionOriginRepository.REIMBURSEMENT, batch.getId());
incrementAnomaly();
} catch (Exception e) {
TraceBackService.trace(new Exception(String.format(I18n.get(IExceptionMessage.BATCH_REIMBURSEMENT_6), batch.getId()), e), ExceptionOriginRepository.REIMBURSEMENT, batch.getId());
incrementAnomaly();
log.error("Bug(Anomalie) généré(e) pour le batch d'import des remboursements {}", batch.getId());
}
}
use of com.axelor.apps.account.db.MoveLine 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.MoveLine in project axelor-open-suite by axelor.
the class MoveManagementRepository method save.
@Override
public Move save(Move move) {
try {
if (move.getStatusSelect() == MoveRepository.STATUS_ACCOUNTED) {
Beans.get(MoveValidateService.class).checkPreconditions(move);
}
Beans.get(MoveSequenceService.class).setDraftSequence(move);
List<MoveLine> moveLineList = move.getMoveLineList();
if (moveLineList != null) {
for (MoveLine moveLine : moveLineList) {
List<AnalyticMoveLine> analyticMoveLineList = moveLine.getAnalyticMoveLineList();
if (analyticMoveLineList != null) {
for (AnalyticMoveLine analyticMoveLine : analyticMoveLineList) {
analyticMoveLine.setAccount(moveLine.getAccount());
analyticMoveLine.setAccountType(moveLine.getAccount().getAccountType());
}
}
}
}
return super.save(move);
} catch (Exception e) {
TraceBackService.traceExceptionFromSaveMethod(e);
throw new PersistenceException(e.getMessage(), e);
}
}
use of com.axelor.apps.account.db.MoveLine 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.MoveLine 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