【发布时间】:2020-10-12 10:23:03
【问题描述】:
您好,感谢您的阅读!
我正在尝试使用 SOAP 创建账单。为了指定特定的非库存项目,我扩展了端点并将字段 InventoryID-InventoryID 包含到 BillDetail 对象中。然后我更新了 WSDL 文件。出口票据现在工作正常。但是创建失败,没有关于该字段的信息。
代码如下:
string lcSQL, lcErrMsg, lcStage = "Start";
AcmtIntegrator.AcumaticaWSDL.DefaultSoapClient soapClient = null;
soapClient = new AcmtIntegrator.AcumaticaWSDL.DefaultSoapClient(clsACMT.CreateBinding(clsGlobals.gcAcmtURL),
clsACMT.CreateEndpoint(clsGlobals.gcAcmtURL, clsGlobals.gcAcmtEndPoint, clsGlobals.gcAcmtVersion));
string lcBranch, lcLocationID;
lcBranch = mdlGU.GetSystemOption("ACMTEXTRACT", "CreditMemo", "Branch", "YOGIFON");
lcLocationID = mdlGU.GetSystemOption("ACMTEXTRACT", "CreditMemo", "LocationID", "");
// Bill Level:
lcBranch = "SOFT";
string docType = "Bill";
string lcVendorCd = "EP00000001";
string lcVendorRef = "VendorRef - 2";
decimal lnBillAmt = 1000;
string lcDocTxnDate = "20201005", lcDocDueDate = "20201104";
string lcCashAccount = "102000SOFT";
string lcBillDesc = "bill Desc 2";
string lcRefNo = "RefNo";
string lcTerms = "30D";
string lcPostPeriod = "102020";
int lnLineCount = 0;
lcSQL = "select count(*) from tblCBInputCMItemLine where CMHdrID = " + Convert.ToString(1);
lnLineCount = mdlGU.GetSQLScalar(lcSQL, 0);
lnLineCount = 1;
// Bill Line
decimal lnLineExtAmt = 1000, lnUnitCost = 0, lnLineQty = 0;
string lcLinePOOrderNbr = "", lcLinePOOrderType = "", lcLineDesc = "Line Desc", lcLineTranDesc = "Tran Desc";
string lcLineAccount, lcLineSubAccount, lcUoM, lcLineItemInvID, lcLineProject = "", lcLineProjectTask = "";
string lcItemAcmtGuid = "61594ca1-0d6b-e411-a445-e06995c86014";
//
BillDetail[] loBillDetails;
loBillDetails = new BillDetail[lnLineCount];
lcSQL = "select AcmtInventoryID from stdAcmtNonStockItem where AcmtGuid = '" + Convert.ToString(lcItemAcmtGuid) + "'";
lcLineItemInvID = mdlGU.GetSQLScalar(lcSQL, "");
lcSQL = "select ItemDesc from stdAcmtNonStockItem where AcmtGuid = '" + lcItemAcmtGuid + "'";
lcLineDesc = mdlGU.GetSQLScalar(lcSQL, "");
lcSQL = "select ExpenseAccount from stdAcmtNonStockItem where AcmtGuid = '" + lcItemAcmtGuid + "'";
lcLineAccount = mdlGU.GetSQLScalar(lcSQL, "215000");
lcSQL = "select ExpenseSubAccount from stdAcmtNonStockItem where AcmtGuid = '" + lcItemAcmtGuid + "'";
lcLineSubAccount = mdlGU.GetSQLScalar(lcSQL, "");
lcSQL = "select BaseUnit from stdAcmtNonStockItem where AcmtGuid = '" + lcItemAcmtGuid + "'";
lcUoM = mdlGU.GetSQLScalar(lcSQL, "");
loBillDetails[0] = new BillDetail
{
Branch = new StringValue { Value = lcBranch },
Amount = new DecimalValue { Value = lnLineExtAmt },
ExtendedCost = new DecimalValue { Value = lnLineExtAmt },
UnitCost = new DecimalValue { Value = lnUnitCost },
Qty = new DecimalValue { Value = lnLineQty },
TransactionDescription = new StringValue { Value = lcLineTranDesc },
Description = new StringValue { Value = lcLineDesc },
POOrderNbr = new StringValue { Value = lcLinePOOrderNbr },
POOrderType = new StringValue { Value = lcLinePOOrderType },
Account = new StringValue { Value = lcLineAccount },
Subaccount = new StringValue { Value = lcLineSubAccount },
// InventoryID = new StringValue { Value = lcLineItemInvID },
UOM = new StringValue { Value = lcUoM },
//Project = new StringValue { Value = lcLineProject },
//ProjectTask = new StringValue { Value = lcLineProjectTask }
};
Bill loBill = new Bill
{
ReturnBehavior = ReturnBehavior.OnlySpecified,
// Type = new StringValue { Value = docType },
// ReferenceNbr = new StringReturn { Value = lcRefNo },
Type = new StringValue (),
ReferenceNbr = new StringReturn (),
Status = new StringReturn(),
Vendor = new StringValue { Value = lcVendorCd },
VendorRef = new StringValue { Value = lcVendorRef },
PostPeriod = new StringValue { Value = lcPostPeriod },
Terms = new StringValue { Value = lcTerms },
Hold = new BooleanValue { Value = false },
Amount = new DecimalValue { Value = lnBillAmt },
Balance = new DecimalValue { Value = lnBillAmt },
CashAccount = new StringValue { Value = lcCashAccount },
Description = new StringValue { Value = lcBillDesc },
ApprovedForPayment = new BooleanValue { Value = true },
BranchID = new StringValue { Value = lcBranch },
Details = loBillDetails,
};
// LocationID is optional
if (lcLocationID != "")
{
loBill.LocationID = new StringValue { Value = lcLocationID };
}
if (lcDocTxnDate != "")
{
loBill.Date = new DateTimeValue
{
Value = new DateTime(Convert.ToInt32(mdlGU.MyLeft(lcDocTxnDate, 4)),
Convert.ToInt32(lcDocTxnDate.Substring(4, 2)),
Convert.ToInt32(lcDocTxnDate.Substring(6, 2)))
};
loBill.DueDate = new DateTimeValue
{
Value = new DateTime(Convert.ToInt32(mdlGU.MyLeft(lcDocDueDate, 4)),
Convert.ToInt32(lcDocDueDate.Substring(4, 2)),
Convert.ToInt32(lcDocDueDate.Substring(6, 2)))
};
};
//Create a Bill
Bill newBill = new Bill();
try
{
newBill = (Bill)soapClient.Put(loBill);
//lcTxnID = newInvoice.ID.ToString();
//lnPaidAmtCurr = newInvoice.Amount.Value.Value * lnAmtMultiplier;
//lcDocRefNumber = newInvoice.ReferenceNbr.Value;
// User to be "and CMNumberCurr = ''" Not sure why.
// lcSQL = String.Format("Update tblCBInputCMHdr set ProcessingStatusID = 5, CMNumberCurr = '{0}', DocRefNumber = '{0}', TxnID = '{2}', PaidAmtCurr = {3} where CMHdrId = {1} and CMNumberCurr = ''", lcRefNumber, lnCMHdrID, lcTxnID, lnPaidAmtCurr);
//lcSQL = String.Format("Update tblCBInputCMHdr set ProcessingStatusID = 5, CMNumberCurr = '{0}', DocRefNumber = '{4}', TxnID = '{2}', PaidAmtCurr = {3} where CMHdrId = {1}", lcRefNumber, lnCMHdrID, lcTxnID, lnPaidAmtCurr, lcDocRefNumber);
//mdlGU.SqlClientExecuteSQL(lcSQL, "MakeCreditMemo", lcSQL, lcErrMsg);
//mdlGU.WriteAppLog("Make CM", "HeaderID = " + Convert.ToString(lnCMHdrID), "Making CM Lines", false);
//mdlGU.WriteAppLog("Make CreditMemo", "HeaderID = " + Convert.ToString(lnCMHdrID), "Set Status in tblCBInputCMHdr", false);
}
catch (Exception ex)
{
lcErrMsg = ex.Message.Replace("'", "").Substring(0, 900);
}
完整的错误消息显示:System.ArgumentNullException: Value cannot be null。\nParameter name: model\n at Microsoft.Data.Edm.EdmUtil.CheckArgumentNull[T](T value, String parameterName)\n at Microsoft。 Data.Edm.ExtensionMethods.EntityContainers(IEdmModel 模型)\n 在 PX.Api.ContractBased.Edm.Helpers.GetEntityType(IEdmModel 模型,字符串 objectName)\n 在 PX.Api.ContractBased.Soap.EntityReaderBase.ReadEntity(String expectedEntityType) \n 在 PX.Api.ContractBased.Soap.EntityReaderBase.ReadEntity(XmlReader reader, String localname, String expectedNamespace, String expectedEntityType)\n 在 PX.Api.ContractBased.Soap.SoapMessageTransformerBase.BindParameters(XmlReader requestReader, MethodInfo methodInfo, Tuple` 2[] parameterInfos)\n 在 PX.Api.ContractBased.Soap.WebApiSoapController.Post(ISoapSystemContract systemContract, XmlReader requestReader, String serviceNamespace, String internalNamespace, MethodInfo 方法, Fun" 抛出异常:mscorlib.dll 中的“System.ServiceModel.FaultException”
我正在使用本地版本的 Acumatica 2019 并培训租户 MyStore。我以管理员身份登录。
任何帮助将不胜感激。
问候, 亚历山大
【问题讨论】:
-
即使在默认端点上创建账单时也会发生同样的错误。
标签: acumatica