Skip to content

Commit

Permalink
fix - allow saving of supplier and customer before initial setup
Browse files Browse the repository at this point in the history
  • Loading branch information
maniamartial committed Sep 13, 2024
1 parent beeaaa7 commit 9a9a2a5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,75 +95,3 @@ frappe.ui.form.on('Company', {
get_tin(frm)
}})


// //Customer
// frappe.ui.form.on('Customer', {
// refresh: function(frm) {
// if (frm.doc.customer_type === 'Company') {
// frm.set_query('custom_gst_category', function() {
// return {
// filters: {
// 'name': ['!=', 'Unregistered']
// }
// };
// });
// }
// },
// customer_type: function(frm) {
// if (frm.doc.customer_type === 'Company') {
// frm.set_query('custom_gst_category', function() {
// return {
// filters: {
// 'name': ['!=', 'Unregistered']
// }
// };
// });
// } else {
// frappe.msgprint("un here");
// frm.set_query('custom_gst_category', function() {
// return {
// filters: {
// 'name': ['!=', 'UN']
// }
// };
// });
// }
// }
// });


// //Supplier
// frappe.ui.form.on('Supplier', {
// refresh: function(frm) {
// if (frm.doc.supplier_type === 'Company') {

// frm.set_query('custom_gst_category', function() {
// return {
// filters: {
// 'name': ['!=', 'Unregistered']
// }
// };
// });
// }
// },
// supplier_type: function(frm) {
// if (frm.doc.supplier_type === 'Company') {
// frm.set_query('custom_gst_category', function() {
// return {
// filters: {
// 'name': ['!=', 'Unregistered']
// }
// };
// });
// } else {
// frm.set_query('custom_gst_category', function() {
// return {
// filters: {
// 'name': ['!=', 'UN']
// }
// };
// });
// }
// }
// });

27 changes: 16 additions & 11 deletions burundi_compliance/burundi_compliance/overrides/check_tin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@
import frappe
from ..api_classes.base import OBRAPIBase

obr_integration_base = OBRAPIBase()

auth_details=obr_integration_base.get_auth_details()
allow_obr_to_track_sales=auth_details["allow_obr_to_track_sales"]


def check_and_verify_tin(doc):
if doc.tax_id is not None and doc.custom_tin_verified == 0:
obr_integration_base = OBRAPIBase()
token = obr_integration_base.authenticate()

tin_verifier = TinVerifier(token)
Expand All @@ -23,18 +28,18 @@ def check_and_verify_tin(doc):
def customer_or_supplier_before_save(doc, method=None):

'''Check and verify the customer's TIN if applicable.'''

if doc.custom_gst_category == "Registered" and doc.tax_id is None:
frappe.throw("Le NIF est obligatoire pour les contribuables enregistrés.")

elif doc.custom_gst_category == "Registered" and doc.tax_id is not None and doc.custom_tin_verified == 0:
check_and_verify_tin(doc)
if allow_obr_to_track_sales==1:
if doc.custom_gst_category == "Registered" and doc.tax_id is None:
frappe.throw("Le NIF est obligatoire pour les contribuables enregistrés.")
elif doc.custom_gst_category == "Registered" and doc.tax_id is not None and doc.custom_tin_verified == 0:
check_and_verify_tin(doc)


@frappe.whitelist(allow_guest=True)
def supplier_before_save(doc, method=None):

'''Check and verify the supplier's TIN if applicable.'''
if doc.tax_id is not None and doc.custom_tin_verified == 0:
check_and_verify_tin(doc)
if allow_obr_to_track_sales==1:
'''Check and verify the supplier's TIN if applicable.'''
if doc.tax_id is not None and doc.custom_tin_verified == 0:
check_and_verify_tin(doc)

0 comments on commit 9a9a2a5

Please sign in to comment.