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;
}
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);
}
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);
}
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);
}
}
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());
}
}
Aggregations