[fix] capacity planning error
This commit is contained in:
parent
1828c12481
commit
3131c732ff
@ -69,8 +69,8 @@ class TestJournalEntry(unittest.TestCase):
|
||||
if test_voucher.doctype == "Journal Entry":
|
||||
# if test_voucher is a Journal Entry, test cancellation of test_voucher
|
||||
test_voucher.cancel()
|
||||
self.assertTrue(not frappe.db.sql("""select name from `tabJournal Entry Account`
|
||||
where against_jv=%s""", test_voucher.name))
|
||||
self.assertFalse(frappe.db.sql("""select name from `tabJournal Entry Account`
|
||||
where reference_type='Journal Entry' and reference_name=%s""", test_voucher.name))
|
||||
|
||||
elif test_voucher.doctype in ["Sales Order", "Purchase Order"]:
|
||||
# if test_voucher is a Sales Order/Purchase Order, test error on cancellation of test_voucher
|
||||
|
@ -218,17 +218,14 @@ class TestPurchaseInvoice(unittest.TestCase):
|
||||
pi.load_from_db()
|
||||
|
||||
self.assertTrue(frappe.db.sql("""select name from `tabJournal Entry Account`
|
||||
where against_voucher=%s""", pi.name))
|
||||
|
||||
self.assertTrue(frappe.db.sql("""select name from `tabJournal Entry Account`
|
||||
where against_voucher=%s and debit=300""", pi.name))
|
||||
where reference_type='Purchase Invoice' and reference_name=%s and debit=300""", pi.name))
|
||||
|
||||
self.assertEqual(pi.outstanding_amount, 1212.30)
|
||||
|
||||
pi.cancel()
|
||||
|
||||
self.assertTrue(not frappe.db.sql("""select name from `tabJournal Entry Account`
|
||||
where against_voucher=%s""", pi.name))
|
||||
self.assertFalse(frappe.db.sql("""select name from `tabJournal Entry Account`
|
||||
where reference_type='Purchase Invoice' and reference_name=%s""", pi.name))
|
||||
|
||||
def test_recurring_invoice(self):
|
||||
from erpnext.controllers.tests.test_recurring_document import test_recurring_document
|
||||
|
@ -4,6 +4,14 @@
|
||||
from __future__ import unicode_literals
|
||||
import frappe
|
||||
from frappe.model.document import Document
|
||||
from frappe.utils import cint
|
||||
from dateutil.relativedelta import relativedelta
|
||||
|
||||
class ManufacturingSettings(Document):
|
||||
pass
|
||||
|
||||
def get_mins_between_operations():
|
||||
if not hasattr(frappe.local, "_mins_between_operations"):
|
||||
frappe.local._mins_between_operations = cint(frappe.db.get_single_value("Manufacturing Settings",
|
||||
"mins_between_operations")) or 10
|
||||
return relativedelta(minutes=frappe.local._mins_between_operations)
|
||||
|
@ -13,6 +13,7 @@ from erpnext.stock.doctype.item.item import validate_end_of_life
|
||||
from erpnext.manufacturing.doctype.workstation.workstation import WorkstationHolidayError, NotInWorkingHoursError
|
||||
from erpnext.projects.doctype.time_log.time_log import OverlapError
|
||||
from erpnext.stock.doctype.stock_entry.stock_entry import get_additional_costs
|
||||
from erpnext.manufacturing.doctype.manufacturing_settings.manufacturing_settings import get_mins_between_operations
|
||||
|
||||
class OverProductionError(frappe.ValidationError): pass
|
||||
class StockOverProductionError(frappe.ValidationError): pass
|
||||
@ -231,6 +232,7 @@ class ProductionOrder(Document):
|
||||
original_start_time = time_log.from_time
|
||||
while True:
|
||||
_from_time = time_log.from_time
|
||||
|
||||
try:
|
||||
time_log.save()
|
||||
break
|
||||
@ -248,6 +250,7 @@ class ProductionOrder(Document):
|
||||
frappe.msgprint(_("Unable to find Time Slot in the next {0} days for Operation {1}").format(plan_days, d.operation))
|
||||
break
|
||||
|
||||
# if time log needs to be moved, make sure that the from time is not the same
|
||||
if _from_time == time_log.from_time:
|
||||
frappe.throw("Capacity Planning Error")
|
||||
|
||||
@ -273,19 +276,13 @@ class ProductionOrder(Document):
|
||||
d.planned_start_time = self.planned_start_date
|
||||
else:
|
||||
d.planned_start_time = get_datetime(self.operations[i-1].planned_end_time)\
|
||||
+ self.get_mins_between_operations()
|
||||
+ get_mins_between_operations()
|
||||
|
||||
d.planned_end_time = get_datetime(d.planned_start_time) + relativedelta(minutes = d.time_in_mins)
|
||||
|
||||
if d.planned_start_time == d.planned_end_time:
|
||||
frappe.throw(_("Capacity Planning Error"))
|
||||
|
||||
def get_mins_between_operations(self):
|
||||
if not hasattr(self, "_mins_between_operations"):
|
||||
self._mins_between_operations = cint(frappe.db.get_single_value("Manufacturing Settings",
|
||||
"mins_between_operations")) or 10
|
||||
return relativedelta(minutes=self._mins_between_operations)
|
||||
|
||||
def check_operation_fits_in_working_hours(self, d):
|
||||
"""Raises expection if operation is longer than working hours in the given workstation."""
|
||||
from erpnext.manufacturing.doctype.workstation.workstation import check_if_within_operating_hours
|
||||
|
@ -6,6 +6,7 @@ import frappe, json
|
||||
from frappe import _
|
||||
from frappe.utils import cstr, flt, get_datetime, get_time, getdate
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from erpnext.manufacturing.doctype.manufacturing_settings.manufacturing_settings import get_mins_between_operations
|
||||
|
||||
class OverlapError(frappe.ValidationError): pass
|
||||
class OverProductionLoggedError(frappe.ValidationError): pass
|
||||
@ -182,9 +183,14 @@ class TimeLog(Document):
|
||||
|
||||
def move_to_next_non_overlapping_slot(self):
|
||||
"""If in overlap, set start as the end point of the overlapping time log"""
|
||||
overlapping = self.get_overlap_for("workstation")
|
||||
if overlapping:
|
||||
self.from_time = get_datetime(overlapping.to_time) + relativedelta(minutes=10)
|
||||
overlapping = self.get_overlap_for("workstation") \
|
||||
or self.get_overlap_for("employee") \
|
||||
or self.get_overlap_for("user")
|
||||
|
||||
if not overlapping:
|
||||
frappe.throw("Logical error: Must find overlapping")
|
||||
|
||||
self.from_time = get_datetime(overlapping.to_time) + get_mins_between_operations()
|
||||
|
||||
def get_time_log_summary(self):
|
||||
"""Returns 'Actual Operating Time'. """
|
||||
|
Loading…
x
Reference in New Issue
Block a user