Fixes to Return Improvements pull request
- Added "Returned Qty" in Sales and Purchase Order - Map Expense Account in Return Delivery Note - Defined some No Copy fields - Added "Credit Note" and "Debit Note" Print Headings - Fixed patch
This commit is contained in:
parent
b719c469c8
commit
fe13bfed44
@ -127,7 +127,7 @@ class PurchaseInvoice(BuyingController):
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
if cint(frappe.db.get_single_value('Buying Settings', 'maintain_same_rate')):
|
if cint(frappe.db.get_single_value('Buying Settings', 'maintain_same_rate')) and not self.is_return:
|
||||||
self.validate_rate_with_reference_doc([
|
self.validate_rate_with_reference_doc([
|
||||||
["Purchase Order", "purchase_order", "po_detail"],
|
["Purchase Order", "purchase_order", "po_detail"],
|
||||||
["Purchase Receipt", "purchase_receipt", "pr_detail"]
|
["Purchase Receipt", "purchase_receipt", "pr_detail"]
|
||||||
|
@ -7,7 +7,7 @@ frappe.listview_settings['Purchase Invoice'] = {
|
|||||||
"currency", "is_return"],
|
"currency", "is_return"],
|
||||||
get_indicator: function(doc) {
|
get_indicator: function(doc) {
|
||||||
if(cint(doc.is_return)==1) {
|
if(cint(doc.is_return)==1) {
|
||||||
return [__("Return"), "darkgrey", "is_return,=,1"];
|
return [__("Return"), "darkgrey", "is_return,=,Yes"];
|
||||||
} else if(flt(doc.outstanding_amount) > 0 && doc.docstatus==1) {
|
} else if(flt(doc.outstanding_amount) > 0 && doc.docstatus==1) {
|
||||||
if(frappe.datetime.get_diff(doc.due_date) < 0) {
|
if(frappe.datetime.get_diff(doc.due_date) < 0) {
|
||||||
return [__("Overdue"), "red", "outstanding_amount,>,0|due_date,<,Today"];
|
return [__("Overdue"), "red", "outstanding_amount,>,0|due_date,<,Today"];
|
||||||
|
@ -64,6 +64,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
|
|||||||
if(doc.outstanding_amount!=0 && !cint(doc.is_return)) {
|
if(doc.outstanding_amount!=0 && !cint(doc.is_return)) {
|
||||||
cur_frm.add_custom_button(__('Payment'), cur_frm.cscript.make_bank_entry).addClass("btn-primary");
|
cur_frm.add_custom_button(__('Payment'), cur_frm.cscript.make_bank_entry).addClass("btn-primary");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show buttons only when pos view is active
|
// Show buttons only when pos view is active
|
||||||
|
@ -82,6 +82,7 @@ class SalesInvoice(SellingController):
|
|||||||
self.check_prev_docstatus()
|
self.check_prev_docstatus()
|
||||||
|
|
||||||
if self.is_return:
|
if self.is_return:
|
||||||
|
# NOTE status updating bypassed for is_return
|
||||||
self.status_updater = []
|
self.status_updater = []
|
||||||
|
|
||||||
self.update_status_updater_args()
|
self.update_status_updater_args()
|
||||||
@ -112,6 +113,7 @@ class SalesInvoice(SellingController):
|
|||||||
remove_against_link_from_jv(self.doctype, self.name)
|
remove_against_link_from_jv(self.doctype, self.name)
|
||||||
|
|
||||||
if self.is_return:
|
if self.is_return:
|
||||||
|
# NOTE status updating bypassed for is_return
|
||||||
self.status_updater = []
|
self.status_updater = []
|
||||||
|
|
||||||
self.update_status_updater_args()
|
self.update_status_updater_args()
|
||||||
@ -126,7 +128,7 @@ class SalesInvoice(SellingController):
|
|||||||
|
|
||||||
def update_status_updater_args(self):
|
def update_status_updater_args(self):
|
||||||
if cint(self.update_stock):
|
if cint(self.update_stock):
|
||||||
self.status_updater.append({
|
self.status_updater.extend([{
|
||||||
'source_dt':'Sales Invoice Item',
|
'source_dt':'Sales Invoice Item',
|
||||||
'target_dt':'Sales Order Item',
|
'target_dt':'Sales Order Item',
|
||||||
'target_parent_dt':'Sales Order',
|
'target_parent_dt':'Sales Order',
|
||||||
@ -144,7 +146,21 @@ class SalesInvoice(SellingController):
|
|||||||
'overflow_type': 'delivery',
|
'overflow_type': 'delivery',
|
||||||
'extra_cond': """ and exists(select name from `tabSales Invoice`
|
'extra_cond': """ and exists(select name from `tabSales Invoice`
|
||||||
where name=`tabSales Invoice Item`.parent and ifnull(update_stock, 0) = 1)"""
|
where name=`tabSales Invoice Item`.parent and ifnull(update_stock, 0) = 1)"""
|
||||||
})
|
},
|
||||||
|
{
|
||||||
|
'source_dt': 'Sales Invoice Item',
|
||||||
|
'target_dt': 'Sales Order Item',
|
||||||
|
'join_field': 'so_detail',
|
||||||
|
'target_field': 'returned_qty',
|
||||||
|
'target_parent_dt': 'Sales Order',
|
||||||
|
# 'target_parent_field': 'per_delivered',
|
||||||
|
# 'target_ref_field': 'qty',
|
||||||
|
'source_field': '-1 * qty',
|
||||||
|
# 'percent_join_field': 'sales_order',
|
||||||
|
# 'overflow_type': 'delivery',
|
||||||
|
'extra_cond': """ and exists (select name from `tabSales Invoice` where name=`tabSales Invoice Item`.parent and update_stock=1 and is_return=1)"""
|
||||||
|
}
|
||||||
|
])
|
||||||
|
|
||||||
def set_missing_values(self, for_validate=False):
|
def set_missing_values(self, for_validate=False):
|
||||||
pos = self.set_pos_fields(for_validate)
|
pos = self.set_pos_fields(for_validate)
|
||||||
@ -281,7 +297,7 @@ class SalesInvoice(SellingController):
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if cint(frappe.db.get_single_value('Selling Settings', 'maintain_same_sales_rate')):
|
if cint(frappe.db.get_single_value('Selling Settings', 'maintain_same_sales_rate')) and not self.is_return:
|
||||||
self.validate_rate_with_reference_doc([
|
self.validate_rate_with_reference_doc([
|
||||||
["Sales Order", "sales_order", "so_detail"],
|
["Sales Order", "sales_order", "so_detail"],
|
||||||
["Delivery Note", "delivery_note", "dn_detail"]
|
["Delivery Note", "delivery_note", "dn_detail"]
|
||||||
|
@ -7,7 +7,7 @@ frappe.listview_settings['Sales Invoice'] = {
|
|||||||
"currency", "is_return"],
|
"currency", "is_return"],
|
||||||
get_indicator: function(doc) {
|
get_indicator: function(doc) {
|
||||||
if(cint(doc.is_return)==1) {
|
if(cint(doc.is_return)==1) {
|
||||||
return [__("Return"), "darkgrey", "is_return,=,1"];
|
return [__("Return"), "darkgrey", "is_return,=,Yes"];
|
||||||
} else if(flt(doc.outstanding_amount)==0) {
|
} else if(flt(doc.outstanding_amount)==0) {
|
||||||
return [__("Paid"), "green", "outstanding_amount,=,0"]
|
return [__("Paid"), "green", "outstanding_amount,=,0"]
|
||||||
} else if (flt(doc.outstanding_amount) > 0 && doc.due_date > frappe.datetime.get_today()) {
|
} else if (flt(doc.outstanding_amount) > 0 && doc.due_date > frappe.datetime.get_today()) {
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"creation": "2015-07-22 17:45:22.220567",
|
|
||||||
"custom_format": 1,
|
|
||||||
"disabled": 0,
|
|
||||||
"doc_type": "Sales Invoice",
|
|
||||||
"docstatus": 0,
|
|
||||||
"doctype": "Print Format",
|
|
||||||
"font": "Default",
|
|
||||||
"html": "<style>\n\t.print-format table, .print-format tr, \n\t.print-format td, .print-format div, .print-format p {\n\t\tfont-family: Monospace;\n\t\tline-height: 200%;\n\t\tvertical-align: middle;\n\t}\n\t@media screen {\n\t\t.print-format {\n\t\t\twidth: 4in;\n\t\t\tpadding: 0.25in;\n\t\t\tmin-height: 6in;\n\t\t}\n\t}\n</style>\n\n<p class=\"text-center\">\n\t{{ doc.company }}<br>\n\t{{ doc.select_print_heading or _(\"Credit Note\") }}<br>\n</p>\n\n<hr>\n\n{%- for label, value in (\n (_(\"Receipt No\"), doc.name),\n (_(\"Date\"), doc.get_formatted(\"posting_date\")),\n\t(_(\"Customer\"), doc.customer_name),\n (_(\"Amount\"), \"<strong>\" + doc.get_formatted(\"grand_total\", absolute_value=True) + \"</strong><br>\" + (doc.in_words or \"\")),\n\t(_(\"Against\"), doc.return_against),\n (_(\"Remarks\"), doc.remarks)\n) -%}\n\n\t\t<div class=\"row\">\n\t\t <div class=\"col-xs-4\"><label class=\"text-right\">{{ label }}</label></div>\n\t\t <div class=\"col-xs-8\">{{ value }}</div>\n\t\t</div>\n{%- endfor -%}\n\n<hr>\n<br>\n<p class=\"strong\">\n {{ _(\"For\") }} {{ doc.company }},<br>\n <br>\n <br>\n <br>\n {{ _(\"Authorized Signatory\") }}\n</p>",
|
|
||||||
"modified": "2015-07-22 17:45:22.220567",
|
|
||||||
"modified_by": "Administrator",
|
|
||||||
"name": "Credit Note - Negative Invoice",
|
|
||||||
"owner": "Administrator",
|
|
||||||
"print_format_builder": 0,
|
|
||||||
"print_format_type": "Server",
|
|
||||||
"standard": "Yes"
|
|
||||||
}
|
|
@ -1002,6 +1002,27 @@
|
|||||||
"set_only_once": 0,
|
"set_only_once": 0,
|
||||||
"unique": 0
|
"unique": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"depends_on": "returned_qty",
|
||||||
|
"fieldname": "returned_qty",
|
||||||
|
"fieldtype": "Float",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"label": "Returned Qty",
|
||||||
|
"no_copy": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"unique": 0
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"fieldname": "billed_amt",
|
"fieldname": "billed_amt",
|
||||||
@ -1074,7 +1095,7 @@
|
|||||||
"is_submittable": 0,
|
"is_submittable": 0,
|
||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"modified": "2015-08-19 12:46:32.384796",
|
"modified": "2015-08-25 06:42:00.898647",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Buying",
|
"module": "Buying",
|
||||||
"name": "Purchase Order Item",
|
"name": "Purchase Order Item",
|
||||||
|
3
erpnext/change_log/current/sales_purchase_return.md
Normal file
3
erpnext/change_log/current/sales_purchase_return.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
- Fixes in Sales and Purchase Return
|
||||||
|
- Update Delivered, Ordered and Returned Quantity based on Return transaction
|
||||||
|
- Allow different Rate in Return transaction
|
@ -83,10 +83,6 @@ def validate_returned_items(doc):
|
|||||||
elif abs(d.qty) > max_return_qty:
|
elif abs(d.qty) > max_return_qty:
|
||||||
frappe.throw(_("Row # {0}: Cannot return more than {1} for Item {2}")
|
frappe.throw(_("Row # {0}: Cannot return more than {1} for Item {2}")
|
||||||
.format(d.idx, ref.qty, d.item_code), StockOverReturnError)
|
.format(d.idx, ref.qty, d.item_code), StockOverReturnError)
|
||||||
elif ref.rate and (doc.doctype in ("Delivery Note", "Purchase Receipt") \
|
|
||||||
or (doc.doctype=="Sales Invoice" and doc.update_stock==1)) and flt(d.rate) > ref.rate:
|
|
||||||
frappe.throw(_("Row # {0}: Rate cannot be greater than {1} {2}")
|
|
||||||
.format(d.idx, doc.doctype, doc.return_against))
|
|
||||||
elif ref.batch_no and d.batch_no != ref.batch_no:
|
elif ref.batch_no and d.batch_no != ref.batch_no:
|
||||||
frappe.throw(_("Row # {0}: Batch No must be same as {1} {2}")
|
frappe.throw(_("Row # {0}: Batch No must be same as {1} {2}")
|
||||||
.format(d.idx, doc.doctype, doc.return_against))
|
.format(d.idx, doc.doctype, doc.return_against))
|
||||||
@ -128,6 +124,14 @@ def make_return_doc(doctype, source_name, target_doc=None):
|
|||||||
if doctype == "Sales Invoice":
|
if doctype == "Sales Invoice":
|
||||||
doc.is_pos = 0
|
doc.is_pos = 0
|
||||||
|
|
||||||
|
# look for Print Heading "Credit Note"
|
||||||
|
if not doc.select_print_heading:
|
||||||
|
doc.select_print_heading = frappe.db.get_value("Print Heading", _("Credit Note"))
|
||||||
|
|
||||||
|
elif doctype == "Purchase Invoice":
|
||||||
|
# look for Print Heading "Debit Note"
|
||||||
|
doc.select_print_heading = frappe.db.get_value("Print Heading", _("Debit Note"))
|
||||||
|
|
||||||
for tax in doc.get("taxes"):
|
for tax in doc.get("taxes"):
|
||||||
if tax.charge_type == "Actual":
|
if tax.charge_type == "Actual":
|
||||||
tax.tax_amount = -1 * tax.tax_amount
|
tax.tax_amount = -1 * tax.tax_amount
|
||||||
@ -151,11 +155,13 @@ def make_return_doc(doctype, source_name, target_doc=None):
|
|||||||
target_doc.against_sales_invoice = source_doc.against_sales_invoice
|
target_doc.against_sales_invoice = source_doc.against_sales_invoice
|
||||||
target_doc.so_detail = source_doc.so_detail
|
target_doc.so_detail = source_doc.so_detail
|
||||||
target_doc.si_detail = source_doc.si_detail
|
target_doc.si_detail = source_doc.si_detail
|
||||||
|
target_doc.expense_account = source_doc.expense_account
|
||||||
elif doctype == "Sales Invoice":
|
elif doctype == "Sales Invoice":
|
||||||
target_doc.sales_order = source_doc.sales_order
|
target_doc.sales_order = source_doc.sales_order
|
||||||
target_doc.delivery_note = source_doc.delivery_note
|
target_doc.delivery_note = source_doc.delivery_note
|
||||||
target_doc.so_detail = source_doc.so_detail
|
target_doc.so_detail = source_doc.so_detail
|
||||||
target_doc.dn_detail = source_doc.dn_detail
|
target_doc.dn_detail = source_doc.dn_detail
|
||||||
|
target_doc.expense_account = source_doc.expense_account
|
||||||
|
|
||||||
doclist = get_mapped_doc(doctype, source_name, {
|
doclist = get_mapped_doc(doctype, source_name, {
|
||||||
doctype: {
|
doctype: {
|
||||||
|
@ -90,6 +90,10 @@ class StatusUpdater(Document):
|
|||||||
self.global_tolerance = None
|
self.global_tolerance = None
|
||||||
|
|
||||||
for args in self.status_updater:
|
for args in self.status_updater:
|
||||||
|
if "target_ref_field" not in args:
|
||||||
|
# if target_ref_field is not specified, the programmer does not want to validate qty / amount
|
||||||
|
continue
|
||||||
|
|
||||||
# get unique transactions to update
|
# get unique transactions to update
|
||||||
for d in self.get_all_children():
|
for d in self.get_all_children():
|
||||||
if d.doctype == args['source_dt'] and d.get(args["join_field"]):
|
if d.doctype == args['source_dt'] and d.get(args["join_field"]):
|
||||||
@ -140,8 +144,9 @@ class StatusUpdater(Document):
|
|||||||
.format(_(item["target_ref_field"].title()), item["reduce_by"]))
|
.format(_(item["target_ref_field"].title()), item["reduce_by"]))
|
||||||
|
|
||||||
def update_qty(self, change_modified=True):
|
def update_qty(self, change_modified=True):
|
||||||
"""
|
"""Updates qty or amount at row level
|
||||||
Updates qty at row level
|
|
||||||
|
:param change_modified: If true, updates `modified` and `modified_by` for target parent doc
|
||||||
"""
|
"""
|
||||||
for args in self.status_updater:
|
for args in self.status_updater:
|
||||||
# condition to include current record (if submit or no if cancel)
|
# condition to include current record (if submit or no if cancel)
|
||||||
@ -150,13 +155,22 @@ class StatusUpdater(Document):
|
|||||||
else:
|
else:
|
||||||
args['cond'] = ' and parent!="%s"' % self.name.replace('"', '\"')
|
args['cond'] = ' and parent!="%s"' % self.name.replace('"', '\"')
|
||||||
|
|
||||||
args['modified_cond'] = ''
|
args['set_modified'] = ''
|
||||||
if change_modified:
|
if change_modified:
|
||||||
args['modified_cond'] = ', modified = now()'
|
args['set_modified'] = ', modified = now(), modified_by = "{0}"'\
|
||||||
|
.format(frappe.db.escape(frappe.session.user))
|
||||||
|
|
||||||
# update quantities in child table
|
self._update_children(args)
|
||||||
|
|
||||||
|
if "percent_join_field" in args:
|
||||||
|
self._update_percent_field(args)
|
||||||
|
|
||||||
|
def _update_children(self, args):
|
||||||
|
"""Update quantities or amount in child table"""
|
||||||
for d in self.get_all_children():
|
for d in self.get_all_children():
|
||||||
if d.doctype == args['source_dt']:
|
if d.doctype != args['source_dt']:
|
||||||
|
continue
|
||||||
|
|
||||||
# updates qty in the child table
|
# updates qty in the child table
|
||||||
args['detail_id'] = d.get(args['join_field'])
|
args['detail_id'] = d.get(args['join_field'])
|
||||||
|
|
||||||
@ -180,9 +194,14 @@ class StatusUpdater(Document):
|
|||||||
and (docstatus=1 %(cond)s) %(extra_cond)s) %(second_source_condition)s
|
and (docstatus=1 %(cond)s) %(extra_cond)s) %(second_source_condition)s
|
||||||
where name='%(detail_id)s'""" % args)
|
where name='%(detail_id)s'""" % args)
|
||||||
|
|
||||||
# get unique transactions to update
|
def _update_percent_field(self, args):
|
||||||
for name in set([d.get(args['percent_join_field']) for d in self.get_all_children(args['source_dt'])]):
|
"""Update percent field in parent transaction"""
|
||||||
if name:
|
unique_transactions = set([d.get(args['percent_join_field']) for d in self.get_all_children(args['source_dt'])])
|
||||||
|
|
||||||
|
for name in unique_transactions:
|
||||||
|
if not name:
|
||||||
|
continue
|
||||||
|
|
||||||
args['name'] = name
|
args['name'] = name
|
||||||
|
|
||||||
# update percent complete in the parent table
|
# update percent complete in the parent table
|
||||||
@ -191,7 +210,7 @@ class StatusUpdater(Document):
|
|||||||
set %(target_parent_field)s = (select sum(if(%(target_ref_field)s >
|
set %(target_parent_field)s = (select sum(if(%(target_ref_field)s >
|
||||||
ifnull(%(target_field)s, 0), %(target_field)s,
|
ifnull(%(target_field)s, 0), %(target_field)s,
|
||||||
%(target_ref_field)s))/sum(%(target_ref_field)s)*100
|
%(target_ref_field)s))/sum(%(target_ref_field)s)*100
|
||||||
from `tab%(target_dt)s` where parent="%(name)s") %(modified_cond)s
|
from `tab%(target_dt)s` where parent="%(name)s") %(set_modified)s
|
||||||
where name='%(name)s'""" % args)
|
where name='%(name)s'""" % args)
|
||||||
|
|
||||||
# update field
|
# update field
|
||||||
@ -202,6 +221,8 @@ class StatusUpdater(Document):
|
|||||||
'Fully %(keyword)s', 'Partly %(keyword)s'))
|
'Fully %(keyword)s', 'Partly %(keyword)s'))
|
||||||
where name='%(name)s'""" % args)
|
where name='%(name)s'""" % args)
|
||||||
|
|
||||||
|
if args.get("set_modified"):
|
||||||
|
frappe.get_doc(args["target_parent_dt"], name).notify_modified()
|
||||||
|
|
||||||
def update_billing_status_for_zero_amount_refdoc(self, ref_dt):
|
def update_billing_status_for_zero_amount_refdoc(self, ref_dt):
|
||||||
ref_fieldname = ref_dt.lower().replace(" ", "_")
|
ref_fieldname = ref_dt.lower().replace(" ", "_")
|
||||||
|
@ -191,6 +191,10 @@ erpnext.patches.v5_4.stock_entry_additional_costs
|
|||||||
erpnext.patches.v5_4.cleanup_journal_entry #2015-08-14
|
erpnext.patches.v5_4.cleanup_journal_entry #2015-08-14
|
||||||
execute:frappe.db.sql("update `tabProduction Order` pro set description = (select description from tabItem where name=pro.production_item) where ifnull(description, '') = ''")
|
execute:frappe.db.sql("update `tabProduction Order` pro set description = (select description from tabItem where name=pro.production_item) where ifnull(description, '') = ''")
|
||||||
erpnext.patches.v5_7.item_template_attributes
|
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 #2015-08-20
|
erpnext.patches.v4_2.repost_reserved_qty #2015-08-20
|
||||||
erpnext.patches.v5_4.update_purchase_cost_against_project
|
erpnext.patches.v5_4.update_purchase_cost_against_project
|
||||||
erpnext.patches.v5_7.update_order_reference_in_return_entries
|
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")
|
||||||
|
@ -55,9 +55,6 @@ def migrate_manage_variants():
|
|||||||
template.set('attributes', attributes)
|
template.set('attributes', attributes)
|
||||||
template.save()
|
template.save()
|
||||||
|
|
||||||
frappe.delete_doc("DocType", "Manage Variants")
|
|
||||||
frappe.delete_doc("DocType", "Manage Variants Item")
|
|
||||||
|
|
||||||
# patch old style
|
# patch old style
|
||||||
def migrate_item_variants():
|
def migrate_item_variants():
|
||||||
for item in frappe.get_all("Item", filters={"has_variants": 1}):
|
for item in frappe.get_all("Item", filters={"has_variants": 1}):
|
||||||
|
1
erpnext/patches/v5_8/__init__.py
Normal file
1
erpnext/patches/v5_8/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
from __future__ import unicode_literals
|
14
erpnext/patches/v5_8/add_credit_note_print_heading.py
Normal file
14
erpnext/patches/v5_8/add_credit_note_print_heading.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# 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
|
||||||
|
from frappe import _
|
||||||
|
|
||||||
|
def execute():
|
||||||
|
for print_heading in (_("Credit Note"), _("Debit Note")):
|
||||||
|
if not frappe.db.exists("Print Heading", print_heading):
|
||||||
|
frappe.get_doc({
|
||||||
|
"doctype": "Print Heading",
|
||||||
|
"print_heading": print_heading
|
||||||
|
}).insert()
|
@ -15,34 +15,41 @@ def execute():
|
|||||||
|
|
||||||
return_entries += list(frappe.db.sql("""
|
return_entries += list(frappe.db.sql("""
|
||||||
select si.name as name, si_item.name as row_id, si.return_against,
|
select si.name as name, si_item.name as row_id, si.return_against,
|
||||||
si_item.item_code, "Sales Invoice" as doctype
|
si_item.item_code, "Sales Invoice" as doctype, update_stock
|
||||||
from `tabSales Invoice Item` si_item, `tabSales Invoice` si
|
from `tabSales Invoice Item` si_item, `tabSales Invoice` si
|
||||||
where si_item.parent=si.name and si.is_return=1 and si.update_stock=1 and si.docstatus < 2
|
where si_item.parent=si.name and si.is_return=1 and si.docstatus < 2
|
||||||
""", as_dict=1))
|
""", as_dict=1))
|
||||||
|
|
||||||
for d in return_entries:
|
for d in return_entries:
|
||||||
ref_field = "against_sales_order" if d.doctype == "Delivery Note" else "sales_order"
|
ref_field = "against_sales_order" if d.doctype == "Delivery Note" else "sales_order"
|
||||||
order_details = frappe.db.sql("""
|
order_details = frappe.db.sql("""
|
||||||
select {0} as sales_order, so_detail
|
select {ref_field} as sales_order, so_detail,
|
||||||
from `tab{1} Item` item
|
(select transaction_date from `tabSales Order` where name=item.{ref_field}) as sales_order_date
|
||||||
|
from `tab{doctype} Item` item
|
||||||
where
|
where
|
||||||
parent=%s and item_code=%s
|
parent=%s
|
||||||
|
and item_code=%s
|
||||||
and ifnull(so_detail, '') !=''
|
and ifnull(so_detail, '') !=''
|
||||||
order by
|
order by sales_order_date DESC limit 1
|
||||||
(select transaction_date from `tabSales Order` where name=item.{3}) DESC
|
""".format(ref_field=ref_field, doctype=d.doctype), (d.return_against, d.item_code), as_dict=1)
|
||||||
""".format(ref_field, d.doctype, ref_field, ref_field), (d.return_against, d.item_code), as_dict=1)
|
|
||||||
|
|
||||||
if order_details:
|
if order_details:
|
||||||
frappe.db.sql("""
|
frappe.db.sql("""
|
||||||
update `tab{0} Item`
|
update `tab{doctype} Item`
|
||||||
set {1}=%s, so_detail=%s
|
set {ref_field}=%s, so_detail=%s
|
||||||
where name=%s
|
where name=%s
|
||||||
""".format(d.doctype, ref_field),
|
""".format(doctype=d.doctype, ref_field=ref_field),
|
||||||
(order_details[0].sales_order, order_details[0].so_detail, d.row_id))
|
(order_details[0].sales_order, order_details[0].so_detail, d.row_id))
|
||||||
|
|
||||||
|
if (d.doctype=="Sales Invoice" and d.update_stock) or d.doctype=="Delivery Note":
|
||||||
doc = frappe.get_doc(d.doctype, d.name)
|
doc = frappe.get_doc(d.doctype, d.name)
|
||||||
doc.update_reserved_qty()
|
doc.update_reserved_qty()
|
||||||
|
|
||||||
|
if d.doctype=="Sales Invoice":
|
||||||
|
doc.status_updater = []
|
||||||
|
doc.update_status_updater_args()
|
||||||
|
|
||||||
|
doc.update_prevdoc_status()
|
||||||
|
|
||||||
#--------------------------
|
#--------------------------
|
||||||
# purchase return
|
# purchase return
|
||||||
@ -54,14 +61,15 @@ def execute():
|
|||||||
|
|
||||||
for d in return_entries:
|
for d in return_entries:
|
||||||
order_details = frappe.db.sql("""
|
order_details = frappe.db.sql("""
|
||||||
select prevdoc_docname as purchase_order, prevdoc_detail_docname as po_detail
|
select prevdoc_docname as purchase_order, prevdoc_detail_docname as po_detail,
|
||||||
|
(select transaction_date from `tabPurchase Order` where name=item.prevdoc_detail_docname) as purchase_order_date
|
||||||
from `tabPurchase Receipt Item` item
|
from `tabPurchase Receipt Item` item
|
||||||
where
|
where
|
||||||
parent=%s and item_code=%s
|
parent=%s
|
||||||
|
and item_code=%s
|
||||||
and ifnull(prevdoc_detail_docname, '') !=''
|
and ifnull(prevdoc_detail_docname, '') !=''
|
||||||
and ifnull(prevdoc_doctype, '') = 'Purchase Order' and ifnull(prevdoc_detail_docname, '') != ''
|
and ifnull(prevdoc_doctype, '') = 'Purchase Order' and ifnull(prevdoc_detail_docname, '') != ''
|
||||||
order by
|
order by purchase_order_date DESC limit 1
|
||||||
(select transaction_date from `tabPurchase Order` where name=item.prevdoc_detail_docname) DESC
|
|
||||||
""", (d.return_against, d.item_code), as_dict=1)
|
""", (d.return_against, d.item_code), as_dict=1)
|
||||||
|
|
||||||
if order_details:
|
if order_details:
|
||||||
@ -73,4 +81,5 @@ def execute():
|
|||||||
|
|
||||||
pr = frappe.get_doc("Purchase Receipt", d.name)
|
pr = frappe.get_doc("Purchase Receipt", d.name)
|
||||||
pr.update_ordered_qty()
|
pr.update_ordered_qty()
|
||||||
|
pr.update_prevdoc_status()
|
||||||
|
|
@ -88,6 +88,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
|||||||
this.set_dynamic_labels();
|
this.set_dynamic_labels();
|
||||||
erpnext.pos.make_pos_btn(this.frm);
|
erpnext.pos.make_pos_btn(this.frm);
|
||||||
this.setup_sms();
|
this.setup_sms();
|
||||||
|
this.make_show_payments_btn();
|
||||||
},
|
},
|
||||||
|
|
||||||
apply_default_taxes: function() {
|
apply_default_taxes: function() {
|
||||||
@ -123,6 +124,22 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
|||||||
var sms_man = new SMSManager(this.frm.doc);
|
var sms_man = new SMSManager(this.frm.doc);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
make_show_payments_btn: function() {
|
||||||
|
var me = this;
|
||||||
|
if (in_list(["Purchase Invoice", "Sales Invoice"], this.frm.doctype)) {
|
||||||
|
if(this.frm.doc.outstanding_amount !== this.frm.doc.base_grand_total) {
|
||||||
|
this.frm.add_custom_button(__("Show Payments"), function() {
|
||||||
|
frappe.route_options = {
|
||||||
|
"Journal Entry Account.reference_type": me.frm.doc.doctype,
|
||||||
|
"Journal Entry Account.reference_name": me.frm.doc.name
|
||||||
|
};
|
||||||
|
|
||||||
|
frappe.set_route("List", "Journal Entry");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
hide_currency_and_price_list: function() {
|
hide_currency_and_price_list: function() {
|
||||||
if(this.frm.doc.conversion_rate == 1 && this.frm.doc.docstatus > 0) {
|
if(this.frm.doc.conversion_rate == 1 && this.frm.doc.docstatus > 0) {
|
||||||
hide_field("currency_and_price_list");
|
hide_field("currency_and_price_list");
|
||||||
|
@ -840,6 +840,27 @@
|
|||||||
"unique": 0,
|
"unique": 0,
|
||||||
"width": "100px"
|
"width": "100px"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"allow_on_submit": 0,
|
||||||
|
"depends_on": "returned_qty",
|
||||||
|
"fieldname": "returned_qty",
|
||||||
|
"fieldtype": "Float",
|
||||||
|
"hidden": 0,
|
||||||
|
"ignore_user_permissions": 0,
|
||||||
|
"in_filter": 0,
|
||||||
|
"in_list_view": 0,
|
||||||
|
"label": "Returned Qty",
|
||||||
|
"no_copy": 1,
|
||||||
|
"permlevel": 0,
|
||||||
|
"precision": "",
|
||||||
|
"print_hide": 1,
|
||||||
|
"read_only": 1,
|
||||||
|
"report_hide": 0,
|
||||||
|
"reqd": 0,
|
||||||
|
"search_index": 0,
|
||||||
|
"set_only_once": 0,
|
||||||
|
"unique": 0
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"allow_on_submit": 0,
|
"allow_on_submit": 0,
|
||||||
"fieldname": "billed_amt",
|
"fieldname": "billed_amt",
|
||||||
@ -960,7 +981,7 @@
|
|||||||
"is_submittable": 0,
|
"is_submittable": 0,
|
||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"modified": "2015-08-19 12:46:32.930498",
|
"modified": "2015-08-25 06:42:11.062909",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Selling",
|
"module": "Selling",
|
||||||
"name": "Sales Order Item",
|
"name": "Sales Order Item",
|
||||||
|
@ -173,6 +173,8 @@ def install(country=None):
|
|||||||
{"doctype": "Offer Term", "offer_term": _("Notice Period")},
|
{"doctype": "Offer Term", "offer_term": _("Notice Period")},
|
||||||
{"doctype": "Offer Term", "offer_term": _("Incentives")},
|
{"doctype": "Offer Term", "offer_term": _("Incentives")},
|
||||||
|
|
||||||
|
{'doctype': "Print Heading", 'print_heading': _("Credit Note")},
|
||||||
|
{'doctype': "Print Heading", 'print_heading': _("Debit Note")}
|
||||||
]
|
]
|
||||||
|
|
||||||
from erpnext.setup.page.setup_wizard.fixtures import industry_type
|
from erpnext.setup.page.setup_wizard.fixtures import industry_type
|
||||||
|
@ -47,6 +47,19 @@ class DeliveryNote(SellingController):
|
|||||||
'source_field': 'qty',
|
'source_field': 'qty',
|
||||||
'percent_join_field': 'against_sales_invoice',
|
'percent_join_field': 'against_sales_invoice',
|
||||||
'overflow_type': 'delivery'
|
'overflow_type': 'delivery'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'source_dt': 'Delivery Note Item',
|
||||||
|
'target_dt': 'Sales Order Item',
|
||||||
|
'join_field': 'so_detail',
|
||||||
|
'target_field': 'returned_qty',
|
||||||
|
'target_parent_dt': 'Sales Order',
|
||||||
|
# 'target_parent_field': 'per_delivered',
|
||||||
|
# 'target_ref_field': 'qty',
|
||||||
|
'source_field': '-1 * qty',
|
||||||
|
# 'percent_join_field': 'against_sales_order',
|
||||||
|
# 'overflow_type': 'delivery',
|
||||||
|
'extra_cond': """ and exists (select name from `tabDelivery Note` where name=`tabDelivery Note Item`.parent and is_return=1)"""
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def onload(self):
|
def onload(self):
|
||||||
@ -118,7 +131,7 @@ class DeliveryNote(SellingController):
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if cint(frappe.db.get_single_value('Selling Settings', 'maintain_same_sales_rate')):
|
if cint(frappe.db.get_single_value('Selling Settings', 'maintain_same_sales_rate')) and not self.is_return:
|
||||||
self.validate_rate_with_reference_doc([["Sales Order", "sales_order", "so_detail"],
|
self.validate_rate_with_reference_doc([["Sales Order", "sales_order", "so_detail"],
|
||||||
["Sales Invoice", "sales_invoice", "si_detail"]])
|
["Sales Invoice", "sales_invoice", "si_detail"]])
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ frappe.listview_settings['Delivery Note'] = {
|
|||||||
"transporter_name", "grand_total", "is_return"],
|
"transporter_name", "grand_total", "is_return"],
|
||||||
get_indicator: function(doc) {
|
get_indicator: function(doc) {
|
||||||
if(cint(doc.is_return)==1) {
|
if(cint(doc.is_return)==1) {
|
||||||
return [__("Return"), "darkgrey", "is_return,=,1"];
|
return [__("Return"), "darkgrey", "is_return,=,Yes"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -912,7 +912,7 @@
|
|||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"in_list_view": 1,
|
"in_list_view": 1,
|
||||||
"label": "Against Sales Order",
|
"label": "Against Sales Order",
|
||||||
"no_copy": 0,
|
"no_copy": 1,
|
||||||
"options": "Sales Order",
|
"options": "Sales Order",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
@ -932,7 +932,7 @@
|
|||||||
"in_filter": 0,
|
"in_filter": 0,
|
||||||
"in_list_view": 0,
|
"in_list_view": 0,
|
||||||
"label": "Against Sales Invoice",
|
"label": "Against Sales Invoice",
|
||||||
"no_copy": 0,
|
"no_copy": 1,
|
||||||
"options": "Sales Invoice",
|
"options": "Sales Invoice",
|
||||||
"permlevel": 0,
|
"permlevel": 0,
|
||||||
"print_hide": 1,
|
"print_hide": 1,
|
||||||
@ -1039,7 +1039,7 @@
|
|||||||
"is_submittable": 0,
|
"is_submittable": 0,
|
||||||
"issingle": 0,
|
"issingle": 0,
|
||||||
"istable": 1,
|
"istable": 1,
|
||||||
"modified": "2015-08-19 12:46:31.447022",
|
"modified": "2015-08-25 07:15:19.811365",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Stock",
|
"module": "Stock",
|
||||||
"name": "Delivery Note Item",
|
"name": "Delivery Note Item",
|
||||||
|
@ -29,6 +29,19 @@ class PurchaseReceipt(BuyingController):
|
|||||||
'source_field': 'qty',
|
'source_field': 'qty',
|
||||||
'percent_join_field': 'prevdoc_docname',
|
'percent_join_field': 'prevdoc_docname',
|
||||||
'overflow_type': 'receipt'
|
'overflow_type': 'receipt'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'source_dt': 'Purchase Receipt Item',
|
||||||
|
'target_dt': 'Purchase Order Item',
|
||||||
|
'join_field': 'prevdoc_detail_docname',
|
||||||
|
'target_field': 'returned_qty',
|
||||||
|
'target_parent_dt': 'Purchase Order',
|
||||||
|
# 'target_parent_field': 'per_received',
|
||||||
|
# 'target_ref_field': 'qty',
|
||||||
|
'source_field': '-1 * qty',
|
||||||
|
# 'percent_join_field': 'prevdoc_docname',
|
||||||
|
# 'overflow_type': 'receipt',
|
||||||
|
'extra_cond': """ and exists (select name from `tabPurchase Receipt` where name=`tabPurchase Receipt Item`.parent and is_return=1)"""
|
||||||
}]
|
}]
|
||||||
|
|
||||||
def onload(self):
|
def onload(self):
|
||||||
@ -113,7 +126,7 @@ class PurchaseReceipt(BuyingController):
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
if cint(frappe.db.get_single_value('Buying Settings', 'maintain_same_rate')):
|
if cint(frappe.db.get_single_value('Buying Settings', 'maintain_same_rate')) and not self.is_return:
|
||||||
self.validate_rate_with_reference_doc([["Purchase Order", "prevdoc_docname", "prevdoc_detail_docname"]])
|
self.validate_rate_with_reference_doc([["Purchase Order", "prevdoc_docname", "prevdoc_detail_docname"]])
|
||||||
|
|
||||||
def po_required(self):
|
def po_required(self):
|
||||||
|
@ -3,7 +3,7 @@ frappe.listview_settings['Purchase Receipt'] = {
|
|||||||
"transporter_name", "is_return"],
|
"transporter_name", "is_return"],
|
||||||
get_indicator: function(doc) {
|
get_indicator: function(doc) {
|
||||||
if(cint(doc.is_return)==1) {
|
if(cint(doc.is_return)==1) {
|
||||||
return [__("Return"), "darkgrey", "is_return,=,1"];
|
return [__("Return"), "darkgrey", "is_return,=,Yes"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -209,7 +209,7 @@ def validate_serial_no(sle, item_det):
|
|||||||
frappe.throw(_("Serial No {0} quantity {1} cannot be a fraction").format(sle.item_code, sle.actual_qty))
|
frappe.throw(_("Serial No {0} quantity {1} cannot be a fraction").format(sle.item_code, sle.actual_qty))
|
||||||
|
|
||||||
if len(serial_nos) and len(serial_nos) != abs(cint(sle.actual_qty)):
|
if len(serial_nos) and len(serial_nos) != abs(cint(sle.actual_qty)):
|
||||||
frappe.throw(_("{0} Serial Numbers required for Item {0}. Only {0} provided.").format(sle.actual_qty, sle.item_code, len(serial_nos)),
|
frappe.throw(_("{0} Serial Numbers required for Item {1}. You have provided {2}.").format(sle.actual_qty, sle.item_code, len(serial_nos)),
|
||||||
SerialNoQtyError)
|
SerialNoQtyError)
|
||||||
|
|
||||||
if len(serial_nos) != len(set(serial_nos)):
|
if len(serial_nos) != len(set(serial_nos)):
|
||||||
|
@ -257,6 +257,10 @@ def validate_price_list(args):
|
|||||||
def validate_conversion_rate(args, meta):
|
def validate_conversion_rate(args, meta):
|
||||||
from erpnext.controllers.accounts_controller import validate_conversion_rate
|
from erpnext.controllers.accounts_controller import validate_conversion_rate
|
||||||
|
|
||||||
|
if (not args.conversion_rate
|
||||||
|
and args.currency==frappe.db.get_value("Company", args.company, "default_currency")):
|
||||||
|
args.conversion_rate = 1.0
|
||||||
|
|
||||||
# validate currency conversion rate
|
# validate currency conversion rate
|
||||||
validate_conversion_rate(args.currency, args.conversion_rate,
|
validate_conversion_rate(args.currency, args.conversion_rate,
|
||||||
meta.get_label("conversion_rate"), args.company)
|
meta.get_label("conversion_rate"), args.company)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user