我在销售订单屏幕上有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'
答案 0 :(得分:0)
我们认为,当您将Operator '!=' cannot be applied to operands of type 'PX.Data.PXResultset<PX.Objects.CR.Location>' and 'string'
变量与cust
字符串常量进行比较时,会生成错误"EXEMPT"
:
if (taxZoneZip != null && cust != "EXEMPT")
{
...
}
可能你应该将一些taxZoneZip
字段值与字符串常量进行比较,如下所示:
taxZoneZip.TaxZoneID != "EXEMPT"