feat: provision to make debit / credit note against the stock returned entry
This commit is contained in:
parent
2d0fd9f519
commit
5d4d70b75f
@ -337,7 +337,8 @@ class PurchaseInvoice(BuyingController):
|
|||||||
if not self.is_return:
|
if not self.is_return:
|
||||||
self.update_against_document_in_jv()
|
self.update_against_document_in_jv()
|
||||||
self.update_billing_status_for_zero_amount_refdoc("Purchase Order")
|
self.update_billing_status_for_zero_amount_refdoc("Purchase Order")
|
||||||
self.update_billing_status_in_pr()
|
|
||||||
|
self.update_billing_status_in_pr()
|
||||||
|
|
||||||
# Updating stock ledger should always be called after updating prevdoc status,
|
# Updating stock ledger should always be called after updating prevdoc status,
|
||||||
# because updating ordered qty in bin depends upon updated ordered qty in PO
|
# because updating ordered qty in bin depends upon updated ordered qty in PO
|
||||||
@ -769,7 +770,8 @@ class PurchaseInvoice(BuyingController):
|
|||||||
|
|
||||||
if not self.is_return:
|
if not self.is_return:
|
||||||
self.update_billing_status_for_zero_amount_refdoc("Purchase Order")
|
self.update_billing_status_for_zero_amount_refdoc("Purchase Order")
|
||||||
self.update_billing_status_in_pr()
|
|
||||||
|
self.update_billing_status_in_pr()
|
||||||
|
|
||||||
# Updating stock ledger should always be called after updating prevdoc status,
|
# Updating stock ledger should always be called after updating prevdoc status,
|
||||||
# because updating ordered qty in bin depends upon updated ordered qty in PO
|
# because updating ordered qty in bin depends upon updated ordered qty in PO
|
||||||
|
@ -290,7 +290,7 @@ class StatusUpdater(Document):
|
|||||||
frappe.db.sql("""update `tab%(target_parent_dt)s`
|
frappe.db.sql("""update `tab%(target_parent_dt)s`
|
||||||
set %(target_parent_field)s = round(
|
set %(target_parent_field)s = round(
|
||||||
ifnull((select
|
ifnull((select
|
||||||
ifnull(sum(if(%(target_ref_field)s > %(target_field)s, abs(%(target_field)s), abs(%(target_ref_field)s))), 0)
|
ifnull(sum(if(abs(%(target_ref_field)s) > abs(%(target_field)s), abs(%(target_field)s), abs(%(target_ref_field)s))), 0)
|
||||||
/ sum(abs(%(target_ref_field)s)) * 100
|
/ sum(abs(%(target_ref_field)s)) * 100
|
||||||
from `tab%(target_dt)s` where parent="%(name)s" having sum(abs(%(target_ref_field)s)) > 0), 0), 6)
|
from `tab%(target_dt)s` where parent="%(name)s" having sum(abs(%(target_ref_field)s)) > 0), 0), 6)
|
||||||
%(update_modified)s
|
%(update_modified)s
|
||||||
|
@ -77,8 +77,34 @@ frappe.ui.form.on("Delivery Note", {
|
|||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
print_without_amount: function(frm) {
|
print_without_amount: function(frm) {
|
||||||
erpnext.stock.delivery_note.set_print_hide(frm.doc);
|
erpnext.stock.delivery_note.set_print_hide(frm.doc);
|
||||||
|
},
|
||||||
|
|
||||||
|
refresh: function(frm) {
|
||||||
|
if (frm.doc.docstatus === 1 && frm.doc.is_return === 1 && frm.doc.per_billed !== 100) {
|
||||||
|
frm.add_custom_button(__('Credit Note'), function() {
|
||||||
|
frappe.confirm(__("Are you sure you want to make credit note?"),
|
||||||
|
function() {
|
||||||
|
frm.trigger("make_credit_note");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}, __('Create'));
|
||||||
|
|
||||||
|
frm.page.set_inner_btn_group_as_primary(__('Create'));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
make_credit_note: function(frm) {
|
||||||
|
frm.call({
|
||||||
|
method: "make_return_invoice",
|
||||||
|
doc: frm.doc,
|
||||||
|
freeze: true,
|
||||||
|
callback: function() {
|
||||||
|
frm.reload_doc();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -333,7 +333,10 @@ class DeliveryNote(SellingController):
|
|||||||
return_invoice.is_return = True
|
return_invoice.is_return = True
|
||||||
return_invoice.save()
|
return_invoice.save()
|
||||||
return_invoice.submit()
|
return_invoice.submit()
|
||||||
frappe.msgprint(_("Credit Note {0} has been created automatically").format(return_invoice.name))
|
|
||||||
|
credit_note_link = frappe.utils.get_link_to_form('Sales Invoice', return_invoice.name)
|
||||||
|
|
||||||
|
frappe.msgprint(_("Credit Note {0} has been created automatically").format(credit_note_link))
|
||||||
except:
|
except:
|
||||||
frappe.throw(_("Could not create Credit Note automatically, please uncheck 'Issue Credit Note' and submit again"))
|
frappe.throw(_("Could not create Credit Note automatically, please uncheck 'Issue Credit Note' and submit again"))
|
||||||
|
|
||||||
|
@ -38,6 +38,29 @@ frappe.ui.form.on("Purchase Receipt", {
|
|||||||
if(frm.doc.company) {
|
if(frm.doc.company) {
|
||||||
frm.trigger("toggle_display_account_head");
|
frm.trigger("toggle_display_account_head");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (frm.doc.docstatus === 1 && frm.doc.is_return === 1 && frm.doc.per_billed !== 100) {
|
||||||
|
frm.add_custom_button(__('Debit Note'), function() {
|
||||||
|
frappe.confirm(__("Are you sure you want to make debit note?"),
|
||||||
|
function() {
|
||||||
|
frm.trigger("make_debit_note");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}, __('Create'));
|
||||||
|
|
||||||
|
frm.page.set_inner_btn_group_as_primary(__('Create'));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
make_debit_note: function(frm) {
|
||||||
|
frm.call({
|
||||||
|
method: "make_return_invoice",
|
||||||
|
doc: frm.doc,
|
||||||
|
freeze: true,
|
||||||
|
callback: function() {
|
||||||
|
frm.reload_doc();
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
company: function(frm) {
|
company: function(frm) {
|
||||||
|
@ -396,6 +396,16 @@ class PurchaseReceipt(BuyingController):
|
|||||||
|
|
||||||
self.load_from_db()
|
self.load_from_db()
|
||||||
|
|
||||||
|
def make_return_invoice(self):
|
||||||
|
return_invoice = make_purchase_invoice(self.name)
|
||||||
|
return_invoice.is_return = True
|
||||||
|
return_invoice.save()
|
||||||
|
return_invoice.submit()
|
||||||
|
|
||||||
|
debit_note_link = frappe.utils.get_link_to_form('Purchase Invoice', return_invoice.name)
|
||||||
|
|
||||||
|
frappe.msgprint(_("Debit Note {0} has been created automatically").format(debit_note_link))
|
||||||
|
|
||||||
def update_billed_amount_based_on_po(po_detail, update_modified=True):
|
def update_billed_amount_based_on_po(po_detail, update_modified=True):
|
||||||
# Billed against Sales Order directly
|
# Billed against Sales Order directly
|
||||||
billed_against_po = frappe.db.sql("""select sum(amount) from `tabPurchase Invoice Item`
|
billed_against_po = frappe.db.sql("""select sum(amount) from `tabPurchase Invoice Item`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user