add MID_WExport class
This commit is contained in:
parent
330a4d2a00
commit
4616356866
|
|
@ -0,0 +1,514 @@
|
|||
package andromedia.midsuit.form;
|
||||
|
||||
import static org.compiere.model.SystemIDs.COLUMN_C_PAYSELECTIONCHECK_C_PAYSELECTION_ID;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.sql.Date;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Vector;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.adempiere.webui.component.Button;
|
||||
import org.adempiere.webui.component.ConfirmPanel;
|
||||
import org.adempiere.webui.component.Grid;
|
||||
import org.adempiere.webui.component.GridFactory;
|
||||
import org.adempiere.webui.component.Label;
|
||||
import org.adempiere.webui.component.Panel;
|
||||
import org.adempiere.webui.component.Row;
|
||||
import org.adempiere.webui.component.Rows;
|
||||
import org.adempiere.webui.editor.WDateEditor;
|
||||
import org.adempiere.webui.editor.WTableDirEditor;
|
||||
import org.adempiere.webui.event.ValueChangeEvent;
|
||||
import org.adempiere.webui.event.ValueChangeListener;
|
||||
import org.adempiere.webui.panel.ADForm;
|
||||
import org.adempiere.webui.panel.CustomForm;
|
||||
import org.adempiere.webui.panel.IFormController;
|
||||
import org.adempiere.webui.session.SessionManager;
|
||||
import org.adempiere.webui.util.ZKUpdateUtil;
|
||||
import org.compiere.apps.form.PayPrint;
|
||||
import org.compiere.model.MLookup;
|
||||
import org.compiere.model.MLookupFactory;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.DisplayType;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
import org.zkoss.zul.Borderlayout;
|
||||
import org.zkoss.zul.Center;
|
||||
import org.zkoss.zul.Filedownload;
|
||||
import org.zkoss.zul.South;
|
||||
|
||||
public class MID_WExport implements IFormController, EventListener<Event>, ValueChangeListener {
|
||||
private CustomForm form = new CustomForm();
|
||||
private int m_WindowNo = 0;
|
||||
public static CLogger log = CLogger.getCLogger(PayPrint.class);
|
||||
|
||||
/**
|
||||
* Initialize Panel
|
||||
*/
|
||||
public MID_WExport() {
|
||||
try {
|
||||
m_WindowNo = form.getWindowNo();
|
||||
dynInit();
|
||||
zkInit();
|
||||
Borderlayout contentLayout = new Borderlayout();
|
||||
ZKUpdateUtil.setWidth(contentLayout, "100%");
|
||||
ZKUpdateUtil.setHeight(contentLayout, "100%");
|
||||
form.appendChild(contentLayout);
|
||||
Center center = new Center();
|
||||
contentLayout.appendChild(center);
|
||||
center.appendChild(centerPanel);
|
||||
South south = new South();
|
||||
south.setStyle("border: none");
|
||||
contentLayout.appendChild(south);
|
||||
south.appendChild(southPanel);
|
||||
} catch (Exception e) {
|
||||
log.log(Level.SEVERE, "", e);
|
||||
}
|
||||
} // init
|
||||
|
||||
// Static Variables
|
||||
protected Label lDateForm = new Label();
|
||||
protected WDateEditor dateFrom = new WDateEditor("DateFrom", false, false, true, "DateFrom");
|
||||
protected Label lDateTo = new Label();
|
||||
protected WDateEditor dateTo = new WDateEditor("DateTo", false, false, true, "DateTo");
|
||||
protected Label lFaktur = new Label();
|
||||
protected Panel centerPanel = new Panel();
|
||||
protected ConfirmPanel southPanel = new ConfirmPanel(true, false, false, false, false, false, false);
|
||||
protected Grid centerLayout = GridFactory.newGridLayout();
|
||||
protected Button bPrint = southPanel.createButton(ConfirmPanel.A_PRINT);
|
||||
protected Button bExport = southPanel.createButton(ConfirmPanel.A_EXPORT);
|
||||
protected Button bCancel = southPanel.getButton(ConfirmPanel.A_CANCEL);
|
||||
protected Button bProcess = southPanel.createButton(ConfirmPanel.A_PROCESS);
|
||||
protected WTableDirEditor TIPE;
|
||||
|
||||
/**
|
||||
* Static Init
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected void zkInit() throws Exception {
|
||||
//
|
||||
centerPanel.appendChild(centerLayout);
|
||||
//
|
||||
bPrint.addActionListener(this);
|
||||
bExport.addActionListener(this);
|
||||
bCancel.addActionListener(this);
|
||||
//
|
||||
bProcess.setEnabled(false);
|
||||
bProcess.addActionListener(this);
|
||||
//
|
||||
lDateTo.setText(Msg.translate(Env.getCtx(), "Date To"));
|
||||
lDateForm.setText(Msg.translate(Env.getCtx(), "Date From"));
|
||||
lFaktur.setText("Jenis Faktur");
|
||||
//
|
||||
Rows rows = centerLayout.newRows();
|
||||
|
||||
Row row = rows.newRow();
|
||||
row.appendChild(lDateForm.rightAlign());
|
||||
row.appendChild(dateFrom.getComponent());
|
||||
row.appendChild(lDateTo.rightAlign());
|
||||
row.appendChild(dateTo.getComponent());
|
||||
row.appendChild(lFaktur.rightAlign());
|
||||
row.appendChild(TIPE.getComponent());
|
||||
ZKUpdateUtil.setHflex(TIPE.getComponent(), "100%");
|
||||
TIPE.showMenu();
|
||||
row = rows.newRow();
|
||||
row.appendCellChild(bExport);
|
||||
southPanel.getButton(ConfirmPanel.A_OK).setVisible(false);
|
||||
} // VPayPrint
|
||||
|
||||
/**
|
||||
* Dynamic Init
|
||||
*/
|
||||
protected void dynInit() {
|
||||
// C_PaySelection_ID
|
||||
int AD_Column_ID = COLUMN_C_PAYSELECTIONCHECK_C_PAYSELECTION_ID; // C_PaySelectionCheck.C_PaySelection_ID
|
||||
MLookup lookupPS = MLookupFactory.get(Env.getCtx(), m_WindowNo, 0, AD_Column_ID, DisplayType.Search);
|
||||
|
||||
try {
|
||||
|
||||
MLookup lookupTIPE = MLookupFactory.get(Env.getCtx(), form.getWindowNo(),
|
||||
148/* C_Invoice.DocAction */, DisplayType.TableDir, Env.getLanguage(Env.getCtx()), "AD_Ref_List_ID",
|
||||
0, false,
|
||||
"AD_Reference_ID IN (Select AD_Reference_ID from AD_Reference where upper(name)='FAKTURREF')");
|
||||
TIPE = new WTableDirEditor("Value", true, false, true, lookupTIPE);
|
||||
TIPE.setValue(Env.getAD_Org_ID(Env.getCtx()));
|
||||
TIPE.addValueChangeListener(this);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
} // dynInit
|
||||
|
||||
/**
|
||||
* Dispose
|
||||
*/
|
||||
public void dispose() {
|
||||
SessionManager.getAppDesktop().closeActiveWindow();
|
||||
} // dispose
|
||||
|
||||
@Override
|
||||
public void valueChange(ValueChangeEvent evt) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEvent(Event ev) throws Exception {
|
||||
if (ev.getTarget() == bCancel) {
|
||||
dispose();
|
||||
}
|
||||
if (ev.getTarget() == bExport) {
|
||||
cmd_export();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ADForm getForm() {
|
||||
// TODO Auto-generated method stub
|
||||
return form;
|
||||
}
|
||||
|
||||
protected void cmd_export() {
|
||||
if (dateFrom.getValue() == null || dateTo.getValue() == null)
|
||||
return;
|
||||
File file = null;
|
||||
try {
|
||||
file = File.createTempFile("HasilFakturPajak", ".csv");
|
||||
} catch (IOException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
char x = '"'; // ease
|
||||
String t = "\"=\""; // force to text
|
||||
int noLines = 0;
|
||||
StringBuffer line = null;
|
||||
try {
|
||||
FileWriter fw = new FileWriter(file);
|
||||
// write header
|
||||
String yn = TIPE.getComponent().getValue().equals("Keluaran") ? "Y" : "N";
|
||||
if (yn.equals("Y")) {
|
||||
line = new StringBuffer();
|
||||
line.append(x).append("FK").append(x).append(",").append(x).append("KD_JENIS_TRANSAKSI").append(x)
|
||||
.append(",").append(x).append("FG_PENGGANTI").append(x).append(",").append(x)
|
||||
.append("NOMOR_FAKTUR").append(x).append(",").append(x).append("MASA_PAJAK").append(x)
|
||||
.append(",").append(x).append("TAHUN_PAJAK").append(x).append(",").append(x)
|
||||
.append("TANGGAL_FAKTUR").append(x).append(",").append(x).append("NPWP").append(x).append(",")
|
||||
.append(x).append("NAMA").append(x).append(",").append(x).append("ALAMAT_LENGKAP").append(x)
|
||||
.append(",").append(x).append("JUMLAH_DPP").append(x).append(",").append(x).append("JUMLAH_PPN")
|
||||
.append(x).append(",").append(x).append("JUMLAH_PPNBM").append(x).append(",").append(x)
|
||||
.append("ID_KETERANGAN_TAMBAHAN").append(x).append(",").append(x).append("FG_UANG_MUKA")
|
||||
.append(x).append(",").append(x).append("UANG_MUKA_DPP").append(x).append(",").append(x)
|
||||
.append("UANG_MUKA_PPN").append(x).append(",").append(x).append("UANG_MUKA_PPNBM").append(x)
|
||||
.append(",").append(x).append("REFERENSI").append(x).append(Env.NL);
|
||||
line.append(x).append("LT").append(x).append(",").append(x).append("NPWP").append(x).append(",")
|
||||
.append(x).append("NAMA").append(x).append(",").append(x).append("JALAN").append(x).append(",")
|
||||
.append(x).append("BLOK").append(x).append(",").append(x).append("NOMOR").append(x).append(",")
|
||||
.append(x).append("RT").append(x).append(",").append(x).append("RW").append(x).append(",")
|
||||
.append(x).append("KECAMATAN").append(x).append(",").append(x).append("KELURAHAN").append(x)
|
||||
.append(",").append(x).append("KABUPATEN").append(x).append(",").append(x).append("PROPINSI")
|
||||
.append(x).append(",").append(x).append("KODE_POS").append(x).append(",").append(x)
|
||||
.append("NOMOR_TELEPON").append(x).append(",").append(Env.NL);
|
||||
line.append(x).append("OF").append(x).append(",").append(x).append("KODE_OBJEK").append(x).append(",")
|
||||
.append(x).append("NAMA").append(x).append(",").append(x).append("HARGA_SATUAN").append(x)
|
||||
.append(",").append(x).append("JUMLAH_BARANG").append(x).append(",").append(x)
|
||||
.append("HARGA_TOTAL").append(x).append(",").append(x).append("DISKON").append(x).append(",")
|
||||
.append(x).append("DPP").append(x).append(",").append(x).append("PPN").append(x).append(",")
|
||||
.append(x).append("TARIF_PPNBM").append(x).append(",").append(x).append("PPNBM").append(x)
|
||||
.append(Env.NL);
|
||||
noLines++;
|
||||
}
|
||||
if (yn.equals("N")) {
|
||||
line = new StringBuffer();
|
||||
line.append(x).append("FM").append(x).append(",").append(x).append("KD_JENIS_TRANSAKSI").append(x)
|
||||
.append(",").append(x).append("FG_PENGGANTI").append(x).append(",").append(x)
|
||||
.append("NOMOR_FAKTUR").append(x).append(",").append(x).append("MASA_PAJAK").append(x)
|
||||
.append(",").append(x).append("TAHUN_PAJAK").append(x).append(",").append(x)
|
||||
.append("TANGGAL_FAKTUR").append(x).append(",").append(x).append("NPWP").append(x).append(",")
|
||||
.append(x).append("NAMA").append(x).append(",").append(x).append("ALAMAT_LENGKAP").append(x)
|
||||
.append(",").append(x).append("JUMLAH_DPP").append(x).append(",").append(x).append("JUMLAH_PPN")
|
||||
.append(x).append(",").append(x).append("JUMLAH_PPNBM").append(x).append(",").append(x)
|
||||
.append("IS_CREDITABLE").append(x).append(Env.NL);
|
||||
noLines++;
|
||||
}
|
||||
|
||||
// write lines
|
||||
Vector<Vector<Object>> bp;
|
||||
if (yn.equalsIgnoreCase("Y")) {
|
||||
bp = getDataKeluaran();
|
||||
String lastDoc = "";
|
||||
for (Vector<Object> data : bp) {
|
||||
if (data.get(3) == null)
|
||||
data.setElementAt("null", 3);
|
||||
String doc = data.get(3).toString();
|
||||
if (!lastDoc.equalsIgnoreCase(data.get(3).toString()) || data.get(3).toString().equals("null")) {
|
||||
line.append(x).append(data.get(0).toString()).append(x).append(",") // Value
|
||||
.append(x).append(t).append(data.get(1).toString()).append(x).append(",") // Name
|
||||
.append(x).append(data.get(2).toString()).append(x).append(",") // Addr1
|
||||
.append(x).append(t).append(data.get(3).toString()).append(x).append(",").append(x)
|
||||
.append(data.get(4).toString()).append(x).append(",").append(x)
|
||||
.append(data.get(5).toString()).append(x).append(",").append(x)
|
||||
.append(data.get(6).toString()).append(x).append(",").append(x).append(t)
|
||||
.append(data.get(7).toString()).append(x).append(",").append(x)
|
||||
.append(data.get(8).toString()).append(x).append(",").append(x)
|
||||
.append(data.get(9).toString()).append(x).append(",").append(x)
|
||||
.append(data.get(10).toString()).append(x).append(",").append(x)
|
||||
.append(data.get(11).toString()).append(x).append(",").append(x)
|
||||
.append(data.get(12).toString()).append(x).append(",").append(x)
|
||||
.append(data.get(13).toString()).append(x).append(",").append(x)
|
||||
.append(data.get(14).toString()).append(x).append(",").append(x)
|
||||
.append(data.get(15).toString()).append(x).append(",").append(x)
|
||||
.append(data.get(16).toString()).append(x).append(",").append(x)
|
||||
.append(data.get(17).toString()).append(x).append(",").append(x)
|
||||
.append(data.get(18).toString()).append(x).append(Env.NL);
|
||||
}
|
||||
log.severe(data.get(28).toString());
|
||||
line.append(x).append(data.get(21).toString()).append(x).append(",").append(x)
|
||||
.append(data.get(20).toString()).append(x).append(",").append(x)
|
||||
.append(data.get(22).toString()).append(x).append(",").append(x)
|
||||
.append(data.get(23).toString()).append(x).append(",").append(x)
|
||||
.append(data.get(24).toString()).append(x).append(",").append(x)
|
||||
.append(data.get(25).toString()).append(x).append(",").append(x)
|
||||
.append(data.get(26).toString()).append(x).append(",").append(x)
|
||||
.append(data.get(25).toString()).append(x).append(",").append(x)
|
||||
.append((new BigDecimal(data.get(28).toString()).setScale(0,BigDecimal.ROUND_DOWN)).toString()).append(x).append(",").append(x)
|
||||
.append(data.get(31).toString()).append(x).append(",").append(x)
|
||||
.append(data.get(31).toString()).append(x).append(Env.NL);
|
||||
lastDoc = data.get(3).toString();
|
||||
//ChangetoPernah(data.get(20).toString());
|
||||
String sql2 = "Update C_Invoice SET sudahpernah ='Y' where C_Invoice_ID ='" + data.get(19).toString() +"'";
|
||||
DB.executeUpdate(sql2,null);
|
||||
noLines++;
|
||||
} // end of while write line
|
||||
} // DROPDOWN KELUARAN
|
||||
if (yn.equalsIgnoreCase("N")) {
|
||||
bp = getDataMasukkan();
|
||||
log.severe(dateFrom.getValue().toString());
|
||||
log.severe(dateTo.getValue().toString());
|
||||
for (Vector<Object> data : bp) {
|
||||
|
||||
line.append(x).append(data.get(0).toString()).append(x).append(",").append(x)
|
||||
.append(data.get(1).toString()).append(x).append(",").append(x)
|
||||
.append(data.get(2).toString()).append(x).append(",=").append(x)
|
||||
.append(data.get(3).toString()).append(x).append(",").append(x)
|
||||
.append(data.get(4).toString()).append(x).append(",").append(x)
|
||||
.append(data.get(5).toString()).append(x).append(",").append(x)
|
||||
.append(data.get(6).toString()).append(x).append(",").append(x)
|
||||
.append(data.get(7).toString()).append(x).append(",").append(x)
|
||||
.append(data.get(8).toString()).append(x).append(",").append(x)
|
||||
.append(data.get(9).toString()).append(x).append(",").append(x)
|
||||
.append(data.get(10).toString()).append(x).append(",").append(x)
|
||||
.append(data.get(11).toString()).append(x).append(",").append(x)
|
||||
.append(data.get(12).toString()).append(x).append(",").append(x)
|
||||
.append(data.get(13).toString()).append(x).append(Env.NL);
|
||||
String sql2 = "Update C_Invoice SET sudahpernah ='Y' where C_Invoice_ID ='" + data.get(14).toString() +"'";
|
||||
DB.executeUpdate(sql2,null);
|
||||
noLines++;
|
||||
} // END FOR
|
||||
} // DROPDOWN MASUKKAN
|
||||
|
||||
fw.write(line.toString());
|
||||
|
||||
fw.flush();
|
||||
fw.close();
|
||||
if (noLines > 0) {
|
||||
Filedownload.save(new FileInputStream(file), "plain/text", "payment.csv");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
log.severe(e.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Vector<Vector<Object>> getDataMasukkan() {
|
||||
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
|
||||
Vector<Object> line = null;
|
||||
String sql2 = "select 'FM' as Tipe, coalesce(substr(iv.nofakturpajak,1,2),'') as jenis_transaksi, coalesce(substr(iv.nofakturpajak,3,1),'') as FGPengganti, coalesce(substr(iv.nofakturpajak,4),'-'),"
|
||||
+ " extract(Month from iv.dateinvoiced) as Masapajak, extract(Year from iv.dateinvoiced) as TahunPajak, coalesce(to_char(iv.fakturdate,'dd/MM/yyyy'),' ') as tanggalfaktur,"
|
||||
+ " coalesce(bp.npwp,' ') , coalesce(bp.name2,bp.name) as namapartner, coalesce(loc.address1,' ') as alamat, floor(iv.totallines) as jumlahDPP, floor(iv.totallines * 10/100) as PPN,'0' as PPNBM,'1' as isCreditable,iv.c_invoice_id "
|
||||
+ " from c_invoice iv left join c_bpartner bp on bp.c_bpartner_id = iv.c_bpartner_id left join c_bpartner_location bpl on bp.c_bpartner_id = bpl.c_bpartner_id left join c_location loc on loc.c_location_id = bpl.c_location_id where iv.dikreditkan='Y' and iv.sudahpernah = 'N' and iv.issotrx ='N' "
|
||||
+ " and iv.ad_client_id = '1000004' and iv.dateinvoiced between '"+ dateFrom.getValue().toString() + "' and '" + dateTo.getValue().toString() + "' order by iv.dateinvoiced";
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
pstmt = DB.prepareStatement(sql2, null);
|
||||
rs = pstmt.executeQuery();
|
||||
while (rs.next()) {
|
||||
line = new Vector<Object>();
|
||||
line.add(rs.getString(1));
|
||||
line.add(rs.getString(2));
|
||||
line.add(rs.getString(3));
|
||||
//line.add(rs.getString(4));
|
||||
|
||||
String nofak = rs.getString(4);
|
||||
char a = '0';
|
||||
if(nofak.equals("-") == true)
|
||||
{
|
||||
line.add(rs.getString(4));
|
||||
}
|
||||
else
|
||||
{
|
||||
for(int i=0; i<nofak.length();i++)
|
||||
{
|
||||
if(nofak.charAt(i) != a )
|
||||
{
|
||||
line.add(nofak.substring(i,nofak.length() ));
|
||||
i = nofak.length();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
line.add(rs.getString(5));
|
||||
line.add(rs.getString(6));
|
||||
//line.add(new SimpleDateFormat("dd/MM/yyyy").format(rs.getTimestamp(7)));
|
||||
line.add(rs.getString(7));
|
||||
line.add(rs.getString(8));
|
||||
line.add(rs.getString(9));
|
||||
line.add(rs.getString(10));
|
||||
line.add(rs.getBigDecimal(11));
|
||||
line.add(rs.getBigDecimal(12));
|
||||
line.add(rs.getString(13));
|
||||
line.add(rs.getString(14));
|
||||
line.add(rs.getString(15));
|
||||
data.add(line);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.severe(e.toString());
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
private Vector<Vector<Object>> getDataKeluaran() {
|
||||
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
|
||||
Vector<Object> line = null;
|
||||
String sql = " select * from ( select iv.ad_client_Id as client_id ,'FK' as head, coalesce(substr(fa.documentno,1,2),'') as kodetransaksi, coalesce(fa.documentno,'') as nodoc, "
|
||||
+" date_part('month',iv.dateinvoiced) as monthinvoiced, extract(Year from iv.dateinvoiced) as extractyear, iv.dateinvoiced as tglnya, coalesce(bp.npwp,'') as npwp,"
|
||||
+" coalesce(bp.name2,bp.name), (select coalesce(getFirstLocation(bp.C_BPartner_ID),'-')) "
|
||||
+ " as alamat,floor(iv.totallines) as jumlahDPP,floor(iv.totallines * 10/100) as ppn,iv.documentno as invoicedoc, iv.c_invoice_id as invoiceid from c_invoice iv "
|
||||
+" join c_faktur fa on fa.c_invoice_Id = iv.c_invoice_id left join c_bpartner bp on bp.c_bpartner_id = iv.c_bpartner_id "
|
||||
+ " where iv.dikreditkan='Y' and iv.sudahpernah = 'N' and iv.issotrx = 'Y' and iv.ad_client_id ='"+Env.getAD_Client_ID(Env.getCtx())+"' and iv.dateinvoiced between '"+dateFrom.getValue().toString()+"' and '"+ dateTo.getValue().toString() +"' ) as head "
|
||||
+ " left join (select 'OF' as lines, coalesce(coalesce(me.merk,pr.name),ch.name) as produkname, round(ivl.priceentered,2) as hargasatuan,round(ivl.qtyinvoiced,0) as qty, floor(ivl.linenetamt) as hargatot, "
|
||||
+" '0' as diskon,floor(ivl.priceentered * ivl.qtyinvoiced) as dpp ,floor((ivl.priceentered * ivl.qtyinvoiced ) * 10/100) as ppn,'0' as ppnbm, '0' as tarifppnbm ,ivl.c_invoice_id as invoiceid "
|
||||
+" from c_invoice iv left join c_invoiceline ivl on iv.c_invoice_id = ivl.c_invoice_id "
|
||||
+" left join m_product pr on ivl.m_product_id = pr.m_product_id "
|
||||
+ " left join c_charge ch on ch.c_charge_id = ivl.c_charge_id "
|
||||
+ " left join ps_merk me on me.m_product_id = ivl.m_product_id and me.c_bpartner_id = iv.c_bpartner_id "
|
||||
+ "where ivl.isdescription='N' ORDER BY ivl.line ) as child on head.invoiceid = child.invoiceid ORDER BY head.tglnya ,head.invoiceid ";
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
pstmt = DB.prepareStatement(sql, null);
|
||||
rs = pstmt.executeQuery();
|
||||
while (rs.next()) {
|
||||
line = new Vector<Object>();
|
||||
line.add(rs.getString(2));
|
||||
line.add(rs.getString(3));
|
||||
line.add("0");
|
||||
|
||||
line.add((rs.getString(4).split("\\.")).length>0 ? rs.getString(4).split("\\.")[1] : rs.getString(4));
|
||||
line.add(rs.getString(5));
|
||||
line.add(rs.getString(6));
|
||||
line.add(new SimpleDateFormat("dd/MM/yyyy").format(rs.getTimestamp(7)));
|
||||
line.add(rs.getString(8));
|
||||
line.add(rs.getString(9));
|
||||
line.add(rs.getString(10));
|
||||
line.add(rs.getBigDecimal(11));
|
||||
line.add(rs.getBigDecimal(12));
|
||||
line.add("0");
|
||||
line.add("0");
|
||||
line.add("0");
|
||||
line.add("0");
|
||||
line.add("0");
|
||||
line.add("0");
|
||||
line.add(rs.getString(13));
|
||||
line.add(rs.getString(14)); //index 20
|
||||
line.add("");
|
||||
line.add(rs.getString(15));
|
||||
line.add(rs.getString(16));
|
||||
line.add(rs.getBigDecimal(17));
|
||||
line.add(rs.getBigDecimal(18));
|
||||
line.add(rs.getBigDecimal(19));
|
||||
line.add(rs.getBigDecimal(20));
|
||||
BigDecimal diskon = rs.getBigDecimal(19);
|
||||
line.add(diskon.toString());
|
||||
line.add(diskon.divide(new BigDecimal(10), 2, RoundingMode.HALF_UP).toString());
|
||||
line.add(rs.getBigDecimal(21).toString());
|
||||
line.add(rs.getBigDecimal(22).toString());
|
||||
log.severe(rs.getBigDecimal(21).toString());
|
||||
log.severe(rs.getBigDecimal(22).toString());
|
||||
line.add(rs.getString(23));
|
||||
BigDecimal dpp = rs.getBigDecimal(24).setScale(0,BigDecimal.ROUND_UP);
|
||||
line.add(dpp);
|
||||
data.add(line);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.severe(e.getMessage());
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private int getJumlahFaktur() {
|
||||
int jumlah = 0;
|
||||
String date1 = dateFrom.getDisplay();
|
||||
String date2 = dateTo.getDisplay();
|
||||
String sql = "select count(*) from c_faktur f " + "where f.created between to_date('" + dateFrom.getDisplay()
|
||||
+ "','MM/DD/YYYY') and to_date('" + dateTo.getDisplay() + "','MM/DD/YYYY')";
|
||||
|
||||
PreparedStatement ps = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
ps = DB.prepareStatement(sql, null);
|
||||
rs = ps.executeQuery();
|
||||
//
|
||||
if (rs.next()) {
|
||||
jumlah = rs.getInt(1);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
} finally {
|
||||
DB.close(rs, ps);
|
||||
rs = null;
|
||||
ps = null;
|
||||
}
|
||||
return jumlah;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void ChangetoPernah(String id)
|
||||
{
|
||||
int jumlah = 0;
|
||||
String sql = "Update C_Invoice SET sudahpernah ='Y' where c_invoice_id ='" + id +"'";
|
||||
|
||||
PreparedStatement ps = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
ps = DB.prepareStatement(sql, null);
|
||||
rs = ps.executeQuery();
|
||||
} catch (SQLException e) {
|
||||
} finally {
|
||||
DB.close(rs, ps);
|
||||
rs = null;
|
||||
ps = null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue