我能够成功创建发票和付款,但似乎无法将付款正确地链接到发票。我尝试了几种变体,但它根本没有链接,或者我得到“业务验证错误:意外的内部错误”。错误日志中的错误。下面是我的c#代码。是否有简化的方式(示例)将付款链接到发票?
Invoice i = QBGet_InvoiceByMDVInvoiceNum(MDVInvoiceNum);
Payment p = new Payment();
Customer customer = QBGet_CustomerByName(ClientName, "CompanyName");
Account acc = QBGet_AccountsReceivableAccount();
p.TxnDate = DateTime.Now;
p.TxnDateSpecified = true;
List<Line> lineList1 = new List<Line>();
Line pmtLine = new Line();
pmtLine.Amount = ReceivedPaymentAmt;
pmtLine.AmountSpecified = true;
List<LinkedTxn> linkedTxnList = new List<LinkedTxn>();
LinkedTxn linkedtxn = new LinkedTxn();
linkedtxn.TxnId = i.Id;
linkedtxn.TxnType = "invoice";
linkedTxnList.Add(linkedtxn);
pmtLine.LinkedTxn = linkedTxnList.ToArray();
//p.LinkedTxn = linkedTxnList.ToArray();
lineList1.Add(pmtLine);
p.Line = lineList1.ToArray();
p.CustomerRef = new ReferenceType()
{
Value = customer.Id
};
p.DepositToAccountRef = new ReferenceType() { Value = acc.Id };
p.PaymentRefNum = ReceiptCheckNo;
p.TotalAmt = ReceivedPaymentAmt;
p.TotalAmtSpecified = true;
DataService service = new DataService(context);
var result = service.Add<Payment>(p);
我也试过这种方法:
p.CustomerRef = new ReferenceType()
{
Value = customer.Id
};
p.PrivateNote ="ReferralID: " + ReferralId + "\r\n" + "PaymentDetailID: " + PaymentDetailID + "\r\n" + Comments;
p.PaymentRefNum = ReceiptCheckNo;
p.PaymentType = PaymentTypeEnum.Check;
p.PaymentTypeSpecified = true;
p.DocNumber = MDVInvoiceNum;
p.TotalAmt = ReceivedPaymentAmt;
p.TotalAmtSpecified = true;
p.TxnDate = PaymentReceivedDate;
p.TxnDateSpecified = true;
LinkedTxn[] lt = {new LinkedTxn()
{
TxnId=i.Id,
TxnType="invoice"
}
};
Line l = new Line()
{
Amount = ReceivedPaymentAmt,
LinkedTxn = lt
};
Line[] aryL = {l};
DataService service = new DataService(context);
Payment pmt = service.Add(p);
p.Line = aryL;
p.LinkedTxn = lt;
Payment pmt2 = service.Update(p);
答案 0 :(得分:0)
共享java代码和相应的工作JSON有效负载。这可能有所帮助。
private void paymentAgainstInvoice() {
Payment payment = new Payment();
Date currentDateTime = null;
try {
currentDateTime = DateUtils.getCurrentDateTime();
} catch (ParseException e) {
e.printStackTrace();
}
payment.setTxnDate(currentDateTime);
Line line = new Line();
line.setAmount(new BigDecimal("100"));
LinkedTxn linkedTxn = new LinkedTxn();
linkedTxn.setTxnId("248");
linkedTxn.setTxnType("Invoice");
List<LinkedTxn> linkedTxnList = new ArrayList<LinkedTxn>();
linkedTxnList.add(linkedTxn);
line.setLinkedTxn(linkedTxnList);
List<Line> lineList = new ArrayList<Line>();
lineList.add(line);
payment.setLine(lineList);
ReferenceType custReferenceType = new ReferenceType();
custReferenceType.setValue("29");
custReferenceType.setName("ABC");
payment.setCustomerRef(custReferenceType);
payment.setTotalAmt(new BigDecimal("100"));
ReferenceType accountRefType = new ReferenceType();
accountRefType.setValue("63");
payment.setPaymentRefNum("ABC-100-Invoice");
payment.setDepositToAccountRef(accountRefType );
try {
this.service.add(payment);
} catch (FMSException e) {
e.printStackTrace();
}
}
JSON有效负载(付款)
{
"CustomerRef":{
"value":"29",
"name":"ABC"
},
"DepositToAccountRef":{
"value":"63"
},
"PaymentRefNum":"ABC-100-Invoice",
"TotalAmt":100,
"TxnDate":"2014-11-30",
"Line":[
{
"Amount":100,
"LinkedTxn":[
{
"TxnId":"248",
"TxnType":"Invoice"
}
]
}
]
}
由于