Ejemplo n.º 1
0
		public void Save(long applicationId, int number, BillModel model, DateTimeOffset saveDate, DateTimeOffset? sendDate)
		{
			var settings = _settings.GetData<BillSettings>(SettingType.Bill);

			Debug.Assert(model.PriceRuble != null, "model.PriceRuble != null");
			_bills.AddOrReplace(applicationId,
				new BillData
				{
					Accountant = model.Accountant,
					Bank = model.BankDetails.Bank,
					BIC = model.BankDetails.BIC,
					CorrespondentAccount = model.BankDetails.CorrespondentAccount,
					CurrentAccount = model.BankDetails.CurrentAccount,
					Head = model.Head,
					HeaderText = model.HeaderText,
					Payee = model.BankDetails.Payee,
					Shipper = model.Shipper,
					TaxRegistrationReasonCode = model.BankDetails.TaxRegistrationReasonCode,
					TIN = model.BankDetails.TIN,
					Client = model.Client,
					Count = model.Count,
					Goods = model.Goods,
					EuroToRuble = settings.EuroToRuble,
					VAT = settings.VAT,
					Price = model.PriceRuble.Value / settings.EuroToRuble,
					Number = number,
					SaveDate = saveDate,
					SendDate = sendDate
				});
		}
Ejemplo n.º 2
0
		public virtual ActionResult Download(long id, BillModel model)
		{
			if(!SaveImpl(id, model))
			{
				return View("Preview", model);
			}

			var file = _pdf.Get(id);

			return file.GetFileResult();
		}
Ejemplo n.º 3
0
		public virtual ActionResult Send(long id, BillModel model)
		{
			if(!SaveImpl(id, model, true))
			{
				return View("Preview", model);
			}

			_manager.Send(id, _identity.Id);

			return RedirectToAction(MVC.Admin.Bill.Sent(id));
		}
Ejemplo n.º 4
0
		public virtual ActionResult Save(long id, BillModel model)
		{
			if(!SaveImpl(id, model))
			{
				return View("Preview", model);
			}

			return RedirectToAction(MVC.Admin.Bill.Preview(id));
		}
Ejemplo n.º 5
0
		private bool SaveImpl(long id, BillModel model, bool isSend = false)
		{
			if(!model.PriceRuble.HasValue || model.PriceRuble.Value <= 0)
			{
				ModelState.AddModelError("PriceRuble", Validation.InvalidValue);
			}

			var bill = _bills.Get(id);
			var application = _applications.Get(id);
			var number = bill != null ? bill.Number : application.DisplayNumber;
			var date = bill != null ? bill.SaveDate : DateTimeProvider.Now;
			var sendDate = isSend
				? DateTimeProvider.Now
				: bill != null
					? bill.SendDate
					: null;

			if(!ModelState.IsValid)
			{
				ViewBag.ApplicationId = id;
				ViewBag.BillNumber = number;
				ViewBag.SaveDate = date;
				ViewBag.SendDate = sendDate;

				return false;
			}

			_manager.Save(id, number, model, date, sendDate);

			return true;
		}