144 lines
5.7 KiB
C#
144 lines
5.7 KiB
C#
using System.Collections.Generic;
|
|
using Newtonsoft.Json.Linq;
|
|
using AyaNova.Models;
|
|
using AyaNova.Biz;
|
|
namespace AyaNova.DataList
|
|
{
|
|
internal class PartInventoryDataList : AyaDataList
|
|
{
|
|
public PartInventoryDataList()
|
|
{
|
|
|
|
DefaultListObjectType = AyaType.PartInventory;
|
|
SQLFrom = "from apartinventory "
|
|
+ "left join apart on (apartinventory.apartid=apart.id) "
|
|
+ "left join apartwarehouse on (apartinventory.apartwarehouseid=apartwarehouse.id) ";
|
|
var RoleSet = BizRoles.GetRoleSet(DefaultListObjectType);
|
|
AllowedRoles = RoleSet.ReadFullRecord | RoleSet.Change;
|
|
|
|
/*
|
|
|
|
"PartInventoryList":"Part inventory",
|
|
"PartInventoryTransaction":"Inventory transaction",
|
|
"PartInventoryTransactionDescription":"Description",
|
|
"PartInventoryTransactionEntryDate":"Date",
|
|
"PartInventoryTransactionSource":"Transaction source",
|
|
"PartInventoryTransactionQuantity":"Quantity",
|
|
"PartInventoryBalance":"On hand quantity"
|
|
|
|
await ExecQueryAsync("CREATE TABLE apartinventory (id BIGINT GENERATED ALWAYS AS
|
|
IDENTITY PRIMARY KEY,
|
|
description text null, " +
|
|
"entrydate timestamp not null, lastentrydate timestamp null,
|
|
partid bigint not null references apart,
|
|
partwarehouseid bigint not null references apartwarehouse, " +
|
|
"sourcetype integer not null, sourceid bigint not null, " +
|
|
"quantity decimal(19,4) not null, balance decimal(19,4) not null,
|
|
lastbalance decimal(19,4) null, " +
|
|
*/
|
|
|
|
//######## DEFAULT VIEW WHEN NO VIEW CHOSEN ############
|
|
//Default ListView
|
|
dynamic dlistView = new JArray();
|
|
dynamic cm = null;
|
|
|
|
cm = new JObject();
|
|
cm.fld = "PartInventoryTransactionEntryDate";
|
|
cm.sort = "-";
|
|
dlistView.Add(cm);
|
|
//part
|
|
//warehouse
|
|
|
|
|
|
cm = new JObject();
|
|
cm.fld = "PartInventoryTransactionQuantity";
|
|
dlistView.Add(cm);
|
|
|
|
cm = new JObject();
|
|
cm.fld = "PartInventoryTransactionDescription";
|
|
dlistView.Add(cm);
|
|
|
|
cm = new JObject();
|
|
cm.fld = "PartInventoryTransactionSource";
|
|
dlistView.Add(cm);
|
|
|
|
cm = new JObject();
|
|
cm.fld = "PartInventoryBalance";
|
|
dlistView.Add(cm);
|
|
|
|
DefaultListView = dlistView.ToString(Newtonsoft.Json.Formatting.None);
|
|
|
|
//NOTE: Due to the join, all the sql id and name fields that can conflict with the joined table need to be specified completely
|
|
FieldDefinitions = new List<AyaDataListFieldDefinition>();
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "PartInventoryTransactionSource",
|
|
FieldKey = "PartInventoryTransactionSource",
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlIdColumnName = "apartinventory.sourceid",
|
|
SqlValueColumnName = "AYGETNAME(apartinventory.sourceid, apartinventory.sourcetype)",
|
|
SqlAyTypeColumnName = "apartinventory.sourcetype"
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "PartPartNumber",
|
|
FieldKey = "PartPartNumber",
|
|
AyaObjectType = (int)AyaType.Part,
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlIdColumnName = "apart.id",
|
|
SqlValueColumnName = "apart.partnumber"
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "PartWarehouseName",
|
|
FieldKey = "PartWarehouseName",
|
|
AyaObjectType = (int)AyaType.PartWarehouse,
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlIdColumnName = "apartwarehouse.id",
|
|
SqlValueColumnName = "apartwarehouse.name"
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "PartInventoryTransactionDescription",
|
|
FieldKey = "PartInventoryTransactionDescription",
|
|
AyaObjectType = (int)AyaType.PartInventory,
|
|
UiFieldDataType = (int)UiFieldDataType.Text,
|
|
SqlIdColumnName = "apartinventory.id",
|
|
SqlValueColumnName = "apartinventory.description",
|
|
IsRowId = true//should open to eventlog since no edit
|
|
});
|
|
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "PartInventoryTransactionEntryDate",
|
|
FieldKey = "PartInventoryTransactionEntryDate",
|
|
UiFieldDataType = (int)UiFieldDataType.DateTime,
|
|
SqlValueColumnName = "apartinventory.entrydate"
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "PartInventoryTransactionQuantity",
|
|
FieldKey = "PartInventoryTransactionQuantity",
|
|
UiFieldDataType = (int)UiFieldDataType.Decimal,
|
|
SqlValueColumnName = "apartinventory.quantity"
|
|
});
|
|
|
|
FieldDefinitions.Add(new AyaDataListFieldDefinition
|
|
{
|
|
TKey = "PartInventoryBalance",
|
|
FieldKey = "PartInventoryBalance",
|
|
UiFieldDataType = (int)UiFieldDataType.Decimal,
|
|
SqlValueColumnName = "apartinventory.balance"
|
|
});
|
|
|
|
}
|
|
|
|
|
|
}//eoc
|
|
}//eons |