Skip to content

Commit

Permalink
Release v15.41.2 (#44037)
Browse files Browse the repository at this point in the history
* fix: improved the conditions for determining voucher subtypes

(cherry picked from commit 00eee16)

* fix: patch

(cherry picked from commit d76cc21)

# Conflicts:
#	erpnext/patches.txt

* test: test voucher subtype for sales invoice

(cherry picked from commit ad6cc35)

* chore: resolve conflict

* fix: NoneType while updating ordered_qty in SO for removed items

(cherry picked from commit 442cdd7)

* refactor: add "margin_type" and "margin_rate_or_amount" to no copy

(cherry picked from commit 70f090c)

* fix: item not set in the batch quick entry form (backport #44028) (#44031)

fix: item not set in the batch quick entry form (#44028)

(cherry picked from commit 0399ccc)

Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>

* fix: calculate percentage received and delivered considering over-receipt and over-delivery (backport #43870) (#44030)

fix: calculate percentage received and delivered considering over-receipt and over-delivery (#43870)

(cherry picked from commit adba116)

Co-authored-by: Nabin Hait <nabinhait@gmail.com>

* fix: sort by ascending to get the first period closing voucher (backport #44029) (#44035)

fix: sort by ascending to get the first period closing voucher (#44029)

(cherry picked from commit 42dcdcd)

Co-authored-by: Venkatesh <47534423+venkat102@users.noreply.github.com>

---------

Co-authored-by: ljain112 <ljain112@gmail.com>
Co-authored-by: Smit Vora <smitvora203@gmail.com>
Co-authored-by: ruthra kumar <ruthra@erpnext.com>
Co-authored-by: bhaveshkumar.j <bhaveshkumar.j@sritindia.com>
Co-authored-by: Ravindu Nethmina <117300601+NethminaHiker360@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: rohitwaghchaure <rohitw1991@gmail.com>
Co-authored-by: Venkatesh <47534423+venkat102@users.noreply.github.com>
  • Loading branch information
9 people authored Nov 8, 2024
1 parent 4819535 commit f5610e2
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def is_first_period_closing_voucher(self):
"Period Closing Voucher",
{"company": self.company, "docstatus": 1},
"name",
order_by="period_end_date",
order_by="period_end_date asc",
)

if not first_pcv or first_pcv == self.name:
Expand Down
19 changes: 19 additions & 0 deletions erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -4005,6 +4005,25 @@ def test_invoice_remarks(self):
si.submit()
self.assertEqual(si.remarks, f"Against Customer Order Test PO dated {format_date(nowdate())}")

def test_gl_voucher_subtype(self):
si = create_sales_invoice()
gl_entries = frappe.get_all(
"GL Entry",
filters={"voucher_type": "Sales Invoice", "voucher_no": si.name},
pluck="voucher_subtype",
)

self.assertTrue(all([x == "Sales Invoice" for x in gl_entries]))

si = create_sales_invoice(is_return=1, qty=-1)
gl_entries = frappe.get_all(
"GL Entry",
filters={"voucher_type": "Sales Invoice", "voucher_no": si.name},
pluck="voucher_subtype",
)

self.assertTrue(all([x == "Credit Note" for x in gl_entries]))


def set_advance_flag(company, flag, default_account):
frappe.db.set_value(
Expand Down
8 changes: 5 additions & 3 deletions erpnext/buying/doctype/purchase_order/purchase_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ def update_reserved_qty_for_subcontract(self):
def update_receiving_percentage(self):
total_qty, received_qty = 0.0, 0.0
for item in self.items:
received_qty += item.received_qty
received_qty += min(item.received_qty, item.qty)
total_qty += item.qty
if total_qty:
self.db_set("per_received", flt(received_qty / total_qty) * 100, update_modified=False)
Expand Down Expand Up @@ -625,9 +625,11 @@ def update_ordered_qty_in_so_for_removed_items(self, removed_items):
if not self.is_against_so():
return
for item in removed_items:
prev_ordered_qty = frappe.get_cached_value(
"Sales Order Item", item.get("sales_order_item"), "ordered_qty"
prev_ordered_qty = (
frappe.get_cached_value("Sales Order Item", item.get("sales_order_item"), "ordered_qty")
or 0.0
)

frappe.db.set_value(
"Sales Order Item", item.get("sales_order_item"), "ordered_qty", prev_ordered_qty - item.qty
)
Expand Down
6 changes: 4 additions & 2 deletions erpnext/controllers/accounts_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -1096,9 +1096,11 @@ def get_voucher_subtype(self):
return "Purchase Return"
elif self.doctype == "Delivery Note" and self.is_return:
return "Sales Return"
elif (self.doctype == "Sales Invoice" and self.is_return) or self.doctype == "Purchase Invoice":
elif self.doctype == "Sales Invoice" and self.is_return:
return "Credit Note"
elif (self.doctype == "Purchase Invoice" and self.is_return) or self.doctype == "Sales Invoice":
elif self.doctype == "Sales Invoice" and self.is_debit_note:
return "Debit Note"
elif self.doctype == "Purchase Invoice" and self.is_return:
return "Debit Note"

return self.doctype
Expand Down
3 changes: 2 additions & 1 deletion erpnext/patches.txt
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ erpnext.patches.v15_0.update_asset_value_for_manual_depr_entries
erpnext.patches.v15_0.update_gpa_and_ndb_for_assdeprsch
erpnext.patches.v14_0.create_accounting_dimensions_for_closing_balance
erpnext.patches.v14_0.set_period_start_end_date_in_pcv
erpnext.patches.v14_0.update_closing_balances #29-10-2024
erpnext.patches.v14_0.update_closing_balances #08-11-2024
execute:frappe.db.set_single_value("Accounts Settings", "merge_similar_account_heads", 0)
erpnext.patches.v14_0.update_reference_type_in_journal_entry_accounts
erpnext.patches.v14_0.update_subscription_details
Expand Down Expand Up @@ -381,3 +381,4 @@ erpnext.patches.v15_0.set_standard_stock_entry_type
erpnext.patches.v15_0.link_purchase_item_to_asset_doc
erpnext.patches.v14_0.update_currency_exchange_settings_for_frankfurter
erpnext.patches.v15_0.update_task_assignee_email_field_in_asset_maintenance_log
erpnext.patches.v15_0.update_sub_voucher_type_in_gl_entries
57 changes: 57 additions & 0 deletions erpnext/patches/v15_0/update_sub_voucher_type_in_gl_entries.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import frappe


def execute():
update_purchase_invoices()
update_sales_invoices()
update_sales_debit_notes()


def update_purchase_invoices():
invoices = frappe.get_all(
"Purchase Invoice",
filters={"docstatus": 1, "is_return": 0},
pluck="name",
)

if not invoices:
return

update_gl_entry(doctype="Purchase Invoice", invoices=invoices, value="Purchase Invoice")


def update_sales_invoices():
invoices = frappe.get_all(
"Sales Invoice",
filters={"docstatus": 1, "is_return": 0, "is_debit_note": 0},
pluck="name",
)
if not invoices:
return

update_gl_entry(doctype="Sales Invoice", invoices=invoices, value="Sales Invoice")


def update_sales_debit_notes():
invoices = frappe.get_all(
"Sales Invoice",
filters={"docstatus": 1, "is_debit_note": 1},
pluck="name",
)

if not invoices:
return

update_gl_entry(doctype="Sales Invoice", invoices=invoices, value="Debit Note")


def update_gl_entry(doctype, invoices, value):
gl_entry = frappe.qb.DocType("GL Entry")
(
frappe.qb.update(gl_entry)
.set("voucher_subtype", value)
.where(gl_entry.voucher_subtype.isnotnull())
.where(gl_entry.voucher_no.isin(invoices))
.where(gl_entry.voucher_type == doctype)
.run()
)
51 changes: 29 additions & 22 deletions erpnext/public/js/controllers/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,28 +289,6 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
}
]);
}

if(this.frm.fields_dict['items'].grid.get_field('serial_and_batch_bundle')) {
let sbb_field = this.frm.get_docfield('items', 'serial_and_batch_bundle');
if (sbb_field) {
sbb_field.get_route_options_for_new_doc = (row) => {
return {
'item_code': row.doc.item_code,
}
};
}
}

if(this.frm.fields_dict['items'].grid.get_field('batch_no')) {
let batch_no_field = this.frm.get_docfield('items', 'batch_no');
if (batch_no_field) {
batch_no_field.get_route_options_for_new_doc = function(row) {
return {
'item': row.doc.item_code
}
};
}
}
}

is_return() {
Expand Down Expand Up @@ -409,6 +387,35 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
this.setup_quality_inspection();
this.validate_has_items();
erpnext.utils.view_serial_batch_nos(this.frm);
this.set_route_options_for_new_doc();
}

set_route_options_for_new_doc() {
// While creating the batch from the link field, copy item from line item to batch form

if(this.frm.fields_dict['items'].grid.get_field('batch_no')) {
let batch_no_field = this.frm.get_docfield('items', 'batch_no');
if (batch_no_field) {
batch_no_field.get_route_options_for_new_doc = function(row) {
return {
'item': row.doc.item_code
}
};
}
}

// While creating the SABB from the link field, copy item, doctype from line item to SABB form
if(this.frm.fields_dict['items'].grid.get_field('serial_and_batch_bundle')) {
let sbb_field = this.frm.get_docfield('items', 'serial_and_batch_bundle');
if (sbb_field) {
sbb_field.get_route_options_for_new_doc = (row) => {
return {
"item_code": row.doc.item_code,
"voucher_type": this.frm.doc.doctype,
}
};
}
}
}

scan_barcode() {
Expand Down
4 changes: 3 additions & 1 deletion erpnext/selling/doctype/sales_order/sales_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ def update_delivery_status(self):
item_delivered_qty = item_delivered_qty[0][0] if item_delivered_qty else 0
item.db_set("delivered_qty", flt(item_delivered_qty), update_modified=False)

delivered_qty += item.delivered_qty
delivered_qty += min(item.delivered_qty, item.qty)
tot_qty += item.qty

if tot_qty != 0:
Expand Down Expand Up @@ -1347,6 +1347,8 @@ def update_item(source, target, source_parent):
"discount_percentage",
"discount_amount",
"pricing_rules",
"margin_type",
"margin_rate_or_amount",
],
"postprocess": update_item,
"condition": lambda doc: doc.ordered_qty < doc.stock_qty
Expand Down

0 comments on commit f5610e2

Please sign in to comment.