首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >准确在线库存地点的库存数量

准确在线库存地点的库存数量
EN

Stack Overflow用户
提问于 2016-11-07 15:59:46
回答 1查看 117关注 0票数 0

使用以下查询,我发现对于具有库存位置的项,有多个行从精确在线的REST返回:

代码语言:javascript
复制
select spn.item_code_attr || '-' || spn.warehouse_code_attr || '-' || stn.code key 
,      itm.itemgroupcode
,      itm.itemgroupdescription
,      spn.item_code_attr
,      spn.item_description
,      spn.currentquantity
,      spn.planning_in
,      spn.planning_out
,      spn.currentquantity + spn.planning_in - spn.planning_out plannedquantity
,      -1 bestelniveau /* out of scope */
,      itm.costpricestandard costprijs
,      itm.costpricestandard * spn.currentquantity stockvalue
,      spn.warehouse_code_attr
,      stn.code locatie
,      itm.unitcode UOM
, itm.id
, whe.id
, sln.stock
, sln.itemid
, sln.warehouse
, stn.id
from   exactonlinexml..StockPositions spn
join   exactonlinerest..items itm
on     itm.code = spn.item_code_attr
and    itm.code = 'LE-10242'
and    itm.isstockitem = 1
join   exactonlinerest..warehouses whe
on     whe.code = spn.warehouse_code_attr
left 
outer
join   exactonlinerest..stocklocations sln
on     sln.itemid = itm.id
and    sln.stock != 0
and    sln.warehouse = whe.id
left
outer
join   storagelocations stn
on     stn.id        = sln.storagelocation
and    stn.warehouse = sln.warehouse
--
-- Filter out no stock nor planned.
--
where  ( spn.currentquantity !=0
         or     
         spn.planning_in != 0
         or     
         spn.planning_out != 0
       )
and    spn.item_code_attr = 'LE-10242'
order 
by     key

例如,对于这个项目,有10个StockLocations。当我对字段股进行求和时,它返回在StockPositions中找到的库存量。但是,似乎每个事务都会创建一个额外的StockLocation条目。

我希望StockLocation能够包含库存中的每个位置--总数量。

编辑

StockLocations API在https://start.exactonline.nl/api/v1/{division}/logistics/$metadata中描述为:

代码语言:javascript
复制
<EntityType Name="StockLocation">
  <Key>
    <PropertyRef Name="ItemID"/>
  </Key>
  <Property Name="ItemID" Type="Edm.Guid" Nullable="false"/>
  <Property Name="Warehouse" Type="Edm.Guid" Nullable="true"/>
  <Property Name="WarehouseCode" Type="Edm.String" Nullable="true"/>
  <Property Name="WarehouseDescription" Type="Edm.String" Nullable="true"/>
  <Property Name="Stock" Type="Edm.Double" Nullable="true"/>
  <Property Name="StorageLocation" Type="Edm.Guid" Nullable="true"/>
  <Property Name="StorageLocationCode" Type="Edm.String" Nullable="true"/>
  <Property Name="StorageLocationDescription" Type="Edm.String" Nullable="true"/>
</EntityType>

不知怎么的,它没有在https://start.exactonline.nl/docs/HlpRestAPIResources.aspx上记录下来。

我做错了什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-11-18 15:57:28

与工程师讨论了关于黑客马拉松的问题。这是因为StockLocation API的工作原理;命名并不能最优地反映内容,但这是预期的行为。

使用select field, sum(stock) from stocklocations group by field,您可以获得正确的信息。

为了提高连接性能,建议为此(如select ... from table1 join table2 ... join ( select field, sum(stock) from stocklocations group by field) )使用内联视图。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40469360

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档