1

по http://api-docs.diadoc.ru/ru/latest/howto/example_send_invoice.html

пробую

public static GeneratedFile GenerateinvoiceXml(string authToken, string box, string tobox)
{
    try
    {
        var content = new InvoiceInfo()
        {
            // заполняем согласно структуре InvoiceInfo
            InvoiceDate = "31.01.2016",                    // дата СФ
            InvoiceNumber = "11-012016-2410000000",                  // номер СФ
            Seller = {
            BoxId = box
        },
            Buyer = {
            BoxId = tobox
        },
            Signer = {
            SignerCertificate = ReadFileContent(FileWithCertName)
        },

            PaymentDocuments =   {
                new PaymentDocumentInfo
                {
                       DocumentDate = "08.08.2016",
                       DocumentNumber = "№00243015140"
                }
        },
            Items = {
            new InvoiceItem
            {
                Product = "Горячая вода (компонент на тепловую энергию). Прочие",
                CountriesOfOrigin = { "23", "3243" } ,
                TaxRate =  TaxRate.Fraction_10_110,
                Subtotal = "321231"
            }
        },
            AdditionalInfos = {
            new AdditionalInfo
            {
                Id = "2312321",
                Value = "32423423"
            }
        },
            Total = "1000"
        };
        return Api.GenerateInvoiceXml(authToken, content);
    }
    catch (Exception e)
    {

        logger.Debug("Except{0}", e, null);
        Console.Read();
        return null;
    }
}

получаю

diadoc_cnsl.Program.GenerateinvoiceXml Debug: ExceptSystem.NullReferenceException: В экземпляре объекта не задана ссылка на объект. в diadoc_cnsl.Program.GenerateinvoiceXml(String authToken, String box, String tobox)

каким образом правильно сформировать сообщение?

как понимаю используется https://developers.google.com/protocol-buffers/docs/proto

0

1 ответ 1

1

Свойства не обязаны быть заполнены, создавайте экземпляры классов, не забывайте:

      Seller = new DiadocOrganizationInfo()
      {
        BoxId = box
      },
      Buyer = new DiadocOrganizationInfo()
      {
        BoxId = tobox
      },
      Signer = new Signer()
      {
        SignerCertificate = null
      },

Ну и сразу, в текущем виде будет ошибка:

InvoiceInfo.Seller.OrgInfo.Address.RussianAddress.Region is required

3
  • откуда вы узнали?
    – des1roer
    29 сен 2016 в 6:31
  • а как описывать страну происхождения? CountriesOfOrigin = { "7" } , получаю AdditionalMessage=Could not recognize InvoiceInfo.Items[0].CountriesOfOrigin[0]: 7,
    – des1roer
    29 сен 2016 в 6:32
  • @des1roer DiadocOrganizationInfo проще не строить вручную, а запросить из сервиса. В одном случае - это ваша организация, где то в GetMyOriganizations, а во втором - контрагента, посмотрите в GetBox.
    – Monk
    29 сен 2016 в 6:54

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.