Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/0019 phase 1 cleanup #58

Merged
merged 3 commits into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions CMMS/DAC/DBBacked/WOEquipment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ public abstract class equipmentID : PX.Data.BQL.BqlInt.Field<equipmentID> { }
[PXDBString(30, IsKey = true, IsUnicode = true, InputMask = "")]
[PXDefault]
[AutoNumber(typeof(WOSetup.equipNumberingID), typeof(AccessInfo.businessDate))]
[PXSelector(typeof(WOEquipment.equipmentCD),
[PXSelector(
typeof(WOEquipment.equipmentCD),
typeof(WOEquipment.equipmentCD),
typeof(WOEquipment.descr),
typeof(WOEquipment.inventoryID),
typeof(WOEquipment.sMEquipmentID),
typeof(WOEquipment.aMMachID)
typeof(WOEquipment.aMMachID),
typeof(WOEquipment.ePEquipmentID),
typeof(WOEquipment.inventoryID),
DescriptionField = typeof(WOEquipment.descr)
)]
[PXUIField(DisplayName = Messages.FieldEquipmentID)]
public virtual string EquipmentCD { get; set; }
Expand Down Expand Up @@ -149,6 +152,20 @@ public abstract class sMEquipmentID : PX.Data.BQL.BqlInt.Field<sMEquipmentID> {
public abstract class aMMachID : PX.Data.BQL.BqlString.Field<aMMachID> { }
#endregion

#region EPEquipmentID
[PXDBInt()]
[PXSelector(
typeof(PX.Objects.EP.EPEquipment.equipmentID),
typeof(PX.Objects.EP.EPEquipment.equipmentCD),
typeof(PX.Objects.EP.EPEquipment.description),
SubstituteKey = typeof(PX.Objects.EP.EPEquipment.equipmentCD),
DescriptionField = typeof(PX.Objects.EP.EPEquipment.description)
)]
[PXUIField(DisplayName = Messages.FieldEPEquipmentID)]
public virtual int? EPEquipmentID { get; set; }
public abstract class ePEquipmentID : PX.Data.BQL.BqlInt.Field<ePEquipmentID> { }
#endregion

#region CreatedByID
[PXDBCreatedByID()]
public virtual Guid? CreatedByID { get; set; }
Expand Down
3 changes: 2 additions & 1 deletion CMMS/DAC/DBBacked/WOLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ public abstract class lastFailureLineNbr : PX.Data.BQL.BqlInt.Field<lastFailureL
typeof(WOEquipment.equipmentID),
typeof(WOEquipment.equipmentCD),
typeof(WOEquipment.descr),
typeof(WOEquipment.inventoryID),
typeof(WOEquipment.sMEquipmentID),
typeof(WOEquipment.aMMachID),
typeof(WOEquipment.ePEquipmentID),
typeof(WOEquipment.inventoryID),
SubstituteKey = typeof(WOEquipment.equipmentCD),
DescriptionField = typeof(WOEquipment.descr)
)]
Expand Down
4 changes: 4 additions & 0 deletions CMMS/DAC/DBBacked/WOLineTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public abstract class lineNbr : PX.Data.BQL.BqlInt.Field<lineNbr> { }
typeof(Search<WOEquipment.equipmentID, Where<WOEquipment.equipmentType, Equal<EquipmentTypes.tool>>>),
typeof(WOEquipment.equipmentCD),
typeof(WOEquipment.descr),
typeof(WOEquipment.sMEquipmentID),
typeof(WOEquipment.aMMachID),
typeof(WOEquipment.ePEquipmentID),
typeof(WOEquipment.inventoryID),
SubstituteKey = typeof(WOEquipment.equipmentCD),
DescriptionField = typeof(WOEquipment.descr)
)]
Expand Down
7 changes: 5 additions & 2 deletions CMMS/DAC/DBBacked/WOOrder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ public abstract class workOrderID : PX.Data.BQL.BqlInt.Field<workOrderID> { }
typeof(Search<WOOrder.workOrderCD, Where<WOOrder.workOrderType, Equal<workOrderType.FromCurrent>>>),
typeof(WOOrder.workOrderCD),
typeof(WOOrder.descr),
typeof(WOOrder.createdDateTime)
typeof(WOOrder.requestDate),
typeof(WOOrder.scheduleDate),
DescriptionField = typeof(WOOrder.descr)
)]
[PXUIField(DisplayName = Messages.FieldWorkOrderID)]
public virtual string WorkOrderCD { get; set; }
Expand Down Expand Up @@ -168,9 +170,10 @@ public abstract class lastLineNbr : PX.Data.BQL.BqlInt.Field<lastLineNbr> { }
typeof(WOEquipment.equipmentID),
typeof(WOEquipment.equipmentCD),
typeof(WOEquipment.descr),
typeof(WOEquipment.inventoryID),
typeof(WOEquipment.sMEquipmentID),
typeof(WOEquipment.aMMachID),
typeof(WOEquipment.ePEquipmentID),
typeof(WOEquipment.inventoryID),
SubstituteKey = typeof(WOEquipment.equipmentCD),
DescriptionField = typeof(WOEquipment.descr)
)]
Expand Down
7 changes: 6 additions & 1 deletion CMMS/DAC/DBBacked/WOSchedule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ public abstract class lastWODate : PX.Data.BQL.BqlDateTime.Field<lastWODate> { }

#region NextWODate
[PXDBDate()]
[PXUIField(DisplayName = Messages.FieldNextWODate)]
[PXUIField(DisplayName = Messages.FieldNextWODate, Enabled = false)]
[PXFormula(typeof(Switch<
Case<Where<lastWODate, IsNotNull, And<frequencyDays, IsNotNull, And<Where<leadTimeDays, IsNull, Or<leadTimeDays, IsNotNull>>>>>,
Sub<Add<lastWODate, frequencyDays>, leadTimeDays>>,
Current<AccessInfo.businessDate>
>))]
public virtual DateTime? NextWODate { get; set; }
public abstract class nextWODate : PX.Data.BQL.BqlDateTime.Field<nextWODate> { }
#endregion
Expand Down
34 changes: 33 additions & 1 deletion CMMS/Graph/Entry/WOOrderEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,26 @@ public abstract class scheduleDate : PX.Data.BQL.BqlDateTime.Field<scheduleDate>
#region Complete Action
public PXAction<WOOrder> complete;
[PXButton(CommitChanges = true), PXUIField(DisplayName = "Complete", MapEnableRights = PXCacheRights.Select, Visible = true)]
protected virtual IEnumerable Complete(PXAdapter adapter) => adapter.Get<WOOrder>();
protected virtual IEnumerable Complete(PXAdapter adapter)
{
WOOrder order = Document.Current;

if(order.TemplateID != null)
{
WOEquipmentMaint graph = PXGraph.CreateInstance<WOEquipmentMaint>();
graph.Equipment.Current = graph.Equipment.Search<WOEquipment.equipmentID>(order.EquipmentID);
graph.Schedules.Current = graph.Schedules.Search<WOSchedule.equipmentID, WOSchedule.workOrderID>(order.EquipmentID, order.TemplateID);
WOSchedule schedule = graph.Schedules.Current;
if (schedule != null)
{
schedule.LastWODate = Accessinfo.BusinessDate;
graph.Schedules.Update(schedule);
graph.Save.Press();
}
}

return adapter.Get<WOOrder>();
}
#endregion

#region RowUp
Expand Down Expand Up @@ -251,6 +270,7 @@ protected IEnumerable RowDown(PXAdapter adapter)
#endregion

#region Events
#region WOLine_OrderNbr_FieldDefaulting
protected virtual void __(Events.FieldDefaulting<WOLine.orderNbr> e)
{
if (e.Row is WOLine row)
Expand All @@ -265,6 +285,18 @@ protected virtual void __(Events.FieldDefaulting<WOLine.orderNbr> e)
e.NewValue = ++highCount;
}
}
#endregion

#region WOOrder_RowSelected
protected virtual void _(Events.RowSelected<WOOrder> e)
{
WOOrder row = e.Row;
if(row != null)
{
PXUIFieldAttribute.SetEnabled<WOOrder.scheduleDate>(e.Cache, row, false);
}
}
#endregion

#endregion

Expand Down
75 changes: 38 additions & 37 deletions CMMS/Graph/Entry/Workflow/WOOrderEntry_ApprovalWorkflow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ protected virtual void Configure(WorkflowContext<WOOrderEntry, WOOrder> context)
{
states
.Add<State.pendingApproval>(flowState => flowState
//.PlaceBefore(State.PendingSchedule)
.WithActions(actions =>
{
actions.Add(g => g.putOnHold);
Expand Down Expand Up @@ -186,25 +187,25 @@ protected virtual void Configure(WorkflowContext<WOOrderEntry, WOOrder> context)
fields.AddAllFields<WOLineFailure>(c => c.IsDisabled());
fields.AddAllFields<CSAnswers>(c => c.IsDisabled());
}));
states
.Add<State.approved>(flowState => flowState
.WithActions(actions =>
{
actions.Add(g => g.putOnHold);
actions.Add(g => g.complete, c => c.IsDuplicatedInToolbar());
})
.WithFieldStates(fields =>
{
fields.AddAllFields<WOOrder>(c => c.IsDisabled());
fields.AddField<workOrderCD>();
fields.AddAllFields<WOLine>(c => c.IsDisabled());
fields.AddAllFields<WOLineItem>(c => c.IsDisabled());
fields.AddAllFields<WOLineLabor>(c => c.IsDisabled());
fields.AddAllFields<WOLineTool>(c => c.IsDisabled());
fields.AddAllFields<WOLineMeasure>(c => c.IsDisabled());
fields.AddAllFields<WOLineFailure>(c => c.IsDisabled());
fields.AddAllFields<CSAnswers>(c => c.IsDisabled());
}));
//states
// .Add<State.approved>(flowState => flowState
// .WithActions(actions =>
// {
// actions.Add(g => g.putOnHold);
// actions.Add(g => g.complete, c => c.IsDuplicatedInToolbar());
// })
// .WithFieldStates(fields =>
// {
// fields.AddAllFields<WOOrder>(c => c.IsDisabled());
// fields.AddField<workOrderCD>();
// fields.AddAllFields<WOLine>(c => c.IsDisabled());
// fields.AddAllFields<WOLineItem>(c => c.IsDisabled());
// fields.AddAllFields<WOLineLabor>(c => c.IsDisabled());
// fields.AddAllFields<WOLineTool>(c => c.IsDisabled());
// fields.AddAllFields<WOLineMeasure>(c => c.IsDisabled());
// fields.AddAllFields<WOLineFailure>(c => c.IsDisabled());
// fields.AddAllFields<CSAnswers>(c => c.IsDisabled());
// }));
})
.WithTransitions(transitions =>
{
Expand All @@ -216,16 +217,16 @@ protected virtual void Configure(WorkflowContext<WOOrderEntry, WOOrder> context)
.IsTriggeredOn(g => g.initializeState)
.When(conditions.IsRejected)
.PlaceAfter(tr => tr.To<State.hold>()));
ts.Add(t => t
.To<State.approved>()
.IsTriggeredOn(g => g.initializeState)
.When(conditions.IsApproved)
.PlaceAfter(tr => tr.To<State.rejected>()));
//ts.Add(t => t
// .To<State.pendingSchedule>()
// .IsTriggeredOn(g => g.initializeState)
// .When(conditions.IsApproved)
// .PlaceAfter(tr => tr.To<State.rejected>()));
ts.Add(t => t
.To<State.pendingApproval>()
.IsTriggeredOn(g => g.initializeState)
.When(!conditions.IsApproved)
.PlaceAfter(tr => tr.To<State.approved>()));
.PlaceAfter(tr => tr.To<State.rejected>()));
});

transitions.UpdateGroupFrom<State.hold>(ts =>
Expand Down Expand Up @@ -275,18 +276,18 @@ protected virtual void Configure(WorkflowContext<WOOrderEntry, WOOrder> context)
);
});

transitions
.AddGroupFrom<State.approved>(ts =>
{
ts.Add(t => t
.To<State.hold>()
.IsTriggeredOn(g => g.putOnHold)
.When(conditions.IsOnHold)
);
ts.Add(t => t
.To<State.complete>()
.IsTriggeredOn(g => g.complete));
});
//transitions
// .AddGroupFrom<State.approved>(ts =>
// {
// ts.Add(t => t
// .To<State.hold>()
// .IsTriggeredOn(g => g.putOnHold)
// .When(conditions.IsOnHold)
// );
// ts.Add(t => t
// .To<State.complete>()
// .IsTriggeredOn(g => g.complete));
// });
})
);

Expand Down
Loading