diff --git a/.github/workflows/patch.yml b/.github/workflows/patch.yml
index 7c9e0272c9..b96a3d6bbe 100644
--- a/.github/workflows/patch.yml
+++ b/.github/workflows/patch.yml
@@ -66,4 +66,8 @@ jobs:
run: bash ${GITHUB_WORKSPACE}/.github/helper/install.sh
- name: Run Patch Tests
- run: cd ~/frappe-bench/ && wget http://build.erpnext.com/20171108_190013_955977f8_database.sql.gz && bench --site test_site --force restore ~/frappe-bench/20171108_190013_955977f8_database.sql.gz && bench --site test_site migrate
+ run: |
+ cd ~/frappe-bench/
+ wget https://erpnext.com/files/v10-erpnext.sql.gz
+ bench --site test_site --force restore ~/frappe-bench/v10-erpnext.sql.gz
+ bench --site test_site migrate
diff --git a/erpnext/patches/repair_tools/__init__.py b/erpnext/accounts/doctype/advance_taxes_and_charges/__init__.py
similarity index 100%
rename from erpnext/patches/repair_tools/__init__.py
rename to erpnext/accounts/doctype/advance_taxes_and_charges/__init__.py
diff --git a/erpnext/accounts/doctype/advance_taxes_and_charges/advance_taxes_and_charges.json b/erpnext/accounts/doctype/advance_taxes_and_charges/advance_taxes_and_charges.json
new file mode 100644
index 0000000000..4d63499431
--- /dev/null
+++ b/erpnext/accounts/doctype/advance_taxes_and_charges/advance_taxes_and_charges.json
@@ -0,0 +1,197 @@
+{
+ "actions": [],
+ "creation": "2020-09-12 22:26:19.594367",
+ "doctype": "DocType",
+ "document_type": "Setup",
+ "editable_grid": 1,
+ "engine": "InnoDB",
+ "field_order": [
+ "add_deduct_tax",
+ "charge_type",
+ "row_id",
+ "account_head",
+ "col_break_1",
+ "description",
+ "included_in_paid_amount",
+ "accounting_dimensions_section",
+ "cost_center",
+ "dimension_col_break",
+ "section_break_8",
+ "rate",
+ "section_break_9",
+ "currency",
+ "tax_amount",
+ "total",
+ "allocated_amount",
+ "column_break_13",
+ "base_tax_amount",
+ "base_total",
+ "base_allocated_amount"
+ ],
+ "fields": [
+ {
+ "columns": 2,
+ "fieldname": "charge_type",
+ "fieldtype": "Select",
+ "in_list_view": 1,
+ "label": "Type",
+ "oldfieldname": "charge_type",
+ "oldfieldtype": "Select",
+ "options": "\nActual\nOn Paid Amount\nOn Previous Row Amount\nOn Previous Row Total",
+ "reqd": 1
+ },
+ {
+ "depends_on": "eval:[\"On Previous Row Amount\", \"On Previous Row Total\"].indexOf(doc.charge_type)!==-1",
+ "fieldname": "row_id",
+ "fieldtype": "Data",
+ "label": "Reference Row #",
+ "oldfieldname": "row_id",
+ "oldfieldtype": "Data"
+ },
+ {
+ "columns": 2,
+ "fieldname": "account_head",
+ "fieldtype": "Link",
+ "in_list_view": 1,
+ "label": "Account Head",
+ "oldfieldname": "account_head",
+ "oldfieldtype": "Link",
+ "options": "Account",
+ "reqd": 1,
+ "search_index": 1
+ },
+ {
+ "fieldname": "col_break_1",
+ "fieldtype": "Column Break",
+ "width": "50%"
+ },
+ {
+ "fieldname": "description",
+ "fieldtype": "Small Text",
+ "label": "Description",
+ "oldfieldname": "description",
+ "oldfieldtype": "Small Text",
+ "print_width": "300px",
+ "reqd": 1,
+ "width": "300px"
+ },
+ {
+ "fieldname": "accounting_dimensions_section",
+ "fieldtype": "Section Break",
+ "label": "Accounting Dimensions"
+ },
+ {
+ "default": ":Company",
+ "fieldname": "cost_center",
+ "fieldtype": "Link",
+ "label": "Cost Center",
+ "oldfieldname": "cost_center_other_charges",
+ "oldfieldtype": "Link",
+ "options": "Cost Center"
+ },
+ {
+ "fieldname": "dimension_col_break",
+ "fieldtype": "Column Break"
+ },
+ {
+ "fieldname": "section_break_8",
+ "fieldtype": "Section Break"
+ },
+ {
+ "columns": 2,
+ "fieldname": "rate",
+ "fieldtype": "Float",
+ "in_list_view": 1,
+ "label": "Rate",
+ "oldfieldname": "rate",
+ "oldfieldtype": "Currency"
+ },
+ {
+ "fieldname": "section_break_9",
+ "fieldtype": "Section Break"
+ },
+ {
+ "columns": 2,
+ "fieldname": "tax_amount",
+ "fieldtype": "Currency",
+ "in_list_view": 1,
+ "label": "Amount",
+ "options": "currency"
+ },
+ {
+ "columns": 2,
+ "fieldname": "total",
+ "fieldtype": "Currency",
+ "in_list_view": 1,
+ "label": "Total",
+ "options": "currency",
+ "read_only": 1
+ },
+ {
+ "fieldname": "column_break_13",
+ "fieldtype": "Column Break"
+ },
+ {
+ "fieldname": "base_tax_amount",
+ "fieldtype": "Currency",
+ "label": "Amount (Company Currency)",
+ "oldfieldname": "tax_amount",
+ "oldfieldtype": "Currency",
+ "options": "Company:company:default_currency",
+ "read_only": 1
+ },
+ {
+ "fieldname": "base_total",
+ "fieldtype": "Currency",
+ "label": "Total (Company Currency)",
+ "oldfieldname": "total",
+ "oldfieldtype": "Currency",
+ "options": "Company:company:default_currency",
+ "read_only": 1
+ },
+ {
+ "fieldname": "add_deduct_tax",
+ "fieldtype": "Select",
+ "label": "Add Or Deduct",
+ "options": "Add\nDeduct",
+ "reqd": 1
+ },
+ {
+ "default": "0",
+ "fieldname": "included_in_paid_amount",
+ "fieldtype": "Check",
+ "label": "Considered In Paid Amount"
+ },
+ {
+ "fieldname": "allocated_amount",
+ "fieldtype": "Currency",
+ "label": "Allocated Amount",
+ "options": "currency"
+ },
+ {
+ "fieldname": "base_allocated_amount",
+ "fieldtype": "Currency",
+ "label": "Allocated Amount (Company Currency)",
+ "options": "Company:company:default_currency"
+ },
+ {
+ "fetch_from": "account_head.account_currency",
+ "fieldname": "currency",
+ "fieldtype": "Link",
+ "label": "Account Currency",
+ "options": "Currency",
+ "read_only": 1
+ }
+ ],
+ "index_web_pages_for_search": 1,
+ "istable": 1,
+ "links": [],
+ "modified": "2021-06-09 11:46:58.373170",
+ "modified_by": "Administrator",
+ "module": "Accounts",
+ "name": "Advance Taxes and Charges",
+ "owner": "Administrator",
+ "permissions": [],
+ "sort_field": "modified",
+ "sort_order": "ASC"
+}
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/advance_taxes_and_charges/advance_taxes_and_charges.py b/erpnext/accounts/doctype/advance_taxes_and_charges/advance_taxes_and_charges.py
new file mode 100644
index 0000000000..597d2ccc62
--- /dev/null
+++ b/erpnext/accounts/doctype/advance_taxes_and_charges/advance_taxes_and_charges.py
@@ -0,0 +1,10 @@
+# -*- coding: utf-8 -*-
+# Copyright (c) 2020, 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
+
+class AdvanceTaxesandCharges(Document):
+ pass
diff --git a/erpnext/accounts/doctype/c_form/c_form.py b/erpnext/accounts/doctype/c_form/c_form.py
index fd86ed4c90..cfe28f3ff9 100644
--- a/erpnext/accounts/doctype/c_form/c_form.py
+++ b/erpnext/accounts/doctype/c_form/c_form.py
@@ -54,7 +54,7 @@ class CForm(Document):
frappe.throw(_("Please enter atleast 1 invoice in the table"))
def set_total_invoiced_amount(self):
- total = sum([flt(d.grand_total) for d in self.get('invoices')])
+ total = sum(flt(d.grand_total) for d in self.get('invoices'))
frappe.db.set(self, 'total_invoiced_amount', total)
@frappe.whitelist()
diff --git a/erpnext/accounts/doctype/coupon_code/coupon_code.py b/erpnext/accounts/doctype/coupon_code/coupon_code.py
index 7829c9320d..55c119315e 100644
--- a/erpnext/accounts/doctype/coupon_code/coupon_code.py
+++ b/erpnext/accounts/doctype/coupon_code/coupon_code.py
@@ -14,7 +14,7 @@ class CouponCode(Document):
if not self.coupon_code:
if self.coupon_type == "Promotional":
- self.coupon_code =''.join([i for i in self.coupon_name if not i.isdigit()])[0:8].upper()
+ self.coupon_code =''.join(i for i in self.coupon_name if not i.isdigit())[0:8].upper()
elif self.coupon_type == "Gift Card":
self.coupon_code = frappe.generate_hash()[:10].upper()
diff --git a/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.py b/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.py
index 95d2ee56d9..b73d8bfbb1 100644
--- a/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.py
+++ b/erpnext/accounts/doctype/invoice_discounting/invoice_discounting.py
@@ -42,7 +42,7 @@ class InvoiceDiscounting(AccountsController):
record.idx, frappe.bold(actual_outstanding), frappe.bold(record.sales_invoice)))
def calculate_total_amount(self):
- self.total_amount = sum([flt(d.outstanding_amount) for d in self.invoices])
+ self.total_amount = sum(flt(d.outstanding_amount) for d in self.invoices)
def on_submit(self):
self.update_sales_invoice()
diff --git a/erpnext/accounts/doctype/journal_entry/journal_entry.py b/erpnext/accounts/doctype/journal_entry/journal_entry.py
index ed1bd28223..937597bc55 100644
--- a/erpnext/accounts/doctype/journal_entry/journal_entry.py
+++ b/erpnext/accounts/doctype/journal_entry/journal_entry.py
@@ -196,8 +196,8 @@ class JournalEntry(AccountsController):
frappe.throw(_("Row {0}: Party Type and Party is required for Receivable / Payable account {1}").format(d.idx, d.account))
def check_credit_limit(self):
- customers = list(set([d.party for d in self.get("accounts")
- if d.party_type=="Customer" and d.party and flt(d.debit) > 0]))
+ customers = list(set(d.party for d in self.get("accounts")
+ if d.party_type=="Customer" and d.party and flt(d.debit) > 0))
if customers:
from erpnext.selling.doctype.customer.customer import check_credit_limit
for customer in customers:
diff --git a/erpnext/accounts/doctype/monthly_distribution/monthly_distribution.py b/erpnext/accounts/doctype/monthly_distribution/monthly_distribution.py
index 88667d7207..bff6422732 100644
--- a/erpnext/accounts/doctype/monthly_distribution/monthly_distribution.py
+++ b/erpnext/accounts/doctype/monthly_distribution/monthly_distribution.py
@@ -21,7 +21,7 @@ class MonthlyDistribution(Document):
idx += 1
def validate(self):
- total = sum([flt(d.percentage_allocation) for d in self.get("percentages")])
+ total = sum(flt(d.percentage_allocation) for d in self.get("percentages"))
if flt(total, 2) != 100.0:
frappe.throw(_("Percentage Allocation should be equal to 100%") + \
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.js b/erpnext/accounts/doctype/payment_entry/payment_entry.js
index b80e8ada38..939f3546ff 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.js
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.js
@@ -3,6 +3,8 @@
{% include "erpnext/public/js/controllers/accounts.js" %}
frappe.provide("erpnext.accounts.dimensions");
+cur_frm.cscript.tax_table = "Advance Taxes and Charges";
+
frappe.ui.form.on('Payment Entry', {
onload: function(frm) {
if(frm.doc.__islocal) {
@@ -91,6 +93,16 @@ frappe.ui.form.on('Payment Entry', {
}
});
+ frm.set_query("advance_tax_account", function() {
+ return {
+ filters: {
+ "company": frm.doc.company,
+ "root_type": ["in", ["Asset", "Liability"]],
+ "is_group": 0
+ }
+ }
+ });
+
frm.set_query("reference_doctype", "references", function() {
if (frm.doc.party_type == "Customer") {
var doctypes = ["Sales Order", "Sales Invoice", "Journal Entry", "Dunning"];
@@ -182,6 +194,8 @@ frappe.ui.form.on('Payment Entry', {
frm.doc.paid_from_account_currency != frm.doc.paid_to_account_currency));
frm.toggle_display("base_paid_amount", frm.doc.paid_from_account_currency != company_currency);
+ frm.toggle_display("base_total_taxes_and_charges", frm.doc.total_taxes_and_charges &&
+ (frm.doc.paid_from_account_currency != company_currency));
frm.toggle_display("base_received_amount", (
frm.doc.paid_to_account_currency != company_currency
@@ -216,7 +230,7 @@ frappe.ui.form.on('Payment Entry', {
var company_currency = frm.doc.company? frappe.get_doc(":Company", frm.doc.company).default_currency: "";
frm.set_currency_labels(["base_paid_amount", "base_received_amount", "base_total_allocated_amount",
- "difference_amount"], company_currency);
+ "difference_amount", "base_paid_amount_after_tax", "base_received_amount_after_tax"], company_currency);
frm.set_currency_labels(["paid_amount"], frm.doc.paid_from_account_currency);
frm.set_currency_labels(["received_amount"], frm.doc.paid_to_account_currency);
@@ -224,11 +238,13 @@ frappe.ui.form.on('Payment Entry', {
var party_account_currency = frm.doc.payment_type=="Receive" ?
frm.doc.paid_from_account_currency : frm.doc.paid_to_account_currency;
- frm.set_currency_labels(["total_allocated_amount", "unallocated_amount"], party_account_currency);
+ frm.set_currency_labels(["total_allocated_amount", "unallocated_amount",
+ "total_taxes_and_charges"], party_account_currency);
var currency_field = (frm.doc.payment_type=="Receive") ? "paid_from_account_currency" : "paid_to_account_currency"
frm.set_df_property("total_allocated_amount", "options", currency_field);
frm.set_df_property("unallocated_amount", "options", currency_field);
+ frm.set_df_property("total_taxes_and_charges", "options", currency_field);
frm.set_df_property("party_balance", "options", currency_field);
frm.set_currency_labels(["total_amount", "outstanding_amount", "allocated_amount"],
@@ -364,6 +380,16 @@ frappe.ui.form.on('Payment Entry', {
}
},
+ apply_tax_withholding_amount: function(frm) {
+ if (!frm.doc.apply_tax_withholding_amount) {
+ frm.set_value("tax_withholding_category", '');
+ } else {
+ frappe.db.get_value('Supplier', frm.doc.party, 'tax_withholding_category', (values) => {
+ frm.set_value("tax_withholding_category", values.tax_withholding_category);
+ });
+ }
+ },
+
paid_from: function(frm) {
if(frm.set_party_account_based_on_party) return;
@@ -843,12 +869,12 @@ frappe.ui.form.on('Payment Entry', {
if(frm.doc.payment_type == "Receive"
&& frm.doc.base_total_allocated_amount < frm.doc.base_received_amount + total_deductions
&& frm.doc.total_allocated_amount < frm.doc.paid_amount + (total_deductions / frm.doc.source_exchange_rate)) {
- unallocated_amount = (frm.doc.base_received_amount + total_deductions
- - frm.doc.base_total_allocated_amount) / frm.doc.source_exchange_rate;
+ unallocated_amount = (frm.doc.base_received_amount + total_deductions + frm.doc.base_total_taxes_and_charges
+ + frm.doc.base_total_allocated_amount) / frm.doc.source_exchange_rate;
} else if (frm.doc.payment_type == "Pay"
&& frm.doc.base_total_allocated_amount < frm.doc.base_paid_amount - total_deductions
&& frm.doc.total_allocated_amount < frm.doc.received_amount + (total_deductions / frm.doc.target_exchange_rate)) {
- unallocated_amount = (frm.doc.base_paid_amount - (total_deductions
+ unallocated_amount = (frm.doc.base_paid_amount + frm.doc.base_total_taxes_and_charges - (total_deductions
+ frm.doc.base_total_allocated_amount)) / frm.doc.target_exchange_rate;
}
}
@@ -874,7 +900,8 @@ frappe.ui.form.on('Payment Entry', {
var total_deductions = frappe.utils.sum($.map(frm.doc.deductions || [],
function(d) { return flt(d.amount) }));
- frm.set_value("difference_amount", difference_amount - total_deductions);
+ frm.set_value("difference_amount", difference_amount - total_deductions +
+ frm.doc.base_total_taxes_and_charges);
frm.events.hide_unhide_fields(frm);
},
@@ -1002,7 +1029,203 @@ frappe.ui.form.on('Payment Entry', {
}
});
}
- }
+ },
+
+ sales_taxes_and_charges_template: function(frm) {
+ frm.trigger('fetch_taxes_from_template');
+ },
+
+ purchase_taxes_and_charges_template: function(frm) {
+ frm.trigger('fetch_taxes_from_template');
+ },
+
+ fetch_taxes_from_template: function(frm) {
+ let master_doctype = '';
+ let taxes_and_charges = '';
+
+ if (frm.doc.party_type == 'Supplier') {
+ master_doctype = 'Purchase Taxes and Charges Template';
+ taxes_and_charges = frm.doc.purchase_taxes_and_charges_template;
+ } else if (frm.doc.party_type == 'Customer') {
+ master_doctype = 'Sales Taxes and Charges Template';
+ taxes_and_charges = frm.doc.sales_taxes_and_charges_template;
+ }
+
+ if (!taxes_and_charges) {
+ return;
+ }
+
+ frappe.call({
+ method: "erpnext.controllers.accounts_controller.get_taxes_and_charges",
+ args: {
+ "master_doctype": master_doctype,
+ "master_name": taxes_and_charges
+ },
+ callback: function(r) {
+ if(!r.exc && r.message) {
+ // set taxes table
+ if(r.message) {
+ for (let tax of r.message) {
+ if (tax.charge_type === 'On Net Total') {
+ tax.charge_type = 'On Paid Amount';
+ }
+ me.frm.add_child("taxes", tax);
+ }
+ frm.events.apply_taxes(frm);
+ frm.events.set_unallocated_amount(frm);
+ }
+ }
+ }
+ });
+ },
+
+ apply_taxes: function(frm) {
+ frm.events.initialize_taxes(frm);
+ frm.events.determine_exclusive_rate(frm);
+ frm.events.calculate_taxes(frm);
+ },
+
+ initialize_taxes: function(frm) {
+ $.each(frm.doc["taxes"] || [], function(i, tax) {
+ tax.item_wise_tax_detail = {};
+ let tax_fields = ["total", "tax_fraction_for_current_item",
+ "grand_total_fraction_for_current_item"];
+
+ if (cstr(tax.charge_type) != "Actual") {
+ tax_fields.push("tax_amount");
+ }
+
+ $.each(tax_fields, function(i, fieldname) { tax[fieldname] = 0.0; });
+
+ frm.doc.paid_amount_after_tax = frm.doc.paid_amount;
+ });
+ },
+
+ determine_exclusive_rate: function(frm) {
+ let has_inclusive_tax = false;
+ $.each(frm.doc["taxes"] || [], function(i, row) {
+ if(cint(row.included_in_paid_amount)) has_inclusive_tax = true;
+ });
+ if(has_inclusive_tax==false) return;
+
+ let cumulated_tax_fraction = 0.0;
+ $.each(frm.doc["taxes"] || [], function(i, tax) {
+ let current_tax_fraction = frm.events.get_current_tax_fraction(frm, tax);
+ tax.tax_fraction_for_current_item = current_tax_fraction[0];
+
+ if(i==0) {
+ tax.grand_total_fraction_for_current_item = 1 + tax.tax_fraction_for_current_item;
+ } else {
+ tax.grand_total_fraction_for_current_item =
+ me.frm.doc["taxes"][i-1].grand_total_fraction_for_current_item +
+ tax.tax_fraction_for_current_item;
+ }
+
+ cumulated_tax_fraction += tax.tax_fraction_for_current_item;
+ frm.doc.paid_amount_after_tax = flt(frm.doc.paid_amount/(1+cumulated_tax_fraction))
+ });
+ },
+
+ get_current_tax_fraction: function(frm, tax) {
+ let current_tax_fraction = 0.0;
+
+ if(cint(tax.included_in_paid_amount)) {
+ let tax_rate = tax.rate;
+
+ if (tax.charge_type == "Actual") {
+ current_tax_fraction = tax.tax_amount/(frm.doc.paid_amount_after_tax + frm.doc.tax_amount);
+ } else if(tax.charge_type == "On Paid Amount") {
+ current_tax_fraction = (tax_rate / 100.0);
+ } else if(tax.charge_type == "On Previous Row Amount") {
+ current_tax_fraction = (tax_rate / 100.0) *
+ frm.doc["taxes"][cint(tax.row_id) - 1].tax_fraction_for_current_item;
+ } else if(tax.charge_type == "On Previous Row Total") {
+ current_tax_fraction = (tax_rate / 100.0) *
+ frm.doc["taxes"][cint(tax.row_id) - 1].grand_total_fraction_for_current_item;
+ }
+ }
+
+ if(tax.add_deduct_tax && tax.add_deduct_tax == "Deduct") {
+ current_tax_fraction *= -1;
+ inclusive_tax_amount_per_qty *= -1;
+ }
+ return current_tax_fraction;
+ },
+
+
+ calculate_taxes: function(frm) {
+ frm.doc.total_taxes_and_charges = 0.0;
+ frm.doc.base_total_taxes_and_charges = 0.0;
+
+ let actual_tax_dict = {};
+
+ // maintain actual tax rate based on idx
+ $.each(frm.doc["taxes"] || [], function(i, tax) {
+ if (tax.charge_type == "Actual") {
+ actual_tax_dict[tax.idx] = flt(tax.tax_amount, precision("tax_amount", tax));
+ }
+ });
+
+ $.each(me.frm.doc["taxes"] || [], function(i, tax) {
+ let current_tax_amount = frm.events.get_current_tax_amount(frm, tax);
+
+ // Adjust divisional loss to the last item
+ if (tax.charge_type == "Actual") {
+ actual_tax_dict[tax.idx] -= current_tax_amount;
+ if (i == frm.doc["taxes"].length - 1) {
+ current_tax_amount += actual_tax_dict[tax.idx];
+ }
+ }
+
+ tax.tax_amount = current_tax_amount;
+ tax.base_tax_amount = tax.tax_amount * frm.doc.source_exchange_rate;
+ current_tax_amount *= (tax.add_deduct_tax == "Deduct") ? -1.0 : 1.0;
+
+ if(i==0) {
+ tax.total = flt(frm.doc.paid_amount_after_tax + current_tax_amount, precision("total", tax));
+ } else {
+ tax.total = flt(frm.doc["taxes"][i-1].total + current_tax_amount, precision("total", tax));
+ }
+
+ tax.base_total = tax.total * frm.doc.source_exchange_rate;
+ frm.doc.total_taxes_and_charges += current_tax_amount;
+ frm.doc.base_total_taxes_and_charges += current_tax_amount * frm.doc.source_exchange_rate;
+
+ frm.refresh_field('taxes');
+ frm.refresh_field('total_taxes_and_charges');
+ frm.refresh_field('base_total_taxes_and_charges');
+ });
+ },
+
+ get_current_tax_amount: function(frm, tax) {
+ let tax_rate = tax.rate;
+ let current_tax_amount = 0.0;
+
+ // To set row_id by default as previous row.
+ if(["On Previous Row Amount", "On Previous Row Total"].includes(tax.charge_type)) {
+ if (tax.idx === 1) {
+ frappe.throw(
+ __("Cannot select charge type as 'On Previous Row Amount' or 'On Previous Row Total' for first row"));
+ }
+ if (!tax.row_id) {
+ tax.row_id = tax.idx - 1;
+ }
+ }
+ if(tax.charge_type == "Actual") {
+ current_tax_amount = flt(tax.tax_amount, precision("tax_amount", tax))
+ } else if(tax.charge_type == "On Paid Amount") {
+ current_tax_amount = flt((tax_rate / 100.0) * frm.doc.paid_amount_after_tax);
+ } else if(tax.charge_type == "On Previous Row Amount") {
+ current_tax_amount = flt((tax_rate / 100.0) *
+ frm.doc["taxes"][cint(tax.row_id) - 1].tax_amount);
+
+ } else if(tax.charge_type == "On Previous Row Total") {
+ current_tax_amount = flt((tax_rate / 100.0) *
+ frm.doc["taxes"][cint(tax.row_id) - 1].total);
+ }
+
+ return current_tax_amount;
+ },
});
@@ -1049,6 +1272,33 @@ frappe.ui.form.on('Payment Entry Reference', {
}
})
+frappe.ui.form.on('Advance Taxes and Charges', {
+ rate: function(frm) {
+ frm.events.apply_taxes(frm);
+ frm.events.set_unallocated_amount(frm);
+ },
+
+ tax_amount : function(frm) {
+ frm.events.apply_taxes(frm);
+ frm.events.set_unallocated_amount(frm);
+ },
+
+ row_id: function(frm) {
+ frm.events.apply_taxes(frm);
+ frm.events.set_unallocated_amount(frm);
+ },
+
+ taxes_remove: function(frm) {
+ frm.events.apply_taxes(frm);
+ frm.events.set_unallocated_amount(frm);
+ },
+
+ included_in_paid_amount: function(frm) {
+ frm.events.apply_taxes(frm);
+ frm.events.set_unallocated_amount(frm);
+ }
+})
+
frappe.ui.form.on('Payment Entry Deduction', {
amount: function(frm) {
frm.events.set_unallocated_amount(frm);
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.json b/erpnext/accounts/doctype/payment_entry/payment_entry.json
index 328584a61a..54623dd6cd 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.json
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.json
@@ -35,12 +35,16 @@
"paid_to_account_balance",
"payment_amounts_section",
"paid_amount",
+ "paid_amount_after_tax",
"source_exchange_rate",
"base_paid_amount",
+ "base_paid_amount_after_tax",
"column_break_21",
"received_amount",
+ "received_amount_after_tax",
"target_exchange_rate",
"base_received_amount",
+ "base_received_amount_after_tax",
"section_break_14",
"get_outstanding_invoice",
"references",
@@ -52,6 +56,17 @@
"unallocated_amount",
"difference_amount",
"write_off_difference_amount",
+ "taxes_and_charges_section",
+ "purchase_taxes_and_charges_template",
+ "sales_taxes_and_charges_template",
+ "advance_tax_account",
+ "column_break_55",
+ "apply_tax_withholding_amount",
+ "tax_withholding_category",
+ "section_break_56",
+ "taxes",
+ "base_total_taxes_and_charges",
+ "total_taxes_and_charges",
"deductions_or_loss_section",
"deductions",
"transaction_references",
@@ -320,6 +335,7 @@
"reqd": 1
},
{
+ "depends_on": "doc.received_amount",
"fieldname": "base_received_amount",
"fieldtype": "Currency",
"label": "Received Amount (Company Currency)",
@@ -584,12 +600,114 @@
"fieldname": "custom_remarks",
"fieldtype": "Check",
"label": "Custom Remarks"
+ },
+ {
+ "depends_on": "eval:doc.apply_tax_withholding_amount",
+ "fieldname": "tax_withholding_category",
+ "fieldtype": "Link",
+ "label": "Tax Withholding Category",
+ "mandatory_depends_on": "eval:doc.apply_tax_withholding_amount",
+ "options": "Tax Withholding Category"
+ },
+ {
+ "default": "0",
+ "depends_on": "eval:doc.party_type == 'Supplier'",
+ "fieldname": "apply_tax_withholding_amount",
+ "fieldtype": "Check",
+ "label": "Apply Tax Withholding Amount"
+ },
+ {
+ "collapsible": 1,
+ "fieldname": "taxes_and_charges_section",
+ "fieldtype": "Section Break",
+ "label": "Taxes and Charges"
+ },
+ {
+ "depends_on": "eval:doc.party_type == 'Supplier'",
+ "fieldname": "purchase_taxes_and_charges_template",
+ "fieldtype": "Link",
+ "label": "Taxes and Charges Template",
+ "options": "Purchase Taxes and Charges Template"
+ },
+ {
+ "depends_on": "eval: doc.party_type == 'Customer'",
+ "fieldname": "sales_taxes_and_charges_template",
+ "fieldtype": "Link",
+ "label": "Taxes and Charges Template",
+ "options": "Sales Taxes and Charges Template"
+ },
+ {
+ "depends_on": "eval: doc.party_type == 'Supplier' || doc.party_type == 'Customer'",
+ "fieldname": "taxes",
+ "fieldtype": "Table",
+ "label": "Advance Taxes and Charges",
+ "options": "Advance Taxes and Charges"
+ },
+ {
+ "fieldname": "base_total_taxes_and_charges",
+ "fieldtype": "Currency",
+ "label": "Total Taxes and Charges (Company Currency)",
+ "options": "Company:company:default_currency",
+ "read_only": 1
+ },
+ {
+ "fieldname": "total_taxes_and_charges",
+ "fieldtype": "Currency",
+ "label": "Total Taxes and Charges",
+ "read_only": 1
+ },
+ {
+ "fieldname": "paid_amount_after_tax",
+ "fieldtype": "Currency",
+ "hidden": 1,
+ "label": "Paid Amount After Tax",
+ "options": "paid_from_account_currency",
+ "read_only": 1
+ },
+ {
+ "fieldname": "base_paid_amount_after_tax",
+ "fieldtype": "Currency",
+ "label": "Paid Amount After Tax (Company Currency)",
+ "options": "Company:company:default_currency",
+ "read_only": 1
+ },
+ {
+ "fieldname": "column_break_55",
+ "fieldtype": "Column Break"
+ },
+ {
+ "fieldname": "section_break_56",
+ "fieldtype": "Section Break",
+ "hide_border": 1
+ },
+ {
+ "depends_on": "eval:doc.apply_tax_withholding_amount",
+ "description": "Provisional tax account for advance tax. Taxes are parked in this account until payments are allocated to invoices",
+ "fieldname": "advance_tax_account",
+ "fieldtype": "Link",
+ "label": "Advance Tax Account",
+ "mandatory_depends_on": "eval:doc.apply_tax_withholding_amount",
+ "options": "Account"
+ },
+ {
+ "depends_on": "eval:doc.received_amount",
+ "fieldname": "received_amount_after_tax",
+ "fieldtype": "Currency",
+ "label": "Received Amount After Tax",
+ "options": "paid_to_account_currency"
+ },
+ {
+ "depends_on": "doc.received_amount",
+ "fieldname": "base_received_amount_after_tax",
+ "fieldtype": "Currency",
+ "label": "Received Amount After Tax (Company Currency)",
+ "options": "Company:company:default_currency"
}
],
"index_web_pages_for_search": 1,
"is_submittable": 1,
"links": [],
- "modified": "2021-03-08 13:05:16.958866",
+ "modified": "2021-06-09 11:55:04.215050",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Payment Entry",
@@ -633,4 +751,4 @@
"sort_order": "DESC",
"title_field": "title",
"track_changes": 1
-}
+}
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/payment_entry/payment_entry.py b/erpnext/accounts/doctype/payment_entry/payment_entry.py
index e01c651a93..2c6deb3896 100644
--- a/erpnext/accounts/doctype/payment_entry/payment_entry.py
+++ b/erpnext/accounts/doctype/payment_entry/payment_entry.py
@@ -5,7 +5,7 @@
from __future__ import unicode_literals
import frappe, erpnext, json
from frappe import _, scrub, ValidationError
-from frappe.utils import flt, comma_or, nowdate, getdate
+from frappe.utils import flt, comma_or, nowdate, getdate, cint
from erpnext.accounts.utils import get_outstanding_invoices, get_account_currency, get_balance_on
from erpnext.accounts.party import get_party_account
from erpnext.accounts.doctype.journal_entry.journal_entry import get_default_bank_cash_account
@@ -15,6 +15,7 @@ from erpnext.hr.doctype.expense_claim.expense_claim import update_reimbursed_amo
from erpnext.accounts.doctype.bank_account.bank_account import get_party_bank_account, get_bank_account_details
from erpnext.controllers.accounts_controller import AccountsController, get_supplier_block_status
from erpnext.accounts.doctype.invoice_discounting.invoice_discounting import get_party_account_based_on_invoice_discounting
+from erpnext.accounts.doctype.tax_withholding_category.tax_withholding_category import get_party_tax_withholding_details
from six import string_types, iteritems
@@ -52,6 +53,8 @@ class PaymentEntry(AccountsController):
self.set_exchange_rate()
self.validate_mandatory()
self.validate_reference_documents()
+ self.set_tax_withholding()
+ self.apply_taxes()
self.set_amounts()
self.clear_unallocated_reference_document_rows()
self.validate_payment_against_negative_invoice()
@@ -306,11 +309,10 @@ class PaymentEntry(AccountsController):
for k, v in no_oustanding_refs.items():
frappe.msgprint(
_("{} - {} now have {} as they had no outstanding amount left before submitting the Payment Entry.")
- .format(k, frappe.bold(", ".join([d.reference_name for d in v])), frappe.bold("negative outstanding amount"))
+ .format(k, frappe.bold(", ".join(d.reference_name for d in v)), frappe.bold("negative outstanding amount"))
+ "
" + _("If this is undesirable please cancel the corresponding Payment Entry."),
title=_("Warning"), indicator="orange")
-
def validate_journal_entry(self):
for d in self.get("references"):
if d.allocated_amount and d.reference_doctype == "Journal Entry":
@@ -391,12 +393,110 @@ class PaymentEntry(AccountsController):
self.db_set('status', self.status, update_modified = True)
+ def set_tax_withholding(self):
+ if not self.party_type == 'Supplier':
+ return
+
+ if not self.apply_tax_withholding_amount:
+ return
+
+ if not self.advance_tax_account:
+ frappe.throw(_("Advance TDS account is mandatory for advance TDS deduction"))
+
+ reference_doclist = []
+ net_total = self.paid_amount
+ included_in_paid_amount = 0
+
+ if self.get('references'):
+ for doc in self.get('references'):
+ if doc.reference_doctype == 'Purchase Order':
+ reference_doclist.append(doc.reference_name)
+
+ if reference_doclist:
+ order_amount = frappe.db.get_all('Purchase Order', fields=['sum(net_total)'],
+ filters = {'name': ('in', reference_doclist), 'docstatus': 1,
+ 'apply_tds': 1}, as_list=1)
+
+ if order_amount:
+ net_total = order_amount[0][0]
+ included_in_paid_amount = 1
+
+ # Adding args as purchase invoice to get TDS amount
+ args = frappe._dict({
+ 'company': self.company,
+ 'doctype': 'Purchase Invoice',
+ 'supplier': self.party,
+ 'posting_date': self.posting_date,
+ 'net_total': net_total
+ })
+
+ tax_withholding_details = get_party_tax_withholding_details(args, self.tax_withholding_category)
+
+ if not tax_withholding_details:
+ return
+
+ tax_withholding_details.update({
+ 'included_in_paid_amount': included_in_paid_amount,
+ 'cost_center': self.cost_center or erpnext.get_default_cost_center(self.company)
+ })
+
+ accounts = []
+ for d in self.taxes:
+ if d.account_head == tax_withholding_details.get("account_head"):
+
+ # Preserve user updated included in paid amount
+ if d.included_in_paid_amount:
+ tax_withholding_details.update({'included_in_paid_amount': d.included_in_paid_amount})
+
+ d.update(tax_withholding_details)
+ accounts.append(d.account_head)
+
+ if not accounts or tax_withholding_details.get("account_head") not in accounts:
+ self.append("taxes", tax_withholding_details)
+
+ to_remove = [d for d in self.taxes
+ if not d.tax_amount and d.account_head == tax_withholding_details.get("account_head")]
+
+ for d in to_remove:
+ self.remove(d)
+
+ def apply_taxes(self):
+ self.initialize_taxes()
+ self.determine_exclusive_rate()
+ self.calculate_taxes()
+
def set_amounts(self):
+ self.set_received_amount()
self.set_amounts_in_company_currency()
+ self.set_amounts_after_tax()
self.set_total_allocated_amount()
self.set_unallocated_amount()
self.set_difference_amount()
+ def set_received_amount(self):
+ self.base_received_amount = self.base_paid_amount
+
+ def set_amounts_after_tax(self):
+ applicable_tax = 0
+ base_applicable_tax = 0
+ for tax in self.get('taxes'):
+ if not tax.included_in_paid_amount:
+ amount = -1 * tax.tax_amount if tax.add_deduct_tax == 'Deduct' else tax.tax_amount
+ base_amount = -1 * tax.base_tax_amount if tax.add_deduct_tax == 'Deduct' else tax.base_tax_amount
+
+ applicable_tax += amount
+ base_applicable_tax += base_amount
+
+ self.paid_amount_after_tax = flt(flt(self.paid_amount) + flt(applicable_tax),
+ self.precision("paid_amount_after_tax"))
+ self.base_paid_amount_after_tax = flt(flt(self.paid_amount_after_tax) * flt(self.source_exchange_rate),
+ self.precision("base_paid_amount_after_tax"))
+
+ self.received_amount_after_tax = flt(flt(self.received_amount) + flt(applicable_tax),
+ self.precision("paid_amount_after_tax"))
+ self.base_received_amount_after_tax = flt(flt(self.received_amount_after_tax) * flt(self.target_exchange_rate),
+ self.precision("base_paid_amount_after_tax"))
+
def set_amounts_in_company_currency(self):
self.base_paid_amount, self.base_received_amount, self.difference_amount = 0, 0, 0
if self.paid_amount:
@@ -424,17 +524,17 @@ class PaymentEntry(AccountsController):
def set_unallocated_amount(self):
self.unallocated_amount = 0
if self.party:
- total_deductions = sum([flt(d.amount) for d in self.get("deductions")])
+ total_deductions = sum(flt(d.amount) for d in self.get("deductions"))
if self.payment_type == "Receive" \
- and self.base_total_allocated_amount < self.base_received_amount + total_deductions \
- and self.total_allocated_amount < self.paid_amount + (total_deductions / self.source_exchange_rate):
- self.unallocated_amount = (self.base_received_amount + total_deductions -
- self.base_total_allocated_amount) / self.source_exchange_rate
+ and self.base_total_allocated_amount < self.base_received_amount_after_tax + total_deductions \
+ and self.total_allocated_amount < self.paid_amount_after_tax + (total_deductions / self.source_exchange_rate):
+ self.unallocated_amount = (self.received_amount_after_tax + total_deductions -
+ self.base_total_allocated_amount) / self.source_exchange_rate
elif self.payment_type == "Pay" \
- and self.base_total_allocated_amount < (self.base_paid_amount - total_deductions) \
- and self.total_allocated_amount < self.received_amount + (total_deductions / self.target_exchange_rate):
- self.unallocated_amount = (self.base_paid_amount - (total_deductions +
- self.base_total_allocated_amount)) / self.target_exchange_rate
+ and self.base_total_allocated_amount < (self.base_paid_amount_after_tax - total_deductions) \
+ and self.total_allocated_amount < self.received_amount_after_tax + (total_deductions / self.target_exchange_rate):
+ self.unallocated_amount = (self.base_paid_amount_after_tax - (total_deductions +
+ self.base_total_allocated_amount)) / self.target_exchange_rate
def set_difference_amount(self):
base_unallocated_amount = flt(self.unallocated_amount) * (flt(self.source_exchange_rate)
@@ -443,13 +543,13 @@ class PaymentEntry(AccountsController):
base_party_amount = flt(self.base_total_allocated_amount) + flt(base_unallocated_amount)
if self.payment_type == "Receive":
- self.difference_amount = base_party_amount - self.base_received_amount
+ self.difference_amount = base_party_amount - self.base_received_amount_after_tax
elif self.payment_type == "Pay":
- self.difference_amount = self.base_paid_amount - base_party_amount
+ self.difference_amount = self.base_paid_amount_after_tax - base_party_amount
else:
- self.difference_amount = self.base_paid_amount - flt(self.base_received_amount)
+ self.difference_amount = self.base_paid_amount_after_tax - flt(self.base_received_amount_after_tax)
- total_deductions = sum([flt(d.amount) for d in self.get("deductions")])
+ total_deductions = sum(flt(d.amount) for d in self.get("deductions"))
self.difference_amount = flt(self.difference_amount - total_deductions,
self.precision("difference_amount"))
@@ -465,8 +565,8 @@ class PaymentEntry(AccountsController):
if ((self.payment_type=="Pay" and self.party_type=="Customer")
or (self.payment_type=="Receive" and self.party_type=="Supplier")):
- total_negative_outstanding = sum([abs(flt(d.outstanding_amount))
- for d in self.get("references") if flt(d.outstanding_amount) < 0])
+ total_negative_outstanding = sum(abs(flt(d.outstanding_amount))
+ for d in self.get("references") if flt(d.outstanding_amount) < 0)
paid_amount = self.paid_amount if self.payment_type=="Receive" else self.received_amount
additional_charges = sum([flt(d.amount) for d in self.deductions])
@@ -537,6 +637,7 @@ class PaymentEntry(AccountsController):
self.add_party_gl_entries(gl_entries)
self.add_bank_gl_entries(gl_entries)
self.add_deductions_gl_entries(gl_entries)
+ self.add_tax_gl_entries(gl_entries)
make_gl_entries(gl_entries, cancel=cancel, adv_adj=adv_adj)
@@ -576,7 +677,7 @@ class PaymentEntry(AccountsController):
gl_entries.append(gle)
if self.unallocated_amount:
- base_unallocated_amount = base_unallocated_amount = self.unallocated_amount * \
+ base_unallocated_amount = self.unallocated_amount * \
(self.source_exchange_rate if self.payment_type=="Receive" else self.target_exchange_rate)
gle = party_gl_dict.copy()
@@ -595,8 +696,8 @@ class PaymentEntry(AccountsController):
"account": self.paid_from,
"account_currency": self.paid_from_account_currency,
"against": self.party if self.payment_type=="Pay" else self.paid_to,
- "credit_in_account_currency": self.paid_amount,
- "credit": self.base_paid_amount,
+ "credit_in_account_currency": self.paid_amount_after_tax,
+ "credit": self.base_paid_amount_after_tax,
"cost_center": self.cost_center
}, item=self)
)
@@ -606,12 +707,48 @@ class PaymentEntry(AccountsController):
"account": self.paid_to,
"account_currency": self.paid_to_account_currency,
"against": self.party if self.payment_type=="Receive" else self.paid_from,
- "debit_in_account_currency": self.received_amount,
- "debit": self.base_received_amount,
+ "debit_in_account_currency": self.received_amount_after_tax,
+ "debit": self.base_received_amount_after_tax,
"cost_center": self.cost_center
}, item=self)
)
+ def add_tax_gl_entries(self, gl_entries):
+ for d in self.get('taxes'):
+ account_currency = get_account_currency(d.account_head)
+ if account_currency != self.company_currency:
+ frappe.throw(_("Currency for {0} must be {1}").format(d.account_head, self.company_currency))
+
+ if (self.payment_type == 'Pay' and self.advance_tax_account) or self.payment_type == 'Receive':
+ dr_or_cr = "debit" if d.add_deduct_tax == "Add" else "credit"
+ elif (self.payment_type == 'Receive' and self.advance_tax_account) or self.payment_type == 'Pay':
+ dr_or_cr = "credit" if d.add_deduct_tax == "Add" else "debit"
+
+ payment_or_advance_account = self.get_party_account_for_taxes()
+
+ gl_entries.append(
+ self.get_gl_dict({
+ "account": d.account_head,
+ "against": self.party if self.payment_type=="Receive" else self.paid_from,
+ dr_or_cr: d.base_tax_amount,
+ dr_or_cr + "_in_account_currency": d.base_tax_amount
+ if account_currency==self.company_currency
+ else d.tax_amount,
+ "cost_center": d.cost_center
+ }, account_currency, item=d))
+
+ #Intentionally use -1 to get net values in party account
+ gl_entries.append(
+ self.get_gl_dict({
+ "account": payment_or_advance_account,
+ "against": self.party if self.payment_type=="Receive" else self.paid_from,
+ dr_or_cr: -1 * d.base_tax_amount,
+ dr_or_cr + "_in_account_currency": -1*d.base_tax_amount
+ if account_currency==self.company_currency
+ else d.tax_amount,
+ "cost_center": self.cost_center,
+ }, account_currency, item=d))
+
def add_deductions_gl_entries(self, gl_entries):
for d in self.get("deductions"):
if d.amount:
@@ -630,6 +767,14 @@ class PaymentEntry(AccountsController):
}, item=d)
)
+ def get_party_account_for_taxes(self):
+ if self.advance_tax_account:
+ return self.advance_tax_account
+ elif self.payment_type == 'Pay':
+ return self.paid_from
+ elif self.payment_type == 'Receive':
+ return self.paid_to
+
def update_advance_paid(self):
if self.payment_type in ("Receive", "Pay") and self.party:
for d in self.get("references"):
@@ -676,6 +821,121 @@ class PaymentEntry(AccountsController):
self.append('deductions', row)
self.set_unallocated_amount()
+ def initialize_taxes(self):
+ for tax in self.get("taxes"):
+ tax_fields = ["total", "tax_fraction_for_current_item", "grand_total_fraction_for_current_item"]
+
+ if tax.charge_type != "Actual":
+ tax_fields.append("tax_amount")
+
+ for fieldname in tax_fields:
+ tax.set(fieldname, 0.0)
+
+ self.paid_amount_after_tax = self.paid_amount
+
+ def determine_exclusive_rate(self):
+ if not any((cint(tax.included_in_paid_amount) for tax in self.get("taxes"))):
+ return
+
+ cumulated_tax_fraction = 0
+ for i, tax in enumerate(self.get("taxes")):
+ tax.tax_fraction_for_current_item = self.get_current_tax_fraction(tax)
+ if i==0:
+ tax.grand_total_fraction_for_current_item = 1 + tax.tax_fraction_for_current_item
+ else:
+ tax.grand_total_fraction_for_current_item = \
+ self.get("taxes")[i-1].grand_total_fraction_for_current_item \
+ + tax.tax_fraction_for_current_item
+
+ cumulated_tax_fraction += tax.tax_fraction_for_current_item
+
+ self.paid_amount_after_tax = flt(self.paid_amount/(1+cumulated_tax_fraction))
+
+ def calculate_taxes(self):
+ self.total_taxes_and_charges = 0.0
+ self.base_total_taxes_and_charges = 0.0
+
+ actual_tax_dict = dict([[tax.idx, flt(tax.tax_amount, tax.precision("tax_amount"))]
+ for tax in self.get("taxes") if tax.charge_type == "Actual"])
+
+ for i, tax in enumerate(self.get('taxes')):
+ current_tax_amount = self.get_current_tax_amount(tax)
+
+ if tax.charge_type == "Actual":
+ actual_tax_dict[tax.idx] -= current_tax_amount
+ if i == len(self.get("taxes")) - 1:
+ current_tax_amount += actual_tax_dict[tax.idx]
+
+ tax.tax_amount = current_tax_amount
+ tax.base_tax_amount = tax.tax_amount * self.source_exchange_rate
+
+ if tax.add_deduct_tax == "Deduct":
+ current_tax_amount *= -1.0
+ else:
+ current_tax_amount *= 1.0
+
+ if i == 0:
+ tax.total = flt(self.paid_amount_after_tax + current_tax_amount, self.precision("total", tax))
+ else:
+ tax.total = flt(self.get('taxes')[i-1].total + current_tax_amount, self.precision("total", tax))
+
+ tax.base_total = tax.total * self.source_exchange_rate
+
+ self.total_taxes_and_charges += current_tax_amount
+ self.base_total_taxes_and_charges += current_tax_amount * self.source_exchange_rate
+
+ if self.get('taxes'):
+ self.paid_amount_after_tax = self.get('taxes')[-1].base_total
+
+ def get_current_tax_amount(self, tax):
+ tax_rate = tax.rate
+
+ # To set row_id by default as previous row.
+ if tax.charge_type in ["On Previous Row Amount", "On Previous Row Total"]:
+ if tax.idx == 1:
+ frappe.throw(_("Cannot select charge type as 'On Previous Row Amount' or 'On Previous Row Total' for first row"))
+
+ if not tax.row_id:
+ tax.row_id = tax.idx - 1
+
+ if tax.charge_type == "Actual":
+ current_tax_amount = flt(tax.tax_amount, self.precision("tax_amount", tax))
+ elif tax.charge_type == "On Paid Amount":
+ current_tax_amount = (tax_rate / 100.0) * self.paid_amount_after_tax
+ elif tax.charge_type == "On Previous Row Amount":
+ current_tax_amount = (tax_rate / 100.0) * \
+ self.get('taxes')[cint(tax.row_id) - 1].tax_amount
+
+ elif tax.charge_type == "On Previous Row Total":
+ current_tax_amount = (tax_rate / 100.0) * \
+ self.get('taxes')[cint(tax.row_id) - 1].total
+
+ return current_tax_amount
+
+ def get_current_tax_fraction(self, tax):
+ current_tax_fraction = 0
+
+ if cint(tax.included_in_paid_amount):
+ tax_rate = tax.rate
+
+ if tax.charge_type == 'Actual':
+ current_tax_fraction = tax.tax_amount/ (self.paid_amount_after_tax + tax.tax_amount)
+ elif tax.charge_type == "On Paid Amount":
+ current_tax_fraction = tax_rate / 100.0
+
+ elif tax.charge_type == "On Previous Row Amount":
+ current_tax_fraction = (tax_rate / 100.0) * \
+ self.get("taxes")[cint(tax.row_id) - 1].tax_fraction_for_current_item
+
+ elif tax.charge_type == "On Previous Row Total":
+ current_tax_fraction = (tax_rate / 100.0) * \
+ self.get("taxes")[cint(tax.row_id) - 1].grand_total_fraction_for_current_item
+
+ if getattr(tax, "add_deduct_tax", None) and tax.add_deduct_tax == "Deduct":
+ current_tax_fraction *= -1.0
+
+ return current_tax_fraction
+
@frappe.whitelist()
def get_outstanding_reference_documents(args):
@@ -1241,6 +1501,13 @@ def get_payment_entry(dt, dn, party_amount=None, bank_account=None, bank_amount=
})
pe.set_difference_amount()
+ if doc.doctype == 'Purchase Order' and doc.apply_tds:
+ pe.apply_tax_withholding_amount = 1
+ pe.tax_withholding_category = doc.tax_withholding_category
+
+ if not pe.advance_tax_account:
+ pe.advance_tax_account = frappe.db.get_value('Company', pe.company, 'unrealized_profit_loss_account')
+
return pe
def get_bank_cash_account(doc, bank_account):
diff --git a/erpnext/accounts/doctype/payment_entry_deduction/payment_entry_deduction.json b/erpnext/accounts/doctype/payment_entry_deduction/payment_entry_deduction.json
index 7060d11691..61a1462dd7 100644
--- a/erpnext/accounts/doctype/payment_entry_deduction/payment_entry_deduction.json
+++ b/erpnext/accounts/doctype/payment_entry_deduction/payment_entry_deduction.json
@@ -1,140 +1,70 @@
{
- "allow_copy": 0,
- "allow_events_in_timeline": 0,
- "allow_guest_to_view": 0,
- "allow_import": 0,
- "allow_rename": 0,
- "beta": 0,
- "creation": "2016-06-15 15:56:30.815503",
- "custom": 0,
- "docstatus": 0,
- "doctype": "DocType",
- "document_type": "",
- "editable_grid": 1,
+ "actions": [],
+ "creation": "2016-06-15 15:56:30.815503",
+ "doctype": "DocType",
+ "editable_grid": 1,
+ "field_order": [
+ "account",
+ "cost_center",
+ "amount",
+ "column_break_2",
+ "description"
+ ],
"fields": [
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "account",
- "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": "Account",
- "length": 0,
- "no_copy": 0,
- "options": "Account",
- "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
- },
+ "fieldname": "account",
+ "fieldtype": "Link",
+ "in_list_view": 1,
+ "label": "Account",
+ "options": "Account",
+ "reqd": 1,
+ "show_days": 1,
+ "show_seconds": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 0,
- "fieldname": "cost_center",
- "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": "Cost Center",
- "length": 0,
- "no_copy": 0,
- "options": "Cost Center",
- "permlevel": 0,
- "precision": "",
- "print_hide": 1,
- "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
- },
+ "fieldname": "cost_center",
+ "fieldtype": "Link",
+ "in_list_view": 1,
+ "label": "Cost Center",
+ "options": "Cost Center",
+ "print_hide": 1,
+ "reqd": 1,
+ "show_days": 1,
+ "show_seconds": 1
+ },
{
- "allow_bulk_edit": 0,
- "allow_in_quick_entry": 0,
- "allow_on_submit": 0,
- "bold": 0,
- "collapsible": 0,
- "columns": 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": "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
+ "fieldname": "amount",
+ "fieldtype": "Currency",
+ "in_list_view": 1,
+ "label": "Amount",
+ "reqd": 1,
+ "show_days": 1,
+ "show_seconds": 1
+ },
+ {
+ "fieldname": "column_break_2",
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
+ },
+ {
+ "fieldname": "description",
+ "fieldtype": "Small Text",
+ "label": "Description",
+ "show_days": 1,
+ "show_seconds": 1
}
- ],
- "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-01-07 16:52:07.040146",
- "modified_by": "Administrator",
- "module": "Accounts",
- "name": "Payment Entry Deduction",
- "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": 0,
- "track_seen": 0,
- "track_views": 0
+ ],
+ "index_web_pages_for_search": 1,
+ "istable": 1,
+ "links": [],
+ "modified": "2020-09-12 20:38:08.110674",
+ "modified_by": "Administrator",
+ "module": "Accounts",
+ "name": "Payment Entry Deduction",
+ "owner": "Administrator",
+ "permissions": [],
+ "quick_entry": 1,
+ "sort_field": "modified",
+ "sort_order": "DESC"
}
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/payment_request/payment_request.py b/erpnext/accounts/doctype/payment_request/payment_request.py
index 468978785b..438951db62 100644
--- a/erpnext/accounts/doctype/payment_request/payment_request.py
+++ b/erpnext/accounts/doctype/payment_request/payment_request.py
@@ -112,7 +112,7 @@ class PaymentRequest(Document):
if not data_of_completed_requests:
return self.grand_total
- request_amounts = sum([json.loads(d).get('request_amount') for d in data_of_completed_requests])
+ request_amounts = sum(json.loads(d).get('request_amount') for d in data_of_completed_requests)
return request_amounts
def on_cancel(self):
diff --git a/erpnext/accounts/doctype/pricing_rule/utils.py b/erpnext/accounts/doctype/pricing_rule/utils.py
index d23b952bdc..b54d0e73a8 100644
--- a/erpnext/accounts/doctype/pricing_rule/utils.py
+++ b/erpnext/accounts/doctype/pricing_rule/utils.py
@@ -20,9 +20,9 @@ from frappe.utils import cint, flt, get_link_to_form, getdate, today, fmt_money
class MultiplePricingRuleConflict(frappe.ValidationError): pass
apply_on_table = {
- 'Item Code': 'items',
- 'Item Group': 'item_groups',
- 'Brand': 'brands'
+ 'Item Code': 'items',
+ 'Item Group': 'item_groups',
+ 'Brand': 'brands'
}
def get_pricing_rules(args, doc=None):
@@ -183,7 +183,7 @@ def _get_tree_conditions(args, parenttype, table, allow_blank=True):
condition = "ifnull({table}.{field}, '') in ({parent_groups})".format(
table=table,
field=field,
- parent_groups=", ".join([frappe.db.escape(d) for d in parent_groups])
+ parent_groups=", ".join(frappe.db.escape(d) for d in parent_groups)
)
frappe.flags.tree_conditions[key] = condition
@@ -264,7 +264,7 @@ def filter_pricing_rules(args, pricing_rules, doc=None):
# find pricing rule with highest priority
if pricing_rules:
- max_priority = max([cint(p.priority) for p in pricing_rules])
+ max_priority = max(cint(p.priority) for p in pricing_rules)
if max_priority:
pricing_rules = list(filter(lambda x: cint(x.priority)==max_priority, pricing_rules))
@@ -272,14 +272,14 @@ def filter_pricing_rules(args, pricing_rules, doc=None):
pricing_rules = list(pricing_rules)
if len(pricing_rules) > 1:
- rate_or_discount = list(set([d.rate_or_discount for d in pricing_rules]))
+ rate_or_discount = list(set(d.rate_or_discount for d in pricing_rules))
if len(rate_or_discount) == 1 and rate_or_discount[0] == "Discount Percentage":
pricing_rules = list(filter(lambda x: x.for_price_list==args.price_list, pricing_rules)) \
or pricing_rules
if len(pricing_rules) > 1 and not args.for_shopping_cart:
frappe.throw(_("Multiple Price Rules exists with same criteria, please resolve conflict by assigning priority. Price Rules: {0}")
- .format("\n".join([d.name for d in pricing_rules])), MultiplePricingRuleConflict)
+ .format("\n".join(d.name for d in pricing_rules)), MultiplePricingRuleConflict)
elif pricing_rules:
return pricing_rules[0]
@@ -541,7 +541,7 @@ def get_product_discount_rule(pricing_rule, item_details, args=None, doc=None):
def apply_pricing_rule_for_free_items(doc, pricing_rule_args, set_missing_values=False):
if pricing_rule_args:
- items = tuple([(d.item_code, d.pricing_rules) for d in doc.items if d.is_free_item])
+ items = tuple((d.item_code, d.pricing_rules) for d in doc.items if d.is_free_item)
for args in pricing_rule_args:
if not items or (args.get('item_code'), args.get('pricing_rules')) not in items:
@@ -589,4 +589,4 @@ def update_coupon_code_count(coupon_name,transaction_type):
elif transaction_type=='cancelled':
if coupon.used>0:
coupon.used=coupon.used-1
- coupon.save(ignore_permissions=True)
\ No newline at end of file
+ coupon.save(ignore_permissions=True)
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
index 9157821520..a714ac7827 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.json
@@ -175,7 +175,9 @@
"hidden": 1,
"label": "Title",
"no_copy": 1,
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "naming_series",
@@ -187,7 +189,9 @@
"options": "ACC-PINV-.YYYY.-\nACC-PINV-RET-.YYYY.-",
"print_hide": 1,
"reqd": 1,
- "set_only_once": 1
+ "set_only_once": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "supplier",
@@ -199,7 +203,9 @@
"options": "Supplier",
"print_hide": 1,
"reqd": 1,
- "search_index": 1
+ "search_index": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"bold": 1,
@@ -211,7 +217,9 @@
"label": "Supplier Name",
"oldfieldname": "supplier_name",
"oldfieldtype": "Data",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fetch_from": "supplier.tax_id",
@@ -219,21 +227,27 @@
"fieldtype": "Read Only",
"label": "Tax Id",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "due_date",
"fieldtype": "Date",
"label": "Due Date",
"oldfieldname": "due_date",
- "oldfieldtype": "Date"
+ "oldfieldtype": "Date",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "0",
"fieldname": "is_paid",
"fieldtype": "Check",
"label": "Is Paid",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "0",
@@ -241,19 +255,25 @@
"fieldtype": "Check",
"label": "Is Return (Debit Note)",
"no_copy": 1,
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "0",
"fieldname": "apply_tds",
"fieldtype": "Check",
"label": "Apply Tax Withholding Amount",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break1",
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1,
"width": "50%"
},
{
@@ -263,13 +283,17 @@
"label": "Company",
"options": "Company",
"print_hide": 1,
- "remember_last_selected_value": 1
+ "remember_last_selected_value": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "cost_center",
"fieldtype": "Link",
"label": "Cost Center",
- "options": "Cost Center"
+ "options": "Cost Center",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "Today",
@@ -281,7 +305,9 @@
"oldfieldtype": "Date",
"print_hide": 1,
"reqd": 1,
- "search_index": 1
+ "search_index": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "posting_time",
@@ -290,6 +316,8 @@
"no_copy": 1,
"print_hide": 1,
"print_width": "100px",
+ "show_days": 1,
+ "show_seconds": 1,
"width": "100px"
},
{
@@ -298,7 +326,9 @@
"fieldname": "set_posting_time",
"fieldtype": "Check",
"label": "Edit Posting Date and Time",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "amended_from",
@@ -310,44 +340,58 @@
"oldfieldtype": "Link",
"options": "Purchase Invoice",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"collapsible_depends_on": "eval:doc.on_hold",
"fieldname": "sb_14",
"fieldtype": "Section Break",
- "label": "Hold Invoice"
+ "label": "Hold Invoice",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "0",
"fieldname": "on_hold",
"fieldtype": "Check",
- "label": "Hold Invoice"
+ "label": "Hold Invoice",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "eval:doc.on_hold",
"description": "Once set, this invoice will be on hold till the set date",
"fieldname": "release_date",
"fieldtype": "Date",
- "label": "Release Date"
+ "label": "Release Date",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "cb_17",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "eval:doc.on_hold",
"fieldname": "hold_comment",
"fieldtype": "Small Text",
- "label": "Reason For Putting On Hold"
+ "label": "Reason For Putting On Hold",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"collapsible_depends_on": "bill_no",
"fieldname": "supplier_invoice_details",
"fieldtype": "Section Break",
- "label": "Supplier Invoice Details"
+ "label": "Supplier Invoice Details",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "bill_no",
@@ -355,11 +399,15 @@
"label": "Supplier Invoice No",
"oldfieldname": "bill_no",
"oldfieldtype": "Data",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_15",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "bill_date",
@@ -368,13 +416,17 @@
"no_copy": 1,
"oldfieldname": "bill_date",
"oldfieldtype": "Date",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "return_against",
"fieldname": "returns",
"fieldtype": "Section Break",
- "label": "Returns"
+ "label": "Returns",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "return_against",
@@ -384,26 +436,34 @@
"no_copy": 1,
"options": "Purchase Invoice",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"fieldname": "section_addresses",
"fieldtype": "Section Break",
- "label": "Address and Contact"
+ "label": "Address and Contact",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "supplier_address",
"fieldtype": "Link",
"label": "Select Supplier Address",
"options": "Address",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "address_display",
"fieldtype": "Small Text",
"label": "Address",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "contact_person",
@@ -411,51 +471,67 @@
"in_global_search": 1,
"label": "Contact Person",
"options": "Contact",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "contact_display",
"fieldtype": "Small Text",
"label": "Contact",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "contact_mobile",
"fieldtype": "Small Text",
"label": "Mobile No",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "contact_email",
"fieldtype": "Small Text",
"label": "Contact Email",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "col_break_address",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "shipping_address",
"fieldtype": "Link",
"label": "Select Shipping Address",
"options": "Address",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "shipping_address_display",
"fieldtype": "Small Text",
"label": "Shipping Address",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"fieldname": "currency_and_price_list",
"fieldtype": "Section Break",
"label": "Currency and Price List",
- "options": "fa fa-tag"
+ "options": "fa fa-tag",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "currency",
@@ -464,7 +540,9 @@
"oldfieldname": "currency",
"oldfieldtype": "Select",
"options": "Currency",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "conversion_rate",
@@ -473,18 +551,24 @@
"oldfieldname": "conversion_rate",
"oldfieldtype": "Currency",
"precision": "9",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break2",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "buying_price_list",
"fieldtype": "Link",
"label": "Price List",
"options": "Price List",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "price_list_currency",
@@ -492,14 +576,18 @@
"label": "Price List Currency",
"options": "Currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "plc_conversion_rate",
"fieldtype": "Float",
"label": "Price List Exchange Rate",
"precision": "9",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "0",
@@ -508,11 +596,15 @@
"label": "Ignore Pricing Rule",
"no_copy": 1,
"permlevel": 1,
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "sec_warehouse",
- "fieldtype": "Section Break"
+ "fieldtype": "Section Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "update_stock",
@@ -521,7 +613,9 @@
"fieldtype": "Link",
"label": "Set Accepted Warehouse",
"options": "Warehouse",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "update_stock",
@@ -531,11 +625,15 @@
"label": "Rejected Warehouse",
"no_copy": 1,
"options": "Warehouse",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "col_break_warehouse",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "No",
@@ -543,25 +641,33 @@
"fieldtype": "Select",
"label": "Raw Materials Supplied",
"options": "No\nYes",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "items_section",
"fieldtype": "Section Break",
"oldfieldtype": "Section Break",
- "options": "fa fa-shopping-cart"
+ "options": "fa fa-shopping-cart",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "0",
"fieldname": "update_stock",
"fieldtype": "Check",
"label": "Update Stock",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "scan_barcode",
"fieldtype": "Data",
- "label": "Scan Barcode"
+ "label": "Scan Barcode",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_bulk_edit": 1,
@@ -571,42 +677,56 @@
"oldfieldname": "entries",
"oldfieldtype": "Table",
"options": "Purchase Invoice Item",
- "reqd": 1
+ "reqd": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "pricing_rule_details",
"fieldtype": "Section Break",
- "label": "Pricing Rules"
+ "label": "Pricing Rules",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "pricing_rules",
"fieldtype": "Table",
"label": "Pricing Rule Detail",
"options": "Pricing Rule Detail",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible_depends_on": "supplied_items",
"fieldname": "raw_materials_supplied",
"fieldtype": "Section Break",
- "label": "Raw Materials Supplied"
+ "label": "Raw Materials Supplied",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "supplied_items",
"fieldtype": "Table",
"label": "Supplied Items",
"options": "Purchase Receipt Item Supplied",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "section_break_26",
- "fieldtype": "Section Break"
+ "fieldtype": "Section Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "total_qty",
"fieldtype": "Float",
"label": "Total Quantity",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_total",
@@ -614,7 +734,9 @@
"label": "Total (Company Currency)",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_net_total",
@@ -624,18 +746,24 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_28",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "total",
"fieldtype": "Currency",
"label": "Total",
"options": "currency",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "net_total",
@@ -645,42 +773,56 @@
"oldfieldtype": "Currency",
"options": "currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "total_net_weight",
"fieldtype": "Float",
"label": "Total Net Weight",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "taxes_section",
"fieldtype": "Section Break",
"oldfieldtype": "Section Break",
- "options": "fa fa-money"
+ "options": "fa fa-money",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "tax_category",
"fieldtype": "Link",
"label": "Tax Category",
"options": "Tax Category",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_49",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "shipping_rule",
"fieldtype": "Link",
"label": "Shipping Rule",
"options": "Shipping Rule",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "section_break_51",
- "fieldtype": "Section Break"
+ "fieldtype": "Section Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "taxes_and_charges",
@@ -689,7 +831,9 @@
"oldfieldname": "purchase_other_charges",
"oldfieldtype": "Link",
"options": "Purchase Taxes and Charges Template",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "taxes",
@@ -697,13 +841,17 @@
"label": "Purchase Taxes and Charges",
"oldfieldname": "purchase_tax_details",
"oldfieldtype": "Table",
- "options": "Purchase Taxes and Charges"
+ "options": "Purchase Taxes and Charges",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"fieldname": "sec_tax_breakup",
"fieldtype": "Section Break",
- "label": "Tax Breakup"
+ "label": "Tax Breakup",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "other_charges_calculation",
@@ -712,13 +860,17 @@
"no_copy": 1,
"oldfieldtype": "HTML",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "totals",
"fieldtype": "Section Break",
"oldfieldtype": "Section Break",
- "options": "fa fa-money"
+ "options": "fa fa-money",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_taxes_and_charges_added",
@@ -728,7 +880,9 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_taxes_and_charges_deducted",
@@ -738,7 +892,9 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_total_taxes_and_charges",
@@ -748,11 +904,15 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_40",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "taxes_and_charges_added",
@@ -762,7 +922,9 @@
"oldfieldtype": "Currency",
"options": "currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "taxes_and_charges_deducted",
@@ -772,7 +934,9 @@
"oldfieldtype": "Currency",
"options": "currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "total_taxes_and_charges",
@@ -780,14 +944,18 @@
"label": "Total Taxes and Charges",
"options": "currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"collapsible_depends_on": "discount_amount",
"fieldname": "section_break_44",
"fieldtype": "Section Break",
- "label": "Additional Discount"
+ "label": "Additional Discount",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "Grand Total",
@@ -795,7 +963,9 @@
"fieldtype": "Select",
"label": "Apply Additional Discount On",
"options": "\nGrand Total\nNet Total",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_discount_amount",
@@ -803,28 +973,38 @@
"label": "Additional Discount Amount (Company Currency)",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_46",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "additional_discount_percentage",
"fieldtype": "Float",
"label": "Additional Discount Percentage",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "discount_amount",
"fieldtype": "Currency",
"label": "Additional Discount Amount",
"options": "currency",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "section_break_49",
- "fieldtype": "Section Break"
+ "fieldtype": "Section Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_grand_total",
@@ -834,7 +1014,9 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "eval:!doc.disable_rounded_total",
@@ -844,7 +1026,9 @@
"no_copy": 1,
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "eval:!doc.disable_rounded_total",
@@ -854,7 +1038,9 @@
"no_copy": 1,
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_in_words",
@@ -864,13 +1050,17 @@
"oldfieldname": "in_words",
"oldfieldtype": "Data",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break8",
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1,
"width": "50%"
},
{
@@ -881,7 +1071,9 @@
"oldfieldname": "grand_total_import",
"oldfieldtype": "Currency",
"options": "currency",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "eval:!doc.disable_rounded_total",
@@ -891,7 +1083,9 @@
"no_copy": 1,
"options": "currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "eval:!doc.disable_rounded_total",
@@ -901,7 +1095,9 @@
"no_copy": 1,
"options": "currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "in_words",
@@ -911,7 +1107,9 @@
"oldfieldname": "in_words_import",
"oldfieldtype": "Data",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "total_advance",
@@ -922,7 +1120,9 @@
"oldfieldtype": "Currency",
"options": "party_account_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "outstanding_amount",
@@ -933,14 +1133,18 @@
"oldfieldtype": "Currency",
"options": "party_account_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "0",
"depends_on": "grand_total",
"fieldname": "disable_rounded_total",
"fieldtype": "Check",
- "label": "Disable Rounded Total"
+ "label": "Disable Rounded Total",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
@@ -948,20 +1152,26 @@
"depends_on": "eval:doc.is_paid===1||(doc.advances && doc.advances.length>0)",
"fieldname": "payments_section",
"fieldtype": "Section Break",
- "label": "Payments"
+ "label": "Payments",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "mode_of_payment",
"fieldtype": "Link",
"label": "Mode of Payment",
"options": "Mode of Payment",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "cash_bank_account",
"fieldtype": "Link",
"label": "Cash/Bank Account",
- "options": "Account"
+ "options": "Account",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "clearance_date",
@@ -969,11 +1179,15 @@
"label": "Clearance Date",
"no_copy": 1,
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "col_br_payments",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "is_paid",
@@ -982,7 +1196,9 @@
"label": "Paid Amount",
"no_copy": 1,
"options": "currency",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_paid_amount",
@@ -991,7 +1207,9 @@
"no_copy": 1,
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
@@ -999,7 +1217,9 @@
"depends_on": "grand_total",
"fieldname": "write_off",
"fieldtype": "Section Break",
- "label": "Write Off"
+ "label": "Write Off",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "write_off_amount",
@@ -1007,7 +1227,9 @@
"label": "Write Off Amount",
"no_copy": 1,
"options": "currency",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_write_off_amount",
@@ -1016,11 +1238,15 @@
"no_copy": 1,
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_61",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "eval:flt(doc.write_off_amount)!=0",
@@ -1028,7 +1254,9 @@
"fieldtype": "Link",
"label": "Write Off Account",
"options": "Account",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "eval:flt(doc.write_off_amount)!=0",
@@ -1036,7 +1264,9 @@
"fieldtype": "Link",
"label": "Write Off Cost Center",
"options": "Cost Center",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
@@ -1046,13 +1276,17 @@
"label": "Advance Payments",
"oldfieldtype": "Section Break",
"options": "fa fa-money",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "0",
"fieldname": "allocate_advances_automatically",
"fieldtype": "Check",
- "label": "Set Advances and Allocate (FIFO)"
+ "label": "Set Advances and Allocate (FIFO)",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "eval:!doc.allocate_advances_automatically",
@@ -1060,7 +1294,9 @@
"fieldtype": "Button",
"label": "Get Advances Paid",
"oldfieldtype": "Button",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "advances",
@@ -1070,20 +1306,26 @@
"oldfieldname": "advance_allocation_details",
"oldfieldtype": "Table",
"options": "Purchase Invoice Advance",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"collapsible_depends_on": "eval:(!doc.is_return)",
"fieldname": "payment_schedule_section",
"fieldtype": "Section Break",
- "label": "Payment Terms"
+ "label": "Payment Terms",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "payment_terms_template",
"fieldtype": "Link",
"label": "Payment Terms Template",
- "options": "Payment Terms Template"
+ "options": "Payment Terms Template",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "payment_schedule",
@@ -1091,7 +1333,9 @@
"label": "Payment Schedule",
"no_copy": 1,
"options": "Payment Schedule",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
@@ -1099,25 +1343,33 @@
"fieldname": "terms_section_break",
"fieldtype": "Section Break",
"label": "Terms and Conditions",
- "options": "fa fa-legal"
+ "options": "fa fa-legal",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "tc_name",
"fieldtype": "Link",
"label": "Terms",
"options": "Terms and Conditions",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "terms",
"fieldtype": "Text Editor",
- "label": "Terms and Conditions1"
+ "label": "Terms and Conditions1",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"fieldname": "printing_settings",
"fieldtype": "Section Break",
- "label": "Printing Settings"
+ "label": "Printing Settings",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
@@ -1125,7 +1377,9 @@
"fieldtype": "Link",
"label": "Letter Head",
"options": "Letter Head",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
@@ -1133,11 +1387,15 @@
"fieldname": "group_same_items",
"fieldtype": "Check",
"label": "Group same items",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_112",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
@@ -1149,14 +1407,18 @@
"oldfieldtype": "Link",
"options": "Print Heading",
"print_hide": 1,
- "report_hide": 1
+ "report_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "language",
"fieldtype": "Data",
"label": "Print Language",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
@@ -1165,7 +1427,9 @@
"label": "More Information",
"oldfieldtype": "Section Break",
"options": "fa fa-file-text",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "credit_to",
@@ -1176,7 +1440,9 @@
"options": "Account",
"print_hide": 1,
"reqd": 1,
- "search_index": 1
+ "search_index": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "party_account_currency",
@@ -1186,7 +1452,9 @@
"no_copy": 1,
"options": "Currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "No",
@@ -1196,7 +1464,9 @@
"oldfieldname": "is_opening",
"oldfieldtype": "Select",
"options": "No\nYes",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "against_expense_account",
@@ -1206,11 +1476,15 @@
"no_copy": 1,
"oldfieldname": "against_expense_account",
"oldfieldtype": "Small Text",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_63",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "Draft",
@@ -1219,7 +1493,9 @@
"in_standard_filter": 1,
"label": "Status",
"options": "\nDraft\nReturn\nDebit Note Issued\nSubmitted\nPaid\nUnpaid\nOverdue\nCancelled\nInternal Transfer",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "inter_company_invoice_reference",
@@ -1228,7 +1504,9 @@
"no_copy": 1,
"options": "Sales Invoice",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "remarks",
@@ -1237,14 +1515,18 @@
"no_copy": 1,
"oldfieldname": "remarks",
"oldfieldtype": "Text",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"fieldname": "subscription_section",
"fieldtype": "Section Break",
"label": "Subscription Section",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
@@ -1253,7 +1535,9 @@
"fieldtype": "Date",
"label": "From Date",
"no_copy": 1,
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
@@ -1262,11 +1546,15 @@
"fieldtype": "Date",
"label": "To Date",
"no_copy": 1,
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_114",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "auto_repeat",
@@ -1275,24 +1563,32 @@
"no_copy": 1,
"options": "Auto Repeat",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
"depends_on": "eval: doc.auto_repeat",
"fieldname": "update_auto_repeat_reference",
"fieldtype": "Button",
- "label": "Update Auto Repeat Reference"
+ "label": "Update Auto Repeat Reference",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"fieldname": "accounting_dimensions_section",
"fieldtype": "Section Break",
- "label": "Accounting Dimensions "
+ "label": "Accounting Dimensions ",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "dimension_col_break",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "0",
@@ -1300,7 +1596,9 @@
"fieldname": "is_internal_supplier",
"fieldtype": "Check",
"label": "Is Internal Supplier",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "tax_withholding_category",
@@ -1308,19 +1606,25 @@
"hidden": 1,
"label": "Tax Withholding Category",
"options": "Tax Withholding Category",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "billing_address",
"fieldtype": "Link",
"label": "Select Billing Address",
- "options": "Address"
+ "options": "Address",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "billing_address_display",
"fieldtype": "Small Text",
"label": "Billing Address",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "project",
@@ -1334,7 +1638,9 @@
"fieldname": "unrealized_profit_loss_account",
"fieldtype": "Link",
"label": "Unrealized Profit / Loss Account",
- "options": "Account"
+ "options": "Account",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "eval:doc.is_internal_supplier",
@@ -1343,7 +1649,9 @@
"fieldname": "represents_company",
"fieldtype": "Link",
"label": "Represents Company",
- "options": "Company"
+ "options": "Company",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "eval:doc.update_stock && doc.is_internal_supplier",
@@ -1355,6 +1663,8 @@
"options": "Warehouse",
"print_hide": 1,
"print_width": "50px",
+ "show_days": 1,
+ "show_seconds": 1,
"width": "50px"
},
{
diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
index 83e9f7583e..0ee0bc7e11 100644
--- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py
@@ -68,9 +68,6 @@ class PurchaseInvoice(BuyingController):
super(PurchaseInvoice, self).validate()
- # apply tax withholding only if checked and applicable
- self.set_tax_withholding()
-
if not self.is_return:
self.po_required()
self.pr_required()
@@ -251,11 +248,9 @@ class PurchaseInvoice(BuyingController):
if self.update_stock and (not item.from_warehouse):
if for_validate and item.expense_account and item.expense_account != warehouse_account[item.warehouse]["account"]:
- msg = _("Row {}: Expense Head changed to {} ").format(item.idx, frappe.bold(warehouse_account[item.warehouse]["account"]))
- msg += _("because account {} is not linked to warehouse {} ").format(frappe.bold(item.expense_account), frappe.bold(item.warehouse))
- msg += _("or it is not the default inventory account")
+ msg = _("Row {0}: Expense Head changed to {1} because account {2} is not linked to warehouse {3} or it is not the default inventory account").format(
+ item.idx, frappe.bold(warehouse_account[item.warehouse]["account"]), frappe.bold(item.expense_account), frappe.bold(item.warehouse))
frappe.msgprint(msg, title=_("Expense Head Changed"))
-
item.expense_account = warehouse_account[item.warehouse]["account"]
else:
# check if 'Stock Received But Not Billed' account is credited in Purchase receipt or not
@@ -266,8 +261,8 @@ class PurchaseInvoice(BuyingController):
if negative_expense_booked_in_pr:
if for_validate and item.expense_account and item.expense_account != stock_not_billed_account:
- msg = _("Row {}: Expense Head changed to {} ").format(item.idx, frappe.bold(stock_not_billed_account))
- msg += _("because expense is booked against this account in Purchase Receipt {}").format(frappe.bold(item.purchase_receipt))
+ msg = _("Row {0}: Expense Head changed to {1} because expense is booked against this account in Purchase Receipt {2}").format(
+ item.idx, frappe.bold(stock_not_billed_account), frappe.bold(item.purchase_receipt))
frappe.msgprint(msg, title=_("Expense Head Changed"))
item.expense_account = stock_not_billed_account
@@ -275,8 +270,9 @@ class PurchaseInvoice(BuyingController):
# If no purchase receipt present then book expense in 'Stock Received But Not Billed'
# This is done in cases when Purchase Invoice is created before Purchase Receipt
if for_validate and item.expense_account and item.expense_account != stock_not_billed_account:
- msg = _("Row {}: Expense Head changed to {} ").format(item.idx, frappe.bold(stock_not_billed_account))
- msg += _("as no Purchase Receipt is created against Item {}. ").format(frappe.bold(item.item_code))
+ msg = _("Row {0}: Expense Head changed to {1} as no Purchase Receipt is created against Item {2}.").format(
+ item.idx, frappe.bold(stock_not_billed_account), frappe.bold(item.item_code))
+ msg += "
"
msg += _("This is done to handle accounting for cases when Purchase Receipt is created after Purchase Invoice")
frappe.msgprint(msg, title=_("Expense Head Changed"))
@@ -308,8 +304,8 @@ class PurchaseInvoice(BuyingController):
if not d.purchase_order:
msg = _("Purchase Order Required for item {}").format(frappe.bold(d.item_code))
msg += "
"
- msg += _("To submit the invoice without purchase order please set {} ").format(frappe.bold(_('Purchase Order Required')))
- msg += _("as {} in {}").format(frappe.bold('No'), get_link_to_form('Buying Settings', 'Buying Settings', 'Buying Settings'))
+ msg += _("To submit the invoice without purchase order please set {0} as {1} in {2}").format(
+ frappe.bold(_('Purchase Order Required')), frappe.bold('No'), get_link_to_form('Buying Settings', 'Buying Settings', 'Buying Settings'))
throw(msg, title=_("Mandatory Purchase Order"))
def pr_required(self):
@@ -323,8 +319,8 @@ class PurchaseInvoice(BuyingController):
if not d.purchase_receipt and d.item_code in stock_items:
msg = _("Purchase Receipt Required for item {}").format(frappe.bold(d.item_code))
msg += "
"
- msg += _("To submit the invoice without purchase receipt please set {} ").format(frappe.bold(_('Purchase Receipt Required')))
- msg += _("as {} in {}").format(frappe.bold('No'), get_link_to_form('Buying Settings', 'Buying Settings', 'Buying Settings'))
+ msg += _("To submit the invoice without purchase receipt please set {0} as {1} in {2}").format(
+ frappe.bold(_('Purchase Receipt Required')), frappe.bold('No'), get_link_to_form('Buying Settings', 'Buying Settings', 'Buying Settings'))
throw(msg, title=_("Mandatory Purchase Receipt"))
def validate_write_off_account(self):
@@ -456,6 +452,8 @@ class PurchaseInvoice(BuyingController):
self.make_tax_gl_entries(gl_entries)
self.make_internal_transfer_gl_entries(gl_entries)
+ self.allocate_advance_taxes(gl_entries)
+
gl_entries = make_regional_gl_entries(gl_entries, self)
gl_entries = merge_similar_entries(gl_entries)
@@ -1090,6 +1088,7 @@ class PurchaseInvoice(BuyingController):
for d in self.taxes:
if d.account_head == tax_withholding_details.get("account_head"):
d.update(tax_withholding_details)
+
accounts.append(d.account_head)
if not accounts or tax_withholding_details.get("account_head") not in accounts:
diff --git a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
index 53db689c84..503dda7728 100644
--- a/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
+++ b/erpnext/accounts/doctype/purchase_invoice/test_purchase_invoice.py
@@ -16,6 +16,7 @@ from erpnext.stock.doctype.stock_entry.test_stock_entry import get_qty_after_tra
from erpnext.projects.doctype.project.test_project import make_project
from erpnext.accounts.doctype.account.test_account import get_inventory_account, create_account
from erpnext.stock.doctype.item.test_item import create_item
+from erpnext.buying.doctype.supplier.test_supplier import create_supplier
test_dependencies = ["Item", "Cost Center", "Payment Term", "Payment Terms Template"]
test_ignore = ["Serial No"]
@@ -631,7 +632,7 @@ class TestPurchaseInvoice(unittest.TestCase):
self.assertEqual(len(pi.get("supplied_items")), 2)
- rm_supp_cost = sum([d.amount for d in pi.get("supplied_items")])
+ rm_supp_cost = sum(d.amount for d in pi.get("supplied_items"))
self.assertEqual(flt(pi.get("items")[0].rm_supp_cost, 2), flt(rm_supp_cost, 2))
def test_rejected_serial_no(self):
@@ -950,6 +951,102 @@ class TestPurchaseInvoice(unittest.TestCase):
acc_settings.submit_journal_entriessubmit_journal_entries = 0
acc_settings.save()
+ def test_purchase_invoice_advance_taxes(self):
+ from erpnext.buying.doctype.purchase_order.test_purchase_order import create_purchase_order
+ from erpnext.accounts.doctype.payment_entry.payment_entry import get_payment_entry
+ from erpnext.buying.doctype.purchase_order.purchase_order import get_mapped_purchase_invoice
+
+ # create a new supplier to test
+ supplier = create_supplier(supplier_name = '_Test TDS Advance Supplier',
+ tax_withholding_category = 'TDS - 194 - Dividends - Individual')
+
+ # Update tax withholding category with current fiscal year and rate details
+ update_tax_witholding_category('_Test Company', 'TDS Payable - _TC', nowdate())
+
+ # Create Purchase Order with TDS applied
+ po = create_purchase_order(do_not_save=1, supplier=supplier.name, rate=3000)
+ po.apply_tds = 1
+ po.tax_withholding_category = 'TDS - 194 - Dividends - Individual'
+ po.save()
+ po.submit()
+
+ # Update Unrealized Profit / Loss Account which is used as default advance tax account
+ frappe.db.set_value('Company', '_Test Company', 'unrealized_profit_loss_account', '_Test Account Excise Duty - _TC')
+
+ # Create Payment Entry Against the order
+ payment_entry = get_payment_entry(dt='Purchase Order', dn=po.name)
+ payment_entry.paid_from = 'Cash - _TC'
+ payment_entry.save()
+ payment_entry.submit()
+
+ # Check GLE for Payment Entry
+ expected_gle = [
+ ['_Test Account Excise Duty - _TC', 3000, 0],
+ ['Cash - _TC', 0, 27000],
+ ['Creditors - _TC', 27000, 0],
+ ['TDS Payable - _TC', 0, 3000],
+ ]
+
+ gl_entries = frappe.db.sql("""select account, debit, credit
+ from `tabGL Entry`
+ where voucher_type='Payment Entry' and voucher_no=%s
+ order by account asc""", (payment_entry.name), as_dict=1)
+
+ for i, gle in enumerate(gl_entries):
+ self.assertEqual(expected_gle[i][0], gle.account)
+ self.assertEqual(expected_gle[i][1], gle.debit)
+ self.assertEqual(expected_gle[i][2], gle.credit)
+
+ # Create Purchase Invoice against Purchase Order
+ purchase_invoice = get_mapped_purchase_invoice(po.name)
+ purchase_invoice.allocate_advances_automatically = 1
+ purchase_invoice.items[0].expense_account = '_Test Account Cost for Goods Sold - _TC'
+ purchase_invoice.save()
+ purchase_invoice.submit()
+
+ # Check GLE for Purchase Invoice
+ # Zero net effect on final TDS Payable on invoice
+ expected_gle = [
+ ['_Test Account Cost for Goods Sold - _TC', 30000, 0],
+ ['_Test Account Excise Duty - _TC', 0, 3000],
+ ['Creditors - _TC', 0, 27000],
+ ['TDS Payable - _TC', 3000, 3000]
+ ]
+
+ gl_entries = frappe.db.sql("""select account, debit, credit
+ from `tabGL Entry`
+ where voucher_type='Purchase Invoice' and voucher_no=%s
+ order by account asc""", (purchase_invoice.name), as_dict=1)
+
+ for i, gle in enumerate(gl_entries):
+ self.assertEqual(expected_gle[i][0], gle.account)
+ self.assertEqual(expected_gle[i][1], gle.debit)
+ self.assertEqual(expected_gle[i][2], gle.credit)
+
+def update_tax_witholding_category(company, account, date):
+ from erpnext.accounts.utils import get_fiscal_year
+
+ fiscal_year = get_fiscal_year(date=date, company=company)
+
+ if not frappe.db.get_value('Tax Withholding Rate',
+ {'parent': 'TDS - 194 - Dividends - Individual', 'fiscal_year': fiscal_year[0]}):
+ tds_category = frappe.get_doc('Tax Withholding Category', 'TDS - 194 - Dividends - Individual')
+ tds_category.append('rates', {
+ 'fiscal_year': fiscal_year[0],
+ 'tax_withholding_rate': 10,
+ 'single_threshold': 2500,
+ 'cumulative_threshold': 0
+ })
+ tds_category.save()
+
+ if not frappe.db.get_value('Tax Withholding Account',
+ {'parent': 'TDS - 194 - Dividends - Individual', 'account': account}):
+ tds_category = frappe.get_doc('Tax Withholding Category', 'TDS - 194 - Dividends - Individual')
+ tds_category.append('accounts', {
+ 'company': company,
+ 'account': account
+ })
+ tds_category.save()
def unlink_payment_on_cancel_of_invoice(enable=1):
accounts_settings = frappe.get_doc("Accounts Settings")
diff --git a/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.json b/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.json
index f9fdc4b605..9b07645ccc 100644
--- a/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.json
+++ b/erpnext/accounts/doctype/purchase_taxes_and_charges/purchase_taxes_and_charges.json
@@ -12,6 +12,7 @@
"charge_type",
"row_id",
"included_in_print_rate",
+ "included_in_paid_amount",
"col_break1",
"account_head",
"description",
@@ -21,6 +22,7 @@
"cost_center",
"dimension_col_break",
"section_break_9",
+ "currency",
"tax_amount",
"tax_amount_after_discount_amount",
"total",
@@ -205,12 +207,27 @@
{
"fieldname": "dimension_col_break",
"fieldtype": "Column Break"
+ },
+ {
+ "fetch_from": "account_head.account_currency",
+ "fieldname": "currency",
+ "fieldtype": "Link",
+ "label": "Account Currency",
+ "options": "Currency",
+ "read_only": 1
+ },
+ {
+ "default": "0",
+ "description": "If checked, the tax amount will be considered as already included in the Paid Amount in Payment Entry",
+ "fieldname": "included_in_paid_amount",
+ "fieldtype": "Check",
+ "label": "Considered In Paid Amount"
}
],
"idx": 1,
"istable": 1,
"links": [],
- "modified": "2020-09-18 17:26:09.703215",
+ "modified": "2021-06-09 11:48:25.335733",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Purchase Taxes and Charges",
diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
index 0b8d28aef0..e14f305fc5 100644
--- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py
@@ -842,6 +842,8 @@ class SalesInvoice(SellingController):
self.make_tax_gl_entries(gl_entries)
self.make_internal_transfer_gl_entries(gl_entries)
+ self.allocate_advance_taxes(gl_entries)
+
self.make_item_gl_entries(gl_entries)
# merge gl entries before adding pos entries
diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
index f493acd609..114b7d2d35 100644
--- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
+++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
@@ -1985,6 +1985,33 @@ def get_sales_invoice_for_e_invoice():
return si
+ def test_item_tax_net_range(self):
+ item = create_item("T Shirt")
+
+ item.set('taxes', [])
+ item.append("taxes", {
+ "item_tax_template": "_Test Account Excise Duty @ 10 - _TC",
+ "minimum_net_rate": 0,
+ "maximum_net_rate": 500
+ })
+
+ item.append("taxes", {
+ "item_tax_template": "_Test Account Excise Duty @ 12 - _TC",
+ "minimum_net_rate": 501,
+ "maximum_net_rate": 1000
+ })
+
+ item.save()
+
+ sales_invoice = create_sales_invoice(item = "T Shirt", rate=700, do_not_submit=True)
+ self.assertEqual(sales_invoice.items[0].item_tax_template, "_Test Account Excise Duty @ 12 - _TC")
+
+ # Apply discount
+ sales_invoice.apply_discount_on = 'Net Total'
+ sales_invoice.discount_amount = 300
+ sales_invoice.save()
+ self.assertEqual(sales_invoice.items[0].item_tax_template, "_Test Account Excise Duty @ 10 - _TC")
+
def make_test_address_for_ewaybill():
if not frappe.db.exists('Address', '_Test Address for Eway bill-Billing'):
address = frappe.get_doc({
@@ -2107,27 +2134,6 @@ def check_gl_entries(doc, voucher_no, expected_gle, posting_date):
doc.assertEqual(expected_gle[i][2], gle.credit)
doc.assertEqual(getdate(expected_gle[i][3]), gle.posting_date)
- def test_item_tax_validity(self):
- item = frappe.get_doc("Item", "_Test Item 2")
-
- if item.taxes:
- item.taxes = []
- item.save()
-
- item.append("taxes", {
- "item_tax_template": "_Test Item Tax Template 1 - _TC",
- "valid_from": add_days(nowdate(), 1)
- })
-
- item.save()
-
- sales_invoice = create_sales_invoice(item = "_Test Item 2", do_not_save=1)
- sales_invoice.items[0].item_tax_template = "_Test Item Tax Template 1 - _TC"
- self.assertRaises(frappe.ValidationError, sales_invoice.save)
-
- item.taxes = []
- item.save()
-
def create_sales_invoice(**args):
si = frappe.new_doc("Sales Invoice")
args = frappe._dict(args)
diff --git a/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.json b/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.json
index 3c8cb6b851..170d34e651 100644
--- a/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.json
+++ b/erpnext/accounts/doctype/sales_taxes_and_charges/sales_taxes_and_charges.json
@@ -1,8 +1,10 @@
{
+ "actions": [],
"creation": "2013-04-24 11:39:32",
"doctype": "DocType",
"document_type": "Setup",
"editable_grid": 1,
+ "engine": "InnoDB",
"field_order": [
"charge_type",
"row_id",
@@ -10,12 +12,14 @@
"col_break_1",
"description",
"included_in_print_rate",
+ "included_in_paid_amount",
"accounting_dimensions_section",
"cost_center",
"dimension_col_break",
"section_break_8",
"rate",
"section_break_9",
+ "currency",
"tax_amount",
"total",
"tax_amount_after_discount_amount",
@@ -23,8 +27,7 @@
"base_tax_amount",
"base_total",
"base_tax_amount_after_discount_amount",
- "item_wise_tax_detail",
- "parenttype"
+ "item_wise_tax_detail"
],
"fields": [
{
@@ -173,17 +176,6 @@
"oldfieldtype": "Small Text",
"read_only": 1
},
- {
- "fieldname": "parenttype",
- "fieldtype": "Data",
- "hidden": 1,
- "in_filter": 1,
- "label": "Parenttype",
- "oldfieldname": "parenttype",
- "oldfieldtype": "Data",
- "print_hide": 1,
- "search_index": 1
- },
{
"fieldname": "accounting_dimensions_section",
"fieldtype": "Section Break",
@@ -192,15 +184,33 @@
{
"fieldname": "dimension_col_break",
"fieldtype": "Column Break"
+ },
+ {
+ "fetch_from": "account_head.account_currency",
+ "fieldname": "currency",
+ "fieldtype": "Link",
+ "label": "Account Currency",
+ "options": "Currency",
+ "read_only": 1
+ },
+ {
+ "default": "0",
+ "description": "If checked, the tax amount will be considered as already included in the Paid Amount in Payment Entry",
+ "fieldname": "included_in_paid_amount",
+ "fieldtype": "Check",
+ "label": "Considered In Paid Amount"
}
],
"idx": 1,
+ "index_web_pages_for_search": 1,
"istable": 1,
- "modified": "2019-05-25 22:59:38.740883",
+ "links": [],
+ "modified": "2021-06-09 11:48:04.691596",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Sales Taxes and Charges",
"owner": "Administrator",
"permissions": [],
+ "sort_field": "modified",
"sort_order": "ASC"
}
\ No newline at end of file
diff --git a/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py b/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py
index 5c1cbaa4aa..b9ee4a0963 100644
--- a/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py
+++ b/erpnext/accounts/doctype/tax_withholding_category/tax_withholding_category.py
@@ -49,7 +49,7 @@ def get_party_tax_withholding_details(inv, tax_withholding_category=None):
if not parties:
parties.append(party)
- fiscal_year = get_fiscal_year(inv.posting_date, company=inv.company)
+ fiscal_year = get_fiscal_year(inv.get('posting_date') or inv.get('transaction_date'), company=inv.company)
tax_details = get_tax_withholding_details(tax_withholding_category, fiscal_year[0], inv.company)
if not tax_details:
@@ -154,7 +154,7 @@ def get_tax_amount(party_type, parties, inv, tax_details, fiscal_year_details, p
tax_deducted = get_deducted_tax(taxable_vouchers, fiscal_year, tax_details)
tax_amount = 0
- posting_date = inv.posting_date
+ posting_date = inv.get('posting_date') or inv.get('transaction_date')
if party_type == 'Supplier':
ldc = get_lower_deduction_certificate(fiscal_year, pan_no)
if tax_deducted:
@@ -257,7 +257,7 @@ def get_tds_amount(ldc, parties, inv, tax_details, fiscal_year_details, tax_dedu
if ((threshold and inv.net_total >= threshold) or (cumulative_threshold and supp_credit_amt >= cumulative_threshold)):
if ldc and is_valid_certificate(
ldc.valid_from, ldc.valid_upto,
- inv.posting_date, tax_deducted,
+ inv.get('posting_date') or inv.get('transaction_date'), tax_deducted,
inv.net_total, ldc.certificate_limit
):
tds_amount = get_ltds_amount(supp_credit_amt, 0, ldc.certificate_limit, ldc.rate, tax_details)
diff --git a/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py b/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py
index 0cea7612dd..dd26be7c99 100644
--- a/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py
+++ b/erpnext/accounts/doctype/tax_withholding_category/test_tax_withholding_category.py
@@ -112,7 +112,7 @@ class TestTaxWithholdingCategory(unittest.TestCase):
si = create_sales_invoice(customer = "Test TCS Customer", rate=5000)
si.submit()
- tcs_charged = sum([d.base_tax_amount for d in si.taxes if d.account_head == 'TCS - _TC'])
+ tcs_charged = sum(d.base_tax_amount for d in si.taxes if d.account_head == 'TCS - _TC')
self.assertEqual(tcs_charged, 500)
invoices.append(si)
diff --git a/erpnext/accounts/general_ledger.py b/erpnext/accounts/general_ledger.py
index d4b249429b..59009ae621 100644
--- a/erpnext/accounts/general_ledger.py
+++ b/erpnext/accounts/general_ledger.py
@@ -143,7 +143,7 @@ def make_entry(args, adv_adj, update_outstanding, from_repost=False):
validate_expense_against_budget(args)
def validate_cwip_accounts(gl_map):
- cwip_enabled = any([cint(ac.enable_cwip_accounting) for ac in frappe.db.get_all("Asset Category","enable_cwip_accounting")])
+ cwip_enabled = any(cint(ac.enable_cwip_accounting) for ac in frappe.db.get_all("Asset Category","enable_cwip_accounting"))
if cwip_enabled and gl_map[0].voucher_type == "Journal Entry":
cwip_accounts = [d[0] for d in frappe.db.sql("""select name from tabAccount
diff --git a/erpnext/accounts/report/account_balance/account_balance.py b/erpnext/accounts/report/account_balance/account_balance.py
index 65e7d789bb..be64c327fd 100644
--- a/erpnext/accounts/report/account_balance/account_balance.py
+++ b/erpnext/accounts/report/account_balance/account_balance.py
@@ -58,11 +58,9 @@ def get_conditions(filters):
def get_data(filters):
data = []
-
conditions = get_conditions(filters)
-
accounts = frappe.db.get_all("Account", fields=["name", "account_currency"],
- filters=conditions)
+ filters=conditions, order_by='name')
for d in accounts:
balance = get_balance_on(d.name, date=filters.report_date)
diff --git a/erpnext/accounts/report/account_balance/test_account_balance.py b/erpnext/accounts/report/account_balance/test_account_balance.py
index b6ced312d0..14ddf4a30f 100644
--- a/erpnext/accounts/report/account_balance/test_account_balance.py
+++ b/erpnext/accounts/report/account_balance/test_account_balance.py
@@ -23,7 +23,7 @@ class TestAccountBalance(unittest.TestCase):
expected_data = [
{
- "account": 'Sales - _TC2',
+ "account": 'Direct Income - _TC2',
"currency": 'EUR',
"balance": -100.0,
},
@@ -32,21 +32,21 @@ class TestAccountBalance(unittest.TestCase):
"currency": 'EUR',
"balance": -100.0,
},
- {
- "account": 'Service - _TC2',
- "currency": 'EUR',
- "balance": 0.0,
- },
- {
- "account": 'Direct Income - _TC2',
- "currency": 'EUR',
- "balance": -100.0,
- },
{
"account": 'Indirect Income - _TC2',
"currency": 'EUR',
"balance": 0.0,
},
+ {
+ "account": 'Sales - _TC2',
+ "currency": 'EUR',
+ "balance": -100.0,
+ },
+ {
+ "account": 'Service - _TC2',
+ "currency": 'EUR',
+ "balance": 0.0,
+ }
]
self.assertEqual(expected_data, report[1])
diff --git a/erpnext/accounts/report/cash_flow/custom_cash_flow.py b/erpnext/accounts/report/cash_flow/custom_cash_flow.py
index ff87276a87..c11c15390b 100644
--- a/erpnext/accounts/report/cash_flow/custom_cash_flow.py
+++ b/erpnext/accounts/report/cash_flow/custom_cash_flow.py
@@ -32,7 +32,7 @@ def get_accounts_in_mappers(mapping_names):
join `tabCash Flow Mapping` cfm on cfma.parent=cfm.name
where cfma.parent in (%s)
order by cfm.is_working_capital
- ''', (', '.join(['"%s"' % d for d in mapping_names])))
+ ''', (', '.join('"%s"' % d for d in mapping_names)))
def setup_mappers(mappers):
@@ -83,8 +83,8 @@ def setup_mappers(mappers):
account_types_labels = sorted(
set(
- [(d['label'], d['is_working_capital'], d['is_income_tax_liability'], d['is_income_tax_expense'])
- for d in account_types]
+ (d['label'], d['is_working_capital'], d['is_income_tax_liability'], d['is_income_tax_expense'])
+ for d in account_types
),
key=lambda x: x[1]
)
@@ -375,7 +375,7 @@ def _get_account_type_based_data(filters, account_names, period_list, accumulate
total = 0
for period in period_list:
start_date = get_start_date(period, accumulated_values, company)
- accounts = ', '.join(['"%s"' % d for d in account_names])
+ accounts = ', '.join('"%s"' % d for d in account_names)
if opening_balances:
date_info = dict(date=start_date)
diff --git a/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py b/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py
index 10b32fea56..c79d7401e6 100644
--- a/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py
+++ b/erpnext/accounts/report/customer_ledger_summary/customer_ledger_summary.py
@@ -145,7 +145,7 @@ class PartyLedgerSummaryReport(object):
out = []
for party, row in iteritems(self.party_data):
if row.opening_balance or row.invoiced_amount or row.paid_amount or row.return_amount or row.closing_amount:
- total_party_adjustment = sum([amount for amount in itervalues(self.party_adjustment_details.get(party, {}))])
+ total_party_adjustment = sum(amount for amount in itervalues(self.party_adjustment_details.get(party, {})))
row.paid_amount -= total_party_adjustment
adjustments = self.party_adjustment_details.get(party, {})
diff --git a/erpnext/accounts/report/financial_statements.py b/erpnext/accounts/report/financial_statements.py
index d20ddbde5c..39ff804518 100644
--- a/erpnext/accounts/report/financial_statements.py
+++ b/erpnext/accounts/report/financial_statements.py
@@ -369,7 +369,7 @@ def set_gl_entries_by_account(
if accounts:
additional_conditions += " and account in ({})"\
- .format(", ".join([frappe.db.escape(d) for d in accounts]))
+ .format(", ".join(frappe.db.escape(d) for d in accounts))
gl_filters = {
"company": company,
diff --git a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py
index cb4d9b43db..685419a17e 100644
--- a/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py
+++ b/erpnext/accounts/report/item_wise_purchase_register/item_wise_purchase_register.py
@@ -334,7 +334,7 @@ def get_aii_accounts():
def get_purchase_receipts_against_purchase_order(item_list):
po_pr_map = frappe._dict()
- po_item_rows = list(set([d.po_detail for d in item_list]))
+ po_item_rows = list(set(d.po_detail for d in item_list))
if po_item_rows:
purchase_receipts = frappe.db.sql("""
diff --git a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py
index 928b373eff..2e794da842 100644
--- a/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py
+++ b/erpnext/accounts/report/item_wise_sales_register/item_wise_sales_register.py
@@ -23,7 +23,7 @@ def _execute(filters=None, additional_table_columns=None, additional_query_colum
if item_list:
itemised_tax, tax_columns = get_tax_accounts(item_list, columns, company_currency)
- mode_of_payments = get_mode_of_payments(set([d.parent for d in item_list]))
+ mode_of_payments = get_mode_of_payments(set(d.parent for d in item_list))
so_dn_map = get_delivery_notes_against_sales_order(item_list)
data = []
diff --git a/erpnext/accounts/report/pos_register/pos_register.py b/erpnext/accounts/report/pos_register/pos_register.py
index cfbd7fd0c8..6a42bb4fb6 100644
--- a/erpnext/accounts/report/pos_register/pos_register.py
+++ b/erpnext/accounts/report/pos_register/pos_register.py
@@ -77,14 +77,14 @@ def get_pos_entries(filters, group_by_field):
), filters, as_dict=1)
def concat_mode_of_payments(pos_entries):
- mode_of_payments = get_mode_of_payments(set([d.pos_invoice for d in pos_entries]))
+ mode_of_payments = get_mode_of_payments(set(d.pos_invoice for d in pos_entries))
for entry in pos_entries:
if mode_of_payments.get(entry.pos_invoice):
entry.mode_of_payment = ", ".join(mode_of_payments.get(entry.pos_invoice, []))
def add_subtotal_row(data, group_invoices, group_by_field, group_by_value):
- grand_total = sum([d.grand_total for d in group_invoices])
- paid_amount = sum([d.paid_amount for d in group_invoices])
+ grand_total = sum(d.grand_total for d in group_invoices)
+ paid_amount = sum(d.paid_amount for d in group_invoices)
data.append({
group_by_field: group_by_value,
"grand_total": grand_total,
diff --git a/erpnext/accounts/report/purchase_register/purchase_register.py b/erpnext/accounts/report/purchase_register/purchase_register.py
index 8ac749d629..10edd41aa8 100644
--- a/erpnext/accounts/report/purchase_register/purchase_register.py
+++ b/erpnext/accounts/report/purchase_register/purchase_register.py
@@ -26,7 +26,7 @@ def _execute(filters=None, additional_table_columns=None, additional_query_colum
invoice_expense_map, invoice_tax_map = get_invoice_tax_map(invoice_list,
invoice_expense_map, expense_accounts)
invoice_po_pr_map = get_invoice_po_pr_map(invoice_list)
- suppliers = list(set([d.supplier for d in invoice_list]))
+ suppliers = list(set(d.supplier for d in invoice_list))
supplier_details = get_supplier_details(suppliers)
company_currency = frappe.get_cached_value('Company', filters.company, "default_currency")
@@ -120,13 +120,13 @@ def get_columns(invoice_list, additional_table_columns):
and docstatus = 1 and (account_head is not null and account_head != '')
and category in ('Total', 'Valuation and Total')
and parent in (%s) order by account_head""" %
- ', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]))
+ ', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list))
unrealized_profit_loss_accounts = frappe.db.sql_list("""SELECT distinct unrealized_profit_loss_account
from `tabPurchase Invoice` where docstatus = 1 and name in (%s)
and ifnull(unrealized_profit_loss_account, '') != ''
order by unrealized_profit_loss_account""" %
- ', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]))
+ ', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list))
expense_columns = [(account + ":Currency/currency:120") for account in expense_accounts]
unrealized_profit_loss_account_columns = [(account + ":Currency/currency:120") for account in unrealized_profit_loss_accounts]
@@ -208,7 +208,7 @@ def get_invoice_expense_map(invoice_list):
from `tabPurchase Invoice Item`
where parent in (%s)
group by parent, expense_account
- """ % ', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
+ """ % ', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list), as_dict=1)
invoice_expense_map = {}
for d in expense_details:
@@ -221,7 +221,7 @@ def get_internal_invoice_map(invoice_list):
unrealized_amount_details = frappe.db.sql("""SELECT name, unrealized_profit_loss_account,
base_net_total as amount from `tabPurchase Invoice` where name in (%s)
and is_internal_supplier = 1 and company = represents_company""" %
- ', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
+ ', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list), as_dict=1)
internal_invoice_map = {}
for d in unrealized_amount_details:
@@ -238,7 +238,7 @@ def get_invoice_tax_map(invoice_list, invoice_expense_map, expense_accounts):
where parent in (%s) and category in ('Total', 'Valuation and Total')
and base_tax_amount_after_discount_amount != 0
group by parent, account_head, add_deduct_tax
- """ % ', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
+ """ % ', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list), as_dict=1)
invoice_tax_map = {}
for d in tax_details:
@@ -258,7 +258,7 @@ def get_invoice_po_pr_map(invoice_list):
select parent, purchase_order, purchase_receipt, po_detail, project
from `tabPurchase Invoice Item`
where parent in (%s)
- """ % ', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
+ """ % ', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list), as_dict=1)
invoice_po_pr_map = {}
for d in pi_items:
diff --git a/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py b/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py
index c234da0fe3..ff774681a2 100644
--- a/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py
+++ b/erpnext/accounts/report/sales_payment_summary/sales_payment_summary.py
@@ -158,7 +158,7 @@ def get_sales_invoice_data(filters):
def get_mode_of_payments(filters):
mode_of_payments = {}
invoice_list = get_invoices(filters)
- invoice_list_names = ",".join(['"' + invoice['name'] + '"' for invoice in invoice_list])
+ invoice_list_names = ",".join('"' + invoice['name'] + '"' for invoice in invoice_list)
if invoice_list:
inv_mop = frappe.db.sql("""select a.owner,a.posting_date, ifnull(b.mode_of_payment, '') as mode_of_payment
from `tabSales Invoice` a, `tabSales Invoice Payment` b
@@ -197,7 +197,7 @@ def get_invoices(filters):
def get_mode_of_payment_details(filters):
mode_of_payment_details = {}
invoice_list = get_invoices(filters)
- invoice_list_names = ",".join(['"' + invoice['name'] + '"' for invoice in invoice_list])
+ invoice_list_names = ",".join('"' + invoice['name'] + '"' for invoice in invoice_list)
if invoice_list:
inv_mop_detail = frappe.db.sql("""select a.owner, a.posting_date,
ifnull(b.mode_of_payment, '') as mode_of_payment, sum(b.base_amount) as paid_amount
diff --git a/erpnext/accounts/report/sales_register/sales_register.py b/erpnext/accounts/report/sales_register/sales_register.py
index cb2c98b64a..909959323f 100644
--- a/erpnext/accounts/report/sales_register/sales_register.py
+++ b/erpnext/accounts/report/sales_register/sales_register.py
@@ -248,19 +248,19 @@ def get_columns(invoice_list, additional_table_columns):
income_accounts = frappe.db.sql_list("""select distinct income_account
from `tabSales Invoice Item` where docstatus = 1 and parent in (%s)
order by income_account""" %
- ', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]))
+ ', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list))
tax_accounts = frappe.db.sql_list("""select distinct account_head
from `tabSales Taxes and Charges` where parenttype = 'Sales Invoice'
and docstatus = 1 and base_tax_amount_after_discount_amount != 0
and parent in (%s) order by account_head""" %
- ', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]))
+ ', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list))
unrealized_profit_loss_accounts = frappe.db.sql_list("""SELECT distinct unrealized_profit_loss_account
from `tabSales Invoice` where docstatus = 1 and name in (%s)
and ifnull(unrealized_profit_loss_account, '') != ''
order by unrealized_profit_loss_account""" %
- ', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]))
+ ', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list))
for account in income_accounts:
income_columns.append({
@@ -406,7 +406,7 @@ def get_invoices(filters, additional_query_columns):
def get_invoice_income_map(invoice_list):
income_details = frappe.db.sql("""select parent, income_account, sum(base_net_amount) as amount
from `tabSales Invoice Item` where parent in (%s) group by parent, income_account""" %
- ', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
+ ', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list), as_dict=1)
invoice_income_map = {}
for d in income_details:
@@ -419,7 +419,7 @@ def get_internal_invoice_map(invoice_list):
unrealized_amount_details = frappe.db.sql("""SELECT name, unrealized_profit_loss_account,
base_net_total as amount from `tabSales Invoice` where name in (%s)
and is_internal_customer = 1 and company = represents_company""" %
- ', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
+ ', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list), as_dict=1)
internal_invoice_map = {}
for d in unrealized_amount_details:
@@ -432,7 +432,7 @@ def get_invoice_tax_map(invoice_list, invoice_income_map, income_accounts):
tax_details = frappe.db.sql("""select parent, account_head,
sum(base_tax_amount_after_discount_amount) as tax_amount
from `tabSales Taxes and Charges` where parent in (%s) group by parent, account_head""" %
- ', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
+ ', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list), as_dict=1)
invoice_tax_map = {}
for d in tax_details:
@@ -451,7 +451,7 @@ def get_invoice_so_dn_map(invoice_list):
si_items = frappe.db.sql("""select parent, sales_order, delivery_note, so_detail
from `tabSales Invoice Item` where parent in (%s)
and (ifnull(sales_order, '') != '' or ifnull(delivery_note, '') != '')""" %
- ', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
+ ', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list), as_dict=1)
invoice_so_dn_map = {}
for d in si_items:
@@ -475,7 +475,7 @@ def get_invoice_cc_wh_map(invoice_list):
si_items = frappe.db.sql("""select parent, cost_center, warehouse
from `tabSales Invoice Item` where parent in (%s)
and (ifnull(cost_center, '') != '' or ifnull(warehouse, '') != '')""" %
- ', '.join(['%s']*len(invoice_list)), tuple([inv.name for inv in invoice_list]), as_dict=1)
+ ', '.join(['%s']*len(invoice_list)), tuple(inv.name for inv in invoice_list), as_dict=1)
invoice_cc_wh_map = {}
for d in si_items:
diff --git a/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py b/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py
index a8280c1b18..e15715dccd 100644
--- a/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py
+++ b/erpnext/accounts/report/tds_computation_summary/tds_computation_summary.py
@@ -78,7 +78,7 @@ def get_invoice_and_tds_amount(supplier, account, company, from_date, to_date, f
and company=%s and posting_date between %s and %s
""", (supplier, company, from_date, to_date), as_dict=1)
- supplier_credit_amount = flt(sum([d.credit for d in entries]))
+ supplier_credit_amount = flt(sum(d.credit for d in entries))
vouchers = [d.voucher_no for d in entries]
vouchers += get_advance_vouchers([supplier], company=company,
@@ -91,7 +91,7 @@ def get_invoice_and_tds_amount(supplier, account, company, from_date, to_date, f
from `tabGL Entry`
where account=%s and posting_date between %s and %s
and company=%s and credit > 0 and voucher_no in ({0})
- """.format(', '.join(["'%s'" % d for d in vouchers])),
+ """.format(', '.join("'%s'" % d for d in vouchers)),
(account, from_date, to_date, company))[0][0])
date_range_filter = [fiscal_year, from_date, to_date]
diff --git a/erpnext/accounts/report/tds_payable_monthly/tds_payable_monthly.js b/erpnext/accounts/report/tds_payable_monthly/tds_payable_monthly.js
index 344539eef6..72de318a48 100644
--- a/erpnext/accounts/report/tds_payable_monthly/tds_payable_monthly.js
+++ b/erpnext/accounts/report/tds_payable_monthly/tds_payable_monthly.js
@@ -54,6 +54,32 @@ frappe.query_reports["TDS Payable Monthly"] = {
frappe.query_report.refresh();
}
},
+ {
+ "fieldname":"purchase_order",
+ "label": __("Purchase Order"),
+ "fieldtype": "Link",
+ "options": "Purchase Order",
+ "get_query": function() {
+ return {
+ "filters": {
+ "name": ["in", frappe.query_report.invoices]
+ }
+ }
+ },
+ on_change: function() {
+ let supplier = frappe.query_report.get_filter_value('supplier');
+ if(!supplier) return; // return if no supplier selected
+
+ // filter invoices based on selected supplier
+ let invoices = [];
+ frappe.query_report.invoice_data.map(d => {
+ if(d.supplier==supplier)
+ invoices.push(d.name)
+ });
+ frappe.query_report.invoices = invoices;
+ frappe.query_report.refresh();
+ }
+ },
{
"fieldname":"from_date",
"label": __("From Date"),
@@ -75,15 +101,17 @@ frappe.query_reports["TDS Payable Monthly"] = {
onload: function(report) {
// fetch all tds applied invoices
frappe.call({
- "method": "erpnext.accounts.report.tds_payable_monthly.tds_payable_monthly.get_tds_invoices",
+ "method": "erpnext.accounts.report.tds_payable_monthly.tds_payable_monthly.get_tds_invoices_and_orders",
callback: function(r) {
let invoices = [];
+
r.message.map(d => {
invoices.push(d.name);
});
- report["invoice_data"] = r.message;
+ report["invoice_data"] = r.message.invoices;
report["invoices"] = invoices;
+
}
});
}
diff --git a/erpnext/accounts/report/tds_payable_monthly/tds_payable_monthly.py b/erpnext/accounts/report/tds_payable_monthly/tds_payable_monthly.py
index a9fb237a04..ceefa31cfa 100644
--- a/erpnext/accounts/report/tds_payable_monthly/tds_payable_monthly.py
+++ b/erpnext/accounts/report/tds_payable_monthly/tds_payable_monthly.py
@@ -11,11 +11,14 @@ def execute(filters=None):
validate_filters(filters)
set_filters(filters)
+ # TDS payment entries
+ payment_entries = get_payment_entires(filters)
+
columns = get_columns(filters)
- if not filters["invoices"]:
+ if not filters.get("invoices"):
return columns, []
- res = get_result(filters)
+ res = get_result(filters, payment_entries)
return columns, res
@@ -27,8 +30,9 @@ def validate_filters(filters):
def set_filters(filters):
invoices = []
- if not filters["invoices"]:
- filters["invoices"] = get_tds_invoices()
+ if not filters.get("invoices"):
+ filters["invoices"] = get_tds_invoices_and_orders()
+
if filters.supplier and filters.purchase_invoice:
for d in filters["invoices"]:
if d.name == filters.purchase_invoice and d.supplier == filters.supplier:
@@ -41,13 +45,29 @@ def set_filters(filters):
for d in filters["invoices"]:
if d.name == filters.purchase_invoice:
invoices.append(d)
+ elif filters.supplier and filters.purchase_order:
+ for d in filters.get("invoices"):
+ if d.name == filters.purchase_order and d.supplier == filters.supplier:
+ invoices.append(d)
+ elif filters.supplier and not filters.purchase_order:
+ for d in filters.get("invoices"):
+ if d.supplier == filters.supplier:
+ invoices.append(d)
+ elif filters.purchase_order and not filters.supplier:
+ for d in filters.get("invoices"):
+ if d.name == filters.purchase_order:
+ invoices.append(d)
filters["invoices"] = invoices if invoices else filters["invoices"]
filters.naming_series = frappe.db.get_single_value('Buying Settings', 'supp_master_name')
-def get_result(filters):
- supplier_map, tds_docs = get_supplier_map(filters)
- gle_map = get_gle_map(filters)
+ #print(filters.get('invoices'))
+
+def get_result(filters, payment_entries):
+ supplier_map, tds_docs = get_supplier_map(filters, payment_entries)
+ documents = [d.get('name') for d in filters.get('invoices')] + [d.get('name') for d in payment_entries]
+
+ gle_map = get_gle_map(filters, documents)
out = []
for d in gle_map:
@@ -62,10 +82,11 @@ def get_result(filters):
for k in gle_map[d]:
if k.party == supplier_map[d] and k.credit > 0:
- total_amount_credited += k.credit
- elif account_list and k.account == account and k.credit > 0:
- tds_deducted = k.credit
- total_amount_credited += k.credit
+ total_amount_credited += (k.credit - k.debit)
+ elif account_list and k.account == account and (k.credit - k.debit) > 0:
+ tds_deducted = (k.credit - k.debit)
+ total_amount_credited += (k.credit - k.debit)
+ voucher_type = k.voucher_type
rate = [i.tax_withholding_rate for i in tds_doc.rates
if i.fiscal_year == gle_map[d][0].fiscal_year]
@@ -73,32 +94,36 @@ def get_result(filters):
if rate and len(rate) > 0 and tds_deducted:
rate = rate[0]
- if getdate(filters.from_date) <= gle_map[d][0].posting_date \
- and getdate(filters.to_date) >= gle_map[d][0].posting_date:
- row = [supplier.pan, supplier.name]
+ row = [supplier.pan, supplier.name]
- if filters.naming_series == 'Naming Series':
- row.append(supplier.supplier_name)
+ if filters.naming_series == 'Naming Series':
+ row.append(supplier.supplier_name)
- row.extend([tds_doc.name, supplier.supplier_type, rate, total_amount_credited,
- tds_deducted, gle_map[d][0].posting_date, "Purchase Invoice", d])
- out.append(row)
+ row.extend([tds_doc.name, supplier.supplier_type, rate, total_amount_credited,
+ tds_deducted, gle_map[d][0].posting_date, voucher_type, d])
+ out.append(row)
return out
-def get_supplier_map(filters):
+def get_supplier_map(filters, payment_entries):
# create a supplier_map of the form {"purchase_invoice": {supplier_name, pan, tds_name}}
# pre-fetch all distinct applicable tds docs
supplier_map, tds_docs = {}, {}
pan = "pan" if frappe.db.has_column("Supplier", "pan") else "tax_id"
+ supplier_list = [d.supplier for d in filters["invoices"]]
+
supplier_detail = frappe.db.get_all('Supplier',
- {"name": ["in", [d.supplier for d in filters["invoices"]]]},
+ {"name": ["in", supplier_list]},
["tax_withholding_category", "name", pan+" as pan", "supplier_type", "supplier_name"])
for d in filters["invoices"]:
supplier_map[d.get("name")] = [k for k in supplier_detail
if k.name == d.get("supplier")][0]
+ for d in payment_entries:
+ supplier_map[d.get("name")] = [k for k in supplier_detail
+ if k.name == d.get("supplier")][0]
+
for d in supplier_detail:
if d.get("tax_withholding_category") not in tds_docs:
tds_docs[d.get("tax_withholding_category")] = \
@@ -106,13 +131,19 @@ def get_supplier_map(filters):
return supplier_map, tds_docs
-def get_gle_map(filters):
+def get_gle_map(filters, documents):
# create gle_map of the form
# {"purchase_invoice": list of dict of all gle created for this invoice}
gle_map = {}
- gle = frappe.db.get_all('GL Entry',\
- {"voucher_no": ["in", [d.get("name") for d in filters["invoices"]]], 'is_cancelled': 0},
- ["fiscal_year", "credit", "debit", "account", "voucher_no", "posting_date"])
+
+ gle = frappe.db.get_all('GL Entry',
+ {
+ "voucher_no": ["in", documents],
+ 'is_cancelled': 0,
+ 'posting_date': ("between", [filters.get('from_date'), filters.get('to_date')]),
+ },
+ ["fiscal_year", "credit", "debit", "account", "voucher_no", "posting_date", "voucher_type"],
+ )
for d in gle:
if not d.voucher_no in gle_map:
@@ -201,8 +232,26 @@ def get_columns(filters):
return columns
+def get_payment_entires(filters):
+ filter_dict = {
+ 'posting_date': ("between", [filters.get('from_date'), filters.get('to_date')]),
+ 'party_type': 'Supplier',
+ 'apply_tax_withholding_amount': 1
+ }
+
+ if filters.get('purchase_invoice') or filters.get('purchase_order'):
+ parent = frappe.db.get_all('Payment Entry Reference',
+ {'reference_name': ('in', [d.get('name') for d in filters.get('invoices')])}, ['parent'])
+
+ filter_dict.update({'name': ('in', [d.get('parent') for d in parent])})
+
+ payment_entries = frappe.get_all('Payment Entry', fields=['name', 'party_name as supplier'],
+ filters=filter_dict)
+
+ return payment_entries
+
@frappe.whitelist()
-def get_tds_invoices():
+def get_tds_invoices_and_orders():
# fetch tds applicable supplier and fetch invoices for these suppliers
suppliers = [d.name for d in frappe.db.get_list("Supplier",
{"tax_withholding_category": ["!=", ""]}, ["name"])]
@@ -210,7 +259,12 @@ def get_tds_invoices():
invoices = frappe.db.get_list("Purchase Invoice",
{"supplier": ["in", suppliers]}, ["name", "supplier"])
+ orders = frappe.db.get_list("Purchase Order",
+ {"supplier": ["in", suppliers]}, ["name", "supplier"])
+
+ invoices = invoices + orders
invoices = [d for d in invoices if d.supplier]
+
frappe.cache().hset("invoices", frappe.session.user, invoices)
return invoices
diff --git a/erpnext/accounts/report/utils.py b/erpnext/accounts/report/utils.py
index b020d0a506..ba461edaf8 100644
--- a/erpnext/accounts/report/utils.py
+++ b/erpnext/accounts/report/utils.py
@@ -139,6 +139,6 @@ def get_invoiced_item_gross_margin(sales_invoice=None, item_code=None, company=N
gross_profit_data = GrossProfitGenerator(filters)
result = gross_profit_data.grouped_data
if not with_item_data:
- result = sum([d.gross_profit for d in result])
+ result = sum(d.gross_profit for d in result)
return result
diff --git a/erpnext/accounts/utils.py b/erpnext/accounts/utils.py
index 5a64e27ccb..66a9b60125 100644
--- a/erpnext/accounts/utils.py
+++ b/erpnext/accounts/utils.py
@@ -635,7 +635,7 @@ def get_held_invoices(party_type, party):
'select name from `tabPurchase Invoice` where release_date IS NOT NULL and release_date > CURDATE()',
as_dict=1
)
- held_invoices = set([d['name'] for d in held_invoices])
+ held_invoices = set(d['name'] for d in held_invoices)
return held_invoices
diff --git a/erpnext/accounts/workspace/accounting/accounting.json b/erpnext/accounts/workspace/accounting/accounting.json
index df68318052..10a4001502 100644
--- a/erpnext/accounts/workspace/accounting/accounting.json
+++ b/erpnext/accounts/workspace/accounting/accounting.json
@@ -445,15 +445,15 @@
"type": "Link"
},
{
- "dependencies": "GL Entry",
- "hidden": 0,
- "is_query_report": 1,
- "label": "UAE VAT 201",
- "link_to": "UAE VAT 201",
- "link_type": "Report",
- "onboard": 0,
- "type": "Link"
- },
+ "dependencies": "GL Entry",
+ "hidden": 0,
+ "is_query_report": 1,
+ "label": "UAE VAT 201",
+ "link_to": "UAE VAT 201",
+ "link_type": "Report",
+ "onboard": 0,
+ "type": "Link"
+ },
{
"hidden": 0,
"is_query_report": 0,
@@ -684,6 +684,7 @@
"is_query_report": 0,
"label": "Goods and Services Tax (GST India)",
"onboard": 0,
+ "only_for": "India",
"type": "Card Break"
},
{
@@ -694,6 +695,7 @@
"link_to": "GST Settings",
"link_type": "DocType",
"onboard": 0,
+ "only_for": "India",
"type": "Link"
},
{
@@ -704,6 +706,7 @@
"link_to": "GST HSN Code",
"link_type": "DocType",
"onboard": 0,
+ "only_for": "India",
"type": "Link"
},
{
@@ -714,6 +717,7 @@
"link_to": "GSTR-1",
"link_type": "Report",
"onboard": 0,
+ "only_for": "India",
"type": "Link"
},
{
@@ -724,6 +728,7 @@
"link_to": "GSTR-2",
"link_type": "Report",
"onboard": 0,
+ "only_for": "India",
"type": "Link"
},
{
@@ -734,6 +739,7 @@
"link_to": "GSTR 3B Report",
"link_type": "DocType",
"onboard": 0,
+ "only_for": "India",
"type": "Link"
},
{
@@ -744,6 +750,7 @@
"link_to": "GST Sales Register",
"link_type": "Report",
"onboard": 0,
+ "only_for": "India",
"type": "Link"
},
{
@@ -754,6 +761,7 @@
"link_to": "GST Purchase Register",
"link_type": "Report",
"onboard": 0,
+ "only_for": "India",
"type": "Link"
},
{
@@ -764,6 +772,7 @@
"link_to": "GST Itemised Sales Register",
"link_type": "Report",
"onboard": 0,
+ "only_for": "India",
"type": "Link"
},
{
@@ -774,6 +783,7 @@
"link_to": "GST Itemised Purchase Register",
"link_type": "Report",
"onboard": 0,
+ "only_for": "India",
"type": "Link"
},
{
@@ -784,6 +794,7 @@
"link_to": "C-Form",
"link_type": "DocType",
"onboard": 0,
+ "only_for": "India",
"type": "Link"
},
{
@@ -794,6 +805,7 @@
"link_to": "Lower Deduction Certificate",
"link_type": "DocType",
"onboard": 0,
+ "only_for": "India",
"type": "Link"
},
{
@@ -1052,7 +1064,7 @@
"type": "Link"
}
],
- "modified": "2021-05-12 11:48:01.905144",
+ "modified": "2021-06-10 03:17:31.427945",
"modified_by": "Administrator",
"module": "Accounts",
"name": "Accounting",
@@ -1107,4 +1119,4 @@
"type": "Dashboard"
}
]
-}
+}
\ No newline at end of file
diff --git a/erpnext/assets/doctype/asset/test_asset.py b/erpnext/assets/doctype/asset/test_asset.py
index 3cd4b802c1..8845f24d10 100644
--- a/erpnext/assets/doctype/asset/test_asset.py
+++ b/erpnext/assets/doctype/asset/test_asset.py
@@ -470,7 +470,7 @@ class TestAsset(unittest.TestCase):
})
asset.insert()
accumulated_depreciation_after_full_schedule = \
- max([d.accumulated_depreciation_amount for d in asset.get("schedules")])
+ max(d.accumulated_depreciation_amount for d in asset.get("schedules"))
asset_value_after_full_schedule = (flt(asset.gross_purchase_amount) -
flt(accumulated_depreciation_after_full_schedule))
diff --git a/erpnext/assets/doctype/asset_value_adjustment/asset_value_adjustment.py b/erpnext/assets/doctype/asset_value_adjustment/asset_value_adjustment.py
index 14308277c1..2f6b5ee2dc 100644
--- a/erpnext/assets/doctype/asset_value_adjustment/asset_value_adjustment.py
+++ b/erpnext/assets/doctype/asset_value_adjustment/asset_value_adjustment.py
@@ -92,7 +92,7 @@ class AssetValueAdjustment(Document):
d.value_after_depreciation = asset_value
if d.depreciation_method in ("Straight Line", "Manual"):
- end_date = max([s.schedule_date for s in asset.schedules if cint(s.finance_book_id) == d.idx])
+ end_date = max(s.schedule_date for s in asset.schedules if cint(s.finance_book_id) == d.idx)
total_days = date_diff(end_date, self.date)
rate_per_day = flt(d.value_after_depreciation) / flt(total_days)
from_date = self.date
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.js b/erpnext/buying/doctype/purchase_order/purchase_order.js
index dd0f065848..0f6d927b36 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.js
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.js
@@ -45,6 +45,14 @@ frappe.ui.form.on("Purchase Order", {
});
erpnext.accounts.dimensions.setup_dimension_filters(frm, frm.doctype);
+ },
+
+ apply_tds: function(frm) {
+ if (!frm.doc.apply_tds) {
+ frm.set_value("tax_withholding_category", '');
+ } else {
+ frm.set_value("tax_withholding_category", frm.supplier_tds);
+ }
}
});
@@ -313,7 +321,8 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
if(me.values) {
me.values.sub_con_rm_items.map((row,i) => {
if (!row.item_code || !row.rm_item_code || !row.warehouse || !row.qty || row.qty === 0) {
- frappe.throw(__("Item Code, warehouse, quantity are required on row {0}", [i+1]));
+ let row_id = i+1;
+ frappe.throw(__("Item Code, warehouse and quantity are required on row {0}", [row_id]));
}
})
me._make_rm_stock_entry(me.dialog.fields_dict.sub_con_rm_items.grid.get_selected_children())
@@ -509,7 +518,7 @@ erpnext.buying.PurchaseOrderController = erpnext.buying.BuyingController.extend(
args: {
reference_doctype: me.frm.doctype,
reference_name: me.frm.docname,
- content: __('Reason for hold: ')+data.reason_for_hold,
+ content: __('Reason for hold:') + " " +data.reason_for_hold,
comment_email: frappe.session.user,
comment_by: frappe.session.user_fullname
},
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.json b/erpnext/buying/doctype/purchase_order/purchase_order.json
index 8677c71bc5..41668c6291 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.json
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.json
@@ -14,6 +14,8 @@
"supplier",
"get_items_from_open_material_requests",
"supplier_name",
+ "apply_tds",
+ "tax_withholding_category",
"column_break1",
"company",
"transaction_date",
@@ -142,7 +144,9 @@
{
"fieldname": "supplier_section",
"fieldtype": "Section Break",
- "options": "fa fa-user"
+ "options": "fa fa-user",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
@@ -152,7 +156,9 @@
"hidden": 1,
"label": "Title",
"no_copy": 1,
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "naming_series",
@@ -164,7 +170,9 @@
"options": "PUR-ORD-.YYYY.-",
"print_hide": 1,
"reqd": 1,
- "set_only_once": 1
+ "set_only_once": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"bold": 1,
@@ -178,14 +186,18 @@
"options": "Supplier",
"print_hide": 1,
"reqd": 1,
- "search_index": 1
+ "search_index": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "eval:doc.supplier && doc.docstatus===0 && (!(doc.items && doc.items.length) || (doc.items.length==1 && !doc.items[0].item_code))",
"description": "Fetch items based on Default Supplier.",
"fieldname": "get_items_from_open_material_requests",
"fieldtype": "Button",
- "label": "Get Items from Open Material Requests"
+ "label": "Get Items from Open Material Requests",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"bold": 1,
@@ -194,7 +206,9 @@
"fieldtype": "Data",
"in_global_search": 1,
"label": "Supplier Name",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "company",
@@ -206,13 +220,17 @@
"options": "Company",
"print_hide": 1,
"remember_last_selected_value": 1,
- "reqd": 1
+ "reqd": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break1",
"fieldtype": "Column Break",
"oldfieldtype": "Column Break",
"print_width": "50%",
+ "show_days": 1,
+ "show_seconds": 1,
"width": "50%"
},
{
@@ -224,27 +242,35 @@
"oldfieldname": "transaction_date",
"oldfieldtype": "Date",
"reqd": 1,
- "search_index": 1
+ "search_index": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
"fieldname": "schedule_date",
"fieldtype": "Date",
- "label": "Required By"
+ "label": "Required By",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
"depends_on": "eval:doc.docstatus===1",
"fieldname": "order_confirmation_no",
"fieldtype": "Data",
- "label": "Order Confirmation No"
+ "label": "Order Confirmation No",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
"depends_on": "eval:doc.order_confirmation_no",
"fieldname": "order_confirmation_date",
"fieldtype": "Date",
- "label": "Order Confirmation Date"
+ "label": "Order Confirmation Date",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "amended_from",
@@ -256,19 +282,25 @@
"oldfieldtype": "Data",
"options": "Purchase Order",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "drop_ship",
"fieldtype": "Section Break",
- "label": "Drop Ship"
+ "label": "Drop Ship",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "customer",
"fieldtype": "Link",
"label": "Customer",
"options": "Customer",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"bold": 1,
@@ -276,31 +308,41 @@
"fieldtype": "Data",
"label": "Customer Name",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_19",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "customer_contact_person",
"fieldtype": "Link",
"label": "Customer Contact",
- "options": "Contact"
+ "options": "Contact",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "customer_contact_display",
"fieldtype": "Small Text",
"hidden": 1,
"label": "Customer Contact",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "customer_contact_mobile",
"fieldtype": "Small Text",
"hidden": 1,
"label": "Customer Mobile No",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "customer_contact_email",
@@ -308,27 +350,35 @@
"hidden": 1,
"label": "Customer Contact Email",
"options": "Email",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"fieldname": "section_addresses",
"fieldtype": "Section Break",
- "label": "Address and Contact"
+ "label": "Address and Contact",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "supplier_address",
"fieldtype": "Link",
"label": "Supplier Address",
"options": "Address",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "contact_person",
"fieldtype": "Link",
"label": "Supplier Contact",
"options": "Contact",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "address_display",
@@ -355,32 +405,42 @@
"label": "Contact Email",
"options": "Email",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "col_break_address",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "shipping_address",
"fieldtype": "Link",
"label": "Company Shipping Address",
"options": "Address",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "shipping_address_display",
"fieldtype": "Small Text",
"label": "Shipping Address Details",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"fieldname": "currency_and_price_list",
"fieldtype": "Section Break",
"label": "Currency and Price List",
- "options": "fa fa-tag"
+ "options": "fa fa-tag",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "currency",
@@ -390,7 +450,9 @@
"oldfieldtype": "Select",
"options": "Currency",
"print_hide": 1,
- "reqd": 1
+ "reqd": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "conversion_rate",
@@ -400,18 +462,24 @@
"oldfieldtype": "Currency",
"precision": "9",
"print_hide": 1,
- "reqd": 1
+ "reqd": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "cb_price_list",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "buying_price_list",
"fieldtype": "Link",
"label": "Price List",
"options": "Price List",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "price_list_currency",
@@ -419,14 +487,18 @@
"label": "Price List Currency",
"options": "Currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "plc_conversion_rate",
"fieldtype": "Float",
"label": "Price List Exchange Rate",
"precision": "9",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "0",
@@ -435,7 +507,9 @@
"label": "Ignore Pricing Rule",
"no_copy": 1,
"permlevel": 1,
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "sec_warehouse",
@@ -448,11 +522,15 @@
"fieldtype": "Link",
"label": "Set Target Warehouse",
"options": "Warehouse",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "col_break_warehouse",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "No",
@@ -461,26 +539,34 @@
"in_standard_filter": 1,
"label": "Supply Raw Materials",
"options": "No\nYes",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "eval:doc.is_subcontracted==\"Yes\"",
"fieldname": "supplier_warehouse",
"fieldtype": "Link",
"label": "Supplier Warehouse",
- "options": "Warehouse"
+ "options": "Warehouse",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "items_section",
"fieldtype": "Section Break",
"hide_border": 1,
"oldfieldtype": "Section Break",
- "options": "fa fa-shopping-cart"
+ "options": "fa fa-shopping-cart",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "scan_barcode",
"fieldtype": "Data",
- "label": "Scan Barcode"
+ "label": "Scan Barcode",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_bulk_edit": 1,
@@ -490,26 +576,34 @@
"oldfieldname": "po_details",
"oldfieldtype": "Table",
"options": "Purchase Order Item",
- "reqd": 1
+ "reqd": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"fieldname": "section_break_48",
"fieldtype": "Section Break",
- "label": "Pricing Rules"
+ "label": "Pricing Rules",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "pricing_rules",
"fieldtype": "Table",
"label": "Purchase Order Pricing Rule",
"options": "Pricing Rule Detail",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible_depends_on": "supplied_items",
"fieldname": "raw_material_details",
"fieldtype": "Section Break",
- "label": "Raw Materials Supplied"
+ "label": "Raw Materials Supplied",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "supplied_items",
@@ -519,17 +613,23 @@
"oldfieldtype": "Table",
"options": "Purchase Order Item Supplied",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "sb_last_purchase",
- "fieldtype": "Section Break"
+ "fieldtype": "Section Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "total_qty",
"fieldtype": "Float",
"label": "Total Quantity",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_total",
@@ -537,7 +637,9 @@
"label": "Total (Company Currency)",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_net_total",
@@ -548,18 +650,24 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_26",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "total",
"fieldtype": "Currency",
"label": "Total",
"options": "currency",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "net_total",
@@ -569,20 +677,26 @@
"oldfieldtype": "Currency",
"options": "currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "total_net_weight",
"fieldtype": "Float",
"label": "Total Net Weight",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "taxes_section",
"fieldtype": "Section Break",
"oldfieldtype": "Section Break",
- "options": "fa fa-money"
+ "options": "fa fa-money",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "taxes_and_charges",
@@ -591,18 +705,24 @@
"oldfieldname": "purchase_other_charges",
"oldfieldtype": "Link",
"options": "Purchase Taxes and Charges Template",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_50",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "shipping_rule",
"fieldtype": "Link",
"label": "Shipping Rule",
"options": "Shipping Rule",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "section_break_52",
@@ -615,13 +735,17 @@
"label": "Purchase Taxes and Charges",
"oldfieldname": "purchase_tax_details",
"oldfieldtype": "Table",
- "options": "Purchase Taxes and Charges"
+ "options": "Purchase Taxes and Charges",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"fieldname": "sec_tax_breakup",
"fieldtype": "Section Break",
- "label": "Tax Breakup"
+ "label": "Tax Breakup",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "other_charges_calculation",
@@ -630,14 +754,18 @@
"no_copy": 1,
"oldfieldtype": "HTML",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "totals",
"fieldtype": "Section Break",
"label": "Taxes and Charges",
"oldfieldtype": "Section Break",
- "options": "fa fa-money"
+ "options": "fa fa-money",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "base_taxes_and_charges_added",
@@ -648,7 +776,9 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "base_taxes_and_charges_deducted",
@@ -659,7 +789,9 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "base_total_taxes_and_charges",
@@ -671,11 +803,15 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_39",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "taxes_and_charges_added",
@@ -686,7 +822,9 @@
"oldfieldtype": "Currency",
"options": "currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "taxes_and_charges_deducted",
@@ -697,7 +835,9 @@
"oldfieldtype": "Currency",
"options": "currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "total_taxes_and_charges",
@@ -706,14 +846,18 @@
"label": "Total Taxes and Charges",
"options": "currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"collapsible_depends_on": "apply_discount_on",
"fieldname": "discount_section",
"fieldtype": "Section Break",
- "label": "Additional Discount"
+ "label": "Additional Discount",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "Grand Total",
@@ -721,7 +865,9 @@
"fieldtype": "Select",
"label": "Apply Additional Discount On",
"options": "\nGrand Total\nNet Total",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_discount_amount",
@@ -729,24 +875,32 @@
"label": "Additional Discount Amount (Company Currency)",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_45",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "additional_discount_percentage",
"fieldtype": "Float",
"label": "Additional Discount Percentage",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "discount_amount",
"fieldtype": "Currency",
"label": "Additional Discount Amount",
"options": "currency",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "totals_section",
@@ -762,7 +916,9 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "eval:!doc.disable_rounded_total",
@@ -772,7 +928,9 @@
"no_copy": 1,
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"description": "In Words will be visible once you save the Purchase Order.",
@@ -783,7 +941,9 @@
"oldfieldname": "in_words",
"oldfieldtype": "Data",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "base_rounded_total",
@@ -793,12 +953,16 @@
"oldfieldtype": "Currency",
"options": "Company:company:default_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break4",
"fieldtype": "Column Break",
- "oldfieldtype": "Column Break"
+ "oldfieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "grand_total",
@@ -808,7 +972,9 @@
"oldfieldname": "grand_total_import",
"oldfieldtype": "Currency",
"options": "currency",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "eval:!doc.disable_rounded_total",
@@ -818,20 +984,26 @@
"no_copy": 1,
"options": "currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "rounded_total",
"fieldtype": "Currency",
"label": "Rounded Total",
"options": "currency",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "0",
"fieldname": "disable_rounded_total",
"fieldtype": "Check",
- "label": "Disable Rounded Total"
+ "label": "Disable Rounded Total",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "in_words",
@@ -841,7 +1013,9 @@
"oldfieldname": "in_words_import",
"oldfieldtype": "Data",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "advance_paid",
@@ -850,19 +1024,25 @@
"no_copy": 1,
"options": "party_account_currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"fieldname": "payment_schedule_section",
"fieldtype": "Section Break",
- "label": "Payment Terms"
+ "label": "Payment Terms",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "payment_terms_template",
"fieldtype": "Link",
"label": "Payment Terms Template",
- "options": "Payment Terms Template"
+ "options": "Payment Terms Template",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "payment_schedule",
@@ -870,7 +1050,9 @@
"label": "Payment Schedule",
"no_copy": 1,
"options": "Payment Schedule",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
@@ -879,7 +1061,9 @@
"fieldtype": "Section Break",
"label": "Terms and Conditions",
"oldfieldtype": "Section Break",
- "options": "fa fa-legal"
+ "options": "fa fa-legal",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "tc_name",
@@ -888,21 +1072,27 @@
"oldfieldname": "tc_name",
"oldfieldtype": "Link",
"options": "Terms and Conditions",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "terms",
"fieldtype": "Text Editor",
"label": "Terms and Conditions",
"oldfieldname": "terms",
- "oldfieldtype": "Text Editor"
+ "oldfieldtype": "Text Editor",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"fieldname": "more_info",
"fieldtype": "Section Break",
"label": "More Information",
- "oldfieldtype": "Section Break"
+ "oldfieldtype": "Section Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"default": "Draft",
@@ -917,7 +1107,9 @@
"print_hide": 1,
"read_only": 1,
"reqd": 1,
- "search_index": 1
+ "search_index": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "ref_sq",
@@ -928,7 +1120,9 @@
"oldfieldtype": "Data",
"options": "Supplier Quotation",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "party_account_currency",
@@ -938,18 +1132,24 @@
"no_copy": 1,
"options": "Currency",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "inter_company_order_reference",
"fieldtype": "Link",
"label": "Inter Company Order Reference",
"options": "Sales Order",
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_74",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "eval:!doc.__islocal",
@@ -959,7 +1159,9 @@
"label": "% Received",
"no_copy": 1,
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "eval:!doc.__islocal",
@@ -969,7 +1171,9 @@
"label": "% Billed",
"no_copy": 1,
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
@@ -979,6 +1183,8 @@
"oldfieldtype": "Column Break",
"print_hide": 1,
"print_width": "50%",
+ "show_days": 1,
+ "show_seconds": 1,
"width": "50%"
},
{
@@ -989,7 +1195,9 @@
"oldfieldname": "letter_head",
"oldfieldtype": "Select",
"options": "Letter Head",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
@@ -1001,11 +1209,15 @@
"oldfieldtype": "Link",
"options": "Print Heading",
"print_hide": 1,
- "report_hide": 1
+ "report_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_86",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
@@ -1013,19 +1225,25 @@
"fieldname": "group_same_items",
"fieldtype": "Check",
"label": "Group same items",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "language",
"fieldtype": "Data",
"label": "Print Language",
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
"fieldname": "subscription_section",
"fieldtype": "Section Break",
- "label": "Subscription Section"
+ "label": "Subscription Section",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
@@ -1033,7 +1251,9 @@
"fieldtype": "Date",
"label": "From Date",
"no_copy": 1,
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
@@ -1041,11 +1261,15 @@
"fieldtype": "Date",
"label": "To Date",
"no_copy": 1,
- "print_hide": 1
+ "print_hide": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "column_break_97",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "auto_repeat",
@@ -1054,27 +1278,35 @@
"no_copy": 1,
"options": "Auto Repeat",
"print_hide": 1,
- "read_only": 1
+ "read_only": 1,
+ "show_days": 1,
+ "show_seconds": 1
},
{
"allow_on_submit": 1,
"depends_on": "eval: doc.auto_repeat",
"fieldname": "update_auto_repeat_reference",
"fieldtype": "Button",
- "label": "Update Auto Repeat Reference"
+ "label": "Update Auto Repeat Reference",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "tax_category",
"fieldtype": "Link",
"label": "Tax Category",
- "options": "Tax Category"
+ "options": "Tax Category",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"depends_on": "supplied_items",
"fieldname": "set_reserve_warehouse",
"fieldtype": "Link",
"label": "Set Reserve Warehouse",
- "options": "Warehouse"
+ "options": "Warehouse",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"collapsible": 1,
@@ -1084,7 +1316,9 @@
},
{
"fieldname": "column_break_75",
- "fieldtype": "Column Break"
+ "fieldtype": "Column Break",
+ "show_days": 1,
+ "show_seconds": 1
},
{
"fieldname": "billing_address",
@@ -1120,6 +1354,23 @@
"label": "Represents Company",
"options": "Company",
"read_only": 1
+ },
+ {
+ "default": "0",
+ "fieldname": "apply_tds",
+ "fieldtype": "Check",
+ "label": "Apply Tax Withholding Amount",
+ "show_days": 1,
+ "show_seconds": 1
+ },
+ {
+ "depends_on": "eval: doc.apply_tds",
+ "fieldname": "tax_withholding_category",
+ "fieldtype": "Link",
+ "label": "Tax Withholding Category",
+ "options": "Tax Withholding Category",
+ "show_days": 1,
+ "show_seconds": 1
}
],
"icon": "fa fa-file-text",
diff --git a/erpnext/buying/doctype/purchase_order/purchase_order.py b/erpnext/buying/doctype/purchase_order/purchase_order.py
index ef9372eeb6..2629ba7d61 100644
--- a/erpnext/buying/doctype/purchase_order/purchase_order.py
+++ b/erpnext/buying/doctype/purchase_order/purchase_order.py
@@ -17,6 +17,7 @@ from erpnext.accounts.party import get_party_account_currency
from six import string_types
from erpnext.stock.doctype.item.item import get_item_defaults
from erpnext.setup.doctype.item_group.item_group import get_item_group_defaults
+from erpnext.accounts.doctype.tax_withholding_category.tax_withholding_category import get_party_tax_withholding_details
from erpnext.accounts.doctype.sales_invoice.sales_invoice import validate_inter_company_party, update_linked_doc,\
unlink_inter_company_doc
@@ -39,11 +40,18 @@ class PurchaseOrder(BuyingController):
'percent_join_field': 'material_request'
}]
+ def onload(self):
+ supplier_tds = frappe.db.get_value("Supplier", self.supplier, "tax_withholding_category")
+ self.set_onload("supplier_tds", supplier_tds)
+
def validate(self):
super(PurchaseOrder, self).validate()
self.set_status()
+ # apply tax withholding only if checked and applicable
+ self.set_tax_withholding()
+
self.validate_supplier()
self.validate_schedule_date()
validate_for_items(self)
@@ -87,6 +95,33 @@ class PurchaseOrder(BuyingController):
if cint(frappe.db.get_single_value('Buying Settings', 'maintain_same_rate')):
self.validate_rate_with_reference_doc([["Supplier Quotation", "supplier_quotation", "supplier_quotation_item"]])
+ def set_tax_withholding(self):
+ if not self.apply_tds:
+ return
+
+ tax_withholding_details = get_party_tax_withholding_details(self, self.tax_withholding_category)
+
+ if not tax_withholding_details:
+ return
+
+ accounts = []
+ for d in self.taxes:
+ if d.account_head == tax_withholding_details.get("account_head"):
+ d.update(tax_withholding_details)
+ accounts.append(d.account_head)
+
+ if not accounts or tax_withholding_details.get("account_head") not in accounts:
+ self.append("taxes", tax_withholding_details)
+
+ to_remove = [d for d in self.taxes
+ if not d.tax_amount and d.account_head == tax_withholding_details.get("account_head")]
+
+ for d in to_remove:
+ self.remove(d)
+
+ # calculate totals again after applying TDS
+ self.calculate_taxes_and_totals()
+
def validate_supplier(self):
prevent_po = frappe.db.get_value("Supplier", self.supplier, 'prevent_pos')
if prevent_po:
@@ -104,7 +139,7 @@ class PurchaseOrder(BuyingController):
def validate_minimum_order_qty(self):
if not self.get("items"): return
- items = list(set([d.item_code for d in self.get("items")]))
+ items = list(set(d.item_code for d in self.get("items")))
itemwise_min_order_qty = frappe._dict(frappe.db.sql("""select name, min_order_qty
from tabItem where name in ({0})""".format(", ".join(["%s"] * len(items))), items))
@@ -291,10 +326,10 @@ class PurchaseOrder(BuyingController):
so.notify_update()
def has_drop_ship_item(self):
- return any([d.delivered_by_supplier for d in self.items])
+ return any(d.delivered_by_supplier for d in self.items)
def is_against_so(self):
- return any([d.sales_order for d in self.items if d.sales_order])
+ return any(d.sales_order for d in self.items if d.sales_order)
def set_received_qty_for_drop_ship_items(self):
for item in self.items:
diff --git a/erpnext/buying/doctype/purchase_order/test_purchase_order.py b/erpnext/buying/doctype/purchase_order/test_purchase_order.py
index aaa98f2f1f..3b9f8e9775 100644
--- a/erpnext/buying/doctype/purchase_order/test_purchase_order.py
+++ b/erpnext/buying/doctype/purchase_order/test_purchase_order.py
@@ -359,7 +359,7 @@ class TestPurchaseOrder(unittest.TestCase):
update_child_qty_rate('Purchase Order', trans_item, po.name)
po.reload()
- total_reqd_qty_after_change = sum([d.get("required_qty") for d in po.as_dict().get("supplied_items")])
+ total_reqd_qty_after_change = sum(d.get("required_qty") for d in po.as_dict().get("supplied_items"))
self.assertEqual(total_reqd_qty_after_change, 2 * total_reqd_qty)
@@ -1111,7 +1111,7 @@ def create_purchase_order(**args):
po.schedule_date = add_days(nowdate(), 1)
po.company = args.company or "_Test Company"
- po.supplier = args.customer or "_Test Supplier"
+ po.supplier = args.supplier or "_Test Supplier"
po.is_subcontracted = args.is_subcontracted or "No"
po.currency = args.currency or frappe.get_cached_value('Company', po.company, "default_currency")
po.conversion_factor = args.conversion_factor or 1
diff --git a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py
index 180ba93666..0127eb8163 100644
--- a/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py
+++ b/erpnext/buying/doctype/request_for_quotation/request_for_quotation.py
@@ -391,7 +391,7 @@ def get_item_from_material_requests_based_on_supplier(source_name, target_doc =
def get_supplier_tag():
if not frappe.cache().hget("Supplier", "Tags"):
filters = {"document_type": "Supplier"}
- tags = list(set([tag.tag for tag in frappe.get_all("Tag Link", filters=filters, fields=["tag"]) if tag]))
+ tags = list(set(tag.tag for tag in frappe.get_all("Tag Link", filters=filters, fields=["tag"]) if tag))
frappe.cache().hset("Supplier", "Tags", tags)
return frappe.cache().hget("Supplier", "Tags")
diff --git a/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/subcontracted_raw_materials_to_be_transferred.py b/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/subcontracted_raw_materials_to_be_transferred.py
index de2ae8fc73..68426abbb0 100644
--- a/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/subcontracted_raw_materials_to_be_transferred.py
+++ b/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/subcontracted_raw_materials_to_be_transferred.py
@@ -9,10 +9,10 @@ def execute(filters=None):
if filters.from_date >= filters.to_date:
frappe.msgprint(_("To Date must be greater than From Date"))
- data = []
columns = get_columns()
- get_data(data , filters)
- return columns, data
+ data = get_data(filters)
+
+ return columns, data or []
def get_columns():
return [
@@ -21,13 +21,12 @@ def get_columns():
"fieldtype": "Link",
"fieldname": "purchase_order",
"options": "Purchase Order",
- "width": 150
+ "width": 200
},
{
"label": _("Date"),
"fieldtype": "Date",
"fieldname": "date",
- "hidden": 1,
"width": 150
},
{
@@ -41,97 +40,58 @@ def get_columns():
"label": _("Item Code"),
"fieldtype": "Data",
"fieldname": "rm_item_code",
- "width": 100
+ "width": 150
},
{
"label": _("Required Quantity"),
"fieldtype": "Float",
- "fieldname": "r_qty",
- "width": 100
+ "fieldname": "reqd_qty",
+ "width": 150
},
{
"label": _("Transferred Quantity"),
"fieldtype": "Float",
- "fieldname": "t_qty",
- "width": 100
+ "fieldname": "transferred_qty",
+ "width": 200
},
{
"label": _("Pending Quantity"),
"fieldtype": "Float",
"fieldname": "p_qty",
- "width": 100
+ "width": 150
}
]
-def get_data(data, filters):
- po = get_po(filters)
- po_transferred_qty_map = frappe._dict(get_transferred_quantity([v.name for v in po]))
+def get_data(filters):
+ po_rm_item_details = get_po_items_to_supply(filters)
- sub_items = get_purchase_order_item_supplied([v.name for v in po])
+ data = []
+ for row in po_rm_item_details:
+ transferred_qty = row.get("transferred_qty") or 0
+ if transferred_qty < row.get("reqd_qty", 0):
+ pending_qty = frappe.utils.flt(row.get("reqd_qty", 0) - transferred_qty)
+ row.p_qty = pending_qty if pending_qty > 0 else 0
+ data.append(row)
- for order in po:
- for item in sub_items:
- if order.name == item.parent and order.name in po_transferred_qty_map and \
- item.required_qty != po_transferred_qty_map.get(order.name).get(item.rm_item_code):
- transferred_qty = po_transferred_qty_map.get(order.name).get(item.rm_item_code) \
- if po_transferred_qty_map.get(order.name).get(item.rm_item_code) else 0
- row ={
- 'purchase_order': item.parent,
- 'date': order.transaction_date,
- 'supplier': order.supplier,
- 'rm_item_code': item.rm_item_code,
- 'r_qty': item.required_qty,
- 't_qty':transferred_qty,
- 'p_qty':item.required_qty - transferred_qty
- }
+ return data
- data.append(row)
-
- return(data)
-
-def get_po(filters):
- record_filters = [
- ["is_subcontracted", "=", "Yes"],
- ["supplier", "=", filters.supplier],
- ["transaction_date", "<=", filters.to_date],
- ["transaction_date", ">=", filters.from_date],
- ["docstatus", "=", 1]
- ]
- return frappe.get_all("Purchase Order", filters=record_filters, fields=["name", "transaction_date", "supplier"])
-
-def get_transferred_quantity(po_name):
- stock_entries = get_stock_entry(po_name)
- stock_entries_detail = get_stock_entry_detail([v.name for v in stock_entries])
- po_transferred_qty_map = {}
-
-
- for entry in stock_entries:
- for details in stock_entries_detail:
- if details.parent == entry.name:
- details["Purchase_order"] = entry.purchase_order
- if entry.purchase_order not in po_transferred_qty_map:
- po_transferred_qty_map[entry.purchase_order] = {}
- po_transferred_qty_map[entry.purchase_order][details.item_code] = details.qty
- else:
- po_transferred_qty_map[entry.purchase_order][details.item_code] = po_transferred_qty_map[entry.purchase_order].get(details.item_code, 0) + details.qty
-
- return po_transferred_qty_map
-
-
-def get_stock_entry(po):
- return frappe.get_all("Stock Entry", filters=[
- ('purchase_order', 'IN', po),
- ('stock_entry_type', '=', 'Send to Subcontractor'),
- ('docstatus', '=', 1)
- ], fields=["name", "purchase_order"])
-
-def get_stock_entry_detail(se):
- return frappe.get_all("Stock Entry Detail", filters=[
- ["parent", "in", se]
+def get_po_items_to_supply(filters):
+ return frappe.db.get_all(
+ "Purchase Order",
+ fields=[
+ "name as purchase_order",
+ "transaction_date as date",
+ "supplier as supplier",
+ "`tabPurchase Order Item Supplied`.rm_item_code as rm_item_code",
+ "`tabPurchase Order Item Supplied`.required_qty as reqd_qty",
+ "`tabPurchase Order Item Supplied`.supplied_qty as transferred_qty"
],
- fields=["parent", "item_code", "qty"])
-
-def get_purchase_order_item_supplied(po):
- return frappe.get_all("Purchase Order Item Supplied", filters=[
- ('parent', 'IN', po)
- ], fields=['parent', 'rm_item_code', 'required_qty'])
+ filters = [
+ ["Purchase Order", "per_received", "<", "100"],
+ ["Purchase Order", "is_subcontracted", "=", "Yes"],
+ ["Purchase Order", "supplier", "=", filters.supplier],
+ ["Purchase Order", "transaction_date", "<=", filters.to_date],
+ ["Purchase Order", "transaction_date", ">=", filters.from_date],
+ ["Purchase Order", "docstatus", "=", 1]
+ ]
+ )
\ No newline at end of file
diff --git a/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/test_subcontracted_raw_materials_to_be_transferred.py b/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/test_subcontracted_raw_materials_to_be_transferred.py
index c1fc6fb82f..11ec7669b0 100644
--- a/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/test_subcontracted_raw_materials_to_be_transferred.py
+++ b/erpnext/buying/report/subcontracted_raw_materials_to_be_transferred/test_subcontracted_raw_materials_to_be_transferred.py
@@ -12,34 +12,68 @@ import json, frappe, unittest
class TestSubcontractedItemToBeTransferred(unittest.TestCase):
def test_pending_and_transferred_qty(self):
- po = create_purchase_order(item_code='_Test FG Item', is_subcontracted='Yes')
+ po = create_purchase_order(item_code='_Test FG Item', is_subcontracted='Yes', supplier_warehouse="_Test Warehouse 1 - _TC")
+
+ # Material Receipt of RMs
make_stock_entry(item_code='_Test Item', target='_Test Warehouse - _TC', qty=100, basic_rate=100)
make_stock_entry(item_code='_Test Item Home Desktop 100', target='_Test Warehouse - _TC', qty=100, basic_rate=100)
- transfer_subcontracted_raw_materials(po.name)
- col, data = execute(filters=frappe._dict({'supplier': po.supplier,
- 'from_date': frappe.utils.get_datetime(frappe.utils.add_to_date(po.transaction_date, days=-10)),
- 'to_date': frappe.utils.get_datetime(frappe.utils.add_to_date(po.transaction_date, days=10))}))
- self.assertEqual(data[0]['purchase_order'], po.name)
- self.assertIn(data[0]['rm_item_code'], ['_Test Item', '_Test Item Home Desktop 100'])
- self.assertIn(data[0]['p_qty'], [9, 18])
- self.assertIn(data[0]['t_qty'], [1, 2])
+
+ se = transfer_subcontracted_raw_materials(po)
+
+ col, data = execute(filters=frappe._dict(
+ {
+ 'supplier': po.supplier,
+ 'from_date': frappe.utils.get_datetime(frappe.utils.add_to_date(po.transaction_date, days=-10)),
+ 'to_date': frappe.utils.get_datetime(frappe.utils.add_to_date(po.transaction_date, days=10))
+ }
+ ))
+ po.reload()
+
+ po_data = [row for row in data if row.get('purchase_order') == po.name]
+
+ self.assertEqual(len(po_data), 2)
+ self.assertIn(po_data[0]['rm_item_code'], ['_Test Item', '_Test Item Home Desktop 100'])
+ self.assertIn(po_data[0]['p_qty'], [9, 18])
+ self.assertIn(po_data[0]['transferred_qty'], [1, 2])
self.assertEqual(data[1]['purchase_order'], po.name)
self.assertIn(data[1]['rm_item_code'], ['_Test Item', '_Test Item Home Desktop 100'])
self.assertIn(data[1]['p_qty'], [9, 18])
- self.assertIn(data[1]['t_qty'], [1, 2])
+ self.assertIn(data[1]['transferred_qty'], [1, 2])
+ se.cancel()
+ po.cancel()
def transfer_subcontracted_raw_materials(po):
rm_item = [
- {'item_code': '_Test Item', 'rm_item_code': '_Test Item', 'item_name': '_Test Item', 'qty': 1,
- 'warehouse': '_Test Warehouse - _TC', 'rate': 100, 'amount': 100, 'stock_uom': 'Nos'},
- {'item_code': '_Test Item Home Desktop 100', 'rm_item_code': '_Test Item Home Desktop 100', 'item_name': '_Test Item Home Desktop 100', 'qty': 2,
- 'warehouse': '_Test Warehouse - _TC', 'rate': 100, 'amount': 200, 'stock_uom': 'Nos'}]
+ {
+ 'name': po.supplied_items[0].name,
+ 'item_code': '_Test Item Home Desktop 100',
+ 'rm_item_code': '_Test Item Home Desktop 100',
+ 'item_name': '_Test Item Home Desktop 100',
+ 'qty': 2,
+ 'warehouse': '_Test Warehouse - _TC',
+ 'rate': 100,
+ 'amount': 200,
+ 'stock_uom': 'Nos'
+ },
+ {
+ 'name': po.supplied_items[1].name,
+ 'item_code': '_Test Item',
+ 'rm_item_code': '_Test Item',
+ 'item_name': '_Test Item',
+ 'qty': 1,
+ 'warehouse': '_Test Warehouse - _TC',
+ 'rate': 100,
+ 'amount': 100,
+ 'stock_uom': 'Nos'
+ }
+ ]
rm_item_string = json.dumps(rm_item)
- se = frappe.get_doc(make_rm_stock_entry(po, rm_item_string))
- se.from_warehouse = '_Test Warehouse 1 - _TC'
- se.to_warehouse = '_Test Warehouse 1 - _TC'
+ se = frappe.get_doc(make_rm_stock_entry(po.name, rm_item_string))
+ se.from_warehouse = '_Test Warehouse - _TC'
+ se.to_warehouse = '_Test Warehouse - _TC'
se.stock_entry_type = 'Send to Subcontractor'
se.save()
se.submit()
+ return se
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 401dfdf0df..7c6061defa 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -116,6 +116,8 @@ class AccountsController(TransactionBase):
if self.doctype == 'Purchase Invoice':
self.calculate_paid_amount()
+ # apply tax withholding only if checked and applicable
+ self.set_tax_withholding()
if self.doctype in ['Purchase Invoice', 'Sales Invoice']:
pos_check_field = "is_pos" if self.doctype=="Sales Invoice" else "is_paid"
@@ -608,8 +610,8 @@ class AccountsController(TransactionBase):
order_field = "purchase_order"
order_doctype = "Purchase Order"
- order_list = list(set([d.get(order_field)
- for d in self.get("items") if d.get(order_field)]))
+ order_list = list(set(d.get(order_field)
+ for d in self.get("items") if d.get(order_field)))
journal_entries = get_advance_journal_entries(party_type, party, party_account,
amount_field, order_doctype, order_list, include_unallocated)
@@ -633,8 +635,8 @@ class AccountsController(TransactionBase):
def validate_advance_entries(self):
order_field = "sales_order" if self.doctype == "Sales Invoice" else "purchase_order"
- order_list = list(set([d.get(order_field)
- for d in self.get("items") if d.get(order_field)]))
+ order_list = list(set(d.get(order_field)
+ for d in self.get("items") if d.get(order_field)))
if not order_list: return
@@ -700,6 +702,7 @@ class AccountsController(TransactionBase):
from erpnext.accounts.utils import unlink_ref_doc_from_payment_entries
if self.doctype in ["Sales Invoice", "Purchase Invoice"]:
+ self.update_allocated_advance_taxes_on_cancel()
if frappe.db.get_single_value('Accounts Settings', 'unlink_payment_on_cancellation_of_invoice'):
unlink_ref_doc_from_payment_entries(self)
@@ -707,6 +710,87 @@ class AccountsController(TransactionBase):
if frappe.db.get_single_value('Accounts Settings', 'unlink_advance_payment_on_cancelation_of_order'):
unlink_ref_doc_from_payment_entries(self)
+ def get_tax_map(self):
+ tax_map = {}
+ for tax in self.get('taxes'):
+ tax_map.setdefault(tax.account_head, 0.0)
+ tax_map[tax.account_head] += tax.tax_amount
+
+ return tax_map
+
+ def update_allocated_advance_taxes_on_cancel(self):
+ if self.get('advances'):
+ tax_accounts = [d.account_head for d in self.get('taxes')]
+ allocated_tax_map = frappe._dict(frappe.get_all('GL Entry', fields=['account', 'sum(credit - debit)'],
+ filters={'voucher_no': self.name, 'account': ('in', tax_accounts)},
+ group_by='account', as_list=1))
+
+ tax_map = self.get_tax_map()
+
+ for pe in self.get('advances'):
+ if pe.reference_type == 'Payment Entry':
+ pe = frappe.get_doc('Payment Entry', pe.reference_name)
+ for tax in pe.get('taxes'):
+ allocated_amount = tax_map.get(tax.account_head) - allocated_tax_map.get(tax.account_head)
+ if allocated_amount > tax.tax_amount:
+ allocated_amount = tax.tax_amount
+
+ if allocated_amount:
+ frappe.db.set_value('Advance Taxes and Charges', tax.name, 'allocated_amount',
+ tax.allocated_amount - allocated_amount)
+ tax_map[tax.account_head] -= allocated_amount
+ allocated_tax_map[tax.account_head] -= allocated_amount
+
+ def allocate_advance_taxes(self, gl_entries):
+ tax_map = self.get_tax_map()
+ for pe in self.get("advances"):
+ if pe.reference_type == "Payment Entry" and \
+ frappe.db.get_value('Payment Entry', pe.reference_name, 'advance_tax_account'):
+ pe = frappe.get_doc("Payment Entry", pe.reference_name)
+ for tax in pe.get("taxes"):
+ account_currency = get_account_currency(tax.account_head)
+
+ if self.doctype == "Purchase Invoice":
+ dr_or_cr = "credit" if tax.add_deduct_tax == "Add" else "debit"
+ rev_dr_cr = "debit" if tax.add_deduct_tax == "Add" else "credit"
+ else:
+ dr_or_cr = "debit" if tax.add_deduct_tax == "Add" else "credit"
+ rev_dr_cr = "credit" if tax.add_deduct_tax == "Add" else "debit"
+
+ party = self.supplier if self.doctype == "Purchase Invoice" else self.customer
+ unallocated_amount = tax.tax_amount - tax.allocated_amount
+ if tax_map.get(tax.account_head):
+ amount = tax_map.get(tax.account_head)
+ if amount < unallocated_amount:
+ unallocated_amount = amount
+
+ gl_entries.append(
+ self.get_gl_dict({
+ "account": tax.account_head,
+ "against": party,
+ dr_or_cr: unallocated_amount,
+ dr_or_cr + "_in_account_currency": unallocated_amount
+ if account_currency==self.company_currency
+ else unallocated_amount,
+ "cost_center": tax.cost_center
+ }, account_currency, item=tax))
+
+ gl_entries.append(
+ self.get_gl_dict({
+ "account": pe.advance_tax_account,
+ "against": party,
+ rev_dr_cr: unallocated_amount,
+ rev_dr_cr + "_in_account_currency": unallocated_amount
+ if account_currency==self.company_currency
+ else unallocated_amount,
+ "cost_center": tax.cost_center
+ }, account_currency, item=tax))
+
+ frappe.db.set_value("Advance Taxes and Charges", tax.name, "allocated_amount",
+ tax.allocated_amount + unallocated_amount)
+
+ tax_map[tax.account_head] -= unallocated_amount
+
def validate_multiple_billing(self, ref_dt, item_ref_dn, based_on, parentfield):
from erpnext.controllers.status_updater import get_allowance_for
item_allowance = {}
@@ -1240,7 +1324,6 @@ def get_advance_payment_entries(party_type, party, party_account, order_doctype,
return list(payment_entries_against_order) + list(unallocated_payment_entries)
-
def update_invoice_status():
# Daily update the status of the invoices
diff --git a/erpnext/controllers/buying_controller.py b/erpnext/controllers/buying_controller.py
index 3f2d3390c0..da819119b1 100644
--- a/erpnext/controllers/buying_controller.py
+++ b/erpnext/controllers/buying_controller.py
@@ -181,8 +181,8 @@ class BuyingController(StockController):
stock_and_asset_items_amount += flt(d.base_net_amount)
last_item_idx = d.idx
- total_valuation_amount = sum([flt(d.base_tax_amount_after_discount_amount) for d in self.get("taxes")
- if d.category in ["Valuation", "Valuation and Total"]])
+ total_valuation_amount = sum(flt(d.base_tax_amount_after_discount_amount) for d in self.get("taxes")
+ if d.category in ["Valuation", "Valuation and Total"])
valuation_amount_adjustment = total_valuation_amount
for i, item in enumerate(self.get("items")):
@@ -325,7 +325,7 @@ class BuyingController(StockController):
def update_raw_materials_supplied_based_on_stock_entries(self):
self.set('supplied_items', [])
- purchase_orders = set([d.purchase_order for d in self.items])
+ purchase_orders = set(d.purchase_order for d in self.items)
# qty of raw materials backflushed (for each item per purchase order)
backflushed_raw_materials_map = get_backflushed_subcontracted_raw_materials(purchase_orders)
diff --git a/erpnext/controllers/queries.py b/erpnext/controllers/queries.py
index 81ac234e70..7bd739a6ad 100644
--- a/erpnext/controllers/queries.py
+++ b/erpnext/controllers/queries.py
@@ -88,7 +88,7 @@ def customer_query(doctype, txt, searchfield, start, page_len, filters):
fields = get_fields("Customer", fields)
searchfields = frappe.get_meta("Customer").get_search_fields()
- searchfields = " or ".join([field + " like %(txt)s" for field in searchfields])
+ searchfields = " or ".join(field + " like %(txt)s" for field in searchfields)
return frappe.db.sql("""select {fields} from `tabCustomer`
where docstatus < 2
diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py
index 54156f379c..7f28289760 100644
--- a/erpnext/controllers/selling_controller.py
+++ b/erpnext/controllers/selling_controller.py
@@ -428,7 +428,7 @@ class SellingController(StockController):
self.po_no = ', '.join(list(set(x.strip() for x in ','.join(po_nos).split(','))))
def get_po_nos(self, ref_doctype, ref_fieldname, po_nos):
- doc_list = list(set([d.get(ref_fieldname) for d in self.items if d.get(ref_fieldname)]))
+ doc_list = list(set(d.get(ref_fieldname) for d in self.items if d.get(ref_fieldname)))
if doc_list:
po_nos += [d.po_no for d in frappe.get_all(ref_doctype, 'po_no', filters = {'name': ('in', doc_list)}) if d.get('po_no')]
diff --git a/erpnext/controllers/status_updater.py b/erpnext/controllers/status_updater.py
index 83d4c33140..943f7aaeb1 100644
--- a/erpnext/controllers/status_updater.py
+++ b/erpnext/controllers/status_updater.py
@@ -299,8 +299,8 @@ class StatusUpdater(Document):
args['name'] = self.get(args['percent_join_field_parent'])
self._update_percent_field(args, update_modified)
else:
- distinct_transactions = set([d.get(args['percent_join_field'])
- for d in self.get_all_children(args['source_dt'])])
+ distinct_transactions = set(d.get(args['percent_join_field'])
+ for d in self.get_all_children(args['source_dt']))
for name in distinct_transactions:
if name:
diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py
index 0da723d56e..9c29b0076b 100644
--- a/erpnext/controllers/stock_controller.py
+++ b/erpnext/controllers/stock_controller.py
@@ -313,7 +313,7 @@ class StockController(AccountsController):
def get_serialized_items(self):
serialized_items = []
- item_codes = list(set([d.item_code for d in self.get("items")]))
+ item_codes = list(set(d.item_code for d in self.get("items")))
if item_codes:
serialized_items = frappe.db.sql_list("""select name from `tabItem`
where has_serial_no=1 and name in ({})""".format(", ".join(["%s"]*len(item_codes))),
@@ -324,8 +324,8 @@ class StockController(AccountsController):
def validate_warehouse(self):
from erpnext.stock.utils import validate_disabled_warehouse, validate_warehouse_company
- warehouses = list(set([d.warehouse for d in
- self.get("items") if getattr(d, "warehouse", None)]))
+ warehouses = list(set(d.warehouse for d in
+ self.get("items") if getattr(d, "warehouse", None)))
target_warehouses = list(set([d.target_warehouse for d in
self.get("items") if getattr(d, "target_warehouse", None)]))
diff --git a/erpnext/controllers/taxes_and_totals.py b/erpnext/controllers/taxes_and_totals.py
index 9fae49482d..2bb83ea7f0 100644
--- a/erpnext/controllers/taxes_and_totals.py
+++ b/erpnext/controllers/taxes_and_totals.py
@@ -54,6 +54,7 @@ class calculate_taxes_and_totals(object):
if item.item_code and item.get('item_tax_template'):
item_doc = frappe.get_cached_doc("Item", item.item_code)
args = {
+ 'net_rate': item.net_rate or item.rate,
'tax_category': self.doc.get('tax_category'),
'posting_date': self.doc.get('posting_date'),
'bill_date': self.doc.get('bill_date'),
@@ -77,10 +78,12 @@ class calculate_taxes_and_totals(object):
taxes = _get_item_tax_template(args, item_taxes + item_group_taxes, for_validate=True)
- if item.item_tax_template not in taxes:
- frappe.throw(_("Row {0}: Invalid Item Tax Template for item {1}").format(
- item.idx, frappe.bold(item.item_code)
- ))
+ if taxes:
+ if item.item_tax_template not in taxes:
+ item.item_tax_template = taxes[0]
+ frappe.msgprint(_("Row {0}: Item Tax template updated as per validity and rate applied").format(
+ item.idx, frappe.bold(item.item_code)
+ ))
def validate_conversion_rate(self):
# validate conversion rate
@@ -375,10 +378,10 @@ class calculate_taxes_and_totals(object):
def manipulate_grand_total_for_inclusive_tax(self):
# if fully inclusive taxes and diff
- if self.doc.get("taxes") and any([cint(t.included_in_print_rate) for t in self.doc.get("taxes")]):
+ if self.doc.get("taxes") and any(cint(t.included_in_print_rate) for t in self.doc.get("taxes")):
last_tax = self.doc.get("taxes")[-1]
- non_inclusive_tax_amount = sum([flt(d.tax_amount_after_discount_amount)
- for d in self.doc.get("taxes") if not d.included_in_print_rate])
+ non_inclusive_tax_amount = sum(flt(d.tax_amount_after_discount_amount)
+ for d in self.doc.get("taxes") if not d.included_in_print_rate)
diff = self.doc.total + non_inclusive_tax_amount \
- flt(last_tax.total, last_tax.precision("total"))
@@ -518,8 +521,8 @@ class calculate_taxes_and_totals(object):
def calculate_total_advance(self):
if self.doc.docstatus < 2:
- total_allocated_amount = sum([flt(adv.allocated_amount, adv.precision("allocated_amount"))
- for adv in self.doc.get("advances")])
+ total_allocated_amount = sum(flt(adv.allocated_amount, adv.precision("allocated_amount"))
+ for adv in self.doc.get("advances"))
self.doc.total_advance = flt(total_allocated_amount, self.doc.precision("total_advance"))
@@ -619,7 +622,7 @@ class calculate_taxes_and_totals(object):
if self.doc.doctype == "Sales Invoice" \
and self.doc.paid_amount > self.doc.grand_total and not self.doc.is_return \
- and any([d.type == "Cash" for d in self.doc.payments]):
+ and any(d.type == "Cash" for d in self.doc.payments):
grand_total = self.doc.rounded_total or self.doc.grand_total
base_grand_total = self.doc.base_rounded_total or self.doc.base_grand_total
@@ -683,7 +686,6 @@ class calculate_taxes_and_totals(object):
self.calculate_paid_amount()
-
def get_itemised_tax_breakup_html(doc):
if not doc.taxes:
return
diff --git a/erpnext/controllers/tests/test_mapper.py b/erpnext/controllers/tests/test_mapper.py
index 66459fdbf8..7a4b2d3614 100644
--- a/erpnext/controllers/tests/test_mapper.py
+++ b/erpnext/controllers/tests/test_mapper.py
@@ -26,8 +26,8 @@ class TestMapper(unittest.TestCase):
# Assert that all inserted items are present in updated sales order
src_items = item_list_1 + item_list_2 + item_list_3
- self.assertEqual(set([d for d in src_items]),
- set([d.item_code for d in updated_so.items]))
+ self.assertEqual(set(d for d in src_items),
+ set(d.item_code for d in updated_so.items))
def make_quotation(self, item_list, customer):
diff --git a/erpnext/controllers/website_list_for_contact.py b/erpnext/controllers/website_list_for_contact.py
index ecf041efd1..7c072e4fad 100644
--- a/erpnext/controllers/website_list_for_contact.py
+++ b/erpnext/controllers/website_list_for_contact.py
@@ -113,7 +113,7 @@ def post_process(doctype, data):
doc.set_indicator()
doc.status_display = ", ".join(doc.status_display)
- doc.items_preview = ", ".join([d.item_name for d in doc.items if d.item_name])
+ doc.items_preview = ", ".join(d.item_name for d in doc.items if d.item_name)
result.append(doc)
return result
diff --git a/erpnext/education/doctype/assessment_result/assessment_result.js b/erpnext/education/doctype/assessment_result/assessment_result.js
index 617a873b82..c35f607a99 100644
--- a/erpnext/education/doctype/assessment_result/assessment_result.js
+++ b/erpnext/education/doctype/assessment_result/assessment_result.js
@@ -6,7 +6,8 @@ frappe.ui.form.on('Assessment Result', {
if (!frm.doc.__islocal) {
frm.trigger('setup_chart');
}
- frm.set_df_property('details', 'read_only', 1);
+
+ frm.get_field('details').grid.cannot_add_rows = true;
frm.set_query('course', function() {
return {
diff --git a/erpnext/healthcare/doctype/patient/patient.py b/erpnext/healthcare/doctype/patient/patient.py
index 789d452c07..cebcb2068e 100644
--- a/erpnext/healthcare/doctype/patient/patient.py
+++ b/erpnext/healthcare/doctype/patient/patient.py
@@ -33,21 +33,21 @@ class Patient(Document):
self.reload() # self.notify_update()
def on_update(self):
- if self.customer:
- customer = frappe.get_doc('Customer', self.customer)
- if self.customer_group:
- customer.customer_group = self.customer_group
- if self.territory:
- customer.territory = self.territory
+ if frappe.db.get_single_value('Healthcare Settings', 'link_customer_to_patient'):
+ if self.customer:
+ customer = frappe.get_doc('Customer', self.customer)
+ if self.customer_group:
+ customer.customer_group = self.customer_group
+ if self.territory:
+ customer.territory = self.territory
- customer.customer_name = self.patient_name
- customer.default_price_list = self.default_price_list
- customer.default_currency = self.default_currency
- customer.language = self.language
- customer.ignore_mandatory = True
- customer.save(ignore_permissions=True)
- else:
- if frappe.db.get_single_value('Healthcare Settings', 'link_customer_to_patient'):
+ customer.customer_name = self.patient_name
+ customer.default_price_list = self.default_price_list
+ customer.default_currency = self.default_currency
+ customer.language = self.language
+ customer.ignore_mandatory = True
+ customer.save(ignore_permissions=True)
+ else:
create_customer(self)
def set_full_name(self):
diff --git a/erpnext/manufacturing/doctype/job_card/job_card.py b/erpnext/manufacturing/doctype/job_card/job_card.py
index d764db33f8..cdc4518894 100644
--- a/erpnext/manufacturing/doctype/job_card/job_card.py
+++ b/erpnext/manufacturing/doctype/job_card/job_card.py
@@ -317,7 +317,7 @@ class JobCard(Document):
'docstatus': ('!=', 2)}, fields = 'sum(transferred_qty) as qty', group_by='operation_id')
if job_cards:
- qty = min([d.qty for d in job_cards])
+ qty = min(d.qty for d in job_cards)
doc.db_set('material_transferred_for_manufacturing', qty)
diff --git a/erpnext/patches.txt b/erpnext/patches.txt
index 93689a0ef3..ed6fefdd87 100644
--- a/erpnext/patches.txt
+++ b/erpnext/patches.txt
@@ -1,494 +1,19 @@
-execute:import unidecode # new requirement
-erpnext.patches.v8_0.move_perpetual_inventory_setting
-erpnext.patches.v8_9.set_print_zero_amount_taxes
erpnext.patches.v12_0.update_is_cancelled_field
erpnext.patches.v11_0.rename_production_order_to_work_order
erpnext.patches.v11_0.refactor_naming_series
erpnext.patches.v11_0.refactor_autoname_naming
-erpnext.patches.v10_0.rename_schools_to_education
-erpnext.patches.v4_0.validate_v3_patch
-erpnext.patches.v4_0.fix_employee_user_id
-erpnext.patches.v4_0.remove_employee_role_if_no_employee
-erpnext.patches.v4_0.update_user_properties
-erpnext.patches.v4_0.apply_user_permissions
-erpnext.patches.v4_0.move_warehouse_user_to_restrictions
-erpnext.patches.v4_0.global_defaults_to_system_settings
-erpnext.patches.v4_0.update_incharge_name_to_sales_person_in_maintenance_schedule
execute:frappe.reload_doc("accounts", "doctype", "POS Payment Method") #2020-05-28
execute:frappe.reload_doc("HR", "doctype", "HR Settings") #2020-01-16 #2020-07-24
-execute:frappe.reload_doc('stock', 'doctype', 'warehouse') # 2017-04-24
-execute:frappe.reload_doc('accounts', 'doctype', 'sales_invoice') # 2016-08-31
-execute:frappe.reload_doc('selling', 'doctype', 'sales_order') # 2014-01-29
-execute:frappe.reload_doc('selling', 'doctype', 'quotation') # 2014-01-29
-execute:frappe.reload_doc('stock', 'doctype', 'delivery_note') # 2014-01-29
-erpnext.patches.v4_0.reload_sales_print_format
-execute:frappe.reload_doc('accounts', 'doctype', 'purchase_invoice') # 2014-01-29
-execute:frappe.reload_doc('buying', 'doctype', 'purchase_order') # 2014-01-29
-execute:frappe.reload_doc('buying', 'doctype', 'supplier_quotation') # 2014-01-29
-execute:frappe.reload_doc('stock', 'doctype', 'purchase_receipt') # 2014-01-29
-execute:frappe.reload_doc('accounts', 'doctype', 'pos_setting') # 2014-01-29
-execute:frappe.reload_doc('selling', 'doctype', 'customer') # 2014-01-29
-execute:frappe.reload_doc('buying', 'doctype', 'supplier') # 2014-01-29
-execute:frappe.reload_doc('accounts', 'doctype', 'asset_category')
-execute:frappe.reload_doc('accounts', 'doctype', 'pricing_rule')
-erpnext.patches.v4_0.map_charge_to_taxes_and_charges
-execute:frappe.reload_doc('support', 'doctype', 'newsletter') # 2014-01-31
-execute:frappe.reload_doc('hr', 'doctype', 'employee') # 2014-02-03
-execute:frappe.db.sql("update tabPage set module='Core' where name='Setup'")
-erpnext.patches.v5_2.change_item_selects_to_checks
-execute:frappe.reload_doctype('Item')
-erpnext.patches.v4_0.fields_to_be_renamed
-erpnext.patches.v4_0.rename_sitemap_to_route
-erpnext.patches.v7_0.re_route #2016-06-27
-erpnext.patches.v4_0.fix_contact_address
-erpnext.patches.v4_0.customer_discount_to_pricing_rule
-execute:frappe.db.sql("""delete from `tabWebsite Item Group` where ifnull(item_group, '')=''""")
-erpnext.patches.v4_0.remove_module_home_pages
-erpnext.patches.v4_0.split_email_settings
-erpnext.patches.v4_0.import_country_codes
-erpnext.patches.v4_0.countrywise_coa
-execute:frappe.delete_doc("DocType", "MIS Control")
-execute:frappe.delete_doc("Page", "Financial Statements")
-execute:frappe.delete_doc("DocType", "Stock Ledger")
-execute:frappe.delete_doc("DocType", "Grade")
-execute:frappe.db.sql("delete from `tabWebsite Item Group` where ifnull(item_group, '')=''")
-execute:frappe.delete_doc("Print Format", "SalesInvoice")
-execute:import frappe.defaults;frappe.defaults.clear_default("price_list_currency")
-erpnext.patches.v4_0.update_account_root_type
-execute:frappe.delete_doc("Report", "Purchase In Transit")
-erpnext.patches.v4_0.new_address_template
-execute:frappe.delete_doc("DocType", "SMS Control")
-execute:frappe.delete_doc_if_exists("DocType", "Bulk SMS") #2015-08-18
-erpnext.patches.v4_0.fix_case_of_hr_module_def
-erpnext.patches.v4_0.fix_address_template
-
-# WATCHOUT: This patch reload's documents
-erpnext.patches.v4_0.reset_permissions_for_masters
-erpnext.patches.v6_20x.rename_project_name_to_project #2016-03-14
-
-erpnext.patches.v4_0.update_tax_amount_after_discount
-execute:frappe.permissions.reset_perms("GL Entry") #2014-06-09
-execute:frappe.permissions.reset_perms("Stock Ledger Entry") #2014-06-09
-erpnext.patches.v4_0.create_custom_fields_for_india_specific_fields
-erpnext.patches.v4_0.save_default_letterhead
-erpnext.patches.v4_0.update_custom_print_formats_for_renamed_fields
-erpnext.patches.v4_0.update_other_charges_in_custom_purchase_print_formats
-erpnext.patches.v4_0.create_price_list_if_missing
-execute:frappe.db.sql("update `tabItem` set end_of_life=null where end_of_life='0000-00-00'") #2014-06-16
-erpnext.patches.v4_0.update_users_report_view_settings
-erpnext.patches.v4_0.set_pricing_rule_for_buying_or_selling
-erpnext.patches.v4_1.set_outgoing_email_footer
-erpnext.patches.v4_1.fix_sales_order_delivered_status
-erpnext.patches.v4_1.fix_delivery_and_billing_status
-execute:frappe.db.sql("update `tabAccount` set root_type='Liability' where root_type='Income' and report_type='Balance Sheet'")
-execute:frappe.delete_doc("DocType", "Payment to Invoice Matching Tool") # 29-07-2014
-execute:frappe.delete_doc("DocType", "Payment to Invoice Matching Tool Detail") # 29-07-2014
-execute:frappe.delete_doc("Page", "trial-balance") #2014-07-22
-erpnext.patches.v4_2.delete_old_print_formats #2014-07-29
-erpnext.patches.v4_2.toggle_rounded_total #2014-07-30
-erpnext.patches.v4_2.fix_account_master_type
-erpnext.patches.v4_2.update_project_milestones
-erpnext.patches.v4_2.add_currency_turkish_lira #2014-08-08
-execute:frappe.delete_doc("DocType", "Landed Cost Wizard")
-erpnext.patches.v4_2.default_website_style
-erpnext.patches.v4_2.set_company_country
-erpnext.patches.v4_2.update_sales_order_invoice_field_name
-erpnext.patches.v4_2.seprate_manufacture_and_repack
-execute:frappe.delete_doc("Report", "Warehouse-Wise Stock Balance")
-execute:frappe.delete_doc("DocType", "Purchase Request")
-execute:frappe.delete_doc("DocType", "Purchase Request Item")
-erpnext.patches.v4_2.recalculate_bom_cost
-erpnext.patches.v4_2.fix_gl_entries_for_stock_transactions
erpnext.patches.v4_2.update_requested_and_ordered_qty #2021-03-31
-execute:frappe.rename_doc("DocType", "Support Ticket", "Issue", force=True)
-erpnext.patches.v4_4.make_email_accounts
-execute:frappe.delete_doc("DocType", "Contact Control")
-erpnext.patches.v4_2.discount_amount
-erpnext.patches.v4_2.reset_bom_costs
-erpnext.patches.v5_0.update_frozen_accounts_permission_role
-erpnext.patches.v5_0.update_dn_against_doc_fields
-execute:frappe.db.sql("update `tabMaterial Request` set material_request_type = 'Material Transfer' where material_request_type = 'Transfer'")
-execute:frappe.reload_doc('stock', 'doctype', 'item')
-erpnext.patches.v5_0.set_default_company_in_bom
-execute:frappe.reload_doc('crm', 'doctype', 'lead')
-execute:frappe.reload_doc('crm', 'doctype', 'opportunity')
-erpnext.patches.v5_0.rename_taxes_and_charges_master
-erpnext.patches.v5_1.sales_bom_rename
-erpnext.patches.v5_0.rename_table_fieldnames
-execute:frappe.db.sql("update `tabJournal Entry` set voucher_type='Journal Entry' where ifnull(voucher_type, '')=''")
-erpnext.patches.v5_0.is_group
-erpnext.patches.v4_2.party_model
-erpnext.patches.v5_0.party_model_patch_fix
-erpnext.patches.v4_1.fix_jv_remarks
-erpnext.patches.v4_2.update_landed_cost_voucher
-erpnext.patches.v4_2.set_item_has_batch
-erpnext.patches.v4_2.update_stock_uom_for_dn_in_sle
-erpnext.patches.v5_0.recalculate_total_amount_in_jv
-erpnext.patches.v5_0.update_companywise_payment_account
-erpnext.patches.v5_0.remove_birthday_events
-erpnext.patches.v5_0.update_item_name_in_bom
-erpnext.patches.v5_0.rename_customer_issue
-erpnext.patches.v5_0.rename_total_fields
-erpnext.patches.v5_0.new_crm_module
-erpnext.patches.v5_0.rename_customer_issue
-erpnext.patches.v5_0.update_material_transfer_for_manufacture
-execute:frappe.reload_doc('crm', 'doctype', 'opportunity_item')
-erpnext.patches.v5_0.update_item_description_and_image
-erpnext.patches.v5_0.update_material_transferred_for_manufacturing
-erpnext.patches.v5_0.stock_entry_update_value
-erpnext.patches.v5_0.convert_stock_reconciliation
-erpnext.patches.v5_0.update_projects
-erpnext.patches.v5_0.item_patches
-erpnext.patches.v5_0.update_journal_entry_title
-erpnext.patches.v5_0.taxes_and_totals_in_party_currency
-erpnext.patches.v5_0.replace_renamed_fields_in_custom_scripts_and_print_formats
-erpnext.patches.v5_0.update_from_bom
-erpnext.patches.v5_0.update_account_types
-erpnext.patches.v5_0.update_sms_sender
-erpnext.patches.v5_0.set_appraisal_remarks
-erpnext.patches.v5_0.update_time_log_title
-erpnext.patches.v7_0.create_warehouse_nestedset
-erpnext.patches.v7_0.merge_account_type_stock_and_warehouse_to_stock
-erpnext.patches.v7_0.set_is_group_for_warehouse
-erpnext.patches.v7_2.stock_uom_in_selling
-erpnext.patches.v4_2.repost_sle_for_si_with_no_warehouse
-erpnext.patches.v5_0.newsletter
-execute:frappe.delete_doc("DocType", "Chart of Accounts")
-execute:frappe.delete_doc("DocType", "Style Settings")
-erpnext.patches.v5_0.update_opportunity
-erpnext.patches.v5_0.opportunity_not_submittable
-execute:frappe.permissions.reset_perms("Purchase Taxes and Charges Template") #2014-06-09
-execute:frappe.permissions.reset_perms("Expense Claim Type") #2014-06-19
-erpnext.patches.v5_0.execute_on_doctype_update
-erpnext.patches.v4_2.fix_recurring_orders
-erpnext.patches.v4_2.delete_gl_entries_for_cancelled_invoices
-erpnext.patches.v5_0.project_costing
-erpnext.patches.v5_0.update_temporary_account
-erpnext.patches.v5_0.update_advance_paid
-erpnext.patches.v5_0.link_warehouse_with_account
-execute:frappe.delete_doc("Page", "stock-ledger")
-execute:frappe.delete_doc("Page","stock-level")
-erpnext.patches.v5_0.reclculate_planned_operating_cost_in_production_order
-erpnext.patches.v5_0.repost_requested_qty
-erpnext.patches.v5_0.fix_taxes_and_totals_in_party_currency
-erpnext.patches.v5_0.update_tax_amount_after_discount_in_purchase_cycle
-erpnext.patches.v5_0.rename_pos_setting
-erpnext.patches.v5_0.update_operation_description
-erpnext.patches.v5_0.set_footer_address
-execute:frappe.db.set_value("Backup Manager", None, "send_backups_to_dropbox", 1 if frappe.db.get_value("Backup Manager", None, "upload_backups_to_dropbox") in ("Daily", "Weekly") else 0)
-execute:frappe.db.sql_list("delete from `tabDocPerm` where parent='Issue' and modified_by='Administrator' and role='Guest'")
-erpnext.patches.v5_0.update_item_and_description_again
-erpnext.patches.v6_0.multi_currency
-erpnext.patches.v7_0.create_budget_record
-erpnext.patches.v5_0.repost_gle_for_jv_with_multiple_party
-erpnext.patches.v5_0.portal_fixes
-erpnext.patches.v5_0.reset_values_in_tools # 02-05-2016
-execute:frappe.delete_doc("Page", "users")
-erpnext.patches.v5_0.update_material_transferred_for_manufacturing_again
-erpnext.patches.v5_0.index_on_account_and_gl_entry
-execute:frappe.db.sql("""delete from `tabProject Task`""")
-erpnext.patches.v5_0.update_item_desc_in_invoice
-erpnext.patches.v5_1.fix_against_account
-execute:frappe.rename_doc("DocType", "Salary Manager", "Process Payroll", force=True)
-erpnext.patches.v5_1.rename_roles
-erpnext.patches.v5_1.default_bom
-execute:frappe.delete_doc("DocType", "Party Type")
-execute:frappe.delete_doc("Module Def", "Contacts")
-erpnext.patches.v5_4.fix_reserved_qty_and_sle_for_packed_items # 30-07-2015
-execute:frappe.reload_doctype("Leave Type")
-execute:frappe.db.sql("update `tabLeave Type` set include_holiday=0")
-erpnext.patches.v5_4.set_root_and_report_type
-erpnext.patches.v5_4.notify_system_managers_regarding_wrong_tax_calculation
-erpnext.patches.v5_4.fix_invoice_outstanding
-execute:frappe.db.sql("update `tabStock Ledger Entry` set stock_queue = '[]' where voucher_type = 'Stock Reconciliation' and ifnull(qty_after_transaction, 0) = 0")
-erpnext.patches.v5_4.fix_missing_item_images
-erpnext.patches.v5_4.stock_entry_additional_costs
-erpnext.patches.v5_4.cleanup_journal_entry #2015-08-14
erpnext.patches.v5_7.update_item_description_based_on_item_master
-erpnext.patches.v5_7.item_template_attributes
-execute:frappe.delete_doc_if_exists("DocType", "Manage Variants")
-execute:frappe.delete_doc_if_exists("DocType", "Manage Variants Item")
erpnext.patches.v4_2.repost_reserved_qty #2021-03-31
-erpnext.patches.v5_4.update_purchase_cost_against_project
-erpnext.patches.v5_8.update_order_reference_in_return_entries
-erpnext.patches.v5_8.add_credit_note_print_heading
-execute:frappe.delete_doc_if_exists("Print Format", "Credit Note - Negative Invoice")
-
-# V6.0
-erpnext.patches.v6_0.set_default_title # 2015-09-03
-erpnext.patches.v6_0.default_activity_rate
-execute:frappe.db.set_value("Stock Settings", None, "automatically_set_serial_nos_based_on_fifo", 1)
-execute:frappe.db.sql("""update `tabProject` set percent_complete=round(percent_complete, 2) where percent_complete is not null""")
-erpnext.patches.v6_0.fix_outstanding_amount
-erpnext.patches.v6_0.fix_planned_qty
-erpnext.patches.v6_2.remove_newsletter_duplicates
-erpnext.patches.v6_2.fix_missing_default_taxes_and_lead
-erpnext.patches.v6_3.convert_applicable_territory
-erpnext.patches.v6_4.round_status_updater_percentages
-erpnext.patches.v6_4.repost_gle_for_journal_entries_where_reference_name_missing
-erpnext.patches.v6_4.fix_journal_entries_due_to_reconciliation
-erpnext.patches.v6_4.fix_status_in_sales_and_purchase_order
-erpnext.patches.v6_4.fix_modified_in_sales_order_and_purchase_order
-erpnext.patches.v6_4.fix_duplicate_bins
-erpnext.patches.v6_4.fix_sales_order_maintenance_status
-erpnext.patches.v6_4.email_digest_update
-
-# delete shopping cart doctypes
-execute:frappe.delete_doc_if_exists("DocType", "Applicable Territory")
-execute:frappe.delete_doc_if_exists("DocType", "Shopping Cart Price List")
-execute:frappe.delete_doc_if_exists("DocType", "Shopping Cart Taxes and Charges Master")
-
-erpnext.patches.v6_4.set_user_in_contact
-erpnext.patches.v6_4.make_image_thumbnail #2015-10-20
-erpnext.patches.v6_5.show_in_website_for_template_item
-erpnext.patches.v6_4.fix_expense_included_in_valuation
-execute:frappe.delete_doc_if_exists("Report", "Item-wise Last Purchase Rate")
-erpnext.patches.v6_6.fix_website_image
-erpnext.patches.v6_6.remove_fiscal_year_from_leave_allocation
-execute:frappe.delete_doc_if_exists("DocType", "Stock UOM Replace Utility")
-erpnext.patches.v6_8.make_webform_standard #2015-11-23
-erpnext.patches.v6_8.move_drop_ship_to_po_items
-erpnext.patches.v6_10.fix_ordered_received_billed
-erpnext.patches.v6_10.fix_jv_total_amount #2015-11-30
-erpnext.patches.v6_10.email_digest_default_quote
-erpnext.patches.v6_10.fix_billed_amount_in_drop_ship_po
-erpnext.patches.v6_10.fix_delivery_status_of_drop_ship_item #2015-12-08
-erpnext.patches.v5_8.tax_rule #2015-12-08
-erpnext.patches.v6_12.set_overdue_tasks
-erpnext.patches.v6_16.update_billing_status_in_dn_and_pr
-erpnext.patches.v6_16.create_manufacturer_records
-execute:frappe.db.sql("update `tabPricing Rule` set title=name where title='' or title is null") #2016-01-27
-erpnext.patches.v6_20.set_party_account_currency_in_orders
-erpnext.patches.v6_19.comment_feed_communication
-erpnext.patches.v6_21.fix_reorder_level
-erpnext.patches.v6_21.rename_material_request_fields
-erpnext.patches.v6_23.update_stopped_status_to_closed
-erpnext.patches.v6_24.set_recurring_id
-erpnext.patches.v6_20x.set_compact_print
-execute:frappe.delete_doc_if_exists("Web Form", "contact") #2016-03-10
-erpnext.patches.v6_20x.remove_fiscal_year_from_holiday_list
-erpnext.patches.v6_24.map_customer_address_to_shipping_address_on_po
-erpnext.patches.v6_27.fix_recurring_order_status
-erpnext.patches.v6_20x.update_product_bundle_description
-erpnext.patches.v7_0.update_party_status #2016-09-22
-erpnext.patches.v7_0.remove_features_setup
-erpnext.patches.v7_0.update_home_page
-execute:frappe.delete_doc_if_exists("Page", "financial-analytics")
-erpnext.patches.v7_0.update_project_in_gl_entry
-execute:frappe.db.sql('update tabQuotation set status="Cancelled" where docstatus=2')
-execute:frappe.rename_doc("DocType", "Payments", "Sales Invoice Payment", force=True)
-erpnext.patches.v7_0.update_mins_to_first_response
-erpnext.patches.v6_20x.repost_valuation_rate_for_negative_inventory
-erpnext.patches.v7_0.migrate_mode_of_payments_v6_to_v7
-erpnext.patches.v7_0.system_settings_setup_complete
-erpnext.patches.v7_0.set_naming_series_for_timesheet #2016-07-27
-execute:frappe.reload_doc('projects', 'doctype', 'project')
-execute:frappe.reload_doc('projects', 'doctype', 'project_user')
-erpnext.patches.v7_0.convert_timelogbatch_to_timesheet
-erpnext.patches.v7_0.convert_timelog_to_timesheet
-erpnext.patches.v7_0.move_timelogbatch_from_salesinvoiceitem_to_salesinvoicetimesheet
-erpnext.patches.v7_0.remove_doctypes_and_reports #2016-10-29
-erpnext.patches.v7_0.update_maintenance_module_in_doctype
-erpnext.patches.v7_0.update_prevdoc_values_for_supplier_quotation_item
-erpnext.patches.v7_0.rename_advance_table_fields
-erpnext.patches.v7_0.rename_salary_components
-erpnext.patches.v7_0.rename_prevdoc_fields
-erpnext.patches.v7_0.rename_time_sheet_doctype
-execute:frappe.delete_doc_if_exists("Report", "Customers Not Buying Since Long Time")
-erpnext.patches.v7_0.make_is_group_fieldtype_as_check
-execute:frappe.reload_doc('projects', 'doctype', 'timesheet') #2016-09-12
-erpnext.patches.v7_1.rename_field_timesheet
-execute:frappe.delete_doc_if_exists("Report", "Employee Holiday Attendance")
-execute:frappe.delete_doc_if_exists("DocType", "Payment Tool")
-execute:frappe.delete_doc_if_exists("DocType", "Payment Tool Detail")
-erpnext.patches.v7_0.setup_account_table_for_expense_claim_type_if_exists
-erpnext.patches.v7_0.migrate_schools_to_erpnext
-erpnext.patches.v7_1.update_lead_source
-erpnext.patches.v6_20x.remove_customer_supplier_roles
-erpnext.patches.v7_0.remove_administrator_role_in_doctypes
-erpnext.patches.v7_0.rename_fee_amount_to_fee_component
-erpnext.patches.v7_0.calculate_total_costing_amount
-erpnext.patches.v7_0.fix_nonwarehouse_ledger_gl_entries_for_transactions
-erpnext.patches.v7_0.remove_old_earning_deduction_doctypes
-erpnext.patches.v7_0.make_guardian
-erpnext.patches.v7_0.update_refdoc_in_landed_cost_voucher
-erpnext.patches.v7_0.set_material_request_type_in_item
-erpnext.patches.v7_0.rename_examination_to_assessment
-erpnext.patches.v7_0.set_portal_settings
-erpnext.patches.v7_0.update_change_amount_account
-erpnext.patches.v7_0.fix_duplicate_icons
-erpnext.patches.v7_0.repost_gle_for_pos_sales_return
-erpnext.patches.v7_1.update_total_billing_hours
-erpnext.patches.v7_1.update_component_type
-erpnext.patches.v7_0.repost_gle_for_pos_sales_return
-erpnext.patches.v7_0.update_missing_employee_in_timesheet
-erpnext.patches.v7_0.update_status_for_timesheet
-erpnext.patches.v7_0.set_party_name_in_payment_entry
-erpnext.patches.v7_1.set_student_guardian
-erpnext.patches.v7_0.update_conversion_factor_in_supplier_quotation_item
-erpnext.patches.v7_1.move_sales_invoice_from_parent_to_child_timesheet
-execute:frappe.db.sql("update `tabTimesheet` ts, `tabEmployee` emp set ts.employee_name = emp.employee_name where emp.name = ts.employee and ts.employee_name is null and ts.employee is not null")
-erpnext.patches.v7_1.fix_link_for_customer_from_lead
-execute:frappe.db.sql("delete from `tabTimesheet Detail` where NOT EXISTS (select name from `tabTimesheet` where name = `tabTimesheet Detail`.parent)")
-erpnext.patches.v7_0.update_mode_of_payment_type
-
-execute:frappe.reload_doctype('Employee') #2016-10-18
-execute:frappe.db.sql("update `tabEmployee` set prefered_contact_email = IFNULL(prefered_contact_email,'') ")
execute:frappe.reload_doc("Payroll", "doctype", "salary_slip")
-execute:frappe.db.sql("update `tabSalary Slip` set posting_date=creation")
-execute:frappe.reload_doc("stock", "doctype", "stock_settings")
-erpnext.patches.v8_0.create_domain_docs #16-05-2017
-erpnext.patches.v7_1.update_portal_roles
-erpnext.patches.v7_1.set_total_amount_currency_in_je
-finally:erpnext.patches.v7_0.update_timesheet_communications
-erpnext.patches.v7_0.update_status_of_zero_amount_sales_order
-erpnext.patches.v7_1.add_field_for_task_dependent
-erpnext.patches.v7_0.repost_bin_qty_and_item_projected_qty
-erpnext.patches.v7_1.set_prefered_contact_email
-execute:frappe.reload_doc('accounts', 'doctype', 'accounts_settings')
-execute:frappe.db.set_value("Accounts Settings", "Accounts Settings", "unlink_payment_on_cancellation_of_invoice", 0)
-execute:frappe.db.sql("update `tabStock Entry` set total_amount = 0 where purpose in('Repack', 'Manufacture')")
-erpnext.patches.v7_1.save_stock_settings
-erpnext.patches.v7_0.repost_gle_for_pi_with_update_stock #2016-11-01
-erpnext.patches.v7_1.add_account_user_role_for_timesheet
-erpnext.patches.v7_0.set_base_amount_in_invoice_payment_table
-erpnext.patches.v7_1.update_invoice_status
-erpnext.patches.v7_0.po_status_issue_for_pr_return
-erpnext.patches.v7_1.update_missing_salary_component_type
-erpnext.patches.v7_1.rename_quality_inspection_field
-erpnext.patches.v7_0.update_autoname_field
-erpnext.patches.v7_1.update_bom_base_currency
-erpnext.patches.v7_0.update_status_of_po_so
-erpnext.patches.v7_1.set_budget_against_as_cost_center
-erpnext.patches.v7_1.set_currency_exchange_date
-erpnext.patches.v7_1.set_sales_person_status
-erpnext.patches.v7_1.repost_stock_for_deleted_bins_for_merging_items
-erpnext.patches.v7_2.update_website_for_variant
-erpnext.patches.v7_2.update_assessment_modules
-erpnext.patches.v7_2.update_doctype_status
-erpnext.patches.v7_2.update_salary_slips
-erpnext.patches.v7_2.delete_fleet_management_module_def
-erpnext.patches.v7_2.contact_address_links
-erpnext.patches.v7_2.mark_students_active
-erpnext.patches.v7_2.set_null_value_to_fields
-erpnext.patches.v7_2.update_guardian_name_in_student_master
-erpnext.patches.v7_2.update_abbr_in_salary_slips
-erpnext.patches.v7_2.rename_evaluation_criteria
-erpnext.patches.v7_2.update_party_type
-erpnext.patches.v7_2.setup_auto_close_settings
-erpnext.patches.v7_2.empty_supplied_items_for_non_subcontracted
-erpnext.patches.v7_2.arrear_leave_encashment_as_salary_component
-erpnext.patches.v7_2.rename_att_date_attendance
-erpnext.patches.v7_2.update_attendance_docstatus
-erpnext.patches.v7_2.make_all_assessment_group
-erpnext.patches.v8_0.repost_reserved_qty_for_multiple_sales_uom
-erpnext.patches.v8_0.addresses_linked_to_lead
-execute:frappe.delete_doc('DocType', 'Purchase Common')
-erpnext.patches.v8_0.update_stock_qty_value_in_purchase_invoice
-erpnext.patches.v8_0.update_supplier_address_in_stock_entry
-erpnext.patches.v8_0.rename_is_sample_item_to_allow_zero_valuation_rate
-erpnext.patches.v8_0.set_null_to_serial_nos_for_disabled_sales_invoices
-erpnext.patches.v8_0.enable_booking_asset_depreciation_automatically
-erpnext.patches.v8_0.set_project_copied_from
-erpnext.patches.v8_0.update_status_as_paid_for_completed_expense_claim
-erpnext.patches.v7_2.stock_uom_in_selling
-erpnext.patches.v8_0.revert_manufacturers_table_from_item
-erpnext.patches.v8_0.disable_instructor_role
-erpnext.patches.v8_0.merge_student_batch_and_student_group
-erpnext.patches.v8_0.rename_total_margin_to_rate_with_margin # 11-05-2017
-erpnext.patches.v8_0.fix_status_for_invoices_with_negative_outstanding
-erpnext.patches.v8_0.make_payments_table_blank_for_non_pos_invoice
-erpnext.patches.v8_0.set_sales_invoice_serial_number_from_delivery_note
-erpnext.patches.v8_0.delete_schools_depricated_doctypes
-erpnext.patches.v8_0.update_customer_pos_id
-erpnext.patches.v8_0.rename_items_in_status_field_of_material_request
-erpnext.patches.v8_0.delete_bin_indexes
-erpnext.patches.v8_0.move_account_head_from_account_to_warehouse_for_inventory
-erpnext.patches.v8_0.change_in_words_varchar_length
-erpnext.patches.v8_0.update_stock_qty_value_in_bom_item
-erpnext.patches.v8_0.update_sales_cost_in_project
-erpnext.patches.v8_0.save_system_settings
-erpnext.patches.v8_1.delete_deprecated_reports
-erpnext.patches.v9_0.remove_subscription_module
-erpnext.patches.v8_7.make_subscription_from_recurring_data
erpnext.patches.v8_1.setup_gst_india #2017-06-27
-execute:frappe.reload_doc('regional', 'doctype', 'gst_hsn_code')
erpnext.patches.v8_1.removed_roles_from_gst_report_non_indian_account #16-08-2018
-erpnext.patches.v8_1.gst_fixes #2017-07-06
-erpnext.patches.v8_0.update_production_orders
-erpnext.patches.v8_1.remove_sales_invoice_from_returned_serial_no
-erpnext.patches.v8_1.allow_invoice_copy_to_edit_after_submit
-erpnext.patches.v8_1.add_hsn_sac_codes
-erpnext.patches.v8_1.update_gst_state #17-07-2017
-erpnext.patches.v8_1.removed_report_support_hours
-erpnext.patches.v8_1.add_indexes_in_transaction_doctypes
-erpnext.patches.v8_3.set_restrict_to_domain_for_module_def
-erpnext.patches.v8_1.update_expense_claim_status
-erpnext.patches.v8_3.update_company_total_sales #2017-08-16
-erpnext.patches.v8_4.make_scorecard_records
-erpnext.patches.v8_1.set_delivery_date_in_so_item #2017-07-28
-erpnext.patches.v8_5.fix_tax_breakup_for_non_invoice_docs
-erpnext.patches.v8_5.remove_quotations_route_in_sidebar
-erpnext.patches.v8_5.update_existing_data_in_project_type
-erpnext.patches.v8_5.set_default_mode_of_payment
-erpnext.patches.v8_5.update_customer_group_in_POS_profile
-erpnext.patches.v8_6.update_timesheet_company_from_PO
-erpnext.patches.v8_6.set_write_permission_for_quotation_for_sales_manager
-erpnext.patches.v8_5.remove_project_type_property_setter
erpnext.patches.v8_7.sync_india_custom_fields
-erpnext.patches.v8_7.fix_purchase_receipt_status
-erpnext.patches.v8_6.rename_bom_update_tool
-erpnext.patches.v8_9.add_setup_progress_actions #08-09-2017 #26-09-2017 #22-11-2017 #15-12-2017
-erpnext.patches.v8_9.rename_company_sales_target_field
-erpnext.patches.v8_8.set_bom_rate_as_per_uom
-erpnext.patches.v8_8.add_new_fields_in_accounts_settings
-erpnext.patches.v8_9.set_default_customer_group
-erpnext.patches.v8_9.delete_gst_doctypes_for_outside_india_accounts
-erpnext.patches.v8_9.set_default_fields_in_variant_settings
-erpnext.patches.v8_9.update_billing_gstin_for_indian_account
-erpnext.patches.v8_9.set_member_party_type
-erpnext.patches.v9_0.add_user_to_child_table_in_pos_profile
-erpnext.patches.v9_0.set_schedule_date_for_material_request_and_purchase_order
-erpnext.patches.v9_0.student_admission_childtable_migrate
-erpnext.patches.v9_0.add_healthcare_domain
-erpnext.patches.v9_0.set_variant_item_description
-erpnext.patches.v9_0.set_uoms_in_variant_field
-erpnext.patches.v9_0.copy_old_fees_field_data
-execute:frappe.delete_doc_if_exists("DocType", "Program Fee")
-erpnext.patches.v9_0.set_pos_profile_name
-erpnext.patches.v9_0.remove_non_existing_warehouse_from_stock_settings
-execute:frappe.delete_doc_if_exists("DocType", "Program Fee")
-erpnext.patches.v8_10.change_default_customer_credit_days
-erpnext.patches.v9_0.update_employee_loan_details
-erpnext.patches.v9_2.delete_healthcare_domain_default_items
-erpnext.patches.v9_1.create_issue_opportunity_type
-erpnext.patches.v9_2.rename_translated_domains_in_en
-erpnext.patches.v9_0.set_shipping_type_for_existing_shipping_rules
-erpnext.patches.v9_0.update_multi_uom_fields_in_material_request
-erpnext.patches.v9_2.repost_reserved_qty_for_production
-erpnext.patches.v9_2.remove_company_from_patient
-erpnext.patches.v9_2.set_item_name_in_production_order
-erpnext.patches.v10_0.update_lft_rgt_for_employee
-erpnext.patches.v9_2.rename_net_weight_in_item_master
-erpnext.patches.v9_2.delete_process_payroll
-erpnext.patches.v10_0.add_agriculture_domain
-erpnext.patches.v10_0.add_non_profit_domain
-erpnext.patches.v10_0.setup_vat_for_uae_and_saudi_arabia #2017-12-28
-erpnext.patches.v10_0.set_primary_contact_for_customer
-erpnext.patches.v10_0.copy_projects_renamed_fields
-erpnext.patches.v10_0.enabled_regional_print_format_based_on_country
-erpnext.patches.v10_0.update_asset_calculate_depreciation
-erpnext.patches.v10_0.add_guardian_role_for_parent_portal
-erpnext.patches.v10_0.set_numeric_ranges_in_template_if_blank
-erpnext.patches.v10_0.update_reserved_qty_for_purchase_order
erpnext.patches.v10_0.fichier_des_ecritures_comptables_for_france
-erpnext.patches.v10_0.update_assessment_plan
-erpnext.patches.v10_0.update_assessment_result
-erpnext.patches.v10_0.set_default_payment_terms_based_on_company
-erpnext.patches.v10_0.update_sales_order_link_to_purchase_order
erpnext.patches.v10_0.rename_price_to_rate_in_pricing_rule
erpnext.patches.v10_0.set_currency_in_pricing_rule
-erpnext.patches.v10_0.set_b2c_limit
erpnext.patches.v10_0.update_translatable_fields
erpnext.patches.v10_0.rename_offer_letter_to_job_offer
execute:frappe.delete_doc('DocType', 'Production Planning Tool', ignore_missing=True)
@@ -496,16 +21,6 @@ erpnext.patches.v10_0.migrate_daily_work_summary_settings_to_daily_work_summary_
erpnext.patches.v10_0.add_default_cash_flow_mappers
erpnext.patches.v11_0.rename_duplicate_item_code_values
erpnext.patches.v11_0.make_quality_inspection_template
-erpnext.patches.v10_0.update_status_for_multiple_source_in_po
-erpnext.patches.v10_0.set_auto_created_serial_no_in_stock_entry
-erpnext.patches.v10_0.update_territory_and_customer_group
-erpnext.patches.v10_0.update_warehouse_address_details
-erpnext.patches.v10_0.update_reserved_qty_for_purchase_order
-erpnext.patches.v10_0.update_hub_connector_domain
-erpnext.patches.v10_0.set_student_party_type
-erpnext.patches.v10_0.update_project_in_sle
-erpnext.patches.v10_0.fix_reserved_qty_for_sub_contract
-erpnext.patches.v10_0.repost_requested_qty_for_non_stock_uom_items
erpnext.patches.v11_0.merge_land_unit_with_location
erpnext.patches.v11_0.add_index_on_nestedset_doctypes
erpnext.patches.v11_0.remove_modules_setup_page
@@ -514,7 +29,6 @@ erpnext.patches.v11_0.update_department_lft_rgt
erpnext.patches.v11_0.add_default_email_template_for_leave
erpnext.patches.v11_0.set_default_email_template_in_hr #08-06-2018
erpnext.patches.v11_0.uom_conversion_data #30-06-2018
-erpnext.patches.v10_0.taxes_issue_with_pos
erpnext.patches.v11_0.update_account_type_in_party_type
erpnext.patches.v11_0.rename_healthcare_doctype_and_fields
erpnext.patches.v11_0.rename_supplier_type_to_supplier_group
@@ -522,8 +36,6 @@ erpnext.patches.v10_1.transfer_subscription_to_auto_repeat
erpnext.patches.v11_0.update_brand_in_item_price
erpnext.patches.v11_0.create_default_success_action
erpnext.patches.v11_0.add_healthcare_service_unit_tree_root
-erpnext.patches.v10_0.set_qty_in_transactions_based_on_serial_no_input
-erpnext.patches.v10_0.show_leaves_of_all_department_members_in_calendar
erpnext.patches.v11_0.rename_field_max_days_allowed
erpnext.patches.v11_0.create_salary_structure_assignments
erpnext.patches.v11_0.rename_health_insurance
@@ -536,7 +48,6 @@ erpnext.patches.v11_0.move_item_defaults_to_child_table_for_multicompany #02-07-
erpnext.patches.v11_0.refactor_erpnext_shopify #2018-09-07
erpnext.patches.v11_0.rename_overproduction_percent_field
erpnext.patches.v11_0.update_backflush_subcontract_rm_based_on_bom
-erpnext.patches.v10_0.update_status_in_purchase_receipt
erpnext.patches.v11_0.inter_state_field_for_gst
erpnext.patches.v11_0.rename_members_with_naming_series #04-06-2018
erpnext.patches.v11_0.set_update_field_and_value_in_workflow_state
@@ -550,13 +61,10 @@ erpnext.patches.v11_0.skip_user_permission_check_for_department
erpnext.patches.v11_0.set_department_for_doctypes
erpnext.patches.v11_0.update_allow_transfer_for_manufacture
erpnext.patches.v11_0.add_item_group_defaults
-erpnext.patches.v10_0.update_address_template_for_india
erpnext.patches.v11_0.add_expense_claim_default_account
execute:frappe.delete_doc("Page", "hub")
erpnext.patches.v11_0.reset_publish_in_hub_for_all_items
erpnext.patches.v11_0.update_hub_url # 2018-08-31 # 2018-09-03
-erpnext.patches.v10_0.set_discount_amount
-erpnext.patches.v10_0.recalculate_gross_margin_for_project
erpnext.patches.v11_0.make_job_card
erpnext.patches.v11_0.redesign_healthcare_billing_work_flow
erpnext.patches.v10_0.delete_hub_documents # 12-08-2018
@@ -570,9 +78,6 @@ 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 #2019-04-26 #2019-05-03
erpnext.patches.v11_0.drop_column_max_days_allowed
-erpnext.patches.v10_0.update_user_image_in_employee
-erpnext.patches.v10_0.repost_gle_for_purchase_receipts_with_rejected_items
-erpnext.patches.v10_0.allow_operators_in_supplier_scorecard
erpnext.patches.v10_0.item_barcode_childtable_migrate # 16-02-2019
erpnext.patches.v11_0.update_delivery_trip_status
erpnext.patches.v11_0.set_missing_gst_hsn_code
diff --git a/erpnext/patches/repair_tools/set_stock_balance_as_per_serial_no.py b/erpnext/patches/repair_tools/set_stock_balance_as_per_serial_no.py
deleted file mode 100644
index 5a421d146f..0000000000
--- a/erpnext/patches/repair_tools/set_stock_balance_as_per_serial_no.py
+++ /dev/null
@@ -1,13 +0,0 @@
-# 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():
- from erpnext.stock.stock_balance import set_stock_balance_as_per_serial_no
- frappe.db.auto_commit_on_many_writes = 1
-
- set_stock_balance_as_per_serial_no()
-
- frappe.db.auto_commit_on_many_writes = 0
diff --git a/erpnext/patches/v10_0/__init__.py b/erpnext/patches/v10_0/__init__.py
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/erpnext/patches/v10_0/add_agriculture_domain.py b/erpnext/patches/v10_0/add_agriculture_domain.py
deleted file mode 100644
index c18e69f3e6..0000000000
--- a/erpnext/patches/v10_0/add_agriculture_domain.py
+++ /dev/null
@@ -1,13 +0,0 @@
-# Copyright (c) 2017, Frappe and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- domain = 'Agriculture'
- if not frappe.db.exists('Domain', domain):
- frappe.get_doc({
- 'doctype': 'Domain',
- 'domain': domain
- }).insert(ignore_permissions=True)
\ No newline at end of file
diff --git a/erpnext/patches/v10_0/add_guardian_role_for_parent_portal.py b/erpnext/patches/v10_0/add_guardian_role_for_parent_portal.py
deleted file mode 100644
index 0b891f21f4..0000000000
--- a/erpnext/patches/v10_0/add_guardian_role_for_parent_portal.py
+++ /dev/null
@@ -1,23 +0,0 @@
-# Copyright (c) 2017, Frappe and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- # create guardian role
- if not frappe.get_value('Role', dict(role_name='Guardian')):
- frappe.get_doc({
- 'doctype': 'Role',
- 'role_name': 'Guardian',
- 'desk_access': 0,
- 'restrict_to_domain': 'Education'
- }).insert(ignore_permissions=True)
-
- # set guardian roles in already created users
- if frappe.db.exists("Doctype", "Guardian"):
- for user in frappe.db.sql_list("""select u.name from `tabUser` u , `tabGuardian` g where g.email_address = u.name"""):
- user = frappe.get_doc('User', user)
- user.flags.ignore_validate = True
- user.flags.ignore_mandatory = True
- user.save()
diff --git a/erpnext/patches/v10_0/add_non_profit_domain.py b/erpnext/patches/v10_0/add_non_profit_domain.py
deleted file mode 100644
index b03d669515..0000000000
--- a/erpnext/patches/v10_0/add_non_profit_domain.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright (c) 2017, Frappe and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- domain = 'Non Profit'
- if not frappe.db.exists('Domain', domain):
- frappe.get_doc({
- 'doctype': 'Domain',
- 'domain': domain
- }).insert(ignore_permissions=True)
-
- frappe.get_doc({
- 'doctype': 'Role',
- 'role_name': 'Non Profit Portal User',
- 'desk_access': 0,
- 'restrict_to_domain': domain
- }).insert(ignore_permissions=True)
\ No newline at end of file
diff --git a/erpnext/patches/v10_0/allow_operators_in_supplier_scorecard.py b/erpnext/patches/v10_0/allow_operators_in_supplier_scorecard.py
deleted file mode 100644
index 827f9bc94f..0000000000
--- a/erpnext/patches/v10_0/allow_operators_in_supplier_scorecard.py
+++ /dev/null
@@ -1,23 +0,0 @@
-# Copyright (c) 2019, Frappe and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- frappe.reload_doc('buying', 'doctype', 'supplier_scorecard_criteria')
- frappe.reload_doc('buying', 'doctype', 'supplier_scorecard_scoring_criteria')
- frappe.reload_doc('buying', 'doctype', 'supplier_scorecard')
-
- for criteria in frappe.get_all('Supplier Scorecard Criteria', fields=['name', 'formula'], limit_page_length=None):
- frappe.db.set_value('Supplier Scorecard Criteria', criteria.name,
- 'formula', criteria.formula.replace('<','<').replace('>','>'))
-
- for criteria in frappe.get_all('Supplier Scorecard Scoring Criteria', fields=['name', 'formula'], limit_page_length=None):
- if criteria.formula: # not mandatory
- frappe.db.set_value('Supplier Scorecard Scoring Criteria', criteria.name,
- 'formula', criteria.formula.replace('<','<').replace('>','>'))
-
- for sc in frappe.get_all('Supplier Scorecard', fields=['name', 'weighting_function'], limit_page_length=None):
- frappe.db.set_value('Supplier Scorecard', sc.name, 'weighting_function',
- sc.weighting_function.replace('<','<').replace('>','>'))
\ No newline at end of file
diff --git a/erpnext/patches/v10_0/copy_projects_renamed_fields.py b/erpnext/patches/v10_0/copy_projects_renamed_fields.py
deleted file mode 100644
index 80db3bdd1e..0000000000
--- a/erpnext/patches/v10_0/copy_projects_renamed_fields.py
+++ /dev/null
@@ -1,13 +0,0 @@
-from __future__ import unicode_literals
-import frappe
-from frappe.model.utils.rename_field import rename_field
-
-def execute():
- """ copy data from old fields to new """
- frappe.reload_doc("projects", "doctype", "project")
-
- if frappe.db.has_column('Project', 'total_sales_cost'):
- rename_field('Project', "total_sales_cost", "total_sales_amount")
-
- if frappe.db.has_column('Project', 'total_billing_amount'):
- rename_field('Project', "total_billing_amount", "total_billable_amount")
\ No newline at end of file
diff --git a/erpnext/patches/v10_0/enabled_regional_print_format_based_on_country.py b/erpnext/patches/v10_0/enabled_regional_print_format_based_on_country.py
deleted file mode 100644
index 38b04cebc2..0000000000
--- a/erpnext/patches/v10_0/enabled_regional_print_format_based_on_country.py
+++ /dev/null
@@ -1,22 +0,0 @@
-# Copyright (c) 2017, Frappe and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- print_format_mapper = {
- 'India': ['GST POS Invoice', 'GST Tax Invoice'],
- 'Saudi Arabia': ['Simplified Tax Invoice', 'Detailed Tax Invoice', 'Tax Invoice'],
- 'United Arab Emirates': ['Simplified Tax Invoice', 'Detailed Tax Invoice', 'Tax Invoice']
- }
-
- frappe.db.sql(""" update `tabPrint Format` set disabled = 1 where name
- in ('GST POS Invoice', 'GST Tax Invoice', 'Simplified Tax Invoice', 'Detailed Tax Invoice')""")
-
- for d in frappe.get_all('Company', fields = ["country"],
- filters={'country': ('in', ['India', 'Saudi Arabia', 'United Arab Emirates'])}):
- if print_format_mapper.get(d.country):
- print_formats = print_format_mapper.get(d.country)
- frappe.db.sql(""" update `tabPrint Format` set disabled = 0
- where name in (%s)""" % ", ".join(["%s"]*len(print_formats)), tuple(print_formats))
\ No newline at end of file
diff --git a/erpnext/patches/v10_0/fix_reserved_qty_for_sub_contract.py b/erpnext/patches/v10_0/fix_reserved_qty_for_sub_contract.py
deleted file mode 100644
index c0a9e5eb5b..0000000000
--- a/erpnext/patches/v10_0/fix_reserved_qty_for_sub_contract.py
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright (c) 2017, Frappe and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-from erpnext.stock.utils import get_bin
-
-def execute():
- frappe.reload_doc("stock", "doctype", "bin")
- frappe.reload_doc("buying", "doctype", "purchase_order_item_supplied")
- for d in frappe.db.sql("""
- select distinct rm_item_code, reserve_warehouse
- from `tabPurchase Order Item Supplied`
- where docstatus=1 and reserve_warehouse is not null and reserve_warehouse != ''"""):
-
- try:
- bin_doc = get_bin(d[0], d[1])
- bin_doc.update_reserved_qty_for_sub_contracting()
- except:
- pass
-
- for d in frappe.db.sql("""select distinct item_code, source_warehouse
- from `tabWork Order Item`
- where docstatus=1 and transferred_qty > required_qty
- and source_warehouse is not null and source_warehouse != ''""", as_list=1):
-
- try:
- bin_doc = get_bin(d[0], d[1])
- bin_doc.update_reserved_qty_for_production()
- except:
- pass
diff --git a/erpnext/patches/v10_0/recalculate_gross_margin_for_project.py b/erpnext/patches/v10_0/recalculate_gross_margin_for_project.py
deleted file mode 100644
index 6d461f3bc9..0000000000
--- a/erpnext/patches/v10_0/recalculate_gross_margin_for_project.py
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2017, Frappe and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- frappe.reload_doc('projects', 'doctype', 'project')
- for d in frappe.db.sql(""" select name from `tabProject` where
- ifnull(total_consumed_material_cost, 0 ) > 0 and ifnull(total_billed_amount, 0) > 0""", as_dict=1):
- doc = frappe.get_doc("Project", d.name)
- doc.calculate_gross_margin()
- doc.db_set('gross_margin', doc.gross_margin)
- doc.db_set('per_gross_margin', doc.per_gross_margin)
\ No newline at end of file
diff --git a/erpnext/patches/v10_0/rename_schools_to_education.py b/erpnext/patches/v10_0/rename_schools_to_education.py
deleted file mode 100644
index 85c25a8943..0000000000
--- a/erpnext/patches/v10_0/rename_schools_to_education.py
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright (c) 2017, Frappe and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- # rename the School module as Education
-
- # rename the school module
- if frappe.db.exists('Module Def', 'Schools') and not frappe.db.exists('Module Def', 'Education'):
- frappe.rename_doc("Module Def", "Schools", "Education")
-
- # delete the school module
- if frappe.db.exists('Module Def', 'Schools') and frappe.db.exists('Module Def', 'Education'):
- frappe.db.sql("""delete from `tabModule Def` where module_name = 'Schools'""")
-
-
- # rename "School Settings" to the "Education Settings
- if frappe.db.exists('DocType', 'School Settings'):
- frappe.rename_doc("DocType", "School Settings", "Education Settings", force=True)
- frappe.reload_doc("education", "doctype", "education_settings")
-
- # delete the discussion web form if exists
- if frappe.db.exists('Web Form', 'Discussion'):
- frappe.db.sql("""delete from `tabWeb Form` where name = 'discussion'""")
-
- # rename the select option field from "School Bus" to "Institute's Bus"
- frappe.reload_doc("education", "doctype", "Program Enrollment")
- if "mode_of_transportation" in frappe.db.get_table_columns("Program Enrollment"):
- frappe.db.sql("""update `tabProgram Enrollment` set mode_of_transportation = "Institute's Bus"
- where mode_of_transportation = "School Bus" """)
diff --git a/erpnext/patches/v10_0/repost_gle_for_purchase_receipts_with_rejected_items.py b/erpnext/patches/v10_0/repost_gle_for_purchase_receipts_with_rejected_items.py
deleted file mode 100644
index e6546e386b..0000000000
--- a/erpnext/patches/v10_0/repost_gle_for_purchase_receipts_with_rejected_items.py
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright (c) 2017, Frappe and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe, erpnext
-
-def execute():
- for company in frappe.get_all("Company"):
- if not erpnext.is_perpetual_inventory_enabled(company.name):
- continue
-
- acc_frozen_upto = frappe.db.get_value("Accounts Settings", None, "acc_frozen_upto") or "1900-01-01"
- pr_with_rejected_warehouse = frappe.db.sql("""
- select pr.name
- from `tabPurchase Receipt` pr, `tabPurchase Receipt Item` pr_item
- where pr.name = pr_item.parent
- and pr.posting_date > %s
- and pr.docstatus=1
- and pr.company = %s
- and pr_item.rejected_qty > 0
- """, (acc_frozen_upto, company.name), as_dict=1)
-
- for d in pr_with_rejected_warehouse:
- doc = frappe.get_doc("Purchase Receipt", d.name)
-
- doc.docstatus = 2
- doc.make_gl_entries_on_cancel()
-
-
- # update gl entries for submit state of PR
- doc.docstatus = 1
- doc.make_gl_entries()
diff --git a/erpnext/patches/v10_0/repost_requested_qty_for_non_stock_uom_items.py b/erpnext/patches/v10_0/repost_requested_qty_for_non_stock_uom_items.py
deleted file mode 100644
index 4fe4e97cf5..0000000000
--- a/erpnext/patches/v10_0/repost_requested_qty_for_non_stock_uom_items.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright (c) 2019, Web Notes Technologies Pvt. Ltd. and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- from erpnext.stock.stock_balance import update_bin_qty, get_indented_qty
-
- count=0
- for item_code, warehouse in frappe.db.sql("""select distinct item_code, warehouse
- from `tabMaterial Request Item` where docstatus = 1 and stock_uom<>uom"""):
- try:
- count += 1
- update_bin_qty(item_code, warehouse, {
- "indented_qty": get_indented_qty(item_code, warehouse),
- })
- if count % 200 == 0:
- frappe.db.commit()
- except:
- frappe.db.rollback()
diff --git a/erpnext/patches/v10_0/set_auto_created_serial_no_in_stock_entry.py b/erpnext/patches/v10_0/set_auto_created_serial_no_in_stock_entry.py
deleted file mode 100644
index c6470f21d7..0000000000
--- a/erpnext/patches/v10_0/set_auto_created_serial_no_in_stock_entry.py
+++ /dev/null
@@ -1,56 +0,0 @@
-# Copyright (c) 2017, Frappe and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- serialised_items = [d.name for d in frappe.get_all("Item", filters={"has_serial_no": 1})]
-
- if not serialised_items:
- return
-
- for dt in ["Stock Entry Detail", "Purchase Receipt Item", "Purchase Invoice Item"]:
- cond = ""
- if dt=="Purchase Invoice Item":
- cond = """ and parent in (select name from `tabPurchase Invoice`
- where `tabPurchase Invoice`.name = `tabPurchase Invoice Item`.parent and update_stock=1)"""
-
- item_rows = frappe.db.sql("""
- select name
- from `tab{0}`
- where conversion_factor != 1
- and docstatus = 1
- and ifnull(serial_no, '') = ''
- and item_code in ({1})
- {2}
- """.format(dt, ', '.join(['%s']*len(serialised_items)), cond), tuple(serialised_items))
-
- if item_rows:
- sle_serial_nos = dict(frappe.db.sql("""
- select voucher_detail_no, serial_no
- from `tabStock Ledger Entry`
- where ifnull(serial_no, '') != ''
- and voucher_detail_no in (%s)
- """.format(', '.join(['%s']*len(item_rows))),
- tuple([d[0] for d in item_rows])))
-
- batch_size = 100
- for i in range(0, len(item_rows), batch_size):
- batch_item_rows = item_rows[i:i + batch_size]
- when_then = []
- for item_row in batch_item_rows:
-
- when_then.append('WHEN `name` = "{row_name}" THEN "{value}"'.format(
- row_name=item_row[0],
- value=sle_serial_nos.get(item_row[0])))
-
- frappe.db.sql("""
- update
- `tab{doctype}`
- set
- serial_no = CASE {when_then_cond} ELSE `serial_no` END
- """.format(
- doctype = dt,
- when_then_cond=" ".join(when_then)
- ))
\ No newline at end of file
diff --git a/erpnext/patches/v10_0/set_b2c_limit.py b/erpnext/patches/v10_0/set_b2c_limit.py
deleted file mode 100644
index 5d964e681a..0000000000
--- a/erpnext/patches/v10_0/set_b2c_limit.py
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- frappe.reload_doc("regional", "doctype", "gst_settings")
- frappe.reload_doc("accounts", "doctype", "gst_account")
- gst_settings = frappe.get_doc("GST Settings")
- gst_settings.b2c_limit = 250000
- gst_settings.save()
diff --git a/erpnext/patches/v10_0/set_default_payment_terms_based_on_company.py b/erpnext/patches/v10_0/set_default_payment_terms_based_on_company.py
deleted file mode 100644
index a90e096390..0000000000
--- a/erpnext/patches/v10_0/set_default_payment_terms_based_on_company.py
+++ /dev/null
@@ -1,37 +0,0 @@
-from __future__ import unicode_literals
-import frappe
-from erpnext.patches.v8_10.change_default_customer_credit_days import make_payment_term, make_template
-
-def execute():
- for dt in ("Company", "Customer Group"):
- frappe.reload_doc("setup", "doctype", frappe.scrub(dt))
-
- credit_records = frappe.db.sql("""
- SELECT DISTINCT `credit_days`, `credit_days_based_on`, `name`
- from `tab{0}`
- where
- ((credit_days_based_on='Fixed Days' or credit_days_based_on is null) and credit_days is not null)
- or credit_days_based_on='Last Day of the Next Month'
- """.format(dt), as_dict=1)
-
- for d in credit_records:
- template = create_payment_terms_template(d)
-
- frappe.db.sql("""
- update `tab{0}`
- set `payment_terms` = %s
- where name = %s
- """.format(dt), (template.name, d.name))
-
-def create_payment_terms_template(data):
- if data.credit_days_based_on == "Fixed Days":
- pyt_template_name = 'Default Payment Term - N{0}'.format(data.credit_days)
- else:
- pyt_template_name = 'Default Payment Term - EO2M'
-
- if not frappe.db.exists("Payment Terms Template", pyt_template_name):
- payment_term = make_payment_term(data.credit_days, data.credit_days_based_on)
- template = make_template(payment_term)
- else:
- template = frappe.get_doc("Payment Terms Template", pyt_template_name)
- return template
\ No newline at end of file
diff --git a/erpnext/patches/v10_0/set_discount_amount.py b/erpnext/patches/v10_0/set_discount_amount.py
deleted file mode 100644
index d5e2c5a84b..0000000000
--- a/erpnext/patches/v10_0/set_discount_amount.py
+++ /dev/null
@@ -1,35 +0,0 @@
-from __future__ import unicode_literals
-
-import frappe
-
-def execute():
- frappe.reload_doc("accounts", "doctype", "sales_invoice_item")
- frappe.reload_doc('accounts', 'doctype', 'purchase_invoice_item')
- frappe.reload_doc('buying', 'doctype', 'purchase_order_item')
- frappe.reload_doc('buying', 'doctype', 'supplier_quotation_item')
- frappe.reload_doc('selling', 'doctype', 'sales_order_item')
- frappe.reload_doc('selling', 'doctype', 'quotation_item')
- frappe.reload_doc('stock', 'doctype', 'delivery_note_item')
- frappe.reload_doc('stock', 'doctype', 'purchase_receipt_item')
-
- selling_doctypes = ["Sales Order Item", "Sales Invoice Item", "Delivery Note Item", "Quotation Item"]
- buying_doctypes = ["Purchase Order Item", "Purchase Invoice Item", "Purchase Receipt Item", "Supplier Quotation Item"]
-
- for doctype in selling_doctypes:
- frappe.db.sql('''
- UPDATE
- `tab%s`
- SET
- discount_amount = if(rate_with_margin > 0, rate_with_margin, price_list_rate) * discount_percentage / 100
- WHERE
- discount_percentage > 0
- ''' % (doctype))
- for doctype in buying_doctypes:
- frappe.db.sql('''
- UPDATE
- `tab%s`
- SET
- discount_amount = price_list_rate * discount_percentage / 100
- WHERE
- discount_percentage > 0
- ''' % (doctype))
\ No newline at end of file
diff --git a/erpnext/patches/v10_0/set_numeric_ranges_in_template_if_blank.py b/erpnext/patches/v10_0/set_numeric_ranges_in_template_if_blank.py
deleted file mode 100644
index 6825f19d74..0000000000
--- a/erpnext/patches/v10_0/set_numeric_ranges_in_template_if_blank.py
+++ /dev/null
@@ -1,35 +0,0 @@
-# Copyright (c) 2017, Frappe and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- item_numeric_attributes = frappe.db.sql("""
- select name, numeric_values, from_range, to_range, increment
- from `tabItem Attribute`
- where numeric_values = 1
- """, as_dict=1)
-
- for d in item_numeric_attributes:
- frappe.db.sql("""
- update `tabItem Variant Attribute`
- set
- from_range = CASE
- WHEN from_range = 0 THEN %(from_range)s
- ELSE from_range
- END,
- to_range = CASE
- WHEN to_range = 0 THEN %(to_range)s
- ELSE to_range
- END,
- increment = CASE
- WHEN increment = 0 THEN %(increment)s
- ELSE increment
- END,
- numeric_values = %(numeric_values)s
- where
- attribute = %(name)s
- and exists(select name from tabItem
- where name=`tabItem Variant Attribute`.parent and has_variants=1)
- """, d)
\ No newline at end of file
diff --git a/erpnext/patches/v10_0/set_primary_contact_for_customer.py b/erpnext/patches/v10_0/set_primary_contact_for_customer.py
deleted file mode 100644
index ae0b31c21f..0000000000
--- a/erpnext/patches/v10_0/set_primary_contact_for_customer.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright (c) 2017, Frappe and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- frappe.reload_doctype('Customer')
-
- frappe.db.sql("""
- update
- `tabCustomer`, (
- select `tabContact`.name, `tabContact`.mobile_no, `tabContact`.email_id,
- `tabDynamic Link`.link_name from `tabContact`, `tabDynamic Link`
- where `tabContact`.name = `tabDynamic Link`.parent and
- `tabDynamic Link`.link_doctype = 'Customer' and `tabContact`.is_primary_contact = 1
- ) as contact
- set
- `tabCustomer`.customer_primary_contact = contact.name,
- `tabCustomer`.mobile_no = contact.mobile_no, `tabCustomer`.email_id = contact.email_id
- where `tabCustomer`.name = contact.link_name""")
\ No newline at end of file
diff --git a/erpnext/patches/v10_0/set_qty_in_transactions_based_on_serial_no_input.py b/erpnext/patches/v10_0/set_qty_in_transactions_based_on_serial_no_input.py
deleted file mode 100644
index 083b7f4b20..0000000000
--- a/erpnext/patches/v10_0/set_qty_in_transactions_based_on_serial_no_input.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright (c) 2017, Frappe and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- frappe.reload_doc("stock", "doctype", "stock_settings")
-
- ss = frappe.get_doc("Stock Settings")
- ss.set_qty_in_transactions_based_on_serial_no_input = 1
-
- if ss.default_warehouse \
- and not frappe.db.exists("Warehouse", ss.default_warehouse):
- ss.default_warehouse = None
-
- if ss.stock_uom and not frappe.db.exists("UOM", ss.stock_uom):
- ss.stock_uom = None
-
- ss.flags.ignore_mandatory = True
- ss.save()
\ No newline at end of file
diff --git a/erpnext/patches/v10_0/set_student_party_type.py b/erpnext/patches/v10_0/set_student_party_type.py
deleted file mode 100644
index 08376ae894..0000000000
--- a/erpnext/patches/v10_0/set_student_party_type.py
+++ /dev/null
@@ -1,8 +0,0 @@
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- if not frappe.db.exists("Party Type", "Student"):
- party = frappe.new_doc("Party Type")
- party.party_type = "Student"
- party.save()
diff --git a/erpnext/patches/v10_0/setup_vat_for_uae_and_saudi_arabia.py b/erpnext/patches/v10_0/setup_vat_for_uae_and_saudi_arabia.py
deleted file mode 100644
index a8d90499d8..0000000000
--- a/erpnext/patches/v10_0/setup_vat_for_uae_and_saudi_arabia.py
+++ /dev/null
@@ -1,13 +0,0 @@
-# Copyright (c) 2017, Frappe and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-from erpnext.setup.doctype.company.company import install_country_fixtures
-
-def execute():
- frappe.reload_doc("accounts", "doctype", "account")
- frappe.reload_doc("accounts", "doctype", "payment_schedule")
- for d in frappe.get_all('Company',
- filters={'country': ('in', ['Saudi Arabia', 'United Arab Emirates'])}):
- install_country_fixtures(d.name)
\ No newline at end of file
diff --git a/erpnext/patches/v10_0/show_leaves_of_all_department_members_in_calendar.py b/erpnext/patches/v10_0/show_leaves_of_all_department_members_in_calendar.py
deleted file mode 100644
index 7e2ff7a8a7..0000000000
--- a/erpnext/patches/v10_0/show_leaves_of_all_department_members_in_calendar.py
+++ /dev/null
@@ -1,6 +0,0 @@
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- frappe.reload_doc("hr", "doctype", "hr_settings")
- frappe.db.set_value("HR Settings", None, "show_leaves_of_all_department_members_in_calendar", 1)
\ No newline at end of file
diff --git a/erpnext/patches/v10_0/taxes_issue_with_pos.py b/erpnext/patches/v10_0/taxes_issue_with_pos.py
deleted file mode 100644
index 2a3275ac2c..0000000000
--- a/erpnext/patches/v10_0/taxes_issue_with_pos.py
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright (c) 2017, Frappe and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- for d in frappe.get_all('Sales Invoice', fields=["name"],
- filters = {'is_pos':1, 'docstatus': 1, 'creation': ('>', '2018-04-23')}):
- doc = frappe.get_doc('Sales Invoice', d.name)
- if (not doc.taxes and doc.taxes_and_charges and doc.pos_profile and doc.outstanding_amount != 0 and
- frappe.db.get_value('POS Profile', doc.pos_profile, 'taxes_and_charges', cache=True) == doc.taxes_and_charges):
-
- doc.append_taxes_from_master()
- doc.calculate_taxes_and_totals()
- for d in doc.taxes:
- d.db_update()
-
- doc.db_update()
-
- delete_gle_for_voucher(doc.name)
- doc.make_gl_entries()
-
-def delete_gle_for_voucher(voucher_no):
- frappe.db.sql("""delete from `tabGL Entry` where voucher_no = %(voucher_no)s""",
- {'voucher_no': voucher_no})
\ No newline at end of file
diff --git a/erpnext/patches/v10_0/update_address_template_for_india.py b/erpnext/patches/v10_0/update_address_template_for_india.py
deleted file mode 100644
index 1ddca93760..0000000000
--- a/erpnext/patches/v10_0/update_address_template_for_india.py
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright (c) 2017, Frappe and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-from erpnext.regional.address_template.setup import set_up_address_templates
-
-def execute():
- if frappe.db.get_value('Company', {'country': 'India'}, 'name'):
- address_template = frappe.db.get_value('Address Template', 'India', 'template')
- if not address_template or "gstin" not in address_template:
- set_up_address_templates(default_country='India')
diff --git a/erpnext/patches/v10_0/update_assessment_plan.py b/erpnext/patches/v10_0/update_assessment_plan.py
deleted file mode 100644
index 174623c1a4..0000000000
--- a/erpnext/patches/v10_0/update_assessment_plan.py
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright (c) 2017, Frappe and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- frappe.reload_doc('education', 'doctype', 'assessment_plan')
-
- frappe.db.sql("""
- UPDATE `tabAssessment Plan` as ap
- INNER JOIN `tabStudent Group` as sg ON sg.name = ap.student_group
- SET ap.academic_term = sg.academic_term,
- ap.academic_year = sg.academic_year,
- ap.program = sg.program
- WHERE ap.docstatus = 1
- """)
\ No newline at end of file
diff --git a/erpnext/patches/v10_0/update_assessment_result.py b/erpnext/patches/v10_0/update_assessment_result.py
deleted file mode 100644
index 96218db972..0000000000
--- a/erpnext/patches/v10_0/update_assessment_result.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright (c) 2017, Frappe and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- frappe.reload_doc('education', 'doctype', 'assessment_result')
-
- frappe.db.sql("""
- UPDATE `tabAssessment Result` AS ar
- INNER JOIN `tabAssessment Plan` AS ap ON ap.name = ar.assessment_plan
- SET ar.academic_term = ap.academic_term,
- ar.academic_year = ap.academic_year,
- ar.program = ap.program,
- ar.course = ap.course,
- ar.assessment_group = ap.assessment_group,
- ar.student_group = ap.student_group
- WHERE ap.docstatus = 1
- """)
\ No newline at end of file
diff --git a/erpnext/patches/v10_0/update_asset_calculate_depreciation.py b/erpnext/patches/v10_0/update_asset_calculate_depreciation.py
deleted file mode 100644
index b947a40b4a..0000000000
--- a/erpnext/patches/v10_0/update_asset_calculate_depreciation.py
+++ /dev/null
@@ -1,12 +0,0 @@
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- frappe.reload_doc('assets', 'doctype', 'asset')
- frappe.reload_doc('assets', 'doctype', 'depreciation_schedule')
-
- frappe.db.sql("""
- update tabAsset a
- set calculate_depreciation = 1
- where exists(select ds.name from `tabDepreciation Schedule` ds where ds.parent=a.name)
- """)
\ No newline at end of file
diff --git a/erpnext/patches/v10_0/update_hub_connector_domain.py b/erpnext/patches/v10_0/update_hub_connector_domain.py
deleted file mode 100644
index baf580a369..0000000000
--- a/erpnext/patches/v10_0/update_hub_connector_domain.py
+++ /dev/null
@@ -1,10 +0,0 @@
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- if frappe.db.table_exists("Data Migration Connector"):
- frappe.db.sql("""
- UPDATE `tabData Migration Connector`
- SET hostname = 'https://hubmarket.org'
- WHERE connector_name = 'Hub Connector'
- """)
\ No newline at end of file
diff --git a/erpnext/patches/v10_0/update_lft_rgt_for_employee.py b/erpnext/patches/v10_0/update_lft_rgt_for_employee.py
deleted file mode 100644
index 46ca786e0d..0000000000
--- a/erpnext/patches/v10_0/update_lft_rgt_for_employee.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from __future__ import unicode_literals
-import frappe
-from frappe.utils.nestedset import rebuild_tree
-
-def execute():
- """ assign lft and rgt appropriately """
- frappe.reload_doc("hr", "doctype", "employee")
-
- rebuild_tree("Employee", "reports_to")
\ No newline at end of file
diff --git a/erpnext/patches/v10_0/update_project_in_sle.py b/erpnext/patches/v10_0/update_project_in_sle.py
deleted file mode 100644
index 08c64f18d8..0000000000
--- a/erpnext/patches/v10_0/update_project_in_sle.py
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright (c) 2017, Frappe and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- for doctype in ['Sales Invoice', 'Delivery Note', 'Stock Entry']:
- frappe.db.sql(""" update
- `tabStock Ledger Entry` sle, `tab{0}` parent_doc
- set
- sle.project = parent_doc.project
- where
- sle.voucher_no = parent_doc.name and sle.voucher_type = %s and sle.project is null
- and parent_doc.project is not null and parent_doc.project != ''""".format(doctype), doctype)
diff --git a/erpnext/patches/v10_0/update_reserved_qty_for_purchase_order.py b/erpnext/patches/v10_0/update_reserved_qty_for_purchase_order.py
deleted file mode 100644
index 7b2c36698a..0000000000
--- a/erpnext/patches/v10_0/update_reserved_qty_for_purchase_order.py
+++ /dev/null
@@ -1,53 +0,0 @@
-from __future__ import unicode_literals
-import frappe
-from erpnext.stock.utils import get_bin
-
-def execute():
- po_item = list(frappe.db.sql(("""
- select distinct po.name as poname, poitem.rm_item_code as rm_item_code, po.company
- from `tabPurchase Order` po, `tabPurchase Order Item Supplied` poitem
- where po.name = poitem.parent
- and po.is_subcontracted = "Yes"
- and po.docstatus = 1"""), as_dict=1))
- if not po_item:
- return
-
- frappe.reload_doc("stock", "doctype", "bin")
- frappe.reload_doc("buying", "doctype", "purchase_order_item_supplied")
- company_warehouse = frappe._dict(frappe.db.sql("""select company, min(name) from `tabWarehouse`
- where is_group = 0 group by company"""))
-
- items = list(set([d.rm_item_code for d in po_item]))
- item_wh = frappe._dict(frappe.db.sql("""select item_code, default_warehouse
- from `tabItem` where name in ({0})""".format(", ".join(["%s"] * len(items))), items))
-
- # Update reserved warehouse
- for item in po_item:
- reserve_warehouse = get_warehouse(item.rm_item_code, item.company, company_warehouse, item_wh)
- frappe.db.sql("""update `tabPurchase Order Item Supplied`
- set reserve_warehouse = %s
- where parent = %s and rm_item_code = %s
- """, (reserve_warehouse, item["poname"], item["rm_item_code"]))
-
- # Update bin
- item_wh_bin = frappe.db.sql(("""
- select distinct poitemsup.rm_item_code as rm_item_code,
- poitemsup.reserve_warehouse as reserve_warehouse
- from `tabPurchase Order` po, `tabPurchase Order Item Supplied` poitemsup
- where po.name = poitemsup.parent
- and po.is_subcontracted = "Yes"
- and po.docstatus = 1"""), as_dict=1)
- for d in item_wh_bin:
- try:
- stock_bin = get_bin(d["rm_item_code"], d["reserve_warehouse"])
- stock_bin.update_reserved_qty_for_sub_contracting()
- except:
- pass
-
-def get_warehouse(item_code, company, company_warehouse, item_wh):
- reserve_warehouse = item_wh.get(item_code)
- if frappe.db.get_value("Warehouse", reserve_warehouse, "company") != company:
- reserve_warehouse = None
- if not reserve_warehouse:
- reserve_warehouse = company_warehouse.get(company)
- return reserve_warehouse
diff --git a/erpnext/patches/v10_0/update_sales_order_link_to_purchase_order.py b/erpnext/patches/v10_0/update_sales_order_link_to_purchase_order.py
deleted file mode 100644
index b4f58384bf..0000000000
--- a/erpnext/patches/v10_0/update_sales_order_link_to_purchase_order.py
+++ /dev/null
@@ -1,18 +0,0 @@
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- frappe.reload_doc("buying", "doctype", "supplier_quotation_item")
-
- for doctype in ['Purchase Order','Supplier Quotation']:
- frappe.db.sql("""
- Update
- `tab{doctype} Item`, `tabMaterial Request Item`
- set
- `tab{doctype} Item`.sales_order = `tabMaterial Request Item`.sales_order
- where
- `tab{doctype} Item`.material_request= `tabMaterial Request Item`.parent
- and `tab{doctype} Item`.material_request_item = `tabMaterial Request Item`.name
- and `tabMaterial Request Item`.sales_order is not null""".format(doctype=doctype))
\ No newline at end of file
diff --git a/erpnext/patches/v10_0/update_status_for_multiple_source_in_po.py b/erpnext/patches/v10_0/update_status_for_multiple_source_in_po.py
deleted file mode 100644
index fd3be08b89..0000000000
--- a/erpnext/patches/v10_0/update_status_for_multiple_source_in_po.py
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright (c) 2017, Frappe and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-
-def execute():
-
-
- # update the sales order item in the material request
- frappe.reload_doc('stock', 'doctype', 'material_request_item')
- frappe.db.sql('''update `tabMaterial Request Item` mri, `tabSales Order Item` soi
- set mri.sales_order_item = soi.name
- where ifnull(mri.sales_order, "")!="" and soi.parent=mri.sales_order
- and soi.item_code=mri.item_code and mri.docstatus=1
- ''')
-
- # update the sales order item in the purchase order
- frappe.db.sql('''update `tabPurchase Order Item` poi, `tabSales Order Item` soi
- set poi.sales_order_item = soi.name
- where ifnull(poi.sales_order, "")!="" and soi.parent=poi.sales_order
- and soi.item_code=poi.item_code and poi.docstatus = 1
- ''')
-
- # Update the status in material request and sales order
- po_list = frappe.db.sql('''
- select parent from `tabPurchase Order Item` where ifnull(material_request, "")!="" and
- ifnull(sales_order, "")!="" and docstatus=1
- ''',as_dict=1)
-
- for po in list(set([d.get("parent") for d in po_list if d.get("parent")])):
- try:
- po_doc = frappe.get_doc("Purchase Order", po)
-
- # update the so in the status updater
- po_doc.update_status_updater()
- po_doc.update_qty(update_modified=False)
-
- except Exception:
- pass
diff --git a/erpnext/patches/v10_0/update_status_in_purchase_receipt.py b/erpnext/patches/v10_0/update_status_in_purchase_receipt.py
deleted file mode 100644
index a0bdd9e2cc..0000000000
--- a/erpnext/patches/v10_0/update_status_in_purchase_receipt.py
+++ /dev/null
@@ -1,8 +0,0 @@
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- frappe.reload_doc("stock", "doctype", "purchase_receipt")
- frappe.db.sql('''
- UPDATE `tabPurchase Receipt` SET status = "Completed" WHERE per_billed = 100 AND docstatus = 1
- ''')
\ No newline at end of file
diff --git a/erpnext/patches/v10_0/update_territory_and_customer_group.py b/erpnext/patches/v10_0/update_territory_and_customer_group.py
deleted file mode 100644
index 7f3dae991d..0000000000
--- a/erpnext/patches/v10_0/update_territory_and_customer_group.py
+++ /dev/null
@@ -1,29 +0,0 @@
-from __future__ import unicode_literals
-import frappe
-from frappe.model.rename_doc import get_fetch_fields
-
-def execute():
- ignore_doctypes = ["Lead", "Opportunity", "POS Profile", "Tax Rule", "Pricing Rule"]
- customers = frappe.get_all('Customer', fields=["name", "customer_group"])
- customer_group_fetch = get_fetch_fields('Customer', 'Customer Group', ignore_doctypes)
-
- batch_size = 1000
- for i in range(0, len(customers), batch_size):
- batch_customers = customers[i:i + batch_size]
- for d in customer_group_fetch:
- when_then = []
- for customer in batch_customers:
- value = frappe.db.escape(frappe.as_unicode(customer.get("customer_group")))
-
- when_then.append('''
- WHEN `%s` = %s and %s != %s
- THEN %s
- '''%(d["master_fieldname"], frappe.db.escape(frappe.as_unicode(customer.name)),
- d["linked_to_fieldname"], value, value))
-
- frappe.db.sql("""
- update
- `tab%s`
- set
- %s = CASE %s ELSE `%s` END
- """%(d['doctype'], d.linked_to_fieldname, " ".join(when_then), d.linked_to_fieldname))
diff --git a/erpnext/patches/v10_0/update_user_image_in_employee.py b/erpnext/patches/v10_0/update_user_image_in_employee.py
deleted file mode 100644
index 72d5d2a857..0000000000
--- a/erpnext/patches/v10_0/update_user_image_in_employee.py
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright (c) 2017, Frappe and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- frappe.reload_doc('hr', 'doctype', 'employee')
-
- frappe.db.sql("""
- UPDATE
- `tabEmployee`, `tabUser`
- SET
- `tabEmployee`.image = `tabUser`.user_image
- WHERE
- `tabEmployee`.user_id = `tabUser`.name and
- `tabEmployee`.user_id is not null and
- `tabEmployee`.user_id != '' and `tabEmployee`.image is null
- """)
diff --git a/erpnext/patches/v10_0/update_warehouse_address_details.py b/erpnext/patches/v10_0/update_warehouse_address_details.py
deleted file mode 100644
index b982b9a662..0000000000
--- a/erpnext/patches/v10_0/update_warehouse_address_details.py
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright (c) 2017, Frappe and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- warehouse = frappe.db.sql("""select name, email_id, phone_no, mobile_no, address_line_1,
- address_line_2, city, state, pin from `tabWarehouse` where ifnull(address_line_1, '') != ''
- or ifnull(mobile_no, '') != ''
- or ifnull(email_id, '') != '' """, as_dict=1)
-
- for d in warehouse:
- try:
- address = frappe.new_doc('Address')
- address.name = d.name
- address.address_title = d.name
- address.address_line1 = d.address_line_1
- address.city = d.city
- address.state = d.state
- address.pincode = d.pin
- address.db_insert()
- address.append('links',{'link_doctype':'Warehouse','link_name':d.name})
- address.links[0].db_insert()
- if d.name and (d.email_id or d.mobile_no or d.phone_no):
- contact = frappe.new_doc('Contact')
- contact.name = d.name
- contact.first_name = d.name
- contact.mobile_no = d.mobile_no
- contact.email_id = d.email_id
- contact.phone = d.phone_no
- contact.db_insert()
- contact.append('links',{'link_doctype':'Warehouse','link_name':d.name})
- contact.links[0].db_insert()
- except frappe.DuplicateEntryError:
- pass
-
\ No newline at end of file
diff --git a/erpnext/patches/v10_1/__init__.py b/erpnext/patches/v10_1/__init__.py
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/erpnext/patches/v11_0/__init__.py b/erpnext/patches/v11_0/__init__.py
deleted file mode 100644
index baffc48825..0000000000
--- a/erpnext/patches/v11_0/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/erpnext/patches/v11_0/remove_subscriber_doctype.py b/erpnext/patches/v11_0/remove_subscriber_doctype.py
deleted file mode 100644
index 4839a20f91..0000000000
--- a/erpnext/patches/v11_0/remove_subscriber_doctype.py
+++ /dev/null
@@ -1,16 +0,0 @@
-from __future__ import unicode_literals
-import frappe
-from frappe.model.utils.rename_field import rename_field
-
-def execute():
- """ copy subscribe field to customer """
- frappe.reload_doc("accounts","doctype","subscription")
-
- if frappe.db.exists("DocType", "Subscriber"):
- if frappe.db.has_column('Subscription','subscriber'):
- frappe.db.sql("""
- update `tabSubscription` s1
- set customer=(select customer from tabSubscriber where name=s1.subscriber)
- """)
-
- frappe.delete_doc("DocType", "Subscriber")
\ No newline at end of file
diff --git a/erpnext/patches/v11_0/rename_bom_wo_fields.py b/erpnext/patches/v11_0/rename_bom_wo_fields.py
index b4a740fabb..882ec84e64 100644
--- a/erpnext/patches/v11_0/rename_bom_wo_fields.py
+++ b/erpnext/patches/v11_0/rename_bom_wo_fields.py
@@ -6,6 +6,10 @@ import frappe
from frappe.model.utils.rename_field import rename_field
def execute():
+ # updating column value to handle field change from Data to Currency
+ changed_field = "base_scrap_material_cost"
+ frappe.db.sql(f"update `tabBOM` set {changed_field} = '0' where trim(coalesce({changed_field}, ''))= ''")
+
for doctype in ['BOM Explosion Item', 'BOM Item', 'Work Order Item', 'Item']:
if frappe.db.has_column(doctype, 'allow_transfer_for_manufacture'):
if doctype != 'Item':
diff --git a/erpnext/patches/v11_1/__init__.py b/erpnext/patches/v11_1/__init__.py
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/erpnext/patches/v12_0/__init__.py b/erpnext/patches/v12_0/__init__.py
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/erpnext/patches/v13_0/__init__.py b/erpnext/patches/v13_0/__init__.py
deleted file mode 100644
index baffc48825..0000000000
--- a/erpnext/patches/v13_0/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-from __future__ import unicode_literals
diff --git a/erpnext/patches/v13_0/healthcare_lab_module_rename_doctypes.py b/erpnext/patches/v13_0/healthcare_lab_module_rename_doctypes.py
index 9af0a8dbef..2549a1e91e 100644
--- a/erpnext/patches/v13_0/healthcare_lab_module_rename_doctypes.py
+++ b/erpnext/patches/v13_0/healthcare_lab_module_rename_doctypes.py
@@ -2,6 +2,7 @@ from __future__ import unicode_literals
import frappe
from frappe.model.utils.rename_field import rename_field
+
def execute():
if frappe.db.exists('DocType', 'Lab Test') and frappe.db.exists('DocType', 'Lab Test Template'):
# rename child doctypes
@@ -17,7 +18,12 @@ def execute():
frappe.reload_doc('healthcare', 'doctype', 'lab_test_template')
for old_dt, new_dt in doctypes.items():
- if not frappe.db.table_exists(new_dt) and frappe.db.table_exists(old_dt):
+ frappe.flags.link_fields = {}
+ should_rename = (
+ frappe.db.table_exists(old_dt)
+ and not frappe.db.table_exists(new_dt)
+ )
+ if should_rename:
frappe.reload_doc('healthcare', 'doctype', frappe.scrub(old_dt))
frappe.rename_doc('DocType', old_dt, new_dt, force=True)
frappe.reload_doc('healthcare', 'doctype', frappe.scrub(new_dt))
diff --git a/erpnext/patches/v4_0/__init__.py b/erpnext/patches/v4_0/__init__.py
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/erpnext/patches/v4_0/apply_user_permissions.py b/erpnext/patches/v4_0/apply_user_permissions.py
deleted file mode 100644
index 3c5d612c18..0000000000
--- a/erpnext/patches/v4_0/apply_user_permissions.py
+++ /dev/null
@@ -1,50 +0,0 @@
-# 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
-from erpnext.hr.doctype.employee.employee import EmployeeUserDisabledError
-
-def execute():
- update_hr_permissions()
- update_permissions()
- remove_duplicate_user_permissions()
- frappe.clear_cache()
-
-def update_hr_permissions():
- # add set user permissions rights to HR Manager
- frappe.db.sql("""update `tabDocPerm` set `set_user_permissions`=1 where parent in ('Employee', 'Leave Application')
- and role='HR Manager' and permlevel=0 and `read`=1""")
- docperm_meta = frappe.get_meta('DocPerm')
- if docperm_meta.get_field('apply_user_permissions'):
- # apply user permissions on Employee and Leave Application
- frappe.db.sql("""update `tabDocPerm` set `apply_user_permissions`=1 where parent in ('Employee', 'Leave Application')
- and role in ('Employee', 'Leave Approver') and permlevel=0 and `read`=1""")
-
- frappe.clear_cache()
-
- # save employees to run on_update events
- for employee in frappe.db.sql_list("""select name from `tabEmployee` where docstatus < 2"""):
- try:
- emp = frappe.get_doc("Employee", employee)
- emp.flags.ignore_mandatory = True
- emp.save()
- except EmployeeUserDisabledError:
- pass
-
-def update_permissions():
- # clear match conditions other than owner
- frappe.db.sql("""update tabDocPerm set `match`=''
- where ifnull(`match`,'') not in ('', 'owner')""")
-
-def remove_duplicate_user_permissions():
- # remove duplicate user_permissions (if they exist)
- for d in frappe.db.sql("""select parent, defkey, defvalue,
- count(*) as cnt from tabDefaultValue
- where parent not in ('__global', '__default')
- group by parent, defkey, defvalue""", as_dict=1):
- if d.cnt > 1:
- # order by parenttype so that user permission does not get removed!
- frappe.db.sql("""delete from tabDefaultValue where `parent`=%s and `defkey`=%s and
- `defvalue`=%s order by parenttype limit %s""", (d.parent, d.defkey, d.defvalue, d.cnt-1))
-
diff --git a/erpnext/patches/v4_0/countrywise_coa.py b/erpnext/patches/v4_0/countrywise_coa.py
deleted file mode 100644
index f45e6028c8..0000000000
--- a/erpnext/patches/v4_0/countrywise_coa.py
+++ /dev/null
@@ -1,29 +0,0 @@
-# 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():
- frappe.reload_doc("setup", 'doctype', "company")
- frappe.reload_doc("accounts", 'doctype', "account")
-
- frappe.db.sql("""update tabAccount set account_type='Cash'
- where account_type='Bank or Cash' and account_name in ('Cash', 'Cash In Hand')""")
-
- frappe.db.sql("""update tabAccount set account_type='Stock'
- where account_name = 'Stock Assets'""")
-
- ac_types = {"Fixed Asset Account": "Fixed Asset", "Bank or Cash": "Bank"}
- for old, new in ac_types.items():
- frappe.db.sql("""update tabAccount set account_type=%s
- where account_type=%s""", (new, old))
-
- try:
- frappe.db.sql("""update `tabAccount` set report_type =
- if(is_pl_account='Yes', 'Profit and Loss', 'Balance Sheet')""")
-
- frappe.db.sql("""update `tabAccount` set balance_must_be=debit_or_credit
- where ifnull(allow_negative_balance, 0) = 0""")
- except:
- pass
diff --git a/erpnext/patches/v4_0/create_custom_fields_for_india_specific_fields.py b/erpnext/patches/v4_0/create_custom_fields_for_india_specific_fields.py
deleted file mode 100644
index fe50e444b5..0000000000
--- a/erpnext/patches/v4_0/create_custom_fields_for_india_specific_fields.py
+++ /dev/null
@@ -1,63 +0,0 @@
-# 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
-from frappe.custom.doctype.custom_field.custom_field import create_custom_field_if_values_exist
-
-def execute():
- frappe.reload_doc("stock", "doctype", "purchase_receipt")
- frappe.reload_doc("hr", "doctype", "employee")
- frappe.reload_doc("Payroll", "doctype", "salary_slip")
-
- india_specific_fields = {
- "Purchase Receipt": [{
- "label": "Supplier Shipment No",
- "fieldname": "challan_no",
- "fieldtype": "Data",
- "insert_after": "is_subcontracted"
- }, {
- "label": "Supplier Shipment Date",
- "fieldname": "challan_date",
- "fieldtype": "Date",
- "insert_after": "is_subcontracted"
- }],
- "Employee": [{
- "label": "PAN Number",
- "fieldname": "pan_number",
- "fieldtype": "Data",
- "insert_after": "company_email"
- }, {
- "label": "Gratuity LIC Id",
- "fieldname": "gratuity_lic_id",
- "fieldtype": "Data",
- "insert_after": "company_email"
- }, {
- "label": "Esic Card No",
- "fieldname": "esic_card_no",
- "fieldtype": "Data",
- "insert_after": "bank_ac_no"
- }, {
- "label": "PF Number",
- "fieldname": "pf_number",
- "fieldtype": "Data",
- "insert_after": "bank_ac_no"
- }],
- "Salary Slip": [{
- "label": "Esic No",
- "fieldname": "esic_no",
- "fieldtype": "Data",
- "insert_after": "letter_head",
- "permlevel": 1
- }, {
- "label": "PF Number",
- "fieldname": "pf_no",
- "fieldtype": "Data",
- "insert_after": "letter_head",
- "permlevel": 1
- }]
- }
-
- for dt, docfields in india_specific_fields.items():
- for df in docfields:
- create_custom_field_if_values_exist(dt, df)
diff --git a/erpnext/patches/v4_0/create_price_list_if_missing.py b/erpnext/patches/v4_0/create_price_list_if_missing.py
deleted file mode 100644
index 039e52111c..0000000000
--- a/erpnext/patches/v4_0/create_price_list_if_missing.py
+++ /dev/null
@@ -1,35 +0,0 @@
-# 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
-from frappe import _
-from frappe.utils.nestedset import get_root_of
-
-def execute():
- # setup not complete
- if not frappe.db.sql("""select name from tabCompany limit 1"""):
- return
-
- if "shopping_cart" in frappe.get_installed_apps():
- frappe.reload_doc("shopping_cart", "doctype", "shopping_cart_settings")
-
- if not frappe.db.sql("select name from `tabPrice List` where buying=1"):
- create_price_list(_("Standard Buying"), buying=1)
-
- if not frappe.db.sql("select name from `tabPrice List` where selling=1"):
- create_price_list(_("Standard Selling"), selling=1)
-
-def create_price_list(pl_name, buying=0, selling=0):
- price_list = frappe.get_doc({
- "doctype": "Price List",
- "price_list_name": pl_name,
- "enabled": 1,
- "buying": buying,
- "selling": selling,
- "currency": frappe.db.get_default("currency"),
- "territories": [{
- "territory": get_root_of("Territory")
- }]
- })
- price_list.insert()
diff --git a/erpnext/patches/v4_0/customer_discount_to_pricing_rule.py b/erpnext/patches/v4_0/customer_discount_to_pricing_rule.py
deleted file mode 100644
index 1b260c48cc..0000000000
--- a/erpnext/patches/v4_0/customer_discount_to_pricing_rule.py
+++ /dev/null
@@ -1,33 +0,0 @@
-# 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
-from frappe.utils.nestedset import get_root_of
-
-def execute():
- frappe.reload_doc("accounts", "doctype", "pricing_rule")
-
- frappe.db.auto_commit_on_many_writes = True
-
- default_item_group = get_root_of("Item Group")
-
- for d in frappe.db.sql("""select * from `tabCustomer Discount`
- where ifnull(parent, '') != ''""", as_dict=1):
- if not d.discount:
- continue
-
- frappe.get_doc({
- "doctype": "Pricing Rule",
- "apply_on": "Item Group",
- "item_group": d.item_group or default_item_group,
- "applicable_for": "Customer",
- "customer": d.parent,
- "price_or_discount": "Discount Percentage",
- "discount_percentage": d.discount,
- "selling": 1
- }).insert()
-
- frappe.db.auto_commit_on_many_writes = False
-
- frappe.delete_doc("DocType", "Customer Discount")
diff --git a/erpnext/patches/v4_0/fields_to_be_renamed.py b/erpnext/patches/v4_0/fields_to_be_renamed.py
deleted file mode 100644
index cc17697132..0000000000
--- a/erpnext/patches/v4_0/fields_to_be_renamed.py
+++ /dev/null
@@ -1,109 +0,0 @@
-# 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
-from frappe.model.utils.rename_field import rename_field
-from frappe.modules import scrub, get_doctype_module
-
-rename_map = {
- "Quotation Item": [
- ["ref_rate", "price_list_rate"],
- ["base_ref_rate", "base_price_list_rate"],
- ["adj_rate", "discount_percentage"],
- ["export_rate", "rate"],
- ["basic_rate", "base_rate"],
- ["amount", "base_amount"],
- ["export_amount", "amount"]
- ],
-
- "Sales Order Item": [
- ["ref_rate", "price_list_rate"],
- ["base_ref_rate", "base_price_list_rate"],
- ["adj_rate", "discount_percentage"],
- ["export_rate", "rate"],
- ["basic_rate", "base_rate"],
- ["amount", "base_amount"],
- ["export_amount", "amount"],
- ["reserved_warehouse", "warehouse"]
- ],
-
- "Delivery Note Item": [
- ["ref_rate", "price_list_rate"],
- ["base_ref_rate", "base_price_list_rate"],
- ["adj_rate", "discount_percentage"],
- ["export_rate", "rate"],
- ["basic_rate", "base_rate"],
- ["amount", "base_amount"],
- ["export_amount", "amount"]
- ],
-
- "Sales Invoice Item": [
- ["ref_rate", "price_list_rate"],
- ["base_ref_rate", "base_price_list_rate"],
- ["adj_rate", "discount_percentage"],
- ["export_rate", "rate"],
- ["basic_rate", "base_rate"],
- ["amount", "base_amount"],
- ["export_amount", "amount"]
- ],
-
- "Supplier Quotation Item": [
- ["import_ref_rate", "price_list_rate"],
- ["purchase_ref_rate", "base_price_list_rate"],
- ["discount_rate", "discount_percentage"],
- ["import_rate", "rate"],
- ["purchase_rate", "base_rate"],
- ["amount", "base_amount"],
- ["import_amount", "amount"]
- ],
-
- "Purchase Order Item": [
- ["import_ref_rate", "price_list_rate"],
- ["purchase_ref_rate", "base_price_list_rate"],
- ["discount_rate", "discount_percentage"],
- ["import_rate", "rate"],
- ["purchase_rate", "base_rate"],
- ["amount", "base_amount"],
- ["import_amount", "amount"]
- ],
-
- "Purchase Receipt Item": [
- ["import_ref_rate", "price_list_rate"],
- ["purchase_ref_rate", "base_price_list_rate"],
- ["discount_rate", "discount_percentage"],
- ["import_rate", "rate"],
- ["purchase_rate", "base_rate"],
- ["amount", "base_amount"],
- ["import_amount", "amount"]
- ],
-
- "Purchase Invoice Item": [
- ["import_ref_rate", "price_list_rate"],
- ["purchase_ref_rate", "base_price_list_rate"],
- ["discount_rate", "discount_percentage"],
- ["import_rate", "rate"],
- ["rate", "base_rate"],
- ["amount", "base_amount"],
- ["import_amount", "amount"],
- ["expense_head", "expense_account"]
- ],
-
- "Item": [
- ["purchase_account", "expense_account"],
- ["default_sales_cost_center", "selling_cost_center"],
- ["cost_center", "buying_cost_center"],
- ["default_income_account", "income_account"],
- ],
- "Item Price": [
- ["ref_rate", "price_list_rate"]
- ]
-}
-
-def execute():
- for dn in rename_map:
- frappe.reload_doc(get_doctype_module(dn), "doctype", scrub(dn))
-
- for dt, field_list in rename_map.items():
- for field in field_list:
- rename_field(dt, field[0], field[1])
diff --git a/erpnext/patches/v4_0/fix_address_template.py b/erpnext/patches/v4_0/fix_address_template.py
deleted file mode 100644
index 905e3db3e8..0000000000
--- a/erpnext/patches/v4_0/fix_address_template.py
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
-
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- missing_line = """{{ address_line1 }}
"""
- for name, template in frappe.db.sql("select name, template from `tabAddress Template`"):
- if missing_line not in template:
- d = frappe.get_doc("Address Template", name)
- d.template = missing_line + d.template
- d.save()
diff --git a/erpnext/patches/v4_0/fix_case_of_hr_module_def.py b/erpnext/patches/v4_0/fix_case_of_hr_module_def.py
deleted file mode 100644
index e77b427b77..0000000000
--- a/erpnext/patches/v4_0/fix_case_of_hr_module_def.py
+++ /dev/null
@@ -1,13 +0,0 @@
-# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
-
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- hr = frappe.db.get_value("Module Def", "HR")
- if hr == "Hr":
- frappe.rename_doc("Module Def", "Hr", "HR")
- frappe.db.set_value("Module Def", "HR", "module_name", "HR")
-
- frappe.clear_cache()
- frappe.setup_module_map()
diff --git a/erpnext/patches/v4_0/fix_contact_address.py b/erpnext/patches/v4_0/fix_contact_address.py
deleted file mode 100644
index 6a3e106b8c..0000000000
--- a/erpnext/patches/v4_0/fix_contact_address.py
+++ /dev/null
@@ -1,13 +0,0 @@
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- frappe.reload_doc("website", "doctype", "contact_us_settings")
- address = frappe.db.get_value("Contact Us Settings", None, "address")
- if address:
- address = frappe.get_doc("Address", address)
- contact = frappe.get_doc("Contact Us Settings", "Contact Us Settings")
- for f in ("address_title", "address_line1", "address_line2", "city", "state", "country", "pincode"):
- contact.set(f, address.get(f))
-
- contact.save()
\ No newline at end of file
diff --git a/erpnext/patches/v4_0/fix_employee_user_id.py b/erpnext/patches/v4_0/fix_employee_user_id.py
deleted file mode 100644
index 6f449f97bb..0000000000
--- a/erpnext/patches/v4_0/fix_employee_user_id.py
+++ /dev/null
@@ -1,23 +0,0 @@
-# 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
-from frappe.utils import get_fullname
-
-def execute():
- for user_id in frappe.db.sql_list("""select distinct user_id from `tabEmployee`
- where ifnull(user_id, '')!=''
- group by user_id having count(name) > 1"""):
-
- fullname = get_fullname(user_id)
- employee = frappe.db.get_value("Employee", {"employee_name": fullname, "user_id": user_id})
-
- if employee:
- frappe.db.sql("""update `tabEmployee` set user_id=null
- where user_id=%s and name!=%s""", (user_id, employee))
- else:
- count = frappe.db.sql("""select count(*) from `tabEmployee` where user_id=%s""", user_id)[0][0]
- frappe.db.sql("""update `tabEmployee` set user_id=null
- where user_id=%s limit %s""", (user_id, count - 1))
diff --git a/erpnext/patches/v4_0/global_defaults_to_system_settings.py b/erpnext/patches/v4_0/global_defaults_to_system_settings.py
deleted file mode 100644
index 2905fe1e6a..0000000000
--- a/erpnext/patches/v4_0/global_defaults_to_system_settings.py
+++ /dev/null
@@ -1,39 +0,0 @@
-# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
-# MIT License. See license.txt
-
-from __future__ import unicode_literals
-
-import frappe
-from collections import Counter
-from frappe.core.doctype.user.user import STANDARD_USERS
-
-def execute():
- frappe.reload_doc("core", "doctype", "system_settings")
- system_settings = frappe.get_doc("System Settings")
-
- # set values from global_defauls
- global_defaults = frappe.db.get_value("Global Defaults", None,
- ["time_zone", "date_format", "number_format", "float_precision", "session_expiry"], as_dict=True)
-
- if global_defaults:
- for key, val in global_defaults.items():
- if not system_settings.get(key):
- system_settings.set(key, val)
-
- # language
- if not system_settings.get("language"):
- # find most common language
- lang = frappe.db.sql_list("""select language from `tabUser`
- where ifnull(language, '')!='' and language not like "Loading%%" and name not in ({standard_users})""".format(
- standard_users=", ".join(["%s"]*len(STANDARD_USERS))), tuple(STANDARD_USERS))
- lang = Counter(lang).most_common(1)
- lang = (len(lang) > 0) and lang[0][0] or "english"
-
- system_settings.language = lang
-
- system_settings.flags.ignore_mandatory = True
- system_settings.save()
-
- global_defaults = frappe.get_doc("Global Defaults")
- global_defaults.flags.ignore_mandatory = True
- global_defaults.save()
diff --git a/erpnext/patches/v4_0/import_country_codes.py b/erpnext/patches/v4_0/import_country_codes.py
deleted file mode 100644
index 43e23d5b63..0000000000
--- a/erpnext/patches/v4_0/import_country_codes.py
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
-# MIT License. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-from frappe.geo.country_info import get_all
-from frappe.utils.install import import_country_and_currency
-
-from six import iteritems
-
-def execute():
- frappe.reload_doc("setup", "doctype", "country")
- import_country_and_currency()
- for name, country in iteritems(get_all()):
- frappe.set_value("Country", name, "code", country.get("code"))
\ No newline at end of file
diff --git a/erpnext/patches/v4_0/map_charge_to_taxes_and_charges.py b/erpnext/patches/v4_0/map_charge_to_taxes_and_charges.py
deleted file mode 100644
index 97e217aa05..0000000000
--- a/erpnext/patches/v4_0/map_charge_to_taxes_and_charges.py
+++ /dev/null
@@ -1,16 +0,0 @@
-# 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():
- # update sales cycle
- for d in ['Sales Invoice', 'Sales Order', 'Quotation', 'Delivery Note']:
- frappe.db.sql("""update `tab%s` set taxes_and_charges=charge""" % d)
-
- # update purchase cycle
- for d in ['Purchase Invoice', 'Purchase Order', 'Supplier Quotation', 'Purchase Receipt']:
- frappe.db.sql("""update `tab%s` set taxes_and_charges=purchase_other_charges""" % d)
-
- frappe.db.sql("""update `tabPurchase Taxes and Charges` set parentfield='other_charges'""")
diff --git a/erpnext/patches/v4_0/move_warehouse_user_to_restrictions.py b/erpnext/patches/v4_0/move_warehouse_user_to_restrictions.py
deleted file mode 100644
index 8b81936d8d..0000000000
--- a/erpnext/patches/v4_0/move_warehouse_user_to_restrictions.py
+++ /dev/null
@@ -1,13 +0,0 @@
-# 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
-import frappe.permissions
-
-def execute():
- for warehouse, user in frappe.db.sql("""select parent, user from `tabWarehouse User`"""):
- frappe.permissions.add_user_permission("Warehouse", warehouse, user)
-
- frappe.delete_doc_if_exists("DocType", "Warehouse User")
- frappe.reload_doc("stock", "doctype", "warehouse")
diff --git a/erpnext/patches/v4_0/new_address_template.py b/erpnext/patches/v4_0/new_address_template.py
deleted file mode 100644
index fa6602706e..0000000000
--- a/erpnext/patches/v4_0/new_address_template.py
+++ /dev/null
@@ -1,14 +0,0 @@
-from __future__ import print_function, unicode_literals
-import frappe
-
-def execute():
- frappe.reload_doc("utilities", "doctype", "address_template")
- if not frappe.db.sql("select name from `tabAddress Template`"):
- try:
- d = frappe.new_doc("Address Template")
- d.update({"country":frappe.db.get_default("country") or
- frappe.db.get_value("Global Defaults", "Global Defaults", "country")})
- d.insert()
- except:
- print(frappe.get_traceback())
-
diff --git a/erpnext/patches/v4_0/reload_sales_print_format.py b/erpnext/patches/v4_0/reload_sales_print_format.py
deleted file mode 100644
index b8f090f9f3..0000000000
--- a/erpnext/patches/v4_0/reload_sales_print_format.py
+++ /dev/null
@@ -1,8 +0,0 @@
-# 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():
- frappe.reload_doc('accounts', 'Print Format', 'POS Invoice')
diff --git a/erpnext/patches/v4_0/remove_employee_role_if_no_employee.py b/erpnext/patches/v4_0/remove_employee_role_if_no_employee.py
deleted file mode 100644
index 8766ace54f..0000000000
--- a/erpnext/patches/v4_0/remove_employee_role_if_no_employee.py
+++ /dev/null
@@ -1,18 +0,0 @@
-# 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
-import frappe.permissions
-
-def execute():
- for user in frappe.db.sql_list("select distinct parent from `tabHas Role` where role='Employee'"):
- # if employee record does not exists, remove employee role!
- if not frappe.db.get_value("Employee", {"user_id": user}):
- try:
- user = frappe.get_doc("User", user)
- for role in user.get("roles", {"role": "Employee"}):
- user.get("roles").remove(role)
- user.save()
- except frappe.DoesNotExistError:
- pass
diff --git a/erpnext/patches/v4_0/remove_module_home_pages.py b/erpnext/patches/v4_0/remove_module_home_pages.py
deleted file mode 100644
index a2720e0ebf..0000000000
--- a/erpnext/patches/v4_0/remove_module_home_pages.py
+++ /dev/null
@@ -1,10 +0,0 @@
-# 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():
- for page in ("accounts-home", "website-home", "support-home", "stock-home", "selling-home", "projects-home",
- "manufacturing-home", "hr-home", "buying-home"):
- frappe.delete_doc("Page", page)
\ No newline at end of file
diff --git a/erpnext/patches/v4_0/rename_sitemap_to_route.py b/erpnext/patches/v4_0/rename_sitemap_to_route.py
deleted file mode 100644
index ffb1fda144..0000000000
--- a/erpnext/patches/v4_0/rename_sitemap_to_route.py
+++ /dev/null
@@ -1,17 +0,0 @@
-from __future__ import unicode_literals
-import frappe
-import frappe.model
-
-def execute():
- frappe.reload_doc("setup", "doctype", "item_group")
- frappe.reload_doc("stock", "doctype", "item")
- frappe.reload_doc("setup", "doctype", "sales_partner")
-
- try:
- frappe.model.rename_field("Item Group", "parent_website_sitemap", "parent_website_route")
- frappe.model.rename_field("Item", "parent_website_sitemap", "parent_website_route")
- frappe.model.rename_field("Sales Partner", "parent_website_sitemap",
- "parent_website_route")
- except Exception as e:
- if e.args[0]!=1054:
- raise
diff --git a/erpnext/patches/v4_0/reset_permissions_for_masters.py b/erpnext/patches/v4_0/reset_permissions_for_masters.py
deleted file mode 100644
index bc1b438e2b..0000000000
--- a/erpnext/patches/v4_0/reset_permissions_for_masters.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import print_function, unicode_literals
-from frappe.permissions import reset_perms
-
-def execute():
- for doctype in ("About Us Settings", "Accounts Settings", "Activity Type",
- "Blog Category", "Blog Settings", "Blogger", "Branch", "Brand", "Buying Settings",
- "Communication", "Company", "Contact Us Settings",
- "Country", "Currency", "Currency Exchange", "Deduction Type", "Department",
- "Designation", "Earning Type", "Event", "Feed", "File", "Fiscal Year",
- "HR Settings", "Industry Type", "Leave Type", "Letter Head",
- "Mode of Payment", "Module Def", "Naming Series", "POS Setting", "Print Heading",
- "Report", "Role", "Selling Settings", "Stock Settings", "Supplier Type", "UOM"):
- try:
- reset_perms(doctype)
- except:
- print("Error resetting perms for", doctype)
- raise
diff --git a/erpnext/patches/v4_0/save_default_letterhead.py b/erpnext/patches/v4_0/save_default_letterhead.py
deleted file mode 100644
index 5d75f096b3..0000000000
--- a/erpnext/patches/v4_0/save_default_letterhead.py
+++ /dev/null
@@ -1,13 +0,0 @@
-# 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():
- """save default letterhead to set default_letter_head_content"""
- try:
- letter_head = frappe.get_doc("Letter Head", {"is_default": 1})
- letter_head.save()
- except frappe.DoesNotExistError:
- pass
diff --git a/erpnext/patches/v4_0/set_pricing_rule_for_buying_or_selling.py b/erpnext/patches/v4_0/set_pricing_rule_for_buying_or_selling.py
deleted file mode 100644
index 7e472e2195..0000000000
--- a/erpnext/patches/v4_0/set_pricing_rule_for_buying_or_selling.py
+++ /dev/null
@@ -1,13 +0,0 @@
-# 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():
- frappe.reload_doc("accounts", "doctype", "pricing_rule")
- frappe.db.sql("""update `tabPricing Rule` set selling=1 where ifnull(applicable_for, '') in
- ('', 'Customer', 'Customer Group', 'Territory', 'Sales Partner', 'Campaign')""")
-
- frappe.db.sql("""update `tabPricing Rule` set buying=1 where ifnull(applicable_for, '') in
- ('', 'Supplier', 'Supplier Type')""")
diff --git a/erpnext/patches/v4_0/split_email_settings.py b/erpnext/patches/v4_0/split_email_settings.py
deleted file mode 100644
index 5d1dea60ee..0000000000
--- a/erpnext/patches/v4_0/split_email_settings.py
+++ /dev/null
@@ -1,67 +0,0 @@
-# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import print_function, unicode_literals
-import frappe
-
-def execute():
- print("WARNING!!!! Email Settings not migrated. Please setup your email again.")
-
- # this will happen if you are migrating very old accounts
- # comment out this line below and remember to create new Email Accounts
- # for incoming and outgoing mails
- raise Exception
-
- return
-
-
- frappe.reload_doc("core", "doctype", "outgoing_email_settings")
- frappe.reload_doc("support", "doctype", "support_email_settings")
-
- email_settings = get_email_settings()
- map_outgoing_email_settings(email_settings)
- map_support_email_settings(email_settings)
-
-
-def map_outgoing_email_settings(email_settings):
- outgoing_email_settings = frappe.get_doc("Outgoing Email Settings")
- for fieldname in (("outgoing_mail_server", "mail_server"),
- "use_ssl", "mail_port", "mail_login", "mail_password",
- "always_use_login_id_as_sender", "auto_email_id"):
-
- if isinstance(fieldname, tuple):
- from_fieldname, to_fieldname = fieldname
- else:
- from_fieldname = to_fieldname = fieldname
-
- outgoing_email_settings.set(to_fieldname, email_settings.get(from_fieldname))
-
- outgoing_email_settings._fix_numeric_types()
- outgoing_email_settings.save()
-
-def map_support_email_settings(email_settings):
- support_email_settings = frappe.get_doc("Support Email Settings")
-
- for fieldname in ("sync_support_mails", "support_email",
- ("support_host", "mail_server"),
- ("support_use_ssl", "use_ssl"),
- ("support_username", "mail_login"),
- ("support_password", "mail_password"),
- "support_signature", "send_autoreply", "support_autoreply"):
-
- if isinstance(fieldname, tuple):
- from_fieldname, to_fieldname = fieldname
- else:
- from_fieldname = to_fieldname = fieldname
-
- support_email_settings.set(to_fieldname, email_settings.get(from_fieldname))
-
- support_email_settings._fix_numeric_types()
- support_email_settings.save()
-
-def get_email_settings():
- ret = {}
- for field, value in frappe.db.sql("select field, value from tabSingles where doctype='Email Settings'"):
- ret[field] = value
- return ret
-
diff --git a/erpnext/patches/v4_0/update_account_root_type.py b/erpnext/patches/v4_0/update_account_root_type.py
deleted file mode 100644
index 15ddf032a4..0000000000
--- a/erpnext/patches/v4_0/update_account_root_type.py
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import print_function, unicode_literals
-import frappe
-
-def execute():
- frappe.reload_doc("accounts", "doctype", "account")
-
- account_table_columns = frappe.db.get_table_columns("Account")
- if "debit_or_credit" in account_table_columns and "is_pl_account" in account_table_columns:
- frappe.db.sql("""UPDATE tabAccount
- SET root_type = CASE
- WHEN (debit_or_credit='Debit' and is_pl_account = 'No') THEN 'Asset'
- WHEN (debit_or_credit='Credit' and is_pl_account = 'No') THEN 'Liability'
- WHEN (debit_or_credit='Debit' and is_pl_account = 'Yes') THEN 'Expense'
- WHEN (debit_or_credit='Credit' and is_pl_account = 'Yes') THEN 'Income'
- END
- WHERE ifnull(parent_account, '') = ''
- """)
-
- else:
- for key, root_type in (("asset", "Asset"), ("liabilities", "Liability"), ("expense", "Expense"),
- ("income", "Income")):
- frappe.db.sql("""update tabAccount set root_type=%s where name like %s
- and ifnull(parent_account, '')=''""", (root_type, "%" + key + "%"))
-
- for root in frappe.db.sql("""SELECT name, lft, rgt, root_type FROM `tabAccount`
- WHERE ifnull(parent_account, '')=''""", as_dict=True):
- if root.root_type:
- frappe.db.sql("""UPDATE tabAccount SET root_type=%s WHERE lft>%s and rgt<%s""",
- (root.root_type, root.lft, root.rgt))
- else:
- print(b"Root type not found for {0}".format(root.name.encode("utf-8")))
diff --git a/erpnext/patches/v4_0/update_custom_print_formats_for_renamed_fields.py b/erpnext/patches/v4_0/update_custom_print_formats_for_renamed_fields.py
deleted file mode 100644
index d784a1b182..0000000000
--- a/erpnext/patches/v4_0/update_custom_print_formats_for_renamed_fields.py
+++ /dev/null
@@ -1,36 +0,0 @@
-# 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
-import re
-
-def execute():
- # NOTE: sequence is important
- fields_list = (
- ("amount", "base_amount"),
- ("ref_rate", "price_list_rate"),
- ("base_ref_rate", "base_price_list_rate"),
- ("adj_rate", "discount_percentage"),
- ("export_rate", "rate"),
- ("basic_rate", "base_rate"),
- ("export_amount", "amount"),
- ("reserved_warehouse", "warehouse"),
- ("import_ref_rate", "price_list_rate"),
- ("purchase_ref_rate", "base_price_list_rate"),
- ("discount_rate", "discount_percentage"),
- ("import_rate", "rate"),
- ("purchase_rate", "base_rate"),
- ("import_amount", "amount")
- )
-
- condition = " or ".join("""html like "%%{}%%" """.format(d[0].replace("_", "\\_")) for d in fields_list
- if d[0] != "amount")
-
- for name, html in frappe.db.sql("""select name, html from `tabPrint Format`
- where standard = 'No' and ({}) and html not like '%%frappe.%%'""".format(condition)):
- html = html.replace("wn.", "frappe.")
- for from_field, to_field in fields_list:
- html = re.sub(r"\b{}\b".format(from_field), to_field, html)
-
- frappe.db.set_value("Print Format", name, "html", html)
diff --git a/erpnext/patches/v4_0/update_incharge_name_to_sales_person_in_maintenance_schedule.py b/erpnext/patches/v4_0/update_incharge_name_to_sales_person_in_maintenance_schedule.py
deleted file mode 100644
index fe66a5e3ef..0000000000
--- a/erpnext/patches/v4_0/update_incharge_name_to_sales_person_in_maintenance_schedule.py
+++ /dev/null
@@ -1,12 +0,0 @@
-# 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():
- frappe.reload_doc("support", "doctype", "schedules")
- frappe.reload_doc("support", "doctype", "maintenance_schedule_item")
-
- frappe.db.sql("""update `tabMaintenance Schedule Detail` set sales_person=incharge_name""")
- frappe.db.sql("""update `tabMaintenance Schedule Item` set sales_person=incharge_name""")
\ No newline at end of file
diff --git a/erpnext/patches/v4_0/update_other_charges_in_custom_purchase_print_formats.py b/erpnext/patches/v4_0/update_other_charges_in_custom_purchase_print_formats.py
deleted file mode 100644
index 2e2e77a9fc..0000000000
--- a/erpnext/patches/v4_0/update_other_charges_in_custom_purchase_print_formats.py
+++ /dev/null
@@ -1,12 +0,0 @@
-# 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
-import re
-
-def execute():
- for name, html in frappe.db.sql("""select name, html from `tabPrint Format`
- where standard = 'No' and html like '%%purchase\\_tax\\_details%%'"""):
- html = re.sub(r"\bpurchase_tax_details\b", "taxes", html)
- frappe.db.set_value("Print Format", name, "html", html)
diff --git a/erpnext/patches/v4_0/update_tax_amount_after_discount.py b/erpnext/patches/v4_0/update_tax_amount_after_discount.py
deleted file mode 100644
index d10329ef37..0000000000
--- a/erpnext/patches/v4_0/update_tax_amount_after_discount.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# 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():
- frappe.reload_doc("accounts", "doctype", "sales_taxes_and_charges")
- docs_with_discount_amount = frappe._dict()
- for dt in ["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"]:
- records = frappe.db.sql_list("""select name from `tab%s`
- where ifnull(discount_amount, 0) > 0 and docstatus=1""" % dt)
- docs_with_discount_amount[dt] = records
-
- for dt, discounted_records in docs_with_discount_amount.items():
- frappe.db.sql("""update `tabSales Taxes and Charges`
- set tax_amount_after_discount_amount = tax_amount
- where parenttype = %s and parent not in (%s)""" %
- ('%s', ', '.join(['%s']*(len(discounted_records)+1))),
- tuple([dt, ''] + discounted_records))
diff --git a/erpnext/patches/v4_0/update_user_properties.py b/erpnext/patches/v4_0/update_user_properties.py
deleted file mode 100644
index f2085ce4df..0000000000
--- a/erpnext/patches/v4_0/update_user_properties.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# 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
-import frappe.permissions
-import frappe.defaults
-
-def execute():
- frappe.reload_doc("core", "doctype", "docfield")
- frappe.reload_doc("hr", "doctype", "employee")
-
- set_print_email_permissions()
- migrate_user_properties_to_user_permissions()
-
- frappe.clear_cache()
-
-def migrate_user_properties_to_user_permissions():
- for d in frappe.db.sql("""select parent, defkey, defvalue from tabDefaultValue
- where parent not in ('__global', '__default')""", as_dict=True):
- df = frappe.db.sql("""select options from tabDocField
- where fieldname=%s and fieldtype='Link'""", d.defkey, as_dict=True)
-
- if df:
- frappe.db.sql("""update tabDefaultValue
- set defkey=%s, parenttype='User Permission'
- where defkey=%s and
- parent not in ('__global', '__default')""", (df[0].options, d.defkey))
-
-def set_print_email_permissions():
- # reset Page perms
- from frappe.core.page.permission_manager.permission_manager import reset
- reset("Page")
- reset("Report")
-
- if "allow_print" not in frappe.db.get_table_columns("DocType"):
- return
-
- # patch to move print, email into DocPerm
- # NOTE: allow_print and allow_email are misnamed. They were used to hide print / hide email
- for doctype, hide_print, hide_email in frappe.db.sql("""select name, ifnull(allow_print, 0), ifnull(allow_email, 0)
- from `tabDocType` where ifnull(issingle, 0)=0 and ifnull(istable, 0)=0 and
- (ifnull(allow_print, 0)=0 or ifnull(allow_email, 0)=0)"""):
-
- if not hide_print:
- frappe.db.sql("""update `tabDocPerm` set `print`=1
- where permlevel=0 and `read`=1 and parent=%s""", doctype)
-
- if not hide_email:
- frappe.db.sql("""update `tabDocPerm` set `email`=1
- where permlevel=0 and `read`=1 and parent=%s""", doctype)
diff --git a/erpnext/patches/v4_0/update_users_report_view_settings.py b/erpnext/patches/v4_0/update_users_report_view_settings.py
deleted file mode 100644
index 6f216f5b38..0000000000
--- a/erpnext/patches/v4_0/update_users_report_view_settings.py
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-
-from frappe.model.utils.rename_field import update_users_report_view_settings
-from erpnext.patches.v4_0.fields_to_be_renamed import rename_map
-
-def execute():
- for dt, field_list in rename_map.items():
- for field in field_list:
- update_users_report_view_settings(dt, field[0], field[1])
diff --git a/erpnext/patches/v4_0/validate_v3_patch.py b/erpnext/patches/v4_0/validate_v3_patch.py
deleted file mode 100644
index 3df39edea6..0000000000
--- a/erpnext/patches/v4_0/validate_v3_patch.py
+++ /dev/null
@@ -1,11 +0,0 @@
-# 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():
- from frappe.modules.patch_handler import executed
- last_v3_patch = 'patches.1401.fix_pos_outstanding'
- if not executed(last_v3_patch):
- raise Exception("site not ready to migrate to version 4")
diff --git a/erpnext/patches/v4_1/__init__.py b/erpnext/patches/v4_1/__init__.py
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/erpnext/patches/v4_1/fix_delivery_and_billing_status.py b/erpnext/patches/v4_1/fix_delivery_and_billing_status.py
deleted file mode 100644
index 8cc6a4b0be..0000000000
--- a/erpnext/patches/v4_1/fix_delivery_and_billing_status.py
+++ /dev/null
@@ -1,12 +0,0 @@
-# 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():
- frappe.db.sql("""update `tabSales Order` set delivery_status = 'Not Delivered'
- where delivery_status = 'Delivered' and ifnull(per_delivered, 0) = 0 and ifnull(docstatus, 0) in (0, 1)""")
-
- frappe.db.sql("""update `tabSales Order` set billing_status = 'Not Billed'
- where billing_status = 'Billed' and ifnull(per_billed, 0) = 0 and ifnull(docstatus, 0) in (0, 1)""")
diff --git a/erpnext/patches/v4_1/fix_jv_remarks.py b/erpnext/patches/v4_1/fix_jv_remarks.py
deleted file mode 100644
index e07bf05f1a..0000000000
--- a/erpnext/patches/v4_1/fix_jv_remarks.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# 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():
- reference_date = guess_reference_date()
- for name in frappe.db.sql_list("""select name from `tabJournal Entry`
- where date(creation)>=%s""", reference_date):
- jv = frappe.get_doc("Journal Entry", name)
- try:
- jv.create_remarks()
- except frappe.MandatoryError:
- pass
- else:
- frappe.db.set_value("Journal Entry", jv.name, "remark", jv.remark)
-
-def guess_reference_date():
- return (frappe.db.get_value("Patch Log", {"patch": "erpnext.patches.v4_0.validate_v3_patch"}, "creation")
- or "2014-05-06")
diff --git a/erpnext/patches/v4_1/fix_sales_order_delivered_status.py b/erpnext/patches/v4_1/fix_sales_order_delivered_status.py
deleted file mode 100644
index 66037b8958..0000000000
--- a/erpnext/patches/v4_1/fix_sales_order_delivered_status.py
+++ /dev/null
@@ -1,15 +0,0 @@
-# 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():
- for si in frappe.db.sql_list("""select name
- from `tabSales Invoice`
- where ifnull(update_stock,0) = 1 and docstatus = 1 and exists(
- select name from `tabSales Invoice Item` where parent=`tabSales Invoice`.name and
- ifnull(so_detail, "") != "")"""):
-
- invoice = frappe.get_doc("Sales Invoice", si)
- invoice.update_qty()
diff --git a/erpnext/patches/v4_1/set_outgoing_email_footer.py b/erpnext/patches/v4_1/set_outgoing_email_footer.py
deleted file mode 100644
index 54d016bf5f..0000000000
--- a/erpnext/patches/v4_1/set_outgoing_email_footer.py
+++ /dev/null
@@ -1,12 +0,0 @@
-# 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
-from erpnext.setup.install import default_mail_footer
-
-def execute():
- return
- mail_footer = frappe.db.get_default('mail_footer') or ''
- mail_footer += default_mail_footer
- frappe.db.set_value("Outgoing Email Settings", "Outgoing Email Settings", "footer", mail_footer)
diff --git a/erpnext/patches/v4_2/__init__.py b/erpnext/patches/v4_2/__init__.py
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/erpnext/patches/v4_2/add_currency_turkish_lira.py b/erpnext/patches/v4_2/add_currency_turkish_lira.py
deleted file mode 100644
index 1a46089f94..0000000000
--- a/erpnext/patches/v4_2/add_currency_turkish_lira.py
+++ /dev/null
@@ -1,10 +0,0 @@
-# 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():
- return
- # country = get_country_info(country="Turkey")
- # add_country_and_currency("Turkey", country)
diff --git a/erpnext/patches/v4_2/default_website_style.py b/erpnext/patches/v4_2/default_website_style.py
deleted file mode 100644
index e8f9502ea6..0000000000
--- a/erpnext/patches/v4_2/default_website_style.py
+++ /dev/null
@@ -1,11 +0,0 @@
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- return
- # frappe.reload_doc('website', 'doctype', 'style_settings')
- # style_settings = frappe.get_doc("Style Settings", "Style Settings")
- # if not style_settings.apply_style:
- # style_settings.update(default_properties)
- # style_settings.apply_style = 1
- # style_settings.save()
diff --git a/erpnext/patches/v4_2/delete_gl_entries_for_cancelled_invoices.py b/erpnext/patches/v4_2/delete_gl_entries_for_cancelled_invoices.py
deleted file mode 100644
index 169b1e2927..0000000000
--- a/erpnext/patches/v4_2/delete_gl_entries_for_cancelled_invoices.py
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- cancelled_invoices = frappe.db.sql_list("""select name from `tabSales Invoice`
- where docstatus = 2 and ifnull(update_stock, 0) = 1""")
-
- if cancelled_invoices:
- frappe.db.sql("""delete from `tabGL Entry`
- where voucher_type = 'Sales Invoice' and voucher_no in (%s)"""
- % (', '.join(['%s']*len(cancelled_invoices))), tuple(cancelled_invoices))
\ No newline at end of file
diff --git a/erpnext/patches/v4_2/delete_old_print_formats.py b/erpnext/patches/v4_2/delete_old_print_formats.py
deleted file mode 100644
index cacdb85ce0..0000000000
--- a/erpnext/patches/v4_2/delete_old_print_formats.py
+++ /dev/null
@@ -1,23 +0,0 @@
-# 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():
- old_formats = ("Sales Invoice", "Sales Invoice Spartan", "Sales Invoice Modern",
- "Sales Invoice Classic",
- "Sales Order Spartan", "Sales Order Modern", "Sales Order Classic",
- "Purchase Order Spartan", "Purchase Order Modern", "Purchase Order Classic",
- "Quotation Spartan", "Quotation Modern", "Quotation Classic",
- "Delivery Note Spartan", "Delivery Note Modern", "Delivery Note Classic")
-
- for fmt in old_formats:
- # update property setter
- for ps in frappe.db.sql_list("""select name from `tabProperty Setter`
- where property='default_print_format' and value=%s""", fmt):
- ps = frappe.get_doc("Property Setter", ps)
- ps.value = "Standard"
- ps.save(ignore_permissions = True)
-
- frappe.delete_doc_if_exists("Print Format", fmt)
diff --git a/erpnext/patches/v4_2/discount_amount.py b/erpnext/patches/v4_2/discount_amount.py
deleted file mode 100644
index 7ab61bdbea..0000000000
--- a/erpnext/patches/v4_2/discount_amount.py
+++ /dev/null
@@ -1,12 +0,0 @@
-# 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
-from frappe.modules import scrub, get_doctype_module
-
-def execute():
- for dt in ["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"]:
- frappe.reload_doc(get_doctype_module(dt), "doctype", scrub(dt))
- frappe.db.sql("""update `tab{0}` set base_discount_amount=discount_amount,
- discount_amount=discount_amount/conversion_rate""".format(dt))
diff --git a/erpnext/patches/v4_2/fix_account_master_type.py b/erpnext/patches/v4_2/fix_account_master_type.py
deleted file mode 100644
index 99444ce83b..0000000000
--- a/erpnext/patches/v4_2/fix_account_master_type.py
+++ /dev/null
@@ -1,12 +0,0 @@
-# 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():
- for d in frappe.db.sql("""select name from `tabAccount`
- where ifnull(master_type, '') not in ('Customer', 'Supplier', 'Employee', '') and docstatus=0"""):
- ac = frappe.get_doc("Account", d[0])
- ac.master_type = None
- ac.save()
diff --git a/erpnext/patches/v4_2/fix_gl_entries_for_stock_transactions.py b/erpnext/patches/v4_2/fix_gl_entries_for_stock_transactions.py
deleted file mode 100644
index c6c94d4179..0000000000
--- a/erpnext/patches/v4_2/fix_gl_entries_for_stock_transactions.py
+++ /dev/null
@@ -1,54 +0,0 @@
-# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import print_function, unicode_literals
-import frappe
-from frappe.utils import flt
-
-def execute():
- from erpnext.stock.stock_balance import repost
- repost(allow_zero_rate=True, only_actual=True)
-
- frappe.reload_doctype("Account")
-
- warehouse_account = frappe.db.sql("""select name, master_name from tabAccount
- where ifnull(account_type, '') = 'Warehouse'""")
- if warehouse_account:
- warehouses = [d[1] for d in warehouse_account]
- accounts = [d[0] for d in warehouse_account]
-
- stock_vouchers = frappe.db.sql("""select distinct sle.voucher_type, sle.voucher_no
- from `tabStock Ledger Entry` sle
- where sle.warehouse in (%s)
- order by sle.posting_date""" %
- ', '.join(['%s']*len(warehouses)), tuple(warehouses))
-
- rejected = []
- for voucher_type, voucher_no in stock_vouchers:
- stock_bal = frappe.db.sql("""select sum(stock_value_difference) from `tabStock Ledger Entry`
- where voucher_type=%s and voucher_no =%s and warehouse in (%s)""" %
- ('%s', '%s', ', '.join(['%s']*len(warehouses))), tuple([voucher_type, voucher_no] + warehouses))
-
- account_bal = frappe.db.sql("""select ifnull(sum(ifnull(debit, 0) - ifnull(credit, 0)), 0)
- from `tabGL Entry`
- where voucher_type=%s and voucher_no =%s and account in (%s)
- group by voucher_type, voucher_no""" %
- ('%s', '%s', ', '.join(['%s']*len(accounts))), tuple([voucher_type, voucher_no] + accounts))
-
- if stock_bal and account_bal and abs(flt(stock_bal[0][0]) - flt(account_bal[0][0])) > 0.1:
- try:
- print(voucher_type, voucher_no, stock_bal[0][0], account_bal[0][0])
-
- frappe.db.sql("""delete from `tabGL Entry`
- where voucher_type=%s and voucher_no=%s""", (voucher_type, voucher_no))
-
- voucher = frappe.get_doc(voucher_type, voucher_no)
- voucher.make_gl_entries()
- frappe.db.commit()
- except Exception as e:
- print(frappe.get_traceback())
- rejected.append([voucher_type, voucher_no])
- frappe.db.rollback()
-
- print("Failed to repost: ")
- print(rejected)
diff --git a/erpnext/patches/v4_2/fix_recurring_orders.py b/erpnext/patches/v4_2/fix_recurring_orders.py
deleted file mode 100644
index ea1724a040..0000000000
--- a/erpnext/patches/v4_2/fix_recurring_orders.py
+++ /dev/null
@@ -1,41 +0,0 @@
-# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- sales_orders = frappe.db.sql("""select name from `tabSales Order`
- where docstatus = 1 and ifnull(is_recurring, 0) = 1
- and (per_delivered > 0 or per_billed > 0)""", as_dict=1)
-
- for so in sales_orders:
- if not frappe.db.exists("Delivery Note Item", {"against_sales_order": so.name, "docstatus": 1}):
- frappe.db.sql("""update `tabSales Order` set per_delivered = 0,
- delivery_status = 'Not Delivered' where name = %s""", so.name)
- frappe.db.sql("""update `tabSales Order Item` set delivered_qty = 0
- where parent = %s""", so.name)
-
- if not frappe.db.exists("Sales Invoice Item", {"sales_order": so.name, "docstatus": 1}):
- frappe.db.sql("""update `tabSales Order` set per_billed = 0,
- billing_status = 'Not Billed' where name = %s""", so.name)
- frappe.db.sql("""update `tabSales Order Item` set billed_amt = 0
- where parent = %s""", so.name)
-
- purchase_orders = frappe.db.sql("""select name from `tabPurchase Order`
- where docstatus = 1 and ifnull(is_recurring, 0) = 1
- and (per_received > 0 or per_billed > 0)""", as_dict=1)
-
- for po in purchase_orders:
- if not frappe.db.exists("Purchase Receipt Item", {"prevdoc_doctype": "Purchase Order",
- "prevdoc_docname": po.name, "docstatus": 1}):
- frappe.db.sql("""update `tabPurchase Order` set per_received = 0
- where name = %s""", po.name)
- frappe.db.sql("""update `tabPurchase Order Item` set received_qty = 0
- where parent = %s""", po.name)
-
- if not frappe.db.exists("Purchase Invoice Item", {"purchase_order": po.name, "docstatus": 1}):
- frappe.db.sql("""update `tabPurchase Order` set per_billed = 0
- where name = %s""", po.name)
- frappe.db.sql("""update `tabPurchase Order Item` set billed_amt = 0
- where parent = %s""", po.name)
\ No newline at end of file
diff --git a/erpnext/patches/v4_2/party_model.py b/erpnext/patches/v4_2/party_model.py
deleted file mode 100644
index 46d7fffee1..0000000000
--- a/erpnext/patches/v4_2/party_model.py
+++ /dev/null
@@ -1,117 +0,0 @@
-# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import print_function, unicode_literals
-import frappe
-
-def execute():
- frappe.reload_doc("accounts", "doctype", "account")
- frappe.reload_doc("setup", "doctype", "company")
- frappe.reload_doc("accounts", "doctype", "gl_entry")
- frappe.reload_doc("accounts", "doctype", "journal_entry_account")
- receivable_payable_accounts = create_receivable_payable_account()
- if receivable_payable_accounts:
- set_party_in_jv_and_gl_entry(receivable_payable_accounts)
- delete_individual_party_account()
- remove_customer_supplier_account_report()
-
-def create_receivable_payable_account():
- receivable_payable_accounts = frappe._dict()
-
- def _create_account(args):
- if args["parent_account"] and frappe.db.exists("Account", args["parent_account"]):
- account_id = frappe.db.get_value("Account",
- {"account_name": args["account_name"], "company": args["company"]})
- if not account_id:
- account = frappe.new_doc("Account")
- account.is_group = 0
- account.update(args)
- account.insert()
-
- account_id = account.name
-
- frappe.db.set_value("Company", args["company"], ("default_receivable_account"
- if args["account_type"]=="Receivable" else "default_payable_account"), account_id)
-
- receivable_payable_accounts.setdefault(args["company"], {}).setdefault(args["account_type"], account_id)
-
- for company in frappe.db.sql_list("select name from tabCompany"):
- _create_account({
- "account_name": "Debtors",
- "account_type": "Receivable",
- "company": company,
- "parent_account": get_parent_account(company, "Customer")
- })
-
- _create_account({
- "account_name": "Creditors",
- "account_type": "Payable",
- "company": company,
- "parent_account": get_parent_account(company, "Supplier")
- })
-
- return receivable_payable_accounts
-
-def get_parent_account(company, master_type):
- parent_account = None
-
- if "receivables_group" in frappe.db.get_table_columns("Company"):
- parent_account = frappe.get_cached_value('Company', company,
- "receivables_group" if master_type=="Customer" else "payables_group")
- if not parent_account:
- parent_account = frappe.db.get_value("Account", {"company": company,
- "account_name": "Accounts Receivable" if master_type=="Customer" else "Accounts Payable"})
-
- if not parent_account:
- parent_account = frappe.db.sql_list("""select parent_account from tabAccount
- where company=%s and ifnull(master_type, '')=%s and ifnull(master_name, '')!='' limit 1""",
- (company, master_type))
- parent_account = parent_account[0][0] if parent_account else None
-
- return parent_account
-
-def set_party_in_jv_and_gl_entry(receivable_payable_accounts):
- accounts = frappe.db.sql("""select name, master_type, master_name, company from `tabAccount`
- where ifnull(master_type, '') in ('Customer', 'Supplier') and ifnull(master_name, '') != ''""", as_dict=1)
-
- account_map = frappe._dict()
- for d in accounts:
- account_map.setdefault(d.name, d)
-
- if not account_map:
- return
-
- for dt in ["Journal Entry Account", "GL Entry"]:
- records = frappe.db.sql("""select name, account from `tab%s`
- where account in (%s) and ifnull(party, '') = '' and docstatus < 2""" %
- (dt, ", ".join(['%s']*len(account_map))), tuple(account_map.keys()), as_dict=1)
- for i, d in enumerate(records):
- account_details = account_map.get(d.account, {})
- account_type = "Receivable" if account_details.get("master_type")=="Customer" else "Payable"
- new_account = receivable_payable_accounts[account_details.get("company")][account_type]
-
- frappe.db.sql("update `tab{0}` set account=%s, party_type=%s, party=%s where name=%s".format(dt),
- (new_account, account_details.get("master_type"), account_details.get("master_name"), d.name))
-
- if i%500 == 0:
- frappe.db.commit()
-
-def delete_individual_party_account():
- frappe.db.sql("""delete from `tabAccount`
- where ifnull(master_type, '') in ('Customer', 'Supplier')
- and ifnull(master_name, '') != ''
- and not exists(select gle.name from `tabGL Entry` gle
- where gle.account = tabAccount.name)""")
-
- accounts_not_deleted = frappe.db.sql_list("""select tabAccount.name from `tabAccount`
- where ifnull(master_type, '') in ('Customer', 'Supplier')
- and ifnull(master_name, '') != ''
- and exists(select gle.name from `tabGL Entry` gle where gle.account = tabAccount.name)""")
-
- if accounts_not_deleted:
- print("Accounts not deleted: " + "\n".join(accounts_not_deleted))
-
-
-def remove_customer_supplier_account_report():
- for d in ["Customer Account Head", "Supplier Account Head"]:
- frappe.delete_doc("Report", d)
diff --git a/erpnext/patches/v4_2/recalculate_bom_cost.py b/erpnext/patches/v4_2/recalculate_bom_cost.py
deleted file mode 100644
index eee89fce96..0000000000
--- a/erpnext/patches/v4_2/recalculate_bom_cost.py
+++ /dev/null
@@ -1,16 +0,0 @@
-# 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():
- for d in frappe.db.sql("select name from `tabBOM` where docstatus < 2"):
- try:
- document = frappe.get_doc('BOM', d[0])
- if document.docstatus == 1:
- document.flags.ignore_validate_update_after_submit = True
- document.calculate_cost()
- document.save()
- except:
- pass
diff --git a/erpnext/patches/v4_2/repost_sle_for_si_with_no_warehouse.py b/erpnext/patches/v4_2/repost_sle_for_si_with_no_warehouse.py
deleted file mode 100644
index 1356129dc0..0000000000
--- a/erpnext/patches/v4_2/repost_sle_for_si_with_no_warehouse.py
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import print_function, unicode_literals
-import frappe
-from erpnext.stock.stock_ledger import NegativeStockError
-
-def execute():
- si_list = frappe.db.sql("""select distinct si.name
- from `tabSales Invoice Item` si_item, `tabSales Invoice` si
- where si.name = si_item.parent and si.modified > '2015-02-16' and si.docstatus=1
- and ifnull(si_item.warehouse, '') = '' and ifnull(si.update_stock, 0) = 1
- order by posting_date, posting_time""", as_dict=1)
-
- failed_list = []
- for si in si_list:
- try:
- si_doc = frappe.get_doc("Sales Invoice", si.name)
- si_doc.docstatus = 2
- si_doc.on_cancel()
-
- si_doc.docstatus = 1
- si_doc.set_missing_item_details()
- si_doc.on_submit()
- frappe.db.commit()
- except:
- failed_list.append(si.name)
- frappe.local.stockledger_exceptions = None
- frappe.db.rollback()
-
- print("Failed to repost: ", failed_list)
-
-
-
\ No newline at end of file
diff --git a/erpnext/patches/v4_2/repost_stock_reconciliation.py b/erpnext/patches/v4_2/repost_stock_reconciliation.py
deleted file mode 100644
index ad20ebbae4..0000000000
--- a/erpnext/patches/v4_2/repost_stock_reconciliation.py
+++ /dev/null
@@ -1,31 +0,0 @@
-# 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
-import json
-
-def execute():
- existing_allow_negative_stock = frappe.db.get_value("Stock Settings", None, "allow_negative_stock")
- frappe.db.set_value("Stock Settings", None, "allow_negative_stock", 1)
-
- head_row = ["Item Code", "Warehouse", "Quantity", "Valuation Rate"]
- stock_reco_to_be_reposted = []
- for d in frappe.db.sql("""select name, reconciliation_json from `tabStock Reconciliation`
- where docstatus=1 and creation > '2014-03-01'""", as_dict=1):
- data = json.loads(d.reconciliation_json)
- for row in data[data.index(head_row)+1:]:
- if row[3] in ["", None]:
- stock_reco_to_be_reposted.append(d.name)
- break
-
- for dn in stock_reco_to_be_reposted:
- reco = frappe.get_doc("Stock Reconciliation", dn)
- reco.docstatus = 2
- reco.on_cancel()
-
- reco.docstatus = 1
- reco.validate()
- reco.on_submit()
-
- frappe.db.set_value("Stock Settings", None, "allow_negative_stock", existing_allow_negative_stock)
diff --git a/erpnext/patches/v4_2/reset_bom_costs.py b/erpnext/patches/v4_2/reset_bom_costs.py
deleted file mode 100644
index 42ca759467..0000000000
--- a/erpnext/patches/v4_2/reset_bom_costs.py
+++ /dev/null
@@ -1,17 +0,0 @@
-# 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():
- frappe.reload_doc('manufacturing', 'doctype', 'bom_operation')
- for d in frappe.db.sql("""select name from `tabBOM` where docstatus < 2""", as_dict=1):
- try:
- bom = frappe.get_doc('BOM', d.name)
- bom.flags.ignore_validate_update_after_submit = True
- bom.calculate_cost()
- bom.save()
- frappe.db.commit()
- except:
- frappe.db.rollback()
diff --git a/erpnext/patches/v4_2/seprate_manufacture_and_repack.py b/erpnext/patches/v4_2/seprate_manufacture_and_repack.py
deleted file mode 100644
index 2c935436a2..0000000000
--- a/erpnext/patches/v4_2/seprate_manufacture_and_repack.py
+++ /dev/null
@@ -1,9 +0,0 @@
-# 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():
- frappe.db.sql("""update `tabStock Entry` set purpose='Manufacture' where purpose='Manufacture/Repack' and ifnull(work_order,"")!="" """)
- frappe.db.sql("""update `tabStock Entry` set purpose='Repack' where purpose='Manufacture/Repack' and ifnull(work_order,"")="" """)
\ No newline at end of file
diff --git a/erpnext/patches/v4_2/set_company_country.py b/erpnext/patches/v4_2/set_company_country.py
deleted file mode 100644
index 89f07f2873..0000000000
--- a/erpnext/patches/v4_2/set_company_country.py
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import print_function, unicode_literals
-import frappe
-
-def execute():
- country = frappe.db.get_single_value("Global Defaults", "country")
- if not country:
- print("Country not specified in Global Defaults")
- return
-
- for company in frappe.db.sql_list("""select name from `tabCompany`
- where ifnull(country, '')=''"""):
- frappe.db.set_value("Company", company, "country", country)
diff --git a/erpnext/patches/v4_2/set_item_has_batch.py b/erpnext/patches/v4_2/set_item_has_batch.py
deleted file mode 100644
index 7e52d2def0..0000000000
--- a/erpnext/patches/v4_2/set_item_has_batch.py
+++ /dev/null
@@ -1,65 +0,0 @@
-# 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():
- frappe.db.sql("update tabItem set has_batch_no = 0 where ifnull(has_batch_no, '') = ''")
- frappe.db.sql("update tabItem set has_serial_no = 0 where ifnull(has_serial_no, '') = ''")
-
- item_list = frappe.db.sql("""select name, has_batch_no, has_serial_no from tabItem
- where is_stock_item = 1""", as_dict=1)
-
- sle_count = get_sle_count()
- sle_with_batch = get_sle_with_batch()
- sle_with_serial = get_sle_with_serial()
-
- batch_items = get_items_with_batch()
- serialized_items = get_items_with_serial()
-
- for d in item_list:
- if d.has_batch_no == 1:
- if d.name not in batch_items and sle_count.get(d.name) and sle_count.get(d.name) != sle_with_batch.get(d.name):
- frappe.db.set_value("Item", d.name, "has_batch_no", 0)
- else:
- if d.name in batch_items or (sle_count.get(d.name) and sle_count.get(d.name) == sle_with_batch.get(d.name)):
- frappe.db.set_value("Item", d.name, "has_batch_no", 1)
-
- if d.has_serial_no == 1:
- if d.name not in serialized_items and sle_count.get(d.name) and sle_count.get(d.name) != sle_with_serial.get(d.name):
- frappe.db.set_value("Item", d.name, "has_serial_no", 0)
- else:
- if d.name in serialized_items or (sle_count.get(d.name) and sle_count.get(d.name) == sle_with_serial.get(d.name)):
- frappe.db.set_value("Item", d.name, "has_serial_no", 1)
-
-
-def get_sle_count():
- sle_count = {}
- for d in frappe.db.sql("""select item_code, count(name) as cnt from `tabStock Ledger Entry` group by item_code""", as_dict=1):
- sle_count.setdefault(d.item_code, d.cnt)
-
- return sle_count
-
-def get_sle_with_batch():
- sle_with_batch = {}
- for d in frappe.db.sql("""select item_code, count(name) as cnt from `tabStock Ledger Entry`
- where ifnull(batch_no, '') != '' group by item_code""", as_dict=1):
- sle_with_batch.setdefault(d.item_code, d.cnt)
-
- return sle_with_batch
-
-
-def get_sle_with_serial():
- sle_with_serial = {}
- for d in frappe.db.sql("""select item_code, count(name) as cnt from `tabStock Ledger Entry`
- where ifnull(serial_no, '') != '' group by item_code""", as_dict=1):
- sle_with_serial.setdefault(d.item_code, d.cnt)
-
- return sle_with_serial
-
-def get_items_with_batch():
- return frappe.db.sql_list("select item from tabBatch")
-
-def get_items_with_serial():
- return frappe.db.sql_list("select item_code from `tabSerial No`")
diff --git a/erpnext/patches/v4_2/toggle_rounded_total.py b/erpnext/patches/v4_2/toggle_rounded_total.py
deleted file mode 100644
index e571208eb6..0000000000
--- a/erpnext/patches/v4_2/toggle_rounded_total.py
+++ /dev/null
@@ -1,9 +0,0 @@
-# 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():
- global_defaults = frappe.get_doc("Global Defaults", "Global Defaults")
- global_defaults.toggle_rounded_total()
diff --git a/erpnext/patches/v4_2/update_landed_cost_voucher.py b/erpnext/patches/v4_2/update_landed_cost_voucher.py
deleted file mode 100644
index ec0029671e..0000000000
--- a/erpnext/patches/v4_2/update_landed_cost_voucher.py
+++ /dev/null
@@ -1,10 +0,0 @@
-# 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():
- frappe.reload_doc("stock", "doctype", "landed_cost_voucher")
- frappe.db.sql("""update `tabLanded Cost Voucher` set distribute_charges_based_on = 'Amount'
- where docstatus=1""")
diff --git a/erpnext/patches/v4_2/update_project_milestones.py b/erpnext/patches/v4_2/update_project_milestones.py
deleted file mode 100644
index e704116d05..0000000000
--- a/erpnext/patches/v4_2/update_project_milestones.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- for project in frappe.db.sql_list("select name from tabProject"):
- frappe.reload_doc("projects", "doctype", "project")
- p = frappe.get_doc("Project", project)
- p.update_milestones_completed()
- p.db_set("percent_milestones_completed", p.percent_milestones_completed)
diff --git a/erpnext/patches/v4_2/update_sales_order_invoice_field_name.py b/erpnext/patches/v4_2/update_sales_order_invoice_field_name.py
deleted file mode 100644
index 28dd5c0d4e..0000000000
--- a/erpnext/patches/v4_2/update_sales_order_invoice_field_name.py
+++ /dev/null
@@ -1,7 +0,0 @@
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- frappe.reload_doc('accounts', 'doctype', 'sales_invoice')
- frappe.db.sql("""update `tabSales Invoice` set from_date = invoice_period_from_date,
- to_date = invoice_period_to_date, is_recurring = convert_into_recurring_invoice""")
diff --git a/erpnext/patches/v4_2/update_stock_uom_for_dn_in_sle.py b/erpnext/patches/v4_2/update_stock_uom_for_dn_in_sle.py
deleted file mode 100644
index 89bf795534..0000000000
--- a/erpnext/patches/v4_2/update_stock_uom_for_dn_in_sle.py
+++ /dev/null
@@ -1,11 +0,0 @@
-# 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():
- frappe.db.sql("""update `tabStock Ledger Entry` sle, tabItem item
- set sle.stock_uom = item.stock_uom
- where sle.voucher_type="Delivery Note" and item.name = sle.item_code
- and sle.stock_uom != item.stock_uom""")
diff --git a/erpnext/patches/v4_4/__init__.py b/erpnext/patches/v4_4/__init__.py
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/erpnext/patches/v4_4/make_email_accounts.py b/erpnext/patches/v4_4/make_email_accounts.py
deleted file mode 100644
index 57df1ae491..0000000000
--- a/erpnext/patches/v4_4/make_email_accounts.py
+++ /dev/null
@@ -1,96 +0,0 @@
-from __future__ import unicode_literals
-import frappe
-from frappe.model import default_fields
-
-from six import iteritems
-
-def execute():
- frappe.reload_doc("email", "doctype", "email_account")
-
- # outgoing
- outgoing = dict(frappe.db.sql("select field, value from tabSingles where doctype='Outgoing Email Settings'"))
- if outgoing and outgoing['mail_server'] and outgoing['mail_login']:
- account = frappe.new_doc("Email Account")
- mapping = {
- "login_id_is_different": 1,
- "email_id": "auto_email_id",
- "login_id": "mail_login",
- "password": "mail_password",
- "footer": "footer",
- "smtp_server": "mail_server",
- "smtp_port": "mail_port",
- "use_tls": "use_ssl"
- }
-
- for target_fieldname, source_fieldname in iteritems(mapping):
- account.set(target_fieldname, outgoing.get(source_fieldname))
-
- account.enable_outgoing = 1
- account.enable_incoming = 0
-
- account.insert()
-
- # support
- support = dict(frappe.db.sql("select field, value from tabSingles where doctype='Support Email Settings'"))
- if support and support['mail_server'] and support['mail_login']:
- account = frappe.new_doc("Email Account")
- mapping = {
- "enable_incoming": "sync_support_mails",
- "email_id": "mail_login",
- "password": "mail_password",
- "email_server": "mail_server",
- "use_ssl": "use_ssl",
- "signature": "support_signature",
- "enable_auto_reply": "send_autoreply",
- "auto_reply_message": "support_autoreply"
- }
-
- for target_fieldname, source_fieldname in iteritems(mapping):
- account.set(target_fieldname, support.get(source_fieldname))
-
- account.enable_outgoing = 0
- account.append_to = "Issue"
-
- insert_or_update(account)
-
- # sales, jobs
- for doctype in ("Sales Email Settings", "Jobs Email Settings"):
- source = dict(frappe.db.sql("select field, value from tabSingles where doctype=%s", doctype))
- if source and source.get('host') and source.get('username'):
- account = frappe.new_doc("Email Account")
- mapping = {
- "enable_incoming": "extract_emails",
- "email_id": "username",
- "password": "password",
- "email_server": "host",
- "use_ssl": "use_ssl",
- }
-
- for target_fieldname, source_fieldname in iteritems(mapping):
- account.set(target_fieldname, source.get(source_fieldname))
-
- account.enable_outgoing = 0
- account.append_to = "Lead" if doctype=="Sales Email Settings" else "Job Applicant"
-
- insert_or_update(account)
-
- for doctype in ("Outgoing Email Settings", "Support Email Settings",
- "Sales Email Settings", "Jobs Email Settings"):
- frappe.delete_doc("DocType", doctype)
-
-def insert_or_update(account):
- try:
- account.insert()
- except frappe.NameError as e:
- if e.args[0]=="Email Account":
- existing_account = frappe.get_doc("Email Account", e.args[1])
- for key, value in account.as_dict().items():
- if not existing_account.get(key) and value \
- and key not in default_fields \
- and key != "__islocal":
- existing_account.set(key, value)
-
- existing_account.save()
- else:
- raise
-
diff --git a/erpnext/patches/v5_0/__init__.py b/erpnext/patches/v5_0/__init__.py
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/erpnext/patches/v5_0/convert_stock_reconciliation.py b/erpnext/patches/v5_0/convert_stock_reconciliation.py
deleted file mode 100644
index 75d1da752f..0000000000
--- a/erpnext/patches/v5_0/convert_stock_reconciliation.py
+++ /dev/null
@@ -1,31 +0,0 @@
-from __future__ import unicode_literals
-import frappe, json
-
-def execute():
- # stock reco now amendable
- frappe.db.sql("""update tabDocPerm set `amend` = 1 where parent='Stock Reconciliation' and submit = 1""")
-
- frappe.reload_doc("stock", "doctype", "stock_reconciliation_item")
- frappe.reload_doctype("Stock Reconciliation")
-
- if frappe.db.has_column("Stock Reconciliation", "reconciliation_json"):
- for sr in frappe.db.get_all("Stock Reconciliation", ["name"],
- {"reconciliation_json": ["!=", ""]}):
- start = False
- sr = frappe.get_doc("Stock Reconciliation", sr.name)
- for row in json.loads(sr.reconciliation_json):
- if start:
- sr.append("items", {
- "item_code": row[0],
- "warehouse": row[1],
- "qty": row[2] if len(row) > 2 else None,
- "valuation_rate": row[3] if len(row) > 3 else None
- })
-
- elif row[0]=="Item Code":
- start = True
-
-
- for item in sr.items:
- item.db_update()
-
diff --git a/erpnext/patches/v5_0/execute_on_doctype_update.py b/erpnext/patches/v5_0/execute_on_doctype_update.py
deleted file mode 100644
index 70b1d8ded6..0000000000
--- a/erpnext/patches/v5_0/execute_on_doctype_update.py
+++ /dev/null
@@ -1,9 +0,0 @@
-# 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():
- for dt in ("Stock Ledger Entry", "Communication", "DefaultValue", "DocShare", "File", "ToDo"):
- frappe.get_doc("DocType", dt).run_module_method("on_doctype_update")
diff --git a/erpnext/patches/v5_0/fix_taxes_and_totals_in_party_currency.py b/erpnext/patches/v5_0/fix_taxes_and_totals_in_party_currency.py
deleted file mode 100644
index 30dc0f8db4..0000000000
--- a/erpnext/patches/v5_0/fix_taxes_and_totals_in_party_currency.py
+++ /dev/null
@@ -1,66 +0,0 @@
-# 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
-from frappe.model.meta import get_field_precision
-
-def execute():
- if not frappe.db.sql("""select name from `tabPatch Log`
- where patch = 'erpnext.patches.v5_0.taxes_and_totals_in_party_currency'"""):
- return
- selling_doctypes = ["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"]
- buying_doctypes = ["Supplier Quotation", "Purchase Order", "Purchase Receipt", "Purchase Invoice"]
-
- for dt in selling_doctypes:
- update_values(dt, "Sales Taxes and Charges")
-
- for dt in buying_doctypes:
- update_values(dt, "Purchase Taxes and Charges")
-
-def update_values(dt, tax_table):
- rate_field_precision = get_field_precision(frappe.get_meta(dt + " Item").get_field("rate"))
- tax_amount_precision = get_field_precision(frappe.get_meta(tax_table).get_field("tax_amount"))
-
- # update net_total, discount_on
- frappe.db.sql("""
- UPDATE
- `tab{0}`
- SET
- total_taxes_and_charges = round(base_total_taxes_and_charges / conversion_rate, {1})
- WHERE
- docstatus < 2
- and ifnull(base_total_taxes_and_charges, 0) != 0
- and ifnull(total_taxes_and_charges, 0) = 0
- """.format(dt, tax_amount_precision))
-
- # update net_amount
- frappe.db.sql("""
- UPDATE
- `tab{0}` par, `tab{1}` item
- SET
- item.net_amount = round(item.base_net_amount / par.conversion_rate, {2}),
- item.net_rate = round(item.base_net_rate / par.conversion_rate, {2})
- WHERE
- par.name = item.parent
- and par.docstatus < 2
- and ((ifnull(item.base_net_amount, 0) != 0 and ifnull(item.net_amount, 0) = 0)
- or (ifnull(item.base_net_rate, 0) != 0 and ifnull(item.net_rate, 0) = 0))
- """.format(dt, dt + " Item", rate_field_precision))
-
- # update tax in party currency
- frappe.db.sql("""
- UPDATE
- `tab{0}` par, `tab{1}` tax
- SET
- tax.tax_amount = round(tax.base_tax_amount / par.conversion_rate, {2}),
- tax.total = round(tax.base_total / conversion_rate, {2}),
- tax.tax_amount_after_discount_amount = round(tax.base_tax_amount_after_discount_amount / conversion_rate, {2})
- WHERE
- par.name = tax.parent
- and par.docstatus < 2
- and ((ifnull(tax.base_tax_amount, 0) != 0 and ifnull(tax.tax_amount, 0) = 0)
- or (ifnull(tax.base_total, 0) != 0 and ifnull(tax.total, 0) = 0)
- or (ifnull(tax.base_tax_amount_after_discount_amount, 0) != 0 and
- ifnull(tax.tax_amount_after_discount_amount, 0) = 0))
- """.format(dt, tax_table, tax_amount_precision))
\ No newline at end of file
diff --git a/erpnext/patches/v5_0/index_on_account_and_gl_entry.py b/erpnext/patches/v5_0/index_on_account_and_gl_entry.py
deleted file mode 100644
index 2920e9293d..0000000000
--- a/erpnext/patches/v5_0/index_on_account_and_gl_entry.py
+++ /dev/null
@@ -1,30 +0,0 @@
-from __future__ import unicode_literals
-
-import frappe
-
-def execute():
- index_map = {
- "Account": ["parent_account", "lft", "rgt"],
- "GL Entry": ["posting_date", "account", 'party', "voucher_no"],
- "Sales Invoice": ["posting_date", "debit_to", "customer"],
- "Purchase Invoice": ["posting_date", "credit_to", "supplier"]
- }
-
- for dt, indexes in index_map.items():
- existing_indexes = [(d.Key_name, d.Column_name) for d in frappe.db.sql("""show index from `tab{0}`
- where Column_name != 'name'""".format(dt), as_dict=1)]
-
- for old, column in existing_indexes:
- if column in ("parent", "group_or_ledger", "is_group", "is_pl_account", "debit_or_credit",
- "account_name", "company", "project", "voucher_date", "due_date", "bill_no",
- "bill_date", "is_opening", "fiscal_year", "outstanding_amount"):
- frappe.db.sql("alter table `tab{0}` drop index {1}".format(dt, old))
-
- existing_indexes = [(d.Key_name, d.Column_name) for d in frappe.db.sql("""show index from `tab{0}`
- where Column_name != 'name'""".format(dt), as_dict=1)]
-
- existing_indexed_columns = list(set([x[1] for x in existing_indexes]))
-
- for new in indexes:
- if new not in existing_indexed_columns:
- frappe.db.sql("alter table `tab{0}` add index ({1})".format(dt, new))
\ No newline at end of file
diff --git a/erpnext/patches/v5_0/is_group.py b/erpnext/patches/v5_0/is_group.py
deleted file mode 100644
index 4e3f760bed..0000000000
--- a/erpnext/patches/v5_0/is_group.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from __future__ import unicode_literals
-
-import frappe
-
-def execute():
- frappe.reload_doctype("Account")
- frappe.reload_doctype("Cost Center")
- frappe.db.sql("update tabAccount set is_group = if(group_or_ledger='Group', 1, 0)")
- frappe.db.sql("update `tabCost Center` set is_group = if(group_or_ledger='Group', 1, 0)")
diff --git a/erpnext/patches/v5_0/item_patches.py b/erpnext/patches/v5_0/item_patches.py
deleted file mode 100644
index e223e09f5b..0000000000
--- a/erpnext/patches/v5_0/item_patches.py
+++ /dev/null
@@ -1,6 +0,0 @@
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- frappe.db.sql("update `tabItem` set end_of_life='2099-12-31' where ifnull(end_of_life, '0000-00-00')='0000-00-00'")
- frappe.db.sql("update `tabItem` set website_image = image where ifnull(website_image, '') = 'attach_files:'")
diff --git a/erpnext/patches/v5_0/link_warehouse_with_account.py b/erpnext/patches/v5_0/link_warehouse_with_account.py
deleted file mode 100644
index 338fd7ad7f..0000000000
--- a/erpnext/patches/v5_0/link_warehouse_with_account.py
+++ /dev/null
@@ -1,10 +0,0 @@
-# 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 "master_name" in frappe.db.get_table_columns("Account"):
- frappe.db.sql("""update tabAccount set warehouse=master_name
- where ifnull(account_type, '') = 'Warehouse' and ifnull(master_name, '') != ''""")
\ No newline at end of file
diff --git a/erpnext/patches/v5_0/new_crm_module.py b/erpnext/patches/v5_0/new_crm_module.py
deleted file mode 100644
index f5dda1f273..0000000000
--- a/erpnext/patches/v5_0/new_crm_module.py
+++ /dev/null
@@ -1,24 +0,0 @@
-# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import json
-import frappe
-
-def execute():
- frappe.reload_doc('crm', 'doctype', 'lead')
- frappe.reload_doc('crm', 'doctype', 'opportunity')
-
- add_crm_to_user_desktop_items()
-
-def add_crm_to_user_desktop_items():
- key = "_user_desktop_items"
- for user in frappe.get_all("User", filters={"enabled": 1, "user_type": "System User"}):
- user = user.name
- user_desktop_items = frappe.db.get_defaults(key, parent=user)
- if user_desktop_items:
- user_desktop_items = json.loads(user_desktop_items)
- if "CRM" not in user_desktop_items:
- user_desktop_items.append("CRM")
- frappe.db.set_default(key, json.dumps(user_desktop_items), parent=user)
-
diff --git a/erpnext/patches/v5_0/newsletter.py b/erpnext/patches/v5_0/newsletter.py
deleted file mode 100644
index 63e3312413..0000000000
--- a/erpnext/patches/v5_0/newsletter.py
+++ /dev/null
@@ -1,38 +0,0 @@
-# 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
-import frappe.permissions
-
-def execute():
- frappe.reload_doc("core", "doctype", "block_module")
- frappe.reload_doctype("User")
- frappe.reload_doctype("Lead")
- frappe.reload_doctype("Contact")
-
- frappe.reload_doc('email', 'doctype', 'email_group')
- frappe.reload_doc('email', 'doctype', 'email_group_member')
- frappe.reload_doc('email', 'doctype', 'newsletter')
-
- frappe.permissions.reset_perms("Newsletter")
-
- if not frappe.db.exists("Role", "Newsletter Manager"):
- frappe.get_doc({"doctype": "Role", "role": "Newsletter Manager"}).insert()
-
- for userrole in frappe.get_all("Has Role", "parent", {"role": "Sales Manager", "parenttype": "User"}):
- if frappe.db.exists("User", userrole.parent):
- user = frappe.get_doc("User", userrole.parent)
- user.append("roles", {
- "doctype": "Has Role",
- "role": "Newsletter Manager"
- })
- user.flags.ignore_mandatory = True
- user.save()
-
- # create default lists
- general = frappe.new_doc("Email Group")
- general.title = "General"
- general.insert()
- general.import_from("Lead")
- general.import_from("Contact")
diff --git a/erpnext/patches/v5_0/opportunity_not_submittable.py b/erpnext/patches/v5_0/opportunity_not_submittable.py
deleted file mode 100644
index e29d66f284..0000000000
--- a/erpnext/patches/v5_0/opportunity_not_submittable.py
+++ /dev/null
@@ -1,10 +0,0 @@
-# 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():
- frappe.reload_doctype("Opportunity")
- frappe.db.sql("update tabDocPerm set submit=0, cancel=0, amend=0 where parent='Opportunity'")
- frappe.db.sql("update tabOpportunity set docstatus=0 where docstatus=1")
diff --git a/erpnext/patches/v5_0/party_model_patch_fix.py b/erpnext/patches/v5_0/party_model_patch_fix.py
deleted file mode 100644
index d9b6709792..0000000000
--- a/erpnext/patches/v5_0/party_model_patch_fix.py
+++ /dev/null
@@ -1,18 +0,0 @@
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- for company in frappe.get_all("Company",
- ["name", "default_receivable_account", "default_payable_account"]):
-
- if company.default_receivable_account:
- frappe.db.sql("""update `tabSales Invoice` invoice set `debit_to`=%(account)s
- where company=%(company)s
- and not exists (select name from `tabAccount` account where account.name=invoice.debit_to)""",
- {"company": company.name, "account": company.default_receivable_account})
-
- if company.default_payable_account:
- frappe.db.sql("""update `tabPurchase Invoice` invoice set `credit_to`=%(account)s
- where company=%(company)s
- and not exists (select name from `tabAccount` account where account.name=invoice.credit_to)""",
- {"company": company.name, "account": company.default_payable_account})
diff --git a/erpnext/patches/v5_0/portal_fixes.py b/erpnext/patches/v5_0/portal_fixes.py
deleted file mode 100644
index 1fefd99167..0000000000
--- a/erpnext/patches/v5_0/portal_fixes.py
+++ /dev/null
@@ -1,7 +0,0 @@
-from __future__ import unicode_literals
-import frappe
-import erpnext.setup.install
-
-def execute():
- frappe.reload_doc("website", "doctype", "web_form_field", force=True, reset_permissions=True)
- #erpnext.setup.install.add_web_forms()
diff --git a/erpnext/patches/v5_0/project_costing.py b/erpnext/patches/v5_0/project_costing.py
deleted file mode 100644
index e2d65d0594..0000000000
--- a/erpnext/patches/v5_0/project_costing.py
+++ /dev/null
@@ -1,8 +0,0 @@
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- frappe.reload_doctype("Project")
- frappe.db.sql("update `tabProject` set expected_start_date = project_start_date, \
- expected_end_date = completion_date, actual_end_date = act_completion_date, \
- estimated_costing = project_value, gross_margin = gross_margin_value")
\ No newline at end of file
diff --git a/erpnext/patches/v5_0/recalculate_total_amount_in_jv.py b/erpnext/patches/v5_0/recalculate_total_amount_in_jv.py
deleted file mode 100644
index d5af43c541..0000000000
--- a/erpnext/patches/v5_0/recalculate_total_amount_in_jv.py
+++ /dev/null
@@ -1,26 +0,0 @@
-# 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
-from frappe.utils import money_in_words
-
-def execute():
- company_currency = dict(frappe.db.sql("select name, default_currency from `tabCompany`"))
- bank_or_cash_accounts = frappe.db.sql_list("""select name from `tabAccount`
- where account_type in ('Bank', 'Cash') and docstatus < 2""")
-
- for je in frappe.db.sql_list("""select name from `tabJournal Entry` where docstatus < 2"""):
- total_amount = 0
- total_amount_in_words = ""
-
- je_doc = frappe.get_doc('Journal Entry', je)
- for d in je_doc.get("accounts"):
- if (d.party_type and d.party) or d.account in bank_or_cash_accounts:
- total_amount = d.debit or d.credit
- if total_amount:
- total_amount_in_words = money_in_words(total_amount, company_currency.get(je_doc.company))
-
- if total_amount:
- frappe.db.sql("""update `tabJournal Entry` set total_amount=%s, total_amount_in_words=%s
- where name = %s""", (total_amount, total_amount_in_words, je))
diff --git a/erpnext/patches/v5_0/reclculate_planned_operating_cost_in_production_order.py b/erpnext/patches/v5_0/reclculate_planned_operating_cost_in_production_order.py
deleted file mode 100644
index 6d392831b4..0000000000
--- a/erpnext/patches/v5_0/reclculate_planned_operating_cost_in_production_order.py
+++ /dev/null
@@ -1,13 +0,0 @@
-# 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():
- for wo in frappe.db.sql("""select name from `tabWork Order` where docstatus < 2""", as_dict=1):
- work_order = frappe.get_doc("Work Order", wo.name)
- if work_order.operations:
- work_order.flags.ignore_validate_update_after_submit = True
- work_order.calculate_time()
- work_order.save()
\ No newline at end of file
diff --git a/erpnext/patches/v5_0/remove_birthday_events.py b/erpnext/patches/v5_0/remove_birthday_events.py
deleted file mode 100644
index 3ead8669b8..0000000000
--- a/erpnext/patches/v5_0/remove_birthday_events.py
+++ /dev/null
@@ -1,7 +0,0 @@
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- for e in frappe.db.sql_list("""select name from tabEvent where
- repeat_on='Every Year' and ref_type='Employee'"""):
- frappe.delete_doc("Event", e, force=True)
diff --git a/erpnext/patches/v5_0/rename_customer_issue.py b/erpnext/patches/v5_0/rename_customer_issue.py
deleted file mode 100644
index 1bd69ceec1..0000000000
--- a/erpnext/patches/v5_0/rename_customer_issue.py
+++ /dev/null
@@ -1,6 +0,0 @@
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- if frappe.db.table_exists("Customer Issue"):
- frappe.rename_doc("DocType", "Customer Issue", "Warranty Claim")
diff --git a/erpnext/patches/v5_0/rename_pos_setting.py b/erpnext/patches/v5_0/rename_pos_setting.py
deleted file mode 100644
index bf10333564..0000000000
--- a/erpnext/patches/v5_0/rename_pos_setting.py
+++ /dev/null
@@ -1,6 +0,0 @@
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- if frappe.db.table_exists("POS Setting"):
- frappe.rename_doc("DocType", "POS Setting", "POS Profile")
diff --git a/erpnext/patches/v5_0/rename_table_fieldnames.py b/erpnext/patches/v5_0/rename_table_fieldnames.py
deleted file mode 100644
index aefb0a2037..0000000000
--- a/erpnext/patches/v5_0/rename_table_fieldnames.py
+++ /dev/null
@@ -1,243 +0,0 @@
-# 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
-from frappe.model.utils.rename_field import rename_field
-from frappe.modules import scrub, get_doctype_module
-
-rename_map = {
- "Opportunity": [
- ["enquiry_details", "items"]
- ],
- "Quotation": [
- ["quotation_details", "items"],
- ["other_charges", "taxes"]
- ],
- "Sales Order": [
- ["sales_order_details", "items"],
- ["other_charges", "taxes"],
- ["packing_details", "packed_items"]
- ],
- "Delivery Note": [
- ["delivery_note_details", "items"],
- ["other_charges", "taxes"],
- ["packing_details", "packed_items"]
- ],
- "Sales Invoice": [
- ["entries", "items"],
- ["other_charges", "taxes"],
- ["packing_details", "packed_items"],
- ["advance_adjustment_details", "advances"]
- ],
- "Material Request": [
- ["indent_details", "items"]
- ],
- "Supplier Quotation": [
- ["quotation_items", "items"],
- ["other_charges", "taxes"]
- ],
- "Purchase Order": [
- ["po_details", "items"],
- ["other_charges", "taxes"],
- ["po_raw_material_details", "supplied_items"]
- ],
- "Purchase Receipt": [
- ["purchase_receipt_details", "items"],
- ["other_charges", "taxes"],
- ["pr_raw_material_details", "supplied_items"]
- ],
- "Purchase Invoice": [
- ["entries", "items"],
- ["other_charges", "taxes"],
- ["advance_allocation_details", "advances"]
- ],
- "Work Order": [
- ["production_order_operations", "operations"]
- ],
- "BOM": [
- ["bom_operations", "operations"],
- ["bom_materials", "items"],
- ["flat_bom_details", "exploded_items"]
- ],
- "Payment Reconciliation": [
- ["payment_reconciliation_payments", "payments"],
- ["payment_reconciliation_invoices", "invoices"]
- ],
- "Sales Taxes and Charges Template": [
- ["other_charges", "taxes"],
- ["valid_for_territories", "territories"]
- ],
- "Purchase Taxes and Charges Template": [
- ["other_charges", "taxes"]
- ],
- "Shipping Rule": [
- ["shipping_rule_conditions", "conditions"],
- ["valid_for_territories", "territories"]
- ],
- "Price List": [
- ["valid_for_territories", "territories"]
- ],
- "Appraisal": [
- ["appraisal_details", "goals"]
- ],
- "Appraisal Template": [
- ["kra_sheet", "goals"]
- ],
- "Bank Reconciliation": [
- ["entries", "journal_entries"]
- ],
- "C-Form": [
- ["invoice_details", "invoices"]
- ],
- "Employee": [
- ["employee_leave_approvers", "leave_approvers"],
- ["educational_qualification_details", "education"],
- ["previous_experience_details", "external_work_history"],
- ["experience_in_company_details", "internal_work_history"]
- ],
- "Expense Claim": [
- ["expense_voucher_details", "expenses"]
- ],
- "Fiscal Year": [
- ["fiscal_year_companies", "companies"]
- ],
- "Holiday List": [
- ["holiday_list_details", "holidays"]
- ],
- "Installation Note": [
- ["installed_item_details", "items"]
- ],
- "Item": [
- ["item_reorder", "reorder_levels"],
- ["uom_conversion_details", "uoms"],
- ["item_supplier_details", "supplier_items"],
- ["item_customer_details", "customer_items"],
- ["item_tax", "taxes"],
- ["item_specification_details", "quality_parameters"],
- ["item_website_specifications", "website_specifications"]
- ],
- "Item Group": [
- ["item_website_specifications", "website_specifications"]
- ],
- "Landed Cost Voucher": [
- ["landed_cost_purchase_receipts", "purchase_receipts"],
- ["landed_cost_items", "items"],
- ["landed_cost_taxes_and_charges", "taxes"]
- ],
- "Maintenance Schedule": [
- ["item_maintenance_detail", "items"],
- ["maintenance_schedule_detail", "schedules"]
- ],
- "Maintenance Visit": [
- ["maintenance_visit_details", "purposes"]
- ],
- "Packing Slip": [
- ["item_details", "items"]
- ],
- "Customer": [
- ["party_accounts", "accounts"]
- ],
- "Customer Group": [
- ["party_accounts", "accounts"]
- ],
- "Supplier": [
- ["party_accounts", "accounts"]
- ],
- "Supplier Type": [
- ["party_accounts", "accounts"]
- ],
- "Payment Tool": [
- ["payment_tool_details", "vouchers"]
- ],
- "Production Planning Tool": [
- ["pp_so_details", "sales_orders"],
- ["pp_details", "items"]
- ],
- "Quality Inspection": [
- ["qa_specification_details", "readings"]
- ],
- "Salary Slip": [
- ["earning_details", "earnings"],
- ["deduction_details", "deductions"]
- ],
- "Salary Structure": [
- ["earning_details", "earnings"],
- ["deduction_details", "deductions"]
- ],
- "Product Bundle": [
- ["sales_bom_items", "items"]
- ],
- "SMS Settings": [
- ["static_parameter_details", "parameters"]
- ],
- "Stock Entry": [
- ["mtn_details", "items"]
- ],
- "Sales Partner": [
- ["partner_target_details", "targets"]
- ],
- "Sales Person": [
- ["target_details", "targets"]
- ],
- "Territory": [
- ["target_details", "targets"]
- ],
- "Time Sheet": [
- ["time_sheet_details", "time_logs"]
- ],
- "Workstation": [
- ["workstation_operation_hours", "working_hours"]
- ],
- "Payment Reconciliation Payment": [
- ["journal_voucher", "journal_entry"],
- ],
- "Purchase Invoice Advance": [
- ["journal_voucher", "journal_entry"],
- ],
- "Sales Invoice Advance": [
- ["journal_voucher", "journal_entry"],
- ],
- "Journal Entry": [
- ["entries", "accounts"]
- ],
- "Monthly Distribution": [
- ["budget_distribution_details", "percentages"]
- ]
-}
-
-def execute():
- # rename doctypes
- tables = frappe.db.sql_list("show tables")
- for old_dt, new_dt in [["Journal Voucher Detail", "Journal Entry Account"],
- ["Journal Voucher", "Journal Entry"],
- ["Budget Distribution Detail", "Monthly Distribution Percentage"],
- ["Budget Distribution", "Monthly Distribution"]]:
- if "tab"+new_dt not in tables:
- frappe.rename_doc("DocType", old_dt, new_dt, force=True)
-
- # reload new child doctypes
- frappe.reload_doc("manufacturing", "doctype", "work_order_operation")
- frappe.reload_doc("manufacturing", "doctype", "workstation_working_hour")
- frappe.reload_doc("stock", "doctype", "item_variant")
- frappe.reload_doc("Payroll", "doctype", "salary_detail")
- frappe.reload_doc("accounts", "doctype", "party_account")
- frappe.reload_doc("accounts", "doctype", "fiscal_year_company")
-
- #rename table fieldnames
- for dn in rename_map:
- if not frappe.db.exists("DocType", dn):
- continue
- frappe.reload_doc(get_doctype_module(dn), "doctype", scrub(dn))
-
- for dt, field_list in rename_map.items():
- if not frappe.db.exists("DocType", dt):
- continue
- for field in field_list:
- rename_field(dt, field[0], field[1])
-
- # update voucher type
- for old, new in [["Bank Voucher", "Bank Entry"], ["Cash Voucher", "Cash Entry"],
- ["Credit Card Voucher", "Credit Card Entry"], ["Contra Voucher", "Contra Entry"],
- ["Write Off Voucher", "Write Off Entry"], ["Excise Voucher", "Excise Entry"]]:
- frappe.db.sql("update `tabJournal Entry` set voucher_type=%s where voucher_type=%s", (new, old))
diff --git a/erpnext/patches/v5_0/rename_taxes_and_charges_master.py b/erpnext/patches/v5_0/rename_taxes_and_charges_master.py
deleted file mode 100644
index e26f48cda1..0000000000
--- a/erpnext/patches/v5_0/rename_taxes_and_charges_master.py
+++ /dev/null
@@ -1,14 +0,0 @@
-from __future__ import unicode_literals
-import frappe
-
-
-def execute():
- if frappe.db.table_exists("Sales Taxes and Charges Master"):
- frappe.rename_doc("DocType", "Sales Taxes and Charges Master",
- "Sales Taxes and Charges Template")
- frappe.delete_doc("DocType", "Sales Taxes and Charges Master")
-
- if frappe.db.table_exists("Purchase Taxes and Charges Master"):
- frappe.rename_doc("DocType", "Purchase Taxes and Charges Master",
- "Purchase Taxes and Charges Template")
- frappe.delete_doc("DocType", "Purchase Taxes and Charges Master")
diff --git a/erpnext/patches/v5_0/rename_total_fields.py b/erpnext/patches/v5_0/rename_total_fields.py
deleted file mode 100644
index 6657dd843e..0000000000
--- a/erpnext/patches/v5_0/rename_total_fields.py
+++ /dev/null
@@ -1,55 +0,0 @@
-# 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
-from frappe.model.utils.rename_field import rename_field
-from frappe.modules import scrub, get_doctype_module
-
-selling_doctypes = ("Quotation", "Sales Order", "Delivery Note", "Sales Invoice")
-
-buying_doctypes = ("Supplier Quotation", "Purchase Order", "Purchase Receipt", "Purchase Invoice")
-
-selling_renamed_fields = (
- ("net_total", "base_net_total"),
- ("net_total_export", "net_total"),
- ("other_charges_total", "base_total_taxes_and_charges"),
- ("other_charges_total_export", "total_taxes_and_charges"),
- ("grand_total", "base_grand_total"),
- ("grand_total_export", "grand_total"),
- ("rounded_total", "base_rounded_total"),
- ("rounded_total_export", "rounded_total"),
- ("in_words", "base_in_words"),
- ("in_words_export", "in_words")
-)
-
-buying_renamed_fields = (
- ("net_total", "base_net_total"),
- ("net_total_import", "net_total"),
- ("grand_total", "base_grand_total"),
- ("grand_total_import", "grand_total"),
- ("rounded_total", "base_rounded_total"),
- ("in_words", "base_in_words"),
- ("in_words_import", "in_words"),
- ("other_charges_added", "base_taxes_and_charges_added"),
- ("other_charges_added_import", "taxes_and_charges_added"),
- ("other_charges_deducted", "base_taxes_and_charges_deducted"),
- ("other_charges_deducted_import", "taxes_and_charges_deducted"),
- ("total_tax", "base_total_taxes_and_charges")
-)
-
-def execute():
- for doctypes, fields in [[selling_doctypes, selling_renamed_fields], [buying_doctypes, buying_renamed_fields]]:
- for dt in doctypes:
- frappe.reload_doc(get_doctype_module(dt), "doctype", scrub(dt))
- table_columns = frappe.db.get_table_columns(dt)
- base_net_total = frappe.db.sql("select sum(ifnull({0}, 0)) from `tab{1}`".format(fields[0][1], dt))[0][0]
- if not base_net_total:
- for f in fields:
- if f[0] in table_columns:
- rename_field(dt, f[0], f[1])
-
- # Added new field "total_taxes_and_charges" in buying cycle, updating value
- if dt in ("Supplier Quotation", "Purchase Order", "Purchase Receipt", "Purchase Invoice"):
- frappe.db.sql("""update `tab{0}` set total_taxes_and_charges =
- round(base_total_taxes_and_charges/conversion_rate, 2)""".format(dt))
diff --git a/erpnext/patches/v5_0/replace_renamed_fields_in_custom_scripts_and_print_formats.py b/erpnext/patches/v5_0/replace_renamed_fields_in_custom_scripts_and_print_formats.py
deleted file mode 100644
index c564f8b02a..0000000000
--- a/erpnext/patches/v5_0/replace_renamed_fields_in_custom_scripts_and_print_formats.py
+++ /dev/null
@@ -1,65 +0,0 @@
-# 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
-import re
-
-def execute():
- # NOTE: sequence is important
- renamed_fields = get_all_renamed_fields()
-
- for dt, script_field, ref_dt_field in (("Client Script", "script", "dt"), ("Print Format", "html", "doc_type")):
-
- cond1 = " or ".join("""{0} like "%%{1}%%" """.format(script_field, d[0].replace("_", "\\_")) for d in renamed_fields)
- cond2 = " and standard = 'No'" if dt == "Print Format" else ""
-
- for name, script, ref_dt in frappe.db.sql("select name, {0} as script, {1} as ref_dt from `tab{2}` where ({3}) {4}".format(script_field, ref_dt_field, dt, cond1, cond2)):
- update_script(dt, name, ref_dt, script_field, script, renamed_fields)
-
-def get_all_renamed_fields():
- from erpnext.patches.v5_0.rename_table_fieldnames import rename_map
-
- renamed_fields = (
- ("base_amount", "base_net_amount"),
- ("net_total", "base_net_total"),
- ("net_total_export", "total"),
- ("net_total_import", "total"),
- ("other_charges_total", "base_total_taxes_and_charges"),
- ("other_charges_total_export", "total_taxes_and_charges"),
- ("other_charges_added", "base_taxes_and_charges_added"),
- ("other_charges_added_import", "taxes_and_charges_added"),
- ("other_charges_deducted", "base_taxes_and_charges_deducted"),
- ("other_charges_deducted_import", "taxes_and_charges_deducted"),
- ("total_tax", "base_total_taxes_and_charges"),
- ("grand_total", "base_grand_total"),
- ("grand_total_export", "grand_total"),
- ("grand_total_import", "grand_total"),
- ("rounded_total", "base_rounded_total"),
- ("rounded_total_export", "rounded_total"),
- ("rounded_total_import", "rounded_total"),
- ("in_words", "base_in_words"),
- ("in_words_export", "in_words"),
- ("in_words_import", "in_words"),
- ("tax_amount", "base_tax_amount"),
- ("tax_amount_after_discount_amount", "base_tax_amount_after_discount_amount"),
- )
-
- for fields in rename_map.values():
- renamed_fields += tuple(fields)
-
- return renamed_fields
-
-def update_script(dt, name, ref_dt, script_field, script, renamed_fields):
- for from_field, to_field in renamed_fields:
- if from_field != "entries":
- script = re.sub(r"\b{}\b".format(from_field), to_field, script)
-
- if ref_dt == "Journal Entry":
- script = re.sub(r"\bentries\b", "accounts", script)
- elif ref_dt == "Bank Reconciliation":
- script = re.sub(r"\bentries\b", "journal_entries", script)
- elif ref_dt in ("Sales Invoice", "Purchase Invoice"):
- script = re.sub(r"\bentries\b", "items", script)
-
- frappe.db.set_value(dt, name, script_field, script)
\ No newline at end of file
diff --git a/erpnext/patches/v5_0/repost_gle_for_jv_with_multiple_party.py b/erpnext/patches/v5_0/repost_gle_for_jv_with_multiple_party.py
deleted file mode 100644
index 76efdcc7c6..0000000000
--- a/erpnext/patches/v5_0/repost_gle_for_jv_with_multiple_party.py
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import print_function, unicode_literals
-import frappe
-
-def execute():
- je_list = frappe.db.sql_list("""
- select par.name from `tabJournal Entry` par
- where par.docstatus=1 and par.creation > '2015-03-01'
- and (select count(distinct child.party) from `tabJournal Entry Account` child
- where par.name=child.parent and ifnull(child.party, '') != '') > 1
- """)
-
- for d in je_list:
- # delete existing gle
- frappe.db.sql("delete from `tabGL Entry` where voucher_type='Journal Entry' and voucher_no=%s", d)
-
- # repost gl entries
- je = frappe.get_doc("Journal Entry", d)
- je.make_gl_entries()
-
- if je_list:
- print(je_list)
-
-
\ No newline at end of file
diff --git a/erpnext/patches/v5_0/repost_requested_qty.py b/erpnext/patches/v5_0/repost_requested_qty.py
deleted file mode 100644
index 6af71f3fc4..0000000000
--- a/erpnext/patches/v5_0/repost_requested_qty.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright (c) 2013, Web Notes Technologies Pvt. Ltd. and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- from erpnext.stock.stock_balance import update_bin_qty, get_indented_qty
-
- count=0
- for item_code, warehouse in frappe.db.sql("""select distinct item_code, warehouse
- from `tabMaterial Request Item` where docstatus = 1"""):
- try:
- count += 1
- update_bin_qty(item_code, warehouse, {
- "indented_qty": get_indented_qty(item_code, warehouse),
- })
- if count % 200 == 0:
- frappe.db.commit()
- except:
- frappe.db.rollback()
diff --git a/erpnext/patches/v5_0/reset_values_in_tools.py b/erpnext/patches/v5_0/reset_values_in_tools.py
deleted file mode 100644
index fd970ba1b0..0000000000
--- a/erpnext/patches/v5_0/reset_values_in_tools.py
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- for dt in ["Payment Tool", "Bank Reconciliation", "Payment Reconciliation", "Leave Control Panel",
- "Salary Manager", "Upload Attenadance", "Production Planning Tool", "BOM Update Tool", "Customize Form",
- "Employee Attendance Tool", "Rename Tool", "BOM Update Tool", "Process Payroll", "Naming Series"]:
- frappe.db.sql("delete from `tabSingles` where doctype=%s", dt)
-
\ No newline at end of file
diff --git a/erpnext/patches/v5_0/set_appraisal_remarks.py b/erpnext/patches/v5_0/set_appraisal_remarks.py
deleted file mode 100644
index 8652c32cf0..0000000000
--- a/erpnext/patches/v5_0/set_appraisal_remarks.py
+++ /dev/null
@@ -1,9 +0,0 @@
-# Copyright (c) 2013, Frappe Technologies Pvt. Ltd. and Contributors
-# License: GNU General Public License v3. See license.txt
-
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- frappe.reload_doctype("Appraisal")
- frappe.db.sql("update `tabAppraisal` set remarks = comments")
\ No newline at end of file
diff --git a/erpnext/patches/v5_0/set_default_company_in_bom.py b/erpnext/patches/v5_0/set_default_company_in_bom.py
deleted file mode 100644
index a5cd761119..0000000000
--- a/erpnext/patches/v5_0/set_default_company_in_bom.py
+++ /dev/null
@@ -1,10 +0,0 @@
-# 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():
- frappe.reload_doc("manufacturing", "doctype", "bom")
- company = frappe.db.get_value("Global Defaults", None, "default_company")
- frappe.db.sql("""update `tabBOM` set company = %s""",company)
diff --git a/erpnext/patches/v5_0/set_footer_address.py b/erpnext/patches/v5_0/set_footer_address.py
deleted file mode 100644
index 8120d834e1..0000000000
--- a/erpnext/patches/v5_0/set_footer_address.py
+++ /dev/null
@@ -1,9 +0,0 @@
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- frappe.reload_doctype("System Settings")
- ss = frappe.get_doc("System Settings", "System Settings")
- ss.email_footer_address = frappe.db.get_default("company")
- ss.flags.ignore_mandatory = True
- ss.save()
diff --git a/erpnext/patches/v5_0/stock_entry_update_value.py b/erpnext/patches/v5_0/stock_entry_update_value.py
deleted file mode 100644
index ba1af310f5..0000000000
--- a/erpnext/patches/v5_0/stock_entry_update_value.py
+++ /dev/null
@@ -1,8 +0,0 @@
-from __future__ import unicode_literals
-import frappe
-
-def execute():
- for d in frappe.db.get_all("Stock Entry"):
- se = frappe.get_doc("Stock Entry", d.name)
- se.set_total_incoming_outgoing_value()
- se.db_update()
diff --git a/erpnext/patches/v5_0/taxes_and_totals_in_party_currency.py b/erpnext/patches/v5_0/taxes_and_totals_in_party_currency.py
deleted file mode 100644
index 76d10820b5..0000000000
--- a/erpnext/patches/v5_0/taxes_and_totals_in_party_currency.py
+++ /dev/null
@@ -1,80 +0,0 @@
-# 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
-from frappe.model.meta import get_field_precision
-from frappe.custom.doctype.property_setter.property_setter import make_property_setter
-
-def execute():
- selling_doctypes = ["Quotation", "Sales Order", "Delivery Note", "Sales Invoice"]
- buying_doctypes = ["Supplier Quotation", "Purchase Order", "Purchase Receipt", "Purchase Invoice"]
-
- for dt in selling_doctypes:
- update_values(dt, "Sales Taxes and Charges")
-
- for dt in buying_doctypes:
- update_values(dt, "Purchase Taxes and Charges")
-
-def update_values(dt, tax_table):
- frappe.reload_doctype(dt)
- frappe.reload_doctype(dt + " Item")
- frappe.reload_doctype(tax_table)
-
- net_total_precision = get_field_precision(frappe.get_meta(dt).get_field("net_total"))
- for field in ("total", "base_total", "base_net_total"):
- make_property_setter(dt, field, "precision", net_total_precision, "Select")
-
- rate_field_precision = get_field_precision(frappe.get_meta(dt + " Item").get_field("rate"))
- for field in ("net_rate", "base_net_rate", "net_amount", "base_net_amount", "base_rate", "base_amount"):
- make_property_setter(dt + " Item", field, "precision", rate_field_precision, "Select")
-
- tax_amount_precision = get_field_precision(frappe.get_meta(tax_table).get_field("tax_amount"))
- for field in ("base_tax_amount", "total", "base_total", "tax_amount_after_discount_amount",
- "base_tax_amount_after_discount_amount"):
- make_property_setter(tax_table, field, "precision", tax_amount_precision, "Select")
-
- # update net_total, discount_on
- frappe.db.sql("""
- UPDATE
- `tab{0}`
- SET
- total = round(net_total, {1}),
- base_total = round(net_total*conversion_rate, {1}),
- net_total = round(base_net_total / conversion_rate, {1}),
- apply_discount_on = "Grand Total"
- WHERE
- docstatus < 2
- """.format(dt, net_total_precision))
-
- # update net_amount
- frappe.db.sql("""
- UPDATE
- `tab{0}` par, `tab{1}` item
- SET
- item.base_net_amount = round(item.base_amount, {2}),
- item.base_net_rate = round(item.base_rate, {2}),
- item.net_amount = round(item.base_amount / par.conversion_rate, {2}),
- item.net_rate = round(item.base_rate / par.conversion_rate, {2}),
- item.base_amount = round(item.amount * par.conversion_rate, {2}),
- item.base_rate = round(item.rate * par.conversion_rate, {2})
- WHERE
- par.name = item.parent
- and par.docstatus < 2
- """.format(dt, dt + " Item", rate_field_precision))
-
- # update tax in party currency
- frappe.db.sql("""
- UPDATE
- `tab{0}` par, `tab{1}` tax
- SET
- tax.base_tax_amount = round(tax.tax_amount, {2}),
- tax.tax_amount = round(tax.tax_amount / par.conversion_rate, {2}),
- tax.base_total = round(tax.total, {2}),
- tax.total = round(tax.total / conversion_rate, {2}),
- tax.base_tax_amount_after_discount_amount = round(tax.tax_amount_after_discount_amount, {2}),
- tax.tax_amount_after_discount_amount = round(tax.tax_amount_after_discount_amount / conversion_rate, {2})
- WHERE
- par.name = tax.parent
- and par.docstatus < 2
- """.format(dt, tax_table, tax_amount_precision))
diff --git a/erpnext/patches/v5_0/update_account_types.py b/erpnext/patches/v5_0/update_account_types.py
deleted file mode 100644
index 424743efaa..0000000000
--- a/erpnext/patches/v5_0/update_account_types.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# 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():
- for company in frappe.db.get_all("Company"):
- company = frappe.get_doc("Company", company.name)
-
- match_types = ("Stock Received But Not Billed", "Stock Adjustment", "Expenses Included In Valuation",
- "Cost of Goods Sold")
-
- for account_type in match_types:
- account_name = "{0} - {1}".format(account_type, company.abbr)
- current_account_type = frappe.db.get_value("Account", account_name, "account_type")
- if current_account_type != account_type:
- frappe.db.set_value("Account", account_name, "account_type", account_type)
-
- company.set_default_accounts()
diff --git a/erpnext/patches/v5_0/update_advance_paid.py b/erpnext/patches/v5_0/update_advance_paid.py
deleted file mode 100644
index 74e71e84c8..0000000000
--- a/erpnext/patches/v5_0/update_advance_paid.py
+++ /dev/null
@@ -1,13 +0,0 @@
-# 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():
- for dt in ("Sales Order", "Purchase Order"):
- orders_with_advance = frappe.db.sql("""select name from `tab{0}`
- where docstatus < 2 and ifnull(advance_paid, 0) != 0""".format(dt), as_dict=1)
-
- for order in orders_with_advance:
- frappe.get_doc(dt, order.name).set_total_advance_paid()
\ No newline at end of file
diff --git a/erpnext/patches/v5_0/update_companywise_payment_account.py b/erpnext/patches/v5_0/update_companywise_payment_account.py
deleted file mode 100644
index fb4b919c85..0000000000
--- a/erpnext/patches/v5_0/update_companywise_payment_account.py
+++ /dev/null
@@ -1,21 +0,0 @@
-# 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():
- frappe.reload_doc('accounts', 'doctype', 'mode_of_payment')
- frappe.reload_doc('accounts', 'doctype', 'mode_of_payment_account')
-
- mode_of_payment_list = frappe.db.sql("""select name, default_account
- from `tabMode of Payment`""", as_dict=1)
-
- for d in mode_of_payment_list:
- if d.get("default_account"):
- parent_doc = frappe.get_doc("Mode of Payment", d.get("name"))
-
- parent_doc.set("accounts",
- [{"company": frappe.db.get_value("Account", d.get("default_account"), "company"),
- "default_account": d.get("default_account")}])
- parent_doc.save()
diff --git a/erpnext/patches/v5_0/update_dn_against_doc_fields.py b/erpnext/patches/v5_0/update_dn_against_doc_fields.py
deleted file mode 100644
index 56f4f484b1..0000000000
--- a/erpnext/patches/v5_0/update_dn_against_doc_fields.py
+++ /dev/null
@@ -1,14 +0,0 @@
-# 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():
- frappe.reload_doc('stock', 'doctype', 'delivery_note_item')
-
- frappe.db.sql("""update `tabDelivery Note Item` set so_detail = prevdoc_detail_docname
- where ifnull(against_sales_order, '') != ''""")
-
- frappe.db.sql("""update `tabDelivery Note Item` set si_detail = prevdoc_detail_docname
- where ifnull(against_sales_invoice, '') != ''""")
diff --git a/erpnext/patches/v5_0/update_from_bom.py b/erpnext/patches/v5_0/update_from_bom.py
deleted file mode 100644
index 4b3e62d7a5..0000000000
--- a/erpnext/patches/v5_0/update_from_bom.py
+++ /dev/null
@@ -1,9 +0,0 @@
-# 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():
- frappe.reload_doctype("Stock Entry")
- frappe.db.sql("update `tabStock Entry` set from_bom = if(ifnull(bom_no, '')='', 0, 1)")
diff --git a/erpnext/patches/v5_0/update_frozen_accounts_permission_role.py b/erpnext/patches/v5_0/update_frozen_accounts_permission_role.py
deleted file mode 100644
index b52785ae60..0000000000
--- a/erpnext/patches/v5_0/update_frozen_accounts_permission_role.py
+++ /dev/null
@@ -1,13 +0,0 @@
-# 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():
- account_settings = frappe.get_doc("Accounts Settings")
-
- if not account_settings.frozen_accounts_modifier and account_settings.bde_auth_role:
- frappe.db.set_value("Accounts Settings", None,
- "frozen_accounts_modifier", account_settings.bde_auth_role)
-
diff --git a/erpnext/patches/v5_0/update_item_and_description_again.py b/erpnext/patches/v5_0/update_item_and_description_again.py
deleted file mode 100644
index 35dedcc072..0000000000
--- a/erpnext/patches/v5_0/update_item_and_description_again.py
+++ /dev/null
@@ -1,50 +0,0 @@
-# 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
-from frappe.utils import cstr
-import re
-
-def execute():
- item_details = frappe._dict()
- for d in frappe.db.sql("select name, description from `tabItem`", as_dict=1):
- description = cstr(d.description).strip()
- new_desc = extract_description(description)
-
- item_details.setdefault(d.name, frappe._dict({
- "old_description": description,
- "new_description": new_desc
- }))
-
-
- dt_list= ["Purchase Order Item","Supplier Quotation Item", "BOM", "BOM Explosion Item" , \
- "BOM Item", "Opportunity Item" , "Quotation Item" , "Sales Order Item" , "Delivery Note Item" , \
- "Material Request Item" , "Purchase Receipt Item" , "Stock Entry Detail"]
- for dt in dt_list:
- frappe.reload_doctype(dt)
- records = frappe.db.sql("""select name, `{0}` as item_code, description from `tab{1}`
- where description is not null and description like '%%