use of org.compiere.util.PaymentExport in project adempiere by adempiere.
the class VPayPrint method cmd_export.
// loadPaymentRuleInfo
/**************************************************************************
* Export payments to file
*/
private void cmd_export() {
ValueNamePair pp = (ValueNamePair) fPaymentRule.getSelectedItem();
if (pp == null)
return;
String paymentRule = pp.getValue();
log.info(paymentRule);
if (!getChecks(paymentRule))
return;
// Get File Info
JFileChooser fc = new JFileChooser();
fc.setDialogTitle(Msg.getMsg(Env.getCtx(), "Export"));
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
fc.setMultiSelectionEnabled(false);
fc.setSelectedFile(new java.io.File("paymentExport.txt"));
if (fc.showSaveDialog(panel) != JFileChooser.APPROVE_OPTION)
return;
// Create File
int no = 0;
StringBuffer error = new StringBuffer("");
if (paymentExportClass == null || paymentExportClass.trim().length() == 0) {
paymentExportClass = "org.compiere.util.GenericPaymentExport";
}
try {
Class<?> clazz = Class.forName(paymentExportClass);
if (clazz.isInstance(PaymentExportList.class)) {
PaymentExportList custom = (PaymentExportList) clazz.newInstance();
no = custom.exportToFile(paySelectionChecks, fc.getSelectedFile(), error);
} else if (clazz.isInstance(PaymentExport.class)) {
PaymentExport custom = (PaymentExport) clazz.newInstance();
no = custom.exportToFile(paySelectionChecks.toArray(new MPaySelectionCheck[paySelectionChecks.size()]), fc.getSelectedFile(), error);
}
} catch (ClassNotFoundException e) {
no = -1;
error.append("No custom PaymentExport class " + paymentExportClass + " - " + e.toString());
log.log(Level.SEVERE, error.toString(), e);
} catch (Exception e) {
no = -1;
error.append("Error in " + paymentExportClass + " check log, " + e.toString());
log.log(Level.SEVERE, error.toString(), e);
}
if (no >= 0) {
ADialog.info(windowNo, panel, "Saved", fc.getSelectedFile().getAbsolutePath() + "\n" + Msg.getMsg(Env.getCtx(), "NoOfLines") + "=" + no);
if (ADialog.ask(windowNo, panel, "VPayPrintSuccess?")) {
// int lastDocumentNo =
MPaySelectionCheck.confirmPrint(paySelectionChecks, paymentBatch);
// document No not updated
}
} else {
ADialog.error(windowNo, panel, "Error", error.toString());
}
dispose();
}
use of org.compiere.util.PaymentExport in project adempiere by adempiere.
the class WPayPrint method cmd_export.
// loadPaymentRuleInfo
/**************************************************************************
* Export payments to file
*/
private void cmd_export() {
if (fPaymentRule.getSelectedItem() == null)
return;
String paymentRule = fPaymentRule.getSelectedItem().toValueNamePair().getValue();
log.info(paymentRule);
if (!getChecks(paymentRule))
return;
try {
// Get File Info
File tempFile = File.createTempFile("paymentExport", ".txt");
// Create File
int no = 0;
StringBuffer error = new StringBuffer("");
if (paymentExportClass == null || paymentExportClass.trim().length() == 0) {
paymentExportClass = "org.compiere.util.GenericPaymentExport";
}
// Get Payment Export Class
try {
Class<?> clazz = Class.forName(paymentExportClass);
if (clazz.isInstance(PaymentExportList.class)) {
PaymentExportList custom = (PaymentExportList) clazz.newInstance();
no = custom.exportToFile(paySelectionChecks, tempFile, error);
} else if (clazz.isInstance(PaymentExport.class)) {
PaymentExport custom = (PaymentExport) clazz.newInstance();
no = custom.exportToFile(paySelectionChecks.toArray(new MPaySelectionCheck[paySelectionChecks.size()]), tempFile, error);
}
} catch (ClassNotFoundException e) {
no = -1;
error.append("No custom PaymentExport class " + paymentExportClass + " - " + e.toString());
log.log(Level.SEVERE, error.toString(), e);
} catch (Exception e) {
no = -1;
error.append("Error in " + paymentExportClass + " check log, " + e.toString());
log.log(Level.SEVERE, error.toString(), e);
}
if (no >= 0) {
Filedownload.save(new FileInputStream(tempFile), "plain/text", "paymentExport.txt");
FDialog.info(windowNo, form, "Saved", Msg.getMsg(Env.getCtx(), "NoOfLines") + "=" + no);
if (FDialog.ask(windowNo, form, "VPayPrintSuccess?")) {
// int lastDocumentNo =
MPaySelectionCheck.confirmPrint(paySelectionChecks, paymentBatch);
// document No not updated
}
} else {
FDialog.error(windowNo, form, "Error", error.toString());
}
dispose();
} catch (Exception e) {
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
}
}
Aggregations