Search in sources :

Example 71 with Move

use of com.axelor.apps.account.db.Move in project axelor-open-suite by axelor.

the class AccountingCutOffServiceImpl method generateCutOffMove.

public Move generateCutOffMove(StockMove stockMove, List<StockMoveLine> sortedStockMoveLine, LocalDate moveDate, LocalDate originDate, boolean isPurchase, boolean recoveredTax, boolean ati, String moveDescription, boolean includeNotStockManagedProduct, boolean isReverse) throws AxelorException {
    if (moveDate == null || stockMove.getOriginTypeSelect() == null || stockMove.getOriginId() == null) {
        return null;
    }
    Company company = stockMove.getCompany();
    AccountConfig accountConfig = accountConfigSupplychainService.getAccountConfig(company);
    Partner partner = stockMove.getPartner();
    Account partnerAccount = null;
    Currency currency = null;
    if (StockMoveRepository.ORIGIN_SALE_ORDER.equals(stockMove.getOriginTypeSelect()) && stockMove.getOriginId() != null) {
        SaleOrder saleOrder = saleOrderRepository.find(stockMove.getOriginId());
        currency = saleOrder.getCurrency();
        if (partner == null) {
            partner = saleOrder.getClientPartner();
        }
        partnerAccount = accountConfigSupplychainService.getForecastedInvCustAccount(accountConfig);
    }
    if (StockMoveRepository.ORIGIN_PURCHASE_ORDER.equals(stockMove.getOriginTypeSelect()) && stockMove.getOriginId() != null) {
        PurchaseOrder purchaseOrder = purchaseOrderRepository.find(stockMove.getOriginId());
        currency = purchaseOrder.getCurrency();
        if (partner == null) {
            partner = purchaseOrder.getSupplierPartner();
        }
        partnerAccount = accountConfigSupplychainService.getForecastedInvSuppAccount(accountConfig);
    }
    String origin = stockMove.getStockMoveSeq();
    Move move = moveCreateService.createMove(accountConfigSupplychainService.getAutoMiscOpeJournal(accountConfig), company, currency, partner, moveDate, null, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, MoveRepository.FUNCTIONAL_ORIGIN_CUT_OFF);
    counter = 0;
    this.generateMoveLines(move, stockMove.getStockMoveLineList(), origin, isPurchase, recoveredTax, ati, moveDescription, isReverse, originDate, includeNotStockManagedProduct);
    this.generatePartnerMoveLine(move, origin, partnerAccount, moveDescription, originDate);
    if (move.getMoveLineList() != null && !move.getMoveLineList().isEmpty()) {
        move.setStockMove(stockMove);
        moveValidateService.validate(move);
    } else {
        moveRepository.remove(move);
        return null;
    }
    return move;
}
Also used : Account(com.axelor.apps.account.db.Account) Company(com.axelor.apps.base.db.Company) Move(com.axelor.apps.account.db.Move) StockMove(com.axelor.apps.stock.db.StockMove) Currency(com.axelor.apps.base.db.Currency) PurchaseOrder(com.axelor.apps.purchase.db.PurchaseOrder) SaleOrder(com.axelor.apps.sale.db.SaleOrder) Partner(com.axelor.apps.base.db.Partner) AccountConfig(com.axelor.apps.account.db.AccountConfig)

Example 72 with Move

use of com.axelor.apps.account.db.Move in project axelor-open-suite by axelor.

the class AccountingCutOffServiceImpl method generateCutOffMoves.

@Transactional(rollbackOn = { Exception.class })
public List<Move> generateCutOffMoves(StockMove stockMove, LocalDate moveDate, LocalDate reverseMoveDate, int accountingCutOffTypeSelect, boolean recoveredTax, boolean ati, String moveDescription, boolean includeNotStockManagedProduct) throws AxelorException {
    List<Move> moveList = new ArrayList<>();
    List<StockMoveLine> stockMoveLineSortedList = stockMove.getStockMoveLineList();
    Collections.sort(stockMoveLineSortedList, Comparator.comparing(StockMoveLine::getSequence));
    Move move = generateCutOffMove(stockMove, stockMoveLineSortedList, moveDate, moveDate, accountingCutOffTypeSelect == SupplychainBatchRepository.ACCOUNTING_CUT_OFF_TYPE_SUPPLIER_INVOICES, recoveredTax, ati, moveDescription, includeNotStockManagedProduct, false);
    if (move == null) {
        return null;
    }
    moveList.add(move);
    Move reverseMove = generateCutOffMove(stockMove, stockMoveLineSortedList, reverseMoveDate, moveDate, accountingCutOffTypeSelect == SupplychainBatchRepository.ACCOUNTING_CUT_OFF_TYPE_SUPPLIER_INVOICES, recoveredTax, ati, moveDescription, includeNotStockManagedProduct, true);
    if (reverseMove == null) {
        return null;
    }
    moveList.add(reverseMove);
    reconcile(move, reverseMove);
    return moveList;
}
Also used : Move(com.axelor.apps.account.db.Move) StockMove(com.axelor.apps.stock.db.StockMove) ArrayList(java.util.ArrayList) StockMoveLine(com.axelor.apps.stock.db.StockMoveLine) Transactional(com.google.inject.persist.Transactional)

Example 73 with Move

use of com.axelor.apps.account.db.Move in project axelor-open-suite by axelor.

the class AdvancePaymentServiceSupplychainImpl method createMoveForAdvancePayment.

@Transactional(rollbackOn = { Exception.class })
public Move createMoveForAdvancePayment(AdvancePayment advancePayment) throws AxelorException {
    SaleOrder saleOrder = advancePayment.getSaleOrder();
    Company company = saleOrder.getCompany();
    PaymentMode paymentMode = advancePayment.getPaymentMode();
    Partner clientPartner = saleOrder.getClientPartner();
    LocalDate advancePaymentDate = advancePayment.getAdvancePaymentDate();
    BankDetails bankDetails = saleOrder.getCompanyBankDetails();
    String ref = saleOrder.getSaleOrderSeq();
    AccountConfig accountConfig = accountConfigService.getAccountConfig(company);
    Journal journal = paymentModeService.getPaymentModeJournal(paymentMode, company, bankDetails);
    Move move = moveService.getMoveCreateService().createMove(journal, company, advancePayment.getCurrency(), clientPartner, advancePaymentDate, paymentMode, MoveRepository.TECHNICAL_ORIGIN_AUTOMATIC, MoveRepository.FUNCTIONAL_ORIGIN_PAYMENT);
    BigDecimal amountConverted = currencyService.getAmountCurrencyConvertedAtDate(advancePayment.getCurrency(), saleOrder.getCurrency(), advancePayment.getAmount(), advancePaymentDate);
    move.addMoveLineListItem(moveLineService.createMoveLine(move, clientPartner, paymentModeService.getPaymentModeAccount(paymentMode, company, bankDetails), amountConverted, true, advancePaymentDate, null, 1, ref, null));
    move.addMoveLineListItem(moveLineService.createMoveLine(move, clientPartner, accountConfigService.getAdvancePaymentAccount(accountConfig), amountConverted, false, advancePaymentDate, null, 2, ref, null));
    moveService.getMoveValidateService().validate(move);
    advancePayment.setMove(move);
    advancePaymentRepository.save(advancePayment);
    return move;
}
Also used : Company(com.axelor.apps.base.db.Company) Move(com.axelor.apps.account.db.Move) BankDetails(com.axelor.apps.base.db.BankDetails) Journal(com.axelor.apps.account.db.Journal) SaleOrder(com.axelor.apps.sale.db.SaleOrder) Partner(com.axelor.apps.base.db.Partner) LocalDate(java.time.LocalDate) BigDecimal(java.math.BigDecimal) PaymentMode(com.axelor.apps.account.db.PaymentMode) AccountConfig(com.axelor.apps.account.db.AccountConfig) Transactional(com.google.inject.persist.Transactional)

Example 74 with Move

use of com.axelor.apps.account.db.Move in project axelor-open-suite by axelor.

the class MoveLineController method filterPartner.

public void filterPartner(ActionRequest request, ActionResponse response) {
    Move move = request.getContext().getParent().asType(Move.class);
    if (move != null) {
        String domain = Beans.get(MoveService.class).filterPartner(move);
        response.setAttr("partner", "domain", domain);
    }
}
Also used : MoveService(com.axelor.apps.account.service.move.MoveService) Move(com.axelor.apps.account.db.Move)

Example 75 with Move

use of com.axelor.apps.account.db.Move in project axelor-open-suite by axelor.

the class MoveLineController method balanceCreditDebit.

public void balanceCreditDebit(ActionRequest request, ActionResponse response) {
    MoveLine moveLine = request.getContext().asType(MoveLine.class);
    Move move = request.getContext().getParent().asType(Move.class);
    try {
        moveLine = Beans.get(MoveLineService.class).balanceCreditDebit(moveLine, move);
        response.setValues(moveLine);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : Move(com.axelor.apps.account.db.Move) MoveLine(com.axelor.apps.account.db.MoveLine) AxelorException(com.axelor.exception.AxelorException)

Aggregations

Move (com.axelor.apps.account.db.Move)101 MoveLine (com.axelor.apps.account.db.MoveLine)51 Transactional (com.google.inject.persist.Transactional)37 Company (com.axelor.apps.base.db.Company)36 AxelorException (com.axelor.exception.AxelorException)34 BigDecimal (java.math.BigDecimal)33 Partner (com.axelor.apps.base.db.Partner)31 LocalDate (java.time.LocalDate)28 Journal (com.axelor.apps.account.db.Journal)25 Account (com.axelor.apps.account.db.Account)22 ArrayList (java.util.ArrayList)22 AccountConfig (com.axelor.apps.account.db.AccountConfig)18 Reconcile (com.axelor.apps.account.db.Reconcile)14 AnalyticMoveLine (com.axelor.apps.account.db.AnalyticMoveLine)11 Invoice (com.axelor.apps.account.db.Invoice)11 List (java.util.List)7 BankDetails (com.axelor.apps.base.db.BankDetails)6 InvoicePayment (com.axelor.apps.account.db.InvoicePayment)5 MoveRepository (com.axelor.apps.account.db.repo.MoveRepository)5 MoveService (com.axelor.apps.account.service.move.MoveService)5