Skip to content

Commit

Permalink
fix: incorrect transferred qty in the job card (#35478)
Browse files Browse the repository at this point in the history
fix: incorrect transfer quantity in the job card

(cherry picked from commit d3a5e49)

Co-authored-by: Rohit Waghchaure <rohitw1991@gmail.com>
  • Loading branch information
mergify[bot] and rohitwaghchaure authored May 31, 2023
1 parent c17e537 commit 86801c2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
22 changes: 9 additions & 13 deletions erpnext/manufacturing/doctype/job_card/job_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -653,23 +653,19 @@ def _validate_over_transfer(row, transferred_qty):
exc=JobCardOverTransferError,
)

job_card_items_transferred_qty = _get_job_card_items_transferred_qty(ste_doc)
job_card_items_transferred_qty = _get_job_card_items_transferred_qty(ste_doc) or {}
allow_excess = frappe.db.get_single_value("Manufacturing Settings", "job_card_excess_transfer")

if job_card_items_transferred_qty:
allow_excess = frappe.db.get_single_value("Manufacturing Settings", "job_card_excess_transfer")

for row in ste_doc.items:
if not row.job_card_item:
continue
for row in ste_doc.items:
if not row.job_card_item:
continue

transferred_qty = flt(job_card_items_transferred_qty.get(row.job_card_item))
transferred_qty = flt(job_card_items_transferred_qty.get(row.job_card_item, 0.0))

if not allow_excess:
_validate_over_transfer(row, transferred_qty)
if not allow_excess:
_validate_over_transfer(row, transferred_qty)

frappe.db.set_value(
"Job Card Item", row.job_card_item, "transferred_qty", flt(transferred_qty)
)
frappe.db.set_value("Job Card Item", row.job_card_item, "transferred_qty", flt(transferred_qty))

def set_transferred_qty(self, update_status=False):
"Set total FG Qty in Job Card for which RM was transferred."
Expand Down
6 changes: 6 additions & 0 deletions erpnext/manufacturing/doctype/job_card/test_job_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,12 @@ def test_job_card_partial_material_transfer(self):
job_card.reload()
self.assertEqual(job_card.transferred_qty, 2)

transfer_entry_2.cancel()
transfer_entry.cancel()

job_card.reload()
self.assertEqual(job_card.transferred_qty, 0.0)

def test_job_card_material_transfer_correctness(self):
"""
1. Test if only current Job Card Items are pulled in a Stock Entry against a Job Card
Expand Down

0 comments on commit 86801c2

Please sign in to comment.