IDEMPIERE-2168 Product with ASI Mandatory Type = When Shipping is still mandatory on sales orders (#976)

This commit is contained in:
hengsin 2021-11-16 02:06:24 +08:00 committed by GitHub
parent f4764b1411
commit 8db15d01d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 11 deletions

View File

@ -1194,7 +1194,7 @@ public class MInOut extends X_M_InOut implements DocAction
//
if (line.getM_AttributeSetInstance_ID() != 0)
continue;
if (product != null && product.isASIMandatory(isSOTrx()))
if (product != null && product.isASIMandatoryFor(MAttributeSet.MANDATORYTYPE_WhenShipping,isSOTrx()))
{
if (product.getAttributeSet() != null && !product.getAttributeSet().excludeTableEntry(MInOutLine.Table_ID, isSOTrx())) {
BigDecimal qtyDiff = line.getMovementQty();

View File

@ -380,7 +380,7 @@ public class MInventory extends X_M_Inventory implements DocAction
if (line.getM_AttributeSetInstance_ID() == 0)
{
MProduct product = MProduct.get(getCtx(), line.getM_Product_ID(), get_TrxName());
if (product != null && product.isASIMandatory(line.isSOTrx()))
if (product != null && product.isASIMandatoryFor(null, line.isSOTrx()))
{
if (product.getAttributeSet() != null && !product.getAttributeSet().excludeTableEntry(MInventoryLine.Table_ID, line.isSOTrx())) {
MDocType dt = MDocType.get(getC_DocType_ID());

View File

@ -294,7 +294,7 @@ public class MMovement extends X_M_Movement implements DocAction
// Mandatory Instance
MProduct product = line.getProduct();
if (line.getM_AttributeSetInstance_ID() == 0) {
if (product != null && product.isASIMandatory(true)) {
if (product != null && product.isASIMandatoryFor(null, true)) {
if (product.getAttributeSet() != null && !product.getAttributeSet().excludeTableEntry(MMovementLine.Table_ID, true)) { // outgoing
BigDecimal qtyDiff = line.getMovementQty();
// verify if the ASIs are captured on lineMA
@ -315,7 +315,7 @@ public class MMovement extends X_M_Movement implements DocAction
}
if (line.getM_AttributeSetInstanceTo_ID() == 0)
{
if (product != null && product.isASIMandatory(false) && line.getM_AttributeSetInstanceTo_ID() == 0)
if (product != null && product.isASIMandatoryFor(null, false) && line.getM_AttributeSetInstanceTo_ID() == 0)
{
if (product.getAttributeSet() != null && !product.getAttributeSet().excludeTableEntry(MMovementLine.Table_ID, false)) { // incoming
m_processMsg = "@Line@ " + line.getLine() + ": @FillMandatory@ @M_AttributeSetInstanceTo_ID@";

View File

@ -1373,7 +1373,7 @@ public class MOrder extends X_C_Order implements DocAction
for (MOrderLine line : getLines()) {
if (line.getM_Product_ID() > 0 && line.getM_AttributeSetInstance_ID() == 0) {
MProduct product = line.getProduct();
if (product.isASIMandatory(isSOTrx())) {
if (product.isASIMandatoryFor(null, isSOTrx())) {
if (product.getAttributeSet() != null && !product.getAttributeSet().excludeTableEntry(MOrderLine.Table_ID, isSOTrx())) {
StringBuilder msg = new StringBuilder("@M_AttributeSet_ID@ @IsMandatory@ (@Line@ #")
.append(line.getLine())

View File

@ -882,8 +882,18 @@ public class MProduct extends X_M_Product implements ImmutablePOSupport
* @param isSOTrx is outgoing trx?
* @return true if ASI is mandatory, false otherwise
*/
@Deprecated
public boolean isASIMandatory(boolean isSOTrx) {
//
return isASIMandatoryFor(null, isSOTrx);
}
/**
* Check if ASI is mandatory according to mandatory type
* @param mandatoryType
* @param isSOTrx
* @return true if ASI is mandatory, false otherwise
*/
public boolean isASIMandatoryFor(String mandatoryType, boolean isSOTrx) {
// If CostingLevel is BatchLot ASI is always mandatory - check all client acct schemas
MAcctSchema[] mass = MAcctSchema.getClientAcctSchema(getCtx(), getAD_Client_ID(), get_TrxName());
for (MAcctSchema as : mass)
@ -899,14 +909,15 @@ public class MProduct extends X_M_Product implements ImmutablePOSupport
if (M_AttributeSet_ID != 0)
{
MAttributeSet mas = MAttributeSet.get(getCtx(), M_AttributeSet_ID);
if (mas == null || !mas.isInstanceAttribute())
if (mas == null || !mas.isInstanceAttribute()){
return false;
// Outgoing transaction
else if (isSOTrx)
return mas.isMandatory();
} else if (isSOTrx){ // Outgoing transaction
return mas.isMandatoryAlways() || (mas.isMandatory() && mas.getMandatoryType().equals(mandatoryType));
}
// Incoming transaction
else // isSOTrx == false
else{ // isSOTrx == false
return mas.isMandatoryAlways();
}
}
//
// Default not mandatory