|
@@ -12,60 +12,12 @@ namespace Comal.Classes
|
|
|
{
|
|
|
public enum JobRequisitionItemStatus
|
|
|
{
|
|
|
- NotChecked, // Default
|
|
|
- /// <summary>
|
|
|
- /// All required stock has been received, and is in the correct <see cref="ProductStyle"/>.<br/>
|
|
|
- /// <code>Allocated + Issued >= Qty</code>
|
|
|
- /// </summary>
|
|
|
- /// <remarks>
|
|
|
- /// This can be set even if there are unreceived <see cref="JobRequisitionItemPurchaseOrderItem"/>,
|
|
|
- /// since if we got the stock some other way, we still think of it as allocated.
|
|
|
- /// </remarks>
|
|
|
+ Stock,
|
|
|
+ Treatment,
|
|
|
Allocated,
|
|
|
- /// <summary>
|
|
|
- /// All required stock has been received, but some is not in the correct <see cref="ProductStyle"/>, meaning a treatment is required.
|
|
|
- /// <code>InStock + Issued >= Qty</code>
|
|
|
- /// </summary>
|
|
|
- /// <remarks>
|
|
|
- /// This can be set even if there are unreceived <see cref="JobRequisitionItemPurchaseOrderItem"/>,
|
|
|
- /// since if we got the stock some other way, we still think of it as having the stock allocated.
|
|
|
- /// </remarks>
|
|
|
- TreatmentRequired,
|
|
|
- /// <summary>
|
|
|
- /// The <see cref="JobRequisitionItem.OrderRequired"/> has been set, but there are no <see cref="JobRequisitionItemPurchaseOrderItem"/>s for
|
|
|
- /// this <see cref="JobRequisitionItem"/>.
|
|
|
- /// </summary>
|
|
|
- OrderRequired,
|
|
|
- /// <summary>
|
|
|
- /// We don't yet have all the stock, and there is at least one unreceived <see cref="JobRequisitionItemPurchaseOrderItem"/> of type
|
|
|
- /// <see cref="JobRequisitionItemPurchaseOrderItemType.Stock"/>.
|
|
|
- /// </summary>
|
|
|
- OnOrder,
|
|
|
- /// <summary>
|
|
|
- /// We don't yet have all the stock, and there is at least one unreceived <see cref="JobRequisitionItemPurchaseOrderItem"/> of type
|
|
|
- /// <see cref="JobRequisitionItemPurchaseOrderItemType.Treatment"/> and none of type <see cref="JobRequisitionItemPurchaseOrderItemType.Stock"/>.
|
|
|
- /// </summary>
|
|
|
- TreatmentOnOrder,
|
|
|
-
|
|
|
- [Obsolete]
|
|
|
- Received,// Drop
|
|
|
- [Obsolete]
|
|
|
- TreatmentReceived,// Drop
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// The <see cref="JobRequisitionItem"/> has been cancelled, meaning it has a non-empty <see cref="JobRequisitionItem.Cancelled"/>.
|
|
|
- /// </summary>
|
|
|
+ Issued,
|
|
|
Cancelled,
|
|
|
- /// <summary>
|
|
|
- /// The <see cref="JobRequisitionItem/"> has been archived, meaning it has a non-empty <see cref="JobRequisitionItem.Archived"/>.
|
|
|
- /// <code>Issued >= Qty</code>
|
|
|
- /// </summary>
|
|
|
- Archived,
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// The <see cref="JobRequisitionItem/"> has been issued, meaning that it has been allocated, and there are stock movements of type <see cref="StockMovementType.Issue"/> adding up to the correct total.
|
|
|
- /// </summary>
|
|
|
- Issued
|
|
|
+ Archived
|
|
|
}
|
|
|
|
|
|
public interface IJobRequisitionItem : IEntity
|
|
@@ -131,14 +83,70 @@ namespace Comal.Classes
|
|
|
|
|
|
[EditorSequence(8)]
|
|
|
public SupplierLink Supplier { get; set; }
|
|
|
-
|
|
|
-
|
|
|
- [NullEditor]
|
|
|
- [EditorSequence(9)]
|
|
|
- [LoggableProperty]
|
|
|
- [RequiredColumn]
|
|
|
- [Obsolete("", true)]
|
|
|
- public JobRequisitionItemStatus Status { get; set; } = JobRequisitionItemStatus.NotChecked;
|
|
|
+
|
|
|
+
|
|
|
+ private class StatusFormula : ComplexFormulaGenerator<JobRequisitionItem, JobRequisitionItemStatus>
|
|
|
+ {
|
|
|
+
|
|
|
+ public override IComplexFormulaNode<JobRequisitionItem, JobRequisitionItemStatus> GetFormula() =>
|
|
|
+
|
|
|
+ If<JobRequisitionItem, DateTime, JobRequisitionItemStatus>(
|
|
|
+ Property<JobRequisitionItem,DateTime>(x => x.Cancelled),
|
|
|
+ Condition.NotEqual,
|
|
|
+ Constant<JobRequisitionItem,DateTime>(DateTime.MinValue),
|
|
|
+ DateTime.MinValue
|
|
|
+ ).Then(
|
|
|
+ Constant(JobRequisitionItemStatus.Cancelled)
|
|
|
+ ).Else(
|
|
|
+ If<JobRequisitionItem, DateTime, JobRequisitionItemStatus>(
|
|
|
+ Property<JobRequisitionItem,DateTime>(x => x.Archived),
|
|
|
+ Condition.NotEqual,
|
|
|
+ Constant<JobRequisitionItem,DateTime>(DateTime.MinValue),
|
|
|
+ DateTime.MinValue
|
|
|
+ ).Then(
|
|
|
+ Constant(JobRequisitionItemStatus.Archived)
|
|
|
+ ).Else(
|
|
|
+ If<JobRequisitionItem, double, JobRequisitionItemStatus>(
|
|
|
+ Property<JobRequisitionItem,double>(x => x.Issued),
|
|
|
+ Condition.GreaterThanOrEqualTo,
|
|
|
+ Property<JobRequisitionItem,double>(x => x.Qty)
|
|
|
+ ).Then(
|
|
|
+ Constant(JobRequisitionItemStatus.Issued)
|
|
|
+ ).Else(
|
|
|
+ If<JobRequisitionItem, double, JobRequisitionItemStatus>(
|
|
|
+ Formula(
|
|
|
+ FormulaOperator.Add,
|
|
|
+ Property<JobRequisitionItem,double>(x => x.Issued),
|
|
|
+ Property<JobRequisitionItem,double>(x => x.Allocated)
|
|
|
+ ),
|
|
|
+ Condition.GreaterThanOrEqualTo,
|
|
|
+ Property<JobRequisitionItem,double>(x => x.Qty)
|
|
|
+ ).Then(
|
|
|
+ Constant(JobRequisitionItemStatus.Allocated)
|
|
|
+ ).Else(
|
|
|
+ If<JobRequisitionItem, double, JobRequisitionItemStatus>(
|
|
|
+ Formula(
|
|
|
+ FormulaOperator.Add,
|
|
|
+ Property<JobRequisitionItem,double>(x => x.InStock),
|
|
|
+ Property<JobRequisitionItem,double>(x => x.Issued)
|
|
|
+ ),
|
|
|
+ Condition.GreaterThanOrEqualTo,
|
|
|
+ Property<JobRequisitionItem,double>(x => x.Qty)
|
|
|
+ ).Then(
|
|
|
+ Constant(JobRequisitionItemStatus.Treatment)
|
|
|
+ ).Else(
|
|
|
+ Constant(JobRequisitionItemStatus.Stock)
|
|
|
+ )
|
|
|
+ )
|
|
|
+ )
|
|
|
+ )
|
|
|
+ );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ [ComplexFormula(typeof(StatusFormula))]
|
|
|
+ [EditorSequence(8)]
|
|
|
+ public JobRequisitionItemStatus Status { get; set; }
|
|
|
|
|
|
private class InStockFormula : ComplexFormulaGenerator<JobRequisitionItem, double>
|
|
|
{
|
|
@@ -204,18 +212,18 @@ namespace Comal.Classes
|
|
|
private class GeneralOrderFormula : ComplexFormulaGenerator<JobRequisitionItem, double>
|
|
|
{
|
|
|
public override IComplexFormulaNode<JobRequisitionItem, double> GetFormula() =>
|
|
|
- //Formula(
|
|
|
- // FormulaOperator.Add,
|
|
|
+ Formula(
|
|
|
+ FormulaOperator.Add,
|
|
|
|
|
|
- // Aggregate<PurchaseOrderItem>(
|
|
|
- // AggregateCalculation.Sum,
|
|
|
- // x => x.Property(x => x.Unallocated),
|
|
|
- // new Filter<PurchaseOrderItem>(x => x.ReceivedDate).IsEqualTo(null)
|
|
|
- // .And(x => x.Job.ID).IsEqualTo(Guid.Empty)
|
|
|
- // )
|
|
|
- // .WithLink(x => x.Product.ID, x => x.Product.ID),
|
|
|
+ Aggregate<PurchaseOrderItem>(
|
|
|
+ AggregateCalculation.Sum,
|
|
|
+ x => x.Property(x => x.Unallocated),
|
|
|
+ new Filter<PurchaseOrderItem>(x => x.ReceivedDate).IsEqualTo(null)
|
|
|
+ .And(x => x.Job.ID).IsEqualTo(Guid.Empty)
|
|
|
+ )
|
|
|
+ .WithLink(x => x.Product.ID, x => x.Product.ID),
|
|
|
|
|
|
- If<JobRequisitionItem, string, double>(
|
|
|
+ If<JobRequisitionItem, string, double>(
|
|
|
Property<JobRequisitionItem, string>(x => x.Dimensions.Unit.Conversion),
|
|
|
Condition.Equals,
|
|
|
Constant<JobRequisitionItem, string>(""),
|
|
@@ -244,9 +252,9 @@ namespace Comal.Classes
|
|
|
).WithLink(x => x.Item.Product.ID, x => x.Product.ID),
|
|
|
Property(x => x.Dimensions.Value)
|
|
|
)
|
|
|
- );
|
|
|
+ )
|
|
|
|
|
|
- //);
|
|
|
+ );
|
|
|
}
|
|
|
[ComplexFormula(typeof(GeneralOrderFormula))]
|
|
|
[DoubleEditor(Editable = Editable.Hidden)]
|