I'm creating a new view for a customized PoS module for my restaurant. It's a specific view for kitchen, already filtered to show just kitchen's related items of a PoS order.
Now I would like to show a particular series of product with the name starting with "#" in a field populated by a function side by side with the "standard" products. In fact I'm speaking of a set of instructions coded as products to be available on PoS and to suit my needs I decided to create kitchen instructions as a product (service). In my PoS there are 3 categories that are not products but instructions (ADD, SUBTRACT, ADDITIONAL NOTE).
A typical order will show as:
Product Quantity
[1007] Pom. Secchi 1
# + Búfala 1
# - Mussarela 1
[2002] Nutella banana 1
# + Mussarela 1
What I would like to archive is a view like:
Product Note Quantity
[1007] Pom. Secchi # + Búfala # - Mussarela 1
[2002] Nutella banana # + Mussarela 1
I need to select just the strings starting with the "#" between two internal code starting with "[code]" and this is the hard thing to do. I don't need to delete the values I "move" because I need the stock view when I print the receipt.
I will call this function using python (and psycopg2 on postgresql 9.4) with on_change or extending the workflow when an order is marked as "paid". I don't think if doing it directly in Python is viable.
I've tried with string_agg(,) but with bad results.
Any tips about what should be the correct path to start coding? Thanks.
Related
Screenshot 2The one screen shot of this errorissue I am building an app using api.ai , an syllabus app which tells you the syllabus, but when I invoke it with desired parameters like branch and semester I have made each individual intent for it even then I'm getting miss answers sometimes like when asked for sem 4 and branch electronics its showing sem 3 sem 4 or of other branch . I have given sem and branch as required n given few invoking statements even then getting this. Tried even training it manually for free 30s of actions on api.ai no solution please help. Not using any web hook , context , event.
Short answer - check here for screenshots http://imgur.com/a/tVBlD
Long answer - You have two options
1) Create 3 separate custom entities for each branch type (computer science, civil, communication) which you need to attach to your branch parameter
2) Using the sys.any entity and attaching it to your branch parameter; then determining what the incoming parameter value is on a server then sending back a response through a webhook.
If you go the second route, you have to create a webhook and hardcode recognized words like 'computer science' in IF statements which check the incoming parameter (sent through JSON from API.AI). This route will be more difficult but I think you will have to travel it regardless because you will have backend architecture which you access to find and return the syllabus.
Note the second route is what I did to solve a similar issue.
You can also use regex to match an item in a list which limits the amount of hardcoding and if statements you have to do.
Python regex search example
baseurl = "http://mywebsite.com:9001/"
# Parse the document
# Build the URL + File Path and Parse the Document
url = baseurl + 'Data'
xmlLink = urllib.request.urlopen(url)
xmlData = etree.parse(xmlLink)
xmlLink.close()
# Find the number of elements to cycle through
numberOfElements = xmlData.xpath("count(//myData/data)")
numberOfElements = int(numberOfElements)
types = xmlData.xpath("//myData/data")
# Search the string
i = 0
while numberOfElements > i:
listSearch= types[i].text
match = re.search(parameter, listSearch, re.IGNORECASE)
if match is None:
i += 1
else:
# Grab the ID
elementID = types[i].get('id')
i = 0
break
An simple trick would be what i did, just have an entity saved for both branch and semester , use sys.original parameters and an common phrase for provoking each intent saves up the hard work.
5250 emulator:
Hello everyone, I want an operator which will count that input fields as it is shown on attached picture. In this case i have 5 input field.
Thanks in advance and best regards
It can be done!
Download this source: http://www.code400.com/ffd.php
You can comment out the GETKEY section from FFDRPG as you won't need that and it will probably cause it to fall over anyway.
Also, rememember when you use the command, to put the record format name in as well as your display file name - don't just leave *FIRST in there or you'll just get the fields from the first record format in the display file.
EDIT:
You'll need to add an extra field to the ListDs data structure:
D ListDs DS
D SfFld 1 10
D SfType 11 11
D SfUse 12 12
D BufferOut 13 16B 0
D FieldLen 21 24B 0
D Digits 25 28B 0
D Decimals 29 32B 0
D FieldDesc 33 82
If you add the 3rd field SfUse, you can check whether it contains 'I' so you only count Input Capable fields.
Check out the QUSLFLD API https://www.ibm.com/support/knowledgecenter/en/ssw_i5_54/apis/quslfld.htm if you want to see exactly what information can be retrieved by this API.
The example in the download uses the most basic format FLDL0100 but more information can be retrieved if you ask for format FLDL0200 or FLDL0300 but they will take longer to execute and you shouldn't need the extra info to achieve what you're after.
I'm not sure if this is possible, but you might find some joy with the DSM APIs.
QsnQry5250 has a maximum number of input fields return parameter, but it may just show you the maximum allowed on the display rather than the number you have on your screen.
There's an example here https://www.ibm.com/support/knowledgecenter/en/ssw_i5_54/apis/dsm1g.htm
And the API documentation here https://www.ibm.com/support/knowledgecenter/en/ssw_ibm_i_72/apis/QsnQry5250.htm
Sorry I can't be of more help - I've never used those APIs and can't think of another way to achieve what you're after.
If you tell us the reason you need to know the number of input fields on screen, we may be able to suggest another way to achieve what you want to achieve.
Damian
I'm working with the dashing ruby gem and I would really like to combine elements of the graph and number widgets. I would like all elements of the graph and include the up/down percentage arrow from the number widget.
I've never done much work with ruby and I understand there are a few files within the widget that might need to be changed.
I've setup a few nice widgets and I'm using a job to pull data from a redis db to populate. I've added the following to the graph.html page:
<p class="change-rate">
<i data-bind-class="arrow"></i><span data-bind="difference"></span>
</p>
This has no effect, and I'm sure that I'm missing something in one of the many files that makes this all work.
Your on the right track, and I've actually put together something very similar but in order to complete what you are trying to do you need to send data to your two new data binds, which would be done with your jobs file and the graph.coffee file.
I'm not sure how exactly you're getting your graph data from redis to your jobs erb file but you will want to setup a couple new variables, for the example I have used nowNumber and lastNumber. These will be the number that the valuation is performed on.
jobs/jobname.erb
send_event('graph', points: points, current: nowNumber, last: lastNumber )
If you print this out you will get something like this:
{:points=>[{:x=>6, :y=>64}, {:x=>5, :y=>62}, {:x=>4, :y=>56}], :current=>57, :last=>64}
Tweak your graph/graph.coffee file:
# The following 6 lines aren't needed for your solution, but if you wanted to take advantage of 'warning', 'danger', and 'ok' status classes (changes background color and flashes), just feed your send_event with 'status: [one of the three status names]
if data.status
# clear existing "status-*" classes
$(#get('node')).attr 'class', (i,c) ->
c.replace /\bstatus-\S+/g, ''
# add new class
$(#get('node')).addClass "status-#{data.status}"
#accessor 'difference', ->
if #get('last')
last = parseInt(#get('last'))
current = parseInt(#get('current'))
if last != 0
diff = Math.abs(Math.round((current - last) / last * 100))
"#{diff}%"
else
""
# Picks the direction of the arrow based on whether the current value is higher or lower than the last
#accessor 'arrow', ->
if #get('last')
if parseInt(#get('current')) > parseInt(#get('last')) then 'icon-arrow-up' else 'icon-arrow-down'
I have an excel file, which initially imports stock data from our cloud based accounting program through .iqy web query.
The column headings are:
A1= Quantity B1= Item C1= Description D1= Bin Code
Now I have created a macro which;
Referesh's the data
Range("A1").QueryTable.Refresh False
Delete's all zero stock items
Dim intRow
Dim intLastRow
intLastRow = Range("A65536").End(xlUp).Row
For intRow = intLastRow To 1 Step -1
Rows(intRow).Select
If Cells(intRow, 1).Value = 0 Or Cells(intRow, 1) = "" Then
Cells(intRow, 1).Select
Selection.EntireRow.Delete
End If
Next intRow
Auto Sort by Bin Code
Range("A1:D1").Select
Selection.AutoFilter
Range("A2").Select
Range("A1:D1668").Sort Key1:=Range("D1"), Order1:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Save the Master list
Dim sFileName As String, sPath As String
sPath = "C:\stock\ms\Master List "
sFileName = Format(Now(), "dd'mm'yy")
ActiveWorkbook.SaveAs (sPath & sFileName)
Now this is the tricky bit,
At least 30 items a day need to be checked, however a bin can not be incomplete! So once 30 items have been selected the script needs to check to see if the next item is in the same bin as the 30th item, and include this in the extraction. So lets say item 30 is in bin 10A2, and also item 31, 32, 33, 34, so all in all 34 items (rows) need to be extracted into a new workbook and saved.
This process must start from the previous days sample, so the mechanics should go like this:
look in c\stock\sl\Sample List -1 dd'mm'yy sample list for -1 day, look at the last item bin number, say 10A1,
take the next rows bin number, 10A2,
from the first row which has 10A2, select 30 rows,
Continue till the bin number changes.
save that file as Sample List dd'mm'yy in c\stock\sl\
email Sample List dd'mm'yy to NNN#NNN.com
This should be able to repeat. Also on Saturday and Sunday the company is not open, so on mondays it should look back on friday, and so forth, also accounting for public holidays.
Any help with this would be a life saver? I don't mind if you want to change the file names so that this issue with holidays can be addressed. However, somewhere a time stamp needs to be placed for the files.
You might want to check out the Dictionary object, it would probably help in this task. If you have any questions along the way ask another question. Not sure if someone else would want to give you a more thorough answer to this question.
Your project might be big enough that you would want to work with classes too.
Please avoid every Select in your code.
For instance,
Range("A1:D1").Select
Selection.AutoFilter
can be replaced by:
Range("A1:D1").AutoFilter
I'm making a code generation script for UN/LOCODE system and the database has unique 3 letter/number codes in every country. So for example the database contains "EE TLL", EE being the country (Estonia) and TLL the unique code inside Estonia, "AR TLL" can also exist (the country code and the 3 letter/number code are stored separately). Codes are in capital letters.
The database is fairly big and already contains a huge number of locations, the user has also the possibility of entering the 3 letter/number him/herself (which will be checked against the database before submission automatically).
Finally neither 0 or 1 may be used (possible confusion with O and I).
What I'm searching for is the most efficient way to pick the next available code when none is provided.
What I've came up with:
I'd check with AAA till 999, but then for each code it would require a new query (slow?).
I could store all the 40000 possibilities in an array and subtract all the used codes that are already in the database... but that uses too much memory IMO (not sure what I'm talking about here actually, maybe 40000 isn't such a big number).
Generate a random code and hope it doesn't exist yet and see if it does, if it does start over again. That's just risk taking.
Is there some magic MySQL query/PHP script that can get me the next available code?
I will go with number 2, it is simple and 40000 is not a big number.
To make it more efficient, you can store a number representing each 3-letter code. The conversion should be trivial because you have a total of 34 (A-Z, 2-9) letters.
I would for option 1 (i.e. do a sequential search), adding a table that gives the last assigned code per country (i.e. such that AAA..code are all assigned already). When assigning a new code through sequential scan, that table gets updated; for user-assigned codes, it remains unmodified.
If you don't want to issue repeated queries, you can also write this scan as a stored routine.
To simplify iteration, it might be better to treat the three-letter codes as numbers (as Shawn Hsiao suggests), i.e. give a meaning to A-Z = 0..25, and 2..9 = 26..33. Then, XYZ is the number X*34^2+Y*34+Z == 23*1156+24*34+25 == 27429. This should be doable using standard MySQL functions, in particular using CONV.
I went with the 2nd option. I was also able to make a script that will try to match as close as possible the country name, for example for Tartu it will try to match T** then TA* and if possible TAR, if not it will try TAT as T is the next letter after R in Tartu.
The code is quite extensive, I'll just post the part that takes the first possible code:
$allowed = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ23456789';
$length = strlen($allowed);
$codes = array();
// store all possibilities in a huge array
for($i=0;$i<$length;$i++)
for($j=0;$j<$length;$j++)
for($k=0;$k<$length;$k++)
$codes[] = substr($allowed, $i, 1).substr($allowed, $j, 1).substr($allowed, $k, 1);
$used = array();
$query = mysql_query("SELECT code FROM location WHERE country = '$country'");
while ($result = mysql_fetch_array($query))
$used[] = $result['code'];
$remaining = array_diff($codes, $used);
$code = $remaining[0];
Thanks for your opinion, this will be the key to transport codes all over the world :)