From 493c8743b1c5d7a33b2ad0bb873ec54693ca24e4 Mon Sep 17 00:00:00 2001 From: vc-ci Date: Mon, 23 Oct 2023 07:14:18 +0000 Subject: [PATCH 1/2] 3.417.0 --- Directory.Build.props | 2 +- src/VirtoCommerce.OrdersModule.Web/module.manifest | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Directory.Build.props b/Directory.Build.props index 75ebeca7..9ab39a76 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -2,7 +2,7 @@ - 3.416.0 + 3.417.0 $(VersionSuffix)-$(BuildNumber) diff --git a/src/VirtoCommerce.OrdersModule.Web/module.manifest b/src/VirtoCommerce.OrdersModule.Web/module.manifest index a52d75f3..aafc1137 100644 --- a/src/VirtoCommerce.OrdersModule.Web/module.manifest +++ b/src/VirtoCommerce.OrdersModule.Web/module.manifest @@ -1,7 +1,7 @@ VirtoCommerce.Orders - 3.416.0 + 3.417.0 3.413.0 From c3efea5201bbc649b44a6a464ccd308a5107f122 Mon Sep 17 00:00:00 2001 From: Konstantin Savosteev Date: Wed, 25 Oct 2023 10:21:43 +0200 Subject: [PATCH 2/2] PT-14000: handle null Store in payment/shipment blade (#384) --- .../Controllers/Api/OrderModuleController.cs | 60 ++++++++++++------- .../Scripts/blades/payment-detail.js | 11 +++- .../Scripts/blades/shipment-detail.js | 13 +++- 3 files changed, 59 insertions(+), 25 deletions(-) diff --git a/src/VirtoCommerce.OrdersModule.Web/Controllers/Api/OrderModuleController.cs b/src/VirtoCommerce.OrdersModule.Web/Controllers/Api/OrderModuleController.cs index 52b29fd5..d68fdc49 100644 --- a/src/VirtoCommerce.OrdersModule.Web/Controllers/Api/OrderModuleController.cs +++ b/src/VirtoCommerce.OrdersModule.Web/Controllers/Api/OrderModuleController.cs @@ -406,21 +406,26 @@ public async Task UpdateOrder([FromBody] CustomerOrder customerOrd public async Task> GetNewShipment(string id) { var order = await _customerOrderService.GetNoCloneAsync(id, CustomerOrderResponseGroup.Full.ToString()); - if (order != null) + if (order == null) { - var retVal = AbstractTypeFactory.TryCreateInstance(); - retVal.Id = Guid.NewGuid().ToString(); - retVal.Currency = order.Currency; - retVal.Status = "New"; - - var store = await _storeService.GetNoCloneAsync(order.StoreId, StoreResponseGroup.StoreInfo.ToString()); - var numberTemplate = store.Settings.GetValue(ModuleConstants.Settings.General.OrderShipmentNewNumberTemplate); - retVal.Number = _uniqueNumberGenerator.GenerateNumber(numberTemplate.ToString()); + return NotFound(); + } - return Ok(retVal); + var store = await _storeService.GetNoCloneAsync(order.StoreId, StoreResponseGroup.StoreInfo.ToString()); + if (store == null) + { + return BadRequest(GetNoStoreErrorMessage(order)); } - return NotFound(); + var retVal = AbstractTypeFactory.TryCreateInstance(); + retVal.Id = Guid.NewGuid().ToString(); + retVal.Currency = order.Currency; + retVal.Status = "New"; + + var numberTemplate = store.Settings.GetValue(ModuleConstants.Settings.General.OrderShipmentNewNumberTemplate); + retVal.Number = _uniqueNumberGenerator.GenerateNumber(numberTemplate.ToString()); + + return Ok(retVal); } /// @@ -433,23 +438,29 @@ public async Task> GetNewShipment(string id) public async Task> GetNewPayment(string id) { var order = await _customerOrderService.GetNoCloneAsync(id, CustomerOrderResponseGroup.Full.ToString()); - if (order != null) + if (order == null) { - var retVal = AbstractTypeFactory.TryCreateInstance(); - retVal.Id = Guid.NewGuid().ToString(); - retVal.Currency = order.Currency; - retVal.CustomerId = order.CustomerId; - retVal.Status = retVal.PaymentStatus.ToString(); + return NotFound(); + } - var store = await _storeService.GetNoCloneAsync(order.StoreId, StoreResponseGroup.StoreInfo.ToString()); - var numberTemplate = store.Settings.GetValue(ModuleConstants.Settings.General.OrderPaymentInNewNumberTemplate); - retVal.Number = _uniqueNumberGenerator.GenerateNumber(numberTemplate.ToString()); - return Ok(retVal); + var store = await _storeService.GetNoCloneAsync(order.StoreId, StoreResponseGroup.StoreInfo.ToString()); + if (store == null) + { + return BadRequest(GetNoStoreErrorMessage(order)); } - return NotFound(); + var retVal = AbstractTypeFactory.TryCreateInstance(); + retVal.Id = Guid.NewGuid().ToString(); + retVal.Currency = order.Currency; + retVal.CustomerId = order.CustomerId; + retVal.Status = retVal.PaymentStatus.ToString(); + + var numberTemplate = store.Settings.GetValue(ModuleConstants.Settings.General.OrderPaymentInNewNumberTemplate); + retVal.Number = _uniqueNumberGenerator.GenerateNumber(numberTemplate.ToString()); + return Ok(retVal); } + /// /// Delete a whole customer orders /// @@ -741,5 +752,10 @@ private async Task ValidateAsync(CustomerOrder customerOrder) return new ValidationResult(); } + + private static string GetNoStoreErrorMessage(CustomerOrder order) + { + return $"Store {order.StoreId} does not exist in the system. Please create {order.StoreId} store or select another store for the order."; + } } } diff --git a/src/VirtoCommerce.OrdersModule.Web/Scripts/blades/payment-detail.js b/src/VirtoCommerce.OrdersModule.Web/Scripts/blades/payment-detail.js index 82324be1..465a0b3d 100644 --- a/src/VirtoCommerce.OrdersModule.Web/Scripts/blades/payment-detail.js +++ b/src/VirtoCommerce.OrdersModule.Web/Scripts/blades/payment-detail.js @@ -28,7 +28,10 @@ angular.module('virtoCommerce.orderModule') foundField.isReadOnly = false; } - customerOrders.getNewPayment({ id: blade.customerOrder.id }, blade.initialize); + customerOrders.getNewPayment({ id: blade.customerOrder.id }, blade.initialize, function (error) { + blade.isLocked = true; + bladeNavigationService.setError(error.data, blade); + }); } else { blade.isLocked = !blade.currentEntity || (blade.currentEntity.status === 'Paid' || blade.currentEntity.cancelledState === 'Requested' @@ -127,6 +130,10 @@ angular.module('virtoCommerce.orderModule') } blade.fetchVendors = function (criteria) { + if (blade.isLocked) { + return []; + } + return members.search(criteria); } @@ -154,7 +161,7 @@ angular.module('virtoCommerce.orderModule') blade.customInitialize = function () { if (!blade.currentEntity) { return; - } + } blade.isLocked = blade.currentEntity.status === 'Paid' || blade.currentEntity.cancelledState === 'Completed' || blade.currentEntity.isCancelled; }; diff --git a/src/VirtoCommerce.OrdersModule.Web/Scripts/blades/shipment-detail.js b/src/VirtoCommerce.OrdersModule.Web/Scripts/blades/shipment-detail.js index 9a7da92a..f9ed11e1 100644 --- a/src/VirtoCommerce.OrdersModule.Web/Scripts/blades/shipment-detail.js +++ b/src/VirtoCommerce.OrdersModule.Web/Scripts/blades/shipment-detail.js @@ -23,7 +23,10 @@ angular.module('virtoCommerce.orderModule') foundField.isReadOnly = false; } - customerOrders.getNewShipment({ id: blade.customerOrder.id }, blade.initialize); + customerOrders.getNewShipment({ id: blade.customerOrder.id }, blade.initialize, function (error) { + blade.isLocked = true; + bladeNavigationService.setError(error.data, blade); + }); } else { blade.isLocked = !blade.currentEntity || blade.currentEntity.status === 'Send' || blade.currentEntity.cancelledState === 'Completed' @@ -62,6 +65,10 @@ angular.module('virtoCommerce.orderModule') } blade.fetchEmployees = function (criteria) { + if (blade.isLocked) { + return []; + } + criteria.memberType = 'Employee'; criteria.deepSearch = true; criteria.sort = 'name'; @@ -84,6 +91,10 @@ angular.module('virtoCommerce.orderModule') } blade.fetchVendors = function (criteria) { + if (blade.isLocked) { + return []; + } + return members.search(criteria); }