IF Statement with Number Range on Netsuite PDF/HTML Template - pdf

I need to specify default shipping method, for when none is provided on the entry form in Netsuite. For various reasons I have to do this within the PDF/HTML template.
This is the code I have so far, but it doesn't seem to work;
<#function toNumber val>
<#if val?has_content && val?length gt 0 >
<#return val?html?replace('[^0-9.]','','r')?number >
<#else><#return 0 ></#if></#function>
<#if record.shipmethod?has_content>
${record.shipmethod} <!-- if a courier is selected -->
<#else> <!-- else -->
<#list 2000..2560 as pcx> <!-- Sydney Metro postcodes -->
<#if toNumber(record.shipzip)==pcx>
Courier1 <!-- Standard Sydney Metro Courier -->
<#else> <!-- else -->
Courier2 <!-- Standard Interstate Courier -->
</#if></#list></#if>

Your loop is going to print something each time it runs (i.e. 560 lines)! Instead of looping through the numbers, you should to test if the zip code falls within a desired range using the lte (less than or equal to) and gte (greater than or equal to) comparison operators:
<#function toNumber val>
<#if val?has_content && val?length gt 0 >
<#return val?html?replace('[^0-9.]','','r')?number >
<#else><#return 0 ></#if></#function>
<#assign zip = toNumber(record.shipzip)>
<#if record.shipmethod?has_content>
${record.shipmethod}
<#elseif zip gte 2000 && zip lte 2560 >
Courier 1
<#else>
Courier 2
</#if>

Related

How to send text into br element using Selenium

I am trying to make a tiktok bot, but I am having issues entering in text to their caption section(see screenshot below). I've tried using wait till element clickable function, but for some reason I can not use selenium to detect this element, would anyone have any suggestions on how to go about this, thank you in advance :)
My current code is below:
driver.get("https://www.tiktok.com/upload?lang=en")
try:
element = WebDriverWait(driver, waittime).until(EC.element_to_be_clickable((By.CSS_SELECTOR, '#root > div > div > div > div > div.jsx-410242825.contents-v2 > div.jsx-2580397738.form-v2 > div.jsx-2580397738.caption-wrap-v2 > div > div:nth-child(1) > div.jsx-1717967343.margin-t-4 > div > div.jsx-1043401508.jsx-723559856.jsx-1657608162.jsx-3887553297.icon-style.hash')))
except:
driver.quit()
element.click()
try:
element = WebDriverWait(driver, waittime).until(EC.presence_of_element_located((By.CSS_SELECTOR, '#root > div > div > div > div > div.jsx-410242825.contents-v2 > div.jsx-2580397738.form-v2 > div.jsx-2580397738.caption-wrap-v2 > div > div:nth-child(1) > div.jsx-1717967343.margin-t-4 > div > div.jsx-1043401508.jsx-723559856.jsx-1657608162.jsx-3887553297.editor > div > div > div > div > div > div > span > span > span')))
except:
driver.quit()
element.clear()
element.send_keys(mainCaption)
Element snapshot:
HTML <br> Tag
The <br> tag inserts a single line break. The <br> tag is an empty tag which means that it has no end tag and is useful for writing addresses or poems to enter line breaks, not to add space between paragraphs. Hence, you can't send any text within a <br> element.
Presumably, <br> tags will have parent/ancestor <p> tags. As an example:
<p>Be not afraid of greatness.<br>
Some are born great,<br>
some achieve greatness,<br>
and others have greatness thrust upon them.</p>
<p><em>-William Shakespeare</em></p>
So in these cases you need to target the parent/ancestor <p> tags to send the text.

beautifulsoup: get text (including html tags) between two different tags (</h3> and <h2>)

I am trying to scrape an html file structured as follow using beautifulsoup. Basicaly, each unit is constisted of:
one <h2></h2>
one <h3></h3>
more than one <p></p>
Something like follow:
<h2>January, 2020</h2>
<h3>facility</h3>
<p>text1-1</p>
<p>text1-2</p>
<h2>April, 2020</h2>
<h3>scientists</h3>
<p>text2-1</p>
<p>text2-2</p>
<h2>June, 2020</h2>
<h3>lawyers</h3>
<p>text3-1</p>
<h2>.....
I want to get text including the <p> tags between </h3> and the next <h2>. The result should be:
for row #1:
<p>text1-1</p>
<p>text1-2</p>
for row #2:
<p>text2-1</p>
<p>text2-2</p>
for row #3:
<p>text3-1</p>
Here is what I tried so far:
num_h2 = len(soup.find_all('h2'))
for i in range(0,num_h2):
print('---------')
print(i)
p_string = ''
sibling = soup.find_all('h3')[i].find_next_sibling('p').getText()
if sibling:
p_string += sibling
else:
break
print(p_string)
The problem with this solution is that it only shows the content of the first <p> under each unit. I do not know how to find how many <p> are there to generate a for loop. Also, is there a better way to do this than using find_next_silibing()?
Maybe css selectors can help:
for s in soup.select('h3'):
for ns in (s.fetchNextSiblings()):
if ns.name == "h2":
break
else:
if ns.name == "p":
print(ns)
Output:
<p>text1-1</p>
<p>text1-2</p>
<p>text2-1</p>
<p>text2-2</p>
<p>text3-1</p>

What's the difference between the `&` and `&&` in Vue.js? [duplicate]

This question already has answers here:
What's the difference between & and && in JavaScript?
(4 answers)
Closed 4 years ago.
What's the difference between the & and && in Vue.js?
I test the:
<span
v-if="1 > 0 & 2 > 1"
>
span
</span>
and
<span
v-if="1 > 0 && 2 > 1"
>
span
</span>
both the text span will show.
So is there some difference between them in Vue.js?
They have the same type of logic. 0101 & 1010 = 0000. However && will not valuate the second one if the first on is false, it will always consider the second one true..
try this
<span
v-if="1 > 3 && 2 > 3"
>
span
</span>

Insert an if statement in go tmpl range

In my project, in the index.tmpl file is the range function defined: {{ range $index, $jb := .Jailbreaks }} which iterates through the Jailbreaks array.
I was wondering if there is a way to check if the $index is on a defined position. So for this I tried {{ if $index == 0 }} but on compiling I get the error
Error rendering index template: template: index.tmpl:63: unexpected "=" in operand
Do I have to define a function in the main.go file to complete this task?
I am working with this project for everyone who is wondering.
You are looking for {{ if eq $index 0 }}. See https://golang.org/pkg/text/template/#hdr-Actions and https://golang.org/pkg/text/template/#hdr-Functions.

How to check if a float is lesser than 0 in QWEB report

I want to know if there is a special keyword as alternative to > in QWEB report.
I found gt (maps to >) but it shows the following error message:
QWebException: invalid syntax (, line 1)
Code:
<t t-if="total gt 0">
<t t-esc="total"/>
</t>
You need to use html codes or in this situation you can use the named codes, too.
> = > = >
< = < = <