Update: Forcibly Close Job

Allow jobs to be closed if procedures cannot be followed.
This commit is contained in:
Gary Sharp
2013-03-19 15:42:16 +11:00
parent 79085614d3
commit e422bf163d
13 changed files with 373 additions and 84 deletions
+62 -3
View File
@@ -329,9 +329,8 @@ namespace Disco.BI.Extensions
if (j.JobMetaNonWarranty.AccountingChargeRequiredDate.HasValue && (!j.JobMetaNonWarranty.AccountingChargePaidDate.HasValue || !j.JobMetaNonWarranty.AccountingChargeAddedDate.HasValue))
return false; // Accounting Charge Required, but not added or paid
// Removed Rule: 2012-05-31 - A Job can be closed if the decision has been made for the user not to pay...
//if (j.JobMetaNonWarranty.AccountingChargeAddedDate.HasValue && !j.JobMetaNonWarranty.AccountingChargePaidDate.HasValue)
// return false; // Accounting Charge Added, but not paid
if (j.JobMetaNonWarranty.AccountingChargeAddedDate.HasValue && !j.JobMetaNonWarranty.AccountingChargePaidDate.HasValue)
return false; // Accounting Charge Added, but not paid
if (j.JobMetaNonWarranty.IsInsuranceClaim && !j.JobMetaInsurance.ClaimFormSentDate.HasValue)
return false; // Is Insurance Claim, but claim form not sent
@@ -350,6 +349,66 @@ namespace Disco.BI.Extensions
}
#endregion
#region Force Close
public static bool CanForceClose(this Job j)
{
var canCloseNormally = j.CanClose();
if (canCloseNormally)
return false;
// Check for Override
if (j.ClosedDate.HasValue)
return false; // Job already Closed
if (j.DeviceHeld.HasValue && !j.DeviceReturnedDate.HasValue)
return false; // Device not returned to User
if (j.WaitingForUserAction.HasValue)
return false; // Job waiting on User Action
switch (j.JobTypeId)
{
case JobType.JobTypeIds.HWar:
if (!string.IsNullOrEmpty(j.JobMetaWarranty.ExternalReference) && !j.JobMetaWarranty.ExternalCompletedDate.HasValue)
return true; // Job Logged (Warranty) but not completed
break;
case JobType.JobTypeIds.HNWar:
if (j.JobMetaNonWarranty.RepairerLoggedDate.HasValue && !j.JobMetaNonWarranty.RepairerCompletedDate.HasValue)
return true; // Job Logged (Repair) but not completed
if (j.JobMetaNonWarranty.AccountingChargeRequiredDate.HasValue && (!j.JobMetaNonWarranty.AccountingChargePaidDate.HasValue || !j.JobMetaNonWarranty.AccountingChargeAddedDate.HasValue))
return true; // Accounting Charge Required, but not added or paid
if (j.JobMetaNonWarranty.AccountingChargeAddedDate.HasValue && !j.JobMetaNonWarranty.AccountingChargePaidDate.HasValue)
return true; // Accounting Charge Added, but not paid
if (j.JobMetaNonWarranty.IsInsuranceClaim && !j.JobMetaInsurance.ClaimFormSentDate.HasValue)
return true; // Is Insurance Claim, but claim form not sent
break;
}
return false;
}
public static void OnForceClose(this Job j, DiscoDataContext dbContext, User Technician, string Reason)
{
if (!j.CanForceClose())
throw new InvalidOperationException("Force Close was Denied");
// Write Log
JobLog jobLog = new JobLog()
{
JobId = j.Id,
TechUserId = Technician.Id,
Timestamp = DateTime.Now,
Comments = string.Format("Job Forcibly Closed{0}Reason: {1}", Environment.NewLine, Reason)
};
dbContext.JobLogs.Add(jobLog);
j.ClosedDate = DateTime.Now;
j.ClosedTechUserId = Technician.Id;
}
#endregion
#region Reopen
public static bool CanReopen(this Job j)
{
+2 -2
View File
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.2.0307.1501")]
[assembly: AssemblyFileVersion("1.2.0307.1501")]
[assembly: AssemblyVersion("1.2.0319.1534")]
[assembly: AssemblyFileVersion("1.2.0319.1534")]