This commit is contained in:
2022-07-05 14:01:43 +00:00
parent 2de02d6f34
commit 9a27e4773c
5 changed files with 70 additions and 23 deletions

View File

@@ -128,6 +128,8 @@
<Compile Include="NameIdActiveItem.cs" /> <Compile Include="NameIdActiveItem.cs" />
<Compile Include="NameIdItem.cs" /> <Compile Include="NameIdItem.cs" />
<Compile Include="Part.cs" /> <Compile Include="Part.cs" />
<Compile Include="PartInventory.cs" />
<Compile Include="PartStockLevel.cs" />
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="QBIIntegrationData.cs" /> <Compile Include="QBIIntegrationData.cs" />

View File

@@ -199,7 +199,7 @@ namespace AyaNovaQBI
switch (_Type) switch (_Type)
{ {
case AyaType.Customer: case AyaType.Customer:
util.ImportAyaCustomer(AyaId, alErrors); await util.ImportAyaCustomer(AyaId, alErrors);
break; break;
case AyaType.Vendor: case AyaType.Vendor:
await util.ImportAyaVendor(AyaId, alErrors); await util.ImportAyaVendor(AyaId, alErrors);

View File

@@ -6,7 +6,37 @@ using System.Threading.Tasks;
namespace AyaNovaQBI namespace AyaNovaQBI
{ {
internal class PartInventory public class PartInventory
{ {
public long Id { get; set; }
public uint Concurrency { get; set; }
public string Description { get; set; }
public DateTime EntryDate { get; set; }
public DateTime? LastEntryDate { get; set; }
public long PartId { get; set; }
public string PartNameViz { get; set; }
public string PartDescriptionViz { get; set; }
public string PartUpcViz { get; set; }
public long PartWarehouseId { get; set; }
public string PartWarehouseViz { get; set; }
public long? SourceId { get; set; }
public string SourceViz { get; set; }
public AyaType? SourceType { get; set; }
public string SourceTypeViz { get; set; }
public decimal Quantity { get; set; }
public decimal Balance { get; set; }
public decimal? LastBalance { get; set; }
public PartInventory()
{
EntryDate = DateTime.UtcNow;
} }
}//eoc
} }

View File

@@ -6,7 +6,14 @@ using System.Threading.Tasks;
namespace AyaNovaQBI namespace AyaNovaQBI
{ {
internal class PartStockLevel public class PartStockLevel
{ {
} public long Id { get; set; }
public uint Concurrency { get; set; }
public long PartWarehouseId { get; set; }
public long PartId { get; set; }
public decimal MinimumQuantity { get; set; }
public string PartWarehouseDisplay { get; set; }//to display name in UI, not relevant to db or biz object
}//eoc
} }

View File

@@ -5219,9 +5219,13 @@ namespace AyaNovaQBI
if (USE_INVENTORY) if (USE_INVENTORY)
{ {
PartInventoryValuesFetcher pbw = PartInventoryValuesFetcher.GetItem(c.ID); var rstocklevel = await GetAsync($"part/stock-levels/{c.Id}");
ca.QuantityOnHand.SetValue((double)pbw.QuantityOnHand); var partstocklevel= rstocklevel.ObjectResponse["data"].ToObject<PartStockLevel>();
ca.ReorderPoint.SetValue((double)pbw.MinStockLevel); var rinventorylevel = await GetAsync($"part/latest-inventory/{c.Id}");
var partinventories = rstocklevel.ObjectResponse["data"].ToObject< List<PartInventory>>();
ca.QuantityOnHand.SetValue((double)partinventories.Sum(z => z.Balance));
ca.ReorderPoint.SetValue((double)partstocklevel.MinimumQuantity);
} }
//------------------------ //------------------------
@@ -5270,13 +5274,16 @@ namespace AyaNovaQBI
_dtQBItems.Rows.Add(dr); _dtQBItems.Rows.Add(dr);
//Link //Link
IntegrationMap m = QBI.Maps.Add(QBI); var m = new IntegrationItem { AType = AyaType.Part, IntegrationItemName = sName, IntegrationItemId = sNewID, LastSync = DateTime.Now, ObjectId = c.Id };
m.Name = sName; QBIntegration.Items.Add(m);
m.RootObjectID = c.ID; await util.SaveIntegrationObject();
m.RootObjectType = RootObjectTypes.Part; //IntegrationMap m = QBI.Maps.Add(QBI);
m.LastSync = DateTime.Now; //m.Name = sName;
m.ForeignID = sNewID; //m.RootObjectID = c.ID;
QBI = (Integration)QBI.Save(); //m.RootObjectType = RootObjectTypes.Part;
//m.LastSync = DateTime.Now;
//m.ForeignID = sNewID;
//QBI = (Integration)QBI.Save();
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -5306,19 +5313,20 @@ namespace AyaNovaQBI
/// </summary> /// </summary>
/// <param name="VendorID"></param> /// <param name="VendorID"></param>
/// <param name="alErrors">An arraylist to hold strings indicating errors on fail</param> /// <param name="alErrors">An arraylist to hold strings indicating errors on fail</param>
public static void ImportAyaRate(Guid RateID, RatePickList ratelist, ArrayList alErrors) public static async Task ImportAyaServiceRate(long RateID, ArrayList alErrors)
{ {
if (!ratelist.Contains(RateID)) if (!AyaServiceRateList.Any(z => z.Id == RateID))
{ {
alErrors.Add("ImportAyaRate: Rate not found in AyaNova (deleted recently?) (" + RateID.ToString() + ")"); alErrors.Add("ImportAyaRate: Rate not found in AyaNova (deleted recently?) (" + RateID.ToString() + ")");
return; return;
} }
RatePickList.RatePickListInfo c = ratelist[RateID]; // RatePickList.RatePickListInfo c = ratelist[RateID];
var r = await GetAsync($"service-rate/{RateID}");
var c = r.ObjectResponse["data"].ToObject<ServiceRate>();
HERE
string sName = c.Name; string sName = c.Name;
if (sName.Length > 31) if (sName.Length > 31)