예제 #1
0
        private int InventoryOut(oInventoryTransaction invTransaction)
        {
            Documents invOut = SboComObject.GetBusinessObject(BoObjectTypes.oInventoryGenExit);

            try
            {
                SboComObject.StartTransaction();

                int retCode = 0;

                invOut.DocDate                 = invTransaction.DocDate;
                invOut.TaxDate                 = invTransaction.TaxDate;
                invOut.Reference2              = invTransaction.ReferenceNo;
                invOut.Series                  = invTransaction.Series;
                invOut.Comments                = invTransaction.Remarks;
                invOut.JournalMemo             = invTransaction.JournalRemarks;
                invOut.BPL_IDAssignedToInvoice = invTransaction.BranchId;

                if (invTransaction.TransactionLines.Count > 0)
                {
                    foreach (oInventoryTransactionLine line in invTransaction.TransactionLines)
                    {
                        invOut.Lines.SetCurrentLine(line.LineNo);
                        invOut.Lines.ItemCode      = line.ItemCode;
                        invOut.Lines.Quantity      = line.Quantity;
                        invOut.Lines.Price         = line.Price;
                        invOut.Lines.WarehouseCode = line.WarehouseId;
                        invOut.Lines.AccountCode   = line.GLAccountCode;
                        invOut.Lines.Add();
                    }
                }

                retCode = invOut.Add();
                if (retCode != 0)
                {
                    int    errCode    = 0;
                    string errMessage = "";
                    SboComObject.GetLastError(out errCode, out errMessage);
                    GlobalInstance.Instance.SBOErrorCode    = errCode;
                    GlobalInstance.Instance.SBOErrorMessage = errMessage;

                    SboComObject.EndTransaction(BoWfTransOpt.wf_RollBack);
                }
                else
                {
                    SboComObject.EndTransaction(BoWfTransOpt.wf_Commit);
                }

                return(retCode);
            }
            catch (Exception ex)
            {
                System.Runtime.InteropServices.Marshal.ReleaseComObject(invOut);
                throw new Exception(GlobalInstance.Instance.SBOErrorMessage == null ? ex.Message : GlobalInstance.Instance.SBOErrorMessage);
            }
            finally
            {
                System.Runtime.InteropServices.Marshal.ReleaseComObject(invOut);
            }
        }
예제 #2
0
        public async Task <IHttpActionResult> AddInventory(oInventoryTransaction transaction)
        {
            try
            {
                if (!GlobalInstance.Instance.IsConnected)
                {
                    GlobalInstance.Instance.InitializeSboComObject();
                }
                var t = await repo.GetTransactionByDocNo(transaction.DocNum, transaction.InventoryTransactionType);

                if (t != null)
                {
                    errMsg = string.Format("Inventory transaction document {0} already exist.", transaction.DocNum);
                    var resp = new HttpResponseMessage(HttpStatusCode.Conflict);
                    resp.Content      = new StringContent(errMsg);
                    resp.ReasonPhrase = "Object already exist.";
                    throw new HttpResponseException(resp);
                }

                if (repo.Add(transaction) < 0)
                {
                    errMsg = GlobalInstance.Instance.SBOErrorMessage;
                    var resp = new HttpResponseMessage(HttpStatusCode.Conflict);
                    resp.Content      = new StringContent(errMsg);
                    resp.ReasonPhrase = "SBO Error";
                    throw new HttpResponseException(resp);
                }

                return(Ok(string.Format("Inventory {0} succesful: document no.: {1}", transaction.InventoryTransactionType.ToString(), transaction.DocNum)));
            }
            catch (HttpResponseException ex)
            {
                throw new HttpResponseException(HttpStatusCode.BadRequest);
            }
        }
        public void LogInventoryTransaction(oInventoryTransaction obj, bool isPosted, string action, string origin, ErrorLog errLog = null)
        {
            try
            {
                log.TransactionNo = obj.DocNum.ToString();
                log.Origin        = origin;
                log.Type          = obj.InventoryTransactionType == InventoryType.In? TransactionLog.SBOType.GR: TransactionLog.SBOType.GI;
                log.LogDate       = DateTime.Now;
                log.IsPosted      = isPosted;

                TransactionData rawData = new TransactionData();
                rawData.PostedOn = obj.DocDate;
                rawData.RawData  = JsonConvert.SerializeObject(obj);

                log.RawData   = rawData;
                log.Action    = action;
                log.CreatedBy = obj.CreatedBy;
                log.CreatedOn = obj.CreateDate;
                repo.AddOrUpdate(log);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #4
0
        public int Add(oInventoryTransaction obj)
        {
            int retCode = 0;

            if (obj.InventoryTransactionType == InventoryType.In)
            {
                retCode = InventoryIn(obj);
            }
            else
            {
                retCode = InventoryOut(obj);
            }

            return(retCode);
        }
예제 #5
0
 public void LogInventoryTransaction(oInventoryTransaction obj, bool isPosted, ErrorLog errLog = null)
 {
     try
     {
         log.TransactionNo     = obj.DocNum.ToString();
         log.Origin            = string.Format("{0}-{1}", HttpContext.Current.Request.UserHostAddress, HttpContext.Current.Request.UserHostName);
         log.Type              = obj.InventoryTransactionType == InventoryType.In? TransactionLog.SBOType.GR: TransactionLog.SBOType.GI;
         log.LogDate           = DateTime.Now;
         log.IsPosted          = isPosted;
         log.TransactionDataID = log.RawData.ID;
         log.RawData.PostedOn  = obj.DocDate;
         log.RawData.RawData   = JsonConvert.SerializeObject(obj);
         repo.AddOrUpdate(log);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
예제 #6
0
        private async Task <List <oInventoryTransaction> > GetInventoryOuts(Func <oInventoryTransaction, bool> fltr)
        {
            try
            {
                List <oInventoryTransaction> invtries = new List <oInventoryTransaction>();

                if (SqlObject != null)
                {
                    var invntryCache = new Dictionary <int, oInventoryTransaction>();
                    var invnty       = await SqlObject.QueryAsync <oInventoryTransaction, oInventoryTransactionLine, oInventoryTransaction>("sp_getIssues", (invntyHdr, invntyLine) =>
                    {
                        oInventoryTransaction _invnty = null;
                        if (!invntryCache.TryGetValue(invntyHdr.DocNum, out _invnty))
                        {
                            _invnty = invntyHdr;
                            _invnty.TransactionLines = new List <oInventoryTransactionLine>();
                            invntryCache.Add(_invnty.DocNum, _invnty);
                        }

                        _invnty.TransactionLines.Add(invntyLine);

                        return(_invnty);
                    }, param : null, transaction : null, buffered : true, splitOn : "Id", commandTimeout : null, commandType : System.Data.CommandType.StoredProcedure);

                    if (fltr != null)
                    {
                        invtries = invnty.Distinct().Where(fltr).ToList();
                    }
                    else
                    {
                        invtries = invnty.Distinct().ToList();
                    }
                }

                return(invtries);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
예제 #7
0
        public void TestMethod1()
        {
            GlobalInstance.Instance.DatabaseServerType = DBType.MSSQL2012;
            GlobalInstance.Instance.Server             = "CHUCKIE";
            GlobalInstance.Instance.DBName             = "ALPALAND_NEW_DB";
            GlobalInstance.Instance.DBUName            = "sa";
            GlobalInstance.Instance.DBPword            = "jsi@111";
            GlobalInstance.Instance.UName = "manager";
            GlobalInstance.Instance.Pword = "5555";

            GlobalInstance.Instance.InitializeSboComObject();
            GlobalInstance.Instance.InitializeSqlObject();

            //IItemRepository repo = new RepositoryFactory().ItemRepository();

            //repo.InitRepository(GlobalInstance.Instance.SqlObject);
            //repo.InitRepository(GlobalInstance.Instance.SboComObject);


            //oItem itm = new oItem
            //{
            //    ItemCode = "SEQL001-DUP",
            //    SellPrice = 600,
            //    ItemCost = 900,
            //    Barcode = "84938439938",
            //    Description = "HYUNDAI GRAND STAREX GLS CRDI VGT (10S) ABN 2617",
            //    ItemGroup = 114,
            //    UoMGroup = 3,
            //    Series = 3,
            //    InventoryItem = "Y",
            //    SalesItem = "Y",
            //    PurchaseItem = "Y"
            //};

            //repo.Add(itm);


            //IBusinessPartnerRepository repo = new RepositoryFactory().BusinessPartnerRepository();

            //repo.InitRepository(GlobalInstance.Instance.SqlObject);
            //repo.InitRepository(GlobalInstance.Instance.SboComObject);

            //oBusinessPartner bp = new oBusinessPartner
            //{
            //    Series = 1,
            //    CardCode = "SUP-001",
            //    CardName = "John Macasero",
            //    GroupCode = 101,
            //    CardType = "S",
            //    LicTradNum = "11928923"
            //};

            //repo.Add(bp);

            //IJournalRepository repo = new RepositoryFactory().JournalRepository();

            //repo.InitRepository(GlobalInstance.Instance.SqlObject);
            //repo.InitRepository(GlobalInstance.Instance.SboComObject);

            //List<oJournalLine> lines = new List<oJournalLine>();
            //lines.Add(new oJournalLine {
            //    GLCode = "SDORM000002",
            //    LineType = "C",
            //    LineMemo = "from api",
            //    Segment = 3,
            //    Debit = 0,
            //    Credit = 8000
            //});

            //lines.Add(new oJournalLine
            //{
            //    GLCode = "_SYS00000000045",
            //    LineType = "D",
            //    LineMemo = "from api",
            //    Segment = 3,
            //    Debit = 6500,
            //    Credit = 0
            //});

            //lines.Add(new oJournalLine
            //{
            //    GLCode = "_SYS00000000157",
            //    LineType = "D",
            //    LineMemo = "from api",
            //    Segment = 3,
            //    Debit = 1500,
            //    Credit = 0
            //});

            //oJournal j = new oJournal {
            //    JdtNumber = 20002968,//supply if update
            //    Series = 102,
            //    DocDate = DateTime.Now,
            //    DocDueDate = DateTime.Now,
            //    CreateDate = DateTime.Now,
            //    JournalMemo = "TEst",
            //    Reference1 = "from api",
            //    Reference2 = "Test",
            //    Reference3 = "Test",
            //    JournalLines = lines
            //};

            //repo.Update(j);


            IInventoryTransactionRepository repo = new RepositoryFactory().InventoryTransactionRepository();

            repo.InitRepository(GlobalInstance.Instance.SboComObject);

            List <oInventoryTransactionLine> invLines = new List <oInventoryTransactionLine>();

            invLines.Add(new oInventoryTransactionLine {
                ItemCode      = "CIPITB020",
                GLAccountCode = "_SYS00000001044",
                WarehouseId   = "01",
                Quantity      = 5,
                Price         = 200
            });

            oInventoryTransaction inv = new oInventoryTransaction();

            inv.BranchId = 1;
            //inv.Series = 141;
            inv.Series                   = 149;
            inv.DocDate                  = DateTime.Now;
            inv.TaxDate                  = DateTime.Now;
            inv.ReferenceNo              = "Test";
            inv.Remarks                  = "Test from sbo.fx";
            inv.JournalRemarks           = "Test";
            inv.TransactionLines         = invLines;
            inv.InventoryTransactionType = InventoryType.Out;

            repo.Add(inv);
        }
예제 #8
0
 public int Update(oInventoryTransaction obj)
 {
     throw new NotImplementedException();
 }