Merge release-7.1 into master

This commit is contained in:
Carlos Ruiz 2020-04-11 16:12:38 +02:00
commit 680bb2090c
5 changed files with 22 additions and 85 deletions

View File

@ -241,7 +241,8 @@ public class GridTabCSVImporter implements IGridTabImporter
manageMasterTrx(gridTab, null);
createTrx(gridTab);
}
trx.setDisplayName(GridTabCSVImporter.class.getName()+"_fileImport_" + gridTab.getTableName());
if (trx != null)
trx.setDisplayName(GridTabCSVImporter.class.getName()+"_fileImport_" + gridTab.getTableName());
String recordResult = processRecord(importMode, gridTab, indxDetail, isDetail, idx, rowResult, childs);
rowResult.append(recordResult);

View File

@ -82,6 +82,8 @@ public class MDocTypeCounter extends X_C_DocTypeCounter
return Counter_C_DocType_ID;
} // getCounterDocType_ID
/**
* Get (first) valid Counter document for document type
* @param ctx context
@ -97,7 +99,7 @@ public class MDocTypeCounter extends X_C_DocTypeCounter
// Direct Relationship
MDocTypeCounter temp = null;
String sql = "SELECT * FROM C_DocTypeCounter WHERE C_DocType_ID=?";
String sql = "SELECT * FROM C_DocTypeCounter WHERE IsActive = 'Y' and C_DocType_ID=?";
PreparedStatement pstmt = null;
ResultSet rs = null;
try

View File

@ -1,21 +0,0 @@
/**
*
*/
package org.idempiere.fa.exceptions;
/**
* @author Teo Sarca, SC ARHIPAC SERVICE SRL
*
*/
public class AssetInvoiceWithMixedLines_LRO extends AssetException {
/**
*
*/
private static final long serialVersionUID = 7477049497754422353L;
public AssetInvoiceWithMixedLines_LRO() {
super("@AssetInvoiceWithMixedLines@");
}
}

View File

@ -22,7 +22,6 @@ import org.compiere.model.SetGetModel;
import org.compiere.model.SetGetUtil;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.idempiere.fa.exceptions.AssetInvoiceWithMixedLines_LRO;
import org.idempiere.fa.exceptions.AssetProductStockedException;
@ -57,7 +56,6 @@ implements org.compiere.model.ModelValidator, org.compiere.model.FactsValidator
engine.addDocValidate(MInvoice.Table_Name, this);
engine.addModelChange(MMatchInv.Table_Name, this);
//
// engine.addFactsValidate(MDepreciationEntry.Table_Name, this);
}
public String login(int AD_Org_ID, int AD_Role_ID, int AD_User_ID)
@ -105,12 +103,6 @@ implements org.compiere.model.ModelValidator, org.compiere.model.FactsValidator
// TABLE C_Invoice
String tableName = po.get_TableName();
if(tableName.equals(MInvoice.Table_Name)){
// Invoice - Validate Fixed Assets Invoice (LRO)
if (timing==TIMING_AFTER_PREPARE)
{
MInvoice invoice = (MInvoice)po;
validateFixedAssetsInvoice_LRO(invoice);
}
if(timing==TIMING_AFTER_COMPLETE){
MInvoice mi = (MInvoice)po;
@ -134,7 +126,7 @@ implements org.compiere.model.ModelValidator, org.compiere.model.FactsValidator
* @param m model
* @param changeType set when called from model validator (See TYPE_*); else -1, when called from callout
*/
public static void modelChange_InvoiceLine(SetGetModel m, int changeType) {
public void modelChange_InvoiceLine(SetGetModel m, int changeType) {
//
// Set Asset Related Fields:
if (-1 == changeType || TYPE_BEFORE_NEW == changeType || TYPE_BEFORE_CHANGE == changeType) {
@ -201,7 +193,7 @@ implements org.compiere.model.ModelValidator, org.compiere.model.FactsValidator
//
// Check Product - fixed assets products shouldn't be stocked (but inventory objects are allowed)
MProduct product = line.getProduct();
if (product.isStocked() && line.get_ValueAsBoolean("IsFixedAssetInvoice")) {
if (product.isStocked() && line.isFixedAssetInvoice()) {
throw new AssetProductStockedException(product);
}
}
@ -222,48 +214,8 @@ implements org.compiere.model.ModelValidator, org.compiere.model.FactsValidator
DB.executeUpdateEx(sql, new Object[]{invoice_id}, m.get_TrxName());
}
}
/**
* Check if is a valid fixed asset related invoice (LRO)
* @param invoice
*/
private void validateFixedAssetsInvoice_LRO(MInvoice invoice)
{
if (invoice.get_ValueAsBoolean("IsFixedAssetInvoice"))
{
boolean hasFixedAssetLines = false;
boolean hasNormalLines = false;
for (MInvoiceLine line : invoice.getLines())
{
if (line.get_ValueAsBoolean("IsFixedAssetInvoice"))
{
hasFixedAssetLines = true;
}
else if (line.getM_Product_ID() > 0)
{
MProduct product = MProduct.get(line.getCtx(), line.getM_Product_ID());
if (product.isItem())
{
// Only items are forbiden for FA invoices because in Romania these should use
// V_Liability vendor account and not V_Liability_FixedAssets vendor account
hasNormalLines = true;
}
}
//
// No mixed lines are allowed
if (hasFixedAssetLines && hasNormalLines)
{
throw new AssetInvoiceWithMixedLines_LRO();
}
}
}
}
public String factsValidate(MAcctSchema schema, List<Fact> facts, PO po) {
// TODO: implement it
return null;
}
}

View File

@ -182,22 +182,25 @@ public class CompiereService {
// Get Login Info
String loginInfo = null;
// Verify existence of User/Client/Org/Role and User's acces to Client & Org
String sql = "SELECT u.Name || '@' || c.Name || '.' || o.Name AS Text "
+ "FROM AD_User u, AD_Client c, AD_Org o, AD_User_Roles ur, AD_Role r "
+ "WHERE u.AD_User_ID=?" // #1
+ " AND c.AD_Client_ID=?" // #2
+ " AND o.AD_Org_ID=?" // #3
+ " AND ur.AD_Role_ID=?" // #4
+ " AND ur.AD_User_ID=u.AD_User_ID"
+ " AND ur.AD_Role_ID=r.AD_Role_ID"
+ " AND (o.AD_Client_ID = 0 OR o.AD_Client_ID=c.AD_Client_ID)"
+ " AND (r.IsAccessAllOrgs='Y' OR (c.AD_Client_ID IN (SELECT AD_Client_ID FROM AD_Role_OrgAccess ca WHERE ca.AD_Role_ID=ur.AD_Role_ID)"
+ " AND o.AD_Org_ID IN (SELECT AD_Org_ID FROM AD_Role_OrgAccess ca WHERE ca.AD_Role_ID=ur.AD_Role_ID)))";
StringBuilder sql = new StringBuilder("SELECT u.Name || '@' || c.Name || '.' || o.Name AS Text")
.append(" FROM AD_User u, AD_Client c, AD_Org o, AD_Role r")
.append(" WHERE u.AD_User_ID = ?") // #1
.append(" AND c.AD_Client_ID = ?") // #2
.append(" AND o.AD_Org_ID = ?") // #3
.append(" AND r.AD_Role_ID = ?") // #4
.append(" AND (o.AD_Client_ID = 0 OR o.AD_Client_ID=c.AD_Client_ID)")
.append(" AND ( ")
.append(" r.IsAccessAllOrgs='Y'")
.append(" OR (r.IsUseUserOrgAccess='N' AND o.AD_Org_ID IN (SELECT AD_Org_ID FROM AD_Role_OrgAccess ra WHERE ra.AD_Role_ID=r.AD_Role_ID AND ra.IsActive='Y'))")
.append(" OR (r.IsUseUserOrgAccess='Y' AND o.AD_Org_ID IN (SELECT AD_Org_ID FROM AD_User_OrgAccess ua WHERE ua.AD_User_ID=u.AD_User_ID AND ua.IsActive='Y'))")
.append(")");
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, null);
pstmt = DB.prepareStatement(sql.toString(), null);
pstmt.setInt(1, AD_User_ID);
pstmt.setInt(2, AD_Client_ID);
pstmt.setInt(3, AD_Org_ID);