Search in sources :

Example 1 with MoveService

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));
    }
}
Also used : MoveService(com.axelor.apps.account.service.move.MoveService) ExtractContextMoveService(com.axelor.apps.account.service.extract.ExtractContextMoveService)

Example 2 with MoveService

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);
}
Also used : MoveRepository(com.axelor.apps.account.db.repo.MoveRepository) Account(com.axelor.apps.account.db.Account) Company(com.axelor.apps.base.db.Company) Invoice(com.axelor.apps.account.db.Invoice) MoveService(com.axelor.apps.account.service.move.MoveService) Journal(com.axelor.apps.account.db.Journal) LocalDate(java.time.LocalDate) AccountConfig(com.axelor.apps.account.db.AccountConfig) AppBaseService(com.axelor.apps.base.service.app.AppBaseService) Move(com.axelor.apps.account.db.Move) AccountConfigService(com.axelor.apps.account.service.config.AccountConfigService) MoveLine(com.axelor.apps.account.db.MoveLine) Transactional(com.google.inject.persist.Transactional)

Aggregations

MoveService (com.axelor.apps.account.service.move.MoveService)2 Account (com.axelor.apps.account.db.Account)1 AccountConfig (com.axelor.apps.account.db.AccountConfig)1 Invoice (com.axelor.apps.account.db.Invoice)1 Journal (com.axelor.apps.account.db.Journal)1 Move (com.axelor.apps.account.db.Move)1 MoveLine (com.axelor.apps.account.db.MoveLine)1 MoveRepository (com.axelor.apps.account.db.repo.MoveRepository)1 AccountConfigService (com.axelor.apps.account.service.config.AccountConfigService)1 ExtractContextMoveService (com.axelor.apps.account.service.extract.ExtractContextMoveService)1 Company (com.axelor.apps.base.db.Company)1 AppBaseService (com.axelor.apps.base.service.app.AppBaseService)1 Transactional (com.google.inject.persist.Transactional)1 LocalDate (java.time.LocalDate)1