Example #1
0
		private static string GetName(ClientData clientData)
		{
			var date = LocalizationHelper.GetDate(DateTimeProvider.Now, CultureInfo.GetCultureInfo(clientData.Language));
			var name = "calculation_" + date + "_" + clientData.Nic + ".xlsx";

			return name.EscapeFileName();
		}
Example #2
0
		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);
		}
Example #3
0
		public bool HaveAccessToClient(ClientData data)
		{
			if(_identity.IsInRole(RoleType.Admin) || _identity.IsInRole(RoleType.Sender) || _identity.IsInRole(RoleType.Manager))
			{
				return true;
			}

			if(data == null)
			{
				throw new ArgumentNullException("data");
			}

			var client = _clients.GetByUserId(_identity.Id);

			return client != null && client.ClientId == data.ClientId;
		}
		private ApplicationIndexModel Test(ClientData[] clients, AirWaybillData[] awbs, long cargoIsFlewStateId)
		{
			_context.IdentityService.SetupGet(x => x.Id).Returns(TestConstants.TestSenderUserId);
			_context.ClientRepository.Setup(x => x.GetAll()).Returns(clients);
			_context.AwbRepository.Setup(x => x.Get()).Returns(awbs);
			_context.StateConfig.SetupGet(x => x.CargoIsFlewStateId).Returns(cargoIsFlewStateId);
			_context.SenderRepository.Setup(x => x.GetByUserId(TestConstants.TestSenderUserId))
				.Returns(TestConstants.TestSenderId);

			var result = _applicationListController.Index();

			var model = (ApplicationIndexModel)result.Model;

			_context.IdentityService.Verify(x => x.Id, Times.Once());
			_context.ClientRepository.Verify(x => x.GetAll(), Times.Once());
			_context.AwbRepository.Verify(x => x.Get(), Times.Once());
			_context.StateConfig.Verify(x => x.CargoIsFlewStateId, Times.Once());
			model.Clients.ShouldAllBeEquivalentTo(clients.ToDictionary(x => x.ClientId, x => x.Nic));
			_context.SenderRepository.Verify(x => x.GetByUserId(TestConstants.TestSenderUserId), Times.Once());

			return model;
		}
Example #5
0
		private void BindBag(long? applicationId, ClientData client)
		{
			ViewBag.ClientNic = client.Nic;

			ViewBag.ClientId = client.ClientId;

			ViewBag.ApplicationId = applicationId;

			if(applicationId.HasValue)
			{
				var data = _applications.Get(applicationId.Value);

				ViewBag.ApplicationNumber = data.DisplayNumber;
			}

			ViewBag.Countries = _countries.All(_identity.Language).ToDictionary(x => x.Id, x => x.Name);

			ViewBag.Senders = _senders.GetAll().OrderBy(x => x.Name).ToDictionary(x => (long?)x.EntityId, x => x.Name);

			ViewBag.Forwarders = _forwarders.GetAll().OrderBy(x => x.Name).ToDictionary(x => (long?)x.Id, x => x.Name);

			ViewBag.Carriers = _carriers.GetAll().OrderBy(x => x.Name).ToDictionary(x => (long?)x.Id, x => x.Name);
		}
Example #6
0
		private static MemoryStream Get(ClientData client, decimal balance, CalculationData[] calculations,
			ClientBalanceHistoryItem[] history)
		{
			var stream = new MemoryStream();

			using(var pck = new ExcelPackage())
			{
				var excel = pck.Workbook.Worksheets.Add(Entities.Application);
				excel.Cells.Style.Font.Name = ExcelConstants.DefaultFontName;
				excel.Cells.Style.Font.Size = ExcelConstants.DefaultFontSize;
				excel.Cells.Style.Numberformat.Format = "0.00";

				var columnCount = DrawHeader(excel, balance);

				var iRow = DrawRows(client, calculations, history, columnCount, 3, excel);

				AdjustExcel(columnCount, excel, iRow);

				pck.SaveAs(stream);
			}

			stream.Position = 0;

			return stream;
		}
Example #7
0
		private static int DrawRows(ClientData client, CalculationData[] calculations,
			ClientBalanceHistoryItem[] history, int columnCount, int iRow, ExcelWorksheet excel)
		{
			var drawables = DrawableMapper.Get(history, excel, client, columnCount)
				.Union(DrawableMapper.Get(calculations, excel, client, columnCount))
				.OrderByDescending(x => x.Position)
				.ToArray();

			foreach(var drawable in drawables)
			{
				iRow = drawable.Draw(iRow);
			}

			return iRow;
		}
Example #8
0
		private static string GetGoodsString(ClientData client)
		{
			var contractNumber = string.IsNullOrWhiteSpace(client.ContractNumber) ? "___" : client.ContractNumber;
			var contractDate = DateTimeOffset.Equals(client.ContractDate, DateTimeOffset.MinValue)
				? "______________"
				: client.ContractDate.ToString("dd MMMM yyyy");

			return string.Format(
				"Оплата по договору {0} от {1}. За одежду, обувь и другие непродовольственные заказы.",
				contractNumber,
				contractDate);
		}
		private static void Validate(
			ClientData clientData, ApplicationAdminModel model, TransitEditModel transitModel,
			ApplicationData data)
		{
			data.ShouldBeEquivalentTo(model,
				options => options.ExcludingMissingProperties()
					.Excluding(x => x.PickupCost)
					.Excluding(x => x.CarrierId)
					.Excluding(x => x.CarrierName)
					.Excluding(x => x.InsuranceRate));
			data.InsuranceRate.ShouldBeEquivalentTo(model.InsuranceRate / 100);
			data.GetAdjustedFactureCost().ShouldBeEquivalentTo(model.FactureCostEdited);
			data.GetAdjustedFactureCostEx().ShouldBeEquivalentTo(model.FactureCostExEdited);
			data.GetAdjustedTransitCost().ShouldBeEquivalentTo(model.TransitCostEdited);
			data.GetAdjustedPickupCost().ShouldBeEquivalentTo(model.PickupCostEdited);
			data.GetAdjustedScotchCost().ShouldBeEquivalentTo(model.ScotchCostEdited);
			data.CurrencyId.ShouldBeEquivalentTo(model.Currency.CurrencyId);
			data.ClientLegalEntity.ShouldBeEquivalentTo(clientData.LegalEntity);
			data.ClientNic.ShouldBeEquivalentTo(clientData.Nic);
			data.TransitAddress.ShouldBeEquivalentTo(transitModel.Address);
			data.TransitCityId.ShouldBeEquivalentTo(TestConstants.TestCityId1);
			data.CarrierId.ShouldBeEquivalentTo(TestConstants.TestCarrierId1);
			data.TransitDeliveryType.ShouldBeEquivalentTo(transitModel.DeliveryType);
			data.TransitMethodOfTransit.ShouldBeEquivalentTo(transitModel.MethodOfTransit);
			data.TransitPhone.ShouldBeEquivalentTo(transitModel.Phone);
			data.TransitRecipientName.ShouldBeEquivalentTo(transitModel.RecipientName);
			data.TransitWarehouseWorkingTime.ShouldBeEquivalentTo(transitModel.WarehouseWorkingTime);
		}
		private void Validate(
			ActionResult result, ClientData clientData, ApplicationAdminModel model,
			TransitEditModel transitModel)
		{
			result.Should().BeOfType<RedirectToRouteResult>();

			var data = _applicationRepository.List(new[]
			{
				TestConstants.DefaultStateId
			},
				new[]
				{
					new Order
					{
						Desc = true,
						OrderType = OrderType.Id
					}
				},
				1,
				clientId: clientData.ClientId).First();

			Validate(clientData, model, transitModel, data);
		}
Example #11
0
		private static ClientModel GetModel(ClientData client, string contractFileName)
		{
			return new ClientModel
			{
				BIC = client.BIC,
				Phone = client.Phone,
				Emails = client.Emails,
				LegalEntity = client.LegalEntity,
				Bank = client.Bank,
				Contacts = client.Contacts,
				INN = client.INN,
				KPP = client.KPP,
				KS = client.KS,
				LegalAddress = client.LegalAddress,
				MailingAddress = client.MailingAddress,
				Nic = client.Nic,
				OGRN = client.OGRN,
				RS = client.RS,
				ContractFile = null,
				ContractFileName = contractFileName,
				Authentication = new AuthenticationModel(client.Login),
				ContractDate = LocalizationHelper.GetDate(client.ContractDate, CultureProvider.GetCultureInfo()),
				ContractNumber = client.ContractNumber,
				DefaultSenderId = client.DefaultSenderId,
				FactureCost = client.FactureCost,
				FactureCostEx = client.FactureCostEx,
				InsuranceRate = client.InsuranceRate * 100,
				PickupCost = client.PickupCost,
				TransitCost = client.TransitCost,
				TariffPerKg = client.TariffPerKg,
				ScotchCostEdited = client.ScotchCostEdited,
                Comments = client.Comments
			};
		}
Example #12
0
		private void ClientCantChangeDefaultSenderId(ClientModel model, ClientData client)
		{
			if (_identity.IsInRole(RoleType.Client))
			{
				model.DefaultSenderId = client.DefaultSenderId;
			}
		}
Example #13
0
		private void ClientCantChangeCalculationSettings(ClientModel model, ClientData client)
		{
			if (_identity.IsInRole(RoleType.Client))
			{
				model.FactureCost = client.FactureCost;
				model.FactureCostEx = client.FactureCostEx;
				model.InsuranceRate = client.InsuranceRate;
				model.PickupCost = client.PickupCost;
				model.TransitCost = client.TransitCost;
				model.TariffPerKg = client.TariffPerKg;
				model.ScotchCostEdited = client.ScotchCostEdited;
			}
		}
Example #14
0
		public static IDrawable[] Get(ClientBalanceHistoryItem[] history, ExcelWorksheet excel, ClientData client,
			int columnCount)
		{
			return history.Select(x => (IDrawable)new ClientBalanceHistoryItemDrawable(
				x, columnCount, excel)).ToArray();
		}
Example #15
0
		public static IDrawable[] Get(CalculationData[] calculations, ExcelWorksheet excel, ClientData client, int columnCount)
		{
			return calculations.Select(x => (IDrawable)new CalculationDataDrawable(
				x, client.Nic, columnCount, excel)).ToArray();
		}