Advertisement
Guest User

Untitled

a guest
Nov 4th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Erlang 1.36 KB | None | 0 0
  1. SanitizeAllSerials=
  2. fun()->
  3. {ok,InventoryLocations}=db_functions:get_all_data(inventory_location,record),
  4. lists:map(
  5. fun(InventoryLocation)->
  6. Barcode=erlang:binary_to_list(hd(erlang:element(3,InventoryLocation))),
  7. ReferenceId=element(2,InventoryLocation),
  8. InventoryLocation1=erlang:setelement(3,InventoryLocation,[re:replace(Barcode,"IMEI","",[{return,binary}])]),
  9. db_functions:db_create_or_update_term(inventory_location,ReferenceId,InventoryLocation1,[])
  10. end,InventoryLocations)
  11. end,
  12.  
  13. FixAllEntries=
  14. fun()->
  15. {ok,InventoryLocations}=db_functions:get_all_data(inventory_location,record),
  16. lists:map(
  17. fun(InventoryLocation)->
  18. Metadata=inventory_location:get_metadata(InventoryLocation),
  19. ReferenceId=element(2,InventoryLocation),
  20. db_functions:db_create_or_update_term(inventory_location,ReferenceId,InventoryLocation,Metadata)
  21. end,InventoryLocations)
  22. end.
  23.  
  24. GetContainerSerials=
  25. fun()->
  26. {ok,ItemSerials}=inventory_location:search_by([{master_data_type,equal,item}],record),
  27. lists:map(
  28. fun(ItemSerials)->
  29. A=[hd(element(3,ItemSerials)),element(6,ItemSerials),element(9,ItemSerials)],
  30. A
  31. end,ItemSerials)
  32. end.
  33.  
  34. UpdateBarcode1=
  35. fun(Ref,Barcode)->
  36. {ok,InventoryLocation}=inventory_location:get_by_id(Ref),
  37. InventoryLocation1=erlang:setelement(3,InventoryLocation,[Barcode]),
  38. db_functions:db_create_or_update_term(inventory_location,Ref,InventoryLocation1,[])
  39. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement