Search in sources :

Example 41 with BankDetails

use of com.axelor.apps.base.db.BankDetails 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 42 with BankDetails

use of com.axelor.apps.base.db.BankDetails in project axelor-open-suite by axelor.

the class PaymentScheduleController method fillCompanyBankDetails.

/**
 * Called on partner, company or payment mode change. Fill the bank details with a default value.
 *
 * @param request
 * @param response
 * @throws AxelorException
 */
public void fillCompanyBankDetails(ActionRequest request, ActionResponse response) throws AxelorException {
    PaymentSchedule paymentSchedule = request.getContext().asType(PaymentSchedule.class);
    PaymentMode paymentMode = paymentSchedule.getPaymentMode();
    Company company = paymentSchedule.getCompany();
    Partner partner = paymentSchedule.getPartner();
    if (company == null) {
        return;
    }
    if (partner != null) {
        partner = Beans.get(PartnerRepository.class).find(partner.getId());
    }
    BankDetails defaultBankDetails = Beans.get(BankDetailsService.class).getDefaultCompanyBankDetails(company, paymentMode, partner, null);
    response.setValue("companyBankDetails", defaultBankDetails);
}
Also used : BankDetailsService(com.axelor.apps.base.service.BankDetailsService) Company(com.axelor.apps.base.db.Company) PaymentSchedule(com.axelor.apps.account.db.PaymentSchedule) BankDetails(com.axelor.apps.base.db.BankDetails) Partner(com.axelor.apps.base.db.Partner) PaymentMode(com.axelor.apps.account.db.PaymentMode)

Example 43 with BankDetails

use of com.axelor.apps.base.db.BankDetails in project axelor-open-suite by axelor.

the class PaymentScheduleController method fillPartnerBankDetails.

/**
 * Called on partner change. Fill the bank details with a default value.
 *
 * @param request
 * @param response
 */
public void fillPartnerBankDetails(ActionRequest request, ActionResponse response) {
    PaymentSchedule paymentSchedule = request.getContext().asType(PaymentSchedule.class);
    Partner partner = paymentSchedule.getPartner();
    if (partner != null) {
        partner = Beans.get(PartnerRepository.class).find(partner.getId());
    }
    BankDetails defaultBankDetails = Beans.get(PartnerService.class).getDefaultBankDetails(partner);
    response.setValue("bankDetails", defaultBankDetails);
}
Also used : PaymentSchedule(com.axelor.apps.account.db.PaymentSchedule) BankDetails(com.axelor.apps.base.db.BankDetails) PartnerService(com.axelor.apps.base.service.PartnerService) Partner(com.axelor.apps.base.db.Partner)

Example 44 with BankDetails

use of com.axelor.apps.base.db.BankDetails in project axelor-open-suite by axelor.

the class PurchaseOrderController method fillCompanyBankDetails.

/**
 * Called on partner, company or payment change. Fill the bank details with a default value.
 *
 * @param request
 * @param response
 */
public void fillCompanyBankDetails(ActionRequest request, ActionResponse response) {
    try {
        PurchaseOrder purchaseOrder = request.getContext().asType(PurchaseOrder.class);
        PaymentMode paymentMode = (PaymentMode) request.getContext().get("paymentMode");
        Company company = purchaseOrder.getCompany();
        Partner partner = purchaseOrder.getSupplierPartner();
        if (company == null) {
            return;
        }
        if (partner != null) {
            partner = Beans.get(PartnerRepository.class).find(partner.getId());
        }
        BankDetails defaultBankDetails = Beans.get(BankDetailsService.class).getDefaultCompanyBankDetails(company, paymentMode, partner, null);
        response.setValue("companyBankDetails", defaultBankDetails);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : BankDetailsService(com.axelor.apps.base.service.BankDetailsService) Company(com.axelor.apps.base.db.Company) BankDetails(com.axelor.apps.base.db.BankDetails) PurchaseOrder(com.axelor.apps.purchase.db.PurchaseOrder) Partner(com.axelor.apps.base.db.Partner) AxelorException(com.axelor.exception.AxelorException) PaymentMode(com.axelor.apps.account.db.PaymentMode)

Example 45 with BankDetails

use of com.axelor.apps.base.db.BankDetails in project axelor-open-suite by axelor.

the class BankOrderFileAFB160Service method createDetailRecord.

/**
 * Method to create a recipient record for national transfer AFB160
 *
 * @param bankOrderLine
 * @return
 * @throws AxelorException
 */
protected String createDetailRecord(BankOrderLine bankOrderLine) throws AxelorException {
    try {
        BankDetails receiverBankDetails = bankOrderLine.getReceiverBankDetails();
        // Zone A : Code enregistrement
        String detailRecord = cfonbToolService.createZone("A", "06", cfonbToolService.STATUS_MANDATORY, cfonbToolService.FORMAT_NUMERIC, 2);
        // Zone B1 : Code opération
        detailRecord += cfonbToolService.createZone("B1", getB1Area(), cfonbToolService.STATUS_MANDATORY, cfonbToolService.FORMAT_ALPHA_NUMERIC, 2);
        // Zone B2 : Zone réservée
        detailRecord += cfonbToolService.createZone("B2", "", cfonbToolService.STATUS_NOT_USED, cfonbToolService.FORMAT_ALPHA_NUMERIC, 8);
        // Zone B3 : Numéro d'émetteur ou d'identification pour le virement particulier code 22
        // (Virement APL)
        detailRecord += cfonbToolService.createZone("B3", getB3Area(), cfonbToolService.STATUS_DEPENDENT, cfonbToolService.FORMAT_ALPHA_NUMERIC, 6);
        // Zone C1 : Référence
        detailRecord += cfonbToolService.createZone(I18n.get("C1 - Sequence"), bankOrderLine.getSequence(), cfonbToolService.STATUS_OPTIONAL, cfonbToolService.FORMAT_ALPHA_NUMERIC, 12);
        // Zone C2 : Nom/Raison sociale du bénéficiaire
        detailRecord += cfonbToolService.createZone(I18n.get("C2 - Receiver company name"), bankOrderLine.getReceiverCompany().getName(), cfonbToolService.STATUS_MANDATORY, cfonbToolService.FORMAT_ALPHA_NUMERIC, 24);
        // Zone D1 : Domiciliation
        detailRecord += cfonbToolService.createZone(I18n.get("D1 - Bank address"), getDetailD1Area(bankOrderLine), cfonbToolService.STATUS_DEPENDENT, cfonbToolService.FORMAT_ALPHA_NUMERIC, 24);
        // Zone D2 : Déclaration à la balance des paiements
        detailRecord += cfonbToolService.createZone("D2", getDetailD2Area(bankOrderLine), cfonbToolService.STATUS_DEPENDENT, cfonbToolService.FORMAT_ALPHA_NUMERIC, 8);
        // Zone D3 : Code guichet de la banque qui tient le compte du bénéficiaire
        detailRecord += cfonbToolService.createZone(I18n.get("D3 - Sort code"), receiverBankDetails.getSortCode(), cfonbToolService.STATUS_MANDATORY, cfonbToolService.FORMAT_NUMERIC, 5);
        // Zone D4 : Numéro de compte du bénéficiaire
        detailRecord += cfonbToolService.createZone(I18n.get("D4 - Account number"), receiverBankDetails.getAccountNbr(), cfonbToolService.STATUS_MANDATORY, cfonbToolService.FORMAT_ALPHA_NUMERIC, 11);
        // Zone E : Montant du virement
        detailRecord += cfonbToolService.createZone(I18n.get("E - Bank order amount"), getDetailEAreaAmount(bankOrderLine), cfonbToolService.STATUS_MANDATORY, cfonbToolService.FORMAT_NUMERIC, 16);
        // Zone F :  Libellé
        detailRecord += cfonbToolService.createZone(I18n.get("F - Receiver label"), getDetailFArea(bankOrderLine), cfonbToolService.STATUS_MANDATORY, cfonbToolService.FORMAT_ALPHA_NUMERIC, 31);
        // Zone G1 : Code établissement de la banque qui tient le compte du bénéficiaire
        detailRecord += cfonbToolService.createZone("G1", receiverBankDetails.getBankCode(), cfonbToolService.STATUS_MANDATORY, cfonbToolService.FORMAT_NUMERIC, 5);
        // Zone G2 : Zone réservée
        detailRecord += cfonbToolService.createZone("G2", "", cfonbToolService.STATUS_NOT_USED, cfonbToolService.FORMAT_ALPHA_NUMERIC, 6);
        cfonbToolService.toUpperCase(detailRecord);
        cfonbToolService.testLength(detailRecord, NB_CHAR_PER_LINE);
        return detailRecord;
    } catch (Exception e) {
        throw new AxelorException(e, bankOrderLine, TraceBackRepository.CATEGORY_MISSING_FIELD, I18n.get(IExceptionMessage.BANK_ORDER_WRONG_MAIN_DETAIL_RECORD) + ": " + e.getMessage(), bankOrderLine.getSequence());
    }
}
Also used : AxelorException(com.axelor.exception.AxelorException) BankDetails(com.axelor.apps.base.db.BankDetails) DatatypeConfigurationException(javax.xml.datatype.DatatypeConfigurationException) IOException(java.io.IOException) JAXBException(javax.xml.bind.JAXBException) AxelorException(com.axelor.exception.AxelorException)

Aggregations

BankDetails (com.axelor.apps.base.db.BankDetails)63 Partner (com.axelor.apps.base.db.Partner)26 AxelorException (com.axelor.exception.AxelorException)26 PaymentMode (com.axelor.apps.account.db.PaymentMode)22 Company (com.axelor.apps.base.db.Company)22 BigDecimal (java.math.BigDecimal)14 LocalDate (java.time.LocalDate)13 Transactional (com.google.inject.persist.Transactional)12 ArrayList (java.util.ArrayList)11 Invoice (com.axelor.apps.account.db.Invoice)10 Journal (com.axelor.apps.account.db.Journal)9 BankDetailsService (com.axelor.apps.base.service.BankDetailsService)8 PaymentModeService (com.axelor.apps.account.service.payment.PaymentModeService)7 BankOrderLine (com.axelor.apps.bankpayment.db.BankOrderLine)7 Currency (com.axelor.apps.base.db.Currency)7 Account (com.axelor.apps.account.db.Account)6 AccountConfig (com.axelor.apps.account.db.AccountConfig)6 InvoicePayment (com.axelor.apps.account.db.InvoicePayment)6 Move (com.axelor.apps.account.db.Move)6 MoveLine (com.axelor.apps.account.db.MoveLine)6