public static bool CompleteInventoryRequestOrder(NameValueCollection fields, ref List <string> log, bool dryRun) { var automation = new Automation(dryRun); try { log.Add("starting complete inventory request order: " + fields["Task Name"]); int.TryParse(fields["Requested Quantity"], out int requestedQuantity); int.TryParse(fields["Produced Quantity"], out int producedQuantity); automation.CompleteInventoryRequest(fields["Component ID"], producedQuantity, requestedQuantity, fields["Location"]); log.Add("updated inventory quantities."); if (!string.IsNullOrEmpty(fields["Order ID"])) { automation.UpdateCompletedInventoryRequestOrder(fields["Order ID"], fields["Component ID"], fields["Owner"], producedQuantity); } else { log.Add("no identifier found in fields, cannot update order record"); } log = automation.Log; return(true); } catch (Exception e) { log = automation.Log; log.Add(e.StackTrace); log.Add(e.Message); } return(false); }
public void CompleteInventoryRequestOrder() { var inventoryBase = new AirtableItemLookup(); var test = new Automation(); var component = inventoryBase.GetComponentByName("ZZZ - Dummy", false); var previousQuantity = component.Quantity; var previousPending = component.Pending; test.CompleteInventoryRequest(component.id, 3, 5); inventoryBase.UpdateComponentRecord(component); component = inventoryBase.GetComponentByName("ZZZ - Dummy", false); Assert.True(component.Quantity - previousQuantity == 3); Assert.True(component.Pending - previousPending == -5); }