Advertisement
ankdroid

Efaktur

Sep 12th, 2022
985
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.04 KB | Source Code | 0 0
  1. Expected Result :
  2. ppn
  3. [customer_id: [
  4.         "KD_JENIS":,
  5.         "FG_PENGGANTI":,
  6.         "NO_FAKTUR":,
  7.         "MASA_PAJAK":,
  8.         "TAHUN_PAJAK":,
  9.         "TANGGAL_PAJAK":,
  10.         "NPWP":,
  11.         "NAMA":,
  12.         "ALAMAT":,
  13.         "JUMLAH_DPP":,
  14.         "JUMLAH_PPN":,
  15.         "DETAIL_FK": [
  16.             "KODE_OBJECT":,
  17.             "PRODUCT_NAME":,
  18.             "HARGA_SATUAN":,
  19.             "JUMLAH_BARANG":,
  20.             "HARGA_TOTAL":,
  21.             "DPP":,
  22.             "PPN":
  23.         ],
  24.        
  25.     ]
  26. ]
  27.  
  28.  
  29. result_ppn = []
  30. result_noppn = []
  31. str_ppn_inv = ''
  32. str_noppn_inv = ''
  33. for cust in invoice(group by customer, date=thismonth, flag_otomatis_ppn = false)
  34.     sum_ppn_inv = 0
  35.     sum_noppn_inv = 0
  36.     ppn_inv = []
  37.     noppn_inv = []
  38.     sum_ppn_cn = 0
  39.     sum_noppn_cn = 0
  40.     ppn_cn = []
  41.     noppn_cn = []
  42.     str_inv = ''
  43.     product_ppn_list = []
  44.     product_noppn_list = []
  45.     ppn_origin = []
  46.     noppn_origin = []
  47.     for inv in invoice ( where customer = cust.name,partner_id=cust.partner_id,date=thismonth)
  48.         #loop line
  49.         for inl in line_ids:
  50.             if inl.product_id.flag_ppn:
  51.                 ppn_inv.append(inl)
  52.                 sum_ppn_inv += inl.amount
  53.                 product_ppn_list.append(product_id)
  54.             else:
  55.                 noppn_inv.append(inl)
  56.                 sum_noppn_inv += inl.amount
  57.                 product_noppn_list.append(product_id)
  58.                
  59.         result_ppn_amount=sum_ppn_inv
  60.         result_noppn_amount=sum_noppn_inv
  61.                
  62.         #cek apakah ada cn
  63.         cns = self.env[invoice].search('origin','=',inv.origin)
  64.         if len(cn) > 0:
  65.             for cn in cns:
  66.                 for c in cn.line_ids:
  67.                     if c.product_id.flag_ppn:
  68.                         ppn_cn.append(c)
  69.                         sum_ppn_cn += c.amount
  70.                     else:
  71.                         noppn_cn.append(c)
  72.                         sum_ppn_cn += c.amount
  73.         if sum_noppn_inv != sum_noppn_cn:
  74.             str_noppn_inv += ','+inv.name
  75.             noppn_origin.append(inv.origin)
  76.             result_noppn_amount = result_noppn_amount - sum_noppn_cn
  77.            
  78.         if sum_ppn_inv != sum_ppn_cn:
  79.             str_ppn_inv += ','+inv.name
  80.             result_ppn_amount = result_ppn_amount - sum_ppn_cn
  81.             ppn_origin.append(inv.origin)
  82.            
  83.     for product_list in product_noppn_list:
  84.         #Cek CN untuk product tsb
  85.         cek_partial_cn_ppn = self.env[invoice_line].search([('inv_id',in , ppn_origin),(product_id = product_list)])
  86.         if len(cek_partial_cn_ppn) > 0:
  87.             sum_partial_cn_ppn = 0
  88.             for pcn in cek_partial_cn_ppn:
  89.                 if pcn.type == 'out_invoice':
  90.                     sum_partial_cn_ppn +=pcn.amount
  91.                 elif pcn.type == 'out_refund':
  92.                     sum_partial_cn_ppn = sum_partial_cn_ppn - pcn.amount
  93.             dpp_amount_ppn = 100/111 * sum_partial_cn_ppn
  94.             pajak_ppn = sum_partial_cn_ppn - dpp_amount_ppn
  95.                    
  96.         cek_partial_cn_noppn = self.env[invoice_line].search([('inv_id',in , ppn_origin),(product_id = product_list)])
  97.         if len(cek_partial_cn_noppn) > 0:
  98.             sum_partial_cn_ppn = 0
  99.             for pcn in cek_partial_cn_noppn:
  100.                 if pcn.type == 'out_invoice':
  101.                     sum_partial_cn_noppn +=pcn.amount
  102.                 elif pcn.type == 'out_refund':
  103.                     sum_partial_cn_noppn = sum_partial_cn_noppn - pcn.amount
  104.             dpp_amount_noppn = sum_partial_cn_noppn
  105.             pajak_noppn = 11/100 * dpp_amount_noppn
  106.            
  107.     if sum_noppn_inv != sum_noppn_cn:
  108.         result_noppn.append[partner_id:inv.partner_id.name,amount=result_amount,dll]
  109.     if sum_ppn_inv != sum_ppn_cn:
  110.         result_ppn.append[partner_id:xxx]
  111.    
  112.    
  113.        
  114.        
  115.    
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement