【问题标题】:Tax Zone Exempt Override税区免税覆盖
【发布时间】:2018-03-20 00:29:06
【问题描述】:

我在“销售订单”屏幕上有 Acumatica 的自定义代码,如果有人覆盖默认送货地址,那么它也会将税区覆盖到被覆盖的送货地址中提供的邮政编码。但是,当我们添加到税区的税区应该是免税的时,它不应该覆盖这个税区。这是我的代码:

  namespace PX.Objects.SO
{
  public class SOOrderEntry_Extension : PXGraphExtension<SOOrderEntry>
  {
    #region Event Handlers
private bool setCustomTaxZoneID = false;
        protected void SOShippingAddress_PostalCode_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e,
            PXFieldUpdated del)
        {
            SOShippingAddress row = e.Row as SOShippingAddress;
            if (row != null && sender.Locate(row) != null && 
                row.OverrideAddress == true && !string.IsNullOrEmpty(row.PostalCode))
            {
                var order = Base.Document.Current;
                order.OverrideTaxZone = true;
                setCustomTaxZoneID = true;

            }

            try
            {
                if (del != null)
                {
                    del(sender, e);
                }
            }
            finally
            {
                setCustomTaxZoneID = false;
            }
        }

        protected void SOOrder_TaxZoneID_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e,
            PXFieldDefaulting del)
        {
            SOOrder row = e.Row as SOOrder;
            if (row != null && setCustomTaxZoneID && row.OverrideTaxZone == true)
            {
                var shippingAddress = (SOShippingAddress)Base.Shipping_Address.Select();
                var location = (SOOrder)Base.CurrentDocument.Select();
                if (!string.IsNullOrEmpty(shippingAddress.PostalCode))
                {

                    var taxZoneZip = PXSelect<TaxZoneZip,
                        Where<TaxZoneZip.zipCode, Equal<Required<TaxZoneZip.zipCode>>>>
                        .Select(Base, shippingAddress.PostalCode)
                        .RowCast<TaxZoneZip>().OrderBy(z => z.TaxZoneID).FirstOrDefault();
                  var cust = PXSelect<Location, Where<Location.bAccountID, Equal<Current<SOOrder.customerID>>>>.Select(Base, location.TaxZoneID);
                    if (taxZoneZip != null && cust != "EXEMPT")
                    {
                        e.NewValue = taxZoneZip.TaxZoneID;
                    }
                }
                return;
            }

            if (del != null)
            {
                del(sender, e);
            }
        }

    #endregion
  }
}

我得到的错误是这样的:

Building directory '\WebSiteValidationDomain\App_RuntimeCode\'.
\App_RuntimeCode\SOOrderEntry.cs(92): error CS0019: Operator '!=' cannot be applied to operands of type 'PX.Data.PXResultset<PX.Objects.CR.Location>' and 'string'
\App_RuntimeCode\SOOrderEntry.cs(92): error CS0019: Operator '!=' cannot be applied to operands of type 'PX.Data.PXResultset<PX.Objects.CR.Location>' and 'string' 

【问题讨论】:

    标签: customization acumatica


    【解决方案1】:

    在我看来,当您将 cust 变量与 "EXEMPT" 字符串常量进行比较时,会生成错误 Operator '!=' cannot be applied to operands of type 'PX.Data.PXResultset&lt;PX.Objects.CR.Location&gt;' and 'string'

    if (taxZoneZip != null && cust != "EXEMPT")
    {
        ...
    }
    

    您可能应该将一些 taxZoneZip 字段值与字符串常量进行比较,如下所示:

    taxZoneZip.TaxZoneID != "EXEMPT"
    

    【讨论】:

    • 这确实有效,但如果 TaxZoneID 设置为 Exempt,我希望该字段根本不可编辑。但解决方案在上面确实有效。
    猜你喜欢
    • 2021-01-01
    • 2023-04-06
    • 2017-12-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多