5.0 Source Code
Committing 5.0 Source Code
This commit is contained in:
@@ -0,0 +1,132 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.5" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||
<Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="pos_messages.properties" key="form.customertitle" replaceFormat="AppLocal.getIntString("{key}")"/>
|
||||
</Property>
|
||||
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
|
||||
<Color id="Default Cursor"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,-81,0,0,3,69"/>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="0"/>
|
||||
<SyntheticProperty name="generateSize" type="boolean" value="true"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="true"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="jPanel3">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="Center"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="jPanel4">
|
||||
<Properties>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo">
|
||||
<EmptyBorder bottom="5" left="5" right="5" top="5"/>
|
||||
</Border>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="Center"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="jPanel8">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="South"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="jPanel1">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="After"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="jcmdOK">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/com/unicenta/images/ok.png"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="pos_messages.properties" key="Button.OK" replaceFormat="AppLocal.getIntString("{key}")"/>
|
||||
</Property>
|
||||
<Property name="enabled" type="boolean" value="false"/>
|
||||
<Property name="focusPainted" type="boolean" value="false"/>
|
||||
<Property name="focusable" type="boolean" value="false"/>
|
||||
<Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
|
||||
<Insets value="[8, 16, 8, 16]"/>
|
||||
</Property>
|
||||
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jcmdOKActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="jcmdCancel">
|
||||
<Properties>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/com/unicenta/images/cancel.png"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="pos_messages.properties" key="Button.Cancel" replaceFormat="AppLocal.getIntString("{key}")"/>
|
||||
</Property>
|
||||
<Property name="focusPainted" type="boolean" value="false"/>
|
||||
<Property name="focusable" type="boolean" value="false"/>
|
||||
<Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
|
||||
<Insets value="[8, 16, 8, 16]"/>
|
||||
</Property>
|
||||
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jcmdCancelActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="javax.swing.JButton" name="jButton1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="jButton1"/>
|
||||
</Properties>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
|
||||
<BorderConstraints direction="Center"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
@@ -0,0 +1,293 @@
|
||||
|
||||
package com.unicenta.pos.voucher;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
import com.unicenta.data.gui.MessageInf;
|
||||
import com.unicenta.data.loader.BaseSentence;
|
||||
import com.unicenta.data.loader.Datas;
|
||||
import com.unicenta.data.loader.QBFBuilder;
|
||||
import com.unicenta.data.loader.SerializerReadBasic;
|
||||
import com.unicenta.data.loader.StaticSentence;
|
||||
import com.unicenta.pos.forms.AppLocal;
|
||||
import com.unicenta.pos.forms.AppView;
|
||||
import com.unicenta.pos.reports.ReportFields;
|
||||
import com.unicenta.pos.reports.ReportFieldsArray;
|
||||
// import com.unicenta.pos.util.FontUtil;
|
||||
import com.unicenta.pos.util.JRViewer400;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dialog;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Window;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
import javax.swing.*;
|
||||
import net.sf.jasperreports.engine.JRDataSource;
|
||||
import net.sf.jasperreports.engine.JREmptyDataSource;
|
||||
import net.sf.jasperreports.engine.JRException;
|
||||
import net.sf.jasperreports.engine.JasperCompileManager;
|
||||
import net.sf.jasperreports.engine.JasperFillManager;
|
||||
import net.sf.jasperreports.engine.JasperPrint;
|
||||
import net.sf.jasperreports.engine.JasperReport;
|
||||
import net.sf.jasperreports.engine.design.JasperDesign;
|
||||
import net.sf.jasperreports.engine.xml.JRXmlLoader;
|
||||
|
||||
public abstract class JDialogReportPanel extends javax.swing.JDialog {
|
||||
|
||||
|
||||
private JRViewer400 reportviewer = null;
|
||||
private JasperReport jr = null;
|
||||
private AppView m_App;
|
||||
private List<String> paramnames = new ArrayList<>();
|
||||
private List<Datas> fielddatas = new ArrayList<>();
|
||||
private List<String> fieldnames = new ArrayList<>();
|
||||
private String sentence;
|
||||
/** Creates new form JCustomerFinder */
|
||||
private JDialogReportPanel(java.awt.Frame parent, boolean modal) {
|
||||
super(parent, modal);
|
||||
}
|
||||
|
||||
/** Creates new form JCustomerFinder */
|
||||
private JDialogReportPanel(java.awt.Dialog parent, boolean modal) {
|
||||
super(parent, modal);
|
||||
}
|
||||
|
||||
public static JDialogReportPanel getDialog(Component parent,AppView _App,VoucherInfo voucherInfo,BufferedImage image) {
|
||||
Window window = getWindow(parent);
|
||||
|
||||
JDialogReportPanel myMsg;
|
||||
if (window instanceof Frame) {
|
||||
myMsg = new JDialogReportPanel((Frame) window, true) {
|
||||
@Override
|
||||
protected String getReport() {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
};
|
||||
} else {
|
||||
myMsg = new JDialogReportPanel((Dialog) window, true) {
|
||||
@Override
|
||||
protected String getReport() {
|
||||
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
|
||||
}
|
||||
};
|
||||
}
|
||||
myMsg.init(_App,voucherInfo,image);
|
||||
myMsg.applyComponentOrientation(parent.getComponentOrientation());
|
||||
return myMsg;
|
||||
}
|
||||
|
||||
|
||||
protected BaseSentence getSentence() {
|
||||
return new StaticSentence(m_App.getSession()
|
||||
, new QBFBuilder(sentence, paramnames.toArray(new String[paramnames.size()]))
|
||||
, null
|
||||
, new SerializerReadBasic(fielddatas.toArray(new Datas[fielddatas.size()])));
|
||||
}
|
||||
|
||||
|
||||
protected ReportFields getReportFields() {
|
||||
return new ReportFieldsArray(fieldnames.toArray(new String[fieldnames.size()]));
|
||||
}
|
||||
|
||||
|
||||
private void launchreport(VoucherInfo voucherInfo,BufferedImage image) {
|
||||
|
||||
|
||||
|
||||
if (jr != null) {
|
||||
try {
|
||||
|
||||
// Archivo de recursos
|
||||
String res = "com/unicenta/reports/voucher_messages";//getResourceBundle();
|
||||
|
||||
// Parametros y los datos
|
||||
// Object params = (editor == null) ? null : editor.createValue();
|
||||
// BaseSentence sql= getSentence() ;
|
||||
// JRDataSource data = new JRDataSourceBasic(sql, getReportFields(), null);
|
||||
|
||||
// Construyo el mapa de los parametros.
|
||||
Map reportparams = new HashMap();
|
||||
reportparams.put("CUSTOMER_NAME", voucherInfo.getCustomerName());
|
||||
reportparams.put("LOGO", image);
|
||||
reportparams.put("CODE", voucherInfo.getVoucherNumber());
|
||||
reportparams.put("ISSUED", new Date());
|
||||
reportparams.put("VALUE", voucherInfo.getAmount());
|
||||
if (res != null) {
|
||||
reportparams.put("REPORT_RESOURCE_BUNDLE", ResourceBundle.getBundle(res));
|
||||
}
|
||||
|
||||
// if (paramsreport.size()>0){
|
||||
// for (Map.Entry<String, String> entry : paramsreport.entrySet()) {
|
||||
// reportparams.put(entry.getKey(), entry.getValue());
|
||||
// }
|
||||
// }
|
||||
|
||||
JasperPrint jp = JasperFillManager.fillReport(jr, reportparams, new JREmptyDataSource());
|
||||
// JasperExportManager.exportReportToPdfFile(jp,"E:\\report7.pdf");
|
||||
reportviewer.loadJasperPrint(jp);
|
||||
|
||||
|
||||
} catch (MissingResourceException e) {
|
||||
MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotloadresourcedata"), e);
|
||||
msg.show(this);
|
||||
} catch (JRException e) {
|
||||
MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotfillreport"), e);
|
||||
msg.show(this);
|
||||
}
|
||||
// catch (BasicException e) {
|
||||
// MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotloadreportdata"), e);
|
||||
// msg.show(this);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void init(AppView _App,VoucherInfo voucherInfo,BufferedImage image) {
|
||||
m_App =_App;
|
||||
initComponents();
|
||||
|
||||
reportviewer = new JRViewer400(null);
|
||||
|
||||
jPanel4.add(reportviewer, BorderLayout.CENTER);
|
||||
|
||||
try {
|
||||
jr = JasperCompileManager.compileReport("com/unicenta/reports/voucher" + ".jrxml");
|
||||
// jr = JasperCompileManager.compileReport(getClass().getResourceAsStream("reports" + "/com/unicenta/reports/voucher" + ".jrxml"));
|
||||
} catch (JRException e) {
|
||||
MessageInf msg = new MessageInf(MessageInf.SGN_WARNING, AppLocal.getIntString("message.cannotloadreport"), e);
|
||||
msg.show(this);
|
||||
jr = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
launchreport(voucherInfo,image);
|
||||
|
||||
|
||||
getRootPane().setDefaultButton(jcmdOK);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
protected abstract String getReport();
|
||||
|
||||
|
||||
|
||||
private static Window getWindow(Component parent) {
|
||||
if (parent == null) {
|
||||
return new JFrame();
|
||||
} else if (parent instanceof Frame || parent instanceof Dialog) {
|
||||
return (Window) parent;
|
||||
} else {
|
||||
return getWindow(parent.getParent());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
* always regenerated by the Form Editor.
|
||||
*/
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
jPanel3 = new javax.swing.JPanel();
|
||||
jPanel4 = new javax.swing.JPanel();
|
||||
jPanel8 = new javax.swing.JPanel();
|
||||
jPanel1 = new javax.swing.JPanel();
|
||||
jcmdOK = new javax.swing.JButton();
|
||||
jcmdCancel = new javax.swing.JButton();
|
||||
jButton1 = new javax.swing.JButton();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
setTitle(AppLocal.getIntString("form.customertitle")); // NOI18N
|
||||
setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
|
||||
|
||||
jPanel3.setLayout(new java.awt.BorderLayout());
|
||||
|
||||
jPanel4.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
||||
jPanel4.setLayout(new java.awt.BorderLayout());
|
||||
jPanel3.add(jPanel4, java.awt.BorderLayout.CENTER);
|
||||
|
||||
jPanel8.setLayout(new java.awt.BorderLayout());
|
||||
|
||||
jcmdOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N
|
||||
jcmdOK.setText(AppLocal.getIntString("Button.OK")); // NOI18N
|
||||
jcmdOK.setEnabled(false);
|
||||
jcmdOK.setFocusPainted(false);
|
||||
jcmdOK.setFocusable(false);
|
||||
jcmdOK.setMargin(new java.awt.Insets(8, 16, 8, 16));
|
||||
jcmdOK.setRequestFocusEnabled(false);
|
||||
jcmdOK.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jcmdOKActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jPanel1.add(jcmdOK);
|
||||
|
||||
jcmdCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/cancel.png"))); // NOI18N
|
||||
jcmdCancel.setText(AppLocal.getIntString("Button.Cancel")); // NOI18N
|
||||
jcmdCancel.setFocusPainted(false);
|
||||
jcmdCancel.setFocusable(false);
|
||||
jcmdCancel.setMargin(new java.awt.Insets(8, 16, 8, 16));
|
||||
jcmdCancel.setRequestFocusEnabled(false);
|
||||
jcmdCancel.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jcmdCancelActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
jPanel1.add(jcmdCancel);
|
||||
|
||||
jPanel8.add(jPanel1, java.awt.BorderLayout.LINE_END);
|
||||
|
||||
jButton1.setText("jButton1");
|
||||
jPanel8.add(jButton1, java.awt.BorderLayout.CENTER);
|
||||
|
||||
jPanel3.add(jPanel8, java.awt.BorderLayout.SOUTH);
|
||||
|
||||
getContentPane().add(jPanel3, java.awt.BorderLayout.CENTER);
|
||||
|
||||
setSize(new java.awt.Dimension(837, 687));
|
||||
setLocationRelativeTo(null);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
private void jcmdOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdOKActionPerformed
|
||||
|
||||
|
||||
dispose();
|
||||
|
||||
}//GEN-LAST:event_jcmdOKActionPerformed
|
||||
|
||||
private void jcmdCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcmdCancelActionPerformed
|
||||
|
||||
dispose();
|
||||
|
||||
}//GEN-LAST:event_jcmdCancelActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton jButton1;
|
||||
private javax.swing.JPanel jPanel1;
|
||||
private javax.swing.JPanel jPanel3;
|
||||
private javax.swing.JPanel jPanel4;
|
||||
private javax.swing.JPanel jPanel8;
|
||||
private javax.swing.JButton jcmdCancel;
|
||||
private javax.swing.JButton jcmdOK;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
}
|
||||
@@ -0,0 +1,251 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.6" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="14" style="0"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jLblStatus" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="m_jStatus" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel5" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="m_jNumber" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="m_jAmount" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="m_jCustomer" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jCBCustomer" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace pref="19" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="jButtonPrint" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="m_jNumber" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="m_jAmount" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="m_jCustomer" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jCBCustomer" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="m_jStatus" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jLblStatus" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="-2" pref="36" max="-2" attributes="0"/>
|
||||
<Component id="jButtonPrint" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="21" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jLabel2">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="pos_messages.properties" key="label.Number" replaceFormat="AppLocal.getIntString("{key}")"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[100, 30]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="m_jNumber">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[240, 30]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel3">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="pos_messages.properties" key="label.customer" replaceFormat="AppLocal.getIntString("{key}")"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[100, 30]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="m_jCustomer">
|
||||
<Properties>
|
||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="ff" green="ff" red="ff" type="rgb"/>
|
||||
</Property>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
|
||||
<Color id="Text Cursor"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[240, 30]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="m_jAmount">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[240, 30]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel5">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="pos_messages.properties" key="label.paymenttotal" replaceFormat="AppLocal.getIntString("{key}")"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[100, 30]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="jButtonPrint">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="12" style="0"/>
|
||||
</Property>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/com/unicenta/images/printer24.png"/>
|
||||
</Property>
|
||||
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="pos_messages.properties" key="button.print" replaceFormat="AppLocal.getIntString("button.print")"/>
|
||||
</Property>
|
||||
<Property name="focusPainted" type="boolean" value="false"/>
|
||||
<Property name="focusable" type="boolean" value="false"/>
|
||||
<Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
|
||||
<Insets value="[8, 14, 8, 14]"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[80, 45]"/>
|
||||
</Property>
|
||||
<Property name="requestFocusEnabled" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButtonPrintActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLblStatus">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/com/unicenta/images/ok.png"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="pos_messages.properties" key="label.Status" replaceFormat="AppLocal.getIntString("{key}")"/>
|
||||
</Property>
|
||||
<Property name="horizontalTextPosition" type="int" value="10"/>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[100, 30]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="m_jStatus">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[240, 30]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JComboBox" name="jCBCustomer">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Arial" size="14" style="0"/>
|
||||
</Property>
|
||||
<Property name="maximumRowCount" type="int" value="2"/>
|
||||
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
|
||||
<StringArray count="2">
|
||||
<StringItem index="0" value="Find"/>
|
||||
<StringItem index="1" value="Create"/>
|
||||
</StringArray>
|
||||
</Property>
|
||||
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="pos_messages.properties" key="tooltip.vouchercustomer" replaceFormat="AppLocal.getIntString("label.voucherCustomer")"/>
|
||||
</Property>
|
||||
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[110, 30]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jCBCustomerActionPerformed"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
@@ -0,0 +1,439 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2017 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// uniCenta oPOS is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.voucher;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
import com.unicenta.data.gui.ComboBoxValModel;
|
||||
import com.unicenta.data.user.DirtyManager;
|
||||
import com.unicenta.data.user.EditorRecord;
|
||||
import com.unicenta.format.Formats;
|
||||
import com.unicenta.pos.customers.CustomerInfo;
|
||||
import com.unicenta.pos.customers.DataLogicCustomers;
|
||||
import com.unicenta.pos.customers.JCustomerFinder;
|
||||
import com.unicenta.pos.customers.JDialogNewCustomer;
|
||||
import com.unicenta.pos.forms.AppLocal;
|
||||
import com.unicenta.pos.forms.AppView;
|
||||
import com.unicenta.pos.forms.DataLogicSystem;
|
||||
import com.unicenta.pos.util.ValidateBuilder;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class VoucherEditor extends javax.swing.JPanel implements EditorRecord {
|
||||
|
||||
private static final DateFormat m_simpledate = new SimpleDateFormat("MM-yy");
|
||||
private Object id;
|
||||
private final DataLogicCustomers dlCustomers;
|
||||
private final DataLogicSystem dlSystem;
|
||||
private CustomerInfo customerInfo;
|
||||
private final AppView m_app;
|
||||
|
||||
private final ComboBoxValModel m_ReasonModel;
|
||||
|
||||
public VoucherEditor(DirtyManager dirty,AppView app) {
|
||||
m_app = app;
|
||||
|
||||
initComponents();
|
||||
|
||||
dlCustomers = (DataLogicCustomers)
|
||||
app.getBean("com.unicenta.pos.customers.DataLogicCustomers");
|
||||
dlSystem = (DataLogicSystem)
|
||||
app.getBean("com.unicenta.pos.forms.DataLogicSystem");
|
||||
m_jNumber.getDocument().addDocumentListener(dirty);
|
||||
m_jCustomer.getDocument().addDocumentListener(dirty);
|
||||
m_jAmount.getDocument().addDocumentListener(dirty);
|
||||
m_jStatus.getDocument().addDocumentListener(dirty);
|
||||
|
||||
jButtonPrint.setVisible(false);
|
||||
|
||||
m_ReasonModel = new ComboBoxValModel();
|
||||
m_ReasonModel.add(AppLocal.getIntString("cboption.find"));
|
||||
m_ReasonModel.add(AppLocal.getIntString("cboption.create"));
|
||||
jCBCustomer.setModel(m_ReasonModel);
|
||||
jLblStatus.setIcon(null);
|
||||
|
||||
writeValueEOF();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeValueEOF() {
|
||||
id = null;
|
||||
m_jNumber.setText(null);
|
||||
m_jNumber.setEnabled(false);
|
||||
m_jCustomer.setText(null);
|
||||
m_jCustomer.setEnabled(false);
|
||||
m_jAmount.setText(null);
|
||||
m_jAmount.setEnabled(false);
|
||||
m_jStatus.setText(null);
|
||||
m_jStatus.setEnabled(false);
|
||||
|
||||
jButtonPrint.setEnabled(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeValueInsert() {
|
||||
id = UUID.randomUUID().toString();
|
||||
m_jNumber.setText(generateVoucherNumber());
|
||||
m_jNumber.setEnabled(true);
|
||||
m_jCustomer.setText(null);
|
||||
m_jCustomer.setEnabled(true);
|
||||
m_jAmount.setText(null);
|
||||
m_jAmount.setEnabled(true);
|
||||
m_jStatus.setText(null);
|
||||
m_jStatus.setText("A");
|
||||
|
||||
jButtonPrint.setEnabled(false);
|
||||
jButtonPrint.setEnabled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeValueDelete(Object value) {
|
||||
if ("A".equals(m_jStatus.getText())) {
|
||||
Object[] attr = (Object[]) value;
|
||||
id = attr[0];
|
||||
m_jNumber.setText(Formats.STRING.formatValue(attr[1]));
|
||||
m_jNumber.setEnabled(false);
|
||||
// customerInfo = dlCustomers.getCustomerInfo(attr[2].toString());
|
||||
// m_jCustomer.setText(customerInfo.getName());
|
||||
m_jCustomer.setText(Formats.STRING.formatValue(attr[2]));
|
||||
m_jCustomer.setEnabled(false);
|
||||
m_jAmount.setText(Formats.DOUBLE.formatValue(attr[3]));
|
||||
m_jAmount.setEnabled(false);
|
||||
m_jStatus.setText(Formats.STRING.formatValue(attr[4]));
|
||||
m_jStatus.setEnabled(false);
|
||||
jButtonPrint.setEnabled(false);
|
||||
} else {
|
||||
JOptionPane.showMessageDialog(this,
|
||||
AppLocal.getIntString("message.voucherdelete"),
|
||||
AppLocal.getIntString("Check"),
|
||||
JOptionPane.WARNING_MESSAGE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeValueEdit(Object value) {
|
||||
|
||||
Object[] attr = (Object[]) value;
|
||||
id = attr[0];
|
||||
m_jNumber.setText(Formats.STRING.formatValue(attr[1]));
|
||||
m_jNumber.setEnabled(true);
|
||||
// customerInfo = dlCustomers.getCustomerInfo(attr[2].toString());
|
||||
// m_jCustomer.setText(customerInfo.getName());
|
||||
m_jCustomer.setText(Formats.STRING.formatValue(attr[2]));
|
||||
m_jCustomer.setEnabled(true);
|
||||
m_jAmount.setText(Formats.DOUBLE.formatValue(attr[3]));
|
||||
m_jAmount.setEnabled(true);
|
||||
m_jStatus.setText(Formats.STRING.formatValue(attr[4]));
|
||||
jButtonPrint.setEnabled(true);
|
||||
|
||||
if (null == m_jStatus.getText()) {
|
||||
jLblStatus.setIcon(null);
|
||||
} else switch (m_jStatus.getText()) {
|
||||
case "A":
|
||||
jLblStatus.setIcon(new javax.swing.ImageIcon(getClass()
|
||||
.getResource("/com/unicenta/images/OK.png")));
|
||||
m_jNumber.setEnabled(true);
|
||||
m_jAmount.setEnabled(true);
|
||||
m_jCustomer.setEnabled(true);
|
||||
jCBCustomer.setEnabled(true);
|
||||
m_jStatus.setText("A");
|
||||
break;
|
||||
case "D":
|
||||
jLblStatus.setIcon(new javax.swing.ImageIcon(getClass()
|
||||
.getResource("/com/unicenta/images/refundit.png")));
|
||||
m_jNumber.setEnabled(false);
|
||||
m_jAmount.setEnabled(false);
|
||||
m_jCustomer.setEnabled(false);
|
||||
jCBCustomer.setEnabled(false);
|
||||
m_jStatus.setText("D");
|
||||
break;
|
||||
default:
|
||||
jLblStatus.setIcon(null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createValue() throws BasicException {
|
||||
|
||||
Object[] attr = new Object[5];
|
||||
|
||||
attr[0] = id;
|
||||
attr[1] = m_jNumber.getText();
|
||||
// attr[2] = customerInfo.getId();
|
||||
attr[2] = m_jCustomer.getText();
|
||||
attr[3] = Formats.DOUBLE.parseValue(m_jAmount.getText());
|
||||
attr[4] = m_jStatus.getText();
|
||||
|
||||
return attr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getComponent() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh() {
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
* always regenerated by the Form Editor.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
jLabel2 = new javax.swing.JLabel();
|
||||
m_jNumber = new javax.swing.JTextField();
|
||||
jLabel3 = new javax.swing.JLabel();
|
||||
m_jCustomer = new javax.swing.JTextField();
|
||||
m_jAmount = new javax.swing.JTextField();
|
||||
jLabel5 = new javax.swing.JLabel();
|
||||
jButtonPrint = new javax.swing.JButton();
|
||||
jLblStatus = new javax.swing.JLabel();
|
||||
m_jStatus = new javax.swing.JTextField();
|
||||
jCBCustomer = new javax.swing.JComboBox<>();
|
||||
|
||||
setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||
|
||||
jLabel2.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||
jLabel2.setText(AppLocal.getIntString("label.Number")); // NOI18N
|
||||
jLabel2.setPreferredSize(new java.awt.Dimension(100, 30));
|
||||
|
||||
m_jNumber.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||
m_jNumber.setPreferredSize(new java.awt.Dimension(240, 30));
|
||||
|
||||
jLabel3.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||
jLabel3.setText(AppLocal.getIntString("label.customer")); // NOI18N
|
||||
jLabel3.setPreferredSize(new java.awt.Dimension(100, 30));
|
||||
|
||||
m_jCustomer.setBackground(new java.awt.Color(255, 255, 255));
|
||||
m_jCustomer.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||
m_jCustomer.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));
|
||||
m_jCustomer.setPreferredSize(new java.awt.Dimension(240, 30));
|
||||
|
||||
m_jAmount.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||
m_jAmount.setPreferredSize(new java.awt.Dimension(240, 30));
|
||||
|
||||
jLabel5.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||
jLabel5.setText(AppLocal.getIntString("label.paymenttotal")); // NOI18N
|
||||
jLabel5.setPreferredSize(new java.awt.Dimension(100, 30));
|
||||
|
||||
jButtonPrint.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
|
||||
jButtonPrint.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/printer24.png"))); // NOI18N
|
||||
jButtonPrint.setToolTipText(AppLocal.getIntString("button.print")); // NOI18N
|
||||
jButtonPrint.setFocusPainted(false);
|
||||
jButtonPrint.setFocusable(false);
|
||||
jButtonPrint.setMargin(new java.awt.Insets(8, 14, 8, 14));
|
||||
jButtonPrint.setPreferredSize(new java.awt.Dimension(80, 45));
|
||||
jButtonPrint.setRequestFocusEnabled(false);
|
||||
jButtonPrint.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jButtonPrintActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
jLblStatus.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||
jLblStatus.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/ok.png"))); // NOI18N
|
||||
jLblStatus.setText(AppLocal.getIntString("label.Status")); // NOI18N
|
||||
jLblStatus.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
|
||||
jLblStatus.setPreferredSize(new java.awt.Dimension(100, 30));
|
||||
|
||||
m_jStatus.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||
m_jStatus.setPreferredSize(new java.awt.Dimension(240, 30));
|
||||
|
||||
jCBCustomer.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
|
||||
jCBCustomer.setMaximumRowCount(2);
|
||||
jCBCustomer.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Find", "Create" }));
|
||||
jCBCustomer.setToolTipText(AppLocal.getIntString("label.voucherCustomer")); // NOI18N
|
||||
jCBCustomer.setPreferredSize(new java.awt.Dimension(110, 30));
|
||||
jCBCustomer.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
jCBCustomerActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jLblStatus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(m_jStatus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(0, 0, Short.MAX_VALUE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(m_jNumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(m_jAmount, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(m_jCustomer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jCBCustomer, 0, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addContainerGap(19, Short.MAX_VALUE))))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jButtonPrint, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(m_jNumber, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(m_jAmount, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(m_jCustomer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jCBCustomer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(m_jStatus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jLblStatus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(36, 36, 36)
|
||||
.addComponent(jButtonPrint, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(21, 21, 21))
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void jButtonPrintActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonPrintActionPerformed
|
||||
|
||||
try {
|
||||
VoucherInfo voucherInfo = dlCustomers.getVoucherInfoAll(id.toString());
|
||||
BufferedImage image = dlSystem.getResourceAsImage("Window.Logo");
|
||||
if (voucherInfo!=null){
|
||||
JDialogReportPanel dialog = JDialogReportPanel
|
||||
.getDialog(this,m_app,voucherInfo,image);
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
|
||||
} catch (BasicException ex) {
|
||||
|
||||
}
|
||||
}//GEN-LAST:event_jButtonPrintActionPerformed
|
||||
|
||||
private void jCBCustomerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCBCustomerActionPerformed
|
||||
if(jCBCustomer.getSelectedIndex() == 0){
|
||||
|
||||
JCustomerFinder finder = JCustomerFinder.getCustomerFinder(this, dlCustomers);
|
||||
finder.setVisible(true);
|
||||
customerInfo = finder.getSelectedCustomer() ;
|
||||
|
||||
if (finder.getSelectedCustomer()!=null){
|
||||
m_jCustomer.setText(customerInfo.getName());
|
||||
}
|
||||
} else {
|
||||
|
||||
JDialogNewCustomer dialog = JDialogNewCustomer.getDialog(this,m_app);
|
||||
dialog.setVisible(true);
|
||||
|
||||
customerInfo=dialog.getSelectedCustomer();
|
||||
if (dialog.getSelectedCustomer()!=null){
|
||||
m_jCustomer.setText(customerInfo.getName());
|
||||
}
|
||||
}
|
||||
|
||||
}//GEN-LAST:event_jCBCustomerActionPerformed
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton jButtonPrint;
|
||||
private javax.swing.JComboBox<String> jCBCustomer;
|
||||
private javax.swing.JLabel jLabel2;
|
||||
private javax.swing.JLabel jLabel3;
|
||||
private javax.swing.JLabel jLabel5;
|
||||
private javax.swing.JLabel jLblStatus;
|
||||
private javax.swing.JTextField m_jAmount;
|
||||
private javax.swing.JTextField m_jCustomer;
|
||||
private javax.swing.JTextField m_jNumber;
|
||||
private javax.swing.JTextField m_jStatus;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
public boolean isDataValid() {
|
||||
ValidateBuilder validate = new ValidateBuilder(this);
|
||||
validate.setValidate(m_jNumber.getText(),ValidateBuilder.IS_NOT_EMPTY,
|
||||
AppLocal.getIntString("message.message.emptynumber"));
|
||||
validate.setValidate(m_jCustomer.getText(),ValidateBuilder.IS_NOT_EMPTY,
|
||||
AppLocal.getIntString("message.emptycustomer"));
|
||||
validate.setValidate(m_jAmount.getText(),ValidateBuilder.IS_DOUBLE,
|
||||
AppLocal.getIntString("message.numericamount"));
|
||||
validate.setValidate(m_jStatus.getText(),ValidateBuilder.IS_NOT_EMPTY,
|
||||
AppLocal.getIntString("message.emptystatus"));
|
||||
return validate.getValid();
|
||||
}
|
||||
|
||||
|
||||
public String generateVoucherNumber(){
|
||||
String result="";
|
||||
|
||||
try {
|
||||
result = "VO-";
|
||||
String date = m_simpledate.format(new Date());
|
||||
result = result + date;
|
||||
String lastNumber= (String)dlCustomers.getVoucherNumber().find(result);
|
||||
int newNumber = 1 ;
|
||||
|
||||
if (lastNumber!=null){
|
||||
newNumber = Integer.parseInt(lastNumber) +1;
|
||||
}
|
||||
result = result + "-" + getNewNumber(newNumber);
|
||||
|
||||
return result;
|
||||
|
||||
} catch (BasicException ex) {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private String getNewNumber(int newNumber){
|
||||
String newNo = newNumber + "";
|
||||
String zero = "";
|
||||
for (int i=0;i< 3 - newNo.length();i++){
|
||||
zero = zero + "0";
|
||||
}
|
||||
return zero+newNo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
// uniCenta oPOS - Touch Friendly Point Of Sale
|
||||
// Copyright (c) 2009-2017 uniCenta & previous Openbravo POS works
|
||||
// https://unicenta.com
|
||||
//
|
||||
// This file is part of uniCenta oPOS
|
||||
//
|
||||
// uniCenta oPOS is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// uniCenta oPOS is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
package com.unicenta.pos.voucher;
|
||||
|
||||
import com.unicenta.basic.BasicException;
|
||||
import com.unicenta.data.loader.DataRead;
|
||||
import com.unicenta.data.loader.IKeyed;
|
||||
import com.unicenta.data.loader.SerializerRead;
|
||||
|
||||
|
||||
public class VoucherInfo implements IKeyed {
|
||||
private String id;
|
||||
private String voucherNumber;
|
||||
private String customerName;
|
||||
private double amount;
|
||||
private String status;
|
||||
|
||||
public VoucherInfo() {
|
||||
}
|
||||
|
||||
public VoucherInfo(
|
||||
String id,
|
||||
String voucherNumber,
|
||||
String customerName,
|
||||
double amount,
|
||||
String status)
|
||||
{
|
||||
this.id = id;
|
||||
this.voucherNumber = voucherNumber;
|
||||
this.customerName = customerName;
|
||||
this.amount = amount;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object getKey() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the id
|
||||
*/
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id the id to set
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the voucherNumber
|
||||
*/
|
||||
public String getVoucherNumber() {
|
||||
return voucherNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param voucherNumber the voucherNumber to set
|
||||
*/
|
||||
public void setVoucherNumber(String voucherNumber) {
|
||||
this.voucherNumber = voucherNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the customerName
|
||||
*/
|
||||
public String getCustomerName() {
|
||||
return customerName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param customerName the customerName to set
|
||||
*/
|
||||
public void setCustomerName(String customerName) {
|
||||
this.customerName = customerName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the amount
|
||||
*/
|
||||
public double getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param amount the amount to set
|
||||
*/
|
||||
public void setAmount(double amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return voucherNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the status
|
||||
*/
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param status the status to set
|
||||
*/
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public static SerializerRead getSerializerRead() {
|
||||
return new SerializerRead()
|
||||
{
|
||||
@Override
|
||||
public Object readValues(DataRead dr) throws BasicException {
|
||||
return new VoucherInfo(
|
||||
dr.getString(1),
|
||||
dr.getString(2),
|
||||
dr.getString(3),
|
||||
dr.getDouble(4),
|
||||
dr.getString(5));
|
||||
}};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
|
||||
|
||||
package com.unicenta.pos.voucher;
|
||||
|
||||
import com.unicenta.data.loader.Datas;
|
||||
import com.unicenta.data.model.*;
|
||||
import com.unicenta.data.user.EditorRecord;
|
||||
import com.unicenta.format.Formats;
|
||||
import com.unicenta.pos.forms.AppLocal;
|
||||
import com.unicenta.pos.panels.JPanelTable2;
|
||||
|
||||
public class VoucherPanel extends JPanelTable2 {
|
||||
|
||||
private VoucherEditor editor;
|
||||
|
||||
@Override
|
||||
protected void init() {
|
||||
row = new Row(
|
||||
new Field("ID", Datas.STRING, Formats.STRING),
|
||||
new Field(AppLocal.getIntString("label.Number"), Datas.STRING, Formats.STRING, true, true, true),
|
||||
new Field(AppLocal.getIntString("label.customer"), Datas.STRING, Formats.STRING),
|
||||
new Field(AppLocal.getIntString("label.paymenttotal"), Datas.DOUBLE, Formats.DOUBLE),
|
||||
new Field(AppLocal.getIntString("label.status"), Datas.STRING, Formats.STRING)
|
||||
|
||||
);
|
||||
Table table = new Table(
|
||||
"vouchers",
|
||||
new PrimaryKey("ID"),
|
||||
new Column("VOUCHER_NUMBER"),
|
||||
new Column("CUSTOMER"),
|
||||
new Column("AMOUNT"),
|
||||
new Column("STATUS"));
|
||||
lpr = row.getListProvider(app.getSession(), table);
|
||||
spr = row.getSaveProvider(app.getSession(), table);
|
||||
|
||||
editor = new VoucherEditor(dirty,app);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EditorRecord getEditor() {
|
||||
return editor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTitle() {
|
||||
return AppLocal.getIntString("Menu.Vouchers");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user