Open paulbalomiri opened 11 years ago
Am pus pe server o varianta preliminara. Ruleaza asta:
node /home/andrei/display_bill/display_bill.js
Functioneaza dar e putin barbar. Discutam cum mai modificam structura in products.json
si order.json
.
Salut,
M-am uitat peste script, si imi pare corect. Pentru production mai trebuiesc implementate urmatoarele schimbari:
Structura (EBNF) , majuscute = terminal:
name= PRODUCT | PRODUCT , optionlist
optionlist= option | optionlist , SI, option
option = CU OPTIONNAME | CU numeric OPTIONNAME
Structura asta trebuie tradus pe un pom corespunzator. Exemplu: stiuca batuta, 1 supa(3 incluse) , 5 tacamuri(2) incluse, 1 sos(1 inclus)
|-------------.
| name |
|.............|
,__________..='_ `._
|PRODUCT | ,''''|
|stiuca batuta | .'|AND |
'`'''''''''''''' .' '`'''`.
,_________.'_ `-.
| SUPA | ,''''|
| qty:1,inc:3| |AND |
'`''''''''''' .-'''-.
.-' `.
,_____.='____ ,____`=._____
| TACAMURI | | SOS |
| qty:5,inc:2| | qty:1,inc:1|
'`''''''''''' '`'''''''''''
Pomul se rezolva recursiv intr-un set de functii (localizabile):
|-------------.
| name |
|.............|
,__________..='_ `._
|PRODUCT | ,''''|
|stiuca batuta | .'|AND |
'`'''''''''''''' .' '`'''`.
,_________.'_ `-.
| SUPA | ,'''''''''''''''|
| qty:1,inc:3| | cu 3 tacamuri |
'`''''''''''' | suplimentare |
`...............|
In final dupa ce pomul a fost rezolvalt recursiv va trebui sa rezulte stiuca batuta cu 2 supe si cu 3 tacamuri
A Python Testsuite, named test_javascript.py is available to ease with quick testcase generation in the project libs/maivic-mobilpay-server.
In order to use it Python PyV8 and all it's dependencies must be installed.
The testsuite accepts tests from the directory https://github.com/bic/maivic-server/blob/master/libs/maivic-mobilpay-server/res/javascript and executes the function with the same name from the same named file like this:
<test_function>.js
: the file containing the js function named test_functiontests/<test_function>_input_<n>.js
: This file activates the test. n is a number, starting with one which identifies the input dataset
test_function(arg[0],arg[1],...)
where arg is eval(content)
content being the file contents from tests/res/javavascript/
which do not have a corresponding input file in res/javavascript/
are not considered Testsres/javavascript/tests/gen/<test_function>_<n>_output_generated_<r>.js
n
is as above the test numberr
is the sequence number of the runner, which increases each time a test is executed, and decreases only if files are removed from the res/javascript/tests/gen
directory.res/javavascript/tests/<test_function>_<n>_output_expected.js
is the expected output which is tested for equality. Note that the implementation is suboptimal, as it is really checked for the equality of the python mapping, which sees reorderings in arrays as different output. Once a usecase and test is found this feature can be implemented.
A function regenerating the table containing the ordered items and their prices
The function display_bill is a wrapper around calculate_bill_items() and display_bill_table()
display_bill(order, use_callbacks)
Within the function table_content is created by _calculate_billitems and consumed by _display_billtable, both functions being described below
The table_content variable used in the example above can be anything as long as it contains
calculate_bill_items(order,products)
This function calculates the contents of the table as displayed in the "Nota de plata detaliata" part of the order view (See #21 )
Return value condition: the JSON structure must contain a "total" and a "tips" entry both having stringified currency values
The function must match the ids supplied in the order against the per offer options and the global options.
In the table the product and the options are listed one beneath the other with their respective prices also being listed independently
offer_changer mechanism
In the case of a offer option having the "offer_changer":"true" in their description the following names can be formed:
In case the orders.offers[id=a].qty >1 the included options are also multiplied. Example:
in this case the bill shall contain:
display_bill_table(table_content, table_id);
This function displays the table content as supplied in table_content
See #21 for the way the table shall be structured.
CSS
The page shall contain the needed css, as the page will not be loaded using whe web, and thus has no possibility to load additional content.