summaryrefslogtreecommitdiff
path: root/indoteknik_api/controllers/api_v1/user.py
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-08-27 14:48:37 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-08-27 14:48:37 +0700
commitf7ba6f97d3367e54e3c24eaf24002ca7abbd5383 (patch)
treef7c4d61d3f03c5f79b79aaac3ac6283ca6a24ad3 /indoteknik_api/controllers/api_v1/user.py
parentcda852c61878d46c14c7c04e8eaaf68a268f6149 (diff)
<iman> update make attachment
Diffstat (limited to 'indoteknik_api/controllers/api_v1/user.py')
-rw-r--r--indoteknik_api/controllers/api_v1/user.py25
1 files changed, 21 insertions, 4 deletions
diff --git a/indoteknik_api/controllers/api_v1/user.py b/indoteknik_api/controllers/api_v1/user.py
index a7e200cd..59684b4c 100644
--- a/indoteknik_api/controllers/api_v1/user.py
+++ b/indoteknik_api/controllers/api_v1/user.py
@@ -9,6 +9,8 @@ import string
import requests
import json
from difflib import SequenceMatcher
+import mimetypes
+import base64
class User(controller.Controller):
@@ -107,14 +109,19 @@ class User(controller.Controller):
phone = kw.get('phone')
# Form Data
+ # Form Data
npwp = kw.get('npwp')
npwp_document = kw.get('npwp_document', False)
+ npwp_filename = kw.get('npwp_filename', 'npwp_document')
sppkp = kw.get('sppkp', False)
sppkp_document = kw.get('sppkp_document', False)
+ sppkp_filename = kw.get('sppkp_filename', 'sppkp_document')
email_partner = kw.get('email_partner')
business_name = kw.get('business_name', False)
industry_id = int(kw.get('industry_id', '0') or 0)
company_type_id = int(kw.get('company_type_id', '0') or 0)
+ alamat_wajib_pajak = kw.get('alamat_wajib_pajak', False)
+ alamat_bisnis = kw.get('alamat_bisnis', False)
nama_wajib_pajak = kw.get('nama_wajib_pajak', False)
is_pkp = kw.get('is_pkp')
type_acc = kw.get('type_acc', False)
@@ -174,6 +181,9 @@ class User(controller.Controller):
if not nama_wajib_pajak and not is_pkp:
nama_wajib_pajak = business_name
+ if not alamat_wajib_pajak and not is_pkp:
+ alamat_wajib_pajak = alamat_bisnis
+
new_company_data = {
'name': business_name if business_name else business_name,
'company_type_id': company_type_id if company_type_id else False,
@@ -182,7 +192,9 @@ class User(controller.Controller):
'npwp': npwp if is_pkp else (npwp if npwp else '0.000.000.0-000.000'),
'sppkp': sppkp if is_pkp else (sppkp if sppkp else ''),
'nama_wajib_pajak': nama_wajib_pajak,
+ 'alamat_lengkap_text': alamat_wajib_pajak,
'email': email_partner,
+ 'street': alamat_bisnis,
'company_type': 'company'
}
new_company = request.env['res.partner'].create(new_company_data)
@@ -191,28 +203,33 @@ class User(controller.Controller):
user.partner_id.npwp = new_company.npwp
user.partner_id.sppkp = new_company.sppkp
user.partner_id.nama_wajib_pajak = new_company.nama_wajib_pajak
+ user.partner_id.alamat_lengkap_text = new_company.alamat_lengkap_text
if npwp_document:
+ npwp_mimetype, _ = mimetypes.guess_type(npwp_filename)
+ npwp_mimetype = npwp_mimetype or 'application/octet-stream'
pdf_data = base64.b64decode(npwp_document)
npwp_attachment = request.env['ir.attachment'].create({
'name': 'NPWP Document',
'type': 'binary',
- 'datas': pdf_data,
+ 'datas': base64.b64encode(pdf_data),
'res_model': 'res.partner',
'res_id': new_company.id,
- 'mimetype': 'application/pdf'
+ 'mimetype': npwp_mimetype
})
new_company.message_post(body="NPWP Uploaded", attachment_ids=[npwp_attachment.id])
if sppkp_document:
+ sppkp_mimetype, _ = mimetypes.guess_type(sppkp_filename)
+ sppkp_mimetype = sppkp_mimetype or 'application/octet-stream'
pdf_data = base64.b64decode(sppkp_document)
sppkp_attachment = request.env['ir.attachment'].create({
'name': 'SPPKP Document',
'type': 'binary',
- 'datas': pdf_data,
+ 'datas': base64.b64encode(pdf_data),
'res_model': 'res.partner',
'res_id': new_company.id,
- 'mimetype': 'application/pdf'
+ 'mimetype': sppkp_mimetype
})
new_company.message_post(body="SPPKP Uploaded", attachment_ids=[sppkp_attachment.id])