R2 - zero values for future months
This commit is contained in:
@@ -78,7 +78,11 @@ public class T4R2Processor
|
|||||||
sourceCodes = ProcessHelper.ParseCodes(rawSourceCodes);
|
sourceCodes = ProcessHelper.ParseCodes(rawSourceCodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var month = 1; month <= DateTime.UtcNow.Month; month++)
|
List<string> lastSourceCodes = new List<string>();
|
||||||
|
|
||||||
|
for (var month = 1; month <= 12; month++)
|
||||||
|
{
|
||||||
|
if (month <= DateTime.UtcNow.Month)
|
||||||
{
|
{
|
||||||
var monthCopy = month;
|
var monthCopy = month;
|
||||||
var dataSource = _db.Layers.Where(x =>
|
var dataSource = _db.Layers.Where(x =>
|
||||||
@@ -90,6 +94,7 @@ public class T4R2Processor
|
|||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
if (dataSource != null)
|
if (dataSource != null)
|
||||||
{
|
{
|
||||||
|
lastSourceCodes = dataSource.Records!.Select(x => x.Code!).ToList();
|
||||||
var news = dataSource.Records!
|
var news = dataSource.Records!
|
||||||
.Where(x => sourceCodes.Count <= 0 || sourceCodes.Contains(int.Parse(x.Code!)))
|
.Where(x => sourceCodes.Count <= 0 || sourceCodes.Contains(int.Parse(x.Code!)))
|
||||||
.Select(x =>
|
.Select(x =>
|
||||||
@@ -120,8 +125,30 @@ public class T4R2Processor
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//0 values for future months
|
||||||
|
if (source.Desc1 == "FK2" || lastSourceCodes.Count <= 0) continue;
|
||||||
|
var news = lastSourceCodes
|
||||||
|
.Where(x => sourceCodes.Contains(int.Parse(x)))
|
||||||
|
.Select(x =>
|
||||||
|
{
|
||||||
|
var newRecord = new Record
|
||||||
|
{
|
||||||
|
Id = Guid.NewGuid(),
|
||||||
|
Code = x + month.ToString("D2"),
|
||||||
|
CreatedAt = DateTime.UtcNow,
|
||||||
|
ModifiedAt = DateTime.UtcNow,
|
||||||
|
Value1 = 0,
|
||||||
|
};
|
||||||
|
return newRecord;
|
||||||
|
}
|
||||||
|
).ToList();
|
||||||
|
newRecords.AddRange(news);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// year summery
|
// year summary
|
||||||
var dataSourceSum = _db.Layers.Where(x =>
|
var dataSourceSum = _db.Layers.Where(x =>
|
||||||
x.Type == LayerType.Processed &&
|
x.Type == LayerType.Processed &&
|
||||||
!x.IsDeleted &&
|
!x.IsDeleted &&
|
||||||
|
|||||||
Reference in New Issue
Block a user