Skip to content

Commit

Permalink
Merge branch 'master' of
Browse files Browse the repository at this point in the history
  • Loading branch information
SusanneCalderon committed Jun 26, 2024
1 parent 7439f6b commit 0d4d2c8
Show file tree
Hide file tree
Showing 6 changed files with 213 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/main/java/org/shw/model/CAValidator.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

import org.adempiere.core.domains.models.X_C_Invoice;
import org.compiere.model.MAllocationHdr;
import org.compiere.model.MAllocationLine;
import org.compiere.model.MBankAccount;
import org.compiere.model.MBankStatement;
import org.compiere.model.MBankStatementLine;
Expand Down
103 changes: 103 additions & 0 deletions src/main/java/org/shw/process/Project_CreateOrder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/******************************************************************************
* Product: ADempiere ERP & CRM Smart Business Solution *
* Copyright (C) 2006-2017 ADempiere Foundation, All Rights Reserved. *
* 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 *
* or (at your option) any later version. *
* 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. *
* For the text or an alternative of this public license, you may reach us *
* or via [email protected] *
* or https://github.com/adempiere/adempiere/blob/develop/license.html *
*****************************************************************************/

package org.shw.process;

import java.sql.Timestamp;
import java.util.List;

import org.compiere.model.MBPartner;
import org.compiere.model.MDocType;
import org.compiere.model.MOrder;
import org.compiere.model.MProject;
import org.compiere.model.MUser;

/** Generated Process for (C_Project_GenerateOrder_POSO)
* @author ADempiere (generated)
* @version Release 3.9.4
*/
public class Project_CreateOrder extends Project_CreateOrderAbstract
{
@Override
protected void prepare()
{
super.prepare();
}

@Override
protected String doIt() throws Exception
{
String Docbasetype = isSOTrx()?"SOO":"POO";
MProject project = new MProject(getCtx(), getRecord_ID(), get_TrxName());
{


MOrder order = new MOrder(getCtx(), 0, get_TrxName());
order.setAD_Org_ID(project.getAD_Org_ID());
order.setC_Campaign_ID(project.getC_Campaign_ID());
//order.
order.setC_Project_ID(project.getC_Project_ID());
order.setDescription(project.getName());
Timestamp ts = project.getDateStart();
if (ts != null)
order.setDateOrdered (ts);
ts = project.getDateFinish();
if (ts != null)
order.setDatePromised (ts);
//
MBPartner bpartner = null;
if (isSOTrx())
{
order.setC_BPartner_ID(project.getC_BPartner_ID());
bpartner = (MBPartner)project.getC_BPartner();
order.setAD_User_ID(project.getAD_User_ID());
order.setSalesRep_ID(project.getSalesRep_ID());
int c_DocType_ID = bpartner.get_ValueAsInt("C_DocType_ID")<=0? MDocType.getDocType(Docbasetype):
bpartner.get_ValueAsInt("C_DocType_ID");
order.setC_DocTypeTarget_ID(c_DocType_ID);
order.setM_PriceList_ID(bpartner.getM_PriceList_ID());
order.setC_PaymentTerm_ID(bpartner.getC_PaymentTerm_ID());
order.setIsSOTrx(true);
}
else
{
order.setC_BPartner_ID(getBPartnerId());
bpartner = new MBPartner(getCtx(), order.getC_BPartner_ID(), get_TrxName());
MUser[] contacts = bpartner.getContacts(true);
if (contacts.length>0)
order.setAD_User_ID(contacts[0].getAD_User_ID());
order.setSalesRep_ID(project.getSalesRep_ID());
int c_DocType_ID = 0;
if (getDocTypeId() ==0)
c_DocType_ID = bpartner.get_ValueAsInt("C_DoctypePO_ID")<=0? MDocType.getDocType(Docbasetype):
bpartner.get_ValueAsInt("C_DoctypePO_ID");
else c_DocType_ID = getDocTypeId();
order.setC_DocTypeTarget_ID(c_DocType_ID);
order.setM_PriceList_ID(bpartner.getPO_PriceList_ID());
order.setC_PaymentTerm_ID(bpartner.getPO_PaymentTerm_ID());
order.setIsSOTrx(false);
}
order.setC_BPartner_Location_ID(bpartner.getPrimaryC_BPartner_Location_ID()); //
order.setM_Warehouse_ID(project.getM_Warehouse_ID());
order.saveEx();
}

return "";
}

}
98 changes: 98 additions & 0 deletions src/main/java/org/shw/process/Project_CreateOrderAbstract.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/******************************************************************************
* Product: ADempiere ERP & CRM Smart Business Solution *
* Copyright (C) 2006-2017 ADempiere Foundation, All Rights Reserved. *
* 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 *
* or (at your option) any later version. *
* 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. *
* For the text or an alternative of this public license, you may reach us *
* or via [email protected] *
* or https://github.com/adempiere/adempiere/blob/develop/license.html *
*****************************************************************************/

package org.shw.process;

import org.compiere.process.SvrProcess;

/** Generated Process for (C_Project_GenerateOrder_POSO)
* @author ADempiere (generated)
* @version Release 3.9.4
*/
public abstract class Project_CreateOrderAbstract extends SvrProcess {
/** Process Value */
private static final String VALUE_FOR_PROCESS = "C_Project_GenerateOrder_POSO";
/** Process Name */
private static final String NAME_FOR_PROCESS = "C_Project_GenerateOrder_POSO";
/** Process Id */
private static final int ID_FOR_PROCESS = 54639;
/** Parameter Name for Sales Transaction */
public static final String ISSOTRX = "IsSOTrx";
/** Parameter Name for Business Partner */
public static final String C_BPARTNER_ID = "C_BPartner_ID";
/** Parameter Name for Document Type */
public static final String C_DOCTYPE_ID = "C_DocType_ID";
/** Parameter Value for Sales Transaction */
private boolean isSOTrx;
/** Parameter Value for Business Partner */
private int bPartnerId;
/** Parameter Value for Document Type */
private int docTypeId;

@Override
protected void prepare() {
isSOTrx = getParameterAsBoolean(ISSOTRX);
bPartnerId = getParameterAsInt(C_BPARTNER_ID);
docTypeId = getParameterAsInt(C_DOCTYPE_ID);
}

/** Getter Parameter Value for Sales Transaction */
protected boolean isSOTrx() {
return isSOTrx;
}

/** Setter Parameter Value for Sales Transaction */
protected void setIsSOTrx(boolean isSOTrx) {
this.isSOTrx = isSOTrx;
}

/** Getter Parameter Value for Business Partner */
protected int getBPartnerId() {
return bPartnerId;
}

/** Setter Parameter Value for Business Partner */
protected void setBPartnerId(int bPartnerId) {
this.bPartnerId = bPartnerId;
}

/** Getter Parameter Value for Document Type */
protected int getDocTypeId() {
return docTypeId;
}

/** Setter Parameter Value for Document Type */
protected void setDocTypeId(int docTypeId) {
this.docTypeId = docTypeId;
}

/** Getter Parameter Value for Process ID */
public static final int getProcessId() {
return ID_FOR_PROCESS;
}

/** Getter Parameter Value for Process Value */
public static final String getProcessValue() {
return VALUE_FOR_PROCESS;
}

/** Getter Parameter Value for Process Name */
public static final String getProcessName() {
return NAME_FOR_PROCESS;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ protected String doIt() throws Exception

public String createLandedCost(MInvoiceLine invoiceLine) {
ArrayList<Object> params = new ArrayList<Object>();
params.add(getUser4Id());
params.add(getProjectId());
params.add(getBPartnerId());
List<MInOut> inOuts = new Query(getCtx(), MInOut.Table_Name, "user4_ID=? and docstatus = 'CO' AND C_BPartner_ID=?", null)
List<MInOut> inOuts = new Query(getCtx(), MInOut.Table_Name, "C_Project_ID=? and docstatus = 'CO' AND C_BPartner_ID=?", null)
.setOnlyActiveRecords(true)
.setParameters(params)
.list();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public abstract class SBP_GenerateLandedCost_InvoiceLineAbstract extends SvrProc
/** Process Id */
private static final int ID_FOR_PROCESS = 54346;
/** Parameter Name for User List 4 */
public static final String USER4_ID = "User4_ID";
public static final String C_PROJECT_ID = "C_Project_ID";
/** Parameter Name for Cost Distribution */
public static final String LANDEDCOSTDISTRIBUTION = "LandedCostDistribution";
/** Parameter Name for Cost Element */
Expand All @@ -42,7 +42,7 @@ public abstract class SBP_GenerateLandedCost_InvoiceLineAbstract extends SvrProc
/** Parameter Name for Business Partner */
public static final String C_BPARTNER_ID = "C_BPartner_ID";
/** Parameter Value for User List 4 */
private int user4Id;
private int projectId;
/** Parameter Value for Cost Distribution */
private String landedCostDistribution;
/** Parameter Value for Cost Element */
Expand All @@ -54,21 +54,21 @@ public abstract class SBP_GenerateLandedCost_InvoiceLineAbstract extends SvrProc

@Override
protected void prepare() {
user4Id = getParameterAsInt(USER4_ID);
projectId = getParameterAsInt(C_PROJECT_ID);
landedCostDistribution = getParameterAsString(LANDEDCOSTDISTRIBUTION);
costElementId = getParameterAsInt(M_COSTELEMENT_ID);
landedCostTypeId = getParameterAsInt(C_LANDEDCOSTTYPE_ID);
bPartnerId = getParameterAsInt(C_BPARTNER_ID);
}

/** Getter Parameter Value for User List 4 */
protected int getUser4Id() {
return user4Id;
protected int getProjectId() {
return projectId;
}

/** Setter Parameter Value for User List 4 */
protected void setUser4Id(int user4Id) {
this.user4Id = user4Id;
protected void setProjectId(int projectId) {
this.projectId = projectId;
}

/** Getter Parameter Value for Cost Distribution */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ protected String doIt() throws Exception {
copyLinkedBusinessPartner();
copyDocumentTypes();
copyWarehouses();
copyPointOfSales();
copyBanks();
copyCashAccounts();
//copyCashAccounts();
//copyPointOfSales();
} catch (Exception e) {
throw new AdempiereException(e);
} finally {
Expand Down

0 comments on commit 0d4d2c8

Please sign in to comment.