public long Add(ApplicationEditData application) { var applicationId = _editor.Add(application); _events.Add(applicationId, EventType.ApplicationCreated, EventState.Emailing); return applicationId; }
public void Add(ApplicationSenderModel model, ClientData client, long creatorSenderId) { var application = new ApplicationEditData { InsuranceRate = client.InsuranceRate ?? _applications.GetDefaultInsuranceRate(), ScotchCostEdited = client.ScotchCostEdited }; Map(model, application); Add(application, client.ClientId, creatorSenderId); }
public long Add(ApplicationClientModel application, TransitEditModel transit, long clientId) { var transitId = _transits.Add(transit, null); var forwarderId = _forwarders.GetByCityOrAny(transit.CityId, null); var client = _clients.Get(clientId); var data = new ApplicationEditData { Class = null, TransitId = transitId, Invoice = application.Invoice, Characteristic = application.Characteristic, AddressLoad = application.AddressLoad, WarehouseWorkingTime = application.WarehouseWorkingTime, Weight = application.Weight, Count = application.Count, Volume = application.Volume, TermsOfDelivery = application.TermsOfDelivery, Value = application.Currency.Value, CurrencyId = application.Currency.CurrencyId, CountryId = application.CountryId, FactoryName = application.FactoryName, FactoryPhone = application.FactoryPhone, FactoryEmail = application.FactoryEmail, FactoryContact = application.FactoryContact, MarkName = application.MarkName, MethodOfDelivery = application.MethodOfDelivery, IsPickup = application.IsPickup, AirWaybillId = null, DateInStock = null, DateOfCargoReceipt = null, TransitReference = null, ClientId = clientId, PickupCost = client.PickupCost, TransitCost = client.TransitCost, FactureCost = client.FactureCost, FactureCostEx = client.FactureCostEx, TariffPerKg = client.TariffPerKg, ScotchCostEdited = client.ScotchCostEdited, FactureCostEdited = null, FactureCostExEdited = null, TransitCostEdited = null, PickupCostEdited = null, SenderId = client.DefaultSenderId, SenderRate = null, ForwarderId = forwarderId, InsuranceRate = client.InsuranceRate ?? _applications.GetDefaultInsuranceRate() }; return _updater.Add(data); }
public void Update(long applicationId, ApplicationEditData application) { var oldData = _applications.Get(applicationId); _editor.Update(applicationId, application); if(oldData.SenderId != application.SenderId && application.SenderId.HasValue) { _events.Add(applicationId, EventType.SetSender, EventState.Emailing); } if(oldData.ForwarderId != application.ForwarderId) { _events.Add(applicationId, EventType.SetForwarder, EventState.Emailing); } }
private decimal GetTapeCost(ApplicationEditData application) { decimal? cost = null; if(application.ScotchCostEdited.HasValue) { cost = application.ScotchCostEdited.Value * application.Count; } else if(application.SenderId.HasValue) { var tariffs = _senders.GetTariffs(application.SenderId.Value); cost = CalculationHelper.GetSenderTapeTariff(tariffs, application.SenderId) * application.Count; } return cost ?? 0; }
public long Add(ApplicationEditData application) { var entity = new DbContext.Application(); Map(application, entity); entity.StateId = _defaultStateId; entity.StateChangeTimestamp = DateTimeProvider.Now; entity.DisplayNumber = _executor.Query<int>("[dbo].[GetNextDisplayNumber]"); entity.CreationTimestamp = DateTimeProvider.Now; _context.Applications.InsertOnSubmit(entity); _context.SaveChanges(); return entity.Id; }
public static decimal GetProfit(ApplicationEditData application, IReadOnlyDictionary<long, decimal> tariffs) { if(application.CalculationProfit != null) { return application.CalculationProfit.Value; } var totalTariffCost = GetTotalTariffCost( application.CalculationTotalTariffCost, application.TariffPerKg, application.Weight); var scotchCost = (application.ScotchCostEdited ?? GetSenderTapeTariff(tariffs, application.SenderId)) * application.Count; return totalTariffCost + (scotchCost ?? 0) + GetInsuranceCost(application.Value, application.InsuranceRate) + (application.FactureCostEdited ?? application.FactureCost ?? 0) + (application.FactureCostExEdited ?? application.FactureCostEx ?? 0) + (application.PickupCostEdited ?? application.PickupCost ?? 0) + (application.TransitCostEdited ?? application.TransitCost ?? 0); }
private string GetClientString(ApplicationEditData application) { var client = _clients.Get(application.ClientId); return string.Format("{0}, ИНН {1}, {2}, {3}", client.LegalEntity, client.INN, client.LegalAddress, client.Contacts); }
private static void Map(ApplicationEditData from, DbContext.Application to) { to.Characteristic = from.Characteristic; to.AddressLoad = from.AddressLoad; to.WarehouseWorkingTime = from.WarehouseWorkingTime; to.Weight = from.Weight; to.Count = from.Count; to.Volume = from.Volume; to.TermsOfDelivery = from.TermsOfDelivery; to.Value = from.Value; to.CurrencyId = (int)@from.CurrencyId; to.MethodOfDeliveryId = (int)from.MethodOfDelivery; to.DateInStock = from.DateInStock; to.DateOfCargoReceipt = from.DateOfCargoReceipt; to.TransitReference = from.TransitReference; to.IsPickup = from.IsPickup; to.ClientId = from.ClientId; to.TransitId = from.TransitId; to.ClassId = (int?)from.Class; to.AirWaybillId = from.AirWaybillId; to.CountryId = from.CountryId; to.SenderId = from.SenderId; to.ForwarderId = from.ForwarderId; to.FactoryName = from.FactoryName; to.FactoryPhone = from.FactoryPhone; to.FactoryEmail = from.FactoryEmail; to.FactoryContact = from.FactoryContact; to.MarkName = from.MarkName; to.Invoice = from.Invoice; to.FactureCost = from.FactureCost; to.FactureCostEx = from.FactureCostEx; to.TariffPerKg = from.TariffPerKg; to.TransitCost = from.TransitCost; to.PickupCost = from.PickupCost; to.FactureCostEdited = from.FactureCostEdited; to.FactureCostExEdited = from.FactureCostExEdited; to.TransitCostEdited = from.TransitCostEdited; to.PickupCostEdited = from.PickupCostEdited; to.ScotchCostEdited = from.ScotchCostEdited; to.SenderRate = from.SenderRate; to.InsuranceRate = from.InsuranceRate; to.CalculationProfit = from.CalculationProfit; to.CalculationTotalTariffCost = from.CalculationTotalTariffCost; to.MRN = from.MRN; to.CountInInvoce = from.CountInInvoce; to.DocumentWeight = from.DocumentWeight; to.Comments = from.Comments; }
public void Update(long applicationId, ApplicationEditData application) { Update(applicationId, entity => Map(application, entity)); }
public long[] FilterByBusinessLogic(ApplicationEditData applicationData, long[] stateAvailability) { var states = stateAvailability.ToList(); if(!applicationData.Weight.HasValue || !applicationData.Count.HasValue) { states.Remove(_config.CargoInStockStateId); } #region AWB if(!applicationData.AirWaybillId.HasValue) { states.Remove(_config.CargoIsFlewStateId); } if(applicationData.AirWaybillId.HasValue) { var airWaybillData = _awbs.Get(applicationData.AirWaybillId.Value).First(); if(string.IsNullOrWhiteSpace(airWaybillData.GTD)) { states.Remove(_config.CargoAtCustomsStateId); } } else { states.Remove(_config.CargoAtCustomsStateId); } #endregion return states.ToArray(); }
private void Add(ApplicationEditData application, long clientId, long senderId) { var transit = _transits.GetByClient(clientId); transit.Id = 0; var transitId = _transits.Add(transit); application.TransitId = transitId; application.ForwarderId = _forwarders.GetByCityOrAny(transit.CityId, null); application.Class = null; application.SenderId = senderId; application.ClientId = clientId; _editor.Add(application); }
private static void Map(ApplicationSenderModel from, ApplicationEditData to) { to.Count = from.Count; to.FactoryName = from.FactoryName; to.Weight = from.Weight; to.Invoice = from.Invoice; to.MarkName = from.MarkName; to.Value = from.Currency.Value; to.CurrencyId = from.Currency.CurrencyId; to.Volume = from.Volume; to.FactureCost = from.FactureCost; to.FactureCostEx = from.FactureCostEx; to.PickupCost = from.PickupCost; to.TransitCost = from.TransitCost; to.CountryId = from.CountryId; to.AddressLoad = from.AddressLoad; to.FactoryContact = from.FactoryContact; to.FactoryEmail = from.FactoryEmail; to.FactoryPhone = from.FactoryPhone; to.WarehouseWorkingTime = from.WarehouseWorkingTime; to.CountInInvoce = from.CountInInvoce; to.DocumentWeight = from.DocumentWeight; to.MRN = from.MRN; to.Comments = from.Comments; }
public long Add(ApplicationAdminModel model, TransitEditModel transit, long clientId) { var transitId = _transitService.Add(transit, model.CarrierId); var data = new ApplicationEditData { Class = null, TransitId = transitId, Invoice = model.Invoice, Characteristic = model.Characteristic, AddressLoad = model.AddressLoad, WarehouseWorkingTime = model.WarehouseWorkingTime, Weight = model.Weight, Count = model.Count, Volume = model.Volume, TermsOfDelivery = model.TermsOfDelivery, Value = model.Currency.Value, CurrencyId = model.Currency.CurrencyId, CountryId = model.CountryId, FactoryName = model.FactoryName, FactoryPhone = model.FactoryPhone, FactoryEmail = model.FactoryEmail, FactoryContact = model.FactoryContact, MarkName = model.MarkName, MethodOfDelivery = model.MethodOfDelivery, IsPickup = model.IsPickup, AirWaybillId = null, DateInStock = null, DateOfCargoReceipt = null, TransitReference = null, ClientId = clientId, PickupCost = model.PickupCost, TransitCost = model.TransitCost, FactureCost = model.FactureCost, FactureCostEx = model.FactureCostEx, TariffPerKg = model.TariffPerKg, ScotchCostEdited = model.ScotchCostEdited, FactureCostEdited = model.FactureCostEdited, FactureCostExEdited = model.FactureCostExEdited, TransitCostEdited = model.TransitCostEdited, PickupCostEdited = model.PickupCostEdited, SenderId = model.SenderId, ForwarderId = GetForwarderId(model.ForwarderId, transit.CityId, null), SenderRate = null, InsuranceRate = model.InsuranceRate / 100, CountInInvoce = model.CountInInvoce, DocumentWeight = model.DocumentWeight, MRN = model.MRN, Comments = model.Comments }; return _editor.Add(data); }
private static void Map(ApplicationClientModel @from, ApplicationEditData to, long forwarderId) { to.CountryId = @from.CountryId; to.Invoice = @from.Invoice; to.Characteristic = @from.Characteristic; to.AddressLoad = @from.AddressLoad; to.WarehouseWorkingTime = @from.WarehouseWorkingTime; to.Weight = @from.Weight; to.Count = @from.Count; to.Volume = @from.Volume; to.TermsOfDelivery = @from.TermsOfDelivery; to.Value = @from.Currency.Value; to.CurrencyId = @from.Currency.CurrencyId; to.FactoryName = @from.FactoryName; to.FactoryPhone = @from.FactoryPhone; to.FactoryEmail = @from.FactoryEmail; to.FactoryContact = @from.FactoryContact; to.IsPickup = @from.IsPickup; to.MarkName = @from.MarkName; to.MethodOfDelivery = @from.MethodOfDelivery; to.ForwarderId = forwarderId; }