Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Expected Result :
- ppn
- [customer_id: [
- "KD_JENIS":,
- "FG_PENGGANTI":,
- "NO_FAKTUR":,
- "MASA_PAJAK":,
- "TAHUN_PAJAK":,
- "TANGGAL_PAJAK":,
- "NPWP":,
- "NAMA":,
- "ALAMAT":,
- "JUMLAH_DPP":,
- "JUMLAH_PPN":,
- "DETAIL_FK": [
- "KODE_OBJECT":,
- "PRODUCT_NAME":,
- "HARGA_SATUAN":,
- "JUMLAH_BARANG":,
- "HARGA_TOTAL":,
- "DPP":,
- "PPN":
- ],
- ]
- ]
- result_ppn = []
- result_noppn = []
- str_ppn_inv = ''
- str_noppn_inv = ''
- for cust in invoice(group by customer, date=thismonth, flag_otomatis_ppn = false)
- sum_ppn_inv = 0
- sum_noppn_inv = 0
- ppn_inv = []
- noppn_inv = []
- sum_ppn_cn = 0
- sum_noppn_cn = 0
- ppn_cn = []
- noppn_cn = []
- str_inv = ''
- product_ppn_list = []
- product_noppn_list = []
- ppn_origin = []
- noppn_origin = []
- for inv in invoice ( where customer = cust.name,partner_id=cust.partner_id,date=thismonth)
- #loop line
- for inl in line_ids:
- if inl.product_id.flag_ppn:
- ppn_inv.append(inl)
- sum_ppn_inv += inl.amount
- product_ppn_list.append(product_id)
- else:
- noppn_inv.append(inl)
- sum_noppn_inv += inl.amount
- product_noppn_list.append(product_id)
- result_ppn_amount=sum_ppn_inv
- result_noppn_amount=sum_noppn_inv
- #cek apakah ada cn
- cns = self.env[invoice].search('origin','=',inv.origin)
- if len(cn) > 0:
- for cn in cns:
- for c in cn.line_ids:
- if c.product_id.flag_ppn:
- ppn_cn.append(c)
- sum_ppn_cn += c.amount
- else:
- noppn_cn.append(c)
- sum_ppn_cn += c.amount
- if sum_noppn_inv != sum_noppn_cn:
- str_noppn_inv += ','+inv.name
- noppn_origin.append(inv.origin)
- result_noppn_amount = result_noppn_amount - sum_noppn_cn
- if sum_ppn_inv != sum_ppn_cn:
- str_ppn_inv += ','+inv.name
- result_ppn_amount = result_ppn_amount - sum_ppn_cn
- ppn_origin.append(inv.origin)
- for product_list in product_noppn_list:
- #Cek CN untuk product tsb
- cek_partial_cn_ppn = self.env[invoice_line].search([('inv_id',in , ppn_origin),(product_id = product_list)])
- if len(cek_partial_cn_ppn) > 0:
- sum_partial_cn_ppn = 0
- for pcn in cek_partial_cn_ppn:
- if pcn.type == 'out_invoice':
- sum_partial_cn_ppn +=pcn.amount
- elif pcn.type == 'out_refund':
- sum_partial_cn_ppn = sum_partial_cn_ppn - pcn.amount
- dpp_amount_ppn = 100/111 * sum_partial_cn_ppn
- pajak_ppn = sum_partial_cn_ppn - dpp_amount_ppn
- cek_partial_cn_noppn = self.env[invoice_line].search([('inv_id',in , ppn_origin),(product_id = product_list)])
- if len(cek_partial_cn_noppn) > 0:
- sum_partial_cn_ppn = 0
- for pcn in cek_partial_cn_noppn:
- if pcn.type == 'out_invoice':
- sum_partial_cn_noppn +=pcn.amount
- elif pcn.type == 'out_refund':
- sum_partial_cn_noppn = sum_partial_cn_noppn - pcn.amount
- dpp_amount_noppn = sum_partial_cn_noppn
- pajak_noppn = 11/100 * dpp_amount_noppn
- if sum_noppn_inv != sum_noppn_cn:
- result_noppn.append[partner_id:inv.partner_id.name,amount=result_amount,dll]
- if sum_ppn_inv != sum_ppn_cn:
- result_ppn.append[partner_id:xxx]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement