This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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>();
|
||||
|
||||
@@ -40,6 +40,7 @@ namespace Sockeye.Models
|
||||
public string Phone3 { get; set; }
|
||||
public string Phone4 { get; set; }
|
||||
public string Phone5 { get; set; }
|
||||
[Required]
|
||||
public string EmailAddress { get; set; }
|
||||
|
||||
//POSTAL ADDRESS
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace Sockeye.Models
|
||||
public long Id { get; set; }
|
||||
public uint Concurrency { get; set; }
|
||||
public long? CustomerId { get; set; }
|
||||
public string RegTo { get; set; }
|
||||
public long? LicenseId { get; set; }//when null and also when pgroup is a licenseable type means it shoudl be processed by SockBotProcessPurchases license gen
|
||||
[NotMapped]
|
||||
public string CustomerViz { get; set; }
|
||||
|
||||
@@ -899,7 +899,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
|
||||
await ExecQueryAsync("CREATE TABLE avendornotification (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, created TIMESTAMPTZ NOT NULL, vendorid BIGINT NOT NULL REFERENCES avendor(id), "
|
||||
+ "vendordata TEXT, processed TIMESTAMPTZ, tags VARCHAR(255) ARRAY )");
|
||||
|
||||
await ExecQueryAsync("CREATE TABLE apurchase (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, customerid BIGINT REFERENCES acustomer(id) ON DELETE CASCADE, "
|
||||
await ExecQueryAsync("CREATE TABLE apurchase (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, customerid BIGINT REFERENCES acustomer(id) ON DELETE CASCADE, regto TEXT NOT NULL, "
|
||||
+ "vendorid BIGINT NOT NULL REFERENCES avendor(id), productid BIGINT REFERENCES aproduct(id), pgroup INTEGER NOT NULL DEFAULT 4, salesordernumber TEXT NOT NULL, "
|
||||
+ "productnet DECIMAL(38,18) NOT NULL default 0, discount DECIMAL(38,18) NOT NULL default 0, vendorfee DECIMAL(38,18) NOT NULL default 0, revenue DECIMAL(38,18) NOT NULL default 0, "
|
||||
+ "currency TEXT, purchasedate TIMESTAMPTZ NOT NULL, expiredate TIMESTAMPTZ, canceldate TIMESTAMPTZ, couponcode text, notes text, "
|
||||
|
||||
Reference in New Issue
Block a user