use of com.axelor.apps.account.db.PaymentScheduleLine in project axelor-open-suite by axelor.
the class IrrecoverableService method passInIrrecoverable.
/**
* Procédure permettant de
*
* @param irrecoverable
* @throws AxelorException
*/
public int passInIrrecoverable(Irrecoverable irrecoverable) throws AxelorException {
irrecoverable.setMoveSet(new HashSet<Move>());
EntityTransaction transaction = JPA.em().getTransaction();
int anomaly = 0;
this.testCompanyField(irrecoverable.getCompany());
int i = 0;
if (irrecoverable.getInvoiceSet() != null && irrecoverable.getInvoiceSet().size() != 0) {
for (Invoice invoice : irrecoverable.getInvoiceSet()) {
i++;
if (!transaction.isActive()) {
transaction.begin();
}
try {
log.debug("Facture : {}", invoice.getInvoiceId());
this.createIrrecoverableInvoiceLineMove(irrecoverable, invoice);
irrecoverableRepo.save(irrecoverable);
if (i % 50 == 0) {
JPA.flush();
JPA.clear();
}
} catch (AxelorException e) {
anomaly++;
TraceBackService.trace(new AxelorException(e, e.getCategory(), I18n.get("Invoice") + " %s", invoice.getInvoiceId()), ExceptionOriginRepository.IRRECOVERABLE, irrecoverable.getId());
log.error("Bug(Anomalie) généré(e) pour la facture : {}", invoice.getInvoiceId());
} catch (Exception e) {
anomaly++;
TraceBackService.trace(new Exception(String.format(I18n.get("Invoice") + " %s", invoice.getInvoiceId()), e), ExceptionOriginRepository.IRRECOVERABLE, irrecoverable.getId());
log.error("Bug(Anomalie) généré(e) pour la facture : {}", invoice.getInvoiceId());
} finally {
if (!transaction.isActive()) {
transaction.begin();
}
}
}
}
if (irrecoverable.getPaymentScheduleLineSet() != null && irrecoverable.getPaymentScheduleLineSet().size() != 0) {
for (PaymentScheduleLine paymentScheduleLine : irrecoverable.getPaymentScheduleLineSet()) {
i++;
if (!transaction.isActive()) {
transaction.begin();
}
try {
log.debug("Ligne d'échéancier : {}", paymentScheduleLine.getName());
this.createMoveForPaymentScheduleLineReject(irrecoverable, paymentScheduleLine);
irrecoverableRepo.save(irrecoverable);
if (i % 50 == 0) {
JPA.flush();
JPA.clear();
}
} catch (AxelorException e) {
anomaly++;
TraceBackService.trace(new AxelorException(e, e.getCategory(), I18n.get(IExceptionMessage.IRRECOVERABLE_1), paymentScheduleLine.getName()), ExceptionOriginRepository.IRRECOVERABLE, irrecoverable.getId());
log.error("Bug(Anomalie) généré(e) pour la ligne d'échéancier : {}", paymentScheduleLine.getName());
} catch (Exception e) {
anomaly++;
TraceBackService.trace(new Exception(String.format(I18n.get(IExceptionMessage.IRRECOVERABLE_1), paymentScheduleLine.getName()), e), ExceptionOriginRepository.IRRECOVERABLE, irrecoverable.getId());
log.error("Bug(Anomalie) généré(e) pour la ligne d'échéancier : {}", paymentScheduleLine.getName());
} finally {
if (!transaction.isActive()) {
transaction.begin();
}
}
}
}
if (!transaction.isActive()) {
transaction.begin();
}
irrecoverable.setStatusSelect(IrrecoverableRepository.STATUS_VALIDATED);
irrecoverableRepo.save(irrecoverable);
transaction.commit();
return anomaly;
}
use of com.axelor.apps.account.db.PaymentScheduleLine in project axelor-open-suite by axelor.
the class IrrecoverableService method createIrrecoverableReport.
/**
* Procédure permettant de passer en irrécouvrables les factures et échéances rejetées récupéré
* sur l'objet Irrécouvrable
*
* @param irrecoverable Un objet Irrécouvrable
*/
@Transactional
public void createIrrecoverableReport(Irrecoverable irrecoverable) {
Set<Invoice> invoiceSet = irrecoverable.getInvoiceSet();
Set<PaymentScheduleLine> paymentScheduleLineSet = irrecoverable.getPaymentScheduleLineSet();
irrecoverable.setMoveSet(new HashSet<Move>());
List<Partner> payerPartnerList = this.getPayerPartnerList(invoiceSet);
EntityTransaction transaction = JPA.em().getTransaction();
int i = 0;
if (payerPartnerList != null && payerPartnerList.size() != 0) {
for (Partner payerPartner : payerPartnerList) {
if (!transaction.isActive()) {
transaction.begin();
}
i++;
try {
log.debug("Tiers : {}", payerPartner.getName());
this.createIrrecoverableCustomerLine(irrecoverable, payerPartner, this.getInvoiceList(payerPartner, invoiceSet), this.getPaymentScheduleLineList(payerPartner, paymentScheduleLineSet));
irrecoverableRepo.save(irrecoverable);
transaction.commit();
if (i % 50 == 0) {
JPA.flush();
JPA.clear();
}
} catch (Exception e) {
TraceBackService.trace(e);
log.error("Bug(Anomalie) généré(e) pour le tiers : {}", payerPartner.getName());
} finally {
if (!transaction.isActive()) {
transaction.begin();
}
}
}
}
}
use of com.axelor.apps.account.db.PaymentScheduleLine in project axelor-open-suite by axelor.
the class IrrecoverableService method getPaymentScheduleLineList.
/**
* Fonction permettant de récupérer les échéances rejetées à passer en irrécouvrable d'un tiers
*
* @param payerPartner Un tiers payeur
* @param allPaymentScheduleLineList La liste des échéances rejetées à passer en irrécouvrable de
* la société
* @return
*/
public List<PaymentScheduleLine> getPaymentScheduleLineList(Partner payerPartner, Set<PaymentScheduleLine> allPaymentScheduleLineList) {
List<PaymentScheduleLine> paymentScheduleLineList = new ArrayList<PaymentScheduleLine>();
for (PaymentScheduleLine paymentScheduleLine : allPaymentScheduleLineList) {
if (paymentScheduleLine.getPaymentSchedule().getPartner().equals(payerPartner)) {
paymentScheduleLineList.add(paymentScheduleLine);
}
}
log.debug("Nombre d'échéances à passer en irrécouvrable pour le tiers : {}", paymentScheduleLineList.size());
return paymentScheduleLineList;
}
use of com.axelor.apps.account.db.PaymentScheduleLine in project axelor-open-suite by axelor.
the class IrrecoverableService method notPassInIrrecoverable.
/**
* Procédure permettant d'annuler le passage en irrécouvrable d'une échéancier de lissage de
* paiement La procédure annulera aussi le passage en irrécouvrable des lignes d'écriture de rejet
* d'échéance en irrécouvrable, ainsi que des factures pas complètement payée selectionnées sur
* l'échéancier
*
* @param paymentSchedule Un échéancier de paiement
* @throws AxelorException
*/
@Transactional(rollbackOn = { Exception.class })
public void notPassInIrrecoverable(PaymentSchedule paymentSchedule) throws AxelorException {
paymentSchedule.setIrrecoverableStatusSelect(PaymentScheduleRepository.IRRECOVERABLE_STATUS_NOT_IRRECOUVRABLE);
List<MoveLine> paymentScheduleLineRejectMoveLineList = new ArrayList<MoveLine>();
for (PaymentScheduleLine paymentScheduleLine : paymentSchedule.getPaymentScheduleLineList()) {
if (paymentScheduleLine.getRejectMoveLine() != null && paymentScheduleLine.getRejectMoveLine().getAmountRemaining().compareTo(BigDecimal.ZERO) > 0) {
paymentScheduleLineRejectMoveLineList.add(paymentScheduleLine.getRejectMoveLine());
}
}
for (MoveLine moveLine : paymentScheduleLineRejectMoveLineList) {
this.notPassInIrrecoverable(moveLine, false);
}
for (Invoice invoice : paymentSchedule.getInvoiceSet()) {
this.notPassInIrrecoverable(invoice);
}
paymentScheduleRepo.save(paymentSchedule);
}
use of com.axelor.apps.account.db.PaymentScheduleLine 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");
}
Aggregations