Я пытаюсь добавить Налоговый код для SalesItemLineDetail в api Invoice of Quickbooks, но он неправильно устанавливает налоговый код при проверке в онлайн-справочниках.
Вот мой C# код, который я Я использую для создания позиции
Line = new Intuit.Ipp.Data.Line();
InvoiceLine = new Intuit.Ipp.Data.SalesItemLineDetail();
InvoiceLine.ItemRef = new Intuit.Ipp.Data.ReferenceType
{
Value = GetItem.Id, // this is inventory Item Id
name = GetItem.Name // inventory item name
};
Line.DetailTypeSpecified = true;
Line.DetailType = Intuit.Ipp.Data.LineDetailTypeEnum.SalesItemLineDetail;
Line.Description = inv.Description;
Line.Amount = (inv.Price == null || inv.Price == 0.0) ? (decimal)0.00 : (decimal)inv.Price;
Line.AmountSpecified = true;
InvoiceLine.Qty = decimal.Parse(inv.Quantity.Value.ToString());
InvoiceLine.QtySpecified = true;
InvoiceLine.AnyIntuitObject = (inv.Price == null || inv.Price == 0.0) ? (decimal)0.00 : (decimal)(Math.Round(inv.Price.Value, 2) / inv.Quantity.Value);
InvoiceLine.ItemElementName = Intuit.Ipp.Data.ItemChoiceType.UnitPrice;
// this line is not settings tax code properly
InvoiceLine.TaxCodeRef = new Intuit.Ipp.Data.ReferenceType
{
name = taxName,
Value = TaxId
};
//Line Sales Item Line Detail - ServiceDate
InvoiceLine.ServiceDate = DateTime.Now.Date;
InvoiceLine.ServiceDateSpecified = true;
//Assign Sales Item Line Detail to Line Item
Line.AnyIntuitObject = InvoiceLine;
lines.Add(Line);
Intuit.Ipp.Data.Invoice invoice = new Intuit.Ipp.Data.Invoice();
// SalesOrder is a database table object, and OrderNumber is auto generated number
invoice.DocNumber = SalesOrder.OrderNumber.ToString();
//TxnDate
invoice.TxnDate = DateTime.Now.Date;
invoice.TxnDateSpecified = true;
invoice.CustomerRef = new Intuit.Ipp.Data.ReferenceType
{
Value = CompanyId
};
//convert list to array for Intuit Line
invoice.Line = lines.ToArray();
//TxnTaxDetail
Intuit.Ipp.Data.Line taxLine = new Intuit.Ipp.Data.Line();
Intuit.Ipp.Data.TxnTaxDetail txnTaxDetail = new Intuit.Ipp.Data.TxnTaxDetail();
Intuit.Ipp.Data.TaxLineDetail taxLineDetail = new Intuit.Ipp.Data.TaxLineDetail(); ;
//txnTaxDetail.TotalTaxSpecified = true;
//txnTaxDetail.TotalTax = decimal.Parse("2");
var MainTaxValue = "";
txnTaxDetail.TxnTaxCodeRef = new Intuit.Ipp.Data.ReferenceType()
{
Value = TaxId,
name = SalesOrder.TaxCode.TaxCodeName
};
foreach (var TAXName in TaxObject.TaxRateDetail)
{
if(TAXName.TaxRateRef.name.Contains(SalesOrder.TaxCode.TaxCodeName))
{
MainTaxValue = TAXName.TaxRateRef.value;
}
}
taxLineDetail.TaxRateRef = new Intuit.Ipp.Data.ReferenceType
{
Value = MainTaxValue
};
taxLine.AnyIntuitObject = taxLineDetail;
txnTaxDetail.TaxLine = new Intuit.Ipp.Data.Line[] { taxLine };
//DueDate
invoice.DueDate = SalesOrder.InvoiceDueDate != null ? SalesOrder.InvoiceDueDate.Value : DateTime.Now.AddDays(30).Date;
invoice.DueDateSpecified = true;
invoice.TxnTaxDetail = txnTaxDetail;
Я пробовал эти ссылки, но у меня не работает
https://gist.github.com/IntuitDeveloperRelations/6500373
Как экспортировать позиции с Налоговым кодом и значением в QBO Canada
https://developer.intuit.com/app/developer/qbo/docs/develop/tutorials/manage-sales-tax-for-non-us-locales
Используя приведенные выше ссылки, я вижу, что мы можем создать Налоговый кодекс использует эту строку кода для каждой позиции строки счета-фактуры, но неправильно устанавливает значение.
InvoiceLine.TaxCodeRef = new Intuit.Ipp.Data.ReferenceType
{
name = taxName,
Value = TaxId
};
Но это не работает. Примечание: это неамериканская компания, поэтому я должен указать налоговый код для каждой строки счета.
Редактировать 1: Прикрепить изображение запроса API Почтальона, которое я отправил в Quickbooks для создания счета. ![enter image description here](https://i.stack.imgur.com/LQhif.png)