/// <summary>
        /// Method which creates QuoteLines for automated quote
        /// </summary>
        /// <param name="package">Details of the package</param>
        /// <param name="quoteId">Quote ID</param>
        public void CreateQuoteLinesForAutomatedQuote(CheckPackageReturnHelper package, int quoteId)
        {
            var service   = _db.Services.First(s => s.ServiceId == package.ServiceId);
            var documents = _db.Services.First(s => s.ServiceId == package.DocumentServiceId);

            // Add package QuoteLine
            _db.QuoteLines.Add(new QuoteLine
            {
                RelatedQuoteId   = quoteId,
                LineNumber       = CheckQuoteLineNumber(quoteId),
                RelatedServiceId = package.ServiceId,
                LineText         = service.ServiceName,
                Quantity         = 1,
                BaseAmount       = service.BasePrice,
                Discount         = 0,
                Price            = package.Price,
                LineTotal        = package.Price,
                InsertDate       = DateTime.Now
            });
            _db.SaveChanges();

            // Add documents QuoteLine
            _db.QuoteLines.Add(new QuoteLine
            {
                RelatedQuoteId   = quoteId,
                LineNumber       = CheckQuoteLineNumber(quoteId),
                RelatedServiceId = package.DocumentServiceId,
                LineText         = documents.ServiceName,
                Quantity         = package.InvoiceQuantity,
                BaseAmount       = documents.BasePrice,
                Discount         = 0,
                Price            = 0,
                LineTotal        = 0,
                InsertDate       = DateTime.Now
            });
            _db.SaveChanges();

            // Add archive QuoteLine
            _db.QuoteLines.Add(new QuoteLine
            {
                RelatedQuoteId   = quoteId,
                LineNumber       = CheckQuoteLineNumber(quoteId),
                RelatedServiceId = 31,
                LineText         = "Uključena arhiva",
                Quantity         = package.InvoiceQuantity,
                BaseAmount       = 0,
                Discount         = 0,
                Price            = package.ArchivePrice,
                LineTotal        = package.ArchivePrice,
                InsertDate       = DateTime.Now
            });
            _db.SaveChanges();

            // Add acquire email base QuoteLine
            _db.QuoteLines.Add(new QuoteLine
            {
                RelatedQuoteId   = quoteId,
                LineNumber       = CheckQuoteLineNumber(quoteId),
                RelatedServiceId = 37,
                LineText         = "Prikupljanje e-mail adresa za dostavu obavijesti o poslanim eRačunima. Prikup obavlja pozivni centar tvrtke Elektronički računi d.o.o. te ovisno o potrebi informira vaše kupce na temu eRačuna. Naplata se vrši nakon odrađene obrade po razredima, ovisno o broju subjekata u bazi kupaca kako je niže navedeno.",
                Quantity         = 1,
                BaseAmount       = 1,
                Discount         = 0,
                Price            = 0,
                LineTotal        = 0,
                InsertDate       = DateTime.Now
            });
            _db.SaveChanges();

            UpdateQuoteSum(quoteId);
        }
        public CheckPackageReturnHelper CheckPackage(string input, int documentsOption, int?documentNumber)
        {
            int     invoiceQuantity    = 0;
            int     serviceId          = 0;
            int     documentsServiceId = 0;
            decimal price        = 0;
            decimal archivePrice = 0;

            //Define whether contract has eInvoices or eDocuments included
            switch (documentsOption)
            {
            case 1:
                documentsServiceId = 5;
                break;

            case 2:
                documentsServiceId = 28;
                break;

            case 3:
                documentsServiceId = 1;
                break;

            default:
                break;
            }

            if (input.Contains(@"PREPAID"))
            {
                documentsServiceId = 4;

                if (input.StartsWith("BASIC"))
                {
                    invoiceQuantity = documentNumber != null ? (int)documentNumber : 0;
                    serviceId       = 23;
                    price           = 49;
                    archivePrice    = (decimal)0.49;
                }
                else if (input.StartsWith("BUSINESS"))
                {
                    invoiceQuantity = documentNumber != null ? (int)documentNumber : 0;
                    serviceId       = 23;
                    price           = 149;
                    archivePrice    = (decimal)0.39;
                }
                else if (input.StartsWith("premium"))
                {
                    invoiceQuantity = documentNumber != null ? (int)documentNumber : 0;
                    serviceId       = 24;
                    price           = 399;
                    archivePrice    = 0;
                }
            }
            else
            {
                if (input.StartsWith("BASIC MICRO"))
                {
                    invoiceQuantity = Int32.Parse(input.Substring(12));
                    serviceId       = 15;

                    switch (invoiceQuantity)
                    {
                    case 10:
                        price        = 39;
                        archivePrice = 5;
                        break;

                    case 20:
                        price        = 59;
                        archivePrice = 10;
                        break;

                    case 50:
                        price        = 119;
                        archivePrice = 25;
                        break;

                    case 75:
                        price        = 169;
                        archivePrice = 37;
                        break;

                    case 100:
                        price        = 219;
                        archivePrice = 49;
                        break;

                    case 150:
                        price        = 329;
                        archivePrice = 69;
                        break;

                    default:
                        break;
                    }
                }
                else if (input.StartsWith("BASIC"))
                {
                    invoiceQuantity = Int32.Parse(input.Substring(6));
                    serviceId       = 16;

                    switch (invoiceQuantity)
                    {
                    case 250:
                        price        = 549;
                        archivePrice = 119;
                        break;

                    case 350:
                        price        = 769;
                        archivePrice = 139;
                        break;

                    case 450:
                        price        = 989;
                        archivePrice = 209;
                        break;

                    case 600:
                        price        = 1319;
                        archivePrice = 279;
                        break;

                    default:
                        break;
                    }
                }
                else if (input.StartsWith("BUSINESS"))
                {
                    invoiceQuantity = 0;
                    serviceId       = 17;

                    price        = 149;
                    archivePrice = (decimal)0.39;
                }
            }

            CheckPackageReturnHelper returnData = new CheckPackageReturnHelper()
            {
                InvoiceQuantity   = invoiceQuantity,
                ServiceId         = serviceId,
                Price             = price,
                ArchivePrice      = archivePrice,
                DocumentServiceId = documentsServiceId
            };

            return(returnData);
        }
        /// <summary>
        /// Method for defining package based on the number of invoices stated by the user
        /// </summary>
        /// <param name="invoiceNumber">Nuber of invoices</param>
        /// <returns>CheckPackageReturnHelper with information on the package</returns>
        public CheckPackageReturnHelper DefinePackage(int invoiceNumber)
        {
            var returnModel = new CheckPackageReturnHelper();

            if (invoiceNumber >= 600)
            {
                returnModel.InvoiceQuantity   = 600;
                returnModel.ServiceId         = 16;
                returnModel.Price             = 1319;
                returnModel.ArchivePrice      = 279;
                returnModel.DocumentServiceId = 28;
            }
            else if (invoiceNumber >= 450 && invoiceNumber < 600)
            {
                returnModel.InvoiceQuantity   = 450;
                returnModel.ServiceId         = 16;
                returnModel.Price             = 989;
                returnModel.ArchivePrice      = 209;
                returnModel.DocumentServiceId = 28;
            }
            else if (invoiceNumber >= 350 && invoiceNumber < 450)
            {
                returnModel.InvoiceQuantity   = 350;
                returnModel.ServiceId         = 16;
                returnModel.Price             = 769;
                returnModel.ArchivePrice      = 139;
                returnModel.DocumentServiceId = 28;
            }
            else if (invoiceNumber >= 250 && invoiceNumber < 350)
            {
                returnModel.InvoiceQuantity   = 250;
                returnModel.ServiceId         = 16;
                returnModel.Price             = 549;
                returnModel.ArchivePrice      = 119;
                returnModel.DocumentServiceId = 28;
            }
            else if (invoiceNumber >= 150 && invoiceNumber < 250)
            {
                returnModel.InvoiceQuantity   = 150;
                returnModel.ServiceId         = 15;
                returnModel.Price             = 329;
                returnModel.ArchivePrice      = 69;
                returnModel.DocumentServiceId = 28;
            }
            else if (invoiceNumber >= 100 && invoiceNumber < 150)
            {
                returnModel.InvoiceQuantity   = 100;
                returnModel.ServiceId         = 15;
                returnModel.Price             = 219;
                returnModel.ArchivePrice      = 49;
                returnModel.DocumentServiceId = 28;
            }
            else if (invoiceNumber >= 75 && invoiceNumber < 100)
            {
                returnModel.InvoiceQuantity   = 75;
                returnModel.ServiceId         = 15;
                returnModel.Price             = 169;
                returnModel.ArchivePrice      = 37;
                returnModel.DocumentServiceId = 28;
            }
            else if (invoiceNumber >= 50 && invoiceNumber < 75)
            {
                returnModel.InvoiceQuantity   = 50;
                returnModel.ServiceId         = 15;
                returnModel.Price             = 119;
                returnModel.ArchivePrice      = 25;
                returnModel.DocumentServiceId = 28;
            }
            else if (invoiceNumber >= 20 && invoiceNumber < 50)
            {
                returnModel.InvoiceQuantity   = 20;
                returnModel.ServiceId         = 15;
                returnModel.Price             = 59;
                returnModel.ArchivePrice      = 10;
                returnModel.DocumentServiceId = 28;
            }
            else if (invoiceNumber < 20)
            {
                returnModel.InvoiceQuantity   = 10;
                returnModel.ServiceId         = 15;
                returnModel.Price             = 39;
                returnModel.ArchivePrice      = 5;
                returnModel.DocumentServiceId = 28;
            }

            return(returnModel);
        }
Ejemplo n.º 4
0
        public CheckPackageReturnHelper CheckPackage(string input, int documentsOption)
        {
            int     invoiceQuantity    = 0;
            int     serviceId          = 0;
            int     documentsServiceId = 0;
            decimal price        = 0;
            decimal archivePrice = 0;

            //Define whether contract has eInvoices or eDocuments included
            switch (documentsOption)
            {
            case 1:
                documentsServiceId = 5;
                break;

            case 2:
                documentsServiceId = 28;
                break;

            default:
                break;
            }

            if (input.StartsWith("BASIC MICRO"))
            {
                invoiceQuantity = Int32.Parse(input.Substring(12));
                serviceId       = 15;

                switch (invoiceQuantity)
                {
                case 20:
                    price        = 59;
                    archivePrice = 10;
                    break;

                case 50:
                    price        = 119;
                    archivePrice = 25;
                    break;

                case 75:
                    price        = 169;
                    archivePrice = 37;
                    break;

                case 100:
                    price        = 219;
                    archivePrice = 49;
                    break;

                case 150:
                    price        = 329;
                    archivePrice = 69;
                    break;

                default:
                    break;
                }
            }
            else if (input.StartsWith("BASIC"))
            {
                invoiceQuantity = Int32.Parse(input.Substring(6));
                serviceId       = 16;

                switch (invoiceQuantity)
                {
                case 250:
                    price        = 549;
                    archivePrice = 119;
                    break;

                case 350:
                    price        = 769;
                    archivePrice = 139;
                    break;

                case 450:
                    price        = 989;
                    archivePrice = 209;
                    break;

                case 600:
                    price        = 1319;
                    archivePrice = 279;
                    break;

                default:
                    break;
                }
            }

            CheckPackageReturnHelper returnData = new CheckPackageReturnHelper()
            {
                InvoiceQuantity   = invoiceQuantity,
                ServiceId         = serviceId,
                Price             = price,
                ArchivePrice      = archivePrice,
                DocumentServiceId = documentsServiceId
            };

            return(returnData);
        }