166 lines
8.3 KiB
C#
166 lines
8.3 KiB
C#
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<string>() { "PurchaseDate", "PurchaseSalesOrderNumber", "Customer", "Product" };
|
|
DefaultSortBy = new Dictionary<string, string>() { { "PurchaseDate", "-" } };
|
|
FieldDefinitions = new List<DataListFieldDefinition>();
|
|
/*
|
|
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 |