diadoc / diadocapi-docs

HTTP API documentation - http://api-docs.diadoc.ru/
40 stars 92 forks source link

GenerateUniversalTransferDocumentXmlForSeller - "Info.DocumentDate is required" #145

Closed natt-eyre closed 7 years ago

natt-eyre commented 7 years ago

Здравствуйте, подскажите, пожалуйста, о каком обязательном поле идет речь в ошибке при генерации УПД "Info.DocumentDate is required" ? В списке полей несколько дат и вроде бы я все какие есть передаю, непонятно почему такая ошибка.

    def generate_utd_xml_for_seller
      @response ||= RestClient::Request.execute(
        method: :post,
        url: "#{DiadocService::HOST}GenerateUniversalTransferDocumentXmlForSeller",
        payload: payload,
        headers: authorization_headers
      )
    rescue Exception => e
      p e.response
    end

    private

    def payload
      { "UniversalTransferDocumentSellerTitleInfo" =>
        { "Function" => "2",
          "DocumentName" => "Универсальный передаточный документ",
          "DocumentDate" => '26.03.2017',
          "DocumentNumber" => "П-5571/1084",
          "Seller" => seller,
          "Buyer" => buyer,
          "Shipper" => { "SameAsSeller" => true },
          "Consignee" => consignee,
          "Signers" => [signer],
          "PaymentDocuments" => [{ "DocumentDate" => '28.02.2017', "DocumentNumber" => "999" }],
          "InvoiceTable" => invoice_table,
          "Currency" => "643",
          "TransferInfo" => transfer_info,
          "DocumentCreator" => "ООО 'Инсейлс Рус'" } }.to_json
    end

    def seller
      { "BoxId" => "0577fe52e00b4aeebe1f19d412e51f35@diadoc.ru",
        "OrgName" => "ООО 'Инсейлс Рус'",
        "Inn" => "9693394875",
        "Kpp" => "969301000",
        "Address" =>
        { "RussianAddress" =>
          { "ZipCode" => "125319",
            "Region" => "77",
            "City" => "Москва",
            "Street" => "Академика Ильюшина",
            "Building" => "4",
            "Block" => "1",
            "Apartment" => "11" } },
        "FnsParticipantId" => "2BM-9693394875-969301000-201703231039329785209",
        "OrgType" => "1",
        "Okopf" => "12300",
        "Okdp" => "62.01",
        "Phone" => "(495) 649-83-14",
        "Email" => "support@insales.ru",
        "CorrespondentAccount" => "30101810500000000222",
        "BankAccountNumber" => "40702810600001004854",
        "BankName" => PaymentTransaction::BankJuridical2::BANK,
        "BankId" => PaymentTransaction::BankJuridical2::BIN }
    end

    def buyer
      { "BoxId" => "a887c1091d0947fba49b5c5b199048f2@diadoc.ru",
        "OrgName" => "ООО 'DDDD Рус'",
        "Inn" => "9649161913",
        "Kpp" => "964901000",
        "Address" =>
        { "RussianAddress" =>
          { "ZipCode" => "125319",
            "Region" => "77",
            "City" => "Москва",
            "Street" => "Академика Ильюшина",
            "Building" => "5",
            "Block" => "2",
            "Apartment" => "21" } },
        "FnsParticipantId" => "2BM-9649161913-964901000-201703280416439274086",
        "OrgType" => "1",
        "Okopf" => "12300",
        "Okdp" => "62.01",
        "Phone" => "(495) 649-84-14",
        "Email" => "support@insadddles.ru",
        "CorrespondentAccount" => "30101810500000000222",
        "BankAccountNumber" => "40702810600001004854",
        "BankName" => PaymentTransaction::BankJuridical2::BANK,
        "BankId" => PaymentTransaction::BankJuridical2::BIN }
    end

    def consignee
      { "BoxId" => "a887c1091d0947fba49b5c5b199048f2@diadoc.ru",
        "OrgName" => "ООО 'DDDD Рус'",
        "Inn" => "9649161913",
        "Kpp" => "964901000",
        "Address" =>
        { "RussianAddress" =>
          { "ZipCode" => "125319",
            "Region" => "77",
            "City" => "Москва",
            "Street" => "Академика Ильюшина",
            "Building" => "5",
            "Block" => "2",
            "Apartment" => "21" } },
        "FnsParticipantId" => "2BM-9649161913-964901000-201703280416439274086",
        "OrgType" => "1",
        "Okopf" => "12300",
        "Okdp" => "62.01",
        "Phone" => "(495) 649-84-14",
        "Email" => "support@insadddles.ru",
        "CorrespondentAccount" => "30101810500000000222",
        "BankAccountNumber" => "40702810600001004854",
        "BankName" => PaymentTransaction::BankJuridical2::BANK,
        "BankId" => PaymentTransaction::BankJuridical2::BIN }
    end

    def signer
      { "BoxId" => "0577fe52e00b4aeebe1f19d412e51f35@diadoc.ru",
        "SignerDetails" => { "Surname" => "Горшков",
                             "FirstName" => "Тимофей",
                             "JobTitle" => "Генеральный директор",
                             "SignerType" => "1",
                             "SignerOrganizationName" => "ООО 'Инсейлс Рус'",
                             "SignerPowers" => "0",
                             "SignerStatus" => "1" } }
    end

    def invoice_table
      { "Items" => items,
        "Vat" => "0.00",
        "Total" => "100.34" }
    end

    def items
      [item]
    end

    def item
      { "Product" => 'Неисключительные права на Программу для ЭВМ "Платформа InSales" тариф "Продвигающий OLD"',
        "TaxRate" => "0",
        "SubtotalWithVatExcluded" => "100.34",
        "Subtotal" => "100.34" }
    end

    def transfer_info
      { "OperationInfo" => "Согласно Лицензионному договору права переданы на указанный срок и в указанном объёме",
        "TransferDate" => '01.03.2017',
        "TransferBase" => [transfer_base],
        "Waybill" => [waybill] }
    end

    def transfer_base
      { "BaseDocumentName" => "Договор",
        "BaseDocumentNumber" => "108499",
        "BaseDocumentDate" => '28.02.2017' }
    end

    def waybill
      { "TransferDocumentNumber" => "100",
        "TransferDocumentDate" => '28.02.2017' }
    end

    def authorization_headers
      { authorization: "DiadocAuth ddauth_api_client_id=#{DiadocService::CLIENT_ID}, ddauth_token=#{ddauth_token}",
        accept: 'application/json', content_type: 'application/json charset=utf-8' }
    end
atytsky commented 7 years ago

DocumentDate - это сроки, оборачивайте их в двойные кавычки.

natt-eyre commented 7 years ago

@atytsky, поменяла на двойные, не помогло.

atytsky commented 7 years ago

Вышлите JSON, который отправляете на сервер в теле запроса.

natt-eyre commented 7 years ago

"{\"UniversalTransferDocumentSellerTitleInfo\":{\"Function\":\"2\",\"DocumentName\":\"\\u0423\\u043d\\u0438\\u0432\\u0435\\u0440\\u0441\\u0430\\u043b\\u044c\\u043d\\u044b\\u0439 \\u043f\\u0435\\u0440\\u0435\\u0434\\u0430\\u0442\\u043e\\u0447\\u043d\\u044b\\u0439 \\u0434\\u043e\\u043a\\u0443\\u043c\\u0435\\u043d\\u0442\",\"DocumentDate\":\"26.03.2017\",\"DocumentNumber\":\"\\u041f-5571/1084\",\"Seller\":{\"BoxId\":\"0577fe52e00b4aeebe1f19d412e51f35@diadoc.ru\",\"OrgName\":\"\\u041e\\u041e\\u041e '\\u0418\\u043d\\u0441\\u0435\\u0439\\u043b\\u0441 \\u0420\\u0443\\u0441'\",\"Inn\":\"9693394875\",\"Kpp\":\"969301000\",\"Address\":{\"RussianAddress\":{\"ZipCode\":\"125319\",\"Region\":\"77\",\"City\":\"\\u041c\\u043e\\u0441\\u043a\\u0432\\u0430\",\"Street\":\"\\u0410\\u043a\\u0430\\u0434\\u0435\\u043c\\u0438\\u043a\\u0430 \\u0418\\u043b\\u044c\\u044e\\u0448\\u0438\\u043d\\u0430\",\"Building\":\"4\",\"Block\":\"1\",\"Apartment\":\"11\"}},\"FnsParticipantId\":\"2BM-9693394875-969301000-201703231039329785209\",\"OrgType\":\"1\",\"Okopf\":\"12300\",\"Okdp\":\"62.01\",\"Phone\":\"(495) 649-83-14\",\"Email\":\"support@insales.ru\",\"CorrespondentAccount\":\"30101810500000000222\",\"BankAccountNumber\":\"40702810600001004854\",\"BankName\":\"\\u0418\\u041d\\u0413 \\u0411\\u0410\\u041d\\u041a (\\u0415\\u0412\\u0420\\u0410\\u0417\\u0418\\u042f) \\u0410\\u041e\",\"BankId\":\"044525222\"},\"Buyer\":{\"BoxId\":\"a887c1091d0947fba49b5c5b199048f2@diadoc.ru\",\"OrgName\":\"\\u041e\\u041e\\u041e 'DDDD \\u0420\\u0443\\u0441'\",\"Inn\":\"9649161913\",\"Kpp\":\"964901000\",\"Address\":{\"RussianAddress\":{\"ZipCode\":\"125319\",\"Region\":\"77\",\"City\":\"\\u041c\\u043e\\u0441\\u043a\\u0432\\u0430\",\"Street\":\"\\u0410\\u043a\\u0430\\u0434\\u0435\\u043c\\u0438\\u043a\\u0430 \\u0418\\u043b\\u044c\\u044e\\u0448\\u0438\\u043d\\u0430\",\"Building\":\"5\",\"Block\":\"2\",\"Apartment\":\"21\"}},\"FnsParticipantId\":\"2BM-9649161913-964901000-201703280416439274086\",\"OrgType\":\"1\",\"Okopf\":\"12300\",\"Okdp\":\"62.01\",\"Phone\":\"(495) 649-84-14\",\"Email\":\"support@insadddles.ru\",\"CorrespondentAccount\":\"30101810500000000222\",\"BankAccountNumber\":\"40702810600001004854\",\"BankName\":\"\\u0418\\u041d\\u0413 \\u0411\\u0410\\u041d\\u041a (\\u0415\\u0412\\u0420\\u0410\\u0417\\u0418\\u042f) \\u0410\\u041e\",\"BankId\":\"044525222\"},\"Shipper\":{\"SameAsSeller\":true},\"Consignee\":{\"BoxId\":\"a887c1091d0947fba49b5c5b199048f2@diadoc.ru\",\"OrgName\":\"\\u041e\\u041e\\u041e 'DDDD \\u0420\\u0443\\u0441'\",\"Inn\":\"9649161913\",\"Kpp\":\"964901000\",\"Address\":{\"RussianAddress\":{\"ZipCode\":\"125319\",\"Region\":\"77\",\"City\":\"\\u041c\\u043e\\u0441\\u043a\\u0432\\u0430\",\"Street\":\"\\u0410\\u043a\\u0430\\u0434\\u0435\\u043c\\u0438\\u043a\\u0430 \\u0418\\u043b\\u044c\\u044e\\u0448\\u0438\\u043d\\u0430\",\"Building\":\"5\",\"Block\":\"2\",\"Apartment\":\"21\"}},\"FnsParticipantId\":\"2BM-9649161913-964901000-201703280416439274086\",\"OrgType\":\"1\",\"Okopf\":\"12300\",\"Okdp\":\"62.01\",\"Phone\":\"(495) 649-84-14\",\"Email\":\"support@insadddles.ru\",\"CorrespondentAccount\":\"30101810500000000222\",\"BankAccountNumber\":\"40702810600001004854\",\"BankName\":\"\\u0418\\u041d\\u0413 \\u0411\\u0410\\u041d\\u041a (\\u0415\\u0412\\u0420\\u0410\\u0417\\u0418\\u042f) \\u0410\\u041e\",\"BankId\":\"044525222\"},\"Signers\":[{\"BoxId\":\"0577fe52e00b4aeebe1f19d412e51f35@diadoc.ru\",\"SignerDetails\":{\"Surname\":\"\\u0413\\u043e\\u0440\\u0448\\u043a\\u043e\\u0432\",\"FirstName\":\"\\u0422\\u0438\\u043c\\u043e\\u0444\\u0435\\u0439\",\"JobTitle\":\"\\u0413\\u0435\\u043d\\u0435\\u0440\\u0430\\u043b\\u044c\\u043d\\u044b\\u0439 \\u0434\\u0438\\u0440\\u0435\\u043a\\u0442\\u043e\\u0440\",\"SignerType\":\"1\",\"SignerOrganizationName\":\"\\u041e\\u041e\\u041e '\\u0418\\u043d\\u0441\\u0435\\u0439\\u043b\\u0441 \\u0420\\u0443\\u0441'\",\"SignerPowers\":\"0\",\"SignerStatus\":\"1\"}}],\"PaymentDocuments\":[{\"DocumentDate\":\"28.02.2017\",\"DocumentNumber\":\"999\"}],\"InvoiceTable\":{\"Items\":[{\"Product\":\"\\u041d\\u0435\\u0438\\u0441\\u043a\\u043b\\u044e\\u0447\\u0438\\u0442\\u0435\\u043b\\u044c\\u043d\\u044b\\u0435 \\u043f\\u0440\\u0430\\u0432\\u0430 \\u043d\\u0430 \\u041f\\u0440\\u043e\\u0433\\u0440\\u0430\\u043c\\u043c\\u0443 \\u0434\\u043b\\u044f \\u042d\\u0412\\u041c \\\"\\u041f\\u043b\\u0430\\u0442\\u0444\\u043e\\u0440\\u043c\\u0430 InSales\\\" \\u0442\\u0430\\u0440\\u0438\\u0444 \\\"\\u041f\\u0440\\u043e\\u0434\\u0432\\u0438\\u0433\\u0430\\u044e\\u0449\\u0438\\u0439 OLD\\\"\",\"TaxRate\":\"0\",\"SubtotalWithVatExcluded\":\"100.34\",\"Subtotal\":\"100.34\"}],\"Vat\":\"0.00\",\"Total\":\"100.34\"},\"Currency\":\"643\",\"TransferInfo\":{\"OperationInfo\":\"\\u0421\\u043e\\u0433\\u043b\\u0430\\u0441\\u043d\\u043e \\u041b\\u0438\\u0446\\u0435\\u043d\\u0437\\u0438\\u043e\\u043d\\u043d\\u043e\\u043c\\u0443 \\u0434\\u043e\\u0433\\u043e\\u0432\\u043e\\u0440\\u0443 \\u043f\\u0440\\u0430\\u0432\\u0430 \\u043f\\u0435\\u0440\\u0435\\u0434\\u0430\\u043d\\u044b \\u043d\\u0430 \\u0443\\u043a\\u0430\\u0437\\u0430\\u043d\\u043d\\u044b\\u0439 \\u0441\\u0440\\u043e\\u043a \\u0438 \\u0432 \\u0443\\u043a\\u0430\\u0437\\u0430\\u043d\\u043d\\u043e\\u043c \\u043e\\u0431\\u044a\\u0451\\u043c\\u0435\",\"TransferDate\":\"01.03.2017\",\"TransferBase\":[{\"BaseDocumentName\":\"\\u0414\\u043e\\u0433\\u043e\\u0432\\u043e\\u0440\",\"BaseDocumentNumber\":\"108499\",\"BaseDocumentDate\":\"28.02.2017\"}],\"Waybill\":[{\"TransferDocumentNumber\":\"100\",\"TransferDocumentDate\":\"28.02.2017\"}]},\"DocumentCreator\":\"\\u041e\\u041e\\u041e '\\u0418\\u043d\\u0441\\u0435\\u0439\\u043b\\u0441 \\u0420\\u0443\\u0441'\"}}"

atytsky commented 7 years ago

У вас снова лишняя вложенность, как и в прошлый раз. Вот здесь приведен пример, как надо формировать тела запроса для JSON.

Уберите верхнюю структуру UniversalTransferDocumentSellerTitleInfo.

natt-eyre commented 7 years ago

@atytsky, спасибо, помогло. Хочется больше примеров для JSON.