fix: indentations
This commit is contained in:
parent
8a42570c96
commit
940db71a82
@ -275,7 +275,7 @@ doc_events = {
|
|||||||
"on_trash": [
|
"on_trash": [
|
||||||
"erpnext.regional.check_deletion_permission",
|
"erpnext.regional.check_deletion_permission",
|
||||||
"erpnext.regional.saudi_arabia.utils.delete_qr_code_file"
|
"erpnext.regional.saudi_arabia.utils.delete_qr_code_file"
|
||||||
],
|
],
|
||||||
"validate": [
|
"validate": [
|
||||||
"erpnext.regional.india.utils.validate_document_name",
|
"erpnext.regional.india.utils.validate_document_name",
|
||||||
"erpnext.regional.india.utils.update_taxable_values"
|
"erpnext.regional.india.utils.update_taxable_values"
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
frappe.ui.form.on('KSA VAT Setting', {
|
frappe.ui.form.on('KSA VAT Setting', {
|
||||||
onload: function(frm) {
|
onload: function () {
|
||||||
frappe.breadcrumbs.add('Accounts', 'KSA VAT Setting');
|
frappe.breadcrumbs.add('Accounts', 'KSA VAT Setting');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
frappe.listview_settings['KSA VAT Setting'] = {
|
frappe.listview_settings['KSA VAT Setting'] = {
|
||||||
onload(list) {
|
onload () {
|
||||||
frappe.breadcrumbs.add('Accounts');
|
frappe.breadcrumbs.add('Accounts');
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,11 +2,13 @@
|
|||||||
# For license information, please see license.txt
|
# For license information, please see license.txt
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import json
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _
|
from frappe import _
|
||||||
from frappe.utils import get_url_to_list
|
from frappe.utils import get_url_to_list
|
||||||
from erpnext.controllers.taxes_and_totals import get_itemised_tax_breakup_data, get_rounded_tax_amount
|
|
||||||
import json
|
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
columns = columns = get_columns()
|
columns = columns = get_columns()
|
||||||
@ -52,7 +54,7 @@ def get_data(filters):
|
|||||||
return data
|
return data
|
||||||
|
|
||||||
ksa_vat_setting = frappe.get_doc('KSA VAT Setting', company)
|
ksa_vat_setting = frappe.get_doc('KSA VAT Setting', company)
|
||||||
|
|
||||||
# Sales Heading
|
# Sales Heading
|
||||||
append_data(data, 'VAT on Sales', '', '', '')
|
append_data(data, 'VAT on Sales', '', '', '')
|
||||||
|
|
||||||
@ -63,19 +65,19 @@ def get_data(filters):
|
|||||||
for vat_setting in ksa_vat_setting.ksa_vat_sales_accounts:
|
for vat_setting in ksa_vat_setting.ksa_vat_sales_accounts:
|
||||||
total_taxable_amount, total_taxable_adjustment_amount, \
|
total_taxable_amount, total_taxable_adjustment_amount, \
|
||||||
total_tax = get_tax_data_for_each_vat_setting(vat_setting, filters, 'Sales Invoice')
|
total_tax = get_tax_data_for_each_vat_setting(vat_setting, filters, 'Sales Invoice')
|
||||||
|
|
||||||
# Adding results to data
|
# Adding results to data
|
||||||
append_data(data, vat_setting.title, total_taxable_amount,
|
append_data(data, vat_setting.title, total_taxable_amount,
|
||||||
total_taxable_adjustment_amount, total_tax)
|
total_taxable_adjustment_amount, total_tax)
|
||||||
|
|
||||||
grand_total_taxable_amount += total_taxable_amount
|
grand_total_taxable_amount += total_taxable_amount
|
||||||
grand_total_taxable_adjustment_amount += total_taxable_adjustment_amount
|
grand_total_taxable_adjustment_amount += total_taxable_adjustment_amount
|
||||||
grand_total_tax += total_tax
|
grand_total_tax += total_tax
|
||||||
|
|
||||||
# Sales Grand Total
|
# Sales Grand Total
|
||||||
append_data(data, 'Grand Total', grand_total_taxable_amount,
|
append_data(data, 'Grand Total', grand_total_taxable_amount,
|
||||||
grand_total_taxable_adjustment_amount, grand_total_tax )
|
grand_total_taxable_adjustment_amount, grand_total_tax)
|
||||||
|
|
||||||
# Blank Line
|
# Blank Line
|
||||||
append_data(data, '', '', '', '')
|
append_data(data, '', '', '', '')
|
||||||
|
|
||||||
@ -89,9 +91,9 @@ def get_data(filters):
|
|||||||
for vat_setting in ksa_vat_setting.ksa_vat_purchase_accounts:
|
for vat_setting in ksa_vat_setting.ksa_vat_purchase_accounts:
|
||||||
total_taxable_amount, total_taxable_adjustment_amount, \
|
total_taxable_amount, total_taxable_adjustment_amount, \
|
||||||
total_tax = get_tax_data_for_each_vat_setting(vat_setting, filters, 'Purchase Invoice')
|
total_tax = get_tax_data_for_each_vat_setting(vat_setting, filters, 'Purchase Invoice')
|
||||||
|
|
||||||
# Adding results to data
|
# Adding results to data
|
||||||
append_data(data, vat_setting.title, total_taxable_amount,
|
append_data(data, vat_setting.title, total_taxable_amount,
|
||||||
total_taxable_adjustment_amount, total_tax)
|
total_taxable_adjustment_amount, total_tax)
|
||||||
|
|
||||||
grand_total_taxable_amount += total_taxable_amount
|
grand_total_taxable_amount += total_taxable_amount
|
||||||
@ -99,8 +101,8 @@ def get_data(filters):
|
|||||||
grand_total_tax += total_tax
|
grand_total_tax += total_tax
|
||||||
|
|
||||||
# Purchase Grand Total
|
# Purchase Grand Total
|
||||||
append_data(data, 'Grand Total', grand_total_taxable_amount,
|
append_data(data, 'Grand Total', grand_total_taxable_amount,
|
||||||
grand_total_taxable_adjustment_amount, grand_total_tax )
|
grand_total_taxable_adjustment_amount, grand_total_tax)
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@ -117,36 +119,33 @@ def get_tax_data_for_each_vat_setting(vat_setting, filters, doctype):
|
|||||||
total_taxable_adjustment_amount = 0
|
total_taxable_adjustment_amount = 0
|
||||||
total_tax = 0
|
total_tax = 0
|
||||||
# Fetch All Invoices
|
# Fetch All Invoices
|
||||||
invoices = frappe.get_list(doctype,
|
invoices = frappe.get_list(doctype,
|
||||||
filters ={
|
filters ={
|
||||||
'docstatus': 1,
|
'docstatus': 1,
|
||||||
'posting_date': ['between', [from_date, to_date]]
|
'posting_date': ['between', [from_date, to_date]]
|
||||||
},
|
}, fields =['name', 'is_return'])
|
||||||
fields =['name', 'is_return'])
|
|
||||||
|
|
||||||
for invoice in invoices:
|
for invoice in invoices:
|
||||||
invoice_items = frappe.get_list(f'{doctype} Item',
|
invoice_items = frappe.get_list(f'{doctype} Item',
|
||||||
filters ={
|
filters ={
|
||||||
'docstatus': 1,
|
'docstatus': 1,
|
||||||
'parent': invoice.name,
|
'parent': invoice.name,
|
||||||
'item_tax_template': vat_setting.item_tax_template
|
'item_tax_template': vat_setting.item_tax_template
|
||||||
},
|
}, fields =['item_code', 'net_amount'])
|
||||||
fields =['item_code', 'net_amount'])
|
|
||||||
|
|
||||||
|
|
||||||
for item in invoice_items:
|
for item in invoice_items:
|
||||||
# Summing up total taxable amount
|
# Summing up total taxable amount
|
||||||
if invoice.is_return == 0:
|
if invoice.is_return == 0:
|
||||||
total_taxable_amount += item.net_amount
|
total_taxable_amount += item.net_amount
|
||||||
|
|
||||||
if invoice.is_return == 1:
|
if invoice.is_return == 1:
|
||||||
total_taxable_adjustment_amount += item.net_amount
|
total_taxable_adjustment_amount += item.net_amount
|
||||||
|
|
||||||
# Summing up total tax
|
# Summing up total tax
|
||||||
total_tax += get_tax_amount(item.item_code, vat_setting.account, doctype, invoice.name)
|
total_tax += get_tax_amount(item.item_code, vat_setting.account, doctype, invoice.name)
|
||||||
|
|
||||||
return total_taxable_amount, total_taxable_adjustment_amount, total_tax
|
return total_taxable_amount, total_taxable_adjustment_amount, total_tax
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def append_data(data, title, amount, adjustment_amount, vat_amount):
|
def append_data(data, title, amount, adjustment_amount, vat_amount):
|
||||||
@ -156,10 +155,10 @@ def append_data(data, title, amount, adjustment_amount, vat_amount):
|
|||||||
def get_tax_amount(item_code, account_head, doctype, parent):
|
def get_tax_amount(item_code, account_head, doctype, parent):
|
||||||
if doctype == 'Sales Invoice':
|
if doctype == 'Sales Invoice':
|
||||||
tax_doctype = 'Sales Taxes and Charges'
|
tax_doctype = 'Sales Taxes and Charges'
|
||||||
|
|
||||||
elif doctype == 'Purchase Invoice':
|
elif doctype == 'Purchase Invoice':
|
||||||
tax_doctype = 'Purchase Taxes and Charges'
|
tax_doctype = 'Purchase Taxes and Charges'
|
||||||
|
|
||||||
item_wise_tax_detail = frappe.get_value(tax_doctype, {
|
item_wise_tax_detail = frappe.get_value(tax_doctype, {
|
||||||
'docstatus': 1,
|
'docstatus': 1,
|
||||||
'parent': parent,
|
'parent': parent,
|
||||||
@ -173,5 +172,5 @@ def get_tax_amount(item_code, account_head, doctype, parent):
|
|||||||
if key == item_code:
|
if key == item_code:
|
||||||
tax_amount = value[1]
|
tax_amount = value[1]
|
||||||
break
|
break
|
||||||
|
|
||||||
return tax_amount
|
return tax_amount
|
@ -1,10 +1,11 @@
|
|||||||
import frappe
|
|
||||||
from frappe import _
|
|
||||||
from erpnext import get_region
|
|
||||||
from pyqrcode import create as qr_create
|
|
||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
import frappe
|
||||||
|
from pyqrcode import create as qr_create
|
||||||
|
|
||||||
|
from erpnext import get_region
|
||||||
|
|
||||||
|
|
||||||
def create_qr_code(doc, method):
|
def create_qr_code(doc, method):
|
||||||
"""Create QR Code after inserting Sales Inv
|
"""Create QR Code after inserting Sales Inv
|
||||||
@ -24,21 +25,21 @@ def create_qr_code(doc, method):
|
|||||||
return
|
return
|
||||||
|
|
||||||
fields = frappe.get_meta('Sales Invoice').fields
|
fields = frappe.get_meta('Sales Invoice').fields
|
||||||
|
|
||||||
for field in fields:
|
for field in fields:
|
||||||
if field.fieldname == 'qr_code' and field.fieldtype == 'Attach Image':
|
if field.fieldname == 'qr_code' and field.fieldtype == 'Attach Image':
|
||||||
# Creating public url to print format
|
# 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")
|
default_print_format = frappe.db.get_value('Property Setter', dict(property='default_print_format', doc_type=doc.doctype), "value")
|
||||||
|
|
||||||
# System Language
|
# System Language
|
||||||
language = frappe.get_system_settings('language')
|
language = frappe.get_system_settings('language')
|
||||||
|
|
||||||
# creating qr code for the url
|
# 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 }?format={ default_print_format or 'Standard' }&_lang={ language }&key={ doc.get_signature() }"
|
||||||
qr_image = io.BytesIO()
|
qr_image = io.BytesIO()
|
||||||
url = qr_create(url, error='L')
|
url = qr_create(url, error='L')
|
||||||
url.png(qr_image, scale=2, quiet_zone=1)
|
url.png(qr_image, scale=2, quiet_zone=1)
|
||||||
|
|
||||||
# making file
|
# making file
|
||||||
filename = f"QR-CODE-{doc.name}.png".replace(os.path.sep, "__")
|
filename = f"QR-CODE-{doc.name}.png".replace(os.path.sep, "__")
|
||||||
_file = frappe.get_doc({
|
_file = frappe.get_doc({
|
||||||
@ -59,7 +60,7 @@ def create_qr_code(doc, method):
|
|||||||
|
|
||||||
def delete_qr_code_file(doc, method):
|
def delete_qr_code_file(doc, method):
|
||||||
"""Delete QR Code on deleted sales invoice"""
|
"""Delete QR Code on deleted sales invoice"""
|
||||||
|
|
||||||
region = get_region(doc.company)
|
region = get_region(doc.company)
|
||||||
if region not in ['Saudi Arabia']:
|
if region not in ['Saudi Arabia']:
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user