diff --git a/server/generator/SockBotProcessPurchasesIntoLicenses.cs b/server/generator/SockBotProcessPurchasesIntoLicenses.cs index 4d15e5c..38a2552 100644 --- a/server/generator/SockBotProcessPurchasesIntoLicenses.cs +++ b/server/generator/SockBotProcessPurchasesIntoLicenses.cs @@ -13,8 +13,10 @@ namespace Sockeye.Biz /// - /// Process purchases into licenses - /// + /// Process purchases into licenses + /// ############## 2023-02-09 THIS IS ON HOLD FOR NOW - unlikely to work immediately due to all manual fuckery involved instead will find ways to speed up manual processing ################ + /// too much other stuff on the go right now and time required to spend processing purchases is a good problem to have can spend more time on it later + /// I'll comment out the job so it's not called and keep the vendor notification processing for now, look at client end improvements (duplicate alone will help) /// internal static class SockBotProcessPurchasesIntoLicenses { @@ -119,8 +121,8 @@ namespace Sockeye.Biz License newLicense = new License(); //Get last license if any, set up some basic stuff common to all license types var firstPurchase = purchaseGroup.First(); - var lastLicense = await ct.License.AsNoTracking().OrderByDescending(z => z.Id).FirstOrDefaultAsync(z => z.CustomerId == firstPurchase.CustomerId && z.PGroup == firstPurchase.PGroup); - + License lastLicense=null; + newLicense.CustomerId = firstPurchase.CustomerId; newLicense.Active = false; newLicense.RegTo = firstPurchase.RegTo; @@ -129,6 +131,8 @@ namespace Sockeye.Biz //if there is one and it's not entirely expired then duplicate and fixup from purchases in this group if (isV7) { + lastLicense = await ct.License.AsNoTracking().OrderByDescending(z => z.Id).FirstOrDefaultAsync(z => z.CustomerId == firstPurchase.CustomerId && z.PGroup == firstPurchase.PGroup); + newLicense.FetchEmail = purchaseGroupCustomer.EmailAddress; newLicense.PGroup = ProductGroup.AyaNova7; @@ -294,18 +298,10 @@ namespace Sockeye.Biz { //it's a RAVEN license + //get last license for this dbid, if active then take all it's value and update it with this -/* -Check if new or renewal: -if it's a renewal it will have several "original_XXXX" fields (they won't exist on first purcahse): - "subscription": { - "expiration_date": "2023-03-07T00:15:13.0000000Z", - "id": "833674953-1", - "interval": "Monthly without end", - "original_notification_no": "7925", - "original_purchase_id": "833674953", - "original_running_no": "1", -*/ + lastLicense = await ct.License.AsNoTracking().OrderByDescending(z => z.Id).FirstOrDefaultAsync(z => z.CustomerId == firstPurchase.CustomerId && z.PGroup == firstPurchase.PGroup); + //If renewal and there is no last license then it's a problem -> THROW EXCEPTION