I want to transform this input in unit, for example now if I type 10 it calculates 10 cents, I want that when I type 10 it will answer me with 10€
<b-form-input id="amount_input" type="number" v-model="form.contract.reward_cents" :state="validate(form.contract.reward_cents)"/>
</b-form-group>
How can i do with vuejs?
Related
I am showing a float variable in a Qweb report:
<t-set="my_qweb_float_variable" t-value="4.0"/>
<span t-esc="'%.4f'% my_qweb_float_variable"/>
I want to round it with the decimal precision of Product Price. I am rounding it to 4 digits because I know that Product Price has a decimal precision of 4 digits, but the right way would be to get the precision value from the record stored in the decimal_precision table, just in case users change it.
Any ideas?
You can get decimal_precision table value this way:
<t t-set="decimal_precision" t-value="request.env['decimal.precision'].precision_get('Product Price')"/>
Then when you print the value of decimal_precision variable, it will show the browsable object of decimal.precision model.
And then you can get your field value this way:
<t t-esc="my_qweb_float_variable" t-options='{"widget": "float", "precision": decimal_precision}'/>
I hope this will helps you. Thank you.
It need integer number for precision value otherwise it will fail.
Following is a example of 2 decimal precision in QWEB report.
Correct:
<t t-esc="my_qweb_float_variable" t-options='{"widget": "float", "precision": 2}'/>
Wrong:
<t t-esc="my_qweb_float_variable" t-options='{"widget": "float", "precision": 2.0}'/>
I have got so far by using soup.findAll('span')
<span data-reactid="12">Previous Close</span>,
<span class="Trsdu(0.3s) " data-reactid="14">5.52</span>,
<span data-reactid="17"></span>,
<span class="Trsdu(0.3s) " data-reactid="19">5.49</span>,
<span data-reactid="38">Volume</span>,
<span class="Trsdu(0.3s) " data-reactid="40">1,164,604</span>,
...
I want a tabkle that shows me
Open 5.49
Volume 1,164,604
...
I tried soup.findAll('span').text but it gives error msg:
ResultSet object has no attribute 'text'. You're probably treating a list of items like a single item. Did you call find_all() when you meant to call find()?
this is the source:
https://finance.yahoo.com/quote/gxl.ax?p=gxl.ax
Luckily the error gives us a hint:
You're probably treating a list of items like a single item. Did you call find_all() when you meant to call find()?
Try one of these:
soup.findAll('span')[0].text
soup.findAll('span')[i].text
soup.find('span').text
This is a generic problem when navigating many selector systems, CSS selectors included. To operate on an element it must be a single element rather than a set. findAll() returns a set (array), so you can either index into that array (e.g. [i]) or find the first match with find().
soup.findAll('span') will return object/elements in ResultSet. You'd have to iterate through those to print the text. So try:
spans = soup.findAll('span')
for ele in spans:
data = ele.text
print(data)
To take your output and put into a dataframe:
your_output = ['Previous Close', '5.52', 'Open', '5.49', 'Bid', 'Ask', "Day's Range", '52 Week Range', 'Volume', '1,164,604', 'Avg. Volume', '660,530']
headers = your_output[::2]
data = your_output[1::2]
df = pd.DataFrame([data], columns = headers)
Additional
You certainly can use BeautifulSoup to parse and throw into a dataframe by iterating through the elements. I would like to offer an aleternative to BeautifulSoup.
Pandas does most of the work for you if it can identify tables within the html, by using .read_html. You can achieve the dataframe type of table you are looking for using that.
import pandas as pd
tables = pd.read_html(url)
df = pd.concat( [ table for table in tables ] )
Output:
print (df)
0 1
0 Previous Close 5.50
1 Open 5.50
2 Bid 5.47 x 0
3 Ask 5.51 x 0
4 Day's Range 5.47 - 5.51
5 52 Week Range 3.58 - 6.49
6 Volume 634191
7 Avg. Volume 675718
0 Market Cap 660.137M
1 Beta (3Y Monthly) 0.10
2 PE Ratio (TTM) 31.49
3 EPS (TTM) 0.17
4 Earnings Date NaN
5 Forward Dividend & Yield 0.15 (2.82%)
6 Ex-Dividend Date 2019-02-12
7 1y Target Est 5.17
I'm currently working on a report where I'm given 3 different datasets. The report essentially calculates the input, output and losses of a given food production process.
In dataset "Spices", contains the quantity of spices used under a field named "Qty_Spice". In dataset "Meat", contains the quantity of meat used under a field named "Qty_Meat". In dataset "Finished", contains the quantity of finished product used under a field "Qty_Finished".
I'm currently trying to create a table where the amount of input (spice+meat) is compared against output (finished product), such that the table looks like this:
Sum of Inputs (kg) | Finished Product (kg) | Losses (kg)
10 8 2
8 5 3
Total:
18 13 5
What I'm currently doing is using lookupset to get all inputs of both spices and meats (using lookupset instead of lookup because there are many different types of meats and spices used), then using a custom code named "Sumlookup" to sum the quantities lookupset returned.
The problem I'm having is that when I want to get the total sum of all inputs and all finished products (bottom of the table) using "Sumlookup" the table is only returning the first weight it finds. In the example above, it would return, 10, 8 and 2 as inputs, finished products and losses respectively.
Does anyone know how I should approach solving this?
Really appreciate any help
Here is the custom code I used for SumLookUp:
Public Function SumLookup(ByVal items As Object()) As Decimal
Dim suma As Decimal = 0
For Each item As Decimal In items
suma += item
Next
Return suma
End Function
I just want to ask on how to solve my problem.
On my report window, 2 computed fields:
1. A field that computes for decimal and I am displaying it to two decimals only (no problem on the display).
2. On my other computed field, I use the result of the first computed field to be multiplied to a certain number. The problem is here, because the value being multiplied is not the value being displayed from the first field. Instead it uses the whole amount.
Scenario:
2,055,232.135 is the computed value and id displays 2,055,232.14 which is good.
But if i multiply it to 9 (2055232.135 * 9), the result is 18,497,089.215 which will be displayed as 18,497,089.22
The problem is I want that the displayed value (2,055,232.14) to be multiplied to 9 (2055232.14 * 9) which will then results to 18,497,089.26
I only wanted to achieve the 2nd value for the computed field so that if the user computes for it, it will be equal.
The following solution can be used in a computed field:
String( Truncate( 2055232.135 * 9, 2), "#,##0.00")
I have the following layout when on a large display:
AAA BBB
AAA CCC
(all A's, all B's, and all C's form one div, so there are 3 elements here)
Now when this collapses I want it to become
BBB
AAA
AAA
CCC
I tried specifying the elements in this order in the HTML, but then the best I could manage to get for the expanded view was (using .push-X classes)
AAA BBB
AAA
CCC
The only solutions I can think of are moving things around by JS, or having duplicates of CCC at the correct position and showing and hiding them depending on viewport size.
Is there a cleaner way to do this?
<div class="row">
<div class="col-xs-12 col-md-6 col-md-push-6">BBB</div>
<div class="col-xs-12 col-md-6 col-md-pull-6">AAA</div>
<div class="col-xs-12 col-md-6 ">AAA</div>
<div class="col-xs-12 col-md-6 ">CCC</div>
</div>
That will work.
How is it done?...
Firstly you need to arrange your content first and foremost for mobile (so consider mobile the 'natural' order i.e.
BBB
AAA
AAA
CCC
Then, when you expand to desktop you'll get this:
BBB AAA <--- wrong order
AAA CCC
So, you then need to swap the order by pushing the BBB content to the right, and pulling the AAA content to the left
BBB------>.
.<------AAA