This commit is contained in:
2023-02-06 20:05:24 +00:00
parent 9e946cc8a3
commit 347b202f91
5 changed files with 58 additions and 3 deletions

View File

@@ -49,7 +49,7 @@ namespace Sockeye.Biz
{
//get a list of all actionable purchases grouped by customer id
var purchaseList = (await ct.Purchase
var purchaseList = (await ct.Purchase.AsNoTracking()
.Where(z => z.Processed == false
&& z.LicenseId == null
&& z.CustomerId != null
@@ -66,6 +66,7 @@ namespace Sockeye.Biz
bool isRavenSubscription = false;
bool isV7 = false;
bool isLessThanV7Age = false;
var purchaseGroupCustomer = await ct.Customer.AsNoTracking().FirstAsync(z => z.Id == purchaseGroup.First().CustomerId);
foreach (var purchase in purchaseGroup)
{
@@ -117,10 +118,61 @@ namespace Sockeye.Biz
//if v7 license then lookup last license for same pgroup for same customer, if none then consider it a new license fresh
//if there is one and it's not entirely expired then duplicate and fixup from purchases in this group
if (isV7)
{
//IF raven license and have what is likely a recognizable dbid that ends in an = symbol then just make the new license and cancel the last one if that's necessary
//get one representative product in the group, first is fine
var firstPurchase = purchaseGroup.First();
var lastLicense = await ct.License.AsNoTracking().OrderByDescending(z => z.Id).FirstOrDefaultAsync(z => z.CustomerId == firstPurchase.CustomerId && z.PGroup == firstPurchase.PGroup);
var newLicense = new License();
newLicense.CustomerId = firstPurchase.CustomerId;
newLicense.Active = false;
newLicense.RegTo = firstPurchase.RegTo;
newLicense.FetchEmail = purchaseGroupCustomer.EmailAddress;
//is there a prior license?
if (lastLicense != null)
{
//copy all the values to the new license
newLicense.ExportToXLS = lastLicense.ExportToXLS;
newLicense.ExportToXLSExpires = lastLicense.ExportToXLSExpires;
newLicense.ImportExportCSVDuplicate=lastLicense.ImportExportCSVDuplicate;
newLicense.ImportExportCSVDuplicateExpires=lastLicense.ImportExportCSVDuplicateExpires;
newLicense.MaintenanceExpire=lastLicense.MaintenanceExpire;
newLicense.MBI=lastLicense.MBI;
newLicense.MBIExpires=lastLicense.MBIExpires;
newLicense.OLI=lastLicense.OLI;
newLicense.OLIExpires=lastLicense.OLIExpires;
newLicense.OutlookSchedule=lastLicense.OutlookSchedule;
newLicense.OutlookScheduleExpires=lastLicense.OutlookScheduleExpires;
newLicense.PTI=lastLicense.PTI;
newLicense.PTIExpires=lastLicense.PTIExpires;
newLicense.QBI=lastLicense.QBI;
newLicense.QBIExpires=lastLicense.QBIExpires;
newLicense.QBOI=lastLicense.QBOI;
newLicense.QBOIExpires=lastLicense.QBOIExpires;
newLicense.QuickNotification=lastLicense.QuickNotification;
newLicense.QuickNotificationExpires=lastLicense.QuickNotificationExpires;
newLicense.Renewal=true;
newLicense.RI=lastLicense.RI;
newLicense.RIExpires=lastLicense.RIExpires;
newLicense.Tags=lastLicense.Tags;
newLicense.Users=lastLicense.Users;
newLicense.WBI=lastLicense.WBI;
newLicense.WBIExpires=lastLicense.WBIExpires;
newLicense.Wiki=lastLicense.Wiki;
}
foreach (var purchase in purchaseGroup)
{
}
}
//IF raven license and have what is likely a recognizable dbid that ends in an = symbol then just make the new license and cancel the last one if that's necessary (NARRATOR: it wasn't, raven only ever fetches the newest)

View File

@@ -218,6 +218,7 @@ namespace Sockeye.Biz
Purchase p = new Purchase();
p.PurchaseDate = purchaseDate;
p.CustomerId = customer.Id;
p.RegTo = jCustomerName;
p.VendorId = vn.VendorId;
p.SalesOrderNumber = salesOrderNumber;
var SalesItemProductVendorCode = jPurchase["product_id"].Value<string>();