public bool addItem(int guestID, string itemName, string itemDesc, int itemQnty, decimal itemPrice)
        {
            PostCharge postCharge = null;
            var        tempCharge = _chargeGateway.findByGuestID(guestID).FirstOrDefault();

            if (tempCharge == null)
            {
                PaymentFactory factory = PaymentFactory.getInstance();
                postCharge = factory.createPayment(guestID: guestID, type: "PostCharge",
                                                   amount: itemPrice * itemQnty, status: "Pending", method: "");
                _chargeGateway.insert(postCharge);
            }
            else
            {
                postCharge = tempCharge;
            }

            var item = new ReceiptItem();

            item.Name        = itemName;
            item.Description = itemDesc;
            item.Quantity    = itemQnty;
            item.Price       = itemPrice;

            try {
                postCharge.ItemList.Add(item);
                _chargeGateway.update(postCharge);
                return(true);
            } catch (Exception e) {
                return(false);
            }
        }
Example #2
0
        private Attachment GetReceiptCard()
        {
            HabitatHomeService obj = new HabitatHomeService();
            var listtopProduct     = obj.MiniCart();
            var receiptItems       = new List <ReceiptItem>();

            foreach (Line topProduct in listtopProduct.Result.Lines)
            {
                var receiptItem = new ReceiptItem(
                    title: Truncate(topProduct.DisplayName, 15),
                    quantity: topProduct.Quantity,
                    price: topProduct.LinePrice,
                    image: new CardImage(StringConstants.HostUrl + topProduct.Image));

                receiptItems.Add(receiptItem);
            }
            var receiptCard = new ReceiptCard()
            {
                Title = Resources.ShowCartDialog_MiniCart_Title,
                Items = receiptItems,
                Tax   = listtopProduct.Result.TaxTotal,
                Total = listtopProduct.Result.Total
            };

            return(receiptCard.ToAttachment());
        }
        private Activity DisplayAccount(List <Account> accounts, Activity activity)
        {
            Activity replyToConversation = activity.CreateReply("");

            replyToConversation.Recipient   = activity.From;
            replyToConversation.Type        = "message";
            replyToConversation.Attachments = new List <Attachment>();
            List <ReceiptItem> items = new List <ReceiptItem>();

            decimal total = 0;

            foreach (Account acc in accounts)
            {
                total += acc.Value;
                ReceiptItem item = new ReceiptItem()
                {
                    Title    = acc.Name,
                    Subtitle = acc.Type,
                    Price    = acc.Value.ToString()
                };
                items.Add(item);
            }

            ReceiptCard Card = new ReceiptCard()
            {
                Title = "Accounts",
                Items = items,
                Total = total.ToString()
            };

            Attachment plAttachment = Card.ToAttachment();

            replyToConversation.Attachments.Add(plAttachment);
            return(replyToConversation);
        }
Example #4
0
        public async Task <IHttpActionResult> Put(int receiptItem_rId, int receiptItem_iId, Boolean isDeleted = true)
        {
            try
            {
                ReceiptItem receiptItem = await db.ReceiptItems
                                          .Where(ri => ri.receiptId == receiptItem_rId && ri.itemId == receiptItem_iId)
                                          .FirstOrDefaultAsync();

                if (receiptItem == null)
                {
                    return(BadRequest("ReceiptItem:" + receiptItem_rId + "/" + receiptItem_iId + " Not Found."));
                }

                receiptItem.isDeleted = isDeleted;

                try
                {
                    await db.SaveChangesAsync();
                }

                catch (DbUpdateConcurrencyException)
                {
                    throw;
                }
                finally
                {
                }
                return(Ok(receiptItem)); //Ok("Removed: " + receiptItem_rId + "/" + receiptItem_iId);
            }
            catch (Exception ex)
            {
                return(BadRequest("Error: " + ex.GetBaseException().Message));
            }
        }
Example #5
0
 public void AddOneToQuantityAndCostTest()
 {
     ReceiptItem testItem = new ReceiptItem("Orange", 0.70m);
     testItem.AddOneToQuantityAndCost();
     Assert.AreEqual(testItem.GetQuantity(), 2);
     Assert.AreEqual(2, testItem.GetQuantity());
 }
        private void AddOweAmount(IQueryable <OweRecord> oweRecords, ReceiptItem receiptItem, string projectId)
        {
            foreach (var user in receiptItem.Users)
            {
                var oweRecord = oweRecords
                                .FirstOrDefault(x => x.UserId == user.ApplicationUserId &&
                                                x.OwedUserId == _currentUserService.UserId);

                if (oweRecord == null)
                {
                    continue;
                }

                var transactions = _context.Transactions.Where(x => x.FinancialProjectId == projectId &&
                                                               x.FromUserId == user.ApplicationUserId &&
                                                               x.ToUserId == _currentUserService.UserId);

                AddOweRecordAmount(oweRecord, receiptItem);

                if (!transactions.Any())
                {
                    oweRecord.Amount *= -1;
                }
            }
        }
Example #7
0
    private void ConvertServiceOrderItemToReceiptItem(ServiceOrderItem serviceOrderItem)
    {
        var receiptItem = new ReceiptItem();

        receiptItem.CompanyId = Company.CompanyId;
        receiptItem.Quantity  = 1;

        if (serviceOrderItem.ProductId.HasValue)
        {
            receiptItem.ProductId   = serviceOrderItem.ProductId.Value;
            receiptItem.Description = serviceOrderItem.Product.Name;
            receiptItem.FiscalClass = serviceOrderItem.Product.FiscalClass;
            Inventory inventory = new InventoryManager(this).GetProductInventory(Company.CompanyId,
                                                                                 receiptItem.ProductId.Value,
                                                                                 Deposit.DepositId);
            receiptItem.UnitPrice = inventory != null
                                        ? inventory.UnitPrice
                                        : Decimal.Zero;
            AddReceiptItem(serviceOrderItem.Product, receiptItem);
        }
        else
        {
            receiptItem.UnitPrice   = serviceOrderItem.Price;
            receiptItem.ServiceId   = serviceOrderItem.ServiceId.Value;
            receiptItem.Description = serviceOrderItem.Service.Name;
            AddReceiptItem(serviceOrderItem.Service, receiptItem);
        }
    }
Example #8
0
        //Delete ReceiptItem
        public async Task <IHttpActionResult> Delete(int receiptItem_rId, int receiptItem_iId)
        {
            try
            {
                ReceiptItem receiptItem = await db.ReceiptItems
                                          .Where(ri => ri.receiptId.Equals(receiptItem_rId) && ri.itemId.Equals(receiptItem_iId))
                                          .FirstOrDefaultAsync();

                if (receiptItem == null)
                {
                    return(BadRequest("ReceiptItem:" + receiptItem_rId + "/" + receiptItem_iId + " Not Found."));
                }

                db.Entry(receiptItem).State = EntityState.Deleted;
                try
                {
                    await db.SaveChangesAsync();
                }

                catch (DbUpdateConcurrencyException)
                {
                    throw;
                }
                finally {
                }
                return(Ok("deleted: " + receiptItem_rId + "/" + receiptItem_iId));
            }
            catch (Exception ex)
            {
                return(BadRequest("Error: " + ex.GetBaseException().Message));
            }
        }
Example #9
0
    private void AddReceiptItem(Product product, ReceiptItem receiptItem)
    {
        String productName = String.Empty;

        if (receiptItem.ProductId.HasValue)
        {
            product = ProductManager.GetProduct(receiptItem.ProductId.Value, Company.CompanyId);
        }

        if (product != null)
        {
            receiptItem.ICMS = product.ICMS;
            receiptItem.IPI  = product.IPI;
            productName      = product.Name;
        }

        var productItem = new ReceiptItem();

        productItem.ReceiptItemId = receiptItem.ReceiptItemId;
        productItem.ReceiptId     = receiptItem.ReceiptId;
        productItem.UnitPrice     = receiptItem.UnitPrice;
        productItem.Quantity      = Convert.ToInt32(receiptItem.Quantity);
        productItem.IPI           = receiptItem.IPI;
        productItem.ICMS          = receiptItem.ICMS;
        productItem.ProductId     = receiptItem.ProductId;
        productItem.Description   = !String.IsNullOrEmpty(productName)
                                      ? productName
                                      : receiptItem.Description;
        ReceiptItems.Add(productItem);

        CalculateTotal(GetReceiptItemTotalValue(productItem, 1));
    }
        public void ReceiptItemInitsWithNoArgs()
        {
            var receiptItems = new ReceiptItem();

            Assert.NotNull(receiptItems);
            Assert.IsType <ReceiptItem>(receiptItems);
        }
Example #11
0
        public ReceiptItem ToReceiptItem()
        {
            var item = new ReceiptItem()
            {
                Discount                = DiscountValue,
                FullPrice               = FullPrice,
                Id                      = Guid.NewGuid(),
                ProductBarcode          = Barcode,
                ProductId               = Id,
                ProductName             = Name,
                ProductPrice            = Price,
                ProductWeight           = (int)Math.Round(Weight, MidpointRounding.AwayFromZero),
                ProductCalculatedWeight = (int)Math.Round(CalculatedWeight, MidpointRounding.AwayFromZero),
                ProductQuantity         = ProductWeightType == ProductWeightType.ByWeight ? (decimal)Weight / 1000M : Quantity,
                ProductWeightType       = ProductWeightType,
                TaxGroup                = TaxGroup,
                RefundedQuantity        = RefundedQuantity,
                Uktzed                  = Uktzed,
                IsUktzedNeedToPrint     = IsUktzedNeedToPrint,
                Excises                 = Excises
            };

            item.TotalPrice = item.FullPrice - item.Discount;

            return(item);
        }
Example #12
0
        internal static IEnumerable <ReceiptItem> CreateReceiptItemSetWithOneItemThatHasSetProperties(string title = default(string), string subtitle = default(string), string text = default(string), CardImage image = default(CardImage), string price = default(string), string quantity = default(string), CardAction tap = default(CardAction))
        {
            var matchingItem = new ReceiptItem(title, subtitle, text, image, price, quantity, tap);
            var items        = CreateRandomReceiptItems();

            items.Add(matchingItem);
            return(items);
        }
        private List <ApplicationUserReceiptItem> GetUserToRemove(ReceiptItem entity, List <UserDto> userDtos)
        {
            var usersToRemove = entity.Users
                                .Where(x => userDtos.All(y => y.Id != x.ApplicationUserId))
                                .ToList();

            return(usersToRemove);
        }
Example #14
0
 public CardImageAssertions(ReceiptItem receiptItem) : this()
 {
     if (receiptItem == null)
     {
         throw new ArgumentNullException(nameof(receiptItem));
     }
     _cardImage = receiptItem.Image;
 }
        public void Setup()
        {
            m_Item = new ReceiptItem(1,
                                     "Test",
                                     2.0);

            m_Sut = new ReceiptItemList();
        }
        private void SubtractReceiptItemCostForSameUsers(List <OweRecord> records, ReceiptItem entity,
                                                         UpdateReceiptItemCommand request)
        {
            var sameUsers = entity.Users.Select(x => x.ApplicationUserId).ToList()
                            .Intersect(request.UserDtos.Select(x => x.Id)).ToList();

            records.SubtractReceiptItemCost(sameUsers !, entity.Price, entity.Count, entity.Users.Count);
        }
Example #17
0
        /// <summary>
        /// Removes a given contact from the repo.
        /// </summary>
        /// <param name="contact">Contact to remove.</param>
        public void Remove(ReceiptItem receiptItem)
        {
            using (var context = new MysqlContext())
            {
                context.Entry(receiptItem).State = EntityState.Deleted;

                context.SaveChanges();
            }
        }
        public ActionResult CreateReceiptItems([Bind(Prefix = "updated")] List <ReceiptItemModel> updatedItems,
                                               [Bind(Prefix = "created")] List <ReceiptItemModel> createdItems,
                                               [Bind(Prefix = "deleted")] List <ReceiptItemModel> deletedItems)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    //Create ReceiptItems
                    if (updatedItems != null)
                    {
                        //get the current receipt
                        var receiptId    = updatedItems.Count > 0 ? updatedItems[0].ReceiptId : 0;
                        var receiptItems = _receiptItemRepository.GetAll().Where(r => r.ReceiptId == receiptId).ToList();
                        foreach (var model in updatedItems)
                        {
                            //we don't merge if the receipt item already existed
                            if (!receiptItems.Any(r => r.ItemId == model.ItemId))
                            {
                                //manually mapping here to set only foreign key
                                //if used AutoMapper, the reference property will also be mapped
                                //and EF will consider these properties as new and insert it
                                //so db records will be duplicated
                                //we can also ignore it in AutoMapper configuation instead of manually mapping
                                var receiptItem = new ReceiptItem
                                {
                                    ReceiptId              = model.ReceiptId,
                                    StoreLocatorId         = model.StoreLocator.Id,
                                    ItemId                 = model.ItemId,
                                    ReceiptUnitOfMeasureId = model.ReceiptUnitOfMeasureId,
                                    ReceiptQuantity        = model.ReceiptQuantity,
                                    ReceiptUnitPrice       = model.ReceiptUnitPrice,
                                    UnitPrice              = model.ReceiptUnitPrice,
                                    Quantity               = model.ReceiptQuantity,
                                    LotNumber              = model.LotNumber,
                                    ExpiryDate             = model.ExpiryDate
                                };
                                receiptItem.Cost = receiptItem.UnitPrice * receiptItem.Quantity;
                                _receiptItemRepository.Insert(receiptItem);
                            }
                        }
                    }

                    _dbContext.SaveChanges();
                    SuccessNotification(_localizationService.GetResource("Record.Saved"));
                    return(new NullJsonResult());
                }
                catch (Exception e)
                {
                    return(Json(new { Errors = e.Message }));
                }
            }
            else
            {
                return(Json(new { Errors = ModelState.SerializeErrors() }));
            }
        }
Example #19
0
        public void WithCardImage_should_return_CardImageAssertions()
        {
            var cardImage   = new CardImage();
            var receiptItem = new ReceiptItem(image: cardImage);

            var sut = new ReceiptItemAssertions(receiptItem);

            sut.WithCardImage().Should().BeAssignableTo <CardImageAssertions>().And.NotBeNull();
        }
Example #20
0
        public void WithTapAction_should_return_CardActionAssertions()
        {
            var tap         = new CardAction();
            var receiptItem = new ReceiptItem(tap: tap);

            var sut = new ReceiptItemAssertions(receiptItem);

            sut.WithTapAction().Should().BeAssignableTo <CardActionAssertions>().And.NotBeNull();
        }
Example #21
0
        /// <summary>
        /// Adds a new contact to the repo.
        /// </summary>
        /// <param name="contact">Contact to add.</param>
        public void Add(ReceiptItem receiptItem)
        {
            using (var context = new MysqlContext())
            {
                context.ReceiptItems.Add(receiptItem);

                context.SaveChanges();
            }
        }
Example #22
0
        /// <summary>
        /// Tries to store (persist) data about a given contact.
        /// </summary>
        /// <param name="contact">Contact to be persisted in the repo.</param>
        public void Store(ReceiptItem receiptItem)
        {
            using (var context = new MysqlContext())
            {
                context.Entry(receiptItem).State = ((receiptItem.ID == 0) ? (EntityState.Added) : (EntityState.Modified));

                context.SaveChanges();
            }
        }
Example #23
0
        public void WithPriceMatching_should_throw_ReceiptItemAssertionFailedException_for_non_matching_regexes(string itemPrice, string regex)
        {
            var receiptItem = new ReceiptItem(price: itemPrice);

            var sut = new ReceiptItemAssertions(receiptItem);

            Action act = () => sut.PriceMatching(regex);

            act.ShouldThrow <ReceiptItemAssertionFailedException>();
        }
Example #24
0
        public void WithPriceMatching_should_pass_regardless_of_case(string itemPrice, string regex)
        {
            var receiptItem = new ReceiptItem(price: itemPrice);

            var sut = new ReceiptItemAssertions(receiptItem);

            Action act = () => sut.PriceMatching(regex);

            act.ShouldNotThrow <Exception>();
        }
Example #25
0
        public void WithPriceMatching_should_pass_when_using_standard_regex_features(string itemPrice, string regex)
        {
            var receiptItem = new ReceiptItem(price: itemPrice);

            var sut = new ReceiptItemAssertions(receiptItem);

            Action act = () => sut.PriceMatching(regex);

            act.ShouldNotThrow <Exception>();
        }
Example #26
0
        public void WithPriceMatching_should_throw_ArgumentNullException_if_regex_is_null()
        {
            var item = new ReceiptItem();

            var sut = new ReceiptItemAssertions(item);

            Action act = () => sut.PriceMatching(null);

            act.ShouldThrow <ArgumentNullException>();
        }
Example #27
0
        public void WithPriceMatching_should_pass_if_regex_exactly_matches_message_Price(string itemPriceAndRegex)
        {
            var receiptItem = new ReceiptItem(price: itemPriceAndRegex);

            var sut = new ReceiptItemAssertions(receiptItem);

            Action act = () => sut.PriceMatching(itemPriceAndRegex);

            act.ShouldNotThrow <Exception>();
        }
Example #28
0
            private static List <ReceiptItem> Convert(List <ItemDto> dtos, Guid receiptId)
            {
                var result = new List <ReceiptItem>();

                foreach (var dto in dtos)
                {
                    result.Add(ReceiptItem.CreateNew(receiptId, dto.Label, dto.Price, dto.Quantity, dto.Amount, dto.Vat));
                }
                return(result);
            }
Example #29
0
        public void WithPriceMatching_should_throw_ReceiptItemAssertionFailedException_when_price_is_null()
        {
            var item = new ReceiptItem();

            var sut = new ReceiptItemAssertions(item);

            Action act = () => sut.PriceMatching("anything");

            act.ShouldThrow <ReceiptItemAssertionFailedException>();
        }
Example #30
0
        public void WithQuantityMatching_should_throw_ReceiptItemAssertionFailedException_for_non_matching_regexes(string itemQuantity, string regex)
        {
            var receiptItem = new ReceiptItem(quantity: itemQuantity);

            var sut = new ReceiptItemAssertions(receiptItem);

            Action act = () => sut.QuantityMatching(regex);

            act.ShouldThrow <ReceiptItemAssertionFailedException>();
        }
    protected void btnReceipItemProduct_Click(object sender, ImageClickEventArgs e)
    {
        // 
        // Popula o receiptItem 
        //
        Inventory inventory;
        Decimal icms = 0, ipi = 0;
        Product product = SelProductAndService.Product;
        Service service = SelProductAndService.Service;
        var receiptItem = new ReceiptItem();

        if (ucCurrFieldIPI.CurrencyValue.HasValue)
            ipi = ucCurrFieldIPI.CurrencyValue.Value;

        if (ucCurrFieldICMS.CurrencyValue.HasValue)
            icms = ucCurrFieldICMS.CurrencyValue.Value;

        receiptItem.ICMS = icms;
        receiptItem.IPI = ipi;
        receiptItem.Description = SelProductAndService.Name;
        receiptItem.UnitPrice = ucCurrFieldUnitPrice.CurrencyValue;

        if (ucCurrFieldProductQuantity.IntValue != 0)
            receiptItem.Quantity = ucCurrFieldProductQuantity.IntValue;
        else
        {
            ShowError("Quantidade não pode ser zero!");
            return;
        }

        if (product != null)
        {
            receiptItem.ProductId = product.ProductId;
            receiptItem.Description = product.Name;
            if (!ucCurrFieldUnitPrice.CurrencyValue.HasValue)
            {
                inventory = InventoryManager.GetInventory(Company.CompanyId, product.ProductId, Deposit.DepositId);
                if (inventory != null)
                    receiptItem.UnitPrice = inventory.UnitPrice;
            }
        }
        else if (service != null)
        {
            receiptItem.ServiceId = service.ServiceId;
            receiptItem.Description = service.Name;
            if (!ucCurrFieldUnitPrice.CurrencyValue.HasValue)
                receiptItem.UnitPrice = service.Price;
        }

        //
        // Adiciona na Lista que está em memória
        // OBS: Ainda não foi para o banco de dados
        //
        ReceiptItems.Add(receiptItem);

        CalculateTotal(GetReceiptItemTotalValue(receiptItem, 1));

        BindReceiptItems();

        //
        // Limpar os campos de produto
        //
        ucCurrFieldProductQuantity.Text = String.Empty;
        ucCurrFieldUnitPrice.Text = String.Empty;
        ucCurrFieldIPI.Text = String.Empty;
        ucCurrFieldICMS.Text = String.Empty;
    }
 /// <summary>
 /// this function fill the ReceiptItem and return this
 /// </summary>
 /// <param name="receiptId"></param>
 /// <param name="receiptItemRow"></param>
 /// <returns></returns>
 private ReceiptItem SetReceiptItemValues(Int32 receiptId, ReceiptItem item)
 {
     var receiptItem = new ReceiptItem();
     receiptItem.CompanyId = Company.CompanyId;
     receiptItem.Description = item.Description;
     receiptItem.ReceiptId = receiptId;
     receiptItem.ServiceId = item.ServiceId;
     receiptItem.ProductId = item.ProductId;
     receiptItem.FiscalClass = item.FiscalClass;
     receiptItem.Quantity = item.Quantity;
     receiptItem.UnitPrice = item.UnitPrice;
     receiptItem.IPI = item.IPI;
     receiptItem.ICMS = item.ICMS;
     return receiptItem;
 }
    /// <summary>
    /// Calcula o valor total de uma linha da Grid
    /// </summary>
    /// <param name="receiptItem"></param>
    /// <returns></returns>
    private decimal GetReceiptItemTotalValue(ReceiptItem receiptItem, int factor)
    {
        Decimal icmsValue = Decimal.Zero;
        Decimal totalProductValue = Convert.ToDecimal(receiptItem.UnitPrice * receiptItem.Quantity);
        Decimal ipiValue = 0;

        if (receiptItem.ICMS > decimal.Zero)
            icmsValue = Convert.ToDecimal(totalProductValue * (receiptItem.ICMS / 100));

        if (receiptItem.IPI > decimal.Zero)
            ipiValue = Convert.ToDecimal(totalProductValue * (receiptItem.IPI / 100));

        if (!ucCurrFieldIPITotalValue.CurrencyValue.HasValue)
            ucCurrFieldIPITotalValue.CurrencyValue = 0;

        ucCurrFieldIPITotalValue.CurrencyValue += ipiValue * factor;

        if (!ucCurrFieldICMSValue.CurrencyValue.HasValue)
            ucCurrFieldICMSValue.CurrencyValue = 0;

        ucCurrFieldICMSValue.CurrencyValue += icmsValue * factor;

        if (!ucCurrFieldTotalProductValue.CurrencyValue.HasValue)
            ucCurrFieldTotalProductValue.CurrencyValue = decimal.Zero;

        ucCurrFieldTotalProductValue.CurrencyValue += totalProductValue * factor;

        return totalProductValue;
    }
    private void AddReceiptItem(Service service, ReceiptItem receiptItem)
    {
        var serviceItem = new ReceiptItem();
        serviceItem.ReceiptItemId = receiptItem.ReceiptItemId;
        serviceItem.CompanyId = receiptItem.CompanyId;
        serviceItem.ServiceId = receiptItem.ServiceId;
        serviceItem.UnitPrice = receiptItem.UnitPrice;
        serviceItem.Quantity = 1;
        serviceItem.ProductId = receiptItem.ProductId;
        serviceItem.IPI = receiptItem.IPI;
        serviceItem.ICMS = receiptItem.ICMS;
        serviceItem.Description = !String.IsNullOrEmpty(service.Name)
                                      ? service.Name
                                      : receiptItem.Description;
        ReceiptItems.Add(serviceItem);

        CalculateTotal(GetReceiptItemTotalValue(serviceItem, 1));
    }
    private void AddReceiptItem(Product product, ReceiptItem receiptItem)
    {
        String productName = String.Empty;

        if (receiptItem.ProductId.HasValue)
            product = ProductManager.GetProduct(receiptItem.ProductId.Value, Company.CompanyId);

        if (product != null)
        {
            receiptItem.ICMS = product.ICMS;
            receiptItem.IPI = product.IPI;
            productName = product.Name;
        }

        var productItem = new ReceiptItem();
        productItem.ReceiptItemId = receiptItem.ReceiptItemId;
        productItem.ReceiptId = receiptItem.ReceiptId;
        productItem.UnitPrice = receiptItem.UnitPrice;
        productItem.Quantity = Convert.ToInt32(receiptItem.Quantity);
        productItem.IPI = receiptItem.IPI;
        productItem.ICMS = receiptItem.ICMS;
        productItem.ProductId = receiptItem.ProductId;
        productItem.Description = !String.IsNullOrEmpty(productName)
                                      ? productName
                                      : receiptItem.Description;
        ReceiptItems.Add(productItem);

        CalculateTotal(GetReceiptItemTotalValue(productItem, 1));
    }
    private void ConvertServiceOrderItemToReceiptItem(ServiceOrderItem serviceOrderItem)
    {
        var receiptItem = new ReceiptItem();

        receiptItem.CompanyId = Company.CompanyId;
        receiptItem.Quantity = 1;

        if (serviceOrderItem.ProductId.HasValue)
        {
            receiptItem.ProductId = serviceOrderItem.ProductId.Value;
            receiptItem.Description = serviceOrderItem.Product.Name;
            receiptItem.FiscalClass = serviceOrderItem.Product.FiscalClass;
            Inventory inventory = new InventoryManager(this).GetProductInventory(Company.CompanyId,
                                                                                 receiptItem.ProductId.Value,
                                                                                 Deposit.DepositId);
            receiptItem.UnitPrice = inventory != null
                                        ? inventory.UnitPrice
                                        : Decimal.Zero;
            AddReceiptItem(serviceOrderItem.Product, receiptItem);
        }
        else
        {
            receiptItem.UnitPrice = serviceOrderItem.Price; 
            receiptItem.ServiceId = serviceOrderItem.ServiceId.Value;
            receiptItem.Description = serviceOrderItem.Service.Name;
            AddReceiptItem(serviceOrderItem.Service, receiptItem);
        }
    }
    private void LoadSale(Int32 saleId)
    {
        Sale sale = new SaleManager(this).GetSale(
            Company.MatrixId.HasValue
                ? Company.MatrixId.Value
                : Company.CompanyId, saleId);
        LstSale.Add(sale.SaleId);

        ReceiptItem receiptItem;
        foreach (SaleItem item in sale.SaleItems)
        {
            receiptItem = new ReceiptItem
                          {
                              Quantity = Convert.ToInt32(item.Quantity),
                              UnitPrice = item.UnitPrice,
                              Description = item.SpecialProductName
                          };

            if (item.ProductId.HasValue)
            {
                receiptItem.ProductId = item.ProductId;
                receiptItem.IPI = item.Product.IPI;
                receiptItem.ICMS = item.Product.ICMS;
                receiptItem.Description = item.Product.Name;

            }
            AddReceiptItem(item.Product, receiptItem);

        }

        SelCustomer.ShowCustomer(sale.Customer);

        ///set discount of sale as otherValues
        ///change the sign because the discount is default
        ucCurrFieldOthersChargesValue.CurrencyValue += sale.Discount;

        BindReceiptItems();
    }