diff --git a/server/DataList/PurchaseDataList.cs b/server/DataList/PurchaseDataList.cs new file mode 100644 index 0000000..fe1bd3d --- /dev/null +++ b/server/DataList/PurchaseDataList.cs @@ -0,0 +1,166 @@ +using System.Collections.Generic; +using System.Linq; +using Sockeye.Biz; +using Sockeye.Models; + +namespace Sockeye.DataList +{ + internal class PurchaseDataList : DataListProcessingBase + { + public PurchaseDataList(long translationId) + { + DefaultListAType = SockType.Purchase; + SQLFrom = @"FROM apurchase LEFT JOIN aproduct on (apurchase.productid = aproduct.id) LEFT JOIN avendor ON (apurchase.vendorid = avendor.id) LEFT JOIN acustomer ON (apurchase.customerid = acustomer.id)"; + + var RoleSet = BizRoles.GetRoleSet(DefaultListAType); + AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change; + DefaultColumns = new List() { "PurchaseDate", "PurchaseSalesOrderNumber", "Customer", "Product" }; + DefaultSortBy = new Dictionary() { { "PurchaseDate", "-" } }; + FieldDefinitions = new List(); + /* +await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'Purchase', 'Purchase' FROM atranslation t where t.baselanguage = 'en'"); +await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'PurchaseList', 'Purchases' FROM atranslation t where t.baselanguage = 'en'"); +await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'PurchaseSalesOrderNumber', 'Sales order #' FROM atranslation t where t.baselanguage = 'en'"); +await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'PurchaseDate', 'Date' FROM atranslation t where t.baselanguage = 'en'"); +await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'PurchaseExpireDate', 'Expires' FROM atranslation t where t.baselanguage = 'en'"); +await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'PurchaseCancelDate', 'Cancelled' FROM atranslation t where t.baselanguage = 'en'"); +await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'PurchaseCouponCode', 'Coupon' FROM atranslation t where t.baselanguage = 'en'"); +await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'PurchaseNotes', 'Notes' FROM atranslation t where t.baselanguage = 'en'"); +await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'PurchaseRenewNoticeSent', 'Renew notice sent' FROM atranslation t where t.baselanguage = 'en'"); +await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'PurchaseQuantity', 'Quantity' FROM atranslation t where t.baselanguage = 'en'"); +await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'PurchaseVendorData', 'Vendor data' FROM atranslation t where t.baselanguage = 'en'"); +await ExecQueryAsync("INSERT INTO atranslationitem(translationid,key,display) SELECT t.id, 'PurchaseProcessedDate', 'Processed' FROM atranslation t where t.baselanguage = 'en'"); +id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, customerid BIGINT NOT NULL REFERENCES acustomer(id) ON DELETE CASCADE, " ++ "vendorid BIGINT NOT NULL REFERENCES avendor(id), productid BIGINT NOT NULL REFERENCES aproduct(id), salesordernumber TEXT, " ++ "purchasedate TIMESTAMPTZ NOT NULL, expiredate TIMESTAMPTZ, canceldate TIMESTAMPTZ, couponcode text, notes text, " ++ "renewnoticesent BOOL NOT NULL DEFAULT false, quantity INTEGER NOT NULL DEFAULT 1, " ++ "vendordata TEXT, processeddate TIMESTAMPTZ, " ++ "wiki TEXT, tags VARCHAR(255) ARRAY +*/ + + FieldDefinitions.Add(new DataListFieldDefinition + { + TKey = "PurchaseSalesOrderNumber", + FieldKey = "PurchaseSalesOrderNumber", + SockType = (int)SockType.Purchase, + UiFieldDataType = (int)UiFieldDataType.Text, + SqlIdColumnName = "apurchase.id", + SqlValueColumnName = "apurchase.salesordernumber", + IsRowId = true + }); + + FieldDefinitions.Add(new DataListFieldDefinition + { + TKey = "Customer", + FieldKey = "Customer", + SockType = (int)SockType.Customer, + UiFieldDataType = (int)UiFieldDataType.Text, + SqlIdColumnName = "apurchase.customerid", + SqlValueColumnName = "acustomer.name" + }); + + FieldDefinitions.Add(new DataListFieldDefinition + { + TKey = "Vendor", + FieldKey = "Vendor", + SockType = (int)SockType.Vendor, + UiFieldDataType = (int)UiFieldDataType.Text, + SqlIdColumnName = "apurchase.vendorid", + SqlValueColumnName = "avendor.name" + }); + + FieldDefinitions.Add(new DataListFieldDefinition + { + TKey = "Product", + FieldKey = "Product", + SockType = (int)SockType.Product, + UiFieldDataType = (int)UiFieldDataType.Text, + SqlIdColumnName = "apurchase.productid", + SqlValueColumnName = "aproduct.name" + }); + + FieldDefinitions.Add(new DataListFieldDefinition + { + TKey = "PurchaseDate", + FieldKey = "PurchaseDate", + UiFieldDataType = (int)UiFieldDataType.DateTime, + SqlValueColumnName = "apurchase.purchasedate" + }); + + FieldDefinitions.Add(new DataListFieldDefinition + { + TKey = "PurchaseExpireDate", + FieldKey = "PurchaseExpireDate", + UiFieldDataType = (int)UiFieldDataType.DateTime, + SqlValueColumnName = "apurchase.expiredate" + }); + + FieldDefinitions.Add(new DataListFieldDefinition + { + TKey = "PurchaseCancelDate", + FieldKey = "PurchaseCancelDate", + UiFieldDataType = (int)UiFieldDataType.DateTime, + SqlValueColumnName = "apurchase.canceldate" + }); + + FieldDefinitions.Add(new DataListFieldDefinition + { + TKey = "PurchaseCouponCode", + FieldKey = "PurchaseCouponCode", + UiFieldDataType = (int)UiFieldDataType.Text, + SqlValueColumnName = "apurchase.couponcode" + }); + + FieldDefinitions.Add(new DataListFieldDefinition + { + TKey = "PurchaseNotes", + FieldKey = "PurchaseNotes", + UiFieldDataType = (int)UiFieldDataType.Text, + SqlValueColumnName = "apurchase.notes" + }); + + FieldDefinitions.Add(new DataListFieldDefinition + { + TKey = "PurchaseRenewNoticeSent", + FieldKey = "PurchaseRenewNoticeSent", + UiFieldDataType = (int)UiFieldDataType.Bool, + SqlValueColumnName = "apurchase.renewnoticesent" + }); + + FieldDefinitions.Add(new DataListFieldDefinition + { + TKey = "PurchaseQuantity", + FieldKey = "PurchaseQuantity", + UiFieldDataType = (int)UiFieldDataType.Integer, + SqlValueColumnName = "apurchase.quantity" + }); + + FieldDefinitions.Add(new DataListFieldDefinition + { + TKey = "PurchaseVendorData", + FieldKey = "PurchaseVendorData", + UiFieldDataType = (int)UiFieldDataType.Text, + SqlValueColumnName = "apurchase.vendordata" + }); + + FieldDefinitions.Add(new DataListFieldDefinition + { + TKey = "PurchaseProcessedDate", + FieldKey = "PurchaseProcessedDate", + UiFieldDataType = (int)UiFieldDataType.DateTime, + SqlValueColumnName = "apurchase.processeddate" + }); + + + FieldDefinitions.Add(new DataListFieldDefinition + { + TKey = "Tags", + FieldKey = "purchasetags", + UiFieldDataType = (int)UiFieldDataType.Tags, + SqlValueColumnName = "apurchase.tags" + }); + + } + + }//eoc +}//eons \ No newline at end of file diff --git a/server/biz/PurchaseBiz.cs b/server/biz/PurchaseBiz.cs index 9026272..c7412a0 100644 --- a/server/biz/PurchaseBiz.cs +++ b/server/biz/PurchaseBiz.cs @@ -193,7 +193,7 @@ namespace Sockeye.Biz .AddText(obj.CouponCode) .AddText(obj.Wiki) .AddText(obj.Tags) - .AddText(obj.PurchaseNotes) + .AddText(obj.Notes) .AddText(obj.VendorData); } diff --git a/server/models/Purchase.cs b/server/models/Purchase.cs index 37e2874..d999b91 100644 --- a/server/models/Purchase.cs +++ b/server/models/Purchase.cs @@ -29,7 +29,7 @@ namespace Sockeye.Models public DateTime? ExpireDate { get; set; } public DateTime? CancelDate { get; set; } public string CouponCode { get; set; } - public string PurchaseNotes { get; set; } + public string Notes { get; set; } public bool RenewNoticeSent { get; set; } = false; public int Quantity { get; set; } = 1; public string VendorData { get; set; } diff --git a/server/util/AySchema.cs b/server/util/AySchema.cs index 1189518..6826a4e 100644 --- a/server/util/AySchema.cs +++ b/server/util/AySchema.cs @@ -899,7 +899,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE"); await ExecQueryAsync("CREATE TABLE apurchase (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, customerid BIGINT NOT NULL REFERENCES acustomer(id) ON DELETE CASCADE, " + "vendorid BIGINT NOT NULL REFERENCES avendor(id), productid BIGINT NOT NULL REFERENCES aproduct(id), salesordernumber TEXT, " - + "purchasedate TIMESTAMPTZ NOT NULL, expiredate TIMESTAMPTZ, canceldate TIMESTAMPTZ, couponcode text, purchasenotes text, " + + "purchasedate TIMESTAMPTZ NOT NULL, expiredate TIMESTAMPTZ, canceldate TIMESTAMPTZ, couponcode text, notes text, " + "renewnoticesent BOOL NOT NULL DEFAULT false, quantity INTEGER NOT NULL DEFAULT 1, " + "vendordata TEXT, processeddate TIMESTAMPTZ, " + "wiki TEXT, tags VARCHAR(255) ARRAY )");