public long Save(DateTime valueDate, string referenceNumber, string statementReference, string data) { try { Collection <StockAdjustmentDetail> stockTransferModels = GetModels(data); foreach (StockAdjustmentDetail model in stockTransferModels) { if (model.TransferTypeEnum == TransactionTypeEnum.Credit) { decimal existingQuantity = Items.CountItemInStock(AppUsers.GetCurrentUserDB(), model.ItemCode, model.UnitName, model.StoreName); if (existingQuantity < model.Quantity) { throw new MixERPException(string.Format(CultureInfo.CurrentCulture, Errors.InsufficientStockWarning, Conversion.TryCastInteger(existingQuantity), model.UnitName, model.ItemName)); } } } int officeId = AppUsers.GetCurrentLogin().View.OfficeId.ToInt(); int userId = AppUsers.GetCurrentLogin().View.UserId.ToInt(); long loginId = AppUsers.GetCurrentLogin().View.LoginId.ToLong(); return(StockTransfer.Add(AppUsers.GetCurrentUserDB(), officeId, userId, loginId, valueDate, referenceNumber, statementReference, stockTransferModels)); } catch (Exception ex) { Log.Warning("Could not save inventory transfer entry. {Exception}", ex); throw; } }
public static string AddData(Company oCompany, ITR model) { StockTransfer oObject = null; RTNMANVAL rtn = new RTNMANVAL(); int errCode; string errMessage, strResult = ""; try { oCompany.StartTransaction(); oObject = oCompany.GetBusinessObject(BoObjectTypes.oInventoryTransferRequest); oObject.DocDate = model.PostingDate; oObject.DueDate = model.DocumentDate; oObject.ToWarehouse = model.ToWarehouseCode; oObject.FromWarehouse = model.FromWarehouseCode; oObject.Address = model.ShipTo; oObject.UserFields.Fields.Item("U_MJTPO").Value = model.NoSPK; oObject.UserFields.Fields.Item("U_MJTSPK").Value = model.NoSPKDetil; oObject.UserFields.Fields.Item("U_MJT_NoSIP2").Value = model.NoSIP2; oObject.UserFields.Fields.Item("U_MJT_TglSIP2").Value = model.TglSIP2; oObject.UserFields.Fields.Item("U_MJTBASTB").Value = model.NoBAP; oObject.UserFields.Fields.Item("U_MJTRCVD").Value = model.TglBAP; oObject.UserFields.Fields.Item("U_mjt_opr").Value = model.Operator; oObject.UserFields.Fields.Item("U_mjt_scr").Value = model.Security; oObject.UserFields.Fields.Item("U_mjt_jam2").Value = model.jam; oObject.UserFields.Fields.Item("U_mjt_qa").Value = model.PetugasQA; oObject.UserFields.Fields.Item("U_MJTPO").Value = model.NoSPK2; oObject.UserFields.Fields.Item("U_MJT_Uraian").Value = model.UraianKerja; oObject.UserFields.Fields.Item("U_MJT_NomorINV").Value = model.NoInvoicePajak; oObject.UserFields.Fields.Item("U_MJT_DP").Value = model.Downpayment; oObject.UserFields.Fields.Item("U_MJT_DP2").Value = model.DownpaymentAmount; for (int i = 0; i < model.lines.Count; i++) { oObject.Lines.ItemCode = model.lines[i].ItemCode; oObject.Lines.FromWarehouseCode = model.FromWarehouseCode; oObject.Lines.WarehouseCode = model.lines[i].ToWarehouseCode; oObject.Lines.Quantity = model.lines[i].Quantity; oObject.Lines.Add(); } int addStatus = oObject.Add(); if (addStatus == 0) { if (strResult == "") { strResult = oCompany.GetNewObjectKey(); } else { strResult = strResult + " | " + oCompany.GetNewObjectKey(); } } else { if (oCompany.InTransaction) { oCompany.EndTransaction(BoWfTransOpt.wf_RollBack); } oCompany.GetLastError(out errCode, out errMessage); throw new Exception("Error Code : " + errCode + " | Error Message : " + errMessage); } oCompany.EndTransaction(BoWfTransOpt.wf_Commit); } catch (Exception) { if (oCompany.InTransaction) { oCompany.EndTransaction(BoWfTransOpt.wf_RollBack); } ; throw; } return(strResult); }