Merge branch 'develop' into feat-customer-credit-limit
This commit is contained in:
commit
b03fa8a441
@ -5,7 +5,7 @@ import frappe
|
|||||||
from erpnext.hooks import regional_overrides
|
from erpnext.hooks import regional_overrides
|
||||||
from frappe.utils import getdate
|
from frappe.utils import getdate
|
||||||
|
|
||||||
__version__ = '12.0.8'
|
__version__ = '12.1.0'
|
||||||
|
|
||||||
def get_default_company(user=None):
|
def get_default_company(user=None):
|
||||||
'''Get default company for user'''
|
'''Get default company for user'''
|
||||||
|
|||||||
@ -8,7 +8,7 @@ def get_data():
|
|||||||
'fieldname': 'bank',
|
'fieldname': 'bank',
|
||||||
'transactions': [
|
'transactions': [
|
||||||
{
|
{
|
||||||
'label': _('Bank Deatils'),
|
'label': _('Bank Details'),
|
||||||
'items': ['Bank Account', 'Bank Guarantee']
|
'items': ['Bank Account', 'Bank Guarantee']
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@ -1118,7 +1118,8 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
if (key) {
|
if (key) {
|
||||||
return $.grep(this.items_list, function (item) {
|
return $.grep(this.items_list, function (item) {
|
||||||
if (search_status) {
|
if (search_status) {
|
||||||
if (in_list(me.batch_no_data[item.item_code], me.search_item.$input.val())) {
|
if (me.batch_no_data[item.item_code] &&
|
||||||
|
in_list(me.batch_no_data[item.item_code], me.search_item.$input.val())) {
|
||||||
search_status = false;
|
search_status = false;
|
||||||
return me.item_batch_no[item.item_code] = me.search_item.$input.val()
|
return me.item_batch_no[item.item_code] = me.search_item.$input.val()
|
||||||
} else if (me.serial_no_data[item.item_code]
|
} else if (me.serial_no_data[item.item_code]
|
||||||
@ -1126,7 +1127,8 @@ erpnext.pos.PointOfSale = erpnext.taxes_and_totals.extend({
|
|||||||
search_status = false;
|
search_status = false;
|
||||||
me.item_serial_no[item.item_code] = [me.search_item.$input.val(), me.serial_no_data[item.item_code][me.search_item.$input.val()]]
|
me.item_serial_no[item.item_code] = [me.search_item.$input.val(), me.serial_no_data[item.item_code][me.search_item.$input.val()]]
|
||||||
return true
|
return true
|
||||||
} else if (in_list(me.barcode_data[item.item_code], me.search_item.$input.val())) {
|
} else if (me.barcode_data[item.item_code] &&
|
||||||
|
in_list(me.barcode_data[item.item_code], me.search_item.$input.val())) {
|
||||||
search_status = false;
|
search_status = false;
|
||||||
return true;
|
return true;
|
||||||
} else if (reg.test(item.item_code.toLowerCase()) || (item.description && reg.test(item.description.toLowerCase())) ||
|
} else if (reg.test(item.item_code.toLowerCase()) || (item.description && reg.test(item.description.toLowerCase())) ||
|
||||||
|
|||||||
@ -40,7 +40,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if(filters.show_pdc_in_print) { %}
|
{% if(filters.show_future_payments) { %}
|
||||||
{% var balance_row = data.slice(-1).pop();
|
{% var balance_row = data.slice(-1).pop();
|
||||||
var range1 = report.columns[11].label;
|
var range1 = report.columns[11].label;
|
||||||
var range2 = report.columns[12].label;
|
var range2 = report.columns[12].label;
|
||||||
@ -122,22 +122,22 @@
|
|||||||
<th style="width: 10%">{%= __("Date") %}</th>
|
<th style="width: 10%">{%= __("Date") %}</th>
|
||||||
<th style="width: 4%">{%= __("Age (Days)") %}</th>
|
<th style="width: 4%">{%= __("Age (Days)") %}</th>
|
||||||
|
|
||||||
{% if(report.report_name === "Accounts Receivable" && filters.show_sales_person_in_print) { %}
|
{% if(report.report_name === "Accounts Receivable" && filters.show_sales_person) { %}
|
||||||
<th style="width: 14%">{%= __("Reference") %}</th>
|
<th style="width: 14%">{%= __("Reference") %}</th>
|
||||||
<th style="width: 10%">{%= __("Sales Person") %}</th>
|
<th style="width: 10%">{%= __("Sales Person") %}</th>
|
||||||
{% } else { %}
|
{% } else { %}
|
||||||
<th style="width: 24%">{%= __("Reference") %}</th>
|
<th style="width: 24%">{%= __("Reference") %}</th>
|
||||||
{% } %}
|
{% } %}
|
||||||
{% if(!filters.show_pdc_in_print) { %}
|
{% if(!filters.show_future_payments) { %}
|
||||||
<th style="width: 20%">{%= (filters.customer || filters.supplier) ? __("Remarks"): __("Party") %}</th>
|
<th style="width: 20%">{%= (filters.customer || filters.supplier) ? __("Remarks"): __("Party") %}</th>
|
||||||
{% } %}
|
{% } %}
|
||||||
<th style="width: 10%; text-align: right">{%= __("Invoiced Amount") %}</th>
|
<th style="width: 10%; text-align: right">{%= __("Invoiced Amount") %}</th>
|
||||||
{% if(!filters.show_pdc_in_print) { %}
|
{% if(!filters.show_future_payments) { %}
|
||||||
<th style="width: 10%; text-align: right">{%= __("Paid Amount") %}</th>
|
<th style="width: 10%; text-align: right">{%= __("Paid Amount") %}</th>
|
||||||
<th style="width: 10%; text-align: right">{%= report.report_name === "Accounts Receivable" ? __('Credit Note') : __('Debit Note') %}</th>
|
<th style="width: 10%; text-align: right">{%= report.report_name === "Accounts Receivable" ? __('Credit Note') : __('Debit Note') %}</th>
|
||||||
{% } %}
|
{% } %}
|
||||||
<th style="width: 10%; text-align: right">{%= __("Outstanding Amount") %}</th>
|
<th style="width: 10%; text-align: right">{%= __("Outstanding Amount") %}</th>
|
||||||
{% if(filters.show_pdc_in_print) { %}
|
{% if(filters.show_future_payments) { %}
|
||||||
{% if(report.report_name === "Accounts Receivable") { %}
|
{% if(report.report_name === "Accounts Receivable") { %}
|
||||||
<th style="width: 12%">{%= __("Customer LPO No.") %}</th>
|
<th style="width: 12%">{%= __("Customer LPO No.") %}</th>
|
||||||
{% } %}
|
{% } %}
|
||||||
@ -162,18 +162,18 @@
|
|||||||
<td>{%= frappe.datetime.str_to_user(data[i]["posting_date"]) %}</td>
|
<td>{%= frappe.datetime.str_to_user(data[i]["posting_date"]) %}</td>
|
||||||
<td style="text-align: right">{%= data[i][__("Age (Days)")] %}</td>
|
<td style="text-align: right">{%= data[i][__("Age (Days)")] %}</td>
|
||||||
<td>
|
<td>
|
||||||
{% if(!filters.show_pdc_in_print) { %}
|
{% if(!filters.show_future_payments) { %}
|
||||||
{%= data[i]["voucher_type"] %}
|
{%= data[i]["voucher_type"] %}
|
||||||
<br>
|
<br>
|
||||||
{% } %}
|
{% } %}
|
||||||
{%= data[i]["voucher_no"] %}
|
{%= data[i]["voucher_no"] %}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
{% if(report.report_name === "Accounts Receivable" && filters.show_sales_person_in_print) { %}
|
{% if(report.report_name === "Accounts Receivable" && filters.show_sales_person) { %}
|
||||||
<td>{%= data[i]["sales_person"] %}</td>
|
<td>{%= data[i]["sales_person"] %}</td>
|
||||||
{% } %}
|
{% } %}
|
||||||
|
|
||||||
{% if(!filters.show_pdc_in_print) { %}
|
{% if(!filters.show_future_payments) { %}
|
||||||
<td>
|
<td>
|
||||||
{% if(!(filters.customer || filters.supplier)) { %}
|
{% if(!(filters.customer || filters.supplier)) { %}
|
||||||
{%= data[i][__("Customer")] || data[i][__("Supplier")] %}
|
{%= data[i][__("Customer")] || data[i][__("Supplier")] %}
|
||||||
@ -195,7 +195,7 @@
|
|||||||
<td style="text-align: right">
|
<td style="text-align: right">
|
||||||
{%= format_currency(data[i]["invoiced_amount"], data[i]["currency"]) %}</td>
|
{%= format_currency(data[i]["invoiced_amount"], data[i]["currency"]) %}</td>
|
||||||
|
|
||||||
{% if(!filters.show_pdc_in_print) { %}
|
{% if(!filters.show_future_payments) { %}
|
||||||
<td style="text-align: right">
|
<td style="text-align: right">
|
||||||
{%= format_currency(data[i]["paid_amount"], data[i]["currency"]) %}</td>
|
{%= format_currency(data[i]["paid_amount"], data[i]["currency"]) %}</td>
|
||||||
<td style="text-align: right">
|
<td style="text-align: right">
|
||||||
@ -204,7 +204,7 @@
|
|||||||
<td style="text-align: right">
|
<td style="text-align: right">
|
||||||
{%= format_currency(data[i]["outstanding_amount"], data[i]["currency"]) %}</td>
|
{%= format_currency(data[i]["outstanding_amount"], data[i]["currency"]) %}</td>
|
||||||
|
|
||||||
{% if(filters.show_pdc_in_print) { %}
|
{% if(filters.show_future_payments) { %}
|
||||||
{% if(report.report_name === "Accounts Receivable") { %}
|
{% if(report.report_name === "Accounts Receivable") { %}
|
||||||
<td style="text-align: right">
|
<td style="text-align: right">
|
||||||
{%= data[i]["po_no"] %}</td>
|
{%= data[i]["po_no"] %}</td>
|
||||||
@ -215,10 +215,10 @@
|
|||||||
{% } %}
|
{% } %}
|
||||||
{% } else { %}
|
{% } else { %}
|
||||||
<td></td>
|
<td></td>
|
||||||
{% if(!filters.show_pdc_in_print) { %}
|
{% if(!filters.show_future_payments) { %}
|
||||||
<td></td>
|
<td></td>
|
||||||
{% } %}
|
{% } %}
|
||||||
{% if(report.report_name === "Accounts Receivable" && filters.show_sales_person_in_print) { %}
|
{% if(report.report_name === "Accounts Receivable" && filters.show_sales_person) { %}
|
||||||
<td></td>
|
<td></td>
|
||||||
{% } %}
|
{% } %}
|
||||||
<td></td>
|
<td></td>
|
||||||
@ -226,7 +226,7 @@
|
|||||||
<td style="text-align: right">
|
<td style="text-align: right">
|
||||||
{%= format_currency(data[i]["invoiced_amount"], data[i]["currency"] ) %}</td>
|
{%= format_currency(data[i]["invoiced_amount"], data[i]["currency"] ) %}</td>
|
||||||
|
|
||||||
{% if(!filters.show_pdc_in_print) { %}
|
{% if(!filters.show_future_payments) { %}
|
||||||
<td style="text-align: right">
|
<td style="text-align: right">
|
||||||
{%= format_currency(data[i]["paid_amount"], data[i]["currency"]) %}</td>
|
{%= format_currency(data[i]["paid_amount"], data[i]["currency"]) %}</td>
|
||||||
<td style="text-align: right">{%= report.report_name === "Accounts Receivable" ? format_currency(data[i]["credit_note"], data[i]["currency"]) : format_currency(data[i]["debit_note"], data[i]["currency"]) %} </td>
|
<td style="text-align: right">{%= report.report_name === "Accounts Receivable" ? format_currency(data[i]["credit_note"], data[i]["currency"]) : format_currency(data[i]["debit_note"], data[i]["currency"]) %} </td>
|
||||||
@ -234,7 +234,7 @@
|
|||||||
<td style="text-align: right">
|
<td style="text-align: right">
|
||||||
{%= format_currency(data[i]["outstanding_amount"], data[i]["currency"]) %}</td>
|
{%= format_currency(data[i]["outstanding_amount"], data[i]["currency"]) %}</td>
|
||||||
|
|
||||||
{% if(filters.show_pdc_in_print) { %}
|
{% if(filters.show_future_payments) { %}
|
||||||
{% if(report.report_name === "Accounts Receivable") { %}
|
{% if(report.report_name === "Accounts Receivable") { %}
|
||||||
<td style="text-align: right">
|
<td style="text-align: right">
|
||||||
{%= data[i][__("Customer LPO")] %}</td>
|
{%= data[i][__("Customer LPO")] %}</td>
|
||||||
|
|||||||
@ -130,13 +130,18 @@ frappe.query_reports["Accounts Receivable"] = {
|
|||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"show_pdc_in_print",
|
"fieldname":"show_future_payments",
|
||||||
"label": __("Show PDC in Print"),
|
"label": __("Show Future Payments"),
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"fieldname":"show_sales_person_in_print",
|
"fieldname":"show_delivery_notes",
|
||||||
"label": __("Show Sales Person in Print"),
|
"label": __("Show Delivery Notes"),
|
||||||
|
"fieldtype": "Check",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname":"show_sales_person",
|
||||||
|
"label": __("Show Sales Person"),
|
||||||
"fieldtype": "Check",
|
"fieldtype": "Check",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -14,33 +14,44 @@ class TestAccountsReceivable(unittest.TestCase):
|
|||||||
|
|
||||||
filters = {
|
filters = {
|
||||||
'company': '_Test Company 2',
|
'company': '_Test Company 2',
|
||||||
'based_on_payment_terms': 1
|
'based_on_payment_terms': 1,
|
||||||
|
'report_date': today(),
|
||||||
|
'range1': 30,
|
||||||
|
'range2': 60,
|
||||||
|
'range3': 90,
|
||||||
|
'range4': 120
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# check invoice grand total and invoiced column's value for 3 payment terms
|
||||||
name = make_sales_invoice()
|
name = make_sales_invoice()
|
||||||
report = execute(filters)
|
report = execute(filters)
|
||||||
|
|
||||||
expected_data = [[100,30], [100,50], [100,20]]
|
expected_data = [[100, 30], [100, 50], [100, 20]]
|
||||||
|
|
||||||
self.assertEqual(expected_data[0], report[1][0][7:9])
|
for i in range(3):
|
||||||
self.assertEqual(expected_data[1], report[1][1][7:9])
|
row = report[1][i-1]
|
||||||
self.assertEqual(expected_data[2], report[1][2][7:9])
|
self.assertEqual(expected_data[i-1], [row.invoice_grand_total, row.invoiced])
|
||||||
|
|
||||||
|
# check invoice grand total, invoiced, paid and outstanding column's value after payment
|
||||||
make_payment(name)
|
make_payment(name)
|
||||||
report = execute(filters)
|
report = execute(filters)
|
||||||
|
|
||||||
expected_data_after_payment = [[100,50], [100,20]]
|
expected_data_after_payment = [[100, 50, 10, 40], [100, 20, 0, 20]]
|
||||||
|
|
||||||
self.assertEqual(expected_data_after_payment[0], report[1][0][7:9])
|
for i in range(2):
|
||||||
self.assertEqual(expected_data_after_payment[1], report[1][1][7:9])
|
row = report[1][i-1]
|
||||||
|
self.assertEqual(expected_data_after_payment[i-1],
|
||||||
|
[row.invoice_grand_total, row.invoiced, row.paid, row.outstanding])
|
||||||
|
|
||||||
|
# check invoice grand total, invoiced, paid and outstanding column's value after credit note
|
||||||
make_credit_note(name)
|
make_credit_note(name)
|
||||||
report = execute(filters)
|
report = execute(filters)
|
||||||
|
|
||||||
expected_data_after_credit_note = [[100,100,30,100,-30]]
|
expected_data_after_credit_note = [100, 0, 0, 40, -40]
|
||||||
|
|
||||||
self.assertEqual(expected_data_after_credit_note[0], report[1][0][7:12])
|
|
||||||
|
|
||||||
|
row = report[1][0]
|
||||||
|
self.assertEqual(expected_data_after_credit_note,
|
||||||
|
[row.invoice_grand_total, row.invoiced, row.paid, row.credit_note, row.outstanding])
|
||||||
|
|
||||||
def make_sales_invoice():
|
def make_sales_invoice():
|
||||||
frappe.set_user("Administrator")
|
frappe.set_user("Administrator")
|
||||||
@ -64,7 +75,7 @@ def make_sales_invoice():
|
|||||||
return si.name
|
return si.name
|
||||||
|
|
||||||
def make_payment(docname):
|
def make_payment(docname):
|
||||||
pe = get_payment_entry("Sales Invoice", docname, bank_account="Cash - _TC2", party_amount=30)
|
pe = get_payment_entry("Sales Invoice", docname, bank_account="Cash - _TC2", party_amount=40)
|
||||||
pe.paid_from = "Debtors - _TC2"
|
pe.paid_from = "Debtors - _TC2"
|
||||||
pe.insert()
|
pe.insert()
|
||||||
pe.submit()
|
pe.submit()
|
||||||
|
|||||||
@ -3,236 +3,11 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _, scrub
|
from frappe import _
|
||||||
from frappe.utils import flt
|
from frappe.utils import flt, cint
|
||||||
from erpnext.accounts.party import get_partywise_advanced_payment_amount
|
from erpnext.accounts.party import get_partywise_advanced_payment_amount
|
||||||
from erpnext.accounts.report.accounts_receivable.accounts_receivable import ReceivablePayableReport
|
from erpnext.accounts.report.accounts_receivable.accounts_receivable import ReceivablePayableReport
|
||||||
|
|
||||||
from six import iteritems
|
from six import iteritems
|
||||||
from six.moves import zip
|
|
||||||
|
|
||||||
class AccountsReceivableSummary(ReceivablePayableReport):
|
|
||||||
def run(self, args):
|
|
||||||
party_naming_by = frappe.db.get_value(args.get("naming_by")[0], None, args.get("naming_by")[1])
|
|
||||||
return self.get_columns(party_naming_by, args), self.get_data(party_naming_by, args)
|
|
||||||
|
|
||||||
def get_columns(self, party_naming_by, args):
|
|
||||||
columns = [_(args.get("party_type")) + ":Link/" + args.get("party_type") + ":200"]
|
|
||||||
|
|
||||||
if party_naming_by == "Naming Series":
|
|
||||||
columns += [ args.get("party_type") + " Name::140"]
|
|
||||||
|
|
||||||
credit_debit_label = "Credit Note Amt" if args.get('party_type') == 'Customer' else "Debit Note Amt"
|
|
||||||
|
|
||||||
columns += [{
|
|
||||||
"label": _("Advance Amount"),
|
|
||||||
"fieldname": "advance_amount",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"options": "currency",
|
|
||||||
"width": 100
|
|
||||||
},{
|
|
||||||
"label": _("Total Invoiced Amt"),
|
|
||||||
"fieldname": "total_invoiced_amt",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"options": "currency",
|
|
||||||
"width": 100
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": _("Total Paid Amt"),
|
|
||||||
"fieldname": "total_paid_amt",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"options": "currency",
|
|
||||||
"width": 100
|
|
||||||
}]
|
|
||||||
|
|
||||||
columns += [
|
|
||||||
{
|
|
||||||
"label": _(credit_debit_label),
|
|
||||||
"fieldname": scrub(credit_debit_label),
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"options": "currency",
|
|
||||||
"width": 140
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": _("Total Outstanding Amt"),
|
|
||||||
"fieldname": "total_outstanding_amt",
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"options": "currency",
|
|
||||||
"width": 160
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": _("0-" + str(self.filters.range1)),
|
|
||||||
"fieldname": scrub("0-" + str(self.filters.range1)),
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"options": "currency",
|
|
||||||
"width": 160
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": _(str(self.filters.range1) + "-" + str(self.filters.range2)),
|
|
||||||
"fieldname": scrub(str(self.filters.range1) + "-" + str(self.filters.range2)),
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"options": "currency",
|
|
||||||
"width": 160
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": _(str(self.filters.range2) + "-" + str(self.filters.range3)),
|
|
||||||
"fieldname": scrub(str(self.filters.range2) + "-" + str(self.filters.range3)),
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"options": "currency",
|
|
||||||
"width": 160
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": _(str(self.filters.range3) + "-" + str(self.filters.range4)),
|
|
||||||
"fieldname": scrub(str(self.filters.range3) + "-" + str(self.filters.range4)),
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"options": "currency",
|
|
||||||
"width": 160
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": _(str(self.filters.range4) + _("-Above")),
|
|
||||||
"fieldname": scrub(str(self.filters.range4) + _("-Above")),
|
|
||||||
"fieldtype": "Currency",
|
|
||||||
"options": "currency",
|
|
||||||
"width": 160
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
if args.get("party_type") == "Customer":
|
|
||||||
columns += [{
|
|
||||||
"label": _("Territory"),
|
|
||||||
"fieldname": "territory",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"options": "Territory",
|
|
||||||
"width": 80
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": _("Customer Group"),
|
|
||||||
"fieldname": "customer_group",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"options": "Customer Group",
|
|
||||||
"width": 80
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": _("Sales Person"),
|
|
||||||
"fieldtype": "Data",
|
|
||||||
"fieldname": "sales_person",
|
|
||||||
"width": 120,
|
|
||||||
}]
|
|
||||||
|
|
||||||
if args.get("party_type") == "Supplier":
|
|
||||||
columns += [{
|
|
||||||
"label": _("Supplier Group"),
|
|
||||||
"fieldname": "supplier_group",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"options": "Supplier Group",
|
|
||||||
"width": 80
|
|
||||||
}]
|
|
||||||
|
|
||||||
columns.append({
|
|
||||||
"fieldname": "currency",
|
|
||||||
"label": _("Currency"),
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"options": "Currency",
|
|
||||||
"width": 80
|
|
||||||
})
|
|
||||||
|
|
||||||
return columns
|
|
||||||
|
|
||||||
def get_data(self, party_naming_by, args):
|
|
||||||
data = []
|
|
||||||
|
|
||||||
partywise_total = self.get_partywise_total(party_naming_by, args)
|
|
||||||
|
|
||||||
partywise_advance_amount = get_partywise_advanced_payment_amount(args.get("party_type"),
|
|
||||||
self.filters.get("report_date")) or {}
|
|
||||||
for party, party_dict in iteritems(partywise_total):
|
|
||||||
row = [party]
|
|
||||||
|
|
||||||
if party_naming_by == "Naming Series":
|
|
||||||
row += [self.get_party_name(args.get("party_type"), party)]
|
|
||||||
|
|
||||||
row += [partywise_advance_amount.get(party, 0)]
|
|
||||||
|
|
||||||
paid_amt = 0
|
|
||||||
if party_dict.paid_amt > 0:
|
|
||||||
paid_amt = flt(party_dict.paid_amt - partywise_advance_amount.get(party, 0))
|
|
||||||
|
|
||||||
row += [
|
|
||||||
party_dict.invoiced_amt, paid_amt, party_dict.credit_amt, party_dict.outstanding_amt,
|
|
||||||
party_dict.range1, party_dict.range2, party_dict.range3, party_dict.range4, party_dict.range5
|
|
||||||
]
|
|
||||||
|
|
||||||
if args.get("party_type") == "Customer":
|
|
||||||
row += [self.get_territory(party), self.get_customer_group(party), ", ".join(set(party_dict.sales_person))]
|
|
||||||
if args.get("party_type") == "Supplier":
|
|
||||||
row += [self.get_supplier_group(party)]
|
|
||||||
|
|
||||||
row.append(party_dict.currency)
|
|
||||||
data.append(row)
|
|
||||||
|
|
||||||
return data
|
|
||||||
|
|
||||||
def get_partywise_total(self, party_naming_by, args):
|
|
||||||
party_total = frappe._dict()
|
|
||||||
for d in self.get_voucherwise_data(party_naming_by, args):
|
|
||||||
party_total.setdefault(d.party,
|
|
||||||
frappe._dict({
|
|
||||||
"invoiced_amt": 0,
|
|
||||||
"paid_amt": 0,
|
|
||||||
"credit_amt": 0,
|
|
||||||
"outstanding_amt": 0,
|
|
||||||
"range1": 0,
|
|
||||||
"range2": 0,
|
|
||||||
"range3": 0,
|
|
||||||
"range4": 0,
|
|
||||||
"range5": 0,
|
|
||||||
"sales_person": []
|
|
||||||
})
|
|
||||||
)
|
|
||||||
for k in list(party_total[d.party]):
|
|
||||||
if k not in ["currency", "sales_person"]:
|
|
||||||
party_total[d.party][k] += flt(d.get(k, 0))
|
|
||||||
|
|
||||||
party_total[d.party].currency = d.currency
|
|
||||||
|
|
||||||
if d.sales_person:
|
|
||||||
party_total[d.party].sales_person.append(d.sales_person)
|
|
||||||
|
|
||||||
return party_total
|
|
||||||
|
|
||||||
def get_voucherwise_data(self, party_naming_by, args):
|
|
||||||
voucherwise_data = ReceivablePayableReport(self.filters).run(args)[1]
|
|
||||||
|
|
||||||
cols = ["posting_date", "party"]
|
|
||||||
|
|
||||||
if party_naming_by == "Naming Series":
|
|
||||||
cols += ["party_name"]
|
|
||||||
|
|
||||||
if args.get("party_type") == 'Customer':
|
|
||||||
cols += ["contact"]
|
|
||||||
|
|
||||||
cols += ["voucher_type", "voucher_no", "due_date"]
|
|
||||||
|
|
||||||
if args.get("party_type") == "Supplier":
|
|
||||||
cols += ["bill_no", "bill_date"]
|
|
||||||
|
|
||||||
cols += ["invoiced_amt", "paid_amt", "credit_amt",
|
|
||||||
"outstanding_amt", "age", "range1", "range2", "range3", "range4", "range5", "currency", "pdc/lc_date", "pdc/lc_ref",
|
|
||||||
"pdc/lc_amount"]
|
|
||||||
|
|
||||||
if args.get("party_type") == "Supplier":
|
|
||||||
cols += ["supplier_group", "remarks"]
|
|
||||||
if args.get("party_type") == "Customer":
|
|
||||||
cols += ["po_no", "do_no", "territory", "customer_group", "sales_person", "remarks"]
|
|
||||||
|
|
||||||
return self.make_data_dict(cols, voucherwise_data)
|
|
||||||
|
|
||||||
def make_data_dict(self, cols, data):
|
|
||||||
data_dict = []
|
|
||||||
for d in data:
|
|
||||||
data_dict.append(frappe._dict(zip(cols, d)))
|
|
||||||
|
|
||||||
return data_dict
|
|
||||||
|
|
||||||
def execute(filters=None):
|
def execute(filters=None):
|
||||||
args = {
|
args = {
|
||||||
@ -241,3 +16,119 @@ def execute(filters=None):
|
|||||||
}
|
}
|
||||||
|
|
||||||
return AccountsReceivableSummary(filters).run(args)
|
return AccountsReceivableSummary(filters).run(args)
|
||||||
|
|
||||||
|
class AccountsReceivableSummary(ReceivablePayableReport):
|
||||||
|
def run(self, args):
|
||||||
|
self.party_type = args.get('party_type')
|
||||||
|
self.party_naming_by = frappe.db.get_value(args.get("naming_by")[0], None, args.get("naming_by")[1])
|
||||||
|
self.get_columns()
|
||||||
|
self.get_data(args)
|
||||||
|
return self.columns, self.data
|
||||||
|
|
||||||
|
def get_data(self, args):
|
||||||
|
self.data = []
|
||||||
|
|
||||||
|
self.receivables = ReceivablePayableReport(self.filters).run(args)[1]
|
||||||
|
|
||||||
|
self.get_party_total(args)
|
||||||
|
|
||||||
|
party_advance_amount = get_partywise_advanced_payment_amount(self.party_type,
|
||||||
|
self.filters.report_date) or {}
|
||||||
|
|
||||||
|
for party, party_dict in iteritems(self.party_total):
|
||||||
|
row = frappe._dict()
|
||||||
|
|
||||||
|
row.party = party
|
||||||
|
if self.party_naming_by == "Naming Series":
|
||||||
|
row.party_name = frappe.get_cached_value(self.party_type, party, [self.party_type + "_name"])
|
||||||
|
|
||||||
|
row.update(party_dict)
|
||||||
|
|
||||||
|
# Advance against party
|
||||||
|
row.advance = party_advance_amount.get(party, 0)
|
||||||
|
|
||||||
|
# In AR/AP, advance shown in paid columns,
|
||||||
|
# but in summary report advance shown in separate column
|
||||||
|
row.paid -= row.advance
|
||||||
|
|
||||||
|
self.data.append(row)
|
||||||
|
|
||||||
|
def get_party_total(self, args):
|
||||||
|
self.party_total = frappe._dict()
|
||||||
|
|
||||||
|
for d in self.receivables:
|
||||||
|
self.init_party_total(d)
|
||||||
|
|
||||||
|
# Add all amount columns
|
||||||
|
for k in list(self.party_total[d.party]):
|
||||||
|
if k not in ["currency", "sales_person"]:
|
||||||
|
|
||||||
|
self.party_total[d.party][k] += d.get(k, 0.0)
|
||||||
|
|
||||||
|
# set territory, customer_group, sales person etc
|
||||||
|
self.set_party_details(d)
|
||||||
|
|
||||||
|
def init_party_total(self, row):
|
||||||
|
self.party_total.setdefault(row.party, frappe._dict({
|
||||||
|
"invoiced": 0.0,
|
||||||
|
"paid": 0.0,
|
||||||
|
"credit_note": 0.0,
|
||||||
|
"outstanding": 0.0,
|
||||||
|
"range1": 0.0,
|
||||||
|
"range2": 0.0,
|
||||||
|
"range3": 0.0,
|
||||||
|
"range4": 0.0,
|
||||||
|
"range5": 0.0,
|
||||||
|
"sales_person": []
|
||||||
|
}))
|
||||||
|
|
||||||
|
def set_party_details(self, row):
|
||||||
|
self.party_total[row.party].currency = row.currency
|
||||||
|
|
||||||
|
for key in ('territory', 'customer_group', 'supplier_group'):
|
||||||
|
if row.get(key):
|
||||||
|
self.party_total[row.party][key] = row.get(key)
|
||||||
|
|
||||||
|
if row.sales_person:
|
||||||
|
self.party_total[row.party].sales_person.append(row.sales_person)
|
||||||
|
|
||||||
|
def get_columns(self):
|
||||||
|
self.columns = []
|
||||||
|
self.add_column(label=_(self.party_type), fieldname='party',
|
||||||
|
fieldtype='Link', options=self.party_type, width=180)
|
||||||
|
|
||||||
|
if self.party_naming_by == "Naming Series":
|
||||||
|
self.add_column(_('{0} Name').format(self.party_type),
|
||||||
|
fieldname = 'party_name', fieldtype='Data')
|
||||||
|
|
||||||
|
credit_debit_label = "Credit Note" if self.party_type == 'Customer' else "Debit Note"
|
||||||
|
|
||||||
|
self.add_column(_('Advance Amount'), fieldname='advance')
|
||||||
|
self.add_column(_('Invoiced Amount'), fieldname='invoiced')
|
||||||
|
self.add_column(_('Paid Amount'), fieldname='paid')
|
||||||
|
self.add_column(_(credit_debit_label), fieldname='credit_note')
|
||||||
|
self.add_column(_('Outstanding Amount'), fieldname='outstanding')
|
||||||
|
|
||||||
|
self.setup_ageing_columns()
|
||||||
|
|
||||||
|
if self.party_type == "Customer":
|
||||||
|
self.add_column(label=_('Territory'), fieldname='territory', fieldtype='Link',
|
||||||
|
options='Territory')
|
||||||
|
self.add_column(label=_('Customer Group'), fieldname='customer_group', fieldtype='Link',
|
||||||
|
options='Customer Group')
|
||||||
|
if self.filters.show_sales_person:
|
||||||
|
self.add_column(label=_('Sales Person'), fieldname='sales_person', fieldtype='Data')
|
||||||
|
else:
|
||||||
|
self.add_column(label=_('Supplier Group'), fieldname='supplier_group', fieldtype='Link',
|
||||||
|
options='Supplier Group')
|
||||||
|
|
||||||
|
self.add_column(label=_('Currency'), fieldname='currency', fieldtype='Link',
|
||||||
|
options='Currency', width=80)
|
||||||
|
|
||||||
|
def setup_ageing_columns(self):
|
||||||
|
for i, label in enumerate(["0-{range1}".format(range1=self.filters["range1"]),
|
||||||
|
"{range1}-{range2}".format(range1=cint(self.filters["range1"])+ 1, range2=self.filters["range2"]),
|
||||||
|
"{range2}-{range3}".format(range2=cint(self.filters["range2"])+ 1, range3=self.filters["range3"]),
|
||||||
|
"{range3}-{range4}".format(range3=cint(self.filters["range3"])+ 1, range4=self.filters["range4"]),
|
||||||
|
"{range4}-{above}".format(range4=cint(self.filters["range4"])+ 1, above=_("Above"))]):
|
||||||
|
self.add_column(label=label, fieldname='range' + str(i+1))
|
||||||
6
erpnext/change_log/v12/v12_1_0.md
Normal file
6
erpnext/change_log/v12/v12_1_0.md
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# Version 12.1.0 Release Notes
|
||||||
|
|
||||||
|
### Stock
|
||||||
|
|
||||||
|
1. [Pick List](https://erpnext.com/docs/user/manual/en/stock/pick-list)
|
||||||
|
2. [Refactored Accounts Receivable Reports](https://erpnext.com/docs/user/manual/en/accounts/accounting-reports#2-accounting-statements)
|
||||||
@ -28,7 +28,7 @@ class CallLog(Document):
|
|||||||
self.trigger_call_popup()
|
self.trigger_call_popup()
|
||||||
|
|
||||||
def trigger_call_popup(self):
|
def trigger_call_popup(self):
|
||||||
scheduled_employees = get_scheduled_employees_for_popup(self.to)
|
scheduled_employees = get_scheduled_employees_for_popup(self.medium)
|
||||||
employee_emails = get_employees_with_number(self.to)
|
employee_emails = get_employees_with_number(self.to)
|
||||||
|
|
||||||
# check if employees with matched number are scheduled to receive popup
|
# check if employees with matched number are scheduled to receive popup
|
||||||
|
|||||||
@ -11,7 +11,7 @@ from frappe.utils import getdate, date_diff
|
|||||||
class AdditionalSalary(Document):
|
class AdditionalSalary(Document):
|
||||||
def before_insert(self):
|
def before_insert(self):
|
||||||
if frappe.db.exists("Additional Salary", {"employee": self.employee, "salary_component": self.salary_component,
|
if frappe.db.exists("Additional Salary", {"employee": self.employee, "salary_component": self.salary_component,
|
||||||
"amount": self.amount, "payroll_date": self.payroll_date, "company": self.company}):
|
"amount": self.amount, "payroll_date": self.payroll_date, "company": self.company, "docstatus": 1}):
|
||||||
|
|
||||||
frappe.throw(_("Additional Salary Component Exists."))
|
frappe.throw(_("Additional Salary Component Exists."))
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,21 @@
|
|||||||
// For license information, please see license.txt
|
// For license information, please see license.txt
|
||||||
|
|
||||||
frappe.ui.form.on('Employee Incentive', {
|
frappe.ui.form.on('Employee Incentive', {
|
||||||
refresh: function(frm) {
|
setup: function(frm) {
|
||||||
|
frm.set_query("employee", function() {
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
"status": "Active"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
frm.set_query("salary_component", function() {
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
"type": "Earning"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,262 +1,90 @@
|
|||||||
{
|
{
|
||||||
"allow_copy": 0,
|
|
||||||
"allow_guest_to_view": 0,
|
|
||||||
"allow_import": 0,
|
|
||||||
"allow_rename": 0,
|
|
||||||
"autoname": "HR-EINV-.YY.-.MM.-.#####",
|
"autoname": "HR-EINV-.YY.-.MM.-.#####",
|
||||||
"beta": 0,
|
|
||||||
"creation": "2018-04-13 16:13:43.404546",
|
"creation": "2018-04-13 16:13:43.404546",
|
||||||
"custom": 0,
|
|
||||||
"docstatus": 0,
|
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"document_type": "",
|
|
||||||
"editable_grid": 1,
|
"editable_grid": 1,
|
||||||
"engine": "InnoDB",
|
"engine": "InnoDB",
|
||||||
|
"field_order": [
|
||||||
|
"employee",
|
||||||
|
"incentive_amount",
|
||||||
|
"payroll_date",
|
||||||
|
"salary_component",
|
||||||
|
"amended_from",
|
||||||
|
"column_break_5",
|
||||||
|
"employee_name",
|
||||||
|
"department",
|
||||||
|
"additional_salary"
|
||||||
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_in_quick_entry": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "employee",
|
"fieldname": "employee",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Employee",
|
"label": "Employee",
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"options": "Employee",
|
"options": "Employee",
|
||||||
"permlevel": 0,
|
"reqd": 1
|
||||||
"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,
|
|
||||||
"fieldname": "incentive_amount",
|
"fieldname": "incentive_amount",
|
||||||
"fieldtype": "Currency",
|
"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": "Incentive Amount",
|
"label": "Incentive Amount",
|
||||||
"length": 0,
|
"reqd": 1
|
||||||
"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
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_in_quick_entry": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "payroll_date",
|
"fieldname": "payroll_date",
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"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": "Payroll Date",
|
"label": "Payroll Date",
|
||||||
"length": 0,
|
"reqd": 1
|
||||||
"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": "amended_from",
|
"fieldname": "amended_from",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"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": "Amended From",
|
"label": "Amended From",
|
||||||
"length": 0,
|
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"options": "Employee Incentive",
|
"options": "Employee Incentive",
|
||||||
"permlevel": 0,
|
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"print_hide_if_no_value": 0,
|
"read_only": 1
|
||||||
"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,
|
|
||||||
"fieldname": "column_break_5",
|
"fieldname": "column_break_5",
|
||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break"
|
||||||
"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,
|
|
||||||
"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,
|
|
||||||
"fetch_from": "employee.employee_name",
|
"fetch_from": "employee.employee_name",
|
||||||
"fieldname": "employee_name",
|
"fieldname": "employee_name",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"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": "Employee Name",
|
"label": "Employee Name",
|
||||||
"length": 0,
|
"read_only": 1
|
||||||
"no_copy": 0,
|
|
||||||
"options": "",
|
|
||||||
"permlevel": 0,
|
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"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": "employee.department",
|
"fetch_from": "employee.department",
|
||||||
"fieldname": "department",
|
"fieldname": "department",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"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": "Department",
|
"label": "Department",
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"options": "Department",
|
"options": "Department",
|
||||||
"permlevel": 0,
|
"read_only": 1
|
||||||
"precision": "",
|
},
|
||||||
"print_hide": 0,
|
{
|
||||||
"print_hide_if_no_value": 0,
|
"fieldname": "additional_salary",
|
||||||
"read_only": 1,
|
"fieldtype": "Link",
|
||||||
"remember_last_selected_value": 0,
|
"label": "Additional Salary",
|
||||||
"report_hide": 0,
|
"no_copy": 1,
|
||||||
"reqd": 0,
|
"options": "Additional Salary",
|
||||||
"search_index": 0,
|
"read_only": 1
|
||||||
"set_only_once": 0,
|
},
|
||||||
"translatable": 0,
|
{
|
||||||
"unique": 0
|
"fieldname": "salary_component",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Salary Component",
|
||||||
|
"options": "Salary Component",
|
||||||
|
"reqd": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"has_web_view": 0,
|
|
||||||
"hide_heading": 0,
|
|
||||||
"hide_toolbar": 0,
|
|
||||||
"idx": 0,
|
|
||||||
"image_view": 0,
|
|
||||||
"in_create": 0,
|
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"issingle": 0,
|
"modified": "2019-09-03 16:48:16.822252",
|
||||||
"istable": 0,
|
|
||||||
"max_attachments": 0,
|
|
||||||
"modified": "2018-08-21 16:15:51.811149",
|
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "HR",
|
"module": "HR",
|
||||||
"name": "Employee Incentive",
|
"name": "Employee Incentive",
|
||||||
"name_case": "",
|
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
{
|
{
|
||||||
@ -266,65 +94,37 @@
|
|||||||
"delete": 1,
|
"delete": 1,
|
||||||
"email": 1,
|
"email": 1,
|
||||||
"export": 1,
|
"export": 1,
|
||||||
"if_owner": 0,
|
|
||||||
"import": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
"print": 1,
|
||||||
"read": 1,
|
"read": 1,
|
||||||
"report": 1,
|
"report": 1,
|
||||||
"role": "HR Manager",
|
"role": "HR Manager",
|
||||||
"set_user_permissions": 0,
|
|
||||||
"share": 1,
|
"share": 1,
|
||||||
"submit": 1,
|
"submit": 1,
|
||||||
"write": 1
|
"write": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"amend": 0,
|
|
||||||
"cancel": 0,
|
|
||||||
"create": 0,
|
|
||||||
"delete": 0,
|
|
||||||
"email": 1,
|
"email": 1,
|
||||||
"export": 1,
|
"export": 1,
|
||||||
"if_owner": 0,
|
|
||||||
"import": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
"print": 1,
|
||||||
"read": 1,
|
"read": 1,
|
||||||
"report": 1,
|
"report": 1,
|
||||||
"role": "Employee",
|
"role": "Employee",
|
||||||
"set_user_permissions": 0,
|
"share": 1
|
||||||
"share": 1,
|
|
||||||
"submit": 0,
|
|
||||||
"write": 0
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"amend": 0,
|
|
||||||
"cancel": 0,
|
|
||||||
"create": 1,
|
"create": 1,
|
||||||
"delete": 0,
|
|
||||||
"email": 1,
|
"email": 1,
|
||||||
"export": 1,
|
"export": 1,
|
||||||
"if_owner": 0,
|
|
||||||
"import": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
"print": 1,
|
||||||
"read": 1,
|
"read": 1,
|
||||||
"report": 1,
|
"report": 1,
|
||||||
"role": "HR User",
|
"role": "HR User",
|
||||||
"set_user_permissions": 0,
|
|
||||||
"share": 1,
|
"share": 1,
|
||||||
"submit": 0,
|
|
||||||
"write": 1
|
"write": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"quick_entry": 0,
|
|
||||||
"read_only": 0,
|
|
||||||
"read_only_onload": 0,
|
|
||||||
"show_name_in_global_search": 0,
|
|
||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"title_field": "employee_name",
|
"title_field": "employee_name",
|
||||||
"track_changes": 1,
|
"track_changes": 1
|
||||||
"track_seen": 0,
|
|
||||||
"track_views": 0
|
|
||||||
}
|
}
|
||||||
@ -7,4 +7,39 @@ import frappe
|
|||||||
from frappe.model.document import Document
|
from frappe.model.document import Document
|
||||||
|
|
||||||
class EmployeeIncentive(Document):
|
class EmployeeIncentive(Document):
|
||||||
pass
|
def on_submit(self):
|
||||||
|
company = frappe.db.get_value('Employee', self.employee, 'company')
|
||||||
|
additional_salary = frappe.db.exists('Additional Salary', {
|
||||||
|
'employee': self.employee,
|
||||||
|
'salary_component': self.salary_component,
|
||||||
|
'payroll_date': self.payroll_date,
|
||||||
|
'company': company,
|
||||||
|
'docstatus': 1
|
||||||
|
})
|
||||||
|
|
||||||
|
if not additional_salary:
|
||||||
|
additional_salary = frappe.new_doc('Additional Salary')
|
||||||
|
additional_salary.employee = self.employee
|
||||||
|
additional_salary.salary_component = self.salary_component
|
||||||
|
additional_salary.amount = self.incentive_amount
|
||||||
|
additional_salary.payroll_date = self.payroll_date
|
||||||
|
additional_salary.company = company
|
||||||
|
additional_salary.submit()
|
||||||
|
self.db_set('additional_salary', additional_salary.name)
|
||||||
|
|
||||||
|
else:
|
||||||
|
incentive_added = frappe.db.get_value('Additional Salary', additional_salary, 'amount') + self.incentive_amount
|
||||||
|
frappe.db.set_value('Additional Salary', additional_salary, 'amount', incentive_added)
|
||||||
|
self.db_set('additional_salary', additional_salary)
|
||||||
|
|
||||||
|
def on_cancel(self):
|
||||||
|
if self.additional_salary:
|
||||||
|
incentive_removed = frappe.db.get_value('Additional Salary', self.additional_salary, 'amount') - self.incentive_amount
|
||||||
|
if incentive_removed == 0:
|
||||||
|
frappe.get_doc('Additional Salary', self.additional_salary).cancel()
|
||||||
|
else:
|
||||||
|
frappe.db.set_value('Additional Salary', self.additional_salary, 'amount', incentive_removed)
|
||||||
|
|
||||||
|
self.db_set('additional_salary', '')
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -10,8 +10,13 @@ frappe.ui.form.on('Retention Bonus', {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
},
|
|
||||||
refresh: function(frm) {
|
|
||||||
|
|
||||||
|
frm.set_query("salary_component", function() {
|
||||||
|
return {
|
||||||
|
filters: {
|
||||||
|
"type": "Earning"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,415 +1,165 @@
|
|||||||
{
|
{
|
||||||
"allow_copy": 0,
|
|
||||||
"allow_guest_to_view": 0,
|
|
||||||
"allow_import": 1,
|
"allow_import": 1,
|
||||||
"allow_rename": 1,
|
"allow_rename": 1,
|
||||||
"autoname": "HR-RTB-.YYYY.-.#####",
|
"autoname": "HR-RTB-.YYYY.-.#####",
|
||||||
"beta": 0,
|
|
||||||
"creation": "2018-05-13 14:59:42.038964",
|
"creation": "2018-05-13 14:59:42.038964",
|
||||||
"custom": 0,
|
|
||||||
"docstatus": 0,
|
|
||||||
"doctype": "DocType",
|
"doctype": "DocType",
|
||||||
"document_type": "",
|
|
||||||
"editable_grid": 1,
|
"editable_grid": 1,
|
||||||
"engine": "InnoDB",
|
"engine": "InnoDB",
|
||||||
|
"field_order": [
|
||||||
|
"company",
|
||||||
|
"employee",
|
||||||
|
"bonus_payment_date",
|
||||||
|
"bonus_amount",
|
||||||
|
"salary_component",
|
||||||
|
"amended_from",
|
||||||
|
"column_break_6",
|
||||||
|
"employee_name",
|
||||||
|
"department",
|
||||||
|
"date_of_joining",
|
||||||
|
"additional_salary"
|
||||||
|
],
|
||||||
"fields": [
|
"fields": [
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_in_quick_entry": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "company",
|
"fieldname": "company",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"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": "Company",
|
"label": "Company",
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"options": "Company",
|
"options": "Company",
|
||||||
"permlevel": 0,
|
"reqd": 1
|
||||||
"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,
|
|
||||||
"fieldname": "employee",
|
"fieldname": "employee",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Employee",
|
"label": "Employee",
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"options": "Employee",
|
"options": "Employee",
|
||||||
"permlevel": 0,
|
"reqd": 1
|
||||||
"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,
|
|
||||||
"fieldname": "bonus_payment_date",
|
"fieldname": "bonus_payment_date",
|
||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"hidden": 0,
|
|
||||||
"ignore_user_permissions": 0,
|
|
||||||
"ignore_xss_filter": 0,
|
|
||||||
"in_filter": 0,
|
|
||||||
"in_global_search": 0,
|
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"in_standard_filter": 0,
|
|
||||||
"label": "Bonus Payment Date",
|
"label": "Bonus Payment Date",
|
||||||
"length": 0,
|
"reqd": 1
|
||||||
"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
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"allow_bulk_edit": 0,
|
|
||||||
"allow_in_quick_entry": 0,
|
|
||||||
"allow_on_submit": 0,
|
|
||||||
"bold": 0,
|
|
||||||
"collapsible": 0,
|
|
||||||
"columns": 0,
|
|
||||||
"fieldname": "bonus_amount",
|
"fieldname": "bonus_amount",
|
||||||
"fieldtype": "Currency",
|
"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": "Bonus Amount",
|
"label": "Bonus Amount",
|
||||||
"length": 0,
|
"reqd": 1
|
||||||
"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": "amended_from",
|
"fieldname": "amended_from",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"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": "Amended From",
|
"label": "Amended From",
|
||||||
"length": 0,
|
|
||||||
"no_copy": 1,
|
"no_copy": 1,
|
||||||
"options": "Retention Bonus",
|
"options": "Retention Bonus",
|
||||||
"permlevel": 0,
|
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
"print_hide_if_no_value": 0,
|
"read_only": 1
|
||||||
"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,
|
|
||||||
"fieldname": "column_break_6",
|
"fieldname": "column_break_6",
|
||||||
"fieldtype": "Column Break",
|
"fieldtype": "Column Break"
|
||||||
"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,
|
|
||||||
"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,
|
|
||||||
"fetch_from": "employee.employee_name",
|
"fetch_from": "employee.employee_name",
|
||||||
"fieldname": "employee_name",
|
"fieldname": "employee_name",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"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": "Employee Name",
|
"label": "Employee Name",
|
||||||
"length": 0,
|
"read_only": 1
|
||||||
"no_copy": 0,
|
|
||||||
"options": "",
|
|
||||||
"permlevel": 0,
|
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"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": "employee.department",
|
"fetch_from": "employee.department",
|
||||||
"fieldname": "department",
|
"fieldname": "department",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
"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": "Department",
|
"label": "Department",
|
||||||
"length": 0,
|
|
||||||
"no_copy": 0,
|
|
||||||
"options": "Department",
|
"options": "Department",
|
||||||
"permlevel": 0,
|
"read_only": 1
|
||||||
"precision": "",
|
|
||||||
"print_hide": 0,
|
|
||||||
"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": "employee.date_of_joining",
|
"fetch_from": "employee.date_of_joining",
|
||||||
"fieldname": "date_of_joining",
|
"fieldname": "date_of_joining",
|
||||||
"fieldtype": "Data",
|
"fieldtype": "Data",
|
||||||
"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": "Date of Joining",
|
"label": "Date of Joining",
|
||||||
"length": 0,
|
"read_only": 1
|
||||||
"no_copy": 0,
|
},
|
||||||
"options": "",
|
{
|
||||||
"permlevel": 0,
|
"fieldname": "additional_salary",
|
||||||
"precision": "",
|
"fieldtype": "Link",
|
||||||
"print_hide": 0,
|
"label": "Additional Salary",
|
||||||
"print_hide_if_no_value": 0,
|
"no_copy": 1,
|
||||||
"read_only": 1,
|
"options": "Additional Salary",
|
||||||
"remember_last_selected_value": 0,
|
"read_only": 1
|
||||||
"report_hide": 0,
|
},
|
||||||
"reqd": 0,
|
{
|
||||||
"search_index": 0,
|
"fieldname": "salary_component",
|
||||||
"set_only_once": 0,
|
"fieldtype": "Link",
|
||||||
"translatable": 0,
|
"label": "Salary Component",
|
||||||
"unique": 0
|
"options": "Salary Component",
|
||||||
|
"reqd": 1
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"has_web_view": 0,
|
|
||||||
"hide_heading": 0,
|
|
||||||
"hide_toolbar": 0,
|
|
||||||
"idx": 0,
|
|
||||||
"image_view": 0,
|
|
||||||
"in_create": 0,
|
|
||||||
"is_submittable": 1,
|
"is_submittable": 1,
|
||||||
"issingle": 0,
|
"modified": "2019-09-03 16:47:24.210422",
|
||||||
"istable": 0,
|
|
||||||
"max_attachments": 0,
|
|
||||||
"modified": "2018-08-21 16:15:38.710684",
|
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "HR",
|
"module": "HR",
|
||||||
"name": "Retention Bonus",
|
"name": "Retention Bonus",
|
||||||
"name_case": "",
|
|
||||||
"owner": "Administrator",
|
"owner": "Administrator",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
{
|
{
|
||||||
"amend": 0,
|
|
||||||
"cancel": 1,
|
"cancel": 1,
|
||||||
"create": 1,
|
"create": 1,
|
||||||
"delete": 1,
|
"delete": 1,
|
||||||
"email": 1,
|
"email": 1,
|
||||||
"export": 1,
|
"export": 1,
|
||||||
"if_owner": 0,
|
|
||||||
"import": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
"print": 1,
|
||||||
"read": 1,
|
"read": 1,
|
||||||
"report": 1,
|
"report": 1,
|
||||||
"role": "System Manager",
|
"role": "System Manager",
|
||||||
"set_user_permissions": 0,
|
|
||||||
"share": 1,
|
"share": 1,
|
||||||
"submit": 1,
|
"submit": 1,
|
||||||
"write": 1
|
"write": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"amend": 0,
|
|
||||||
"cancel": 1,
|
"cancel": 1,
|
||||||
"create": 1,
|
"create": 1,
|
||||||
"delete": 1,
|
"delete": 1,
|
||||||
"email": 1,
|
"email": 1,
|
||||||
"export": 1,
|
"export": 1,
|
||||||
"if_owner": 0,
|
|
||||||
"import": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
"print": 1,
|
||||||
"read": 1,
|
"read": 1,
|
||||||
"report": 1,
|
"report": 1,
|
||||||
"role": "HR Manager",
|
"role": "HR Manager",
|
||||||
"set_user_permissions": 0,
|
|
||||||
"share": 1,
|
"share": 1,
|
||||||
"submit": 1,
|
"submit": 1,
|
||||||
"write": 1
|
"write": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"amend": 0,
|
|
||||||
"cancel": 1,
|
"cancel": 1,
|
||||||
"create": 1,
|
"create": 1,
|
||||||
"delete": 1,
|
"delete": 1,
|
||||||
"email": 1,
|
"email": 1,
|
||||||
"export": 1,
|
"export": 1,
|
||||||
"if_owner": 0,
|
|
||||||
"import": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
"print": 1,
|
||||||
"read": 1,
|
"read": 1,
|
||||||
"report": 1,
|
"report": 1,
|
||||||
"role": "HR User",
|
"role": "HR User",
|
||||||
"set_user_permissions": 0,
|
|
||||||
"share": 1,
|
"share": 1,
|
||||||
"submit": 1,
|
"submit": 1,
|
||||||
"write": 1
|
"write": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"amend": 0,
|
|
||||||
"cancel": 0,
|
|
||||||
"create": 0,
|
|
||||||
"delete": 0,
|
|
||||||
"email": 1,
|
"email": 1,
|
||||||
"export": 1,
|
"export": 1,
|
||||||
"if_owner": 0,
|
|
||||||
"import": 0,
|
|
||||||
"permlevel": 0,
|
|
||||||
"print": 1,
|
"print": 1,
|
||||||
"read": 1,
|
"read": 1,
|
||||||
"report": 1,
|
"report": 1,
|
||||||
"role": "Employee",
|
"role": "Employee",
|
||||||
"set_user_permissions": 0,
|
"share": 1
|
||||||
"share": 1,
|
|
||||||
"submit": 0,
|
|
||||||
"write": 0
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"quick_entry": 1,
|
"quick_entry": 1,
|
||||||
"read_only": 0,
|
|
||||||
"read_only_onload": 0,
|
|
||||||
"show_name_in_global_search": 0,
|
|
||||||
"sort_field": "modified",
|
"sort_field": "modified",
|
||||||
"sort_order": "DESC",
|
"sort_order": "DESC",
|
||||||
"track_changes": 1,
|
"track_changes": 1
|
||||||
"track_seen": 0,
|
|
||||||
"track_views": 0
|
|
||||||
}
|
}
|
||||||
@ -10,7 +10,42 @@ from frappe.utils import getdate
|
|||||||
|
|
||||||
class RetentionBonus(Document):
|
class RetentionBonus(Document):
|
||||||
def validate(self):
|
def validate(self):
|
||||||
if frappe.get_value("Employee", self.employee, "status") == "Left":
|
if frappe.get_value('Employee', self.employee, 'status') == 'Left':
|
||||||
frappe.throw(_("Cannot create Retention Bonus for left Employees"))
|
frappe.throw(_('Cannot create Retention Bonus for left Employees'))
|
||||||
if getdate(self.bonus_payment_date) < getdate():
|
if getdate(self.bonus_payment_date) < getdate():
|
||||||
frappe.throw(_("Bonus Payment Date cannot be a past date"))
|
frappe.throw(_('Bonus Payment Date cannot be a past date'))
|
||||||
|
|
||||||
|
def on_submit(self):
|
||||||
|
company = frappe.db.get_value('Employee', self.employee, 'company')
|
||||||
|
additional_salary = frappe.db.exists('Additional Salary', {
|
||||||
|
'employee': self.employee,
|
||||||
|
'salary_component': self.salary_component,
|
||||||
|
'payroll_date': self.bonus_payment_date,
|
||||||
|
'company': company,
|
||||||
|
'docstatus': 1
|
||||||
|
})
|
||||||
|
|
||||||
|
if not additional_salary:
|
||||||
|
additional_salary = frappe.new_doc('Additional Salary')
|
||||||
|
additional_salary.employee = self.employee
|
||||||
|
additional_salary.salary_component = self.salary_component
|
||||||
|
additional_salary.amount = self.bonus_amount
|
||||||
|
additional_salary.payroll_date = self.bonus_payment_date
|
||||||
|
additional_salary.company = company
|
||||||
|
additional_salary.submit()
|
||||||
|
self.db_set('additional_salary', additional_salary.name)
|
||||||
|
|
||||||
|
else:
|
||||||
|
bonus_added = frappe.db.get_value('Additional Salary', additional_salary, 'amount') + self.bonus_amount
|
||||||
|
frappe.db.set_value('Additional Salary', additional_salary, 'amount', bonus_added)
|
||||||
|
self.db_set('additional_salary', additional_salary)
|
||||||
|
|
||||||
|
def on_cancel(self):
|
||||||
|
if self.additional_salary:
|
||||||
|
bonus_removed = frappe.db.get_value('Additional Salary', self.additional_salary, 'amount') - self.bonus_amount
|
||||||
|
if bonus_removed == 0:
|
||||||
|
frappe.get_doc('Additional Salary', self.additional_salary).cancel()
|
||||||
|
else:
|
||||||
|
frappe.db.set_value('Additional Salary', self.additional_salary, 'amount', bonus_removed)
|
||||||
|
|
||||||
|
self.db_set('additional_salary', '')
|
||||||
@ -99,7 +99,7 @@ class ProductionPlan(Document):
|
|||||||
self.get_mr_items()
|
self.get_mr_items()
|
||||||
|
|
||||||
def get_so_items(self):
|
def get_so_items(self):
|
||||||
so_list = [d.sales_order for d in self.sales_orders if d.sales_order]
|
so_list = [d.sales_order for d in self.get("sales_orders", []) if d.sales_order]
|
||||||
if not so_list:
|
if not so_list:
|
||||||
msgprint(_("Please enter Sales Orders in the above table"))
|
msgprint(_("Please enter Sales Orders in the above table"))
|
||||||
return []
|
return []
|
||||||
@ -134,7 +134,7 @@ class ProductionPlan(Document):
|
|||||||
self.calculate_total_planned_qty()
|
self.calculate_total_planned_qty()
|
||||||
|
|
||||||
def get_mr_items(self):
|
def get_mr_items(self):
|
||||||
mr_list = [d.material_request for d in self.material_requests if d.material_request]
|
mr_list = [d.material_request for d in self.get("material_requests", []) if d.material_request]
|
||||||
if not mr_list:
|
if not mr_list:
|
||||||
msgprint(_("Please enter Material Requests in the above table"))
|
msgprint(_("Please enter Material Requests in the above table"))
|
||||||
return []
|
return []
|
||||||
|
|||||||
@ -82,7 +82,7 @@ def get_item_tax_template(item_tax_templates, rename_template_to_untitled, item_
|
|||||||
account_name = " - ".join(parts[:-1])
|
account_name = " - ".join(parts[:-1])
|
||||||
company = frappe.db.get_value("Company", filters={"abbr": parts[-1]})
|
company = frappe.db.get_value("Company", filters={"abbr": parts[-1]})
|
||||||
parent_account = frappe.db.get_value("Account",
|
parent_account = frappe.db.get_value("Account",
|
||||||
filters={"account_type": "Tax", "root_type": "Liability", "is_group": 0}, fieldname="parent_account")
|
filters={"account_type": "Tax", "root_type": "Liability", "is_group": 0, "company": company}, fieldname="parent_account")
|
||||||
|
|
||||||
frappe.get_doc({
|
frappe.get_doc({
|
||||||
"doctype": "Account",
|
"doctype": "Account",
|
||||||
|
|||||||
@ -377,7 +377,7 @@ def get_customer_primary_contact(doctype, txt, searchfield, start, page_len, fil
|
|||||||
return frappe.db.sql("""
|
return frappe.db.sql("""
|
||||||
select `tabContact`.name from `tabContact`, `tabDynamic Link`
|
select `tabContact`.name from `tabContact`, `tabDynamic Link`
|
||||||
where `tabContact`.name = `tabDynamic Link`.parent and `tabDynamic Link`.link_name = %(customer)s
|
where `tabContact`.name = `tabDynamic Link`.parent and `tabDynamic Link`.link_name = %(customer)s
|
||||||
and `tabDynamic Link`.link_doctype = 'Customer' and `tabContact`.is_primary_contact = 1
|
and `tabDynamic Link`.link_doctype = 'Customer'
|
||||||
and `tabContact`.name like %(txt)s
|
and `tabContact`.name like %(txt)s
|
||||||
""", {
|
""", {
|
||||||
'customer': customer,
|
'customer': customer,
|
||||||
@ -389,7 +389,7 @@ def get_customer_primary_address(doctype, txt, searchfield, start, page_len, fil
|
|||||||
return frappe.db.sql("""
|
return frappe.db.sql("""
|
||||||
select `tabAddress`.name from `tabAddress`, `tabDynamic Link`
|
select `tabAddress`.name from `tabAddress`, `tabDynamic Link`
|
||||||
where `tabAddress`.name = `tabDynamic Link`.parent and `tabDynamic Link`.link_name = %(customer)s
|
where `tabAddress`.name = `tabDynamic Link`.parent and `tabDynamic Link`.link_name = %(customer)s
|
||||||
and `tabDynamic Link`.link_doctype = 'Customer' and `tabAddress`.is_primary_address = 1
|
and `tabDynamic Link`.link_doctype = 'Customer'
|
||||||
and `tabAddress`.name like %(txt)s
|
and `tabAddress`.name like %(txt)s
|
||||||
""", {
|
""", {
|
||||||
'customer': customer,
|
'customer': customer,
|
||||||
|
|||||||
@ -336,19 +336,20 @@ def set_price_list_and_rate(quotation, cart_settings):
|
|||||||
|
|
||||||
def _set_price_list(quotation, cart_settings):
|
def _set_price_list(quotation, cart_settings):
|
||||||
"""Set price list based on customer or shopping cart default"""
|
"""Set price list based on customer or shopping cart default"""
|
||||||
if quotation.selling_price_list:
|
from erpnext.accounts.party import get_default_price_list
|
||||||
return
|
|
||||||
|
|
||||||
# check if customer price list exists
|
# check if customer price list exists
|
||||||
selling_price_list = None
|
selling_price_list = None
|
||||||
if quotation.party_name:
|
if quotation.party_name:
|
||||||
from erpnext.accounts.party import get_default_price_list
|
selling_price_list = frappe.db.get_value('Customer', quotation.party_name, 'default_price_list')
|
||||||
selling_price_list = get_default_price_list(frappe.get_doc("Customer", quotation.party_name))
|
|
||||||
|
|
||||||
# else check for territory based price list
|
# else check for territory based price list
|
||||||
if not selling_price_list:
|
if not selling_price_list:
|
||||||
selling_price_list = cart_settings.price_list
|
selling_price_list = cart_settings.price_list
|
||||||
|
|
||||||
|
if not selling_price_list and quotation.party_name:
|
||||||
|
selling_price_list = get_default_price_list(frappe.get_doc("Customer", quotation.party_name))
|
||||||
|
|
||||||
quotation.selling_price_list = selling_price_list
|
quotation.selling_price_list = selling_price_list
|
||||||
|
|
||||||
def set_taxes(quotation, cart_settings):
|
def set_taxes(quotation, cart_settings):
|
||||||
|
|||||||
@ -181,10 +181,7 @@ class update_entries_after(object):
|
|||||||
# rounding as per precision
|
# rounding as per precision
|
||||||
self.stock_value = flt(self.stock_value, self.precision)
|
self.stock_value = flt(self.stock_value, self.precision)
|
||||||
|
|
||||||
if self.prev_stock_value < 0 and self.stock_value >= 0 and sle.voucher_type != 'Stock Reconciliation':
|
stock_value_difference = self.stock_value - self.prev_stock_value
|
||||||
stock_value_difference = sle.actual_qty * self.valuation_rate
|
|
||||||
else:
|
|
||||||
stock_value_difference = self.stock_value - self.prev_stock_value
|
|
||||||
|
|
||||||
self.prev_stock_value = self.stock_value
|
self.prev_stock_value = self.stock_value
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user