How to make an item always appear last on list (Netsuite Advanced PDF) - netsuite

I am trying to make an item appear last on the list if it appears on an in the invoice (Advanced PDF,NetSuite).
I was thinking bout trying to sort by and adding some ZZZs to the item name, but thats because I dont really know much outside of basic HTML.
Any Help would be appreciated.
Below is the table code I am dealing with.
<table class="itemtable" style="width: 100%; margin-top: 10px;"><!-- start items --><#list record.item as item><#if item_index==0>
<thead>
<tr>
<th align="center" colspan="3">${item.quantity#label}</th>
<th colspan="12">${item.item#label}</th>
<th colspan="3">${item.options#label}</th>
<th align="right" colspan="4">${item.rate#label}</th>
<th align="right" colspan="4">${item.amount#label}</th>
</tr>
</thead>
</#if><tr>
<td align="center" colspan="3" line-height="150%">${item.quantity}</td>
<td colspan="12"><span class="itemname">${item.item}</span><br />${item.description}</td>
<td colspan="3">${item.options}</td>
<td align="right" colspan="4">${item.rate}</td>
<td align="right" colspan="4">${item.amount}</td>
</tr>
</#list>
I need the to be able to choose a specific itemname to always show at the bottom.

You can use the assign tag to hold the values for your bottom item.
<#assign bottomItemName = 'Bottom Item Name'>
<#assign bottomItem = {}>
<#list record.item as item>
<#if item_index==0>
<thead>
<tr>
<th align="center" colspan="3">${item.quantity#label}</th>
<th colspan="12">${item.item#label}</th>
<th colspan="3">${item.options#label}</th>
<th align="right" colspan="4">${item.rate#label}</th>
<th align="right" colspan="4">${item.amount#label}</th>
</tr>
</thead>
</#if>
<#if item.item == bottomItemName>
<#assign bottomItem = bottomItem + item>
<#else>
<tr>
<td align="center" colspan="3" line-height="150%">${item.quantity}</td>
<td colspan="12"><span class="itemname">${item.item}</span><br />${item.description}</td>
<td colspan="3">${item.options}</td>
<td align="right" colspan="4">${item.rate}</td>
<td align="right" colspan="4">${item.amount}</td>
</tr>
</#if>
</#list>
<#if bottomItem.item??>
<tr>
<td align="center" colspan="3" line-height="150%">${bottomItem.quantity}</td>
<td colspan="12"><span class="itemname">${bottomItem.item}</span><br />${bottomItem.description}</td>
<td colspan="3">${bottomItem.options}</td>
<td align="right" colspan="4">${bottomItem.rate}</td>
<td align="right" colspan="4">${bottomItem.amount}</td>
</tr>
</#if>

You could try looping 2x.
<table class="itemtable" style="width: 100%; margin-top: 10px;"><!-- start items --><#list record.item as item><#if item_index==0>
<thead>
<tr>
<th align="center" colspan="3">${item.quantity#label}</th>
<th colspan="12">${item.item#label}</th>
<th colspan="3">${item.options#label}</th>
<th align="right" colspan="4">${item.rate#label}</th>
<th align="right" colspan="4">${item.amount#label}</th>
</tr>
</thead>
</#if><#if ${item.item}!="Your Item"><tr>
<td align="center" colspan="3" line-height="150%">${item.quantity}</td>
<td colspan="12"><span class="itemname">${item.item}</span><br />${item.description}</td>
<td colspan="3">${item.options}</td>
<td align="right" colspan="4">${item.rate}</td>
<td align="right" colspan="4">${item.amount}</td>
</tr>
</#list>
<#list record.item as item><#if ${item.item}=="Your Item"><tr>
<td align="center" colspan="3" line-height="150%">${item.quantity}</td>
<td colspan="12"><span class="itemname">${item.item}</span><br />${item.description}</td>
<td colspan="3">${item.options}</td>
<td align="right" colspan="4">${item.rate}</td>
<td align="right" colspan="4">${item.amount}</td>
</tr>
</#list>
I haven't tested the if statement, so good luck

Related

Python multiple if statements for petrol price movement

Situation:
I buy a certain volume of petrol at price X, which is usually sold within a 30 days. During these 30 days, I will need to adjust my petrol station gas price according to average State gas price. If State price goes up by 1.2% from my purchased price, I will set my price to +1% of my purchased price.
Here is an example:
<style type="text/css">
.tg {border-collapse:collapse;border-spacing:0;}
.tg td{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;
overflow:hidden;padding:10px 5px;word-break:normal;}
.tg th{border-color:black;border-style:solid;border-width:1px;font-family:Arial, sans-serif;font-size:14px;
font-weight:normal;overflow:hidden;padding:10px 5px;word-break:normal;}
.tg .tg-wa1i{font-weight:bold;text-align:center;vertical-align:middle}
.tg .tg-7zrl{text-align:left;vertical-align:bottom}
.tg .tg-0lax{text-align:left;vertical-align:top}
</style>
<table class="tg">
<thead>
<tr>
<th class="tg-wa1i">Time</th>
<th class="tg-wa1i">Average state gas price</th>
<th class="tg-wa1i">Av state price change, %</th>
<th class="tg-wa1i">My price change, %</th>
<th class="tg-wa1i">My station gas price</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tg-7zrl">1</td>
<td class="tg-0lax"> 4.231 </td>
<td class="tg-0lax"> - </td>
<td class="tg-0lax"> - </td>
<td class="tg-0lax"> 4.231 </td>
</tr>
<tr>
<td class="tg-7zrl">2</td>
<td class="tg-0lax"> 4.337 </td>
<td class="tg-0lax"> 2.5%</td>
<td class="tg-0lax"> 2.0%</td>
<td class="tg-0lax"> 4.316 </td>
</tr>
<tr>
<td class="tg-7zrl">3</td>
<td class="tg-0lax"> 4.437 </td>
<td class="tg-0lax"> 4.9%</td>
<td class="tg-0lax"> 4.0%</td>
<td class="tg-0lax"> 4.400 </td>
</tr>
<tr>
<td class="tg-7zrl">4</td>
<td class="tg-0lax"> 4.481 </td>
<td class="tg-0lax"> 5.9%</td>
<td class="tg-0lax"> 5.0%</td>
<td class="tg-0lax"> 4.443 </td>
</tr>
<tr>
<td class="tg-7zrl">5</td>
<td class="tg-0lax"> 4.571 </td>
<td class="tg-0lax"> 8.0%</td>
<td class="tg-0lax"> 8.0%</td>
<td class="tg-0lax"> 4.569 </td>
</tr>
<tr>
<td class="tg-7zrl">6</td>
<td class="tg-0lax"> 4.616 </td>
<td class="tg-0lax"> 9.1%</td>
<td class="tg-0lax"> 9.0%</td>
<td class="tg-0lax"> 4.612 </td>
</tr>
<tr>
<td class="tg-7zrl">7</td>
<td class="tg-0lax"> 4.709 </td>
<td class="tg-0lax"> 11.3%</td>
<td class="tg-0lax"> 11.0%</td>
<td class="tg-0lax"> 4.696 </td>
</tr>
<tr>
<td class="tg-7zrl">8</td>
<td class="tg-0lax"> 4.850 </td>
<td class="tg-0lax"> 14.6%</td>
<td class="tg-0lax"> 14.0%</td>
<td class="tg-0lax"> 4.823 </td>
</tr>
</tbody>
</table>
Here is a python code but it is very clunky, and if gas price moves up by 20%, then I have to write my_priceX up to 20 times. Is there a more elegant solution?
my_price1 = last_gas_price["price"]*1.01
my_price2 = last_gas_price["price"]*1.02
my_price3 = last_gas_price["price"]*1.03
my_price4 = last_gas_price["price"]*1.04
my_price5 = last_gas_price["price"]*1.05
if last_gas_price > my_price1:
adj_price(price = my_price1)
if last_gas_price > my_price2:
adj_price(price = my_price2)
if last_gas_price > my_price3:
adj_price(price = my_price3)
if last_gas_price > my_price4:
adj_price(price = my_price4)
if last_gas_price > my_price5:
adj_price(price = my_price5)

Check for vertical scrollbar in html local file

I have a VBA code that opens local HTML files using selenium like that
bot.Get "file:///" & Environ("USERPROFILE") & "\Desktop\OutputHTML.html"
Sometimes I got an error Out of memory as I am trying to take a screen shot for large size of the table (inside the HTML body)
Is it possible to check if there is a vertical scrollbar of the selenium browser and if there is a vertical scrollbar, I need to zoom in till this scrollbar disappears?
This is the code for you to test
Private bot As Selenium.ChromeDriver
Sub Test()
Dim eleTable As Selenium.WebElement, strPath As String, img As Image
Set bot = New Selenium.ChromeDriver
strPath = ThisWorkbook.Path & "\"
bot.Get "file:///" & Environ("USERPROFILE") & "\Desktop\OutputHTML.html"
Set eleTable = Nothing
On Error Resume Next
Set eleTable = bot.FindElementByCss(".table-striped")
On Error GoTo 0
If Not eleTable Is Nothing Then
Set img = eleTable.ScrollIntoView().TakeScreenshot()
img.SaveAs strPath & "Output.png"
Else
Debug.Print "Error In Taking Screenshot"
End If
End Sub
and this is example of the HTML local file
<bdo dir="rtl"><meta http-equiv="Content-Type" content="text/html; charset=windows-1256"/>
<style type="text/css">
th,td{
text-align: center !important;
}
</style>
<table class="table table-striped">
<tr class="">
<th width="5%" style="text-align:center;">م</th>
<th width="15%" style="text-align:center;">التاريخ</th>
<th style="text-align:center;">العملية</th>
</tr>
<tr class="resultRowOdd" align="center" style="line-height:25px;">
<td>1</td>
<td dir="ltr">2022-02-23</td>
<td style="padding-right:10px;">اعادة فتح ملف )مغلق(</td>
</tr>
<tr class="resultRowEven" align="center" style="line-height:25px;">
<td>2</td>
<td dir="ltr">2022-02-22</td>
<td style="padding-right:10px;">اغلاق ملف</td>
</tr>
<tr class="resultRowOdd" align="center" style="line-height:25px;">
<td>3</td>
<td dir="ltr">2022-02-22</td>
<td style="padding-right:10px;">ايصال توريد</td>
</tr>
<tr class="resultRowEven" align="center" style="line-height:25px;">
<td>4</td>
<td dir="ltr">2022-02-14</td>
<td style="padding-right:10px;">اذن صرف</td>
</tr>
<tr class="resultRowOdd" align="center" style="line-height:25px;">
<td>5</td>
<td dir="ltr">2022-02-14</td>
<td style="padding-right:10px;">استمارة صــرف</td>
</tr>
<tr class="resultRowEven" align="center" style="line-height:25px;">
<td>6</td>
<td dir="ltr">2022-01-19</td>
<td style="padding-right:10px;">اعادة فتح ملف )مغلق(</td>
</tr>
<tr class="resultRowOdd" align="center" style="line-height:25px;">
<td>7</td>
<td dir="ltr">2022-01-18</td>
<td style="padding-right:10px;">اغلاق ملف</td>
</tr>
<tr class="resultRowEven" align="center" style="line-height:25px;">
<td>8</td>
<td dir="ltr">2022-01-18</td>
<td style="padding-right:10px;">ايصال توريد</td>
</tr>
<tr class="resultRowOdd" align="center" style="line-height:25px;">
<td>9</td>
<td dir="ltr">2021-12-27</td>
<td style="padding-right:10px;">اعادة فتح ملف )مغلق(</td>
</tr>
<tr class="resultRowEven" align="center" style="line-height:25px;">
<td>10</td>
<td dir="ltr">2021-12-26</td>
<td style="padding-right:10px;">اغلاق ملف</td>
</tr>
<tr class="resultRowOdd" align="center" style="line-height:25px;">
<td>11</td>
<td dir="ltr">2021-12-26</td>
<td style="padding-right:10px;">ايصال توريد</td>
</tr>
<tr class="resultRowEven" align="center" style="line-height:25px;">
<td>12</td>
<td dir="ltr">2021-11-22</td>
<td style="padding-right:10px;">اعادة فتح ملف )مغلق(</td>
</tr>
<tr class="resultRowOdd" align="center" style="line-height:25px;">
<td>13</td>
<td dir="ltr">2021-11-21</td>
<td style="padding-right:10px;">اغلاق ملف</td>
</tr>
<tr class="resultRowEven" align="center" style="line-height:25px;">
<td>14</td>
<td dir="ltr">2021-11-21</td>
<td style="padding-right:10px;">ايصال توريد</td>
</tr>
<tr class="resultRowOdd" align="center" style="line-height:25px;">
<td>15</td>
<td dir="ltr">2021-11-15</td>
<td style="padding-right:10px;">اذن صرف</td>
</tr>
<tr class="resultRowEven" align="center" style="line-height:25px;">
<td>16</td>
<td dir="ltr">2021-11-15</td>
<td style="padding-right:10px;">استمارة صــرف</td>
</tr>
<tr class="resultRowOdd" align="center" style="line-height:25px;">
<td>17</td>
<td dir="ltr">2021-10-19</td>
<td style="padding-right:10px;">اعادة فتح ملف )مغلق(</td>
</tr>
<tr class="resultRowEven" align="center" style="line-height:25px;">
<td>18</td>
<td dir="ltr">2021-10-18</td>
<td style="padding-right:10px;">اغلاق ملف</td>
</tr>
<tr class="resultRowOdd" align="center" style="line-height:25px;">
<td>19</td>
<td dir="ltr">2021-10-18</td>
<td style="padding-right:10px;">ايصال توريد</td>
</tr>
<tr class="resultRowEven" align="center" style="line-height:25px;">
<td>20</td>
<td dir="ltr">2021-09-15</td>
<td style="padding-right:10px;">اعادة فتح ملف )مغلق(</td>
</tr>
<tr class="resultRowOdd" align="center" style="line-height:25px;">
<td>21</td>
<td dir="ltr">2021-09-14</td>
<td style="padding-right:10px;">اغلاق ملف</td>
</tr>
<tr class="resultRowEven" align="center" style="line-height:25px;">
<td>22</td>
<td dir="ltr">2021-09-14</td>
<td style="padding-right:10px;">ايصال توريد</td>
</tr>
<tr class="resultRowOdd" align="center" style="line-height:25px;">
<td>23</td>
<td dir="ltr">2021-09-12</td>
<td style="padding-right:10px;">اذن صرف</td>
</tr>
<tr class="resultRowEven" align="center" style="line-height:25px;">
<td>24</td>
<td dir="ltr">2021-09-12</td>
<td style="padding-right:10px;">استمارة صــرف</td>
</tr>
<tr class="resultRowOdd" align="center" style="line-height:25px;">
<td>25</td>
<td dir="ltr">2021-09-12</td>
<td style="padding-right:10px;">ايصال توريد</td>
</tr>
<tr class="resultRowEven" align="center" style="line-height:25px;">
<td>26</td>
<td dir="ltr">2021-08-23</td>
<td style="padding-right:10px;">اعادة فتح ملف )مغلق(</td>
</tr>
<tr class="resultRowOdd" align="center" style="line-height:25px;">
<td>27</td>
<td dir="ltr">2021-08-22</td>
<td style="padding-right:10px;">اغلاق ملف</td>
</tr>
<tr class="resultRowEven" align="center" style="line-height:25px;">
<td>28</td>
<td dir="ltr">2021-08-22</td>
<td style="padding-right:10px;">ايصال توريد</td>
</tr>
<tr class="resultRowOdd" align="center" style="line-height:25px;">
<td>29</td>
<td dir="ltr">2021-08-02</td>
<td style="padding-right:10px;">اعادة فتح ملف )مغلق(</td>
</tr>
<tr class="resultRowEven" align="center" style="line-height:25px;">
<td>30</td>
<td dir="ltr">2021-08-01</td>
<td style="padding-right:10px;">اغلاق ملف</td>
</tr>
</table>
</html></bdo>
I tried such a line to check the vertical scrollbar
Debug.Print bot.ExecuteScript("return document.documentElement.scrollHeight>document.documentElement.clientHeight;")
But this returns False although there's a scroll bar
I tried this line bot.ExecuteScript "document.body.style.zoom='90%';" to make the zoom out but I got another error Element outside the screenshot

Need the full correct html code for this Table

Image table
Please write full html codes for this table. You may see the Table image from above via the link.
<table border="1" width="800">
<tr>
<th>Level1</th>
<th>Level2</th>
<th>Level2</th>
<th>Info</th>
<th>Name</th>
</tr>
<tr>
<td rowspan="6">System</td>
</tr>
<tr>
<td rowspan="4">System Apps</td>
<td rowspan="2">System Memory</td>
</tr>
<tr>
<td rowspan="3">SystemEnv</td>
<td rowspan="1">SystemEnv2</td>
<td rowspan="2">Memeory Test</td>
</tr>
Here is the table code :
<table border="2">
<tr>
<th>Level 1</th>
<th>Level 2</th>
<th>Level 3</th>
<th>info</th>
<th>Name</th>
</tr>
<tr>
<td rowSpan="6">System</td>
<td rowSpan="4">System apps</td>
<td rowSpan="3">SystemEnv</td>
<td>App Text</td>
<td>foo</td>
</tr>
<tr>
<td>App memory</td>
<td>foo</td>
</tr>
<tr>
<td>App test</td>
<td>bar</td>
</tr>
<tr>
<td>Systemenv2</td>
<td>App test</td>
<td>bar</td>
</tr>
<tr>
<td rowSpan="2">System Memory</td>
<td rowSpan="2">Memory test</td>
<td>memory func</td>
<td>foo</td>
</tr>
<tr>
<td>Memory Func</td>
<td>foo</td>
</tr>
</table>

How to you print one Result on the Advanced PDF Template from a Saved Search vs a list?

I have an Inbound Shipment saved search of items coming in listed by container. I have no problem printing the list of the items with quantities, description, etc. but when I add in the "vessel Number" or "shipment number" I don't need it to repeat on every line. I would prefer to show the information that I would normally "group" at the top of the PDF vs. on each line.
I should note that when I print the saved search, I would have already filtered the search down to one container, meaning only one "shipment number" and one "vessel number".
<table align="center" border=".5" cellpadding=".5" cellspacing=".5" class="NATIVE-TABLE" style="width:100%;"><#list results as result><#if result_index == 0>
<thead>
<tr>
<th align="center" scope="col" style="width: 107px;">
<div><big>Shipment #</big></div>
</th>
<th align="center" scope="col" style="width: 103px;">
<div><big>Status</big></div>
</th>
<th align="center" scope="col" style="width: 156px;">
<div><big>Destination</big></div>
</th>
<th align="center" scope="col" style="width: 150px;">
<div><big>Actual Ship Date</big></div>
</th>
<th align="center" scope="col" style="width: 154px;">
<div><big>Expected Delivery Date</big></div>
</th>
<th align="center" scope="col">
<div><big>Carrier</big></div>
</th>
<th align="center" scope="col">
<div><big>Vessel #</big></div>
</th>
</tr>
</thead>
</#if><tr>
<td align="center" style="width: 107px;">${result.shipmentnumber}</td>
<td align="center" style="width: 103px;">${result.status}</td>
<td align="center" style="width: 156px;">${result.custrecord142}</td>
<td align="center" style="width: 150px;">${result.actualshippingdate}</td>
<td align="center" style="width: 154px;">${result.expecteddeliverydate}</td>
<td align="center" style="width: 154px;">${result.custrecord_htd_shipper_info}</td>
<td align="center" style="width: 154px;">${result.vesselnumber}</td>
</tr>
</#list></table>
First: please post your code so we can see where you're up to and respond accordingly - it helps us to help you!
Second: The general pattern would be that you simply use values from the first result to make up your header, and then iterate through all results to give your lines. It would look something like:
<#list results as result>
<#if result_index == 0>
*header information goes here*
</#if>
*line information goes here*
</#list>
Edited to add code
<table align="center" border=".5" cellpadding=".5" cellspacing=".5" class="NATIVE-TABLE" style="width:100%;"><#list results as result><#if result_index == 0>
<thead>
<tr>
<th align="center" scope="col" style="width: 107px;">
<div><big>Shipment #</big></div>
</th>
<th align="center" scope="col" style="width: 103px;">
<div><big>Status</big></div>
</th>
<th align="center" scope="col" style="width: 156px;">
<div><big>Destination</big></div>
</th>
<th align="center" scope="col" style="width: 150px;">
<div><big>Actual Ship Date</big></div>
</th>
<th align="center" scope="col" style="width: 154px;">
<div><big>Expected Delivery Date</big></div>
</th>
<th align="center" scope="col">
<div><big>Carrier</big></div>
</th>
<th align="center" scope="col">
<div><big>Vessel #</big></div>
</th>
</tr>
</thead>
<tr>
<td align="center" style="width: 107px;">${result.shipmentnumber}</td>
<td align="center" style="width: 103px;">${result.status}</td>
<td align="center" style="width: 156px;">${result.custrecord142}</td>
<td align="center" style="width: 150px;">${result.actualshippingdate}</td>
<td align="center" style="width: 154px;">${result.expecteddeliverydate}</td>
<td align="center" style="width: 154px;">${result.custrecord_htd_shipper_info}</td>
<td align="center" style="width: 154px;">${result.vesselnumber}</td>
</tr>
</#if>
<tr>
<td align="center" style="width: 107px;"></td>
<td align="center" style="width: 103px;">${result.status}</td>
<td align="center" style="width: 156px;">${result.custrecord142}</td>
<td align="center" style="width: 150px;">${result.actualshippingdate}</td>
<td align="center" style="width: 154px;">${result.expecteddeliverydate}</td>
<td align="center" style="width: 154px;">${result.custrecord_htd_shipper_info}</td>
<td align="center" style="width: 154px;"></td>
</tr>
</#list>
</table>

MorningStar KeyStat to pandas Dataframe

I am trying to read keyStat in MorningStar and know the data which is HTML where is warped in a JSON. So far I can put a request that can get the json by Beautifulsoup:
url = 'http://financials.morningstar.com/ajax/keystatsAjax.html?t=tou&culture=en-CA&region=CAN'
lm_json = requests.get(url).json()
ksContent = BeautifulSoup(lm_json["ksContent"],"html.parser")
Now here is a bit wired to me that the html data as 'ksContent' which contains actual data as a table. I am not a fan of html and wondering how can I just make all it to a nice pandas dataframe? As the table is long, here is some of it:
<table cellpadding="0" cellspacing="0" class="r_table1 text2">
<colgroup>
<col width="23%"/>
<col span="11" width="7%"/>
</colgroup>
<thead>
<tr>
<th align="left" scope="row"></th>
<th align="right" id="Y0" scope="col">2008-12</th>
<th align="right" id="Y1" scope="col">2009-12</th>
<th align="right" id="Y2" scope="col">2010-12</th>
<th align="right" id="Y3" scope="col">2011-12</th>
<th align="right" id="Y4" scope="col">2012-12</th>
<th align="right" id="Y5" scope="col">2013-12</th>
<th align="right" id="Y6" scope="col">2014-12</th>
<th align="right" id="Y7" scope="col">2015-12</th>
<th align="right" id="Y8" scope="col">2016-12</th>
<th align="right" id="Y9" scope="col">2017-12</th>
<th align="right" id="Y10" scope="col">TTM</th>
</tr>
</thead>
<tbody>
<tr class="hr">
<td colspan="12"></td>
</tr>
<tr>
<th class="row_lbl" id="i0" scope="row">Revenue <span>CAD Mil</span></th>
<td align="right" headers="Y0 i0">—</td>
<td align="right" headers="Y1 i0">40</td>
<td align="right" headers="Y2 i0">212</td>
<td align="right" headers="Y3 i0">349</td>
<td align="right" headers="Y4 i0">442</td>
<td align="right" headers="Y5 i0">759</td>
<td align="right" headers="Y6 i0">1,379</td>
<td align="right" headers="Y7 i0">1,074</td>
<td align="right" headers="Y8 i0">1,125</td>
<td align="right" headers="Y9 i0">1,662</td>
<td align="right" headers="Y10 i0">1,760</td>
</tr> ...
It defines a header tr, Y0, Y1 ... Y10 as actual date and next tr refers to it.
your help appreciated!
You can use read_html() to convert it into a list of dataframes
import requests
import pandas as pd
url = 'http://financials.morningstar.com/ajax/keystatsAjax.html?t=tou&culture=en-CA&region=CAN'
lm_json = requests.get(url).json()
df_list=pd.read_html(lm_json["ksContent"])
You can iterate through it and get the dataframes one by one. You can also use dropna() to get rid of the NaN only rows.
Sample output screenshot from my jupyter Notebook

Resources