|
@@ -22,9 +22,15 @@ public class StockMovementStore : BaseStore<StockMovement>
|
|
|
|
|
|
if(sm.Job.HasOriginalValue(x => x.ID) && sm.Job.ID != Guid.Empty && sm.JobScope.ID == Guid.Empty)
|
|
if(sm.Job.HasOriginalValue(x => x.ID) && sm.Job.ID != Guid.Empty && sm.JobScope.ID == Guid.Empty)
|
|
{
|
|
{
|
|
|
|
+ // If we have updated the Job.ID to a non-empty value, we should
|
|
|
|
+ // update the JobScope to the default job scope for that job.
|
|
|
|
+
|
|
var scopeID = Guid.Empty;
|
|
var scopeID = Guid.Empty;
|
|
if(sm.ID != Guid.Empty)
|
|
if(sm.ID != Guid.Empty)
|
|
{
|
|
{
|
|
|
|
+ // It's possible that the JobScope ID just wasn't passed up, if
|
|
|
|
+ // this entity already exists; hence, we shall load the scopeID
|
|
|
|
+ // from the database just in case.
|
|
scopeID = Provider.Query(
|
|
scopeID = Provider.Query(
|
|
new Filter<StockMovement>(x => x.ID).IsEqualTo(sm.ID),
|
|
new Filter<StockMovement>(x => x.ID).IsEqualTo(sm.ID),
|
|
Columns.None<StockMovement>().Add(x => x.JobScope.ID))
|
|
Columns.None<StockMovement>().Add(x => x.JobScope.ID))
|
|
@@ -32,6 +38,8 @@ public class StockMovementStore : BaseStore<StockMovement>
|
|
}
|
|
}
|
|
if(scopeID == Guid.Empty)
|
|
if(scopeID == Guid.Empty)
|
|
{
|
|
{
|
|
|
|
+ // No scope has been assigned; however, we have a job, so we
|
|
|
|
+ // load the default scope for the job.
|
|
sm.JobScope.ID = Provider.Query(
|
|
sm.JobScope.ID = Provider.Query(
|
|
new Filter<Job>(x => x.ID).IsEqualTo(sm.Job.ID),
|
|
new Filter<Job>(x => x.ID).IsEqualTo(sm.Job.ID),
|
|
Columns.None<Job>().Add(x => x.DefaultScope.ID))
|
|
Columns.None<Job>().Add(x => x.DefaultScope.ID))
|
|
@@ -61,12 +69,12 @@ public class StockMovementStore : BaseStore<StockMovement>
|
|
{
|
|
{
|
|
base.BeforeDelete(entity);
|
|
base.BeforeDelete(entity);
|
|
|
|
|
|
- // We need to do this in before delete, because aotherwise we wont have the data
|
|
|
|
- // that we need to pull to properly update the stockholdings
|
|
|
|
|
|
+ // We need to do this in before delete, because otherwise we wont have
|
|
|
|
+ // the data that we need to pull to properly update the stockholdings
|
|
StockHoldingStore.UpdateStockHolding(this, entity.ID,StockHoldingStore.Action.Decrease);
|
|
StockHoldingStore.UpdateStockHolding(this, entity.ID,StockHoldingStore.Action.Decrease);
|
|
|
|
|
|
- // Now let's pull the requisition ID, so that we can clean this up properly
|
|
|
|
- // in AfterDelete()
|
|
|
|
|
|
+ // Now let's pull the requisition ID, so that we can clean this up
|
|
|
|
+ // properly in AfterDelete()
|
|
entity.JobRequisitionItem.ID = Provider.Query(
|
|
entity.JobRequisitionItem.ID = Provider.Query(
|
|
new Filter<StockMovement>(x => x.ID).IsEqualTo(entity.ID),
|
|
new Filter<StockMovement>(x => x.ID).IsEqualTo(entity.ID),
|
|
Columns.None<StockMovement>().Add(x => x.JobRequisitionItem.ID)
|
|
Columns.None<StockMovement>().Add(x => x.JobRequisitionItem.ID)
|