我正在使用netsuite ruby gem(https://github.com/RevolutionPrep/netsuite)。
我和宝石的创始人交谈过,我正在使用抓取交易的正确方法: https://github.com/RevolutionPrep/netsuite/issues/52
在Gemfile中:
gem 'netsuite'
我在进行交易搜索时一直这样做:
1.9.3p448 :008 > search = NetSuite::Records::Transaction.get(3820)
HTTPI GET request to webservices.netsuite.com (net_http)
HTTPI POST request to webservices.netsuite.com (net_http)
Savon::SOAPFault: (soapenv:Server.userException) org.xml.sax.SAXException: transaction is not a legal value for {urn:types.core_2013_2.platform.webservices.netsuite.com}RecordType
这也会产生同样的错误:
search = NetSuite::Records::Transaction.get(:internal_id => 3820)
这有效:
def getAllTransactions
#SearchStringField, searchValue
t = Time.new
search = NetSuite::Records::Transaction.search({
criteria: {
basic: [
{
field: 'type',
operator: 'anyOf',
type: 'SearchEnumMultiSelectField',
value: [ "_invoice" ]
},
{
field: 'tranDate',
operator: 'within',
type: 'SearchDateField',
value: [
Date.parse("12/1/2013").strftime("%Y-%m-%dT%H:%M:%S%z"),
Date.parse("#{t.month}/#{t.day}/#{t.year}").strftime("%Y-%m-%dT%H:%M:%S%z")
]
}
]
}
})
search
end
这也有效:
NetSuite::Records::Customer.get(:internal_id => 3820)
这些不起作用:
1.9.3p448 :007 > customer = NetSuite::Records::Invoice.get(:internal_id => 7996)
HTTPI GET request to webservices.netsuite.com (net_http)
HTTPI POST request to webservices.netsuite.com (net_http)
NetSuite::RecordNotFound: NetSuite::Records::Invoice with OPTIONS={:internal_id=>7996} could not be found
from /Users/pkatepalli/.rvm/gems/ruby-1.9.3-p448/gems/netsuite-0.2.0/lib/netsuite/actions/get.rb:73:in `get'
from (irb):7
from /Users/pkatepalli/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/commands/console.rb:47:in `start'
from /Users/pkatepalli/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/commands/console.rb:8:in `start'
from /Users/pkatepalli/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:5:in `require'
from script/rails:5:in `<main>'
1.9.3p448 :008 > customer = NetSuite::Records::SalesOrder.get(:internal_id => 7996)
HTTPI GET request to webservices.netsuite.com (net_http)
HTTPI POST request to webservices.netsuite.com (net_http)
NetSuite::RecordNotFound: NetSuite::Records::SalesOrder with OPTIONS={:internal_id=>7996} could not be found
from /Users/pkatepalli/.rvm/gems/ruby-1.9.3-p448/gems/netsuite-0.2.0/lib/netsuite/actions/get.rb:73:in `get'
from (irb):8
from /Users/pkatepalli/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/commands/console.rb:47:in `start'
from /Users/pkatepalli/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/commands/console.rb:8:in `start'
from /Users/pkatepalli/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:5:in `require'
from script/rails:5:in `<main>'
1.9.3p448 :009 > customer = NetSuite::Records::CashSale.get(:internal_id => 7996)
HTTPI GET request to webservices.netsuite.com (net_http)
HTTPI POST request to webservices.netsuite.com (net_http)
NetSuite::RecordNotFound: NetSuite::Records::CashSale with OPTIONS={:internal_id=>7996} could not be found
from /Users/pkatepalli/.rvm/gems/ruby-1.9.3-p448/gems/netsuite-0.2.0/lib/netsuite/actions/get.rb:73:in `get'
from (irb):9
from /Users/pkatepalli/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/commands/console.rb:47:in `start'
from /Users/pkatepalli/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/commands/console.rb:8:in `start'
from /Users/pkatepalli/.rvm/gems/ruby-1.9.3-p448/gems/railties-3.2.12/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:5:in `require'
from script/rails:5:in `<main>'
这有效:
1.9.3p448 :010 > customer = NetSuite::Records::Customer.get(:internal_id => 7996)
HTTPI GET request to webservices.netsuite.com (net_http)
HTTPI POST request to webservices.netsuite.com (net_http)
答案 0 :(得分:3)
当NS gem生成SOAP XML时,它实际上是添加了一个不正确的类型:
<env:Body>
<platformMsgs:get>
<platformMsgs:baseRef xsi:type="platformCore:RecordRef" internalId="130619" type="transaction"/>
</platformMsgs:get>
</env:Body>
type ='transaction'被正确报告为错误。当您查看Schema Browser时,可以单击左上方框架中的'[types]来查找'platform core.xsd'。然后单击左下方框中显示的“RecordType”链接。
单击RecordType后,右侧框架中将显示RecordTypes列表。滚动浏览此列表时,您将看到它不包含“事务”条目。
但是,NetSuite::Records::Transaction
类似乎只是SalesOrder
类的包装器。
当我在控制台中运行以下内容时,所有事务(即销售)数据都在SalesOrder
对象中返回:
NetSuite::Records::SalesOrder.get(interal_id: 1234)
长话短说,如果你只需要抓住一个交易(与搜索交易相比,你记得确实有效),你的应用和要求是否允许你只使用SalesOrder
类?
答案 1 :(得分:3)
您无法提取交易记录 - 您必须提取特定的类型或交易记录。某些类型包括:Invoice,SalesOrder和CashSale。
尝试访问以下网址:
https://system.netsuite.com/app/accounting/transactions/transaction.nl?id=3820
这可以让您了解记录的事务类型。如果是发票,您可以使用以下方式检索它:
NetSuite::Records::Invoice.get(1234)
以下是NS交易流程的一些粗略说明。其中一些可能是我们的实例特有的,但其中大部分都适用于NS作为一个整体,可能对您或其他试图拼凑NS如何工作的人有所帮助。