Merge branch 'develop' into fix-hsn_wise

This commit is contained in:
Deepesh Garg
2021-11-14 10:37:36 +05:30
committed by GitHub
2021 changed files with 1879 additions and 4572 deletions

View File

@@ -1,7 +1,6 @@
# Copyright (c) 2018, Frappe Technologies and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from frappe import _

View File

@@ -1,5 +1,3 @@
from __future__ import unicode_literals
from unittest import TestCase
import frappe

View File

@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
# import frappe
from frappe.model.document import Document

View File

@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt
from __future__ import unicode_literals
# import frappe
import unittest

View File

@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from frappe.model.document import Document

View File

@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt
from __future__ import unicode_literals
import unittest

View File

@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2017, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import os

View File

@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt
from __future__ import unicode_literals
import unittest

View File

@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import json
import os
@@ -11,7 +9,6 @@ import frappe
from frappe import _
from frappe.model.document import Document
from frappe.utils import cstr, flt
from six import iteritems
from erpnext.regional.india import state_numbers
@@ -283,7 +280,7 @@ class GSTR3BReport(Document):
if self.get('invoice_items'):
# Build itemised tax for export invoices, nil and exempted where tax table is blank
for invoice, items in iteritems(self.invoice_items):
for invoice, items in self.invoice_items.items():
if invoice not in self.items_based_on_tax_rate and self.invoice_detail_map.get(invoice, {}).get('export_type') \
== "Without Payment of Tax" and self.invoice_detail_map.get(invoice, {}).get('gst_category') == "Overseas":
self.items_based_on_tax_rate.setdefault(invoice, {}).setdefault(0, items.keys())
@@ -351,7 +348,7 @@ class GSTR3BReport(Document):
self.report_dict['sup_details']['isup_rev']['txval'] += taxable_value
def set_inter_state_supply(self, inter_state_supply):
for key, value in iteritems(inter_state_supply):
for key, value in inter_state_supply.items():
if key[0] == "Unregistered":
self.report_dict["inter_sup"]["unreg_details"].append(value)

View File

@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt
from __future__ import unicode_literals
import json
import unittest

View File

@@ -1,7 +1,6 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import re
import zipfile

View File

@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt
from __future__ import unicode_literals
# import frappe
import unittest

View File

@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from frappe import _
@@ -31,7 +29,7 @@ class LowerDeductionCertificate(Document):
<= fiscal_year.year_end_date):
frappe.throw(_("Valid Upto date not in Fiscal Year {0}").format(frappe.bold(self.fiscal_year)))
def tax_withholding_category(self):
def validate_supplier_against_tax_category(self):
duplicate_certificate = frappe.db.get_value('Lower Deduction Certificate',
{'supplier': self.supplier, 'tax_withholding_category': self.tax_withholding_category, 'name': ("!=", self.name)},
['name', 'valid_from', 'valid_upto'], as_dict=True)

View File

@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt
from __future__ import unicode_literals
# import frappe
import unittest

View File

@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from frappe import _

View File

@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt
from __future__ import unicode_literals
import unittest

View File

@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
# import frappe
from frappe.model.document import Document

View File

@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
# import frappe
from frappe.model.document import Document

View File

@@ -1,7 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt
from __future__ import unicode_literals
# import frappe
import unittest

View File

@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
# import frappe
from frappe.model.document import Document

View File

@@ -1,7 +1,6 @@
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields

View File

@@ -1,7 +1,6 @@
# Copyright (c) 2018, Frappe Technologies and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
# don't remove this function it is used in tests

View File

@@ -1,4 +1,3 @@
# coding: utf-8
"""Constants used in datev.py."""
TRANSACTION_COLUMNS = [

View File

@@ -1,6 +1,3 @@
# coding: utf-8
from __future__ import unicode_literals
import datetime
import zipfile
from csv import QUOTE_NONNUMERIC
@@ -46,7 +43,7 @@ def get_datev_csv(data, filters, csv_class):
data = result.to_csv(
# Reason for str(';'): https://github.com/pandas-dev/pandas/issues/6035
sep=str(';'),
sep=';',
# European decimal seperator
decimal=',',
# Windows "ANSI" encoding

View File

@@ -1,6 +1,3 @@
from __future__ import unicode_literals
from six import iteritems
states = [
'',
@@ -83,4 +80,4 @@ state_numbers = {
"West Bengal": "19",
}
number_state_mapping = {v: k for k, v in iteritems(state_numbers)}
number_state_mapping = {v: k for k, v in state_numbers.items()}

View File

@@ -1,7 +1,6 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe, os, json
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
@@ -13,7 +12,7 @@ from frappe.utils import today
def setup(company=None, patch=True):
# Company independent fixtures should be called only once at the first company setup
if frappe.db.count('Company', {'country': 'India'}) <=1:
if patch or frappe.db.count('Company', {'country': 'India'}) <=1:
setup_company_independent_fixtures(patch=patch)
if not patch:

View File

@@ -1,5 +1,3 @@
from __future__ import unicode_literals
import unittest
from unittest.mock import patch

View File

@@ -1,5 +1,3 @@
from __future__ import unicode_literals
import json
import re
@@ -7,7 +5,6 @@ import frappe
from frappe import _
from frappe.model.utils import get_fetch_values
from frappe.utils import cint, cstr, date_diff, flt, getdate, nowdate
from six import string_types
from erpnext.controllers.accounts_controller import get_taxes_and_charges
from erpnext.controllers.taxes_and_totals import get_itemised_tax, get_itemised_taxable_amount
@@ -29,12 +26,13 @@ def validate_gstin_for_india(doc, method):
gst_category = []
if len(doc.links):
link_doctype = doc.links[0].get("link_doctype")
link_name = doc.links[0].get("link_name")
if hasattr(doc, 'gst_category'):
if len(doc.links):
link_doctype = doc.links[0].get("link_doctype")
link_name = doc.links[0].get("link_name")
if link_doctype in ["Customer", "Supplier"]:
gst_category = frappe.db.get_value(link_doctype, {'name': link_name}, ['gst_category'])
if link_doctype in ["Customer", "Supplier"]:
gst_category = frappe.db.get_value(link_doctype, {'name': link_name}, ['gst_category'])
doc.gstin = doc.gstin.upper().strip()
if not doc.gstin or doc.gstin == 'NA':
@@ -76,12 +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):
for link in doc.links:
if link.link_doctype in ['Customer', 'Supplier']:
if doc.get('gstin'):
frappe.db.sql("""
UPDATE `tab{0}` SET gst_category = %s WHERE name = %s AND gst_category = 'Unregistered'
""".format(link.link_doctype), ("Registered Regular", link.link_name)) #nosec
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')
def set_gst_state_and_state_number(doc):
if not doc.gst_state:
@@ -194,7 +191,7 @@ def get_place_of_supply(party_details, doctype):
@frappe.whitelist()
def get_regional_address_details(party_details, doctype, company):
if isinstance(party_details, string_types):
if isinstance(party_details, str):
party_details = json.loads(party_details)
party_details = frappe._dict(party_details)
@@ -446,7 +443,7 @@ def get_ewb_data(dt, dn):
data = get_address_details(data, doc, company_address, billing_address, dispatch_address)
data.itemList = []
data.totalValue = doc.total
data.totalValue = doc.net_total
data = get_item_list(data, doc, hsn_wise=True)
@@ -791,7 +788,7 @@ def get_regional_round_off_accounts(company, account_list):
if country != 'India':
return
if isinstance(account_list, string_types):
if isinstance(account_list, str):
account_list = json.loads(account_list)
if not frappe.db.get_single_value('GST Settings', 'round_off_gst_values'):
@@ -855,7 +852,7 @@ def get_depreciation_amount(asset, depreciable_value, row):
if row.depreciation_method in ("Straight Line", "Manual"):
# if the Depreciation Schedule is being prepared for the first time
if not asset.flags.increase_in_asset_life:
depreciation_amount = (flt(row.value_after_depreciation) -
depreciation_amount = (flt(asset.gross_purchase_amount) - flt(asset.opening_accumulated_depreciation) -
flt(row.expected_value_after_useful_life)) / depreciation_left
# if the Depreciation Schedule is being modified after Asset Repair

View File

@@ -1,5 +1,3 @@
# coding=utf-8
fiscal_regimes = [
"RF01-Ordinario",
"RF02-Contribuenti minimi (art.1, c.96-117, L. 244/07)",

View File

@@ -2,7 +2,6 @@
# License: GNU General Public License v3. See license.txt
# coding=utf-8
from __future__ import unicode_literals
import frappe
from frappe import _

View File

@@ -1,5 +1,3 @@
from __future__ import unicode_literals
import io
import json
@@ -7,7 +5,6 @@ import frappe
from frappe import _
from frappe.utils import cstr, flt
from frappe.utils.file_manager import remove_file
from six import string_types
from erpnext.controllers.taxes_and_totals import get_itemised_tax
from erpnext.regional.italy import state_codes
@@ -168,7 +165,7 @@ def get_invoice_summary(items, taxes):
if tax.rate == 0:
for item in items:
item_tax_rate = item.item_tax_rate
if isinstance(item.item_tax_rate, string_types):
if isinstance(item.item_tax_rate, str):
item_tax_rate = json.loads(item.item_tax_rate)
if item_tax_rate and tax.account_head in item_tax_rate:

File diff suppressed because one or more lines are too long

View File

@@ -1,4 +1,3 @@
# coding: utf-8
"""
Provide a report and downloadable CSV according to the German DATEV format.
@@ -7,13 +6,11 @@ Provide a report and downloadable CSV according to the German DATEV format.
- CSV download functionality `download_datev_csv` that provides a CSV file with
all required columns. Used to import the data into the DATEV Software.
"""
from __future__ import unicode_literals
import json
import frappe
from frappe import _
from six import string_types
from erpnext.accounts.utils import get_fiscal_year
from erpnext.regional.germany.utils.datev.datev_constants import (
@@ -351,7 +348,7 @@ def run_query(filters, extra_fields, extra_joins, extra_filters, as_dict=1):
gl.posting_date as 'Belegdatum',
gl.voucher_no as 'Belegfeld 1',
LEFT(gl.remarks, 60) as 'Buchungstext',
REPLACE(LEFT(gl.remarks, 60), '\n', ' ') as 'Buchungstext',
gl.voucher_type as 'Beleginfo - Art 1',
gl.voucher_no as 'Beleginfo - Inhalt 1',
gl.against_voucher_type as 'Beleginfo - Art 2',
@@ -546,7 +543,7 @@ def download_datev_csv(filters):
Arguments / Params:
filters -- dict of filters to be passed to the sql query
"""
if isinstance(filters, string_types):
if isinstance(filters, str):
filters = json.loads(filters)
validate(filters)

View File

@@ -1,6 +1,3 @@
# coding=utf-8
from __future__ import unicode_literals
import zipfile
from unittest import TestCase

View File

@@ -1,7 +1,6 @@
# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
from erpnext.accounts.report.sales_register.sales_register import _execute

View File

@@ -1,7 +1,6 @@
# Copyright (c) 2013, FinByz Tech Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import json
import re

View File

@@ -1,7 +1,6 @@
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import re

View File

@@ -1,7 +1,6 @@
# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
from erpnext.accounts.report.item_wise_purchase_register.item_wise_purchase_register import (
_execute,

View File

@@ -1,7 +1,6 @@
# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
from erpnext.accounts.report.item_wise_sales_register.item_wise_sales_register import _execute

View File

@@ -1,7 +1,6 @@
# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
from erpnext.accounts.report.purchase_register.purchase_register import _execute

View File

@@ -1,7 +1,6 @@
# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
from erpnext.accounts.report.sales_register.sales_register import _execute

View File

@@ -1,7 +1,6 @@
# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import json
from datetime import date
@@ -9,7 +8,6 @@ from datetime import date
import frappe
from frappe import _
from frappe.utils import flt, formatdate, getdate
from six import iteritems
from erpnext.regional.india.utils import get_gst_accounts
@@ -124,7 +122,7 @@ class Gstr1Report(object):
row["cess_amount"] += flt(self.invoice_cess.get(inv), 2)
row["type"] = "E" if ecommerce_gstin else "OE"
for key, value in iteritems(b2cs_output):
for key, value in b2cs_output.items():
self.data.append(value)
def get_row_data_for_invoice(self, invoice, invoice_details, tax_rate, items):
@@ -250,18 +248,17 @@ class Gstr1Report(object):
""" % (self.doctype, ', '.join(['%s']*len(self.invoices))), tuple(self.invoices), as_dict=1)
for d in items:
if d.item_code not in self.invoice_items.get(d.parent, {}):
self.invoice_items.setdefault(d.parent, {}).setdefault(d.item_code, 0.0)
self.invoice_items[d.parent][d.item_code] += d.get('taxable_value', 0) or d.get('base_net_amount', 0)
self.invoice_items.setdefault(d.parent, {}).setdefault(d.item_code, 0.0)
self.invoice_items[d.parent][d.item_code] += d.get('taxable_value', 0) or d.get('base_net_amount', 0)
item_tax_rate = {}
item_tax_rate = {}
if d.item_tax_rate:
item_tax_rate = json.loads(d.item_tax_rate)
if d.item_tax_rate:
item_tax_rate = json.loads(d.item_tax_rate)
for account, rate in item_tax_rate.items():
tax_rate_dict = self.item_tax_rate.setdefault(d.parent, {}).setdefault(d.item_code, [])
tax_rate_dict.append(rate)
for account, rate in item_tax_rate.items():
tax_rate_dict = self.item_tax_rate.setdefault(d.parent, {}).setdefault(d.item_code, [])
tax_rate_dict.append(rate)
def get_items_based_on_tax_rate(self):
self.tax_details = frappe.db.sql("""
@@ -318,7 +315,7 @@ class Gstr1Report(object):
+ "<br>" + "<br>".join(unidentified_gst_accounts), alert=True)
# Build itemised tax for export invoices where tax table is blank
for invoice, items in iteritems(self.invoice_items):
for invoice, items in self.invoice_items.items():
if invoice not in self.items_based_on_tax_rate and invoice not in unidentified_gst_accounts_invoice \
and self.invoices.get(invoice, {}).get('export_type') == "Without Payment of Tax" \
and self.invoices.get(invoice, {}).get('gst_category') == "Overseas":
@@ -783,7 +780,7 @@ def get_b2b_json(res, gstin):
b2b_item, inv = {"ctin": gst_in, "inv": []}, []
if not gst_in: continue
for number, invoice in iteritems(res[gst_in]):
for number, invoice in res[gst_in].items():
if not invoice[0]["place_of_supply"]:
frappe.throw(_("""{0} not entered in Invoice {1}.
Please update and try again""").format(frappe.bold("Place Of Supply"),
@@ -852,7 +849,7 @@ def get_b2cs_json(data, gstin):
def get_advances_json(data, gstin):
company_state_number = gstin[0:2]
out = []
for place_of_supply, items in iteritems(data):
for place_of_supply, items in data.items():
supply_type = "INTRA" if company_state_number == place_of_supply.split('-')[0] else "INTER"
row = {
"pos": place_of_supply.split('-')[0],
@@ -934,7 +931,7 @@ def get_cdnr_reg_json(res, gstin):
cdnr_item, inv = {"ctin": gst_in, "nt": []}, []
if not gst_in: continue
for number, invoice in iteritems(res[gst_in]):
for number, invoice in res[gst_in].items():
if not invoice[0]["place_of_supply"]:
frappe.throw(_("""{0} not entered in Invoice {1}.
Please update and try again""").format(frappe.bold("Place Of Supply"),
@@ -965,7 +962,7 @@ def get_cdnr_reg_json(res, gstin):
def get_cdnr_unreg_json(res, gstin):
out = []
for invoice, items in iteritems(res):
for invoice, items in res.items():
inv_item = {
"nt_num": items[0]["invoice_number"],
"nt_dt": getdate(items[0]["posting_date"]).strftime('%d-%m-%Y'),

View File

@@ -1,7 +1,6 @@
# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
from datetime import date

View File

@@ -1,7 +1,6 @@
# Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import json
@@ -9,7 +8,6 @@ import frappe
from frappe import _
from frappe.model.meta import get_field_precision
from frappe.utils import cstr, flt, getdate
from six import iteritems
import erpnext
from erpnext.regional.india.utils import get_gst_accounts
@@ -213,7 +211,7 @@ def get_merged_data(columns, data):
else:
merged_hsn_dict[row[0]][d['fieldname']] = row[i]
for key, value in iteritems(merged_hsn_dict):
for key, value in merged_hsn_dict.items():
result.append(value)
return result

View File

@@ -49,7 +49,6 @@ frappe.query_reports["KSA VAT"] = {
value = $(`<span>${value}</span>`);
var $value = $(value).css("font-weight", "bold");
value = $value.wrap("<p></p>").parent().html();
console.log($value)
return value
}
}else{

View File

@@ -1,7 +1,6 @@
# Copyright (c) 2013, Havenir Solutions and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import json
@@ -119,14 +118,14 @@ def get_tax_data_for_each_vat_setting(vat_setting, filters, doctype):
total_taxable_adjustment_amount = 0
total_tax = 0
# Fetch All Invoices
invoices = frappe.get_list(doctype,
invoices = frappe.get_all(doctype,
filters ={
'docstatus': 1,
'posting_date': ['between', [from_date, to_date]]
}, fields =['name', 'is_return'])
for invoice in invoices:
invoice_items = frappe.get_list(f'{doctype} Item',
invoice_items = frappe.get_all(f'{doctype} Item',
filters ={
'docstatus': 1,
'parent': invoice.name,

View File

@@ -1,7 +1,6 @@
# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from frappe import _

View File

@@ -1,7 +1,6 @@
# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from frappe import _

View File

@@ -1,6 +1,3 @@
# coding=utf-8
from __future__ import unicode_literals
from unittest import TestCase
import frappe

View File

@@ -1,7 +1,6 @@
# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from frappe import _

View File

@@ -1,7 +1,6 @@
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
from unittest import TestCase

View File

@@ -1,7 +1,6 @@
# Copyright (c) 2021, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import json

View File

@@ -1,19 +1,17 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
from frappe.permissions import add_permission, update_permission_property
from erpnext.regional.united_arab_emirates.setup import make_custom_fields as uae_custom_fields, add_print_formats
from erpnext.regional.saudi_arabia.wizard.operations.setup_ksa_vat_setting import create_ksa_vat_setting
from frappe.custom.doctype.custom_field.custom_field import create_custom_field
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields
def setup(company=None, patch=True):
uae_custom_fields()
add_print_formats()
add_permissions()
create_ksa_vat_setting(company)
make_qrcode_field()
make_custom_fields()
def add_permissions():
"""Add Permissions for KSA VAT Setting."""
@@ -26,12 +24,40 @@ def add_permissions():
"""Enable KSA VAT Report"""
frappe.db.set_value('Report', 'KSA VAT', 'disabled', 0)
def make_qrcode_field():
"""Created QR code Image file"""
qr_code_field = dict(
fieldname='qr_code',
label='QR Code',
fieldtype='Attach Image',
read_only=1, no_copy=1, hidden=1)
def make_custom_fields():
"""Create Custom fields
- QR code Image file
- Company Name in Arabic
- Address in Arabic
"""
custom_fields = {
'Sales Invoice': [
dict(
fieldname='qr_code',
label='QR Code',
fieldtype='Attach Image',
read_only=1, no_copy=1, hidden=1
)
],
'Address': [
dict(
fieldname='address_in_arabic',
label='Address in Arabic',
fieldtype='Data',
insert_after='address_line2'
)
],
'Company': [
dict(
fieldname='company_name_in_arabic',
label='Company Name In Arabic',
fieldtype='Data',
insert_after='company_name'
)
]
}
create_custom_field('Sales Invoice', qr_code_field)
create_custom_fields(custom_fields, update=True)
def update_regional_tax_settings(country, company):
create_ksa_vat_setting(company)

View File

@@ -15,7 +15,7 @@
{
"title": "Exempted sales",
"item_tax_template": "KSA VAT Exempted",
"account": "VAT Zero"
"account": "VAT Exempted"
}
]
},
@@ -40,7 +40,7 @@
{
"title": "Exempted purchases",
"item_tax_template": "KSA VAT Exempted",
"account": "VAT Zero"
"account": "VAT Exempted"
}
]
}

View File

@@ -3,14 +3,11 @@ import os
import frappe
from erpnext.setup.setup_wizard.operations.taxes_setup import setup_taxes_and_charges
def create_ksa_vat_setting(company):
"""On creation of first company. Creates KSA VAT Setting"""
company = frappe.get_doc('Company', company)
setup_taxes_and_charges(company.name, company.country)
file_path = os.path.join(os.path.dirname(__file__), '..', 'data', 'ksa_vat_settings.json')
with open(file_path, 'r') as json_file:

View File

@@ -1,7 +1,6 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields

View File

@@ -1,4 +1,2 @@
from __future__ import unicode_literals
def setup(company=None, patch=True):
pass

View File

@@ -1,7 +1,6 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
from frappe.custom.doctype.custom_field.custom_field import create_custom_fields

View File

@@ -1,9 +1,6 @@
from __future__ import unicode_literals
import frappe
from frappe import _
from frappe.utils import flt, money_in_words, round_based_on_smallest_currency_fraction
from six import iteritems
import erpnext
from erpnext.controllers.taxes_and_totals import get_itemised_tax
@@ -24,7 +21,7 @@ def update_itemised_tax_data(doc):
# First check if tax rate is present
# If not then look up in item_wise_tax_detail
if item_tax_rate:
for account, rate in iteritems(item_tax_rate):
for account, rate in item_tax_rate.items():
tax_rate += rate
elif row.item_code and itemised_tax.get(row.item_code):
tax_rate = sum([tax.get('tax_rate', 0) for d, tax in itemised_tax.get(row.item_code).items()])

View File

@@ -1,7 +1,6 @@
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import frappe
import os
import json

View File

@@ -1,6 +1,5 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
from __future__ import unicode_literals
import unittest