use of com.axelor.apps.account.service.move.MoveService in project axelor-open-suite by axelor.
the class MoveController method removeOneMove.
protected void removeOneMove(Move move, ActionResponse response) throws Exception {
MoveService moveService = Beans.get(MoveService.class);
if (move.getStatusSelect().equals(MoveRepository.STATUS_NEW)) {
moveService.getMoveRemoveService().deleteMove(move);
response.setFlash(I18n.get(IExceptionMessage.MOVE_REMOVED_OK));
} else if (move.getStatusSelect().equals(MoveRepository.STATUS_ACCOUNTED)) {
moveService.getMoveRemoveService().archiveDaybookMove(move);
response.setFlash(I18n.get(IExceptionMessage.MOVE_ARCHIVE_OK));
} else if (move.getStatusSelect().equals(MoveRepository.STATUS_CANCELED)) {
moveService.getMoveRemoveService().archiveMove(move);
response.setFlash(I18n.get(IExceptionMessage.MOVE_ARCHIVE_OK));
}
}
use of com.axelor.apps.account.service.move.MoveService in project axelor-open-suite by axelor.
the class SubrogationReleaseServiceImpl method enterReleaseInTheAccounts.
@Override
@Transactional(rollbackOn = { Exception.class })
public void enterReleaseInTheAccounts(SubrogationRelease subrogationRelease) throws AxelorException {
MoveService moveService = Beans.get(MoveService.class);
MoveRepository moveRepository = Beans.get(MoveRepository.class);
AccountConfigService accountConfigService = Beans.get(AccountConfigService.class);
AppBaseService appBaseService = Beans.get(AppBaseService.class);
Company company = subrogationRelease.getCompany();
AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
Journal journal = accountConfigService.getAutoMiscOpeJournal(accountConfig);
Account factorCreditAccount = accountConfigService.getFactorCreditAccount(accountConfig);
Account factorDebitAccount = accountConfigService.getFactorDebitAccount(accountConfig);
if (subrogationRelease.getAccountingDate() == null) {
subrogationRelease.setAccountingDate(appBaseService.getTodayDate(company));
}
this.checkIfAnOtherSubrogationAlreadyExist(subrogationRelease);
for (Invoice invoice : subrogationRelease.getInvoiceSet()) {
boolean isRefund = false;
if (invoice.getOperationTypeSelect() == InvoiceRepository.OPERATION_TYPE_CLIENT_REFUND) {
isRefund = true;
}
LocalDate date = subrogationRelease.getAccountingDate();
Move move = moveService.getMoveCreateService().createMove(journal, company, company.getCurrency(), invoice.getPartner(), date, null, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, MoveRepository.FUNCTIONAL_ORIGIN_PAYMENT);
MoveLine creditMoveLine, debitMoveLine;
debitMoveLine = moveService.getMoveLineService().createMoveLine(move, invoice.getPartner(), factorDebitAccount, invoice.getCompanyInTaxTotalRemaining(), !isRefund, date, null, 1, subrogationRelease.getSequenceNumber(), invoice.getInvoiceId());
creditMoveLine = moveService.getMoveLineService().createMoveLine(move, invoice.getPartner(), factorCreditAccount, invoice.getCompanyInTaxTotalRemaining(), isRefund, date, null, 2, subrogationRelease.getSequenceNumber(), invoice.getInvoiceId());
move.addMoveLineListItem(debitMoveLine);
move.addMoveLineListItem(creditMoveLine);
move = moveRepository.save(move);
moveService.getMoveValidateService().validate(move);
invoice.setSubrogationRelease(subrogationRelease);
invoice.setSubrogationReleaseMove(move);
subrogationRelease.addMoveListItem(move);
}
subrogationRelease.setStatusSelect(SubrogationReleaseRepository.STATUS_ACCOUNTED);
}
Aggregations