Esempio n. 1
0
        public void Test_InvoiceBase_Creation()
        {
            InvoiceBase baseInvoice = new InvoiceBase();

            Assert.That(baseInvoice.CreatedTime.HasValue);
            Assert.IsNotNull(baseInvoice);
        }
Esempio n. 2
0
        public void Test_InvoiceBase_Required()
        {
            InvoiceBase baseInvoice = new InvoiceBase();
            Assert.IsFalse(Validator.TryValidateObject(baseInvoice, new ValidationContext(baseInvoice), new List<ValidationResult>(), true));

            baseInvoice.Vendor = "TestVendorId";
            baseInvoice.Notes = "Test Note";
            Assert.IsTrue(Validator.TryValidateObject(baseInvoice, new ValidationContext(baseInvoice), new List<ValidationResult>(), true));
        }
Esempio n. 3
0
        public void Test_InvoiceBase_Required()
        {
            InvoiceBase baseInvoice = new InvoiceBase();

            Assert.IsFalse(Validator.TryValidateObject(baseInvoice, new ValidationContext(baseInvoice), new List <ValidationResult>(), true));

            baseInvoice.Vendor = "TestVendorId";
            baseInvoice.Notes  = "Test Note";
            Assert.IsTrue(Validator.TryValidateObject(baseInvoice, new ValidationContext(baseInvoice), new List <ValidationResult>(), true));
        }
Esempio n. 4
0
 public void PublishReplace(IInvoice OriINV, IList <ProductInv> lst, InvoiceBase INV, string AttacheFile = "")
 {
     try
     {
         INV.Products = lst.Select(p => p).ToList <IProductInv>();
         string xmldata = string.Empty;
         xmldata = INV.SerializeToXML();
         string data = "{'xmlData':'" + xmldata + "','pattern':'" + OriINV.Pattern + "', 'serial': '" + OriINV.Serial + "','invNo':'" + OriINV.No + "','fkey':'" + OriINV.Fkey + "','convert':0}";
         Message = callApi("api/business/replaceInv", data);
     }
     catch (Exception ex)
     {
         log.Error(ex);
         Message = ex.Message;
     }
 }
Esempio n. 5
0
        public void Test_InvoiceBase_Generated()
        {
            List <ItemDetails> invoiceItems = new List <ItemDetails>();

            invoiceItems.Add(new ItemDetails()
            {
                Item     = "Test Item 1",
                Price    = 100,
                Quantity = 1,
                VAT      = 10,
                Weight   = 5
            });

            invoiceItems.Add(new ItemDetails()
            {
                Item     = "Test Item 2",
                Price    = 100,
                Quantity = 3,
                VAT      = 20,
                Weight   = 2
            });

            InvoiceBase baseInvoice = new InvoiceBase(invoiceItems);

            DateTime dueDate = baseInvoice.CreatedTime.Value.AddDays(5);

            baseInvoice.Vendor         = "TestVendorId";
            baseInvoice.Notes          = "Test Note";
            baseInvoice.ServiceCharge  = 100;
            baseInvoice.DueDate        = dueDate;
            baseInvoice.Paid           = PaymentStatus.Pending;
            baseInvoice.NetTotal       = 100;
            baseInvoice.SubTotal       = 200;
            baseInvoice.TotalToPay     = 400;
            baseInvoice.TotalVATAmount = 10;
            baseInvoice.Weight         = 5;

            Assert.AreEqual(100, baseInvoice.NetTotal);
            Assert.AreEqual(200, baseInvoice.SubTotal);
            Assert.AreEqual(400, baseInvoice.TotalToPay);
            Assert.AreEqual(10, baseInvoice.TotalVATAmount);
            Assert.AreEqual(5, baseInvoice.Weight);
        }
Esempio n. 6
0
        public void Test_InvoiceBase_Generated()
        {
            List<ItemDetails> invoiceItems = new List<ItemDetails>();
            invoiceItems.Add(new ItemDetails()
            {
                Item = "Test Item 1",
                Price = 100,
                Quantity = 1,
                VAT = 10,
                Weight = 5
            });

            invoiceItems.Add(new ItemDetails()
            {
                Item = "Test Item 2",
                Price = 100,
                Quantity = 3,
                VAT = 20,
                Weight = 2
            });

            InvoiceBase baseInvoice = new InvoiceBase(invoiceItems);

            DateTime dueDate = baseInvoice.CreatedTime.Value.AddDays(5);

            baseInvoice.Vendor = "TestVendorId";
            baseInvoice.Notes = "Test Note";
            baseInvoice.ServiceCharge = 100;
            baseInvoice.DueDate = dueDate;
            baseInvoice.Paid = PaymentStatus.Pending;
            baseInvoice.NetTotal = 100;
            baseInvoice.SubTotal = 200;
            baseInvoice.TotalToPay = 400;
            baseInvoice.TotalVATAmount = 10;
            baseInvoice.Weight = 5;

            Assert.AreEqual(100, baseInvoice.NetTotal);
            Assert.AreEqual(200, baseInvoice.SubTotal);
            Assert.AreEqual(400, baseInvoice.TotalToPay);
            Assert.AreEqual(10, baseInvoice.TotalVATAmount);
            Assert.AreEqual(5, baseInvoice.Weight);
        }
        /// <summary>
        /// Updates Invoice
        /// </summary>
        /// <param name="invoiceObject">Object to be updated</param>
        /// <returns>Number of rows affected</returns>
        public long Update(InvoiceBase invoiceObject)
        {
            try
            {
                SqlCommand cmd = GetSPCommand(UPDATEINVOICE);

                AddParameter(cmd, pInt32(InvoiceBase.Property_Id, invoiceObject.Id));
                AddCommonParams(cmd, invoiceObject);

                long result = UpdateRecord(cmd);
                if (result > 0)
                {
                    invoiceObject.RowState = BaseBusinessEntity.RowStateEnum.NormalRow;
                }
                return(result);
            }
            catch (SqlException x)
            {
                throw new ObjectUpdateException(invoiceObject, x);
            }
        }
Esempio n. 8
0
        public void PublishAdjust(IInvoice OriINV, IList <ProductInv> lst, InvoiceBase INV, string AttacheFile = "")
        {
            Company currentCom = ((EInvoiceContext)FXContext.Current).CurrentCompany;

            try
            {
                Launcher.Instance.PublishAdjust(OriINV, lst, INV, AttacheFile);
                Message = "OK:";
                try
                {
                    ILogSystemService businessLog = IoC.Resolve <ILogSystemService>();
                    businessLog.WriteLogReplaceAdjust(currentCom.id, OriINV.Pattern, OriINV.Serial, OriINV.No, OriINV.PublishDate, OriINV.Amount, INV.Pattern, INV.Serial, INV.No, INV.PublishDate, INV.Amount, INV.CusName, INV.CusAddress, INV.CusCode, INV.CusTaxCode, HttpContext.Current.User.Identity.Name, BusinessLogType.Adjust);
                    businessLog.CommitChanges();
                }
                catch { }
            }
            catch (Exception ex)
            {
                Message = ex.Message;
            }
        }
 /// <summary>
 /// Add common parameters before calling a procedure
 /// </summary>
 /// <param name="cmd">command object, where parameters will be added</param>
 /// <param name="invoiceObject"></param>
 private void AddCommonParams(SqlCommand cmd, InvoiceBase invoiceObject)
 {
     AddParameter(cmd, pNVarChar(InvoiceBase.Property_InvoiceId, 15, invoiceObject.InvoiceId));
     AddParameter(cmd, pGuid(InvoiceBase.Property_CustomerId, invoiceObject.CustomerId));
     AddParameter(cmd, pGuid(InvoiceBase.Property_CompanyId, invoiceObject.CompanyId));
     AddParameter(cmd, pDouble(InvoiceBase.Property_Amount, invoiceObject.Amount));
     AddParameter(cmd, pDouble(InvoiceBase.Property_Tax, invoiceObject.Tax));
     AddParameter(cmd, pNVarChar(InvoiceBase.Property_DiscountCode, 50, invoiceObject.DiscountCode));
     AddParameter(cmd, pDouble(InvoiceBase.Property_DiscountAmount, invoiceObject.DiscountAmount));
     AddParameter(cmd, pDouble(InvoiceBase.Property_TotalAmount, invoiceObject.TotalAmount));
     AddParameter(cmd, pNVarChar(InvoiceBase.Property_Status, 50, invoiceObject.Status));
     AddParameter(cmd, pDateTime(InvoiceBase.Property_InvoiceDate, invoiceObject.InvoiceDate));
     AddParameter(cmd, pDateTime(InvoiceBase.Property_CreatedDate, invoiceObject.CreatedDate));
     AddParameter(cmd, pNVarChar(InvoiceBase.Property_CreatedBy, 50, invoiceObject.CreatedBy));
     AddParameter(cmd, pBool(InvoiceBase.Property_IsEstimate, invoiceObject.IsEstimate));
     AddParameter(cmd, pBool(InvoiceBase.Property_IsBill, invoiceObject.IsBill));
     AddParameter(cmd, pNVarChar(InvoiceBase.Property_BillingAddress, invoiceObject.BillingAddress));
     AddParameter(cmd, pDateTime(InvoiceBase.Property_DueDate, invoiceObject.DueDate));
     AddParameter(cmd, pNVarChar(InvoiceBase.Property_Terms, 50, invoiceObject.Terms));
     AddParameter(cmd, pNVarChar(InvoiceBase.Property_ShippingAddress, invoiceObject.ShippingAddress));
     AddParameter(cmd, pNVarChar(InvoiceBase.Property_ShippingVia, 50, invoiceObject.ShippingVia));
     AddParameter(cmd, pDateTime(InvoiceBase.Property_ShippingDate, invoiceObject.ShippingDate));
     AddParameter(cmd, pNVarChar(InvoiceBase.Property_TrackingNo, 50, invoiceObject.TrackingNo));
     AddParameter(cmd, pDouble(InvoiceBase.Property_ShippingCost, invoiceObject.ShippingCost));
     AddParameter(cmd, pDouble(InvoiceBase.Property_Discountpercent, invoiceObject.Discountpercent));
     AddParameter(cmd, pDouble(InvoiceBase.Property_BalanceDue, invoiceObject.BalanceDue));
     AddParameter(cmd, pDouble(InvoiceBase.Property_Deposit, invoiceObject.Deposit));
     AddParameter(cmd, pNVarChar(InvoiceBase.Property_Message, invoiceObject.Message));
     AddParameter(cmd, pNVarChar(InvoiceBase.Property_TaxType, 50, invoiceObject.TaxType));
     AddParameter(cmd, pDateTime(InvoiceBase.Property_LastUpdatedDate, invoiceObject.LastUpdatedDate));
     AddParameter(cmd, pDouble(InvoiceBase.Property_Balance, invoiceObject.Balance));
     AddParameter(cmd, pNVarChar(InvoiceBase.Property_Memo, 500, invoiceObject.Memo));
     AddParameter(cmd, pNVarChar(InvoiceBase.Property_InvoiceFor, 50, invoiceObject.InvoiceFor));
     AddParameter(cmd, pDouble(InvoiceBase.Property_LateFee, invoiceObject.LateFee));
     AddParameter(cmd, pDouble(InvoiceBase.Property_LateAmount, invoiceObject.LateAmount));
     AddParameter(cmd, pDateTime(InvoiceBase.Property_InstallDate, invoiceObject.InstallDate));
     AddParameter(cmd, pNVarChar(InvoiceBase.Property_Description, invoiceObject.Description));
     AddParameter(cmd, pNVarChar(InvoiceBase.Property_DiscountType, 50, invoiceObject.DiscountType));
     AddParameter(cmd, pNVarChar(InvoiceBase.Property_BillingCycle, 50, invoiceObject.BillingCycle));
 }
        /// <summary>
        /// Inserts Invoice
        /// </summary>
        /// <param name="invoiceObject">Object to be inserted</param>
        /// <returns>Number of rows affected</returns>
        public long Insert(InvoiceBase invoiceObject)
        {
            try
            {
                SqlCommand cmd = GetSPCommand(INSERTINVOICE);

                AddParameter(cmd, pInt32Out(InvoiceBase.Property_Id));
                AddCommonParams(cmd, invoiceObject);

                long result = InsertRecord(cmd);
                if (result > 0)
                {
                    invoiceObject.RowState = BaseBusinessEntity.RowStateEnum.NormalRow;
                    invoiceObject.Id       = (Int32)GetOutParameter(cmd, InvoiceBase.Property_Id);
                }
                return(result);
            }
            catch (SqlException x)
            {
                throw new ObjectInsertException(invoiceObject, x);
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Helper method used to fill data for invoice templates.
        /// </summary>
        /// <param name="invoice"></param>
        private static void FillInvoceData(InvoiceBase invoice)
        {
            invoice.invoiceNr       = "12345";
            invoice.date            = DateTime.UtcNow.ToString();
            invoice.dueDate         = "-";
            invoice.fromCompanyName = "ACME";
            invoice.fromAddress     = "Yellow St, 69/a";
            invoice.fromCity        = "New York";
            invoice.fromState       = "-";
            invoice.fromCountry     = "USA";
            invoice.fromPostal      = "11-665";
            invoice.fromContact     = "John B.";
            invoice.toCompanyName   = "Coctails SA.";
            invoice.toAddress       = "Red Blvrd 9";
            invoice.toCity          = "Tbilisi";
            invoice.toState         = "-";
            invoice.toCountry       = "Georgia";
            invoice.toPostal        = "99";
            invoice.toContact       = "Mungashvili.";
            invoice.comments        = "-";
            invoice.subtotal        = "100";
            invoice.taxRate         = "0";
            invoice.taxDue          = "-";
            invoice.other           = "-";
            invoice.total           = "100";
            invoice.taxable         = "0";

            invoice.rows = new InvoiceRow[] {
                new InvoiceRow {
                    rowItemName = "Element", rowPrice = "20", rowQuantity = "2", rowTotal = "40"
                },
                new InvoiceRow {
                    rowItemName = "Something", rowPrice = "15", rowQuantity = "4", rowTotal = "60"
                },
            };

            invoice.images = new string[] { "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA6fptVAAAACklEQVR4nGNiAAAABgADNjd8qAAAAABJRU5ErkJggg==" };
        }
Esempio n. 12
0
        private string processAdjust(string xmlData, string pattern, string fkey, string serial = null, decimal invNo = 0, int convert = 0)
        {
            if (FXContext.Current == null)
            {
                return("ERR:1");
            }
            try
            {
                XmlSchemaValidator validator = new XmlSchemaValidator();
                //xmlInvData = convertSpecialCharacter(xmlInvData);
                if (!validator.ValidXmlDoc(xmlData, "", AppDomain.CurrentDomain.BaseDirectory + @"xmlvalidate\adjustvatinvoice.xsd"))
                {
                    log.Info("adjustInv " + validator.ValidationError);
                    return("ERR:3 err:" + validator.ValidationError);  //du lieu dau vao khong hop le
                }
                if (convert == 1)
                {
                    xmlData = DataHelper.convertTCVN3ToUnicode(xmlData);
                }
                ICustomerService _cusSvr         = IoC.Resolve <ICustomerService>();
                Company          _currentCompany = ((EInvoiceContext)FXContext.Current).CurrentCompany;
                int comID = _currentCompany.id;
                if (_currentCompany == null)
                {
                    return("ERR:7");                        //username khong phu hop - ko tim thay company phu hop voi [username]
                }
                string invNumList = "";
                int    isPattern  = string.IsNullOrEmpty(pattern) ? 0 : 1;
                IPublishInvoiceService _PubInvSrv = IoC.Resolve <IPublishInvoiceService>();
                switch ((isPattern))
                {
                case 0:
                    PublishInvoice pubinv = _PubInvSrv.GetFirst(comID, new int[] { 1, 2 });
                    if (pubinv != null)
                    {
                        pattern = pubinv.InvPattern;
                        serial  = pubinv.InvSerial;
                        _PubInvSrv.UnbindSession(pubinv);
                    }
                    else
                    {
                        return("ERR:20");     //tham so pattern va serial khong hop le
                    }
                    break;

                case 1:
                    PublishInvoice pubFirst = _PubInvSrv.GetbyPattern(comID, pattern, new int[] { 1, 2 }).FirstOrDefault();
                    if (pubFirst == null)
                    {
                        return("ERR:20");
                    }
                    else
                    {
                        serial = !string.IsNullOrWhiteSpace(serial) ? serial : pubFirst.InvSerial;
                        _PubInvSrv.UnbindSession(pubFirst);
                    }
                    break;
                }

                IInvoiceService iinvSrc    = InvServiceFactory.GetService(pattern, comID);
                IInvoice        currentInv = InvServiceFactory.NewInstance(pattern, comID);
                if (invNo > 0)
                {
                    currentInv = iinvSrc.GetByNo(comID, pattern, serial, invNo);
                }
                else
                {
                    currentInv = iinvSrc.GetByFkey(comID, fkey);
                }
                if (null == currentInv)
                {
                    return("ERR:2");  //khong ton tai hoa don
                }

                string invPattern = null, invSerial = null, errorMessage = "";
                if (!LaunchInvoices.Instance.ExistNoInPubInv(comID, currentInv.Pattern, currentInv.Serial, out invPattern, out invSerial, out errorMessage))
                {
                    log.Error(errorMessage);
                    return("ERR:6 " + fkey);   //het so hoa don trong dai
                }
                try
                {
                    XElement    xeles = XElement.Parse(xmlData);
                    InvoiceBase inv   = (InvoiceBase)InvServiceFactory.NewInstance(invPattern, comID);
                    string      read  = xmlData;
                    DataHelper.DeserializeEinvFromXML(read, inv);
                    inv.No       = 0;
                    inv.Name     = currentInv.Name;
                    inv.Pattern  = invPattern;
                    inv.Serial   = invSerial;
                    inv.CreateBy = System.Web.HttpContext.Current.User.Identity.Name;
                    XElement elem = XElement.Parse(xmlData);//invs.ElementAt(i);
                    //loai hoa don sua doi
                    if (elem.Element("Type") != null && !string.IsNullOrWhiteSpace(elem.Element("Type").Value))
                    {
                        inv.Type = (InvoiceType)Convert.ToInt32(elem.Element("Type").Value);
                    }
                    else
                    {
                        inv.Type = (InvoiceType)0;
                    }
                    //inv.Type = 0;
                    var Typecus = (from c in _cusSvr.Query where c.ComID == comID && c.Code == inv.CusCode && c.CusType == 1 select c.CusType).SingleOrDefault();
                    if (Typecus == 0)
                    {
                        inv.CusSignStatus = cusSignStatus.NocusSignStatus;
                    }
                    else
                    {
                        inv.CusSignStatus = cusSignStatus.NoSignStatus;
                    }
                    if (currentInv.Status == InvoiceStatus.SignedInv || currentInv.Status == InvoiceStatus.AdjustedInv || inv.Status == InvoiceStatus.InUseInv)
                    {
                        IList <ProductInv> products = new List <ProductInv>();
                        foreach (IProductInv ii in inv.Products)
                        {
                            products.Add((ProductInv)ii);
                        }
                        Launcher.Instance.PublishAdjust(currentInv, products, (InvoiceBase)inv, "");
                        invNumList += inv.Fkey ?? "";
                        ILogSystemService businessLog = IoC.Resolve <ILogSystemService>();
                        businessLog.WriteLogReplaceAdjust(comID, currentInv.Pattern, currentInv.Serial, currentInv.No, currentInv.PublishDate, currentInv.Amount, inv.Pattern, inv.Serial, inv.No, inv.PublishDate, inv.Amount, inv.CusName, inv.CusAddress, inv.CusCode, inv.CusTaxCode, HttpContext.Current.User.Identity.Name, BusinessLogType.Adjust);
                        businessLog.CommitChanges();
                    }
                    else
                    {
                        return("ERR:9 " + currentInv.Status);
                    }
                }
                catch (EInvoice.Core.Launching.NoFactory.OpenTranException ex)
                {
                    return("ERR:14");
                }
                catch (Exception ex)
                {
                    //iinvSrc.CommitTran();
                    log.Error("adjustInv err5: " + ex);
                    return("ERR:5 " + ex.Message);//loi phat hanh hoa don
                }
                //invNumList = invNumList.Remove(invNumList.Length - 1, 1);
                return("OK_" + invNumList);
            }
            catch (Exception ex)
            {
                log.Error("adjustInv " + ex);
                return("ERR:5 " + ex.Message);
            }
        }
Esempio n. 13
0
        public ActionResult CreateAdJustInv(string NewPattern, string NewSerial, string Pattern, string PubDatasource, string NoInv, string SerialNo, string type, HttpPostedFileBase FileUpload)
        {
            ICompanyService  _comSrv    = IoC.Resolve <ICompanyService>();
            Company          currentCom = _comSrv.Getbykey(((EInvoiceContext)FXContext.Current).CurrentCompany.id);
            ICustomerService _CusSvc    = IoC.Resolve <ICustomerService>();
            InvoiceBase      model      = (InvoiceBase)InvServiceFactory.NewInstance(NewPattern, currentCom.id);

            TryUpdateModelFromType(model.GetType(), model);
            model.Pattern = NewPattern;
            model.Serial  = NewSerial;
            model.ComID   = currentCom.id;
            IInvoiceService    IInvSrv = InvServiceFactory.GetService(Pattern, currentCom.id);
            IInvoice           inv     = IInvSrv.GetByNo(currentCom.id, Pattern, SerialNo, Convert.ToDecimal(NoInv));
            IList <ProductInv> lst     = (IList <ProductInv>)PubDatasource.DeserializeJSON <ProductInv>(typeof(IList <ProductInv>));

            if (lst.Count() == 0)
            {
                Messages.AddErrorFlashMessage(Resources.Message.MRequestProd);
                return(RedirectToAction("CreateAdJustInv", new { Pattern = Pattern, Serial = SerialNo, invNo = NoInv }));
            }
            try
            {
                var Typecus = (from c in _CusSvc.Query where c.Code == model.CusCode && c.CusType == 1 && c.ComID == currentCom.id select c.CusType).SingleOrDefault();
                if (Typecus == 0)
                {
                    model.CusSignStatus = cusSignStatus.NocusSignStatus;
                }
                else
                {
                    model.CusSignStatus = cusSignStatus.NoSignStatus;
                }
                if ((inv.Status == InvoiceStatus.SignedInv || inv.Status == InvoiceStatus.InUseInv || inv.Status == InvoiceStatus.AdjustedInv))// =1 hoa don dieu chinh
                {
                    if (lst != null && lst.Count > 0)
                    {
                        model.Products = (from pr in lst select pr as IProductInv).ToList();
                    }
                    string xmldata        = string.Empty;
                    string message        = string.Empty;
                    string resultLauncher = string.Empty;
                    model.Fkey = "";
                    model.id   = 0;
                    model.Type = (InvoiceType)Convert.ToInt32(type);
                    //save file and get path
                    string strPath = "";
                    if (FileUpload != null)
                    {
                        string fileext = (Path.GetExtension(FileUpload.FileName).Length > 1) ? Path.GetExtension(FileUpload.FileName).Substring(1) : "";
                        if (fileext.ToLower() == "docx" || fileext.ToLower() == "pdf" || fileext.ToLower() == "doc")
                        {
                            strPath = @"\RecordsInv\" + currentCom.id + @"\" + Pattern.Replace("/", "") + @"\" + SerialNo.Replace("/", "") + "_" + NoInv + "." + fileext;
                            string strFullPath = GetFullPathRecordsCancel(strPath);
                            FileUpload.SaveAs(strFullPath);
                        }
                    }
                    ILauncherService _launcher = IoC.Resolve(Type.GetType(currentCom.Config["LauncherType"])) as ILauncherService;
                    _launcher.PublishAdjust(inv, lst, model, strPath);
                    resultLauncher = _launcher.Message;
                    if (resultLauncher.Contains("OK:"))
                    {
                        Messages.AddFlashMessage("Điều chỉnh hóa đơn thành công.");
                    }
                    else
                    {
                        Messages.AddErrorFlashMessage(StringErrorService(resultLauncher));
                    }
                }
            }
            catch (Exception ex)
            {
                Messages.AddErrorFlashMessage("Có lỗi xảy ra, vui lòng thực hiện lại.");
                log.Error(" CreateAdJustInv -: " + ex);
            }
            return(RedirectToAction("AdjustInvIndex", new { pattern = Pattern, Serial = SerialNo }));
        }
 /// <summary>
 /// Fills Invoice object
 /// </summary>
 /// <param name="invoiceObject">The object to be filled</param>
 /// <param name="reader">The reader to use to fill a single object</param>
 protected void FillObject(InvoiceBase invoiceObject, SqlDataReader reader)
 {
     FillObject(invoiceObject, reader, 0);
 }
        /// <summary>
        /// Fills Invoice object
        /// </summary>
        /// <param name="invoiceObject">The object to be filled</param>
        /// <param name="reader">The reader to use to fill a single object</param>
        /// <param name="start">The ordinal position from which to start reading the reader</param>
        protected void FillObject(InvoiceBase invoiceObject, SqlDataReader reader, int start)
        {
            invoiceObject.Id         = reader.GetInt32(start + 0);
            invoiceObject.InvoiceId  = reader.GetString(start + 1);
            invoiceObject.CustomerId = reader.GetGuid(start + 2);
            invoiceObject.CompanyId  = reader.GetGuid(start + 3);
            invoiceObject.Amount     = reader.GetDouble(start + 4);
            if (!reader.IsDBNull(5))
            {
                invoiceObject.Tax = reader.GetDouble(start + 5);
            }
            if (!reader.IsDBNull(6))
            {
                invoiceObject.DiscountCode = reader.GetString(start + 6);
            }
            if (!reader.IsDBNull(7))
            {
                invoiceObject.DiscountAmount = reader.GetDouble(start + 7);
            }
            if (!reader.IsDBNull(8))
            {
                invoiceObject.TotalAmount = reader.GetDouble(start + 8);
            }
            invoiceObject.Status = reader.GetString(start + 9);
            if (!reader.IsDBNull(10))
            {
                invoiceObject.InvoiceDate = reader.GetDateTime(start + 10);
            }
            invoiceObject.CreatedDate = reader.GetDateTime(start + 11);
            invoiceObject.CreatedBy   = reader.GetString(start + 12);
            invoiceObject.IsEstimate  = reader.GetBoolean(start + 13);
            if (!reader.IsDBNull(14))
            {
                invoiceObject.IsBill = reader.GetBoolean(start + 14);
            }
            if (!reader.IsDBNull(15))
            {
                invoiceObject.BillingAddress = reader.GetString(start + 15);
            }
            if (!reader.IsDBNull(16))
            {
                invoiceObject.DueDate = reader.GetDateTime(start + 16);
            }
            if (!reader.IsDBNull(17))
            {
                invoiceObject.Terms = reader.GetString(start + 17);
            }
            if (!reader.IsDBNull(18))
            {
                invoiceObject.ShippingAddress = reader.GetString(start + 18);
            }
            if (!reader.IsDBNull(19))
            {
                invoiceObject.ShippingVia = reader.GetString(start + 19);
            }
            if (!reader.IsDBNull(20))
            {
                invoiceObject.ShippingDate = reader.GetDateTime(start + 20);
            }
            if (!reader.IsDBNull(21))
            {
                invoiceObject.TrackingNo = reader.GetString(start + 21);
            }
            if (!reader.IsDBNull(22))
            {
                invoiceObject.ShippingCost = reader.GetDouble(start + 22);
            }
            if (!reader.IsDBNull(23))
            {
                invoiceObject.Discountpercent = reader.GetDouble(start + 23);
            }
            if (!reader.IsDBNull(24))
            {
                invoiceObject.BalanceDue = reader.GetDouble(start + 24);
            }
            if (!reader.IsDBNull(25))
            {
                invoiceObject.Deposit = reader.GetDouble(start + 25);
            }
            if (!reader.IsDBNull(26))
            {
                invoiceObject.Message = reader.GetString(start + 26);
            }
            if (!reader.IsDBNull(27))
            {
                invoiceObject.TaxType = reader.GetString(start + 27);
            }
            if (!reader.IsDBNull(28))
            {
                invoiceObject.LastUpdatedDate = reader.GetDateTime(start + 28);
            }
            if (!reader.IsDBNull(29))
            {
                invoiceObject.Balance = reader.GetDouble(start + 29);
            }
            if (!reader.IsDBNull(30))
            {
                invoiceObject.Memo = reader.GetString(start + 30);
            }
            if (!reader.IsDBNull(31))
            {
                invoiceObject.InvoiceFor = reader.GetString(start + 31);
            }
            if (!reader.IsDBNull(32))
            {
                invoiceObject.LateFee = reader.GetDouble(start + 32);
            }
            if (!reader.IsDBNull(33))
            {
                invoiceObject.LateAmount = reader.GetDouble(start + 33);
            }
            if (!reader.IsDBNull(34))
            {
                invoiceObject.InstallDate = reader.GetDateTime(start + 34);
            }
            if (!reader.IsDBNull(35))
            {
                invoiceObject.Description = reader.GetString(start + 35);
            }
            if (!reader.IsDBNull(36))
            {
                invoiceObject.DiscountType = reader.GetString(start + 36);
            }
            if (!reader.IsDBNull(37))
            {
                invoiceObject.BillingCycle = reader.GetString(start + 37);
            }
            FillBaseObject(invoiceObject, reader, (start + 38));


            invoiceObject.RowState = BaseBusinessEntity.RowStateEnum.NormalRow;
        }
Esempio n. 16
0
 public void Test_InvoiceBase_Creation()
 {
     InvoiceBase baseInvoice = new InvoiceBase();
     Assert.That(baseInvoice.CreatedTime.HasValue);
     Assert.IsNotNull(baseInvoice);
 }