mirror of
https://github.com/frappe/erpnext.git
synced 2026-07-28 06:58:17 +00:00
Compare commits
83 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a9e9efbd23 | ||
|
|
2f175e6d85 | ||
|
|
df817a858b | ||
|
|
4a73059ed3 | ||
|
|
552615525c | ||
|
|
25e408fd2a | ||
|
|
375a6f67ae | ||
|
|
ead8d82a84 | ||
|
|
2c229c6403 | ||
|
|
5fb78a375d | ||
|
|
8fcad571f5 | ||
|
|
53d7e667dd | ||
|
|
7395716476 | ||
|
|
c068b6a885 | ||
|
|
02d28c5908 | ||
|
|
90d0d24d1a | ||
|
|
6aab14f9cf | ||
|
|
163dbdca34 | ||
|
|
dcc99a2644 | ||
|
|
f5297cf386 | ||
|
|
9f7fd16882 | ||
|
|
5296ab1f87 | ||
|
|
e42c14f2cb | ||
|
|
4ef10fd6c3 | ||
|
|
4c0d0e226b | ||
|
|
094caaa03e | ||
|
|
ce51553d29 | ||
|
|
f41fc21274 | ||
|
|
1f49b77529 | ||
|
|
a0012f8c48 | ||
|
|
4b1c3ad7ac | ||
|
|
a063803224 | ||
|
|
63c7fd90a5 | ||
|
|
c9c02c7c85 | ||
|
|
bc7ef1937e | ||
|
|
75b63c5b4c | ||
|
|
625191d20a | ||
|
|
1417c7e828 | ||
|
|
a4bbc68945 | ||
|
|
2d7a591c61 | ||
|
|
448a5e1c9c | ||
|
|
7be75adc3f | ||
|
|
fafee7cf61 | ||
|
|
16aa23e454 | ||
|
|
a4d5c5414d | ||
|
|
b104e3595c | ||
|
|
5a06dd1ed1 | ||
|
|
27fe55efe1 | ||
|
|
9089b242ba | ||
|
|
98e511d236 | ||
|
|
93784d3804 | ||
|
|
d29fde0bf3 | ||
|
|
8326925fe8 | ||
|
|
a924b636a4 | ||
|
|
3526ed975c | ||
|
|
d0faec3cc0 | ||
|
|
661a5ce332 | ||
|
|
b289aa3548 | ||
|
|
4ed521162e | ||
|
|
8865d05b4c | ||
|
|
4df46737ef | ||
|
|
09ac547a80 | ||
|
|
c1bbaf07a4 | ||
|
|
73a081d806 | ||
|
|
e1df414f8b | ||
|
|
cefef3b62d | ||
|
|
bd4ee60d1e | ||
|
|
0555223797 | ||
|
|
de93efb304 | ||
|
|
6856033d3c | ||
|
|
1aa5462f36 | ||
|
|
f83514418e | ||
|
|
3c13e8e8b9 | ||
|
|
de0955b8ed | ||
|
|
82af75b853 | ||
|
|
d3ce4f815d | ||
|
|
85bf9203ed | ||
|
|
3763169978 | ||
|
|
4dacb89da6 | ||
|
|
c552d74746 | ||
|
|
2697c2d869 | ||
|
|
1897ed38df | ||
|
|
88bd0674ed |
@@ -5,7 +5,7 @@ import frappe
|
||||
from erpnext.hooks import regional_overrides
|
||||
from frappe.utils import getdate
|
||||
|
||||
__version__ = '11.1.23'
|
||||
__version__ = '11.1.26'
|
||||
|
||||
def get_default_company(user=None):
|
||||
'''Get default company for user'''
|
||||
|
||||
@@ -105,20 +105,27 @@ class Account(NestedSet):
|
||||
descendants = get_descendants_of('Company', self.company)
|
||||
if not descendants: return
|
||||
|
||||
acc_name_map = {}
|
||||
acc_name = frappe.db.get_value('Account', self.parent_account, "account_name")
|
||||
parent_acc_name_map = {}
|
||||
parent_acc_name = frappe.db.get_value('Account', self.parent_account, "account_name")
|
||||
for d in frappe.db.get_values('Account',
|
||||
{"company": ["in", descendants], "account_name": acc_name},
|
||||
{"company": ["in", descendants], "account_name": parent_acc_name},
|
||||
["company", "name"], as_dict=True):
|
||||
acc_name_map[d["company"]] = d["name"]
|
||||
parent_acc_name_map[d["company"]] = d["name"]
|
||||
|
||||
if not acc_name_map: return
|
||||
if not parent_acc_name_map: return
|
||||
|
||||
for company in descendants:
|
||||
if not parent_acc_name_map.get(company):
|
||||
frappe.throw(_("While creating account for child Company {0}, parent account {1} not found. Please create the parent account in corresponding COA")
|
||||
.format(company, parent_acc_name))
|
||||
|
||||
doc = frappe.copy_doc(self)
|
||||
doc.flags.ignore_root_company_validation = True
|
||||
doc.update({"company": company, "account_currency": None,
|
||||
"parent": acc_name_map[company], "parent_account": acc_name_map[company]})
|
||||
doc.update({
|
||||
"company": company,
|
||||
"account_currency": None,
|
||||
"parent_account": parent_acc_name_map[company]
|
||||
})
|
||||
doc.save()
|
||||
frappe.msgprint(_("Account {0} is added in the child company {1}")
|
||||
.format(doc.name, company))
|
||||
|
||||
@@ -12,6 +12,11 @@ frappe.ui.form.on('Bank Account', {
|
||||
}
|
||||
};
|
||||
});
|
||||
frm.set_query("party_type", function() {
|
||||
return {
|
||||
query: "erpnext.setup.doctype.party_type.party_type.get_party_type",
|
||||
};
|
||||
});
|
||||
},
|
||||
refresh: function(frm) {
|
||||
frappe.dynamic_link = { doc: frm.doc, fieldname: 'name', doctype: 'Bank Account' }
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"allow_copy": 0,
|
||||
"allow_events_in_timeline": 0,
|
||||
"allow_guest_to_view": 0,
|
||||
"allow_import": 0,
|
||||
"allow_import": 1,
|
||||
"allow_rename": 1,
|
||||
"autoname": "",
|
||||
"beta": 0,
|
||||
@@ -975,7 +975,7 @@
|
||||
"email": 1,
|
||||
"export": 1,
|
||||
"if_owner": 0,
|
||||
"import": 0,
|
||||
"import": 1,
|
||||
"permlevel": 0,
|
||||
"print": 1,
|
||||
"read": 1,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// For license information, please see license.txt
|
||||
|
||||
frappe.ui.form.on('Bank Transaction', {
|
||||
onload: function(frm) {
|
||||
onload(frm) {
|
||||
frm.set_query('payment_document', 'payment_entries', function() {
|
||||
return {
|
||||
"filters": {
|
||||
@@ -12,3 +12,21 @@ frappe.ui.form.on('Bank Transaction', {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
frappe.ui.form.on('Bank Transaction Payments', {
|
||||
payment_entries_remove: function(frm, cdt, cdn) {
|
||||
update_clearance_date(frm, cdt, cdn);
|
||||
}
|
||||
});
|
||||
|
||||
const update_clearance_date = (frm, cdt, cdn) => {
|
||||
if (frm.doc.docstatus === 1) {
|
||||
frappe.xcall('erpnext.accounts.doctype.bank_transaction.bank_transaction.unclear_reference_payment',
|
||||
{doctype: cdt, docname: cdn})
|
||||
.then(e => {
|
||||
if (e == "success") {
|
||||
frappe.show_alert({message:__("Document {0} successfully uncleared", [e]), indicator:'green'});
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,19 +1,32 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2018, Frappe Technologies Pvt. Ltd. and contributors
|
||||
# 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
|
||||
from erpnext.controllers.status_updater import StatusUpdater
|
||||
from frappe.utils import flt
|
||||
from six.moves import reduce
|
||||
from frappe import _
|
||||
|
||||
class BankTransaction(Document):
|
||||
class BankTransaction(StatusUpdater):
|
||||
def after_insert(self):
|
||||
self.unallocated_amount = abs(flt(self.credit) - flt(self.debit))
|
||||
|
||||
def on_submit(self):
|
||||
self.clear_linked_payment_entries()
|
||||
self.set_status()
|
||||
|
||||
def on_update_after_submit(self):
|
||||
allocated_amount = reduce(lambda x, y: flt(x) + flt(y), [x.allocated_amount for x in self.payment_entries])
|
||||
self.update_allocations()
|
||||
self.clear_linked_payment_entries()
|
||||
self.set_status(update=True)
|
||||
|
||||
def update_allocations(self):
|
||||
if self.payment_entries:
|
||||
allocated_amount = reduce(lambda x, y: flt(x) + flt(y), [x.allocated_amount for x in self.payment_entries])
|
||||
else:
|
||||
allocated_amount = 0
|
||||
|
||||
if allocated_amount:
|
||||
frappe.db.set_value(self.doctype, self.name, "allocated_amount", flt(allocated_amount))
|
||||
@@ -23,4 +36,67 @@ class BankTransaction(Document):
|
||||
frappe.db.set_value(self.doctype, self.name, "allocated_amount", 0)
|
||||
frappe.db.set_value(self.doctype, self.name, "unallocated_amount", abs(flt(self.credit) - flt(self.debit)))
|
||||
|
||||
self.reload()
|
||||
self.reload()
|
||||
|
||||
def clear_linked_payment_entries(self):
|
||||
for payment_entry in self.payment_entries:
|
||||
allocated_amount = get_total_allocated_amount(payment_entry)
|
||||
paid_amount = get_paid_amount(payment_entry)
|
||||
|
||||
if paid_amount and allocated_amount:
|
||||
if flt(allocated_amount[0]["allocated_amount"]) > flt(paid_amount):
|
||||
frappe.throw(_("The total allocated amount ({0}) is greated than the paid amount ({1}).".format(flt(allocated_amount[0]["allocated_amount"]), flt(paid_amount))))
|
||||
elif flt(allocated_amount[0]["allocated_amount"]) == flt(paid_amount):
|
||||
if payment_entry.payment_document in ["Payment Entry", "Journal Entry", "Purchase Invoice", "Expense Claim"]:
|
||||
self.clear_simple_entry(payment_entry)
|
||||
|
||||
elif payment_entry.payment_document == "Sales Invoice":
|
||||
self.clear_sales_invoice(payment_entry)
|
||||
|
||||
def clear_simple_entry(self, payment_entry):
|
||||
frappe.db.set_value(payment_entry.payment_document, payment_entry.payment_entry, "clearance_date", self.date)
|
||||
|
||||
def clear_sales_invoice(self, payment_entry):
|
||||
frappe.db.set_value("Sales Invoice Payment", dict(parenttype=payment_entry.payment_document,
|
||||
parent=payment_entry.payment_entry), "clearance_date", self.date)
|
||||
|
||||
def get_total_allocated_amount(payment_entry):
|
||||
return frappe.db.sql("""
|
||||
SELECT
|
||||
SUM(btp.allocated_amount) as allocated_amount,
|
||||
bt.name
|
||||
FROM
|
||||
`tabBank Transaction Payments` as btp
|
||||
LEFT JOIN
|
||||
`tabBank Transaction` bt ON bt.name=btp.parent
|
||||
WHERE
|
||||
btp.payment_document = %s
|
||||
AND
|
||||
btp.payment_entry = %s
|
||||
AND
|
||||
bt.docstatus = 1""", (payment_entry.payment_document, payment_entry.payment_entry), as_dict=True)
|
||||
|
||||
def get_paid_amount(payment_entry):
|
||||
if payment_entry.payment_document in ["Payment Entry", "Sales Invoice", "Purchase Invoice"]:
|
||||
return frappe.db.get_value(payment_entry.payment_document, payment_entry.payment_entry, "paid_amount")
|
||||
|
||||
elif payment_entry.payment_document == "Journal Entry":
|
||||
return frappe.db.get_value(payment_entry.payment_document, payment_entry.payment_entry, "total_credit")
|
||||
|
||||
elif payment_entry.payment_document == "Expense Claim":
|
||||
return frappe.db.get_value(payment_entry.payment_document, payment_entry.payment_entry, "total_amount_reimbursed")
|
||||
|
||||
else:
|
||||
frappe.throw("Please reconcile {0}: {1} manually".format(payment_entry.payment_document, payment_entry.payment_entry))
|
||||
|
||||
@frappe.whitelist()
|
||||
def unclear_reference_payment(doctype, docname):
|
||||
if frappe.db.exists(doctype, docname):
|
||||
doc = frappe.get_doc(doctype, docname)
|
||||
if doctype == "Sales Invoice":
|
||||
frappe.db.set_value("Sales Invoice Payment", dict(parenttype=doc.payment_document,
|
||||
parent=doc.payment_entry), "clearance_date", None)
|
||||
else:
|
||||
frappe.db.set_value(doc.payment_document, doc.payment_entry, "clearance_date", None)
|
||||
|
||||
return doc.payment_entry
|
||||
|
||||
@@ -6,7 +6,7 @@ frappe.listview_settings['Bank Transaction'] = {
|
||||
get_indicator: function(doc) {
|
||||
if(flt(doc.unallocated_amount)>0) {
|
||||
return [__("Unreconciled"), "orange", "unallocated_amount,>,0"];
|
||||
} else if(flt(doc.unallocated_amount)===0) {
|
||||
} else if(flt(doc.unallocated_amount)<=0) {
|
||||
return [__("Reconciled"), "green", "unallocated_amount,=,0"];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,8 @@ def upload_bank_statement():
|
||||
def create_bank_entries(columns, data, bank_account):
|
||||
header_map = get_header_mapping(columns, bank_account)
|
||||
|
||||
count = 0
|
||||
success = 0
|
||||
errors = 0
|
||||
for d in json.loads(data):
|
||||
if all(item is None for item in d) is True:
|
||||
continue
|
||||
@@ -44,7 +45,6 @@ def create_bank_entries(columns, data, bank_account):
|
||||
for key, value in iteritems(header_map):
|
||||
fields.update({key: d[int(value)-1]})
|
||||
|
||||
|
||||
try:
|
||||
bank_transaction = frappe.get_doc({
|
||||
"doctype": "Bank Transaction"
|
||||
@@ -54,12 +54,12 @@ def create_bank_entries(columns, data, bank_account):
|
||||
bank_transaction.bank_account = bank_account
|
||||
bank_transaction.insert()
|
||||
bank_transaction.submit()
|
||||
count = count + 1
|
||||
except Exception as e:
|
||||
frappe.throw(e)
|
||||
success += 1
|
||||
except Exception:
|
||||
frappe.log_error(frappe.get_traceback())
|
||||
errors += 1
|
||||
|
||||
return count
|
||||
return {"success": success, "errors": errors}
|
||||
|
||||
def get_header_mapping(columns, bank_account):
|
||||
mapping = get_bank_mapping(bank_account)
|
||||
|
||||
@@ -160,7 +160,7 @@ class PaymentEntry(AccountsController):
|
||||
d.reference_name, self.party_account_currency)
|
||||
|
||||
for field, value in iteritems(ref_details):
|
||||
if not d.get(field) or force:
|
||||
if field == 'exchange_rate' or not d.get(field) or force:
|
||||
d.set(field, value)
|
||||
|
||||
def validate_payment_type(self):
|
||||
|
||||
38
erpnext/accounts/doctype/sales_invoice/regional/india.js
Normal file
38
erpnext/accounts/doctype/sales_invoice/regional/india.js
Normal file
@@ -0,0 +1,38 @@
|
||||
frappe.ui.form.on("Sales Invoice", {
|
||||
setup: function(frm) {
|
||||
frm.set_query('transporter', function() {
|
||||
return {
|
||||
filters: {
|
||||
'is_transporter': 1
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
frm.set_query('driver', function(doc) {
|
||||
return {
|
||||
filters: {
|
||||
'transporter': doc.transporter
|
||||
}
|
||||
};
|
||||
});
|
||||
},
|
||||
|
||||
refresh: function(frm) {
|
||||
if(frm.doc.docstatus == 1 && !frm.is_dirty()
|
||||
&& !frm.doc.is_return && !frm.doc.ewaybill) {
|
||||
|
||||
frm.add_custom_button('Generate e-Way Bill JSON', () => {
|
||||
var w = window.open(
|
||||
frappe.urllib.get_full_url(
|
||||
"/api/method/erpnext.regional.india.utils.generate_ewb_json?"
|
||||
+ "dt=" + encodeURIComponent(frm.doc.doctype)
|
||||
+ "&dn=" + encodeURIComponent(frm.doc.name)
|
||||
)
|
||||
);
|
||||
if (!w) {
|
||||
frappe.msgprint(__("Please enable pop-ups")); return;
|
||||
}
|
||||
}, __("Make"));
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,33 @@
|
||||
var globalOnload = frappe.listview_settings['Sales Invoice'].onload;
|
||||
frappe.listview_settings['Sales Invoice'].onload = function (doclist) {
|
||||
|
||||
// Provision in case onload event is added to sales_invoice.js in future
|
||||
if (globalOnload) {
|
||||
globalOnload(doclist);
|
||||
}
|
||||
|
||||
const action = () => {
|
||||
const selected_docs = doclist.get_checked_items();
|
||||
const docnames = doclist.get_checked_items(true);
|
||||
|
||||
for (let doc of selected_docs) {
|
||||
if (doc.docstatus !== 1) {
|
||||
frappe.throw(__("e-Way Bill JSON can only be generated from a submitted document"));
|
||||
}
|
||||
}
|
||||
|
||||
var w = window.open(
|
||||
frappe.urllib.get_full_url(
|
||||
"/api/method/erpnext.regional.india.utils.generate_ewb_json?"
|
||||
+ "dt=" + encodeURIComponent(doclist.doctype)
|
||||
+ "&dn=" + encodeURIComponent(docnames)
|
||||
)
|
||||
);
|
||||
if (!w) {
|
||||
frappe.msgprint(__("Please enable pop-ups")); return;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
doclist.page.add_actions_menu_item(__('Generate e-Way Bill JSON'), action, false);
|
||||
};
|
||||
@@ -18,6 +18,8 @@ from erpnext.accounts.doctype.account.test_account import get_inventory_account,
|
||||
from erpnext.controllers.taxes_and_totals import get_itemised_tax_breakup_data
|
||||
from erpnext.stock.doctype.item.test_item import create_item
|
||||
from six import iteritems
|
||||
from erpnext.regional.india.utils import get_ewb_data
|
||||
|
||||
class TestSalesInvoice(unittest.TestCase):
|
||||
def make(self):
|
||||
w = frappe.copy_doc(test_records[0])
|
||||
@@ -1611,6 +1613,110 @@ class TestSalesInvoice(unittest.TestCase):
|
||||
self.assertEqual(expected_gle[i][2], gle.credit)
|
||||
self.assertEqual(getdate(expected_gle[i][3]), gle.posting_date)
|
||||
|
||||
def test_eway_bill_json(self):
|
||||
if not frappe.db.exists('Address', '_Test Address for Eway bill-Billing'):
|
||||
address = frappe.get_doc({
|
||||
"address_line1": "_Test Address Line 1",
|
||||
"address_title": "_Test Address for Eway bill",
|
||||
"address_type": "Billing",
|
||||
"city": "_Test City",
|
||||
"state": "Test State",
|
||||
"country": "India",
|
||||
"doctype": "Address",
|
||||
"is_primary_address": 1,
|
||||
"phone": "+91 0000000000",
|
||||
"gstin": "27AAECE4835E1ZR",
|
||||
"gst_state": "Maharashtra",
|
||||
"gst_state_number": "27",
|
||||
"pincode": "401108"
|
||||
}).insert()
|
||||
|
||||
address.append("links", {
|
||||
"link_doctype": "Company",
|
||||
"link_name": "_Test Company"
|
||||
})
|
||||
|
||||
address.save()
|
||||
|
||||
if not frappe.db.exists('Address', '_Test Customer-Address for Eway bill-Shipping'):
|
||||
address = frappe.get_doc({
|
||||
"address_line1": "_Test Address Line 1",
|
||||
"address_title": "_Test Customer-Address for Eway bill",
|
||||
"address_type": "Shipping",
|
||||
"city": "_Test City",
|
||||
"state": "Test State",
|
||||
"country": "India",
|
||||
"doctype": "Address",
|
||||
"is_primary_address": 1,
|
||||
"phone": "+91 0000000000",
|
||||
"gst_state": "Maharashtra",
|
||||
"gst_state_number": "27",
|
||||
"pincode": "410038"
|
||||
}).insert()
|
||||
|
||||
address.append("links", {
|
||||
"link_doctype": "Customer",
|
||||
"link_name": "_Test Customer"
|
||||
})
|
||||
|
||||
address.save()
|
||||
|
||||
gst_settings = frappe.get_doc("GST Settings")
|
||||
|
||||
gst_account = frappe.get_all(
|
||||
"GST Account",
|
||||
fields=["cgst_account", "sgst_account", "igst_account"],
|
||||
filters = {"company": "_Test Company"})
|
||||
|
||||
if not gst_account:
|
||||
gst_settings.append("gst_accounts", {
|
||||
"company": "_Test Company",
|
||||
"cgst_account": "CGST - _TC",
|
||||
"sgst_account": "SGST - _TC",
|
||||
"igst_account": "IGST - _TC",
|
||||
})
|
||||
|
||||
gst_settings.save()
|
||||
|
||||
si = create_sales_invoice(do_not_save =1, rate = '60000')
|
||||
|
||||
si.distance = 2000
|
||||
si.company_address = "_Test Address for Eway bill-Billing"
|
||||
si.customer_address = "_Test Customer-Address for Eway bill-Shipping"
|
||||
si.vehicle_no = "KA12KA1234"
|
||||
|
||||
si.append("taxes", {
|
||||
"charge_type": "On Net Total",
|
||||
"account_head": "CGST - _TC",
|
||||
"cost_center": "Main - _TC",
|
||||
"description": "CGST @ 9.0",
|
||||
"rate": 9
|
||||
})
|
||||
|
||||
si.append("taxes", {
|
||||
"charge_type": "On Net Total",
|
||||
"account_head": "SGST - _TC",
|
||||
"cost_center": "Main - _TC",
|
||||
"description": "SGST @ 9.0",
|
||||
"rate": 9
|
||||
})
|
||||
|
||||
si.submit()
|
||||
|
||||
data = get_ewb_data("Sales Invoice", si.name)
|
||||
|
||||
self.assertEqual(data['version'], '1.0.1118')
|
||||
self.assertEqual(data['billLists'][0]['fromGstin'], '27AAECE4835E1ZR')
|
||||
self.assertEqual(data['billLists'][0]['fromTrdName'], '_Test Company')
|
||||
self.assertEqual(data['billLists'][0]['toTrdName'], '_Test Customer')
|
||||
self.assertEqual(data['billLists'][0]['vehicleType'], 'R')
|
||||
self.assertEqual(data['billLists'][0]['totalValue'], 60000)
|
||||
self.assertEqual(data['billLists'][0]['cgstValue'], 5400)
|
||||
self.assertEqual(data['billLists'][0]['sgstValue'], 5400)
|
||||
self.assertEqual(data['billLists'][0]['vehicleNo'], 'KA12KA1234')
|
||||
self.assertEqual(data['billLists'][0]['itemList'][0]['taxableAmount'], 60000)
|
||||
|
||||
|
||||
def create_sales_invoice(**args):
|
||||
si = frappe.new_doc("Sales Invoice")
|
||||
args = frappe._dict(args)
|
||||
|
||||
@@ -191,7 +191,7 @@ erpnext.accounts.bankTransactionUpload = class bankTransactionUpload {
|
||||
frappe.xcall('erpnext.accounts.doctype.bank_transaction.bank_transaction_upload.create_bank_entries',
|
||||
{columns: this.datatable.datamanager.columns, data: this.datatable.datamanager.data, bank_account: me.parent.bank_account}
|
||||
).then((result) => {
|
||||
let result_title = __("{0} bank transaction(s) created", [result])
|
||||
let result_title = result.errors == 0 ? __("{0} bank transaction(s) created", [result.success]) : __("{0} bank transaction(s) created and {1} errors", [result.success, result.errors])
|
||||
let result_msg = `
|
||||
<div class="flex justify-center align-center text-muted" style="height: 50vh; display: flex;">
|
||||
<h5 class="text-muted">${result_title}</h5>
|
||||
@@ -199,7 +199,11 @@ erpnext.accounts.bankTransactionUpload = class bankTransactionUpload {
|
||||
me.parent.page.clear_primary_action();
|
||||
me.parent.$main_section.empty();
|
||||
me.parent.$main_section.append(result_msg);
|
||||
frappe.show_alert({message:__("All bank transactions have been created"), indicator:'green'});
|
||||
if (result.errors == 0) {
|
||||
frappe.show_alert({message:__("All bank transactions have been created"), indicator:'green'});
|
||||
} else {
|
||||
frappe.show_alert({message:__("Please check the error log for details about the import errors"), indicator:'red'});
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -530,11 +534,13 @@ erpnext.accounts.ReconciliationRow = class ReconciliationRow {
|
||||
.then(doc => {
|
||||
let displayed_docs = []
|
||||
if (dt === "Payment Entry") {
|
||||
doc.currency = doc.payment_type == "Receive" ? doc.paid_to_account_currency : doc.paid_from_account_currency;
|
||||
displayed_docs.push(doc);
|
||||
payment.currency = doc.payment_type == "Receive" ? doc.paid_to_account_currency : doc.paid_from_account_currency;
|
||||
payment.doctype = dt
|
||||
displayed_docs.push(payment);
|
||||
} else if (dt === "Journal Entry") {
|
||||
doc.accounts.forEach(payment => {
|
||||
if (payment.account === me.gl_account) {
|
||||
payment.doctype = dt;
|
||||
payment.posting_date = doc.posting_date;
|
||||
payment.party = doc.pay_to_recd_from;
|
||||
payment.reference_no = doc.cheque_no;
|
||||
@@ -548,6 +554,7 @@ erpnext.accounts.ReconciliationRow = class ReconciliationRow {
|
||||
} else if (dt === "Sales Invoice") {
|
||||
doc.payments.forEach(payment => {
|
||||
if (payment.clearance_date === null || payment.clearance_date === "") {
|
||||
payment.doctype = dt;
|
||||
payment.posting_date = doc.posting_date;
|
||||
payment.party = doc.customer;
|
||||
payment.reference_no = doc.remarks;
|
||||
|
||||
@@ -28,7 +28,6 @@ def reconcile(bank_transaction, payment_doctype, payment_name):
|
||||
frappe.throw(_("The selected payment entry should be linked with a creditor bank transaction"))
|
||||
|
||||
add_payment_to_transaction(transaction, payment_entry, gl_entry)
|
||||
clear_payment_entry(transaction, payment_entry, gl_entry)
|
||||
|
||||
return 'reconciled'
|
||||
|
||||
@@ -42,40 +41,6 @@ def add_payment_to_transaction(transaction, payment_entry, gl_entry):
|
||||
})
|
||||
transaction.save()
|
||||
|
||||
def clear_payment_entry(transaction, payment_entry, gl_entry):
|
||||
linked_bank_transactions = frappe.db.sql("""
|
||||
SELECT
|
||||
bt.credit, bt.debit
|
||||
FROM
|
||||
`tabBank Transaction Payments` as btp
|
||||
LEFT JOIN
|
||||
`tabBank Transaction` as bt on btp.parent=bt.name
|
||||
WHERE
|
||||
btp.payment_document = %s
|
||||
AND
|
||||
btp.payment_entry = %s
|
||||
AND
|
||||
bt.docstatus = 1
|
||||
""", (payment_entry.doctype, payment_entry.name), as_dict=True)
|
||||
|
||||
amount_cleared = (flt(linked_bank_transactions[0].credit) - flt(linked_bank_transactions[0].debit))
|
||||
amount_to_be_cleared = (flt(gl_entry.debit) - flt(gl_entry.credit))
|
||||
|
||||
if payment_entry.doctype in ("Payment Entry", "Journal Entry", "Purchase Invoice", "Expense Claim"):
|
||||
clear_simple_entry(amount_cleared, amount_to_be_cleared, payment_entry, transaction)
|
||||
|
||||
elif payment_entry.doctype == "Sales Invoice":
|
||||
clear_sales_invoice(amount_cleared, amount_to_be_cleared, payment_entry, transaction)
|
||||
|
||||
def clear_simple_entry(amount_cleared, amount_to_be_cleared, payment_entry, transaction):
|
||||
if amount_cleared >= amount_to_be_cleared:
|
||||
frappe.db.set_value(payment_entry.doctype, payment_entry.name, "clearance_date", transaction.date)
|
||||
|
||||
def clear_sales_invoice(amount_cleared, amount_to_be_cleared, payment_entry, transaction):
|
||||
if amount_cleared >= amount_to_be_cleared:
|
||||
frappe.db.set_value("Sales Invoice Payment", dict(parenttype=payment_entry.doctype,
|
||||
parent=payment_entry.name), "clearance_date", transaction.date)
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_linked_payments(bank_transaction):
|
||||
transaction = frappe.get_doc("Bank Transaction", bank_transaction)
|
||||
@@ -250,7 +215,7 @@ def get_matching_descriptions_data(company, transaction):
|
||||
if key == "Payment Entry":
|
||||
data.extend(frappe.get_all("Payment Entry", filters=[["name", "in", value]], fields=["'Payment Entry' as doctype", "posting_date", "party", "reference_no", "reference_date", "paid_amount", "paid_to_account_currency as currency"]))
|
||||
if key == "Journal Entry":
|
||||
journal_entries = frappe.get_all("Journal Entry", filters=[["name", "in", value]], fields=["name", "'Journal Entry' as doctype", "posting_date", "paid_to_recd_from as party", "cheque_no as reference_no", "cheque_date as reference_date", "total_credit as paid_amount"])
|
||||
journal_entries = frappe.get_all("Journal Entry", filters=[["name", "in", value]], fields=["name", "'Journal Entry' as doctype", "posting_date", "pay_to_recd_from as party", "cheque_no as reference_no", "cheque_date as reference_date", "total_credit as paid_amount"])
|
||||
for journal_entry in journal_entries:
|
||||
journal_entry_accounts = frappe.get_all("Journal Entry Account", filters={"parenttype": journal_entry["doctype"], "parent": journal_entry["name"]}, fields=["account_currency"])
|
||||
journal_entry["currency"] = journal_entry_accounts[0]["account_currency"] if journal_entry_accounts else company_currency
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// For license information, please see license.txt
|
||||
/* eslint-disable */
|
||||
|
||||
frappe.query_reports["Inactive Items"] = {
|
||||
frappe.query_reports["Inactive Sales Items"] = {
|
||||
"filters": [
|
||||
{
|
||||
fieldname: "item",
|
||||
@@ -1,21 +1,20 @@
|
||||
{
|
||||
"add_total_row": 0,
|
||||
"creation": "2019-04-16 16:05:00.647308",
|
||||
"creation": "2019-05-01 12:59:52.018850",
|
||||
"disable_prepared_report": 0,
|
||||
"disabled": 0,
|
||||
"docstatus": 0,
|
||||
"doctype": "Report",
|
||||
"idx": 0,
|
||||
"is_standard": "Yes",
|
||||
"letter_head": "Test Letter Head 1",
|
||||
"modified": "2019-04-16 16:06:33.630043",
|
||||
"modified": "2019-05-01 13:00:26.545278",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Stock",
|
||||
"name": "Inactive Items",
|
||||
"module": "Accounts",
|
||||
"name": "Inactive Sales Items",
|
||||
"owner": "Administrator",
|
||||
"prepared_report": 0,
|
||||
"ref_doctype": "Sales Invoice",
|
||||
"report_name": "Inactive Items",
|
||||
"report_name": "Inactive Sales Items",
|
||||
"report_type": "Script Report",
|
||||
"roles": [
|
||||
{
|
||||
@@ -80,27 +80,24 @@ def get_data(filters):
|
||||
sales_invoice_data = get_sales_details(filters)
|
||||
|
||||
for item in items:
|
||||
row = {
|
||||
"item_group": item.item_group,
|
||||
"item": item.name,
|
||||
"item_name": item.item_name
|
||||
}
|
||||
|
||||
if sales_invoice_data.get(item.name):
|
||||
item_obj = sales_invoice_data[item.name]
|
||||
if item_obj.days_since_last_order > cint(filters['days']):
|
||||
row = {
|
||||
row.update({
|
||||
"territory": item_obj.territory,
|
||||
"item_group": item_obj.item_group,
|
||||
"item": item_obj.name,
|
||||
"item_name": item_obj.item_name,
|
||||
"customer": item_obj.customer,
|
||||
"last_order_date": item_obj.last_order_date,
|
||||
"qty": item_obj.qty,
|
||||
"days_since_last_order": item_obj.days_since_last_order
|
||||
}
|
||||
data.append(row)
|
||||
else:
|
||||
row = {
|
||||
"item_group": item.item_group,
|
||||
"item": item.name,
|
||||
"item_name": item.item_name
|
||||
}
|
||||
data.append(row)
|
||||
})
|
||||
|
||||
data.append(row)
|
||||
|
||||
return data
|
||||
|
||||
@@ -145,4 +142,3 @@ def get_items(filters):
|
||||
items = frappe.get_all("Item", fields=["name", "item_group", "item_name"], filters=filters_dict, order_by="name")
|
||||
|
||||
return items
|
||||
|
||||
@@ -205,11 +205,14 @@ def get_already_returned_items(doc):
|
||||
|
||||
def make_return_doc(doctype, source_name, target_doc=None):
|
||||
from frappe.model.mapper import get_mapped_doc
|
||||
company = frappe.db.get_value("Delivery Note", source_name, "company")
|
||||
default_warehouse_for_sales_return = frappe.db.get_value("Company", company, "default_warehouse_for_sales_return")
|
||||
def set_missing_values(source, target):
|
||||
doc = frappe.get_doc(target)
|
||||
doc.is_return = 1
|
||||
doc.return_against = source.name
|
||||
doc.ignore_pricing_rule = 1
|
||||
doc.set_warehouse = ""
|
||||
if doctype == "Sales Invoice":
|
||||
doc.is_pos = source.is_pos
|
||||
|
||||
@@ -277,12 +280,16 @@ def make_return_doc(doctype, source_name, target_doc=None):
|
||||
target_doc.so_detail = source_doc.so_detail
|
||||
target_doc.si_detail = source_doc.si_detail
|
||||
target_doc.expense_account = source_doc.expense_account
|
||||
if default_warehouse_for_sales_return:
|
||||
target_doc.warehouse = default_warehouse_for_sales_return
|
||||
elif doctype == "Sales Invoice":
|
||||
target_doc.sales_order = source_doc.sales_order
|
||||
target_doc.delivery_note = source_doc.delivery_note
|
||||
target_doc.so_detail = source_doc.so_detail
|
||||
target_doc.dn_detail = source_doc.dn_detail
|
||||
target_doc.expense_account = source_doc.expense_account
|
||||
if default_warehouse_for_sales_return:
|
||||
target_doc.warehouse = default_warehouse_for_sales_return
|
||||
|
||||
def update_terms(source_doc, target_doc, source_parent):
|
||||
target_doc.payment_amount = -source_doc.payment_amount
|
||||
|
||||
@@ -95,6 +95,10 @@ status_map = {
|
||||
["Ordered", "eval:self.status != 'Stopped' and self.per_ordered == 100 and self.docstatus == 1 and self.material_request_type == 'Purchase'"],
|
||||
["Transferred", "eval:self.status != 'Stopped' and self.per_ordered == 100 and self.docstatus == 1 and self.material_request_type == 'Material Transfer'"],
|
||||
["Issued", "eval:self.status != 'Stopped' and self.per_ordered == 100 and self.docstatus == 1 and self.material_request_type == 'Material Issue'"]
|
||||
],
|
||||
"Bank Transaction": [
|
||||
["Unreconciled", "eval:self.docstatus == 1 and self.unallocated_amount>0"],
|
||||
["Reconciled", "eval:self.docstatus == 1 and self.unallocated_amount<=0"]
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -608,7 +608,7 @@ def get_itemised_tax_breakup_data(doc):
|
||||
|
||||
return itemised_tax, itemised_taxable_amount
|
||||
|
||||
def get_itemised_tax(taxes):
|
||||
def get_itemised_tax(taxes, with_tax_account=False):
|
||||
itemised_tax = {}
|
||||
for tax in taxes:
|
||||
if getattr(tax, "category", None) and tax.category=="Valuation":
|
||||
@@ -633,6 +633,9 @@ def get_itemised_tax(taxes):
|
||||
tax_amount = tax_amount
|
||||
))
|
||||
|
||||
if with_tax_account:
|
||||
itemised_tax[item_code][tax.description].tax_account = tax.account_head
|
||||
|
||||
return itemised_tax
|
||||
|
||||
def get_itemised_taxable_amount(items):
|
||||
|
||||
@@ -4,6 +4,10 @@ from frappe import _
|
||||
def get_data():
|
||||
return {
|
||||
'fieldname': 'lead',
|
||||
'non_standard_fieldnames': {
|
||||
'Quotation': 'party_name',
|
||||
'Opportunity': 'party_name'
|
||||
},
|
||||
'transactions': [
|
||||
{
|
||||
'items': ['Opportunity', 'Quotation']
|
||||
|
||||
@@ -186,7 +186,7 @@ def link_item(item_data,item_status):
|
||||
item.item_name = str(item_data.get("name"))
|
||||
item.item_code = "woocommerce - " + str(item_data.get("product_id"))
|
||||
item.woocommerce_id = str(item_data.get("product_id"))
|
||||
item.item_group = "WooCommerce Products"
|
||||
item.item_group = _("WooCommerce Products")
|
||||
item.stock_uom = woocommerce_settings.uom or _("Nos")
|
||||
item.save()
|
||||
frappe.db.commit()
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
|
||||
from frappe import _
|
||||
from frappe.utils.nestedset import get_root_of
|
||||
from frappe.model.document import Document
|
||||
from six.moves.urllib.parse import urlparse
|
||||
|
||||
@@ -62,10 +62,10 @@ class WoocommerceSettings(Document):
|
||||
custom.read_only = 1
|
||||
custom.save()
|
||||
|
||||
if not frappe.get_value("Item Group",{"name": "WooCommerce Products"}):
|
||||
if not frappe.get_value("Item Group",{"name": _("WooCommerce Products")}):
|
||||
item_group = frappe.new_doc("Item Group")
|
||||
item_group.item_group_name = "WooCommerce Products"
|
||||
item_group.parent_item_group = _("All Item Groups")
|
||||
item_group.item_group_name = _("WooCommerce Products")
|
||||
item_group.parent_item_group = get_root_of("Item Group")
|
||||
item_group.save()
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ class WoocommerceSettings(Document):
|
||||
for name in email_names:
|
||||
frappe.delete_doc("Custom Field",name)
|
||||
|
||||
frappe.delete_doc("Item Group","WooCommerce Products")
|
||||
frappe.delete_doc("Item Group", _("WooCommerce Products"))
|
||||
|
||||
frappe.db.commit()
|
||||
|
||||
|
||||
@@ -256,7 +256,7 @@ scheduler_events = {
|
||||
"daily_long": [
|
||||
"erpnext.manufacturing.doctype.bom_update_tool.bom_update_tool.update_latest_price_in_all_boms"
|
||||
],
|
||||
"monthly": [
|
||||
"monthly_long": [
|
||||
"erpnext.accounts.deferred_revenue.convert_deferred_revenue_to_income",
|
||||
"erpnext.accounts.deferred_revenue.convert_deferred_expense_to_expense",
|
||||
"erpnext.hr.utils.allocate_earned_leaves"
|
||||
|
||||
@@ -78,7 +78,7 @@ class Employee(NestedSet):
|
||||
|
||||
def update_user_permissions(self):
|
||||
if not self.create_user_permission: return
|
||||
if not has_permission('User Permission', ptype='write'): return
|
||||
if not has_permission('User Permission', ptype='write', raise_exception=False): return
|
||||
|
||||
employee_user_permission_exists = frappe.db.exists('User Permission', {
|
||||
'allow': 'Employee',
|
||||
@@ -237,7 +237,7 @@ def validate_employee_role(doc, method):
|
||||
def update_user_permissions(doc, method):
|
||||
# called via User hook
|
||||
if "Employee" in [d.role for d in doc.get("roles")]:
|
||||
if not has_permission('User Permission', ptype='write'): return
|
||||
if not has_permission('User Permission', ptype='write', raise_exception=False): return
|
||||
employee = frappe.get_doc("Employee", {"user_id": doc.name})
|
||||
employee.update_user_permissions()
|
||||
|
||||
|
||||
@@ -177,9 +177,12 @@ def get_benefit_component_amount(employee, start_date, end_date, struct_row, sal
|
||||
|
||||
# Considering there is only one application for a year
|
||||
benefit_application_name = frappe.db.sql("""
|
||||
select name from `tabEmployee Benefit Application`
|
||||
where payroll_period=%(payroll_period)s and employee=%(employee)s
|
||||
and docstatus = 1
|
||||
select name
|
||||
from `tabEmployee Benefit Application`
|
||||
where
|
||||
payroll_period=%(payroll_period)s
|
||||
and employee=%(employee)s
|
||||
and docstatus = 1
|
||||
""", {
|
||||
'employee': employee,
|
||||
'payroll_period': payroll_period
|
||||
@@ -209,7 +212,8 @@ def get_benefit_pro_rata_ratio_amount(sal_struct, component_max):
|
||||
total_pro_rata_max = 0
|
||||
benefit_amount = 0
|
||||
for sal_struct_row in sal_struct.get("earnings"):
|
||||
pay_against_benefit_claim, max_benefit_amount = frappe.db.get_value("Salary Component", sal_struct_row.salary_component, ["pay_against_benefit_claim", "max_benefit_amount"])
|
||||
pay_against_benefit_claim, max_benefit_amount = frappe.db.get_value("Salary Component",
|
||||
sal_struct_row.salary_component, ["pay_against_benefit_claim", "max_benefit_amount"])
|
||||
if sal_struct_row.is_flexible_benefit == 1 and pay_against_benefit_claim != 1:
|
||||
total_pro_rata_max += max_benefit_amount
|
||||
if total_pro_rata_max > 0:
|
||||
|
||||
@@ -1,179 +1,179 @@
|
||||
{
|
||||
"allow_copy": 0,
|
||||
"allow_events_in_timeline": 0,
|
||||
"allow_guest_to_view": 0,
|
||||
"allow_import": 0,
|
||||
"allow_rename": 0,
|
||||
"beta": 0,
|
||||
"creation": "2018-04-13 16:56:23.333041",
|
||||
"custom": 0,
|
||||
"docstatus": 0,
|
||||
"doctype": "DocType",
|
||||
"document_type": "",
|
||||
"editable_grid": 1,
|
||||
"engine": "InnoDB",
|
||||
"allow_copy": 0,
|
||||
"allow_events_in_timeline": 0,
|
||||
"allow_guest_to_view": 0,
|
||||
"allow_import": 0,
|
||||
"allow_rename": 0,
|
||||
"beta": 0,
|
||||
"creation": "2018-04-13 16:56:23.333041",
|
||||
"custom": 0,
|
||||
"docstatus": 0,
|
||||
"doctype": "DocType",
|
||||
"document_type": "",
|
||||
"editable_grid": 1,
|
||||
"engine": "InnoDB",
|
||||
"fields": [
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "exemption_sub_category",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Exemption Sub Category",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Employee Tax Exemption Sub Category",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 1,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "exemption_sub_category",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Exemption Sub Category",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Employee Tax Exemption Sub Category",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 1,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_from": "exemption_sub_category.exemption_category",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "exemption_category",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Exemption Category",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Employee Tax Exemption Category",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 1,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_from": "exemption_sub_category.exemption_category",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "exemption_category",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Exemption Category",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "Employee Tax Exemption Category",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 1,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_from": "exemption_sub_category.max_amount",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "max_amount",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Maximum Exemption Amount",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 1,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_from": "exemption_sub_category.max_amount",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "max_amount",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Maximum Exempted Amount",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 1,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "amount",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Declared Amount",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 1,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "amount",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 1,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Declared Amount",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 1,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
}
|
||||
],
|
||||
"has_web_view": 0,
|
||||
"hide_heading": 0,
|
||||
"hide_toolbar": 0,
|
||||
"idx": 0,
|
||||
"image_view": 0,
|
||||
"in_create": 0,
|
||||
"is_submittable": 0,
|
||||
"issingle": 0,
|
||||
"istable": 1,
|
||||
"max_attachments": 0,
|
||||
"modified": "2019-04-25 15:45:11.279158",
|
||||
"modified_by": "Administrator",
|
||||
"module": "HR",
|
||||
"name": "Employee Tax Exemption Declaration Category",
|
||||
"name_case": "",
|
||||
"owner": "Administrator",
|
||||
"permissions": [],
|
||||
"quick_entry": 1,
|
||||
"read_only": 0,
|
||||
"read_only_onload": 0,
|
||||
"show_name_in_global_search": 0,
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"track_changes": 1,
|
||||
"track_seen": 0,
|
||||
],
|
||||
"has_web_view": 0,
|
||||
"hide_heading": 0,
|
||||
"hide_toolbar": 0,
|
||||
"idx": 0,
|
||||
"image_view": 0,
|
||||
"in_create": 0,
|
||||
"is_submittable": 0,
|
||||
"issingle": 0,
|
||||
"istable": 1,
|
||||
"max_attachments": 0,
|
||||
"modified": "2019-04-26 11:28:14.023086",
|
||||
"modified_by": "Administrator",
|
||||
"module": "HR",
|
||||
"name": "Employee Tax Exemption Declaration Category",
|
||||
"name_case": "",
|
||||
"owner": "Administrator",
|
||||
"permissions": [],
|
||||
"quick_entry": 1,
|
||||
"read_only": 0,
|
||||
"read_only_onload": 0,
|
||||
"show_name_in_global_search": 0,
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"track_changes": 1,
|
||||
"track_seen": 0,
|
||||
"track_views": 0
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"allow_copy": 0,
|
||||
"allow_events_in_timeline": 0,
|
||||
"allow_guest_to_view": 0,
|
||||
"allow_import": 1,
|
||||
"allow_rename": 0,
|
||||
@@ -20,6 +21,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "company",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -53,6 +55,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "column_break_2",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
@@ -84,6 +87,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "start_date",
|
||||
"fieldtype": "Date",
|
||||
"hidden": 0,
|
||||
@@ -116,6 +120,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "end_date",
|
||||
"fieldtype": "Date",
|
||||
"hidden": 0,
|
||||
@@ -148,6 +153,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "section_break_5",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 1,
|
||||
@@ -180,6 +186,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "periods",
|
||||
"fieldtype": "Table",
|
||||
"hidden": 0,
|
||||
@@ -213,6 +220,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "section_break_7",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -245,6 +253,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "taxable_salary_slabs",
|
||||
"fieldtype": "Table",
|
||||
"hidden": 0,
|
||||
@@ -270,6 +279,39 @@
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "standard_tax_exemption_amount",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Standard Tax Exemption Amount",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
}
|
||||
],
|
||||
"has_web_view": 0,
|
||||
@@ -282,7 +324,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2018-05-25 12:29:07.207927",
|
||||
"modified": "2019-04-26 01:45:03.160929",
|
||||
"modified_by": "Administrator",
|
||||
"module": "HR",
|
||||
"name": "Payroll Period",
|
||||
@@ -354,5 +396,6 @@
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"track_changes": 1,
|
||||
"track_seen": 0
|
||||
"track_seen": 0,
|
||||
"track_views": 0
|
||||
}
|
||||
@@ -5,10 +5,8 @@ frappe.ui.form.on('Salary Component', {
|
||||
setup: function(frm) {
|
||||
frm.set_query("default_account", "accounts", function(doc, cdt, cdn) {
|
||||
var d = locals[cdt][cdn];
|
||||
var root_types = ["Expense", "Liability"];
|
||||
return {
|
||||
filters: {
|
||||
"root_type": ["in", root_types],
|
||||
"is_group": 0,
|
||||
"company": d.company
|
||||
}
|
||||
|
||||
@@ -107,8 +107,8 @@ class SalarySlip(TransactionBase):
|
||||
for d in self.get("earnings"):
|
||||
if d.is_flexible_benefit == 1:
|
||||
current_flexi_amount += d.amount
|
||||
last_benefits = get_last_payroll_period_benefits(self.employee, self.start_date, self.end_date,\
|
||||
current_flexi_amount, payroll_period, self._salary_structure_doc)
|
||||
last_benefits = get_last_payroll_period_benefits(self.employee, self.start_date, self.end_date,
|
||||
current_flexi_amount, payroll_period, self._salary_structure_doc)
|
||||
if last_benefits:
|
||||
for last_benefit in last_benefits:
|
||||
last_benefit = frappe._dict(last_benefit)
|
||||
@@ -118,7 +118,7 @@ class SalarySlip(TransactionBase):
|
||||
def add_employee_flexi_benefits(self, struct_row):
|
||||
if frappe.db.get_value("Salary Component", struct_row.salary_component, "pay_against_benefit_claim") != 1:
|
||||
benefit_component_amount = get_benefit_component_amount(self.employee, self.start_date, self.end_date, \
|
||||
struct_row, self._salary_structure_doc, self.total_working_days, self.payroll_frequency)
|
||||
struct_row, self._salary_structure_doc, self.total_working_days, self.payroll_frequency)
|
||||
if benefit_component_amount:
|
||||
self.update_component_row(struct_row, benefit_component_amount, "earnings")
|
||||
else:
|
||||
@@ -418,7 +418,7 @@ class SalarySlip(TransactionBase):
|
||||
|
||||
for d in self.get(component_type):
|
||||
if (self.salary_structure and
|
||||
cint(d.depends_on_payment_days) and
|
||||
cint(d.depends_on_payment_days) and cint(self.total_working_days) and
|
||||
(not
|
||||
self.salary_slip_based_on_timesheet or
|
||||
getdate(self.start_date) < joining_date or
|
||||
@@ -574,8 +574,8 @@ class SalarySlip(TransactionBase):
|
||||
|
||||
def calculate_variable_tax(self, tax_component, payroll_period):
|
||||
annual_taxable_earning, period_factor = 0, 0
|
||||
pro_rata_tax_paid, additional_tax_paid, benefit_tax_paid = 0, 0, 0
|
||||
unclaimed_earning, unclaimed_benefit, additional_income = 0, 0, 0
|
||||
pro_rata_tax_paid, additional_tax_paid, benefit_tax_paid = 0.0, 0.0, 0.0
|
||||
unclaimed_earning, unclaimed_benefit, additional_income = 0.0, 0.0, 0.0
|
||||
|
||||
# get taxable_earning, additional_income in this slip
|
||||
taxable_earning = self.get_taxable_earnings()
|
||||
@@ -590,7 +590,7 @@ class SalarySlip(TransactionBase):
|
||||
unclaimed_earning = self.calculate_unclaimed_taxable_earning(payroll_period, tax_component)
|
||||
earning_in_period = taxable_earning["taxable_earning"] + unclaimed_earning
|
||||
period_factor = self.get_period_factor(payroll_period.start_date, payroll_period.end_date,
|
||||
payroll_period.start_date, self.end_date)
|
||||
payroll_period.start_date, self.end_date)
|
||||
annual_taxable_earning = earning_in_period * period_factor
|
||||
additional_income += self.get_total_additional_income(payroll_period.start_date)
|
||||
else:
|
||||
@@ -604,6 +604,7 @@ class SalarySlip(TransactionBase):
|
||||
{"employee": self.employee, "payroll_period": payroll_period.name, "docstatus": 1},
|
||||
"total_exemption_amount")
|
||||
annual_taxable_earning = annual_earning - exemption_amount
|
||||
|
||||
if self.deduct_tax_for_unclaimed_employee_benefits or self.deduct_tax_for_unsubmitted_tax_exemption_proof:
|
||||
tax_detail = self.get_tax_paid_in_period(payroll_period, tax_component)
|
||||
if tax_detail:
|
||||
@@ -613,11 +614,17 @@ class SalarySlip(TransactionBase):
|
||||
|
||||
# add any additional income in this slip
|
||||
additional_income += taxable_earning["additional_income"]
|
||||
args = {"payroll_period": payroll_period.name, "tax_component": tax_component,
|
||||
"annual_taxable_earning": annual_taxable_earning, "period_factor": period_factor,
|
||||
"unclaimed_benefit": unclaimed_benefit, "additional_income": additional_income,
|
||||
"pro_rata_tax_paid": pro_rata_tax_paid, "benefit_tax_paid": benefit_tax_paid,
|
||||
"additional_tax_paid": additional_tax_paid}
|
||||
args = {
|
||||
"payroll_period": payroll_period.name,
|
||||
"tax_component": tax_component,
|
||||
"period_factor": period_factor,
|
||||
"annual_taxable_earning": annual_taxable_earning,
|
||||
"additional_income": additional_income,
|
||||
"unclaimed_benefit": unclaimed_benefit,
|
||||
"pro_rata_tax_paid": pro_rata_tax_paid,
|
||||
"benefit_tax_paid": benefit_tax_paid,
|
||||
"additional_tax_paid": additional_tax_paid
|
||||
}
|
||||
return self.calculate_tax(args)
|
||||
|
||||
def calculate_unclaimed_taxable_benefit(self, payroll_period):
|
||||
@@ -664,27 +671,49 @@ class SalarySlip(TransactionBase):
|
||||
return total_taxable_earning
|
||||
|
||||
def get_total_additional_income(self, from_date):
|
||||
total_additional_pay = 0
|
||||
sum_additional_earning = frappe.db.sql("""select sum(sd.amount) from `tabSalary Detail` sd join
|
||||
`tabSalary Slip` ss on sd.parent=ss.name where sd.parentfield='earnings'
|
||||
and sd.is_tax_applicable=1 and is_additional_component=1 and is_flexible_benefit=0
|
||||
and ss.docstatus=1 and ss.employee='{0}' and ss.start_date between '{1}' and '{2}'
|
||||
and ss.end_date between '{1}' and '{2}'""".format(self.employee,
|
||||
from_date, self.start_date))
|
||||
if sum_additional_earning and sum_additional_earning[0][0]:
|
||||
total_additional_pay = sum_additional_earning[0][0]
|
||||
return total_additional_pay
|
||||
sum_additional_earning = frappe.db.sql("""
|
||||
select sum(sd.amount)
|
||||
from
|
||||
`tabSalary Detail` sd join `tabSalary Slip` ss on sd.parent=ss.name
|
||||
where
|
||||
sd.parentfield='earnings'
|
||||
and sd.is_tax_applicable=1 and is_additional_component=1
|
||||
and is_flexible_benefit=0 and ss.docstatus=1
|
||||
and ss.employee=%(employee)s
|
||||
and ss.start_date between %(from_date)s and %(to_date)s
|
||||
and ss.end_date between %(from_date)s and %(to_date)s
|
||||
""", {
|
||||
"employee": self.employee,
|
||||
"from_date": from_date,
|
||||
"to_date": self.start_date
|
||||
})
|
||||
return flt(sum_additional_earning[0][0]) if sum_additional_earning else 0
|
||||
|
||||
def get_tax_paid_in_period(self, payroll_period, tax_component, only_total=False):
|
||||
# find total_tax_paid, tax paid for benefit, additional_salary
|
||||
sum_tax_paid = frappe.db.sql("""select sum(sd.amount), sum(tax_on_flexible_benefit),
|
||||
sum(tax_on_additional_salary) from `tabSalary Detail` sd join `tabSalary Slip`
|
||||
ss on sd.parent=ss.name where sd.parentfield='deductions' and sd.salary_component='{3}'
|
||||
and sd.variable_based_on_taxable_salary=1 and ss.docstatus=1 and ss.employee='{0}'
|
||||
and ss.start_date between '{1}' and '{2}' and ss.end_date between '{1}' and
|
||||
'{2}'""".format(self.employee, payroll_period.start_date, self.start_date, tax_component))
|
||||
sum_tax_paid = frappe.db.sql("""
|
||||
select
|
||||
sum(sd.amount), sum(tax_on_flexible_benefit), sum(tax_on_additional_salary)
|
||||
from
|
||||
`tabSalary Detail` sd join `tabSalary Slip` ss on sd.parent=ss.name
|
||||
where
|
||||
sd.parentfield='deductions' and sd.salary_component=%(salary_component)s
|
||||
and sd.variable_based_on_taxable_salary=1
|
||||
and ss.docstatus=1 and ss.employee=%(employee)s
|
||||
and ss.start_date between %(from_date)s and %(to_date)s
|
||||
and ss.end_date between %(from_date)s and %(to_date)s
|
||||
""", {
|
||||
"salary_component": tax_component,
|
||||
"employee": self.employee,
|
||||
"from_date": payroll_period.start_date,
|
||||
"to_date": self.start_date
|
||||
})
|
||||
if sum_tax_paid and sum_tax_paid[0][0]:
|
||||
return {'total_tax_paid': sum_tax_paid[0][0], 'benefit_tax':sum_tax_paid[0][1], 'additional_tax': sum_tax_paid[0][2]}
|
||||
return {
|
||||
'total_tax_paid': sum_tax_paid[0][0],
|
||||
'benefit_tax':sum_tax_paid[0][1],
|
||||
'additional_tax': sum_tax_paid[0][2]
|
||||
}
|
||||
|
||||
def get_taxable_earnings(self, include_flexi=0, only_flexi=0):
|
||||
taxable_earning = 0
|
||||
@@ -695,22 +724,22 @@ class SalarySlip(TransactionBase):
|
||||
additional_income += earning.amount
|
||||
continue
|
||||
if only_flexi:
|
||||
if earning.is_tax_applicable and earning.is_flexible_benefit:
|
||||
if earning.is_flexible_benefit:
|
||||
taxable_earning += earning.amount
|
||||
continue
|
||||
if include_flexi:
|
||||
if earning.is_tax_applicable or (earning.is_tax_applicable and earning.is_flexible_benefit):
|
||||
taxable_earning += earning.amount
|
||||
else:
|
||||
if earning.is_tax_applicable and not earning.is_flexible_benefit:
|
||||
taxable_earning += earning.amount
|
||||
return {"taxable_earning": taxable_earning, "additional_income": additional_income}
|
||||
if include_flexi or not earning.is_flexible_benefit:
|
||||
taxable_earning += earning.amount
|
||||
return {
|
||||
"taxable_earning": taxable_earning,
|
||||
"additional_income": additional_income
|
||||
}
|
||||
|
||||
def calculate_tax(self, args):
|
||||
tax_amount, benefit_tax, additional_tax = 0, 0, 0
|
||||
annual_taxable_earning = args.get("annual_taxable_earning")
|
||||
benefit_to_tax = args.get("unclaimed_benefit")
|
||||
additional_income = args.get("additional_income")
|
||||
|
||||
# Get tax calc by period
|
||||
annual_tax = self.calculate_tax_by_tax_slab(args.get("payroll_period"), annual_taxable_earning)
|
||||
|
||||
@@ -741,8 +770,10 @@ class SalarySlip(TransactionBase):
|
||||
|
||||
def calculate_tax_by_tax_slab(self, payroll_period, annual_taxable_earning):
|
||||
payroll_period_obj = frappe.get_doc("Payroll Period", payroll_period)
|
||||
annual_taxable_earning -= flt(payroll_period_obj.standard_tax_exemption_amount)
|
||||
data = self.get_data_for_eval()
|
||||
data.update({"annual_taxable_earning": annual_taxable_earning})
|
||||
|
||||
taxable_amount = 0
|
||||
for slab in payroll_period_obj.taxable_salary_slabs:
|
||||
if slab.condition and not self.eval_tax_slab_condition(slab.condition, data):
|
||||
|
||||
@@ -159,21 +159,21 @@ class TestSalarySlip(unittest.TestCase):
|
||||
month = "%02d" % getdate(nowdate()).month
|
||||
m = get_month_details(fiscal_year, month)
|
||||
|
||||
for payroll_frequncy in ["Monthly", "Bimonthly", "Fortnightly", "Weekly", "Daily"]:
|
||||
make_employee(payroll_frequncy + "_test_employee@salary.com")
|
||||
ss = make_employee_salary_slip(payroll_frequncy + "_test_employee@salary.com", payroll_frequncy)
|
||||
if payroll_frequncy == "Monthly":
|
||||
for payroll_frequency in ["Monthly", "Bimonthly", "Fortnightly", "Weekly", "Daily"]:
|
||||
make_employee(payroll_frequency + "_test_employee@salary.com")
|
||||
ss = make_employee_salary_slip(payroll_frequency + "_test_employee@salary.com", payroll_frequency)
|
||||
if payroll_frequency == "Monthly":
|
||||
self.assertEqual(ss.end_date, m['month_end_date'])
|
||||
elif payroll_frequncy == "Bimonthly":
|
||||
elif payroll_frequency == "Bimonthly":
|
||||
if getdate(ss.start_date).day <= 15:
|
||||
self.assertEqual(ss.end_date, m['month_mid_end_date'])
|
||||
else:
|
||||
self.assertEqual(ss.end_date, m['month_end_date'])
|
||||
elif payroll_frequncy == "Fortnightly":
|
||||
elif payroll_frequency == "Fortnightly":
|
||||
self.assertEqual(ss.end_date, add_days(nowdate(),13))
|
||||
elif payroll_frequncy == "Weekly":
|
||||
elif payroll_frequency == "Weekly":
|
||||
self.assertEqual(ss.end_date, add_days(nowdate(),6))
|
||||
elif payroll_frequncy == "Daily":
|
||||
elif payroll_frequency == "Daily":
|
||||
self.assertEqual(ss.end_date, nowdate())
|
||||
|
||||
def test_tax_for_payroll_period(self):
|
||||
|
||||
@@ -57,11 +57,12 @@ class SalaryStructure(Document):
|
||||
have_a_flexi = True
|
||||
max_of_component = frappe.db.get_value("Salary Component", earning_component.salary_component, "max_benefit_amount")
|
||||
flexi_amount += max_of_component
|
||||
|
||||
if have_a_flexi and flt(self.max_benefits) == 0:
|
||||
frappe.throw(_("Max benefits should be greater than zero to dispense benefits"))
|
||||
if have_a_flexi and flt(self.max_benefits) > flexi_amount:
|
||||
frappe.throw(_("Total flexible benefit component amount {0} should not be less \
|
||||
than max benefits {1}").format(flexi_amount, self.max_benefits))
|
||||
if have_a_flexi and flexi_amount and flt(self.max_benefits) > flexi_amount:
|
||||
frappe.throw(_("Total flexible benefit component amount {0} should not be less than max benefits {1}")
|
||||
.format(flexi_amount, self.max_benefits))
|
||||
if not have_a_flexi and flt(self.max_benefits) > 0:
|
||||
frappe.throw(_("Salary Structure should have flexible benefit component(s) to dispense benefit amount"))
|
||||
|
||||
|
||||
@@ -5,11 +5,6 @@ frappe.provide("erpnext.bom");
|
||||
|
||||
frappe.ui.form.on("BOM", {
|
||||
setup: function(frm) {
|
||||
frm.add_fetch("item", "description", "description");
|
||||
frm.add_fetch("item", "image", "image");
|
||||
frm.add_fetch("item", "item_name", "item_name");
|
||||
frm.add_fetch("item", "stock_uom", "uom");
|
||||
|
||||
frm.set_query("bom_no", "items", function() {
|
||||
return {
|
||||
filters: {
|
||||
@@ -413,8 +408,4 @@ frappe.ui.form.on("BOM", "with_operations", function(frm) {
|
||||
frm.set_value("operations", []);
|
||||
}
|
||||
toggle_operations(frm);
|
||||
});
|
||||
|
||||
cur_frm.cscript.image = function() {
|
||||
refresh_field("image_view");
|
||||
};
|
||||
});
|
||||
@@ -20,6 +20,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"description": "Item to be manufactured or repacked",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "item",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -55,6 +56,8 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "",
|
||||
"fetch_from": "item.item_name",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "item_name",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
@@ -87,6 +90,43 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_from": "item.image",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "image",
|
||||
"fieldtype": "Attach Image",
|
||||
"hidden": 1,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Image",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "image",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 1,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 1,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_from": "item.stock_uom",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "uom",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -121,6 +161,7 @@
|
||||
"columns": 0,
|
||||
"default": "1",
|
||||
"description": "Quantity of item obtained after manufacturing / repacking from given quantities of raw materials",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "quantity",
|
||||
"fieldtype": "Float",
|
||||
"hidden": 0,
|
||||
@@ -154,6 +195,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "cb0",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
@@ -185,6 +227,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"default": "1",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "is_active",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 0,
|
||||
@@ -219,6 +262,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"default": "1",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "is_default",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 0,
|
||||
@@ -253,6 +297,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"description": "Manage cost of operations",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "with_operations",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 0,
|
||||
@@ -284,6 +329,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "inspection_required",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 0,
|
||||
@@ -316,6 +362,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "allow_alternative_item",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 0,
|
||||
@@ -348,6 +395,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "allow_same_item_multiple_times",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 0,
|
||||
@@ -381,6 +429,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"default": "1",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "set_rate_of_sub_assembly_item_based_on_bom",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 0,
|
||||
@@ -414,6 +463,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "inspection_required",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "quality_inspection_template",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -447,6 +497,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "currency_detail",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -479,6 +530,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "company",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -513,6 +565,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"default": "",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "transfer_material_against",
|
||||
"fieldtype": "Select",
|
||||
"hidden": 0,
|
||||
@@ -546,6 +599,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "conversion_rate",
|
||||
"fieldtype": "Float",
|
||||
"hidden": 0,
|
||||
@@ -578,6 +632,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "column_break_12",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
@@ -609,6 +664,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "currency",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -643,6 +699,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"default": "Valuation Rate",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "rm_cost_as_per",
|
||||
"fieldtype": "Select",
|
||||
"hidden": 0,
|
||||
@@ -676,6 +733,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "eval:doc.rm_cost_as_per===\"Price List\"",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "buying_price_list",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -710,6 +768,7 @@
|
||||
"columns": 0,
|
||||
"depends_on": "",
|
||||
"description": "",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "operations_section",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -742,6 +801,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "routing",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -775,6 +835,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "operations",
|
||||
"fieldtype": "Table",
|
||||
"hidden": 0,
|
||||
@@ -809,6 +870,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "materials_section",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -841,6 +903,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "items",
|
||||
"fieldtype": "Table",
|
||||
"hidden": 0,
|
||||
@@ -875,6 +938,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 1,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "scrap_section",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -907,6 +971,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "scrap_items",
|
||||
"fieldtype": "Table",
|
||||
"hidden": 0,
|
||||
@@ -940,6 +1005,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "costing",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -972,6 +1038,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "operating_cost",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
@@ -1004,6 +1071,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "raw_material_cost",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
@@ -1036,6 +1104,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "scrap_material_cost",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
@@ -1069,6 +1138,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "cb1",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
@@ -1099,6 +1169,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "base_operating_cost",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
@@ -1132,6 +1203,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "base_raw_material_cost",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
@@ -1165,6 +1237,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "base_scrap_material_cost",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
@@ -1198,6 +1271,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "total_cost_of_bom",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -1229,6 +1303,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "total_cost",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
@@ -1261,6 +1336,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "column_break_26",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
@@ -1292,6 +1368,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "base_total_cost",
|
||||
"fieldtype": "Currency",
|
||||
"hidden": 0,
|
||||
@@ -1325,6 +1402,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "more_info_section",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -1356,6 +1434,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "project",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -1390,6 +1469,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "amended_from",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -1422,6 +1502,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "col_break23",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
@@ -1452,6 +1533,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "section_break_25",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -1483,6 +1565,8 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_from": "item.description",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "description",
|
||||
"fieldtype": "Small Text",
|
||||
"hidden": 0,
|
||||
@@ -1514,6 +1598,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "column_break_27",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
@@ -1538,71 +1623,6 @@
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "image",
|
||||
"fieldtype": "Attach",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Image",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
"allow_on_submit": 0,
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fieldname": "image_view",
|
||||
"fieldtype": "Image",
|
||||
"hidden": 0,
|
||||
"ignore_user_permissions": 0,
|
||||
"ignore_xss_filter": 0,
|
||||
"in_filter": 0,
|
||||
"in_global_search": 0,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"label": "Image View",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"options": "image",
|
||||
"permlevel": 0,
|
||||
"precision": "",
|
||||
"print_hide": 0,
|
||||
"print_hide_if_no_value": 0,
|
||||
"read_only": 0,
|
||||
"remember_last_selected_value": 0,
|
||||
"report_hide": 0,
|
||||
"reqd": 0,
|
||||
"search_index": 0,
|
||||
"set_only_once": 0,
|
||||
"translatable": 0,
|
||||
"unique": 0
|
||||
},
|
||||
{
|
||||
"allow_bulk_edit": 0,
|
||||
"allow_in_quick_entry": 0,
|
||||
@@ -1611,6 +1631,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "eval:!doc.__islocal",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "section_break0",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -1642,6 +1663,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "exploded_items",
|
||||
"fieldtype": "Table",
|
||||
"hidden": 0,
|
||||
@@ -1676,6 +1698,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 1,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "website_section",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -1710,6 +1733,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "show_in_website",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 0,
|
||||
@@ -1742,6 +1766,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "route",
|
||||
"fieldtype": "Small Text",
|
||||
"hidden": 0,
|
||||
@@ -1776,6 +1801,7 @@
|
||||
"columns": 0,
|
||||
"depends_on": "show_in_website",
|
||||
"description": "Item Image (if not slideshow)",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "website_image",
|
||||
"fieldtype": "Attach Image",
|
||||
"hidden": 0,
|
||||
@@ -1808,6 +1834,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "thumbnail",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
@@ -1842,6 +1869,7 @@
|
||||
"collapsible_depends_on": "website_items",
|
||||
"columns": 0,
|
||||
"depends_on": "show_in_website",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "sb_web_spec",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -1875,6 +1903,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "show_in_website",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "web_long_description",
|
||||
"fieldtype": "Text Editor",
|
||||
"hidden": 0,
|
||||
@@ -1908,6 +1937,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "show_in_website",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "show_items",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 0,
|
||||
@@ -1941,6 +1971,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "eval:(doc.show_in_website && doc.with_operations)",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "show_operations",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 0,
|
||||
@@ -1972,13 +2003,14 @@
|
||||
"hide_toolbar": 0,
|
||||
"icon": "fa fa-sitemap",
|
||||
"idx": 1,
|
||||
"image_field": "image",
|
||||
"image_view": 0,
|
||||
"in_create": 0,
|
||||
"is_submittable": 1,
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2019-01-30 16:39:34.353721",
|
||||
"modified": "2019-05-01 16:36:05.197126",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Manufacturing",
|
||||
"name": "BOM",
|
||||
@@ -2026,7 +2058,7 @@
|
||||
"quick_entry": 0,
|
||||
"read_only": 0,
|
||||
"read_only_onload": 0,
|
||||
"search_fields": "item",
|
||||
"search_fields": "item, item_name",
|
||||
"show_name_in_global_search": 1,
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -571,7 +571,7 @@ execute:frappe.delete_doc_if_exists("Page", "sales-analytics")
|
||||
execute:frappe.delete_doc_if_exists("Page", "purchase-analytics")
|
||||
execute:frappe.delete_doc_if_exists("Page", "stock-analytics")
|
||||
execute:frappe.delete_doc_if_exists("Page", "production-analytics")
|
||||
erpnext.patches.v11_0.ewaybill_fields_gst_india #2018-11-13 #2019-01-09 #2019-04-01
|
||||
erpnext.patches.v11_0.ewaybill_fields_gst_india #2018-11-13 #2019-01-09 #2019-04-01 #2019-04-26 #2019-05-03
|
||||
erpnext.patches.v11_0.drop_column_max_days_allowed
|
||||
erpnext.patches.v11_0.change_healthcare_desktop_icons
|
||||
erpnext.patches.v10_0.update_user_image_in_employee
|
||||
@@ -595,3 +595,6 @@ erpnext.patches.v11_1.woocommerce_set_creation_user
|
||||
erpnext.patches.v11_1.delete_bom_browser
|
||||
erpnext.patches.v11_1.set_salary_details_submittable
|
||||
erpnext.patches.v11_1.rename_depends_on_lwp
|
||||
erpnext.patches.v11_1.set_missing_title_for_quotation
|
||||
execute:frappe.delete_doc("Report", "Inactive Items")
|
||||
erpnext.patches.v11_1.delete_scheduling_tool
|
||||
9
erpnext/patches/v11_1/delete_scheduling_tool.py
Normal file
9
erpnext/patches/v11_1/delete_scheduling_tool.py
Normal file
@@ -0,0 +1,9 @@
|
||||
# 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
|
||||
|
||||
def execute():
|
||||
if frappe.db.exists("DocType", "Scheduling Tool"):
|
||||
frappe.delete_doc("DocType", "Scheduling Tool", ignore_permissions=True)
|
||||
27
erpnext/patches/v11_1/set_missing_title_for_quotation.py
Normal file
27
erpnext/patches/v11_1/set_missing_title_for_quotation.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import frappe
|
||||
|
||||
def execute():
|
||||
# update customer_name from Customer document if quotation_to is set to Customer
|
||||
frappe.db.sql('''
|
||||
update tabQuotation, tabCustomer
|
||||
set
|
||||
tabQuotation.customer_name = tabCustomer.customer_name,
|
||||
tabQuotation.title = tabCustomer.customer_name
|
||||
where
|
||||
tabQuotation.customer_name is null
|
||||
and tabQuotation.party_name = tabCustomer.name
|
||||
and tabQuotation.quotation_to = 'Customer'
|
||||
''')
|
||||
|
||||
# update customer_name from Lead document if quotation_to is set to Lead
|
||||
|
||||
frappe.db.sql('''
|
||||
update tabQuotation, tabLead
|
||||
set
|
||||
tabQuotation.customer_name = case when ifnull(tabLead.company_name, '') != '' then tabLead.company_name else tabLead.lead_name end,
|
||||
tabQuotation.title = case when ifnull(tabLead.company_name, '') != '' then tabLead.company_name else tabLead.lead_name end
|
||||
where
|
||||
tabQuotation.customer_name is null
|
||||
and tabQuotation.party_name = tabLead.name
|
||||
and tabQuotation.quotation_to = 'Lead'
|
||||
''')
|
||||
@@ -74,7 +74,7 @@ class Project(Document):
|
||||
self.load_tasks()
|
||||
self.validate_dates()
|
||||
self.send_welcome_email()
|
||||
self.update_percent_complete()
|
||||
self.update_percent_complete(from_validate=True)
|
||||
|
||||
def validate_project_name(self):
|
||||
if self.get("__islocal") and frappe.db.exists("Project", self.project_name):
|
||||
@@ -198,7 +198,7 @@ class Project(Document):
|
||||
if self.sales_order:
|
||||
frappe.db.set_value("Sales Order", self.sales_order, "project", self.name)
|
||||
|
||||
def update_percent_complete(self):
|
||||
def update_percent_complete(self, from_validate=False):
|
||||
if not self.tasks: return
|
||||
total = frappe.db.sql("""select count(name) from tabTask where project=%s""", self.name)[0][0]
|
||||
if not total and self.percent_complete:
|
||||
@@ -227,7 +227,9 @@ class Project(Document):
|
||||
self.status = "Completed"
|
||||
elif not self.status == "Cancelled":
|
||||
self.status = "Open"
|
||||
self.db_update()
|
||||
|
||||
if not from_validate:
|
||||
self.db_update()
|
||||
|
||||
def update_costing(self):
|
||||
from_time_sheet = frappe.db.sql("""select
|
||||
@@ -316,7 +318,8 @@ class Project(Document):
|
||||
if not self.get('deleted_task_list'): return
|
||||
|
||||
for d in self.get('deleted_task_list'):
|
||||
frappe.delete_doc("Task", d)
|
||||
# unlink project
|
||||
frappe.db.set_value('Task', d, 'project', '')
|
||||
|
||||
self.deleted_task_list = []
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
"in_filter": 0,
|
||||
"in_global_search": 1,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"in_standard_filter": 1,
|
||||
"label": "Subject",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
@@ -1396,7 +1396,7 @@
|
||||
"istable": 0,
|
||||
"max_attachments": 5,
|
||||
"menu_index": 0,
|
||||
"modified": "2019-04-18 22:33:03.798331",
|
||||
"modified": "2019-04-24 23:10:00.014378",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Projects",
|
||||
"name": "Task",
|
||||
|
||||
@@ -157,6 +157,12 @@ class Task(NestedSet):
|
||||
if check_if_child_exists(self.name):
|
||||
throw(_("Child Task exists for this Task. You can not delete this Task."))
|
||||
|
||||
if self.project:
|
||||
tasks = frappe.get_doc('Project', self.project).tasks
|
||||
for task in tasks:
|
||||
if (task.get('task_id') == self.name):
|
||||
frappe.delete_doc('Project Task', task.name)
|
||||
|
||||
self.update_nsm_model()
|
||||
|
||||
def update_status(self):
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe import _
|
||||
from frappe.utils import time_diff_in_hours
|
||||
from frappe.utils import time_diff_in_hours, flt
|
||||
|
||||
def get_columns():
|
||||
return [
|
||||
@@ -43,7 +43,7 @@ def get_columns():
|
||||
"width": 50
|
||||
},
|
||||
{
|
||||
"label": _("Amount"),
|
||||
"label": _("Billing Amount"),
|
||||
"fieldtype": "Currency",
|
||||
"fieldname": "amount",
|
||||
"width": 100
|
||||
@@ -52,46 +52,53 @@ def get_columns():
|
||||
|
||||
def get_data(filters):
|
||||
data = []
|
||||
record = get_records(filters)
|
||||
if(filters.from_date > filters.to_date):
|
||||
frappe.msgprint(_(" From Date can not be greater than To Date"))
|
||||
return data
|
||||
|
||||
for entries in record:
|
||||
timesheets = get_timesheets(filters)
|
||||
|
||||
filters.from_date = frappe.utils.get_datetime(filters.from_date)
|
||||
filters.to_date = frappe.utils.add_to_date(frappe.utils.get_datetime(filters.to_date), days=1, seconds=-1)
|
||||
|
||||
timesheet_details = get_timesheet_details(filters, timesheets.keys())
|
||||
|
||||
for ts, ts_details in timesheet_details.items():
|
||||
total_hours = 0
|
||||
total_billable_hours = 0
|
||||
total_billing_hours = 0
|
||||
total_amount = 0
|
||||
entries_exists = False
|
||||
timesheet_details = get_timesheet_details(filters, entries.name)
|
||||
|
||||
for activity in timesheet_details:
|
||||
entries_exists = True
|
||||
time_start = activity.from_time
|
||||
time_end = frappe.utils.add_to_date(activity.from_time, hours=activity.hours)
|
||||
from_date = frappe.utils.get_datetime(filters.from_date)
|
||||
to_date = frappe.utils.get_datetime(filters.to_date)
|
||||
for row in ts_details:
|
||||
from_time, to_time = filters.from_date, filters.to_date
|
||||
|
||||
if time_start <= from_date and time_end >= from_date:
|
||||
total_hours, total_billable_hours, total_amount = get_billable_and_total_hours(activity,
|
||||
time_end, from_date, total_hours, total_billable_hours, total_amount)
|
||||
elif time_start <= to_date and time_end >= to_date:
|
||||
total_hours, total_billable_hours, total_amount = get_billable_and_total_hours(activity,
|
||||
to_date, time_start, total_hours, total_billable_hours, total_amount)
|
||||
elif time_start >= from_date and time_end <= to_date:
|
||||
total_hours, total_billable_hours, total_amount = get_billable_and_total_hours(activity,
|
||||
time_end, time_start, total_hours, total_billable_hours, total_amount)
|
||||
if row.to_time < from_time or row.from_time > to_time:
|
||||
continue
|
||||
|
||||
if row.from_time > from_time:
|
||||
from_time = row.from_time
|
||||
|
||||
if row.to_time < to_time:
|
||||
to_time = row.to_time
|
||||
|
||||
activity_duration, billing_duration = get_billable_and_total_duration(row, from_time, to_time)
|
||||
|
||||
total_hours += activity_duration
|
||||
total_billing_hours += billing_duration
|
||||
total_amount += billing_duration * flt(row.billing_rate)
|
||||
|
||||
if total_hours:
|
||||
data.append({
|
||||
"employee": timesheets.get(ts).employee,
|
||||
"employee_name": timesheets.get(ts).employee_name,
|
||||
"timesheet": ts,
|
||||
"total_billable_hours": total_billing_hours,
|
||||
"total_hours": total_hours,
|
||||
"amount": total_amount
|
||||
})
|
||||
|
||||
row = {
|
||||
"employee": entries.employee,
|
||||
"employee_name": entries.employee_name,
|
||||
"timesheet": entries.name,
|
||||
"total_billable_hours": total_billable_hours,
|
||||
"total_hours": total_hours,
|
||||
"amount": total_amount
|
||||
}
|
||||
if entries_exists:
|
||||
data.append(row)
|
||||
entries_exists = False
|
||||
return data
|
||||
|
||||
def get_records(filters):
|
||||
def get_timesheets(filters):
|
||||
record_filters = [
|
||||
["start_date", "<=", filters.to_date],
|
||||
["end_date", ">=", filters.from_date],
|
||||
@@ -101,23 +108,39 @@ def get_records(filters):
|
||||
if "employee" in filters:
|
||||
record_filters.append(["employee", "=", filters.employee])
|
||||
|
||||
return frappe.get_all("Timesheet", filters=record_filters, fields=[" * "] )
|
||||
timesheets = frappe.get_all("Timesheet", filters=record_filters, fields=["employee", "employee_name", "name"])
|
||||
timesheet_map = frappe._dict()
|
||||
for d in timesheets:
|
||||
timesheet_map.setdefault(d.name, d)
|
||||
|
||||
def get_billable_and_total_hours(activity, end, start, total_hours, total_billable_hours, total_amount):
|
||||
total_hours += abs(time_diff_in_hours(end, start))
|
||||
if activity.billable:
|
||||
total_billable_hours += abs(time_diff_in_hours(end, start))
|
||||
total_amount += total_billable_hours * activity.billing_rate
|
||||
return total_hours, total_billable_hours, total_amount
|
||||
return timesheet_map
|
||||
|
||||
def get_timesheet_details(filters, parent):
|
||||
timesheet_details_filter = {"parent": parent}
|
||||
def get_timesheet_details(filters, timesheet_list):
|
||||
timesheet_details_filter = {
|
||||
"parent": ["in", timesheet_list]
|
||||
}
|
||||
|
||||
if "project" in filters:
|
||||
timesheet_details_filter["project"] = filters.project
|
||||
|
||||
return frappe.get_all(
|
||||
timesheet_details = frappe.get_all(
|
||||
"Timesheet Detail",
|
||||
filters = timesheet_details_filter,
|
||||
fields=["*"]
|
||||
)
|
||||
fields=["from_time", "to_time", "hours", "billable", "billing_hours", "billing_rate", "parent"]
|
||||
)
|
||||
|
||||
timesheet_details_map = frappe._dict()
|
||||
for d in timesheet_details:
|
||||
timesheet_details_map.setdefault(d.parent, []).append(d)
|
||||
|
||||
return timesheet_details_map
|
||||
|
||||
def get_billable_and_total_duration(activity, start_time, end_time):
|
||||
activity_duration = time_diff_in_hours(end_time, start_time)
|
||||
billing_duration = 0.0
|
||||
if activity.billable:
|
||||
billing_duration = activity.billing_hours
|
||||
if activity_duration != activity.billing_hours:
|
||||
billing_duration = activity_duration * activity.billing_hours / activity.hours
|
||||
|
||||
return flt(activity_duration, 2), flt(billing_duration, 2)
|
||||
@@ -8,9 +8,10 @@ erpnext.utils.get_party_details = function(frm, method, args, callback) {
|
||||
method = "erpnext.accounts.party.get_party_details";
|
||||
}
|
||||
if(!args) {
|
||||
if(frm.doctype != "Purchase Order" && frm.doc.customer) {
|
||||
if((frm.doctype != "Purchase Order" && frm.doc.customer)
|
||||
|| (frm.doc.party_name && in_list(['Quotation', 'Opportunity'], frm.doc.doctype))) {
|
||||
args = {
|
||||
party: frm.doc.customer,
|
||||
party: frm.doc.customer || frm.doc.party_name,
|
||||
party_type: "Customer",
|
||||
price_list: frm.doc.selling_price_list
|
||||
};
|
||||
@@ -103,7 +104,7 @@ erpnext.utils.get_address_display = function(frm, address_field, display_field,
|
||||
erpnext.utils.set_taxes = function(frm, address_field, display_field, is_your_company_address) {
|
||||
if(frappe.meta.get_docfield(frm.doc.doctype, "taxes") && !is_your_company_address) {
|
||||
if(!erpnext.utils.validate_mandatory(frm, "Lead/Customer/Supplier",
|
||||
frm.doc.customer || frm.doc.supplier || frm.doc.lead, address_field)) {
|
||||
frm.doc.customer || frm.doc.supplier || frm.doc.lead || frm.doc.party_name , address_field)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -125,6 +126,9 @@ erpnext.utils.set_taxes = function(frm, address_field, display_field, is_your_co
|
||||
} else if (frm.doc.supplier) {
|
||||
party_type = 'Supplier';
|
||||
party = frm.doc.supplier;
|
||||
} else if (frm.doc.quotation_to){
|
||||
party_type = frm.doc.quotation_to;
|
||||
party = frm.doc.party_name;
|
||||
}
|
||||
|
||||
frappe.call({
|
||||
|
||||
@@ -189,9 +189,10 @@ def make_custom_fields(update=True):
|
||||
'fieldname': 'gst_transporter_id',
|
||||
'label': 'GST Transporter ID',
|
||||
'fieldtype': 'Data',
|
||||
'insert_after': 'transporter_name',
|
||||
'insert_after': 'transporter',
|
||||
'fetch_from': 'transporter.gst_transporter_id',
|
||||
'print_hide': 1
|
||||
'print_hide': 1,
|
||||
'translatable': 0
|
||||
},
|
||||
{
|
||||
'fieldname': 'mode_of_transport',
|
||||
@@ -199,18 +200,142 @@ def make_custom_fields(update=True):
|
||||
'fieldtype': 'Select',
|
||||
'options': '\nRoad\nAir\nRail\nShip',
|
||||
'default': 'Road',
|
||||
'insert_after': 'transporter_name',
|
||||
'print_hide': 1,
|
||||
'translatable': 0
|
||||
},
|
||||
{
|
||||
'fieldname': 'gst_vehicle_type',
|
||||
'label': 'GST Vehicle Type',
|
||||
'fieldtype': 'Select',
|
||||
'options': 'Regular\nOver Dimensional Cargo (ODC)',
|
||||
'depends_on': 'eval:(doc.mode_of_transport === "Road")',
|
||||
'default': 'Regular',
|
||||
'insert_after': 'lr_date',
|
||||
'print_hide': 1,
|
||||
'translatable': 0
|
||||
}
|
||||
]
|
||||
|
||||
si_ewaybill_fields = [
|
||||
{
|
||||
'fieldname': 'transporter_info',
|
||||
'label': 'Transporter Info',
|
||||
'fieldtype': 'Section Break',
|
||||
'insert_after': 'terms',
|
||||
'collapsible': 1,
|
||||
'collapsible_depends_on': 'transporter',
|
||||
'print_hide': 1
|
||||
},
|
||||
{
|
||||
'fieldname': 'transporter',
|
||||
'label': 'Transporter',
|
||||
'fieldtype': 'Link',
|
||||
'insert_after': 'transporter_info',
|
||||
'options': 'Supplier',
|
||||
'print_hide': 1
|
||||
},
|
||||
{
|
||||
'fieldname': 'gst_transporter_id',
|
||||
'label': 'GST Transporter ID',
|
||||
'fieldtype': 'Data',
|
||||
'insert_after': 'transporter',
|
||||
'fetch_from': 'transporter.gst_transporter_id',
|
||||
'print_hide': 1,
|
||||
'translatable': 0
|
||||
},
|
||||
{
|
||||
'fieldname': 'driver',
|
||||
'label': 'Driver',
|
||||
'fieldtype': 'Link',
|
||||
'insert_after': 'gst_transporter_id',
|
||||
'options': 'Driver',
|
||||
'print_hide': 1
|
||||
},
|
||||
{
|
||||
'fieldname': 'lr_no',
|
||||
'label': 'Transport Receipt No',
|
||||
'fieldtype': 'Data',
|
||||
'insert_after': 'driver',
|
||||
'print_hide': 1,
|
||||
'translatable': 0
|
||||
},
|
||||
{
|
||||
'fieldname': 'vehicle_no',
|
||||
'label': 'Vehicle No',
|
||||
'fieldtype': 'Data',
|
||||
'insert_after': 'lr_no',
|
||||
'print_hide': 1,
|
||||
'translatable': 0
|
||||
},
|
||||
{
|
||||
'fieldname': 'distance',
|
||||
'label': 'Distance (in km)',
|
||||
'fieldtype': 'Float',
|
||||
'insert_after': 'vehicle_no',
|
||||
'print_hide': 1
|
||||
},
|
||||
{
|
||||
'fieldname': 'transporter_col_break',
|
||||
'fieldtype': 'Column Break',
|
||||
'insert_after': 'distance'
|
||||
},
|
||||
{
|
||||
'fieldname': 'transporter_name',
|
||||
'label': 'Transporter Name',
|
||||
'fieldtype': 'Data',
|
||||
'insert_after': 'transporter_col_break',
|
||||
'fetch_from': 'transporter.name',
|
||||
'read_only': 1,
|
||||
'print_hide': 1,
|
||||
'translatable': 0
|
||||
},
|
||||
{
|
||||
'fieldname': 'mode_of_transport',
|
||||
'label': 'Mode of Transport',
|
||||
'fieldtype': 'Select',
|
||||
'options': '\nRoad\nAir\nRail\nShip',
|
||||
'default': 'Road',
|
||||
'insert_after': 'transporter_name',
|
||||
'print_hide': 1,
|
||||
'translatable': 0
|
||||
},
|
||||
{
|
||||
'fieldname': 'driver_name',
|
||||
'label': 'Driver Name',
|
||||
'fieldtype': 'Data',
|
||||
'insert_after': 'mode_of_transport',
|
||||
'fetch_from': 'driver.full_name',
|
||||
'print_hide': 1,
|
||||
'translatable': 0
|
||||
},
|
||||
{
|
||||
'fieldname': 'lr_date',
|
||||
'label': 'Transport Receipt Date',
|
||||
'fieldtype': 'Date',
|
||||
'insert_after': 'driver_name',
|
||||
'default': 'Today',
|
||||
'print_hide': 1
|
||||
},
|
||||
{
|
||||
'fieldname': 'gst_vehicle_type',
|
||||
'label': 'GST Vehicle Type',
|
||||
'fieldtype': 'Select',
|
||||
'options': '\nRegular\nOver Dimensional Cargo (ODC)',
|
||||
'default': 'Regular',
|
||||
'options': 'Regular\nOver Dimensional Cargo (ODC)',
|
||||
'depends_on': 'eval:(doc.mode_of_transport === "Road")',
|
||||
'insert_after': 'mode_of_transport',
|
||||
'print_hide': 1
|
||||
'default': 'Regular',
|
||||
'insert_after': 'lr_date',
|
||||
'print_hide': 1,
|
||||
'translatable': 0
|
||||
},
|
||||
{
|
||||
'fieldname': 'ewaybill',
|
||||
'label': 'e-Way Bill No.',
|
||||
'fieldtype': 'Data',
|
||||
'depends_on': 'eval:(doc.docstatus === 1)',
|
||||
'allow_on_submit': 1,
|
||||
'insert_after': 'project',
|
||||
'translatable': 0
|
||||
}
|
||||
]
|
||||
|
||||
@@ -226,7 +351,8 @@ def make_custom_fields(update=True):
|
||||
'Purchase Invoice': invoice_gst_fields + purchase_invoice_gst_fields + purchase_invoice_itc_fields,
|
||||
'Purchase Order': purchase_invoice_gst_fields,
|
||||
'Purchase Receipt': purchase_invoice_gst_fields,
|
||||
'Sales Invoice': invoice_gst_fields + sales_invoice_gst_fields + sales_invoice_shipping_fields,
|
||||
'Sales Invoice': (invoice_gst_fields + sales_invoice_gst_fields
|
||||
+ sales_invoice_shipping_fields + si_ewaybill_fields),
|
||||
'Delivery Note': sales_invoice_gst_fields + ewaybill_fields + sales_invoice_shipping_fields,
|
||||
'Sales Order': sales_invoice_gst_fields,
|
||||
'Sales Taxes and Charges Template': inter_state_gst_field,
|
||||
@@ -306,7 +432,7 @@ def make_custom_fields(update=True):
|
||||
]
|
||||
}
|
||||
|
||||
create_custom_fields(custom_fields, ignore_validate = frappe.flags.in_patch, update=update)
|
||||
create_custom_fields(custom_fields, update=update)
|
||||
|
||||
def make_fixtures(company=None):
|
||||
docs = []
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe, re
|
||||
import frappe, re, json
|
||||
from frappe import _
|
||||
from frappe.utils import cstr, flt, date_diff, nowdate
|
||||
from erpnext.regional.india import states, state_numbers
|
||||
@@ -14,6 +14,8 @@ def validate_gstin_for_india(doc, method):
|
||||
if not hasattr(doc, 'gstin') or not doc.gstin:
|
||||
return
|
||||
|
||||
set_gst_state_and_state_number(doc)
|
||||
|
||||
doc.gstin = doc.gstin.upper().strip() if doc.gstin else ""
|
||||
if not doc.gstin or doc.gstin == 'NA':
|
||||
return
|
||||
@@ -27,6 +29,11 @@ def validate_gstin_for_india(doc, method):
|
||||
|
||||
validate_gstin_check_digit(doc.gstin)
|
||||
|
||||
if doc.gst_state_number != doc.gstin[:2]:
|
||||
frappe.throw(_("Invalid GSTIN! First 2 digits of GSTIN should match with State number {0}.")
|
||||
.format(doc.gst_state_number))
|
||||
|
||||
def set_gst_state_and_state_number(doc):
|
||||
if not doc.gst_state:
|
||||
if not doc.state:
|
||||
return
|
||||
@@ -38,11 +45,9 @@ def validate_gstin_for_india(doc, method):
|
||||
return
|
||||
|
||||
doc.gst_state_number = state_numbers[doc.gst_state]
|
||||
if doc.gst_state_number != doc.gstin[:2]:
|
||||
frappe.throw(_("Invalid GSTIN! First 2 digits of GSTIN should match with State number {0}.")
|
||||
.format(doc.gst_state_number))
|
||||
|
||||
def validate_gstin_check_digit(gstin):
|
||||
|
||||
def validate_gstin_check_digit(gstin, label='GSTIN'):
|
||||
''' Function to validate the check digit of the GSTIN.'''
|
||||
factor = 1
|
||||
total = 0
|
||||
@@ -55,8 +60,8 @@ def validate_gstin_check_digit(gstin):
|
||||
total += digit
|
||||
factor = 2 if factor == 1 else 1
|
||||
if gstin[-1] != code_point_chars[((mod - (total % mod)) % mod)]:
|
||||
frappe.throw(_("Invalid GSTIN! The check digit validation has failed. " +
|
||||
"Please ensure you've typed the GSTIN correctly."))
|
||||
frappe.throw(_("Invalid {0}! The check digit validation has failed. " +
|
||||
"Please ensure you've typed the {0} correctly.".format(label)))
|
||||
|
||||
def get_itemised_tax_breakup_header(item_doctype, tax_accounts):
|
||||
if frappe.get_meta(item_doctype).has_field('gst_hsn_code'):
|
||||
@@ -64,8 +69,8 @@ def get_itemised_tax_breakup_header(item_doctype, tax_accounts):
|
||||
else:
|
||||
return [_("Item"), _("Taxable Amount")] + tax_accounts
|
||||
|
||||
def get_itemised_tax_breakup_data(doc):
|
||||
itemised_tax = get_itemised_tax(doc.taxes)
|
||||
def get_itemised_tax_breakup_data(doc, account_wise=False):
|
||||
itemised_tax = get_itemised_tax(doc.taxes, with_tax_account=account_wise)
|
||||
|
||||
itemised_taxable_amount = get_itemised_taxable_amount(doc.items)
|
||||
|
||||
@@ -80,14 +85,17 @@ def get_itemised_tax_breakup_data(doc):
|
||||
for item, taxes in itemised_tax.items():
|
||||
hsn_code = item_hsn_map.get(item)
|
||||
hsn_tax.setdefault(hsn_code, frappe._dict())
|
||||
for tax_account, tax_detail in taxes.items():
|
||||
hsn_tax[hsn_code].setdefault(tax_account, {"tax_rate": 0, "tax_amount": 0})
|
||||
hsn_tax[hsn_code][tax_account]["tax_rate"] = tax_detail.get("tax_rate")
|
||||
hsn_tax[hsn_code][tax_account]["tax_amount"] += tax_detail.get("tax_amount")
|
||||
for tax_desc, tax_detail in taxes.items():
|
||||
key = tax_desc
|
||||
if account_wise:
|
||||
key = tax_detail.get('tax_account')
|
||||
hsn_tax[hsn_code].setdefault(key, {"tax_rate": 0, "tax_amount": 0})
|
||||
hsn_tax[hsn_code][key]["tax_rate"] = tax_detail.get("tax_rate")
|
||||
hsn_tax[hsn_code][key]["tax_amount"] += tax_detail.get("tax_amount")
|
||||
|
||||
# set taxable amount
|
||||
hsn_taxable_amount = frappe._dict()
|
||||
for item, taxable_amount in itemised_taxable_amount.items():
|
||||
for item in itemised_taxable_amount:
|
||||
hsn_code = item_hsn_map.get(item)
|
||||
hsn_taxable_amount.setdefault(hsn_code, 0)
|
||||
hsn_taxable_amount[hsn_code] += itemised_taxable_amount.get(item)
|
||||
@@ -262,3 +270,276 @@ def calculate_hra_exemption_for_period(doc):
|
||||
exemptions["monthly_house_rent"] = monthly_rent
|
||||
exemptions["total_eligible_hra_exemption"] = eligible_hra
|
||||
return exemptions
|
||||
|
||||
|
||||
def get_ewb_data(dt, dn):
|
||||
if dt != 'Sales Invoice':
|
||||
frappe.throw(_('e-Way Bill JSON can only be generated from Sales Invoice'))
|
||||
|
||||
dn = dn.split(',')
|
||||
|
||||
ewaybills = []
|
||||
for doc_name in dn:
|
||||
doc = frappe.get_doc(dt, doc_name)
|
||||
|
||||
validate_sales_invoice(doc)
|
||||
|
||||
data = frappe._dict({
|
||||
"transporterId": "",
|
||||
"TotNonAdvolVal": 0,
|
||||
})
|
||||
|
||||
data.userGstin = data.fromGstin = doc.company_gstin
|
||||
data.supplyType = 'O'
|
||||
|
||||
if doc.invoice_type in ['Regular', 'SEZ']:
|
||||
data.subSupplyType = 1
|
||||
elif doc.invoice_type in ['Export', 'Deemed Export']:
|
||||
data.subSupplyType = 3
|
||||
else:
|
||||
frappe.throw(_('Unsupported Invoice Type for e-Way Bill JSON generation'))
|
||||
|
||||
data.docType = 'INV'
|
||||
data.docDate = frappe.utils.formatdate(doc.posting_date, 'dd/mm/yyyy')
|
||||
|
||||
company_address = frappe.get_doc('Address', doc.company_address)
|
||||
billing_address = frappe.get_doc('Address', doc.customer_address)
|
||||
|
||||
shipping_address = frappe.get_doc('Address', doc.shipping_address_name)
|
||||
|
||||
data = get_address_details(data, doc, company_address, billing_address)
|
||||
|
||||
data.itemList = []
|
||||
data.totalValue = doc.total
|
||||
|
||||
data = get_item_list(data, doc)
|
||||
|
||||
disable_rounded = frappe.db.get_single_value('Global Defaults', 'disable_rounded_total')
|
||||
data.totInvValue = doc.grand_total if disable_rounded else doc.rounded_total
|
||||
|
||||
data = get_transport_details(data, doc)
|
||||
|
||||
fields = {
|
||||
"/. -": {
|
||||
'docNo': doc.name,
|
||||
'fromTrdName': doc.company,
|
||||
'toTrdName': doc.customer_name,
|
||||
'transDocNo': doc.lr_no,
|
||||
},
|
||||
"@#/,&. -": {
|
||||
'fromAddr1': company_address.address_line1,
|
||||
'fromAddr2': company_address.address_line2,
|
||||
'fromPlace': company_address.city,
|
||||
'toAddr1': shipping_address.address_line1,
|
||||
'toAddr2': shipping_address.address_line2,
|
||||
'toPlace': shipping_address.city,
|
||||
'transporterName': doc.transporter_name
|
||||
}
|
||||
}
|
||||
|
||||
for allowed_chars, field_map in fields.items():
|
||||
for key, value in field_map.items():
|
||||
if not value:
|
||||
data[key] = ''
|
||||
else:
|
||||
data[key] = re.sub(r'[^\w' + allowed_chars + ']', '', value)
|
||||
|
||||
ewaybills.append(data)
|
||||
|
||||
data = {
|
||||
'version': '1.0.1118',
|
||||
'billLists': ewaybills
|
||||
}
|
||||
|
||||
return data
|
||||
|
||||
@frappe.whitelist()
|
||||
def generate_ewb_json(dt, dn):
|
||||
|
||||
data = get_ewb_data(dt, dn)
|
||||
|
||||
frappe.local.response.filecontent = json.dumps(data, indent=4, sort_keys=True)
|
||||
frappe.local.response.type = 'download'
|
||||
|
||||
if len(data['billLists']) > 1:
|
||||
doc_name = 'Bulk'
|
||||
else:
|
||||
doc_name = dn
|
||||
|
||||
frappe.local.response.filename = '{0}_e-WayBill_Data_{1}.json'.format(doc_name, frappe.utils.random_string(5))
|
||||
|
||||
|
||||
def get_address_details(data, doc, company_address, billing_address):
|
||||
data.fromPincode = validate_pincode(company_address.pincode, 'Company Address')
|
||||
data.fromStateCode = data.actualFromStateCode = validate_state_code(
|
||||
company_address.gst_state_number, 'Company Address')
|
||||
|
||||
if not doc.billing_address_gstin or len(doc.billing_address_gstin) < 15:
|
||||
data.toGstin = 'URP'
|
||||
set_gst_state_and_state_number(billing_address)
|
||||
else:
|
||||
data.toGstin = doc.billing_address_gstin
|
||||
|
||||
data.toPincode = validate_pincode(billing_address.pincode, 'Customer Address')
|
||||
data.toStateCode = validate_state_code(billing_address.gst_state_number, 'Customer Address')
|
||||
|
||||
if doc.customer_address != doc.shipping_address_name:
|
||||
data.transType = 2
|
||||
shipping_address = frappe.get_doc('Address', doc.shipping_address_name)
|
||||
set_gst_state_and_state_number(shipping_address)
|
||||
data.toPincode = validate_pincode(shipping_address.pincode, 'Shipping Address')
|
||||
data.actualToStateCode = validate_state_code(shipping_address.gst_state_number, 'Shipping Address')
|
||||
else:
|
||||
data.transType = 1
|
||||
data.actualToStateCode = data.toStateCode
|
||||
shipping_address = billing_address
|
||||
|
||||
return data
|
||||
|
||||
def get_item_list(data, doc):
|
||||
for attr in ['cgstValue', 'sgstValue', 'igstValue', 'cessValue', 'OthValue']:
|
||||
data[attr] = 0
|
||||
|
||||
gst_accounts = get_gst_accounts(doc.company, account_wise=True)
|
||||
tax_map = {
|
||||
'sgst_account': ['sgstRate', 'sgstValue'],
|
||||
'cgst_account': ['cgstRate', 'cgstValue'],
|
||||
'igst_account': ['igstRate', 'igstValue'],
|
||||
'cess_account': ['cessRate', 'cessValue']
|
||||
}
|
||||
item_data_attrs = ['sgstRate', 'cgstRate', 'igstRate', 'cessRate', 'cessNonAdvol']
|
||||
hsn_wise_charges, hsn_taxable_amount = get_itemised_tax_breakup_data(doc, account_wise=True)
|
||||
for hsn_code, taxable_amount in hsn_taxable_amount.items():
|
||||
item_data = frappe._dict()
|
||||
if not hsn_code:
|
||||
frappe.throw(_('GST HSN Code does not exist for one or more items'))
|
||||
item_data.hsnCode = int(hsn_code)
|
||||
item_data.taxableAmount = taxable_amount
|
||||
item_data.qtyUnit = ""
|
||||
for attr in item_data_attrs:
|
||||
item_data[attr] = 0
|
||||
|
||||
for account, tax_detail in hsn_wise_charges.get(hsn_code, {}).items():
|
||||
account_type = gst_accounts.get(account, '')
|
||||
for tax_acc, attrs in tax_map.items():
|
||||
if account_type == tax_acc:
|
||||
item_data[attrs[0]] = tax_detail.get('tax_rate')
|
||||
data[attrs[1]] += tax_detail.get('tax_amount')
|
||||
break
|
||||
else:
|
||||
data.OthValue += tax_detail.get('tax_amount')
|
||||
|
||||
data.itemList.append(item_data)
|
||||
|
||||
# Tax amounts rounded to 2 decimals to avoid exceeding max character limit
|
||||
for attr in ['sgstValue', 'cgstValue', 'igstValue', 'cessValue']:
|
||||
data[attr] = flt(data[attr], 2)
|
||||
|
||||
return data
|
||||
|
||||
def validate_sales_invoice(doc):
|
||||
if doc.docstatus != 1:
|
||||
frappe.throw(_('e-Way Bill JSON can only be generated from submitted document'))
|
||||
|
||||
if doc.is_return:
|
||||
frappe.throw(_('e-Way Bill JSON cannot be generated for Sales Return as of now'))
|
||||
|
||||
if doc.ewaybill:
|
||||
frappe.throw(_('e-Way Bill already exists for this document'))
|
||||
|
||||
reqd_fields = ['company_gstin', 'company_address', 'customer_address',
|
||||
'shipping_address_name', 'mode_of_transport', 'distance']
|
||||
|
||||
for fieldname in reqd_fields:
|
||||
if not doc.get(fieldname):
|
||||
frappe.throw(_('{} is required to generate e-Way Bill JSON'.format(
|
||||
doc.meta.get_label(fieldname)
|
||||
)))
|
||||
|
||||
if len(doc.company_gstin) < 15:
|
||||
frappe.throw(_('You must be a registered supplier to generate e-Way Bill'))
|
||||
|
||||
def get_transport_details(data, doc):
|
||||
if doc.distance > 4000:
|
||||
frappe.throw(_('Distance cannot be greater than 4000 kms'))
|
||||
|
||||
data.transDistance = int(round(doc.distance))
|
||||
|
||||
transport_modes = {
|
||||
'Road': 1,
|
||||
'Rail': 2,
|
||||
'Air': 3,
|
||||
'Ship': 4
|
||||
}
|
||||
|
||||
vehicle_types = {
|
||||
'Regular': 'R',
|
||||
'Over Dimensional Cargo (ODC)': 'O'
|
||||
}
|
||||
|
||||
data.transMode = transport_modes.get(doc.mode_of_transport)
|
||||
|
||||
if doc.mode_of_transport == 'Road':
|
||||
if not doc.gst_transporter_id and not doc.vehicle_no:
|
||||
frappe.throw(_('Either GST Transporter ID or Vehicle No is required if Mode of Transport is Road'))
|
||||
if doc.vehicle_no:
|
||||
data.vehicleNo = doc.vehicle_no.replace(' ', '')
|
||||
if not doc.gst_vehicle_type:
|
||||
frappe.throw(_('Vehicle Type is required if Mode of Transport is Road'))
|
||||
else:
|
||||
data.vehicleType = vehicle_types.get(doc.gst_vehicle_type)
|
||||
else:
|
||||
if not doc.lr_no or not doc.lr_date:
|
||||
frappe.throw(_('Transport Receipt No and Date are mandatory for your chosen Mode of Transport'))
|
||||
|
||||
if doc.lr_no:
|
||||
data.transDocNo = doc.lr_no
|
||||
|
||||
if doc.lr_date:
|
||||
data.transDocDate = frappe.utils.formatdate(doc.lr_date, 'dd/mm/yyyy')
|
||||
|
||||
if doc.gst_transporter_id:
|
||||
validate_gstin_check_digit(doc.gst_transporter_id, label='GST Transporter ID')
|
||||
data.transporterId = doc.gst_transporter_id
|
||||
|
||||
return data
|
||||
|
||||
|
||||
def validate_pincode(pincode, address):
|
||||
pin_not_found = "Pin Code doesn't exist for {}"
|
||||
incorrect_pin = "Pin Code for {} is incorrecty formatted. It must be 6 digits (without spaces)"
|
||||
|
||||
if not pincode:
|
||||
frappe.throw(_(pin_not_found.format(address)))
|
||||
|
||||
pincode = pincode.replace(' ', '')
|
||||
if not pincode.isdigit() or len(pincode) != 6:
|
||||
frappe.throw(_(incorrect_pin.format(address)))
|
||||
else:
|
||||
return int(pincode)
|
||||
|
||||
def validate_state_code(state_code, address):
|
||||
no_state_code = "GST State Code not found for {0}. Please set GST State in {0}"
|
||||
if not state_code:
|
||||
frappe.throw(_(no_state_code.format(address)))
|
||||
else:
|
||||
return int(state_code)
|
||||
|
||||
def get_gst_accounts(company, account_wise=False):
|
||||
gst_accounts = frappe._dict()
|
||||
gst_settings_accounts = frappe.get_all("GST Account",
|
||||
filters={"parent": "GST Settings", "company": company},
|
||||
fields=["cgst_account", "sgst_account", "igst_account", "cess_account"])
|
||||
|
||||
if not gst_settings_accounts:
|
||||
frappe.throw(_("Please set GST Accounts in GST Settings"))
|
||||
|
||||
for d in gst_settings_accounts:
|
||||
for acc, val in d.items():
|
||||
if not account_wise:
|
||||
gst_accounts.setdefault(acc, []).append(val)
|
||||
elif val:
|
||||
gst_accounts[val] = acc
|
||||
|
||||
|
||||
return gst_accounts
|
||||
@@ -7,6 +7,7 @@ from frappe import _
|
||||
from frappe.utils import flt, formatdate
|
||||
from datetime import date
|
||||
from six import iteritems
|
||||
from erpnext.regional.india.utils import get_gst_accounts
|
||||
|
||||
def execute(filters=None):
|
||||
return Gstr1Report(filters).run()
|
||||
@@ -41,7 +42,7 @@ class Gstr1Report(object):
|
||||
|
||||
def run(self):
|
||||
self.get_columns()
|
||||
self.get_gst_accounts()
|
||||
self.gst_accounts = get_gst_accounts(self.filters.company)
|
||||
self.get_invoice_data()
|
||||
|
||||
if self.invoices:
|
||||
@@ -60,7 +61,7 @@ class Gstr1Report(object):
|
||||
for inv, items_based_on_rate in self.items_based_on_tax_rate.items():
|
||||
invoice_details = self.invoices.get(inv)
|
||||
for rate, items in items_based_on_rate.items():
|
||||
row, taxable_value = self.get_row_data_for_invoice(inv, invoice_details, rate, items)
|
||||
row = self.get_row_data_for_invoice(inv, invoice_details, rate, items)
|
||||
|
||||
if self.filters.get("type_of_business") == "CDNR":
|
||||
row.append("Y" if invoice_details.posting_date <= date(2017, 7, 1) else "N")
|
||||
@@ -117,7 +118,7 @@ class Gstr1Report(object):
|
||||
for item_code, net_amount in self.invoice_items.get(invoice).items() if item_code in items])
|
||||
row += [tax_rate or 0, taxable_value]
|
||||
|
||||
return row, taxable_value
|
||||
return row
|
||||
|
||||
def get_invoice_data(self):
|
||||
self.invoices = frappe._dict()
|
||||
@@ -239,19 +240,6 @@ class Gstr1Report(object):
|
||||
and frappe.db.get_value(self.doctype, invoice, "export_type") == "Without Payment of Tax":
|
||||
self.items_based_on_tax_rate.setdefault(invoice, {}).setdefault(0, items.keys())
|
||||
|
||||
def get_gst_accounts(self):
|
||||
self.gst_accounts = frappe._dict()
|
||||
gst_settings_accounts = frappe.get_all("GST Account",
|
||||
filters={"parent": "GST Settings", "company": self.filters.company},
|
||||
fields=["cgst_account", "sgst_account", "igst_account", "cess_account"])
|
||||
|
||||
if not gst_settings_accounts:
|
||||
frappe.throw(_("Please set GST Accounts in GST Settings"))
|
||||
|
||||
for d in gst_settings_accounts:
|
||||
for acc, val in d.items():
|
||||
self.gst_accounts.setdefault(acc, []).append(val)
|
||||
|
||||
def get_columns(self):
|
||||
self.tax_columns = [
|
||||
{
|
||||
|
||||
@@ -124,10 +124,5 @@ frappe.ui.form.on("Customer", {
|
||||
validate: function(frm) {
|
||||
if(frm.doc.lead_name) frappe.model.clear_doc("Lead", frm.doc.lead_name);
|
||||
|
||||
var total = 0;
|
||||
for (var idx in frm.doc.sales_team) {
|
||||
total += frm.doc.sales_team[idx].allocated_percentage;
|
||||
if (total > 100) frappe.throw(__("Total contribution percentage can't exceed 100"));
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -60,6 +60,10 @@ class Customer(TransactionBase):
|
||||
if self.loyalty_program == customer.loyalty_program and not self.loyalty_program_tier:
|
||||
self.loyalty_program_tier = customer.loyalty_program_tier
|
||||
|
||||
if self.sales_team:
|
||||
if sum([member.allocated_percentage for member in self.sales_team]) != 100:
|
||||
frappe.throw(_("Total contribution percentage should be equal to 100"))
|
||||
|
||||
def check_customer_group_change(self):
|
||||
frappe.flags.customer_group_changed = False
|
||||
|
||||
|
||||
@@ -42,10 +42,16 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
|
||||
this._super(doc, dt, dn);
|
||||
|
||||
},
|
||||
party_name: function() {
|
||||
var me = this;
|
||||
erpnext.utils.get_party_details(this.frm, null, null, function() {
|
||||
me.apply_price_list();
|
||||
});
|
||||
},
|
||||
refresh: function(doc, dt, dn) {
|
||||
this._super(doc, dt, dn);
|
||||
doctype = doc.quotation_to == 'Customer' ? 'Customer':'Lead';
|
||||
frappe.dynamic_link = {doc: this.frm.doc, fieldname: doctype.toLowerCase(), doctype: doctype}
|
||||
frappe.dynamic_link = {doc: this.frm.doc, fieldname: 'party_name', doctype: doctype}
|
||||
|
||||
var me = this;
|
||||
|
||||
@@ -127,14 +133,24 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
|
||||
|
||||
// to overwrite the customer_filter trigger from queries.js
|
||||
this.frm.toggle_reqd("party_name", this.frm.doc.quotation_to);
|
||||
this.frm.set_query('customer_address', erpnext.queries.address_query);
|
||||
this.frm.set_query('shipping_address_name', erpnext.queries.address_query);
|
||||
this.frm.set_query('customer_address', this.address_query);
|
||||
this.frm.set_query('shipping_address_name', this.address_query);
|
||||
},
|
||||
|
||||
tc_name: function() {
|
||||
this.get_terms();
|
||||
},
|
||||
|
||||
address_query: function(doc) {
|
||||
return {
|
||||
query: 'frappe.contacts.doctype.address.address.address_query',
|
||||
filters: {
|
||||
link_doctype: frappe.dynamic_link.doctype,
|
||||
link_name: doc.party_name
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
validate_company_and_party: function(party_field) {
|
||||
if(!this.frm.doc.quotation_to) {
|
||||
frappe.msgprint(__("Please select a value for {0} quotation_to {1}", [this.frm.doc.doctype, this.frm.doc.name]));
|
||||
|
||||
@@ -169,8 +169,8 @@
|
||||
"in_filter": 0,
|
||||
"in_global_search": 1,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 1,
|
||||
"label": "Customer/Lead",
|
||||
"in_standard_filter": 0,
|
||||
"label": "Party",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
"oldfieldname": "customer",
|
||||
@@ -195,7 +195,7 @@
|
||||
"bold": 1,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_from": "customer.customer_name",
|
||||
"fetch_from": "",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "customer_name",
|
||||
"fieldtype": "Data",
|
||||
@@ -441,7 +441,7 @@
|
||||
"collapsible": 1,
|
||||
"collapsible_depends_on": "",
|
||||
"columns": 0,
|
||||
"depends_on": "eval:(doc.customer || doc.lead)",
|
||||
"depends_on": "eval:doc.party_name",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "contact_section",
|
||||
"fieldtype": "Section Break",
|
||||
@@ -542,7 +542,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "eval:doc.customer",
|
||||
"depends_on": "",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "contact_person",
|
||||
"fieldtype": "Link",
|
||||
@@ -3224,7 +3224,7 @@
|
||||
"istable": 0,
|
||||
"max_attachments": 1,
|
||||
"menu_index": 0,
|
||||
"modified": "2019-04-25 15:26:21.983298",
|
||||
"modified": "2019-05-07 14:29:22.565474",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Selling",
|
||||
"name": "Quotation",
|
||||
|
||||
@@ -29,6 +29,7 @@ class Quotation(SellingController):
|
||||
self.validate_order_type()
|
||||
self.validate_uom_is_integer("stock_uom", "qty")
|
||||
self.validate_valid_till()
|
||||
self.set_customer_name()
|
||||
if self.items:
|
||||
self.with_items = 1
|
||||
|
||||
@@ -46,6 +47,13 @@ class Quotation(SellingController):
|
||||
if self.quotation_to == "Lead" and self.party_name:
|
||||
frappe.get_doc("Lead", self.party_name).set_status(update=True)
|
||||
|
||||
def set_customer_name(self):
|
||||
if self.party_name and self.quotation_to == 'Customer':
|
||||
self.customer_name = frappe.db.get_value("Customer", self.party_name, "customer_name")
|
||||
elif self.party_name and self.quotation_to == 'Lead':
|
||||
lead_name, company_name = frappe.db.get_value("Lead", self.party_name, ["lead_name", "company_name"])
|
||||
self.customer_name = company_name or lead_name
|
||||
|
||||
def update_opportunity(self):
|
||||
for opportunity in list(set([d.prevdoc_docname for d in self.get("items")])):
|
||||
if opportunity:
|
||||
@@ -204,35 +212,38 @@ def _make_sales_invoice(source_name, target_doc=None, ignore_permissions=False):
|
||||
return doclist
|
||||
|
||||
def _make_customer(source_name, ignore_permissions=False):
|
||||
quotation = frappe.db.get_value("Quotation", source_name, ["order_type", "party_name", "customer_name"])
|
||||
if quotation and quotation[1] and not quotation[2]:
|
||||
lead_name = quotation[1]
|
||||
customer_name = frappe.db.get_value("Customer", {"lead_name": lead_name},
|
||||
["name", "customer_name"], as_dict=True)
|
||||
if not customer_name:
|
||||
from erpnext.crm.doctype.lead.lead import _make_customer
|
||||
customer_doclist = _make_customer(lead_name, ignore_permissions=ignore_permissions)
|
||||
customer = frappe.get_doc(customer_doclist)
|
||||
customer.flags.ignore_permissions = ignore_permissions
|
||||
if quotation[1] == "Shopping Cart":
|
||||
customer.customer_group = frappe.db.get_value("Shopping Cart Settings", None,
|
||||
"default_customer_group")
|
||||
quotation = frappe.db.get_value("Quotation",
|
||||
source_name, ["order_type", "party_name", "customer_name"], as_dict=1)
|
||||
|
||||
try:
|
||||
customer.insert()
|
||||
return customer
|
||||
except frappe.NameError:
|
||||
if frappe.defaults.get_global_default('cust_master_name') == "Customer Name":
|
||||
customer.run_method("autoname")
|
||||
customer.name += "-" + lead_name
|
||||
if quotation and quotation.get('party_name'):
|
||||
if not frappe.db.exists("Customer", quotation.get("party_name")):
|
||||
lead_name = quotation.get("party_name")
|
||||
customer_name = frappe.db.get_value("Customer", {"lead_name": lead_name},
|
||||
["name", "customer_name"], as_dict=True)
|
||||
if not customer_name:
|
||||
from erpnext.crm.doctype.lead.lead import _make_customer
|
||||
customer_doclist = _make_customer(lead_name, ignore_permissions=ignore_permissions)
|
||||
customer = frappe.get_doc(customer_doclist)
|
||||
customer.flags.ignore_permissions = ignore_permissions
|
||||
if quotation.get("party_name") == "Shopping Cart":
|
||||
customer.customer_group = frappe.db.get_value("Shopping Cart Settings", None,
|
||||
"default_customer_group")
|
||||
|
||||
try:
|
||||
customer.insert()
|
||||
return customer
|
||||
else:
|
||||
raise
|
||||
except frappe.MandatoryError:
|
||||
frappe.local.message_log = []
|
||||
frappe.throw(_("Please create Customer from Lead {0}").format(lead_name))
|
||||
except frappe.NameError:
|
||||
if frappe.defaults.get_global_default('cust_master_name') == "Customer Name":
|
||||
customer.run_method("autoname")
|
||||
customer.name += "-" + lead_name
|
||||
customer.insert()
|
||||
return customer
|
||||
else:
|
||||
raise
|
||||
except frappe.MandatoryError:
|
||||
frappe.local.message_log = []
|
||||
frappe.throw(_("Please create Customer from Lead {0}").format(lead_name))
|
||||
else:
|
||||
return customer_name
|
||||
else:
|
||||
return customer_name
|
||||
else:
|
||||
return frappe.get_doc("Customer",quotation[2])
|
||||
return frappe.get_doc("Customer", quotation.get("party_name"))
|
||||
|
||||
@@ -544,7 +544,7 @@ def make_project(source_name, target_doc=None):
|
||||
"Sales Order Item": {
|
||||
"doctype": "Project Task",
|
||||
"field_map": {
|
||||
"description": "title",
|
||||
"item_code": "title",
|
||||
},
|
||||
}
|
||||
}, target_doc, postprocess)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -9,6 +9,7 @@ from frappe.model.naming import make_autoname, revert_series_if_last
|
||||
from frappe.utils import flt, cint
|
||||
from frappe.utils.jinja import render_template
|
||||
from frappe.utils.data import add_days
|
||||
from six import string_types
|
||||
|
||||
class UnableToSelectBatchError(frappe.ValidationError):
|
||||
pass
|
||||
@@ -60,7 +61,7 @@ def _make_naming_series_key(prefix):
|
||||
:param prefix: Naming series prefix gotten from Stock Settings
|
||||
:return: The derived key. If no prefix is given, an empty string is returned
|
||||
"""
|
||||
if not unicode(prefix):
|
||||
if not isinstance(prefix, string_types):
|
||||
return ''
|
||||
else:
|
||||
return prefix.upper() + '.#####'
|
||||
@@ -86,7 +87,7 @@ class Batch(Document):
|
||||
def autoname(self):
|
||||
"""Generate random ID for batch if not specified"""
|
||||
if not self.batch_id:
|
||||
create_new_batch, batch_number_series = frappe.db.get_value('Item', self.item,
|
||||
create_new_batch, batch_number_series = frappe.db.get_value('Item', self.item,
|
||||
['create_new_batch', 'batch_number_series'])
|
||||
|
||||
if create_new_batch:
|
||||
|
||||
@@ -1068,7 +1068,7 @@ class StockEntry(StockController):
|
||||
frappe.MappingMismatchError)
|
||||
|
||||
def validate_batch(self):
|
||||
if self.purpose in ["Material Transfer for Manufacture", "Manufacture", "Repack", "Subcontract", "Material Issue"]:
|
||||
if self.purpose in ["Material Transfer for Manufacture", "Manufacture", "Repack", "Subcontract"]:
|
||||
for item in self.get("items"):
|
||||
if item.batch_no:
|
||||
disabled = frappe.db.get_value("Batch", item.batch_no, "disabled")
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"allow_copy": 0,
|
||||
"allow_events_in_timeline": 0,
|
||||
"allow_guest_to_view": 0,
|
||||
"allow_import": 1,
|
||||
"allow_rename": 1,
|
||||
@@ -20,6 +21,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "subject_section",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -53,6 +55,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"default": "",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "naming_series",
|
||||
"fieldtype": "Select",
|
||||
"hidden": 0,
|
||||
@@ -85,6 +88,7 @@
|
||||
"bold": 1,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "subject",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
@@ -93,7 +97,7 @@
|
||||
"in_filter": 0,
|
||||
"in_global_search": 1,
|
||||
"in_list_view": 0,
|
||||
"in_standard_filter": 0,
|
||||
"in_standard_filter": 1,
|
||||
"label": "Subject",
|
||||
"length": 0,
|
||||
"no_copy": 0,
|
||||
@@ -116,6 +120,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "issue_type",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -149,6 +154,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "cb00",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
@@ -180,6 +186,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"default": "Open",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "status",
|
||||
"fieldtype": "Select",
|
||||
"hidden": 0,
|
||||
@@ -215,6 +222,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"default": "Medium",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "priority",
|
||||
"fieldtype": "Select",
|
||||
"hidden": 0,
|
||||
@@ -249,6 +257,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "eval:doc.__islocal",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "raised_by",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
@@ -283,6 +292,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "email_account",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -316,6 +326,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "customer",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -350,6 +361,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 1,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "section_break_7",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -383,6 +395,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "description",
|
||||
"fieldtype": "Text Editor",
|
||||
"hidden": 0,
|
||||
@@ -416,6 +429,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 1,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "response",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -448,6 +462,7 @@
|
||||
"bold": 1,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "mins_to_first_response",
|
||||
"fieldtype": "Float",
|
||||
"hidden": 0,
|
||||
@@ -480,6 +495,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "first_responded_on",
|
||||
"fieldtype": "Datetime",
|
||||
"hidden": 0,
|
||||
@@ -511,6 +527,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 1,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "additional_info",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -543,6 +560,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "lead",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -575,6 +593,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "contact",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -607,6 +626,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "column_break_16",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
@@ -638,6 +658,7 @@
|
||||
"bold": 1,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "customer_name",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 0,
|
||||
@@ -671,6 +692,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "project",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -704,6 +726,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "company",
|
||||
"fieldtype": "Link",
|
||||
"hidden": 0,
|
||||
@@ -736,6 +759,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 1,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "section_break_19",
|
||||
"fieldtype": "Section Break",
|
||||
"hidden": 0,
|
||||
@@ -769,6 +793,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "eval:!doc.__islocal",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "resolution_details",
|
||||
"fieldtype": "Text Editor",
|
||||
"hidden": 0,
|
||||
@@ -803,6 +828,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "eval:!doc.__islocal",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "column_break1",
|
||||
"fieldtype": "Column Break",
|
||||
"hidden": 0,
|
||||
@@ -835,6 +861,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"default": "Today",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "opening_date",
|
||||
"fieldtype": "Date",
|
||||
"hidden": 0,
|
||||
@@ -868,6 +895,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "opening_time",
|
||||
"fieldtype": "Time",
|
||||
"hidden": 0,
|
||||
@@ -902,6 +930,7 @@
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"depends_on": "eval:!doc.__islocal",
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "resolution_date",
|
||||
"fieldtype": "Datetime",
|
||||
"hidden": 0,
|
||||
@@ -935,6 +964,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "content_type",
|
||||
"fieldtype": "Data",
|
||||
"hidden": 1,
|
||||
@@ -966,6 +996,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "attachment",
|
||||
"fieldtype": "Attach",
|
||||
"hidden": 1,
|
||||
@@ -998,6 +1029,7 @@
|
||||
"bold": 0,
|
||||
"collapsible": 0,
|
||||
"columns": 0,
|
||||
"fetch_if_empty": 0,
|
||||
"fieldname": "via_customer_portal",
|
||||
"fieldtype": "Check",
|
||||
"hidden": 0,
|
||||
@@ -1035,7 +1067,7 @@
|
||||
"issingle": 0,
|
||||
"istable": 0,
|
||||
"max_attachments": 0,
|
||||
"modified": "2018-08-21 14:44:27.615004",
|
||||
"modified": "2019-04-24 23:09:48.711076",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Support",
|
||||
"name": "Issue",
|
||||
|
||||
Reference in New Issue
Block a user