/// <summary> /// Создает из сущности модель для грида. /// </summary> /// <param name="entity">Сущность.</param> /// <returns>Модель.</returns> public static RepairOrderGridItemModel CreateItemModel(RepairOrderDTO entity) { var deviceSum = RemontinkaServer.Instance.DataStore.GetDeviceItemsSum(entity.RepairOrderID) ?? decimal.Zero; var workSum = RemontinkaServer.Instance.DataStore.GetWorkItemsSum(entity.RepairOrderID) ?? decimal.Zero; var item = new RepairOrderGridItemModel { ClientFullName = entity.ClientFullName, DeviceTitle = entity.DeviceTitle, StatusTitle = entity.IsUrgent? "Срочный " + entity.OrderStatusTitle:entity.OrderStatusTitle, ManagerFullName = entity.ManagerFullName, EngineerFullName = entity.EngineerFullName ?? "Не назначен", EventDate = Utils.DateTimeToString(entity.EventDate), EventDateOfBeReady = Utils.DateTimeToString(entity.DateOfBeReady), Id = entity.RepairOrderID, Number = entity.Number, RowClass = entity.IsUrgent ? GridRowColors.Danger : OrderStatusDataAdapter.StatusesColors[entity.StatusKind], Totals = string.Format("Общая:{0:0.00}; запчасти: {1:0.00}; работа: {2:0.00}", deviceSum + workSum, deviceSum, workSum), Defect = entity.Defect }; var diff = entity.DateOfBeReady - DateTime.Today; if (diff.Days < 3) { item.RowClass = GridRowColors.Danger; } return(item); }
/// <summary> /// Контекст для заказа. /// </summary> /// <param name="order">Заказ.</param> public RepairOrderContextItem(RepairOrderDTO order) { _values[ContextConstants.ClientFullName] = order.ClientFullName; _values[ContextConstants.ClientPhone] = order.ClientPhone; _values[ContextConstants.DateOfBeReady] = order.DateOfBeReady; _values[ContextConstants.Defect] = order.Defect; _values[ContextConstants.DeviceAppearance] = order.DeviceAppearance; _values[ContextConstants.DeviceModel] = order.DeviceModel; _values[ContextConstants.DeviceSN] = order.DeviceSN; _values[ContextConstants.DeviceTitle] = order.DeviceTitle; _values[ContextConstants.DeviceTrademark] = order.DeviceTrademark; _values[ContextConstants.EngineerFullName] = order.EngineerFullName; _values[ContextConstants.EventDate] = order.EventDate; _values[ContextConstants.GuidePrice] = order.GuidePrice; _values[ContextConstants.IsUrgent] = order.IsUrgent; _values[ContextConstants.IssueDate] = order.IssueDate; _values[ContextConstants.ManagerFullName] = order.ManagerFullName; _values[ContextConstants.Notes] = order.Notes; _values[ContextConstants.Number] = order.Number; _values[ContextConstants.Options] = order.Options; _values[ContextConstants.OrderKindTitle] = order.OrderKindTitle; _values[ContextConstants.OrderStatusTitle] = order.OrderStatusTitle; _values[ContextConstants.PrePayment] = order.PrePayment; _values[ContextConstants.Recommendation] = order.Recommendation; _values[ContextConstants.WarrantyTo] = order.WarrantyTo; }
/// <summary> /// Создает таблицу для товарного чека . /// </summary> /// <param name="token">Токен безопасности.</param> /// <param name="repairOrder">Заказ.</param> /// <param name="branch">Филиал.</param> /// <returns>Созданная таблица.</returns> private static string CreateProductList(SecurityToken token, RepairOrderDTO repairOrder, Branch branch) { var total = decimal.Zero; #if CLIENT var workItems = ClientCore.Instance.DataStore.GetWorkItems(repairOrder.RepairOrderIDGuid); var deviceItems = ClientCore.Instance.DataStore.GetDeviceItems(repairOrder.RepairOrderIDGuid); #else var workItems = RemontinkaServer.Instance.DataStore.GetWorkItems(repairOrder.RepairOrderID); var deviceItems = RemontinkaServer.Instance.DataStore.GetDeviceItems(repairOrder.RepairOrderID); #endif var stringBuilder = new StringBuilder(); int index = 1; foreach (var workItem in workItems) { total += (decimal)workItem.Price; stringBuilder.AppendFormat(ProductListItemFormat, IntToString(index), workItem.Title, "-", DecimalToString(workItem.Price), DecimalToString(workItem.Price)); index++; } //foreach foreach (var deviceItem in deviceItems) { total += (decimal)deviceItem.Price * (decimal)deviceItem.Count; stringBuilder.AppendFormat(ProductListItemFormat, IntToString(index), deviceItem.Title, DecimalToString(deviceItem.Count), DecimalToString(deviceItem.Price), DecimalToString(deviceItem.Price * deviceItem.Count)); index++; } //foreach return(string.Format(ProductListTableFormat, stringBuilder, DecimalToString(total))); }
/// <summary> /// Контекст для заказа. /// </summary> /// <param name="order">Заказ.</param> public BarcodeContextItem(RepairOrderDTO order) { var imageTagBuilder = new TagBuilder("img"); var url = BarcodeHtmlHelper.CreateBarcodeImageUrl(order.Number, BarcodeSymbology.Code128); url = url.Substring(2, url.Length - 2);//Убираем ~/ imageTagBuilder.MergeAttribute("src", url); imageTagBuilder.MergeAttribute("alt", order.Number); _values[ContextConstants.RepairOrderNumberCode128] = imageTagBuilder.ToString(TagRenderMode.SelfClosing); }
/// <summary> /// Initializes a new instance of the <see cref="T:System.Object"/> class. /// </summary> public RepairOrderItemModel(RepairOrderDTO entity) { _order = entity; ClientFullName = entity.ClientFullName; DeviceTitle = entity.DeviceTitle; StatusTitle = entity.IsUrgentBoolean ? "Срочный " + entity.OrderStatusTitle : entity.OrderStatusTitle; ManagerFullName = entity.ManagerFullName; EngineerFullName = entity.EngineerFullName ?? "Не назначен"; EventDate = WpfUtils.DateTimeToString(entity.EventDateDateTime); EventDateOfBeReady = WpfUtils.DateTimeToString(entity.DateOfBeReadyDateTime); Id = entity.RepairOrderIDGuid; Number = entity.Number; var deviceSum = ClientCore.Instance.DataStore.GetDeviceItemsSum(entity.RepairOrderIDGuid) ?? decimal.Zero; var workSum = ClientCore.Instance.DataStore.GetWorkItemsSum(entity.RepairOrderIDGuid) ?? decimal.Zero; Totals = string.Format("Общая:{0:0.00}; запчасти: {1:0.00}; работа: {2:0.00}", deviceSum + workSum, deviceSum, workSum); }
public void SaveRepairOrderRequestTest() { var message = new SaveRepairOrderRequest(); Assert.AreEqual(message.Kind, MessageKind.SaveRepairOrderRequest); var order = new RepairOrderDTO(); order.BranchID = Guid.NewGuid(); order.CallEventDate = new DateTime(2015, 06, 01); order.ClientAddress = "ClientAddress"; order.ClientEmail = "ClientEmail"; order.ClientFullName = "ClientFullName"; order.ClientPhone = "ClientPhone"; order.DateOfBeReady = new DateTime(2015, 07, 07); order.Defect = "Defect"; order.DeviceAppearance = "DeviceAppearance"; order.DeviceModel = "DeviceModel"; order.DeviceSN = "DeviceSN"; order.DeviceTitle = "DeviceTitle"; order.DeviceTrademark = "DeviceTrademark"; order.EngineerID = Guid.NewGuid(); order.EventDate = new DateTime(2014, 02, 05); order.GuidePrice = 44; order.IsUrgent = true; order.IssueDate = new DateTime(2013, 05, 04); order.IssuerID = Guid.NewGuid(); order.ManagerID = Guid.NewGuid(); order.Notes = "Notes"; order.Number = "Number" + Guid.NewGuid(); order.Options = "Options"; order.OrderKindID = Guid.NewGuid(); order.OrderStatusID = Guid.NewGuid(); order.PrePayment = 55; order.Recommendation = "Recommendation"; order.WarrantyTo = new DateTime(2017, 01, 2); var workItem = new WorkItemDTO(); workItem.WorkItemID = Guid.NewGuid(); workItem.EventDate = new DateTime(2015, 10, 7); workItem.Price = 55.66M; workItem.RepairOrderID = Guid.NewGuid(); workItem.UserID = Guid.NewGuid(); var deviceItem = new DeviceItemDTO(); deviceItem.DeviceItemID = Guid.NewGuid(); deviceItem.Count = 33; deviceItem.EventDate = new DateTime(2015, 01, 01); deviceItem.Price = 55.33M; deviceItem.RepairOrderID = Guid.NewGuid(); deviceItem.Title = "Title"; var timeLine = new OrderTimelineDTO(); timeLine.EventDateTime = new DateTime(2015, 06, 07, 01, 2, 3); timeLine.OrderTimelineID = Guid.NewGuid(); timeLine.RepairOrderID = Guid.NewGuid(); timeLine.TimelineKindID = 1; timeLine.Title = "Title"; order.WorkItems.Add(workItem); order.OrderTimelines.Add(timeLine); order.DeviceItems.Add(deviceItem); message.RepairOrder = order; var serializer = new ProtocolSerializer(ProtocolVersion.Version10); var data = serializer.Serialize(message); Assert.IsNotNull(data); var savedMessage = serializer.DeserializeSaveRepairOrderRequest(data); Assert.IsNotNull(savedMessage); Assert.AreEqual(serializer.GetMessageInfoOrNull(data).Kind, MessageKind.SaveRepairOrderRequest); Assert.IsNotNull(savedMessage.RepairOrder); Assert.AreEqual(savedMessage.RepairOrder.DeviceItems.Count, 1); Assert.AreEqual(savedMessage.RepairOrder.WorkItems.Count, 1); Assert.AreEqual(savedMessage.RepairOrder.OrderTimelines.Count, 1); var savedDeviceItem = savedMessage.RepairOrder.DeviceItems[0]; var savedWorkItem = savedMessage.RepairOrder.WorkItems[0]; var savedTimeline = savedMessage.RepairOrder.OrderTimelines[0]; var savedItem = savedMessage.RepairOrder; Assert.AreEqual(order.BranchID, savedItem.BranchID); Assert.AreEqual(order.CallEventDate, savedItem.CallEventDate); Assert.AreEqual(order.ClientAddress, savedItem.ClientAddress); Assert.AreEqual(order.ClientEmail, savedItem.ClientEmail); Assert.AreEqual(order.ClientFullName, savedItem.ClientFullName); Assert.AreEqual(order.ClientPhone, savedItem.ClientPhone); Assert.AreEqual(order.DateOfBeReady, savedItem.DateOfBeReady); Assert.AreEqual(order.Defect, savedItem.Defect); Assert.AreEqual(order.DeviceAppearance, savedItem.DeviceAppearance); Assert.AreEqual(order.DeviceModel, savedItem.DeviceModel); Assert.AreEqual(order.DeviceSN, savedItem.DeviceSN); Assert.AreEqual(order.DeviceTitle, savedItem.DeviceTitle); Assert.AreEqual(order.DeviceTrademark, savedItem.DeviceTrademark); Assert.AreEqual(order.EngineerID, savedItem.EngineerID); Assert.AreEqual(order.EventDate, savedItem.EventDate); Assert.AreEqual(order.GuidePrice, savedItem.GuidePrice); Assert.AreEqual(order.IsUrgent, savedItem.IsUrgent); Assert.AreEqual(order.IssueDate, savedItem.IssueDate); Assert.AreEqual(order.IssuerID, savedItem.IssuerID); Assert.AreEqual(order.ManagerID, savedItem.ManagerID); Assert.AreEqual(order.Notes, savedItem.Notes); Assert.AreEqual(order.Number, savedItem.Number); Assert.AreEqual(order.Options, savedItem.Options); Assert.AreEqual(order.OrderKindID, savedItem.OrderKindID); Assert.AreEqual(order.OrderStatusID, savedItem.OrderStatusID); Assert.AreEqual(order.PrePayment, savedItem.PrePayment); Assert.AreEqual(order.Recommendation, savedItem.Recommendation); Assert.AreEqual(order.WarrantyTo, savedItem.WarrantyTo); Assert.AreEqual(deviceItem.DeviceItemID, savedDeviceItem.DeviceItemID); Assert.AreEqual(deviceItem.CostPrice, savedDeviceItem.CostPrice); Assert.AreEqual(deviceItem.EventDate, savedDeviceItem.EventDate); Assert.AreEqual(deviceItem.Price, savedDeviceItem.Price); Assert.AreEqual(deviceItem.RepairOrderID, savedDeviceItem.RepairOrderID); Assert.AreEqual(deviceItem.Title, savedDeviceItem.Title); Assert.AreEqual(deviceItem.UserID, savedDeviceItem.UserID); Assert.AreEqual(deviceItem.WarehouseItemID, savedDeviceItem.WarehouseItemID); Assert.AreEqual(savedWorkItem.EventDate, workItem.EventDate); Assert.AreEqual(savedWorkItem.Price, workItem.Price); Assert.AreEqual(savedWorkItem.RepairOrderID, workItem.RepairOrderID); Assert.AreEqual(savedWorkItem.Title, workItem.Title); Assert.AreEqual(savedWorkItem.UserID, workItem.UserID); Assert.AreEqual(savedWorkItem.WorkItemID, workItem.WorkItemID); Assert.AreEqual(savedTimeline.EventDateTime, timeLine.EventDateTime); Assert.AreEqual(savedTimeline.OrderTimelineID, timeLine.OrderTimelineID); Assert.AreEqual(savedTimeline.RepairOrderID, timeLine.RepairOrderID); Assert.AreEqual(savedTimeline.TimelineKindID, timeLine.TimelineKindID); Assert.AreEqual(savedTimeline.Title, timeLine.Title); }
/// <summary> /// Создает html представление отчетов связанных с заказами. /// </summary> /// <param name="token">Токен безопасности.</param> /// <param name="customReportID">Код необходимого отчета. </param> /// <param name="repairOrder">Связанный заказ.</param> /// <returns>Сгенерированный результат.</returns> public string CreateRepairOrderReport(SecurityToken token, Guid?customReportID, RepairOrderDTO repairOrder) { _logger.InfoFormat("Начало создания отчета по объекту заказа {0} для заказа {1} пользователем {2}", customReportID, repairOrder.RepairOrderID, token.LoginName); #if CLIENT var customReport = ClientCore.Instance.DataStore.GetCustomReportItem(customReportID); #else var customReport = RemontinkaServer.Instance.EntitiesFacade.GetCustomReportItem(token, customReportID); #endif if (customReport == null || string.IsNullOrWhiteSpace(customReport.HtmlContent)) { _logger.ErrorFormat("Отчет не найден или не задан {0}", customReportID); return(NotFoundMessage); } //if var contextBuilder = new ContextStringBuilder(); #if CLIENT var branch = ClientCore.Instance.DataStore.GetBranch(repairOrder.BranchIDGuid); #else var branch = RemontinkaServer.Instance.EntitiesFacade.GetBranch(token, repairOrder.BranchID); var domain = RemontinkaServer.Instance.EntitiesFacade.GetUserDomain(token); contextBuilder.Add(new RepairOrderGlobalReferenceContextItem(repairOrder, domain)); #endif contextBuilder.Add(new TodayContextItem()); contextBuilder.Add(new RepairOrderContextItem(repairOrder)); contextBuilder.Add(new BranchContextItem(branch)); #if CLIENT #else contextBuilder.Add(new BarcodeContextItem(repairOrder)); #endif foreach ( var key in _contextTableMap.Keys.Where(i => customReport.HtmlContent.Contains(string.Format("{{{0}}}", i)))) { contextBuilder.Add(new SimpleContextItem(key, _contextTableMap[key](token, repairOrder, branch))); } //foreach #if CLIENT var deviceInfo = ClientCore.Instance.DataStore.GetDeviceItemsTotal(repairOrder.RepairOrderIDGuid); var workInfo = ClientCore.Instance.DataStore.GetWorkItemsTotal(repairOrder.RepairOrderIDGuid); #else var deviceInfo = RemontinkaServer.Instance.DataStore.GetDeviceItemsTotal(repairOrder.RepairOrderID); var workInfo = RemontinkaServer.Instance.DataStore.GetWorkItemsTotal(repairOrder.RepairOrderID); #endif var totalCount = 0.0M; var totalPrice = 0.0M; if (deviceInfo != null) { totalCount = (decimal?)deviceInfo.Count ?? decimal.Zero; totalPrice = (decimal?)deviceInfo.TotalAmount ?? decimal.Zero; } //if if (workInfo != null) { totalCount += (decimal?)workInfo.Count ?? 0; totalPrice += (decimal?)workInfo.Amount ?? decimal.Zero; } //if contextBuilder.Add(new SimpleContextItem(ContextConstants.TotalItemsCount, DecimalToString(totalCount))); contextBuilder.Add(new SimpleContextItem(ContextConstants.TotalItemsAmount, DecimalToString(totalPrice))); contextBuilder.Add(new SimpleContextItem(ContextConstants.TotalItemsAmountRus, RusCurrency.StrRur((double)totalPrice))); return(contextBuilder.Create(customReport.HtmlContent)); }