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