use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.
the class CfonbExportService method exportCFONB.
/**
* Méthode permettant d'exporter les prélèvements de facture et d'échéance de paiement au format
* CFONB
*
* @param paymentScheduleExport
* @param paymentScheduleLineList
* @param invoiceList
* @param company
* @throws AxelorException
*/
public void exportCFONB(ZonedDateTime processingDateTime, LocalDate scheduleDate, List<PaymentScheduleLine> paymentScheduleLineList, List<Invoice> invoiceList, Company company, BankDetails bankDetails) throws AxelorException {
if ((paymentScheduleLineList == null || paymentScheduleLineList.isEmpty()) && (invoiceList == null || invoiceList.isEmpty())) {
return;
}
this.testCompanyExportCFONBField(company);
// paramètre obligatoire : au minimum
// un enregistrement emetteur par date de règlement (code 03)
// un enregistrement destinataire (code 06)
// un enregistrement total (code 08)
String senderCFONB = this.createSenderMonthlyExportCFONB(scheduleDate, bankDetails);
List<String> multiRecipientCFONB = new ArrayList<String>();
// Echéanciers
for (PaymentScheduleLine paymentScheduleLine : paymentScheduleLineList) {
paymentScheduleLine = paymentScheduleLineRepo.find(paymentScheduleLine.getId());
multiRecipientCFONB.add(this.createRecipientCFONB(paymentScheduleLine, false));
}
// Factures
for (Invoice invoice : invoiceList) {
invoice = invoiceRepo.find(invoice.getId());
multiRecipientCFONB.add(this.createRecipientCFONB(company, invoice));
}
BigDecimal amount = this.getTotalAmountPaymentSchedule(paymentScheduleLineList).add(this.getTotalAmountInvoice(invoiceList));
String totalCFONB = this.createPaymentScheduleTotalCFONB(company, amount);
// cfonbToolService.testLength(senderCFONB, totalCFONB, multiRecipientCFONB, company);
// List<String> cFONB = this.createCFONBExport(senderCFONB, multiRecipientCFONB, totalCFONB);
// Mise en majuscule des enregistrement
// cFONB = this.toUpperCase(cFONB);
// this.createCFONBFile(cFONB, processingDateTime,
// company.getAccountConfig().getPaymentScheduleExportFolderPathCFONB(), "prelevement");
}
use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.
the class CfonbExportService method exportInvoiceCFONB.
/**
* Méthode permettant d'exporter les prélèvements de facture au format CFONB
*
* @param paymentScheduleExport
* @param paymentScheduleLineList
* @param invoiceList
* @param company
* @throws AxelorException
*/
public void exportInvoiceCFONB(ZonedDateTime processingDateTime, LocalDate scheduleDate, List<Invoice> invoiceList, Company company, BankDetails bankDetails) throws AxelorException {
if ((invoiceList == null || invoiceList.isEmpty())) {
return;
}
this.testCompanyExportCFONBField(company);
// paramètre obligatoire : au minimum
// un enregistrement emetteur par date de règlement (code 03)
// un enregistrement destinataire (code 06)
// un enregistrement total (code 08)
String senderCFONB = this.createSenderMonthlyExportCFONB(scheduleDate, bankDetails);
List<String> multiRecipientCFONB = new ArrayList<String>();
for (Invoice invoice : invoiceList) {
invoice = invoiceRepo.find(invoice.getId());
multiRecipientCFONB.add(this.createRecipientCFONB(company, invoice));
}
BigDecimal amount = this.getTotalAmountInvoice(invoiceList);
String totalCFONB = this.createPaymentScheduleTotalCFONB(company, amount);
// cfonbToolService.testLength(senderCFONB, totalCFONB, multiRecipientCFONB, company);
// List<String> cFONB = this.createCFONBExport(senderCFONB, multiRecipientCFONB, totalCFONB);
// Mise en majuscule des enregistrement
// cFONB = this.toUpperCase(cFONB);
// this.createCFONBFile(cFONB, processingDateTime,
// company.getAccountConfig().getPaymentScheduleExportFolderPathCFONB(), "prelevement");
}
use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.
the class InvoiceController method fillPaymentModeAndCondition.
/**
* Function returning both the paymentMode and the paymentCondition
*
* @param request
* @param response
*/
public void fillPaymentModeAndCondition(ActionRequest request, ActionResponse response) {
Invoice invoice = request.getContext().asType(Invoice.class);
try {
if (invoice.getOperationTypeSelect() == null) {
return;
}
PaymentMode paymentMode = InvoiceToolService.getPaymentMode(invoice);
PaymentCondition paymentCondition = InvoiceToolService.getPaymentCondition(invoice);
response.setValue("paymentMode", paymentMode);
response.setValue("paymentCondition", paymentCondition);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.
the class InvoiceController method refusalToPay.
public void refusalToPay(ActionRequest request, ActionResponse response) {
Invoice invoice = request.getContext().asType(Invoice.class);
Beans.get(InvoiceService.class).refusalToPay(Beans.get(InvoiceRepository.class).find(invoice.getId()), invoice.getReasonOfRefusalToPay(), invoice.getReasonOfRefusalToPayStr());
response.setCanClose(true);
}
use of com.axelor.apps.account.db.Invoice in project axelor-open-suite by axelor.
the class InvoiceController method validateAndVentilate.
/**
* Called by the validate button, if the ventilation is skipped in invoice config
*
* @param request
* @param response
*/
public void validateAndVentilate(ActionRequest request, ActionResponse response) {
Invoice invoice = request.getContext().asType(Invoice.class);
invoice = Beans.get(InvoiceRepository.class).find(invoice.getId());
try {
// we have to inject TraceBackService to use non static methods
TraceBackService traceBackService = Beans.get(TraceBackService.class);
long tracebackCount = traceBackService.countMessageTraceBack(invoice);
Beans.get(InvoiceService.class).validateAndVentilate(invoice);
response.setReload(true);
if (traceBackService.countMessageTraceBack(invoice) > tracebackCount) {
traceBackService.findLastMessageTraceBack(invoice).ifPresent(traceback -> response.setNotify(String.format(I18n.get(com.axelor.apps.message.exception.IExceptionMessage.SEND_EMAIL_EXCEPTION), traceback.getMessage())));
}
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations