Merge branch 'develop' into fix-hsn_wise

This commit is contained in:
vorasmit
2021-11-29 16:33:21 +05:30
committed by GitHub
130 changed files with 2409 additions and 2065 deletions

View File

@@ -103,6 +103,45 @@ class TestGSTR3BReport(unittest.TestCase):
gst_settings.round_off_gst_values = 1
gst_settings.save()
def test_gst_category_auto_update(self):
if not frappe.db.exists("Customer", "_Test GST Customer With GSTIN"):
customer = frappe.get_doc({
"customer_group": "_Test Customer Group",
"customer_name": "_Test GST Customer With GSTIN",
"customer_type": "Individual",
"doctype": "Customer",
"territory": "_Test Territory"
}).insert()
self.assertEqual(customer.gst_category, 'Unregistered')
if not frappe.db.exists('Address', '_Test GST Category-1-Billing'):
address = frappe.get_doc({
"address_line1": "_Test Address Line 1",
"address_title": "_Test GST Category-1",
"address_type": "Billing",
"city": "_Test City",
"state": "Test State",
"country": "India",
"doctype": "Address",
"is_primary_address": 1,
"phone": "+91 0000000000",
"gstin": "29AZWPS7135H1ZG",
"gst_state": "Karnataka",
"gst_state_number": "29"
}).insert()
address.append("links", {
"link_doctype": "Customer",
"link_name": "_Test GST Customer With GSTIN"
})
address.save()
customer.load_from_db()
self.assertEqual(customer.gst_category, 'Registered Regular')
def make_sales_invoice():
si = create_sales_invoice(company="_Test Company GST",
customer = '_Test GST Customer',

View File

@@ -791,7 +791,7 @@ def set_tax_withholding_category(company):
accounts = [dict(company=company, account=tds_account)]
try:
fiscal_year_details = get_fiscal_year(today(), verbose=0, company=company)
fiscal_year_details = get_fiscal_year(today(), verbose=0)
except FiscalYearError:
pass

View File

@@ -74,11 +74,11 @@ def validate_tax_category(doc, method):
frappe.throw(_("Intra State tax category for GST State {0} already exists").format(doc.gst_state))
def update_gst_category(doc, method):
if hasattr(doc, 'gst_category'):
for link in doc.links:
if link.link_doctype in ['Customer', 'Supplier']:
if doc.get('gstin'):
frappe.db.set_value(link.link_doctype, {'name': link.link_name, 'gst_category': 'Unregistered'}, 'gst_category', 'Registered Regular')
for link in doc.links:
if link.link_doctype in ['Customer', 'Supplier']:
meta = frappe.get_meta(link.link_doctype)
if doc.get('gstin') and meta.has_field('gst_category'):
frappe.db.set_value(link.link_doctype, {'name': link.link_name, 'gst_category': 'Unregistered'}, 'gst_category', 'Registered Regular')
def set_gst_state_and_state_number(doc):
if not doc.gst_state:

File diff suppressed because one or more lines are too long

View File

@@ -106,14 +106,14 @@ def set_address_details(row, special_characters):
row.update({'ship_to_state': row.to_state})
def set_taxes(row, filters):
taxes = frappe.get_list("Sales Taxes and Charges",
taxes = frappe.get_all("Sales Taxes and Charges",
filters={
'parent': row.dn_id
},
fields=('item_wise_tax_detail', 'account_head'))
account_list = ["cgst_account", "sgst_account", "igst_account", "cess_account"]
taxes_list = frappe.get_list("GST Account",
taxes_list = frappe.get_all("GST Account",
filters={
"parent": "GST Settings",
"company": filters.company

View File

@@ -41,7 +41,7 @@ class VATAuditReport(object):
return self.columns, self.data
def get_sa_vat_accounts(self):
self.sa_vat_accounts = frappe.get_list("South Africa VAT Account",
self.sa_vat_accounts = frappe.get_all("South Africa VAT Account",
filters = {"parent": self.filters.company}, pluck="account")
if not self.sa_vat_accounts and not frappe.flags.in_test and not frappe.flags.in_migrate:
link_to_settings = get_link_to_form("South Africa VAT Settings", "", label="South Africa VAT Settings")

View File

@@ -28,14 +28,22 @@ def create_qr_code(doc, method):
for field in meta.get_image_fields():
if field.fieldname == 'qr_code':
from urllib.parse import urlencode
# Creating public url to print format
default_print_format = frappe.db.get_value('Property Setter', dict(property='default_print_format', doc_type=doc.doctype), "value")
# System Language
language = frappe.get_system_settings('language')
params = urlencode({
'format': default_print_format or 'Standard',
'_lang': language,
'key': doc.get_signature()
})
# creating qr code for the url
url = f"{ frappe.utils.get_url() }/{ doc.doctype }/{ doc.name }?format={ default_print_format or 'Standard' }&_lang={ language }&key={ doc.get_signature() }"
url = f"{ frappe.utils.get_url() }/{ doc.doctype }/{ doc.name }?{ params }"
qr_image = io.BytesIO()
url = qr_create(url, error='L')
url.png(qr_image, scale=2, quiet_zone=1)
@@ -74,4 +82,11 @@ def delete_qr_code_file(doc, method):
'file_url': doc.get('qr_code')
})
if len(file_doc):
frappe.delete_doc('File', file_doc[0].name)
frappe.delete_doc('File', file_doc[0].name)
def delete_vat_settings_for_company(doc, method):
if doc.country != 'Saudi Arabia':
return
settings_doc = frappe.get_doc('KSA VAT Setting', {'company': doc.name})
settings_doc.delete()