The following are the things I want to achieve now.
I need a new column with Supplier Balance. How can I achieve this using get_balance_on(party_type, party) function? I tried the below code, but was of no help.
So I figured out the answer for my first question from a response to my question on stackoverflow. The below line of code will fetch me supplier balances in my pandas pivot table.
# First, create your dataframe "df"
column_names = []
for each_column_name in df.columns.values:
new_dict = {
"label": each_column_name,
"field_name": each_column_name,
"fieldtype": "Data",
"width": 100
}
column_names.append(this_dict)
# variable "column_names" is now in the correct format for Report usage.
If you wanted to get fancier, you could teach it to map to DocFields, and fetch metadata, to get a more friendly “label”, and an accurate “fieldtype”.
data = pvt.reset_index().values.tolist() # reset the index and create a list for use in report.
columns += pvt.columns.values.tolist() # create the list of dynamic columns added to the previously defined static columns
df = df.set_index('party') # to change the index to party, otherwise index will get displayed again.
data = df.values.tolist()
columns = df.columns.values.tolist()
@aakvatech Thanks for the input. I just modified your code to get the desired output. @brian_pond Thanks for the input brother
I have finished my report. But now I have stumbled upon a new problem. This might be a real silly question for developers, I have just started on my journey to learning python
All the values in the report is showing as float and without proper column dict, how can I assign it as currency?
Once the report was done. I get the report from ERPNext. Not the command line. As @brian_pond pointed, it was just a script report where i used Pandas.