예제 #1
0
        private EnterEquipmentQuote GetEquipmentQuote_Model(string QuoteRef)
        {
            if (string.IsNullOrEmpty(QuoteRef))
            {
                return(null);
            }
            else
            {
                EWS.Domain.Data.DataModel.Quote quote = GetExistingQuote(QuoteRef);
                if (quote != null)
                {
                    return(GetEquipmentQuote_Model(quote));
                }
                else
                {
                    Domain.Model.SourceQuote sourcequote = GetSourceQuote(QuoteRef);
                    if (sourcequote == null)
                    {
                        return(null);
                    }
                    else
                    {
                        EnterEquipmentQuote model = new EnterEquipmentQuote();

                        model.QuoteRef = QuoteRef;

                        DeviceQuery query = new Domain.Data.Queries.DeviceQuery()
                        {
                            DeviceID = sourcequote.DeviceID
                        };
                        model.Device = _queryProcessor.Execute(query);

                        model.TenderNumber        = sourcequote.TenderNumber;
                        model.VAT                 = sourcequote.VAT;
                        model.SellingPriceExclVAT = sourcequote.SellingPriceInclVAT / Convert.ToDecimal(1 + sourcequote.VAT / 100);
                        model.SellingPriceInclVAT = sourcequote.SellingPriceInclVAT;

                        model.ContractCalculations = GetNewEquipmentContractCalculationModels(model.SellingPriceExclVAT);


                        if (quote == null)   // fill in from source quote:
                        {
                            // Exchange Rate
                            CurrencyQuery cquery = new CurrencyQuery()
                            {
                                ID = "USD"
                            };
                            Domain.Data.DataModel.Currency usd = _queryProcessor.Execute(cquery);

                            model.ExchangeRate = new ExchangeRate()
                            {
                                Rate = Convert.ToDecimal(usd.DefaultRateOfExchange),
                                Date = DateTime.Today
                            };
                        }
                        return(model);
                    }
                }
            }
        } //GetEquipmentQuote_Model
예제 #2
0
        public string SaveQuote(EnterEquipmentQuote model)
        {
            try
            {
                QuoteSaveCommand cmd1 = new QuoteSaveCommand()
                {
                    ID           = model.QuoteID,
                    CustomerID   = model.Customer.Id,
                    DeviceID     = model.Device.Id,
                    TenderNo     = model.TenderNumber,
                    QuoteRef     = model.QuoteRef,
                    SellingPrice = model.SellingPriceExclVAT,
                    ROE          = model.ExchangeRate.Rate,
                    ROEDate      = model.ExchangeRate.Date,
                    VAT          = model.VAT,
                    ContractTerm = model.NoOfMonths,
                    Deleted      = false
                };
                _commandProcessor.Execute(cmd1);

                model.QuoteID = cmd1.ID;

                SaveQuoteCalculation(model.ContractCalculations, model.QuoteID);

                return(string.Empty);
            }
            catch (Exception ex)
            {
                return("Save was unsuccessful: " + ex.Message);
            }
        }
예제 #3
0
        private EnterEquipmentQuote GetEquipmentQuote_Model(EWS.Domain.Data.DataModel.Quote entity)
        {
            EnterEquipmentQuote model = new EnterEquipmentQuote();

            model.QuoteID             = entity.ID;
            model.QuoteRef            = entity.QuoteRef;
            model.TenderNumber        = entity.TenderNo;
            model.VAT                 = entity.VAT;
            model.SellingPriceExclVAT = entity.SellingPrice;
            model.SellingPriceInclVAT = Math.Round(entity.SellingPrice * Convert.ToDecimal(entity.VAT / 100 + 1), 2);
            model.NoOfMonths          = entity.ContractTerm;

            model.Customer = GetCustomer_Model(entity.CustomerID);

            DeviceQuery dqry = new Domain.Data.Queries.DeviceQuery()
            {
                DeviceID = entity.DeviceID
            };

            model.Device = _queryProcessor.Execute(dqry);

            model.ExchangeRate = new ExchangeRate()
            {
                Rate = entity.ROE,
                Date = entity.ROEDate
            };

            model.ContractCalculations = GetNewEquipmentContractCalculationModels(model.SellingPriceExclVAT);
            UpdateModelFromSavedValues(model.ContractCalculations, model.QuoteID);


            return(model);
        }