Merge branch 'develop' into service-units-in-appointment
This commit is contained in:
commit
ab920b55a7
@ -53,8 +53,8 @@ def _execute(filters=None, additional_table_columns=None, additional_query_colum
|
||||
|
||||
row = {
|
||||
'item_code': d.item_code,
|
||||
'item_name': item_record.item_name,
|
||||
'item_group': item_record.item_group,
|
||||
'item_name': item_record.item_name if item_record else d.item_name,
|
||||
'item_group': item_record.item_group if item_record else d.item_group,
|
||||
'description': d.description,
|
||||
'invoice': d.parent,
|
||||
'posting_date': d.posting_date,
|
||||
@ -316,6 +316,7 @@ def get_items(filters, additional_query_columns):
|
||||
`tabPurchase Invoice`.posting_date, `tabPurchase Invoice`.credit_to, `tabPurchase Invoice`.company,
|
||||
`tabPurchase Invoice`.supplier, `tabPurchase Invoice`.remarks, `tabPurchase Invoice`.base_net_total,
|
||||
`tabPurchase Invoice Item`.`item_code`, `tabPurchase Invoice Item`.description,
|
||||
`tabPurchase Invoice Item`.`item_name`, `tabPurchase Invoice Item`.`item_group`,
|
||||
`tabPurchase Invoice Item`.`project`, `tabPurchase Invoice Item`.`purchase_order`,
|
||||
`tabPurchase Invoice Item`.`purchase_receipt`, `tabPurchase Invoice Item`.`po_detail`,
|
||||
`tabPurchase Invoice Item`.`expense_account`, `tabPurchase Invoice Item`.`stock_qty`,
|
||||
|
@ -8,12 +8,12 @@
|
||||
"is_mandatory": 0,
|
||||
"is_single": 0,
|
||||
"is_skipped": 0,
|
||||
"modified": "2020-05-14 17:38:27.496696",
|
||||
"modified": "2021-01-21 15:28:52.483839",
|
||||
"modified_by": "Administrator",
|
||||
"name": "Create Opportunity",
|
||||
"owner": "Administrator",
|
||||
"reference_document": "Opportunity",
|
||||
"show_full_form": 0,
|
||||
"show_full_form": 1,
|
||||
"title": "Create Opportunity",
|
||||
"validate_action": 1
|
||||
}
|
@ -12,6 +12,8 @@ frappe.ui.form.on('Additional Salary', {
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
frm.trigger('set_earning_component');
|
||||
},
|
||||
|
||||
employee: function(frm) {
|
||||
@ -43,6 +45,20 @@ frappe.ui.form.on('Additional Salary', {
|
||||
});
|
||||
},
|
||||
|
||||
company: function(frm) {
|
||||
frm.trigger('set_earning_component');
|
||||
},
|
||||
|
||||
set_earning_component: function(frm) {
|
||||
if (!frm.doc.company) return;
|
||||
frm.set_query("salary_component", function() {
|
||||
return {
|
||||
query: "erpnext.payroll.doctype.salary_structure.salary_structure.get_earning_deduction_components",
|
||||
filters: {type: "earning", company: frm.doc.company}
|
||||
};
|
||||
});
|
||||
},
|
||||
|
||||
get_employee_currency: function(frm) {
|
||||
frappe.call({
|
||||
method: "erpnext.payroll.doctype.salary_structure_assignment.salary_structure_assignment.get_employee_currency",
|
||||
|
File diff suppressed because one or more lines are too long
@ -4,7 +4,7 @@
|
||||
frappe.query_reports["IRS 1099"] = {
|
||||
"filters": [
|
||||
{
|
||||
"fieldname":"company",
|
||||
"fieldname": "company",
|
||||
"label": __("Company"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Company",
|
||||
@ -13,7 +13,7 @@ frappe.query_reports["IRS 1099"] = {
|
||||
"width": 80,
|
||||
},
|
||||
{
|
||||
"fieldname":"fiscal_year",
|
||||
"fieldname": "fiscal_year",
|
||||
"label": __("Fiscal Year"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Fiscal Year",
|
||||
@ -22,7 +22,7 @@ frappe.query_reports["IRS 1099"] = {
|
||||
"width": 80,
|
||||
},
|
||||
{
|
||||
"fieldname":"supplier_group",
|
||||
"fieldname": "supplier_group",
|
||||
"label": __("Supplier Group"),
|
||||
"fieldtype": "Link",
|
||||
"options": "Supplier Group",
|
||||
@ -32,16 +32,16 @@ frappe.query_reports["IRS 1099"] = {
|
||||
},
|
||||
],
|
||||
|
||||
onload: function(query_report) {
|
||||
onload: function (query_report) {
|
||||
query_report.page.add_inner_button(__("Print IRS 1099 Forms"), () => {
|
||||
build_1099_print(query_report);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function build_1099_print(query_report){
|
||||
function build_1099_print(query_report) {
|
||||
let filters = JSON.stringify(query_report.get_values());
|
||||
let w = window.open('/api/method/erpnext.regional.report.irs_1099.irs_1099.irs_1099_print?' +
|
||||
'&filters=' + encodeURIComponent(filters));
|
||||
'&filters=' + encodeURIComponent(filters));
|
||||
// w.print();
|
||||
}
|
||||
|
@ -1,29 +1,34 @@
|
||||
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
|
||||
# For license information, please see license.txt
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
import json
|
||||
from frappe import _, _dict
|
||||
from frappe.utils import nowdate
|
||||
from frappe.utils.data import fmt_money
|
||||
from erpnext.accounts.utils import get_fiscal_year
|
||||
|
||||
from PyPDF2 import PdfFileWriter
|
||||
|
||||
import frappe
|
||||
from erpnext.accounts.utils import get_fiscal_year
|
||||
from frappe import _
|
||||
from frappe.utils import cstr, nowdate
|
||||
from frappe.utils.data import fmt_money
|
||||
from frappe.utils.jinja import render_template
|
||||
from frappe.utils.pdf import get_pdf
|
||||
from frappe.utils.print_format import read_multi_pdf
|
||||
from frappe.utils.jinja import render_template
|
||||
|
||||
IRS_1099_FORMS_FILE_EXTENSION = ".pdf"
|
||||
|
||||
|
||||
def execute(filters=None):
|
||||
filters = filters if isinstance(filters, _dict) else _dict(filters)
|
||||
|
||||
filters = filters if isinstance(filters, frappe._dict) else frappe._dict(filters)
|
||||
if not filters:
|
||||
filters.setdefault('fiscal_year', get_fiscal_year(nowdate())[0])
|
||||
filters.setdefault('company', frappe.db.get_default("company"))
|
||||
|
||||
region = frappe.db.get_value("Company", fieldname = ["country"], filters = { "name": filters.company })
|
||||
region = frappe.db.get_value("Company",
|
||||
filters={"name": filters.company},
|
||||
fieldname=["country"])
|
||||
|
||||
if region != 'United States':
|
||||
return [],[]
|
||||
return [], []
|
||||
|
||||
data = []
|
||||
columns = get_columns()
|
||||
@ -34,20 +39,23 @@ def execute(filters=None):
|
||||
s.tax_id as "tax_id",
|
||||
SUM(gl.debit_in_account_currency) AS "payments"
|
||||
FROM
|
||||
`tabGL Entry` gl INNER JOIN `tabSupplier` s
|
||||
`tabGL Entry` gl
|
||||
INNER JOIN `tabSupplier` s
|
||||
WHERE
|
||||
s.name = gl.party
|
||||
AND s.irs_1099 = 1
|
||||
AND gl.fiscal_year = %(fiscal_year)s
|
||||
AND gl.party_type = "Supplier"
|
||||
|
||||
AND s.irs_1099 = 1
|
||||
AND gl.fiscal_year = %(fiscal_year)s
|
||||
AND gl.party_type = "Supplier"
|
||||
GROUP BY
|
||||
gl.party
|
||||
|
||||
ORDER BY
|
||||
gl.party DESC""", {"fiscal_year": filters.fiscal_year,
|
||||
gl.party DESC
|
||||
""", {
|
||||
"fiscal_year": filters.fiscal_year,
|
||||
"supplier_group": filters.supplier_group,
|
||||
"company": filters.company}, as_dict=True)
|
||||
"company": filters.company
|
||||
}, as_dict=True)
|
||||
|
||||
return columns, data
|
||||
|
||||
|
||||
@ -74,7 +82,6 @@ def get_columns():
|
||||
"width": 120
|
||||
},
|
||||
{
|
||||
|
||||
"fieldname": "payments",
|
||||
"label": _("Total Payments"),
|
||||
"fieldtype": "Currency",
|
||||
@ -88,23 +95,32 @@ def irs_1099_print(filters):
|
||||
if not filters:
|
||||
frappe._dict({
|
||||
"company": frappe.db.get_default("Company"),
|
||||
"fiscal_year": frappe.db.get_default("fiscal_year")})
|
||||
"fiscal_year": frappe.db.get_default("Fiscal Year")
|
||||
})
|
||||
else:
|
||||
filters = frappe._dict(json.loads(filters))
|
||||
|
||||
fiscal_year_doc = get_fiscal_year(fiscal_year=filters.fiscal_year, as_dict=True)
|
||||
fiscal_year = cstr(fiscal_year_doc.year_start_date.year)
|
||||
|
||||
company_address = get_payer_address_html(filters.company)
|
||||
company_tin = frappe.db.get_value("Company", filters.company, "tax_id")
|
||||
|
||||
columns, data = execute(filters)
|
||||
template = frappe.get_doc("Print Format", "IRS 1099 Form").html
|
||||
output = PdfFileWriter()
|
||||
|
||||
for row in data:
|
||||
row["fiscal_year"] = fiscal_year
|
||||
row["company"] = filters.company
|
||||
row["company_tin"] = company_tin
|
||||
row["payer_street_address"] = company_address
|
||||
row["recipient_street_address"], row["recipient_city_state"] = get_street_address_html("Supplier", row.supplier)
|
||||
row["recipient_street_address"], row["recipient_city_state"] = get_street_address_html(
|
||||
"Supplier", row.supplier)
|
||||
row["payments"] = fmt_money(row["payments"], precision=0, currency="USD")
|
||||
frappe._dict(row)
|
||||
pdf = get_pdf(render_template(template, row), output=output if output else None)
|
||||
frappe.local.response.filename = filters.fiscal_year + " " + filters.company + " IRS 1099 Forms"
|
||||
|
||||
frappe.local.response.filename = f"{filters.fiscal_year} {filters.company} IRS 1099 Forms{IRS_1099_FORMS_FILE_EXTENSION}"
|
||||
frappe.local.response.filecontent = read_multi_pdf(output)
|
||||
frappe.local.response.type = "download"
|
||||
|
||||
@ -120,36 +136,45 @@ def get_payer_address_html(company):
|
||||
ORDER BY
|
||||
address_type="Postal" DESC, address_type="Billing" DESC
|
||||
LIMIT 1
|
||||
""", {"company": company}, as_dict=True)
|
||||
""", {"company": company}, as_dict=True)
|
||||
|
||||
address_display = ""
|
||||
if address_list:
|
||||
company_address = address_list[0]["name"]
|
||||
return frappe.get_doc("Address", company_address).get_display()
|
||||
else:
|
||||
return ""
|
||||
address_display = frappe.get_doc("Address", company_address).get_display()
|
||||
|
||||
return address_display
|
||||
|
||||
|
||||
def get_street_address_html(party_type, party):
|
||||
address_list = frappe.db.sql("""
|
||||
SELECT
|
||||
link.parent
|
||||
FROM `tabDynamic Link` link, `tabAddress` address
|
||||
WHERE link.parenttype = "Address"
|
||||
AND link.link_name = %(party)s
|
||||
ORDER BY address.address_type="Postal" DESC,
|
||||
FROM
|
||||
`tabDynamic Link` link,
|
||||
`tabAddress` address
|
||||
WHERE
|
||||
link.parenttype = "Address"
|
||||
AND link.link_name = %(party)s
|
||||
ORDER BY
|
||||
address.address_type="Postal" DESC,
|
||||
address.address_type="Billing" DESC
|
||||
LIMIT 1
|
||||
""", {"party": party}, as_dict=True)
|
||||
""", {"party": party}, as_dict=True)
|
||||
|
||||
street_address = city_state = ""
|
||||
if address_list:
|
||||
supplier_address = address_list[0]["parent"]
|
||||
doc = frappe.get_doc("Address", supplier_address)
|
||||
|
||||
if doc.address_line2:
|
||||
street = doc.address_line1 + "<br>\n" + doc.address_line2 + "<br>\n"
|
||||
street_address = doc.address_line1 + "<br>\n" + doc.address_line2 + "<br>\n"
|
||||
else:
|
||||
street = doc.address_line1 + "<br>\n"
|
||||
city = doc.city + ", " if doc.city else ""
|
||||
city = city + doc.state + " " if doc.state else city
|
||||
city = city + doc.pincode if doc.pincode else city
|
||||
city += "<br>\n"
|
||||
return street, city
|
||||
else:
|
||||
return "", ""
|
||||
street_address = doc.address_line1 + "<br>\n"
|
||||
|
||||
city_state = doc.city + ", " if doc.city else ""
|
||||
city_state = city_state + doc.state + " " if doc.state else city_state
|
||||
city_state = city_state + doc.pincode if doc.pincode else city_state
|
||||
city_state += "<br>\n"
|
||||
|
||||
return street_address, city_state
|
||||
|
@ -214,7 +214,10 @@ class Issue(Document):
|
||||
|
||||
def before_insert(self):
|
||||
if frappe.db.get_single_value("Support Settings", "track_service_level_agreement"):
|
||||
self.set_response_and_resolution_time(priority=self.priority, service_level_agreement=self.service_level_agreement)
|
||||
if frappe.flags.in_test:
|
||||
self.set_response_and_resolution_time(priority=self.priority, service_level_agreement=self.service_level_agreement)
|
||||
else:
|
||||
self.set_response_and_resolution_time()
|
||||
|
||||
def set_response_and_resolution_time(self, priority=None, service_level_agreement=None):
|
||||
service_level_agreement = get_active_service_level_agreement_for(priority=priority,
|
||||
|
Loading…
Reference in New Issue
Block a user