diff --git a/bssb_core_banking_asset/models/cb_asset_backend.py b/bssb_core_banking_asset/models/cb_asset_backend.py
index 2334429..f3aa829 100644
--- a/bssb_core_banking_asset/models/cb_asset_backend.py
+++ b/bssb_core_banking_asset/models/cb_asset_backend.py
@@ -70,9 +70,12 @@ def _default_company_id(self):
string="Password",
required=True,
)
- token = fields.Char(
+ token = fields.Text(
string="Token",
)
+ app_id = fields.Char(
+ string="App ID",
+ )
@api.multi
def name_get(self):
diff --git a/bssb_core_banking_asset/models/cb_asset_batch.py b/bssb_core_banking_asset/models/cb_asset_batch.py
index 16123a0..23f6dfd 100644
--- a/bssb_core_banking_asset/models/cb_asset_batch.py
+++ b/bssb_core_banking_asset/models/cb_asset_batch.py
@@ -272,16 +272,18 @@ def action_done(self):
@api.multi
def _prepare_data_core_banking(self):
+ company = self.env.user.company_id
+ backend = company.cb_asset_backend_id
data = {
- "APP_ID": "ATI-UMUM",
+ "APP_ID": backend.app_id,
"NO_TRANS": self.name,
"REK_DEBET": self.warehouse_id.code + self.depreciation_expense_account_id.code,
"NOMINAL_DEBET": self.final_depreciation_amount,
"KET_DEBET": self.description,
"NOTLP_DEBET": "",
- "JENIS_TRANS": ""
+ "JENIS_TRANS": "0200",
}
-
+ # Range nanti diganti sama line_ids
for i in range(1,4):
rek_kredit = "REK_KREDIT" + str(i)
nominal_kredit = "NOMINAL_KREDIT" + str(i)
@@ -308,8 +310,8 @@ def _get_token(self):
url = backend.base_url + backend.api_token
payload = json.dumps({
- "user": "ati-umum",
- "password": "ati-umum"
+ "user": backend.username,
+ "password": backend.password,
})
headers = {
"Content-Type": "application/json",
@@ -323,16 +325,27 @@ def _get_token(self):
code = result["code"]
if code == "00":
backend.token = result["message"]
- msg_err = _(
+ msg_err = _(
+ """
+ Status: Success
+ API: %s
+ Payload: %s
+ Response: %s
"""
- Status: Success
- API: %s
- Payload: %s
- Response: %s
- """
- % (url, payload, response.text)
- )
- return self._set_response("success", msg_err)
+ % (url, payload, response.text)
+ )
+ return self._set_response("success", msg_err)
+ else:
+ msg_err = _(
+ """
+ Status: Error
+ API: %s
+ Payload: %s
+ Response: %s
+ """
+ % (url, payload, response.text)
+ )
+ return self._set_response("failed", msg_err)
except requests.exceptions.Timeout as e:
msg_err = _(
"""
@@ -385,24 +398,33 @@ def _send_2_core_banking(self, data):
headers = {
"Authorization": "Bearer " + backend.token,
}
-
- payload = json.dumps(data)
-
try:
response = requests.request(
- "POST", url, headers=headers, data=payload
+ "POST", url, headers=headers, json=data
)
- self.action_done()
- msg_err = _(
+ if response.status_code == 200:
+ self.action_done()
+ msg_err = _(
+ """
+ Status: Success
+ API: %s
+ Payload: %s
+ Response: %s
"""
- Status: Success
- API: %s
- Payload: %s
- Response: %s
- """
- % (url, payload, response.text)
- )
- return self._set_response("success", msg_err)
+ % (url, payload, response.text)
+ )
+ return self._set_response("success", msg_err)
+ else:
+ msg_err = _(
+ """
+ Status: Error
+ API: %s
+ Payload: %s
+ Response: %s
+ """
+ % (url, payload, response.text)
+ )
+ return self._set_response("success", msg_err)
except requests.exceptions.Timeout as e:
msg_err = _(
"""
diff --git a/bssb_core_banking_asset/views/cb_asset_backend_views.xml b/bssb_core_banking_asset/views/cb_asset_backend_views.xml
index 7159226..2baa17e 100644
--- a/bssb_core_banking_asset/views/cb_asset_backend_views.xml
+++ b/bssb_core_banking_asset/views/cb_asset_backend_views.xml
@@ -67,10 +67,14 @@
-
+
+
+
+
+