Skip to content

Instantly share code, notes, and snippets.

@dianecawley
Created December 30, 2022 22:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dianecawley/27ec111c700133afa3b7caeafefd75e9 to your computer and use it in GitHub Desktop.
Save dianecawley/27ec111c700133afa3b7caeafefd75e9 to your computer and use it in GitHub Desktop.
Example of Mfg Labor Transaction PUT and Release
//Build the transaction details and header. Start with the transaction being On Hold
var laborentryapi = new LaborEntryApi(configuration);
List<LaborEntryDetail> receiptDetails = new List<LaborEntryDetail>();
string LocationID = "1";
int32 LaborMinutes = 15;
string MachineID = "LASER";
Decimal LaborHours = Math.Floor(Convert.ToDecimal(Math.Abs(LaborMinutes) / 60));
Decimal LaborMin = Math.Abs(LaborMinutes) - (60 * LaborHours);
string FormattedLaborTime = Math.Abs(LaborHours).ToString("00") + ":" + Math.Abs(LaborMin).ToString("00");
if (LaborMinutes < 0) { FormattedLaborTime = "-" + FormattedLaborTime; }
List<LaborEntryTranAttributes> attrList = new List<LaborEntryTranAttributes>();
attrList.Add(new LaborEntryTranAttributes
{
Attribute = new StringValue { Value = "MACHINE" },
Value = new StringValue { Value = MachineID }
});
receiptDetails.Add(new LaborEntryDetail
{
LaborType = new StringValue { Value = "Direct" },
OrderType = new StringValue { Value = OrderType },
ProductionNbr = new StringValue { Value = OrderID },
OperationNbr = new StringValue { Value = OperationID },
EmployeeID = new StringValue { Value = EmployeeID },
Shift = new StringValue { Value = ShiftID },
LaborTime = new StringValue { Value = FormattedLaborTime },
Warehouse = new StringValue { Value = SiteID },
Location = new StringValue { Value = LocationID },
Quantity = new DecimalValue { Value = Convert.ToDecimal(Qty) },
LotSerialNbr = new StringValue { Value = LotNum },
TransactionAttributes = attrList
}
);
LaborEntry moveEntry = new LaborEntry
{
Date = new DateTimeValue { Value = Convert.ToDateTime(TranDateString) },
Hold = new BooleanValue { Value = true },
Description = new StringValue { Value = "Labor" },
Details = receiptDetails
};
//Now Save (PUT) the transaction - document will be On Hold
LaborEntry newLaborEntry = laborentryapi.PutEntity(moveEntry, "BatchNbr");
//Now Remove the Hold, and Save Again (PUT)
newLaborEntry.Hold = new BooleanValue { Value = false };
LaborEntry new2LaborEntry = laborentryapi.PutEntity(newLaborEntry, "BatchNbr");
//Finally, release (POST) the transaction
laborentryapi.WaitActionCompletion(laborentryapi.InvokeAction(new ReleaseLaborEntry(new2LaborEntry)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment