hi @lasalesi,
i have write your code.:
@frappe.whitelist()
def download():
content = ";".join(map(str, (["FK", "KD_JENIS_TRANSAKSI", "FG_PENGGANTI", "NOMOR_FAKTUR", "MASA_PAJAK", "TAHUN_PAJAK", "TANGGAL_FAKTUR", "NPWP", "NAMA", "ALAMAT_LENGKAP","JUMLAH_DPP", "JUMLAH_PPN", "JUMLAH_PPNBM", "ID_KETERANGAN_TAMBAHAN", "FG_UANG_MUKA", "UANG_MUKA_DPP", "UANG_MUKA_PPN", "UANG_MUKA_PPNBM", "REFERENSI"]))) + "\n\r"
content = ";".join(map(str, (["LT", "NPWP", "NAMA", "JALAN", "BLOK", "NOMOR", "RT", "RW", "KECAMATAN", "KELURAHAN", "KABUPATEN", "PROPINSI", "KODE_POS", "NOMOR_TELEPON"]))) + "\n\r"
content = ";".join(map(str, (["OF", "KODE_OBJEK", "NAMA", "HARGA_SATUAN", "JUMLAH_BARANG", "HARGA_TOTAL", "DISKON", "DPP", "PPN", "TARIF_PPNBM", "PPNBM"]))) + "\n\r"
parents = frappe.db.sql("select MONTH(posting_date) as month,Year(posting_date) as year, posting_date, tax_id, customer, address_display, name,(select SUM((price_list_rate*qty)-net_amount) as JUMLAH_DPP1 from `tabSales Invoice Item` where `tabSales Invoice Item`.parent=`tabSales Invoice`.name) as JUMLAH_DPP from `tabSales Invoice`", as_dict=1)
for parent in parents:
content = ";".join(map(str, (["FK", "1", "", "0", parent['month'], parent['year'], parent['posting_date'], parent['tax_id'], parent['customer'], parent['address_display'], parent['JUMLAH_DPP'], parent['JUMLAH_DPP']*0.1, "0", "", "0", "0", "0", "0", parent['name']]))) + "\n\r"
children = frappe.db.sql("select item_name, price_list_rate, qty, (price_list_rate*qty) as amount, net_amount, ((price_list_rate*qty)-net_amount) as dpp from `tabSales Invoice Item` where parent=%s", parent.name, as_dict=1)
for child in children:
content = ";".join(map(str, (["OF", "", child['item_name'], child['price_list_rate'], child['qty'],child['amount'], child['net_amount'], child['dpp'], child['dpp']*0.1]))) + "\n\r"
return content
@frappe.whitelist()
def get_my_csv():
content = download()
return {‘content’: content }
why csv content only one row? this not looping?