RMA, Upload TPB, PEB

--HG--
branch : EDII
This commit is contained in:
hodianto 2019-02-15 16:01:54 +07:00
parent 16d6b0a7c7
commit 8ba1eaa38f
12 changed files with 141 additions and 82 deletions

View File

@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Andromedia Midsuit
Bundle-SymbolicName: andromedia.midsuit.project;singleton:=true
Bundle-SymbolicName: andromedia.midsuit.project
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: org.adempiere.base;bundle-version="5.1.0",

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="andromedia.midsuit.validator">
<implementation class="andromedia.midsuit.factory.MID_ValidatorFactory"/>
<property name="service.ranking" type="Integer" value="1"/>
<reference bind="bindEventManager" cardinality="1..1" interface="org.adempiere.base.event.IEventManager" name="IEventManager" policy="static" unbind="unbindEventManager"/>
</scr:component>

View File

@ -7,12 +7,6 @@ bin.includes = .,\
OSGI-INF/MID_CreateFromFactory.xml,\
OSGI-INF/MID_FormFactory.xml,\
OSGI-INF/MID_DocFactory.xml,\
META-INF/apache-commons-lang.jar,\
META-INF/bcprov-ext-jdk15on-160.jar,\
META-INF/hsqldb.jar,\
META-INF/jackcess-2.2.0.jar,\
META-INF/jackcess-encrypt-2.1.4.jar,\
META-INF/org-apache-commons-logging.jar,\
META-INF/poi-ooxml-3.9.jar,\
META-INF/ucanaccess-4.0.4.jar
META-INF/,\
OSGI-INF/
source.. = src/

View File

@ -1,16 +1,3 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 2010 Heng Sin Low *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program 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 this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package andromedia.midsuit.activator;
import org.osgi.framework.BundleActivator;
@ -19,26 +6,22 @@ import org.osgi.framework.BundleContext;
public class Activator implements BundleActivator {
private static BundleContext context;
private BundleContext context;
static BundleContext getContext() {
@Override
public void start(BundleContext context) throws Exception {
this.context = context;
}
protected BundleContext getContext() {
return context;
}
/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext bundleContext) throws Exception {
Activator.context = bundleContext;
protected void setContext(BundleContext context) {
this.context = context;
}
/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext bundleContext) throws Exception {
Activator.context = null;
@Override
public void stop(BundleContext context) throws Exception {
this.context = null;
}
}

View File

@ -130,7 +130,7 @@ public abstract class MID_CreateFromInvoice extends CreateFrom {
ArrayList<KeyNamePair> list = new ArrayList<KeyNamePair>();
String sqlStmt = "SELECT r.M_RMA_ID, r.DocumentNo || '-' || r.Amt from M_RMA r "
+ "WHERE ISSOTRX='N' AND r.DocStatus in ('CO', 'CL') "
+ "WHERE ISSOTRX=? AND r.DocStatus in ('CO', 'CL') "
+ "AND r.C_BPartner_ID=? "
+ "AND NOT EXISTS (SELECT * FROM C_Invoice inv "
+ "WHERE inv.M_RMA_ID=r.M_RMA_ID AND inv.DocStatus IN ('CO', 'CL'))";
@ -139,7 +139,8 @@ public abstract class MID_CreateFromInvoice extends CreateFrom {
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sqlStmt, null);
pstmt.setInt(1, C_BPartner_ID);
pstmt.setString(1, isSOTrx? "Y" : "N");
pstmt.setInt(2, C_BPartner_ID);
rs = pstmt.executeQuery();
while (rs.next()) {
list.add(new KeyNamePair(rs.getInt(1), rs.getString(2)));

View File

@ -109,7 +109,7 @@ public class MID_WCreateFromInvoice extends MID_CreateFromInvoice implements Eve
// RMA Selection option should only be available for AP Credit Memo
Integer docTypeId = (Integer)getGridTab().getValue("C_DocTypeTarget_ID");
MDocType docType = MDocType.get(Env.getCtx(), docTypeId);
if (!MDocType.DOCBASETYPE_APCreditMemo.equals(docType.getDocBaseType()))
if (!MDocType.DOCBASETYPE_APCreditMemo.equals(docType.getDocBaseType()) && !MDocType.DOCBASETYPE_ARCreditMemo.equals(docType.getDocBaseType()))
{
rmaLabel.setVisible(false);
rmaField.setVisible(false);

View File

@ -595,7 +595,7 @@ public class X_MID_UploadTPBLine extends PO implements I_MID_UploadTPBLine, I_Pe
for(X_MID_UploadTPBLineDet line : lines) {
int M_RequisitionLine_ID = DB.getSQLValue(get_TrxName(), "SELECT M_RequisitionLine_ID FROM M_RequisitionLine WHERE M_Requisition_ID =? AND M_Product_ID =?"
, new Object[] { getM_Requisition_ID()});
, new Object[] { getM_Requisition_ID(), line.getM_Product_ID()});
if(M_RequisitionLine_ID >0) {
line.setM_RequisitionLine_ID(M_RequisitionLine_ID);
line.saveEx();

View File

@ -45,9 +45,10 @@ public class MID_TPBUpdateOrder extends SvrProcess{
createPurchaseOrderLine(line, order);
line.setC_Order_ID(order.get_ID());
}else if (line.getM_RMA_ID()>0 && isRetur) {
MRMA RMA = createCustomerRMA(line);
createCustomerRMALine(line, RMA);
line.setM_RMA_ID(RMA.get_ID());
createCustomerRMA(line);
// MRMA RMA = createCustomerRMA(line);
// createCustomerRMALine(line, RMA);
// line.setM_RMA_ID(RMA.get_ID());
}else {
continue;
}
@ -70,34 +71,32 @@ public class MID_TPBUpdateOrder extends SvrProcess{
.setParameters(new Object[] { line.get_ID() })
.setOnlyActiveRecords(true)
.list();
int C_Tax_ID = DB.getSQLValueEx(get_TrxName(), "SELECT C_Tax_ID FROM C_Tax WHERE Name=? AND AD_Client_ID =?", new Object[] { "Exempt", getAD_Client_ID()});
for(X_MID_UploadTPBLineDet detailLine : detailLines) {
if(detailLine.getM_RequisitionLine_ID()==0)
throw new AdempiereException(" Requistion Line untuk Aju "+line.getNoAju()+" belum terisi !!!");
// int C_Tax_ID = DB.getSQLValueEx(get_TrxName(), "SELECT C_Tax_ID FROM C_Tax WHERE Name=? AND AD_Client_ID =?", new Object[] { "Exempt", getAD_Client_ID()});
// for(X_MID_UploadTPBLineDet detailLine : detailLines) {
MRMALine rmaLine = new MRMALine(getCtx(), 0, get_TrxName());
rmaLine.setAD_Org_ID(RMA.getAD_Org_ID());
rmaLine.setM_Product_ID(detailLine.getM_Product_ID());
rmaLine.setQty(detailLine.getQty());
rmaLine.setM_InOutLine_ID(detailLine.getM_InOutLine_ID());
rmaLine.setC_Tax_ID(C_Tax_ID);
rmaLine.saveEx();
}
// MRMALine rmaLine = new MRMALine(getCtx(), 0, get_TrxName());
// rmaLine.setAD_Org_ID(RMA.getAD_Org_ID());
// rmaLine.setM_Product_ID(detailLine.getM_Product_ID());
// rmaLine.setQty(detailLine.getQty());
// rmaLine.setM_InOutLine_ID(detailLine.getM_InOutLine_ID());
// rmaLine.setC_Tax_ID(C_Tax_ID);
// rmaLine.saveEx();
// }
}
private MRMA createCustomerRMA(X_MID_UploadTPBLine line) {
MRMA retValue = new MRMA(getCtx(), 0, get_TrxName());
retValue.setAD_Org_ID(line.getAD_Org_ID());
MRMA retValue = new MRMA(getCtx(), line.getM_RMA_ID(), get_TrxName());
// retValue.setAD_Org_ID(line.getAD_Org_ID());
retValue.set_ValueNoCheck("NoAju1", line.getNoAju());
retValue.set_ValueNoCheck("RegisterDate", line.getRegisterDate());
retValue.set_ValueNoCheck("RegisterNo", line.getRegisterNo());
retValue.set_ValueNoCheck("MID_AJUDocumentType_ID", line.getMID_AJUDocumentType_ID());
retValue.setC_BPartner_ID(line.getC_BPartner_ID());
retValue.setC_Currency_ID(line.getC_Currency_ID());
retValue.setSalesRep_ID(line.getSalesRep_ID());
retValue.setIsSOTrx(true);
retValue.setM_InOut_ID(line.getM_InOut_ID());
retValue.setM_RMAType_ID(DB.getSQLValue(get_TrxName(), "SELECT M_RMAType_ID FROM M_RMAType WHERE Name =? AND AD_Client_ID =?", new Object[] {"Rusak", getAD_Client_ID()}));
// retValue.setC_BPartner_ID(line.getC_BPartner_ID());
// retValue.setC_Currency_ID(line.getC_Currency_ID());
// retValue.setSalesRep_ID(line.getSalesRep_ID());
// retValue.setIsSOTrx(true);
// retValue.setM_InOut_ID(line.getM_InOut_ID());
// retValue.setM_RMAType_ID(DB.getSQLValue(get_TrxName(), "SELECT M_RMAType_ID FROM M_RMAType WHERE Name =? AND AD_Client_ID =?", new Object[] {"Rusak", getAD_Client_ID()}));
retValue.saveEx();
return retValue;

View File

@ -65,16 +65,16 @@ public class MID_TPBUpdateOrderLine extends SvrProcess{
.list();
int C_Tax_ID = DB.getSQLValueEx(get_TrxName(), "SELECT C_Tax_ID FROM C_Tax WHERE Name=? AND AD_Client_ID =?", new Object[] { "Exempt", getAD_Client_ID()});
for(X_MID_UploadTPBLineDet detailLine : detailLines) {
if(detailLine.getM_RequisitionLine_ID()==0)
throw new AdempiereException(" Requistion Line untuk Aju "+line.getNoAju()+" belum terisi !!!");
// if(detailLine.getM_RequisitionLine_ID()==0)
// throw new AdempiereException(" Requistion Line untuk Aju "+line.getNoAju()+" belum terisi !!!");
MRMALine rmaLine = new MRMALine(getCtx(), 0, get_TrxName());
rmaLine.setAD_Org_ID(RMA.getAD_Org_ID());
rmaLine.setM_Product_ID(detailLine.getM_Product_ID());
rmaLine.setQty(detailLine.getQty());
rmaLine.setM_InOutLine_ID(detailLine.getM_InOutLine_ID());
rmaLine.setC_Tax_ID(C_Tax_ID);
rmaLine.saveEx();
// MRMALine rmaLine = new MRMALine(getCtx(), 0, get_TrxName());
// rmaLine.setAD_Org_ID(RMA.getAD_Org_ID());
// rmaLine.setM_Product_ID(detailLine.getM_Product_ID());
// rmaLine.setQty(detailLine.getQty());
// rmaLine.setM_InOutLine_ID(detailLine.getM_InOutLine_ID());
// rmaLine.setC_Tax_ID(C_Tax_ID);
// rmaLine.saveEx();
}
}

View File

@ -66,6 +66,21 @@ public class MID_UploadPEB extends SvrProcess{
Iterator<Row> rows = header.rowIterator();
int rowNum = 0;
Iterator<Row> checkRows = header.rowIterator();
String documentValidation = "";
while(checkRows.hasNext()) {
Row checkRow = checkRows.next();
String NoAju = checkRow.getCell(0).getStringCellValue();
int no = DB.getSQLValue(get_TrxName(), "SELECT COUNT(*) FROM MID_UploadPEBLine WHERE NoAju=?", new Object[] { NoAju });
if(no>0)
documentValidation= documentValidation+NoAju+" ";
}
if(documentValidation.length()>1)
throw new AdempiereException(documentValidation+" already created !!!");
while(rows.hasNext()){
Row row = rows.next();
if(rowNum==0) {
@ -145,6 +160,24 @@ public class MID_UploadPEB extends SvrProcess{
Statement statement = conn.createStatement();
ResultSet rs = statement.executeQuery(sql);
String documentValidation = "";
while(rs.next()) {
String NoAju = rs.getString("CAR");
int no = DB.getSQLValue(get_TrxName(), "SELECT COUNT(*) FROM MID_UploadPEBLine WHERE NoAju=?", new Object[] { NoAju });
if(no>0)
documentValidation= documentValidation+NoAju+" ";
}
if(documentValidation.length()>1)
throw new AdempiereException(documentValidation+" already created !!!");
statement.close();
rs.close();
statement=null;
rs = null;
statement = conn.createStatement();
rs = statement.executeQuery(sql);
while (rs.next()) {
int C_BPartner_ID = DB.getSQLValue(get_TrxName(), "SELECT C_BPartner_ID FROM C_Bpartner WHERE Name =? AND AD_Client_ID =? AND isCustomer ='Y'", new Object[] { rs.getString("NAMABELI"), getAD_Client_ID()});
int C_Currency_ID = DB.getSQLValue(get_TrxName(), "SELECT C_Currency_ID FROM C_Currency WHERE ISO_Code =? ", new Object[] { rs.getString("KDVAL") });

View File

@ -73,6 +73,21 @@ public class MID_UploadPEBWindow extends SvrProcess{
Iterator<Row> rows = header.rowIterator();
int rowNum = 0;
Iterator<Row> checkRows = header.rowIterator();
String documentValidation = "";
while(checkRows.hasNext()) {
Row checkRow = checkRows.next();
String NoAju = checkRow.getCell(0).getStringCellValue();
int no = DB.getSQLValue(get_TrxName(), "SELECT COUNT(*) FROM MID_UploadPEBLine WHERE NoAju=?", new Object[] { NoAju });
if(no>0)
documentValidation= documentValidation+NoAju+" ";
}
if(documentValidation.length()>1)
throw new AdempiereException(documentValidation+" already created !!!");
while(rows.hasNext()){
Row row = rows.next();
if(rowNum==0) {
@ -91,7 +106,7 @@ public class MID_UploadPEBWindow extends SvrProcess{
line.setNoAju(row.getCell(0).getStringCellValue());
String AJU_DocType_Value = row.getCell(5).getStringCellValue();
int MID_AJUDocType_ID = DB.getSQLValue(get_TrxName(), "SELECT MID_AJUDocumentType_ID FROM MID_AjuDocumentType WHERE Value =?", new Object[] { AJU_DocType_Value });
int MID_AJUDocType_ID = DB.getSQLValue(get_TrxName(), "SELECT MID_AJUDocumentType_ID FROM MID_AjuDocumentType WHERE Value =? AND AD_Client_ID =?", new Object[] { AJU_DocType_Value, getAD_Client_ID() });
if(MID_AJUDocType_ID <=0)
throw new AdempiereException("AJU Document For "+AJU_DocType_Value+" !!!");
line.setMID_AJUDocumentType_ID(MID_AJUDocType_ID);
@ -110,7 +125,24 @@ public class MID_UploadPEBWindow extends SvrProcess{
Statement statement = conn.createStatement();
ResultSet rs = statement.executeQuery(sql);
String documentValidation = "";
while(rs.next()) {
String NoAju = rs.getString("CAR");
int no = DB.getSQLValue(get_TrxName(), "SELECT COUNT(*) FROM MID_UploadPEBLine WHERE NoAju=?", new Object[] { NoAju });
if(no>0)
documentValidation= documentValidation+NoAju+" ";
}
if(documentValidation.length()>1)
throw new AdempiereException(documentValidation+" already created !!!");
statement.close();
rs.close();
statement=null;
rs = null;
statement = conn.createStatement();
rs = statement.executeQuery(sql);
while (rs.next()) {
if (msg != "") throw new AdempiereException(msg);
X_MID_UploadPEBLine line = new X_MID_UploadPEBLine(getCtx(), 0, get_TrxName());

View File

@ -48,6 +48,21 @@ public class MID_UploadTPB extends SvrProcess{
Workbook workbook = WorkbookFactory.create(TPB);
Sheet header = workbook.getSheet("Header");
Iterator<Row> checkRows = header.rowIterator();
String documentValidation = "";
while(checkRows.hasNext()) {
Row checkRow = checkRows.next();
String NoAju = checkRow.getCell(0).getStringCellValue();
int no = DB.getSQLValue(get_TrxName(), "SELECT COUNT(*) FROM MID_UploadTPBLine WHERE NoAju=?", new Object[] { NoAju });
if(no>0)
documentValidation= documentValidation+NoAju+" ";
}
if(documentValidation.length()>1)
throw new AdempiereException(documentValidation+" already created !!!");
Iterator<Row> rows = header.rowIterator();
int rowNum = 0;
@ -62,7 +77,7 @@ public class MID_UploadTPB extends SvrProcess{
X_MID_UploadTPBLine line = createTPBDocumentLine(row);
Sheet Barang = null;
if(AJU_DocType_Value.equals("27a") || AJU_DocType_Value.equals("27b"))
if(AJU_DocType_Value.equals("27a") || AJU_DocType_Value.equals("27b") || AJU_DocType_Value.equals("262") || AJU_DocType_Value.equals("261"))
Barang = workbook.getSheet("BahanBaku");
else
Barang = workbook.getSheet("Barang");
@ -157,7 +172,7 @@ public class MID_UploadTPB extends SvrProcess{
BigDecimal PriceList = Env.ZERO;
BigDecimal Discount = Env.ZERO;
BigDecimal PriceActual = Env.ZERO;
if(AJU_DocType_Value.equals("23") || AJU_DocType_Value.equals("40") || AJU_DocType_Value.equals("262")){
if(AJU_DocType_Value.equals("23") || AJU_DocType_Value.equals("40")){
M_Product_ID = DB.getSQLValue(get_TrxName(), "SELECT M_Product_ID FROM M_Product WHERE Value =?", new Object[] { rowBarang.getCell(20).getStringCellValue() });
C_UOM_ID = DB.getSQLValue(get_TrxName(), " SELECT C_UOM_ID FROM C_UOM WHERE UOMSymbol =?", new Object[] { rowBarang.getCell(27).getStringCellValue()});
@ -178,7 +193,7 @@ public class MID_UploadTPB extends SvrProcess{
}
if(AJU_DocType_Value.equals("23") || AJU_DocType_Value.equals("262")){
if(AJU_DocType_Value.equals("23")){
Qty = new BigDecimal(rowBarang.getCell(16).getStringCellValue());
PriceList = new BigDecimal(rowBarang.getCell(12).getStringCellValue());
try {
@ -195,6 +210,9 @@ public class MID_UploadTPB extends SvrProcess{
PriceActual = PriceList;
}else{
Qty = new BigDecimal(rowBarang.getCell(8).getStringCellValue());
if(AJU_DocType_Value.equals("261") || AJU_DocType_Value.equals("262"))
PriceActual = new BigDecimal(rowBarang.getCell(3).getStringCellValue());
else
PriceActual = new BigDecimal(rowBarang.getCell(5).getStringCellValue());
if(AJU_DocType_Value.equals("27"))
PriceList = new BigDecimal(rowBarang.getCell(12).getStringCellValue());