Esempio n. 1
0
        public async Task BuildRMA(HSOrder order, List <string> supplierIDs, LineItemStatusChanges lineItemStatusChanges, List <HSLineItem> lineItemsChanged, DecodedToken decodedToken)
        {
            foreach (string supplierID in supplierIDs)
            {
                HSSupplier supplier = await _oc.Suppliers.GetAsync <HSSupplier>(supplierID);

                RMA rma = new RMA()
                {
                    PartitionKey     = "PartitionValue",
                    SourceOrderID    = order.ID,
                    TotalCredited    = 0M,
                    ShippingCredited = 0M,
                    RMANumber        = await BuildRMANumber(order),
                    SupplierID       = supplierID,
                    SupplierName     = supplier.Name,
                    Type             = lineItemStatusChanges.Status == LineItemStatus.CancelRequested ? RMAType.Cancellation : RMAType.Return,
                    DateCreated      = DateTime.Now,
                    DateComplete     = null,
                    Status           = RMAStatus.Requested,
                    LineItems        = BuildLineItemRMA(supplierID, lineItemStatusChanges, lineItemsChanged, order),
                    Logs             = new List <RMALog>(),
                    FromBuyerID      = order.FromCompanyID,
                    FromBuyerUserID  = order.FromUser.ID
                };
                await PostRMA(rma);
            }
        }
Esempio n. 2
0
 private RMA UpdateRMAStatus(RMA rma)
 {
     // If any line items have a status of requested or processing, the status should be Processing.
     if (rma.LineItems.Any(li => li.Status == RMALineItemStatus.Requested || li.Status == RMALineItemStatus.Processing))
     {
         rma.Status = RMAStatus.Processing;
     }
     // If all line items have a status of Denied, the status should be Denied.
     else if (rma.LineItems.All(li => li.Status == RMALineItemStatus.Denied))
     {
         rma.Status       = RMAStatus.Denied;
         rma.DateComplete = DateTime.Now;
     }
     // If all line items have a status of Complete, PartialQtyComplete, and/or Denied, the status should be Complete.
     else if (rma.LineItems.All(li => li.Status == RMALineItemStatus.Complete || li.Status == RMALineItemStatus.PartialQtyComplete || li.Status == RMALineItemStatus.Denied))
     {
         rma.Status       = RMAStatus.Complete;
         rma.DateComplete = DateTime.Now;
     }
     // If RMAs have a mixture of statuses at this point, at least one line item is approved but awaiting processing.  Set to Approved.
     else if (rma.LineItems.Any(li => li.Status == RMALineItemStatus.Approved || li.Status == RMALineItemStatus.PartialQtyApproved))
     {
         rma.Status = RMAStatus.Approved;
     }
     return(rma);
 }
Esempio n. 3
0
        private dynamic NewRMA(dynamic arg)
        {
            if (!this.CurrentUser.HasClaim("admin"))
            {
                return(403);
            }

            var rma = new RMA()
            {
                InboundShipment = new RMAShipment()
                {
                    Location = new JObject()
                },
                OutboundShipment = new RMAShipment()
                {
                    Location = new JObject()
                },
                Status   = "",
                Customer = new JObject()
            };

            rma = this.SiteDatabase.UpsertRecord(rma);
            rma.RMAIdentifier = string.Format(CultureInfo.InvariantCulture,
                                              "RMA{0:yyyyMMdd}-{1:000000}",
                                              rma.__createdAt,
                                              rma.Id);
            rma = this.SiteDatabase.UpsertRecord(rma);

            return(rma);
        }
Esempio n. 4
0
 public InitializingRhinoDialog(RMA.RhiExec.Engine.RhinoInitializer initializer)
 {
     InitializeComponent();
       m_initializer = initializer;
       m_worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(m_worker_RunWorkerCompleted);
       m_worker.DoWork += new DoWorkEventHandler(m_worker_DoWork);
 }
Esempio n. 5
0
        public async Task <RMA> ProcessRMA([FromBody] RMA rma)
        {
            RMAWithLineItemStatusByQuantity rmaWithLineItemStatusByQuantity = await _rmaCommand.ProcessRMA(rma, UserContext);

            await _lineItemCommand.HandleRMALineItemStatusChanges(OrderDirection.Incoming, rmaWithLineItemStatusByQuantity, UserContext);

            return(rmaWithLineItemStatusByQuantity.RMA);
        }
Esempio n. 6
0
        private void ValidateRMA(RMA rma, string supplierID)
        {
            if (rma.SupplierID != supplierID)
            {
                throw new Exception("You do not have permission to process a refund for this RMA.");
            }

            if (rma.Status == RMAStatus.Complete || rma.Status == RMAStatus.Denied || rma.Status == RMAStatus.Requested)
            {
                throw new Exception("This RMA is not in a valid status to be refunded.");
            }
        }
Esempio n. 7
0
        public virtual decimal GetShippingRefundIfCancellingAll(HSOrderWorksheet worksheet, RMA rma, CosmosListPage <RMA> allRMAsOnThisOrder)
        {
            // What are all the line items on this order for this supplier and their quantities?
            IEnumerable <HSLineItem> allLineItemsShippedFromThisSupplier = worksheet.LineItems
                                                                           .Where(li => li.SupplierID == rma.SupplierID && worksheet.Order.xp.PaymentMethod == "Credit Card");
            Dictionary <string, int> allLineItemsDictionary = new Dictionary <string, int>();

            foreach (HSLineItem li in allLineItemsShippedFromThisSupplier)
            {
                allLineItemsDictionary.Add(li.ID, li.Quantity);
            }

            // Including this RMA and previous RMAs for this supplier, get everything that has been refunded or is about to be refunded.
            var rmasFromThisSupplier = allRMAsOnThisOrder.Items.Where(r => r.SupplierID == rma.SupplierID);
            Dictionary <string, int> allCompleteRMALineItemsDictionary = new Dictionary <string, int>();

            foreach (RMA existingRMA in rmasFromThisSupplier)
            {
                RMA rmaToAnalyze = existingRMA.RMANumber == rma.RMANumber ? rma : existingRMA;
                foreach (RMALineItem rmaLineItem in rmaToAnalyze.LineItems)
                {
                    if (rmaLineItem.Status == RMALineItemStatus.Complete && rmaLineItem.RefundableViaCreditCard)
                    {
                        if (!allCompleteRMALineItemsDictionary.ContainsKey(rmaLineItem.ID))
                        {
                            allCompleteRMALineItemsDictionary.Add(rmaLineItem.ID, rmaLineItem.QuantityProcessed);
                        }
                        else
                        {
                            allCompleteRMALineItemsDictionary[rmaLineItem.ID] += rmaLineItem.QuantityProcessed;
                        }
                    }
                }
            }

            // If these are the same, the supplier hasn't shipped anything, and shipping should be credited back to the buyer.
            bool shouldShippingBeCanceled = allLineItemsDictionary.OrderBy(kvp => kvp.Key)
                                            .SequenceEqual(allCompleteRMALineItemsDictionary.OrderBy(kvp => kvp.Key));

            // Figure out what the buyer paid for shipping for this supplier on this order.
            if (shouldShippingBeCanceled)
            {
                string selectedShipMethodID = worksheet.ShipEstimateResponse.ShipEstimates
                                              .FirstOrDefault(estimate => estimate.xp.SupplierID == rma.SupplierID)?.SelectedShipMethodID;
                TransactionLineModel shippingLine = worksheet.OrderCalculateResponse.xp.TaxResponse.lines.FirstOrDefault(line => line.lineNumber == selectedShipMethodID);
                decimal shippingCostToRefund      = (decimal)(shippingLine.taxableAmount + shippingLine.tax + shippingLine.exemptAmount);
                rma.ShippingCredited += shippingCostToRefund;
                return(shippingCostToRefund);
            }

            return(0M);
        }
Esempio n. 8
0
        private async Task <RMA> GetRMA(string rmaNumber, DecodedToken decodedToken)
        {
            var currentRMAFilter = new ListFilter("RMANumber", rmaNumber);
            CosmosListOptions currentRMAListOptions = new CosmosListOptions()
            {
                PageSize = 1, ContinuationToken = null, Filters = { currentRMAFilter }
            };
            CosmosListPage <RMA> currentRMAListPage = await ListRMAs(currentRMAListOptions, decodedToken);

            RMA currentRMA = currentRMAListPage.Items[0];

            return(currentRMA);
        }
Esempio n. 9
0
        public async Task <RMAWithLineItemStatusByQuantity> ProcessRefund(string rmaNumber, DecodedToken decodedToken)
        {
            var me = await _oc.Me.GetAsync(accessToken : decodedToken.AccessToken);

            RMA rma = await GetRMA(rmaNumber, decodedToken);

            ValidateRMA(rma, me.Supplier.ID);

            decimal initialAmountRefunded = rma.TotalCredited;

            IEnumerable <RMALineItem> rmaLineItemsToUpdate = rma.LineItems
                                                             .Where(li => !li.IsRefunded &&
                                                                    (li.Status == RMALineItemStatus.Approved || li.Status == RMALineItemStatus.PartialQtyApproved)).ToList();

            HSOrderWorksheet worksheet = await _oc.IntegrationEvents.GetWorksheetAsync <HSOrderWorksheet>(OrderDirection.Incoming, rma.SourceOrderID);

            CosmosListPage <RMA> allRMAsOnThisOrder = await ListRMAsByOrderID(worksheet.Order.ID, decodedToken.CommerceRole, me, true);

            CalculateAndUpdateLineTotalRefund(rmaLineItemsToUpdate, worksheet, allRMAsOnThisOrder, rma.SupplierID);

            // UPDATE RMA LINE ITEM STATUSES
            SetRMALineItemStatusesToComplete(rmaLineItemsToUpdate);

            // UPDATE RMA STATUS
            UpdateRMAStatus(rma);

            await HandleRefund(rma, allRMAsOnThisOrder, worksheet, decodedToken);

            MarkRMALineItemsAsRefunded(rmaLineItemsToUpdate);

            decimal totalRefundedForThisTransaction = rma.TotalCredited - initialAmountRefunded;
            RMALog  log = new RMALog()
            {
                Status = rma.Status, Date = DateTime.Now, AmountRefunded = totalRefundedForThisTransaction, FromUserID = me.ID
            };

            rma.Logs.Insert(0, log);

            List <LineItemStatusChanges> lineItemStatusChangesList = BuildLineItemStatusChanges(rmaLineItemsToUpdate, worksheet, rma.Type, false);

            // SAVE RMA
            ItemResponse <RMA> updatedRMA = await _rmaRepo.ReplaceItemAsync(rma.id, rma);

            RMAWithLineItemStatusByQuantity rmaWithStatusByQuantityChanges = new RMAWithLineItemStatusByQuantity()
            {
                SupplierOrderID = $"{rma.SourceOrderID}-{rma.SupplierID}", RMA = updatedRMA.Resource, LineItemStatusChangesList = lineItemStatusChangesList
            };

            return(rmaWithStatusByQuantityChanges);
        }
        public override bool AfterInstall(Package package, RhinoInfo[] RhinoList, RMA.RhiExec.Engine.InstallerUser InstallAsUser)
        {
            ClearPluginInfo();

              m_package = package;
              if (m_package == null)
            return false;

              string PackageFolder = package.PackagePath;
              ReportProgress("PythonPackage.Install() starting for Package at '" + PackageFolder + "'", LogLevel.Info);

              // Find all the *_cmd.py files (in top directory only, not subdirectories) and register them with IronPython
              if (!Plugin.IsValid())
              {
            ReportProgress("Package Description:\n" + Describe(), LogLevel.Info);
            ReportProgress("Package failed to initialize properly: " + PackageFolder, LogLevel.Error);
            return false;
              }

              string[] commands = Plugin.Commands;

              if (commands.Length == 0)
              {
            ReportProgress("No files named *_cmd.py found in " + PackageFolder, LogLevel.Error);
            return false;
              }

              // HKEY_CURRENT_USER\Software\McNeel\Rhinoceros\5.0\Plug-Ins\814d908a-e25c-493d-97e9-ee3861957f49\CommandList
              RegistryKey RegCmd_32 = Registry.CurrentUser.CreateSubKey(@"Software\McNeel\Rhinoceros\5.0\Plug-Ins\814d908a-e25c-493d-97e9-ee3861957f49\CommandList");
              if (RegCmd_32 == null)
            ReportProgress(@"Unable to write to HKCU\Software\McNeel\Rhinoceros\5.0\Plug-Ins\814d908a-e25c-493d-97e9-ee3861957f49\CommandList", LogLevel.Error);

              RegistryKey RegCmd_64 = Registry.CurrentUser.CreateSubKey(@"Software\McNeel\Rhinoceros\5.0x64\Plug-Ins\814d908a-e25c-493d-97e9-ee3861957f49\CommandList");
              if (RegCmd_64 == null)
            ReportProgress(@"Unable to write to HKCU\Software\McNeel\Rhinoceros\5.0\Plug-Ins\814d908a-e25c-493d-97e9-ee3861957f49\CommandList", LogLevel.Error);

              foreach (string cmd in commands)
              {
            // Register this command in IronPython:
            if (RegCmd_32 != null) // 32-bit
              RegCmd_32.SetValue(cmd, "66;" + cmd, RegistryValueKind.String);
            if (RegCmd_64 != null) // 64-bit
              RegCmd_64.SetValue(cmd, "66;" + cmd, RegistryValueKind.String);

            ReportProgress("Registering command: " + cmd, LogLevel.Info);
              }

              return true;
        }
Esempio n. 11
0
        public async Task <RMAWithLineItemStatusByQuantity> ProcessRMA(RMA rma, DecodedToken decodedToken)
        {
            // Get the RMA from the last time it was saved.
            var me = await _oc.Me.GetAsync(accessToken : decodedToken.AccessToken);

            RMA currentRMA = await GetRMA(rma.RMANumber, decodedToken);

            if (currentRMA.SupplierID != me.Supplier.ID)
            {
                throw new Exception($"You do not have permission to process this RMA.");
            }

            // Should the Status and IsResolved proprerties of an RMALineItem change?
            rma.LineItems = UpdateRMALineItemStatusesAndCheckIfResolved(rma.LineItems);

            // Should status of RMA change?
            rma = UpdateRMAStatus(rma);

            // If the status on the new RMA differs from the old RMA, create an RMALog
            if (rma.Status != currentRMA.Status)
            {
                RMALog log = new RMALog()
                {
                    Status = rma.Status, Date = DateTime.Now, FromUserID = me.ID
                };
                rma.Logs.Insert(0, log);
            }

            HSOrderWorksheet worksheet = await _oc.IntegrationEvents.GetWorksheetAsync <HSOrderWorksheet>(OrderDirection.Incoming, rma.SourceOrderID);

            IEnumerable <RMALineItem> deniedLineItems = rma.LineItems
                                                        .Where(li => !li.IsRefunded && li.Status == RMALineItemStatus.Denied)
                                                        .Where(li => currentRMA.LineItems.FirstOrDefault(currentLi => currentLi.ID == li.ID).Status != RMALineItemStatus.Denied).ToList();

            List <LineItemStatusChanges> lineItemStatusChangesList = BuildLineItemStatusChanges(deniedLineItems, worksheet, rma.Type, true);

            ItemResponse <RMA> updatedRMA = await _rmaRepo.ReplaceItemAsync(currentRMA.id, rma);

            await HandlePendingApprovalEmails(currentRMA, rma.LineItems, worksheet);

            RMAWithLineItemStatusByQuantity rmaWithStatusByQuantityChanges = new RMAWithLineItemStatusByQuantity()
            {
                SupplierOrderID           = $"{rma.SourceOrderID}-{rma.SupplierID}",
                RMA                       = updatedRMA.Resource,
                LineItemStatusChangesList = lineItemStatusChangesList
            };

            return(rmaWithStatusByQuantityChanges);
        }
Esempio n. 12
0
        private async Task HandlePendingApprovalEmails(RMA rma, List <RMALineItem> rmaLineItems, HSOrderWorksheet worksheet)
        {
            IEnumerable <RMALineItem> pendingApprovalLineItemsWithNewComments = rmaLineItems
                                                                                .Where(li => li.Status == RMALineItemStatus.Processing)
                                                                                .Where(li => li.Comment != rma.LineItems.FirstOrDefault(item => item.ID == li.ID).Comment);

            if (!pendingApprovalLineItemsWithNewComments.Any())
            {
                return;
            }

            LineItemStatusChanges lineItemStatusChanges = new LineItemStatusChanges()
            {
                Status  = rma.Type == RMAType.Cancellation ? LineItemStatus.CancelRequested : LineItemStatus.ReturnRequested,
                Changes = new List <LineItemStatusChange>()
            };

            foreach (var rmaLineItem in pendingApprovalLineItemsWithNewComments)
            {
                lineItemStatusChanges.Changes.Add(new LineItemStatusChange()
                {
                    ID       = rmaLineItem.ID,
                    Quantity = rmaLineItem.QuantityProcessed,
                    Comment  = rmaLineItem.Comment,
                    QuantityRequestedForRefund = rmaLineItem.QuantityRequested
                });
            }

            List <HSLineItem> lineItemsChanged = worksheet.LineItems.Where(li => lineItemStatusChanges.Changes.Select(li => li.ID).Contains(li.ID)).ToList();

            Supplier supplier = await _oc.Suppliers.GetAsync(rma.SupplierID);

            EmailDisplayText emailText = new EmailDisplayText()
            {
                EmailSubject = $"New message available from {supplier.Name}",
                DynamicText  = $"{supplier.Name} has contacted you regarding your request for {rma.Type.ToString().ToLower()}",
                DynamicText2 = "The following items have new messages"
            };

            await _sendgridService.SendLineItemStatusChangeEmail(worksheet.Order, lineItemStatusChanges, lineItemsChanged, worksheet.Order.FromUser.FirstName, worksheet.Order.FromUser.LastName, worksheet.Order.FromUser.Email, emailText);
        }
Esempio n. 13
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="rma"></param>
 public void SetStatus(RMA rma)
 {
 }
Esempio n. 14
0
 public async Task <RMA> PostRMA([FromBody] RMA rma)
 {
     return(await _rmaCommand.PostRMA(rma));
 }
Esempio n. 15
0
 public async Task <RMA> GenerateRMA([FromBody] RMA rma)
 {
     return(await _rmaCommand.GenerateRMA(rma, VerifiedUserContext));
 }
Esempio n. 16
0
        public virtual async Task HandleRefundTransaction(HSOrderWorksheet worksheet, HSPayment creditCardPayment, HSPaymentTransaction creditCardPaymentTransaction, decimal totalToRefund, RMA rma)
        {
            try
            {
                CardConnectRefundRequest requestedRefund = new CardConnectRefundRequest()
                {
                    currency = worksheet.Order.xp.Currency.ToString(),
                    merchid  = creditCardPaymentTransaction.xp.CardConnectResponse.merchid,
                    retref   = creditCardPaymentTransaction.xp.CardConnectResponse.retref,
                    amount   = totalToRefund.ToString("F2"),
                };
                CardConnectRefundResponse response = await _cardConnect.Refund(requestedRefund);

                HSPayment newCreditCardPayment = new HSPayment()
                {
                    Amount = response.amount
                };
                await _oc.Payments.CreateTransactionAsync(OrderDirection.Incoming, rma.SourceOrderID, creditCardPayment.ID, CardConnectMapper.Map(newCreditCardPayment, response));
            }
            catch (CreditCardRefundException ex)
            {
                throw new CatalystBaseException(new ApiError
                {
                    ErrorCode = "Payment.FailedToRefund",
                    Message   = ex.ApiError.Message
                });
            }
        }
Esempio n. 17
0
        private void InsertGuestRoom(string hotelId, string hotelCode, IList <OTA_HotelDescriptiveInfoRS.HotelDescriptiveContentsLocalType.HotelDescriptiveContentLocalType.FacilityInfoLocalType.GuestRoomsLocalType> GuestRooms)
        {
            if (GuestRooms != null && GuestRooms.Count > 0)
            {
                using (var context = new TravelDBContext())
                {
                    // TransactionOptions transactionOption = new TransactionOptions();
                    //  transactionOption.Timeout = new TimeSpan(0, 0, 600);

                    // using (TransactionScope tran = new TransactionScope(TransactionScopeOption.Required, transactionOption))
                    {
                        EfRepository <GuestRoom> guestRoomContext = new EfRepository <GuestRoom>(context);

                        EfRepository <RoomExtension>  roomExtensionsContext = new EfRepository <RoomExtension>(context);
                        EfRepository <RMARoomMapping> rmaRoomMappingContext = new EfRepository <RMARoomMapping>(context);
                        EfRepository <RMA>            rmaContext            = new EfRepository <RMA>(context);

                        int Inserted       = 0;
                        var guestRoomCheck = (from r in guestRoomContext.Table where r.HotelID == hotelId select r).ToList();

                        if (guestRoomCheck.Count > 0)
                        {
                            foreach (var item in guestRoomCheck)
                            {
                                var roomExtensions = (from e in roomExtensionsContext.Table where e.RoomID == item.Id select e).ToList();
                                if (roomExtensions.Count > 0)
                                {
                                    roomExtensionsContext.Delete(roomExtensions);
                                    LoggerHelper(hotelCode, "roomExtension  " + item.Name + " deleted");
                                }
                                var rmaRoomMapping = (from r in rmaRoomMappingContext.Table where r.RoomID == item.Id select r).ToList();
                                if (rmaRoomMapping.Count > 0)
                                {
                                    rmaRoomMappingContext.Delete(rmaRoomMapping);
                                    LoggerHelper(hotelCode, "roomMapping  " + item.Name + "  deleted");
                                }

                                guestRoomContext.Delete(item);
                                LoggerHelper(hotelCode, "GuestRoom " + item.Name + "  deleted");
                            }
                        }

                        foreach (var item in GuestRooms[0].GuestRoom)
                        {
                            string roomName = item.RoomTypeName;

                            var typeName = item.TypeRoom;
                            if (Check(typeName))
                            {
                                var    typeNameNode      = typeName[0];
                                int    StandardOccupancy = Convert.ToInt32(typeNameNode.StandardOccupancy);
                                string Size         = typeNameNode.Size;
                                string Name         = typeNameNode.Name;
                                string RoomTypeCode = typeNameNode.RoomTypeCode;
                                string Floor        = typeNameNode.Floor;
                                string InvBlockCode = typeNameNode.InvBlockCode;
                                string BedTypeCode  = typeNameNode.BedTypeCode;
                                string NonSmoking   = typeNameNode.NonSmoking;
                                string HasWindow    = typeNameNode.HasWindow;
                                string Quantity     = typeNameNode.Quantity;
                                string RoomSize     = typeNameNode.RoomSize;


                                GuestRoom gr = new GuestRoom();
                                gr.StandardOccupancy = StandardOccupancy;
                                gr.Size           = Size;
                                gr.Name           = Name;
                                gr.RoomTypeCode   = Convert.ToInt32(RoomTypeCode);
                                gr.Floor          = Floor;
                                gr.InvBlockCode   = Convert.ToInt32(InvBlockCode);
                                gr.BedTypeCode    = Convert.ToInt32(BedTypeCode);
                                gr.NonSmoking     = NonSmoking == "false" ? 0 : 1;
                                gr.HasWindow      = Convert.ToInt32(HasWindow);
                                gr.Quantity       = Convert.ToInt32(Quantity);
                                gr.RoomSize       = RoomSize;
                                gr.LastMofifyTime = DateTime.Now;
                                gr.HotelID        = hotelId;


                                var feature = item.Features;
                                if (Check(feature))
                                {
                                    gr.FeatureDescription = feature[0].Feature[0].DescriptiveText;
                                }
                                guestRoomContext.Insert(gr);

                                Inserted = gr.Id;
                                LoggerHelper(hotelCode, "GuestRoom " + Name + "  Inserted");
                            }

                            var Amenities = item.Amenities;
                            if (Check(Amenities))
                            {
                                foreach (var amentity in Amenities[0].Amenity)
                                {
                                    int    RoomAmenityCode = Convert.ToInt32(amentity.RoomAmenityCode);
                                    string DescriptiveText = amentity.DescriptiveText;

                                    var rmaCheck = (from r in rmaContext.Table where r.Id == RoomAmenityCode select r).ToList();
                                    if (rmaCheck.Count == 0)
                                    {
                                        RMA r = new RMA();
                                        r.Id            = RoomAmenityCode;
                                        r.Name          = DescriptiveText;
                                        r.LastModiyTime = DateTime.Now;

                                        rmaContext.Insert(r);
                                    }

                                    RMARoomMapping rmaRoomMapping = new RMARoomMapping();
                                    rmaRoomMapping.RMAID          = RoomAmenityCode;
                                    rmaRoomMapping.RoomID         = Inserted;
                                    rmaRoomMapping.LastMofifyTime = DateTime.Now;

                                    rmaRoomMappingContext.Insert(rmaRoomMapping);
                                    LoggerHelper(hotelCode, "Guest Amentity " + RoomAmenityCode + "," + DescriptiveText + "  Inserted");
                                }
                            }

                            var TPA_Extensions = item.TPA_Extensions;
                            if (Check(TPA_Extensions))
                            {
                                foreach (var extension in TPA_Extensions[0].TPA_Extension)
                                {
                                    string        FacilityName  = extension.FacilityName;
                                    string        FTypeName     = extension.FTypeName;
                                    string        FacilityValue = extension.FacilityValue;
                                    string        isAvailable   = extension.FacilityValue;
                                    RoomExtension re            = new RoomExtension();
                                    re.FacilityName   = FacilityName;
                                    re.FaciliTypeName = FTypeName;
                                    re.LastMofifyTime = DateTime.Now;
                                    re.IsAllAvailable = Convert.ToInt32(isAvailable);
                                    re.RoomID         = Inserted;

                                    roomExtensionsContext.Insert(re);
                                    LoggerHelper(hotelCode, "Room Extensions Inserted " + FacilityName + "  Inserted");
                                }
                            }
                        }

                        //tran.Complete();
                    }
                }
            }
        }
Esempio n. 18
0
        public virtual async Task HandleRefund(RMA rma, CosmosListPage <RMA> allRMAsOnThisOrder, HSOrderWorksheet worksheet, DecodedToken decodedToken)
        {
            // Get payment info from the order
            ListPage <HSPayment> paymentResponse = await _oc.Payments.ListAsync <HSPayment>(OrderDirection.Incoming, rma.SourceOrderID);

            HSPayment creditCardPayment = paymentResponse.Items.FirstOrDefault(payment => payment.Type == OrderCloud.SDK.PaymentType.CreditCard);

            if (creditCardPayment == null)
            {
                // Items were not paid for with a credit card.  No refund to process via CardConnect.
                return;
            }
            HSPaymentTransaction creditCardPaymentTransaction = creditCardPayment.Transactions
                                                                .OrderBy(x => x.DateExecuted)
                                                                .LastOrDefault(x => x.Type == "CreditCard" && x.Succeeded);
            decimal purchaseOrderTotal = (decimal)paymentResponse.Items
                                         .Where(payment => payment.Type == OrderCloud.SDK.PaymentType.PurchaseOrder)
                                         .Select(payment => payment.Amount)
                                         .Sum();

            // Refund via CardConnect
            CardConnectInquireResponse inquiry = await _cardConnect.Inquire(new CardConnectInquireRequest
            {
                merchid  = creditCardPaymentTransaction.xp.CardConnectResponse.merchid,
                orderid  = rma.SourceOrderID,
                set      = "1",
                currency = worksheet.Order.xp.Currency.ToString(),
                retref   = creditCardPaymentTransaction.xp.CardConnectResponse.retref
            });

            decimal shippingRefund = rma.Type == RMAType.Cancellation ? GetShippingRefundIfCancellingAll(worksheet, rma, allRMAsOnThisOrder) : 0M;

            decimal lineTotalToRefund = rma.LineItems
                                        .Where(li => li.IsResolved &&
                                               !li.IsRefunded &&
                                               li.RefundableViaCreditCard &&
                                               (li.Status == RMALineItemStatus.PartialQtyComplete || li.Status == RMALineItemStatus.Complete)
                                               ).Select(li => li.LineTotalRefund)
                                        .Sum();

            decimal totalToRefund = lineTotalToRefund + shippingRefund;

            // Update Total Credited on RMA
            rma.TotalCredited += totalToRefund;

            // Transactions that are queued for capture can only be fully voided, and we are only allowing partial voids moving forward.
            if (inquiry.voidable == "Y" && inquiry.setlstat == QUEUED_FOR_CAPTURE)
            {
                throw new CatalystBaseException(new ApiError
                {
                    ErrorCode = "Payment.FailedToVoidAuthorization",
                    Message   = "This customer's credit card transaction is currently queued for capture and cannot be refunded at this time.  Please try again later."
                });
            }

            // If voidable, but not refundable, void the refund amount off the original order total
            if (inquiry.voidable == "Y")
            {
                await HandleVoidTransaction(worksheet, creditCardPayment, creditCardPaymentTransaction, totalToRefund, rma);
            }

            // If refundable, but not voidable, do a refund
            if (inquiry.voidable == "N")
            {
                await HandleRefundTransaction(worksheet, creditCardPayment, creditCardPaymentTransaction, totalToRefund, rma);
            }
        }
Esempio n. 19
0
        public void Notify(params object[] args)
        {
            //从事件参数中取得当前业务实体
            if (args == null || args.Length == 0 || !(args[0] is UFSoft.UBF.Business.EntityEvent))
            {
                return;
            }
            BusinessEntity.EntityKey key = ((UFSoft.UBF.Business.EntityEvent)args[0]).EntityKey;
            if (key == null)
            {
                return;
            }

            RMA rma = key.GetEntity() as RMA;

            if (rma == null)
            {
                return;
            }

            //审核时,生成条码管理档案和销售退回收货单
            if (rma.Status == RMAStatusEnum.Posted && rma.OriginalData.Status != RMAStatusEnum.Posted)
            {
                List <ProductBarCodeByRMADTO> barCodeDTOs = new List <ProductBarCodeByRMADTO>();
                //条码流水字典
                Dictionary <string, int> barCodeFlowNoDict = new Dictionary <string, int>();
                foreach (RMALine rmaline in rma.RMALines)
                {
                    int actualLength = 0;
                    if (!string.IsNullOrEmpty(rmaline.DescFlexField.PrivateDescSeg2))
                    {
                        int.TryParse(rmaline.DescFlexField.PrivateDescSeg2, out actualLength);
                    }
                    if (actualLength <= 0)
                    {
                        throw new RMALineException(rmaline.ID, "段长没有录入或者录入数值无效,无法生成条码");
                    }

                    string qcOperatorCode = rmaline.DescFlexField.PrivateDescSeg3;
                    if (string.IsNullOrEmpty(qcOperatorCode))
                    {
                        throw new RMALineException(rmaline.ID, "检验员没有录入,无法生成条码");
                    }
                    Operators qcOperator = Operators.Finder.Find(string.Format("Org={0} and Code='{1}'", rmaline.OrgKey.ID, qcOperatorCode));
                    if (qcOperator == null)
                    {
                        throw new RMALineException(rmaline.ID, "无法找到检验员对应的实体,无法生成条码");
                    }

                    int totalLength = (int)rmaline.ApplyQtyTU1;   //总长
                    int count       = totalLength / actualLength; //盘数

                    string baseBarCode = ProductBarCode.GetBaseBarCode(rmaline.ItemInfo.ItemCode, actualLength, Base.Context.LoginDate, qcOperatorCode);
                    if (!barCodeFlowNoDict.ContainsKey(baseBarCode))
                    {
                        barCodeFlowNoDict.Add(baseBarCode, ProductBarCode.GetBarCodeFlowNo(baseBarCode));
                    }

                    for (int i = 0; i < count; i++)
                    {
                        ProductBarCodeByRMADTO barCodeDTO = new ProductBarCodeByRMADTO();
                        barCodeDTO.BarCode      = ProductBarCode.GetBarCode(baseBarCode, barCodeFlowNoDict[baseBarCode]);
                        barCodeDTO.ActualLength = actualLength;
                        barCodeDTO.ItemID       = rmaline.ItemInfo.ItemIDKey.ID;
                        barCodeDTO.OrgID        = rmaline.OrgKey.ID;
                        barCodeDTO.QcOperator   = qcOperator.ID;
                        barCodeDTO.RMA          = rma.ID;
                        barCodeDTO.RMALine      = rmaline.ID;

                        barCodeDTOs.Add(barCodeDTO);
                        barCodeFlowNoDict[baseBarCode] = barCodeFlowNoDict[baseBarCode] + 1;
                    }
                }

                GenProductBarCodesByRMA genBarCode = new GenProductBarCodesByRMA();
                genBarCode.ProductBarCodeDTOs = barCodeDTOs;
                genBarCode.Do();
            }
        }
Esempio n. 20
0
        //writing to file
        //returns true if we have any data to wite
        /*public override bool CallWriteDocument(IRhinoFileWriteOptions options)
        {
            //only return true if you REALLY want to save something to the document
            //that is about to be written to disk
            if (options.Mode(IRhinoFileWriteOptions.ModeFlag.SelectedMode) == true) return false;
            if (options.Mode(IRhinoFileWriteOptions.ModeFlag.AsVersion2) == true) return false;
            if (options.Mode(IRhinoFileWriteOptions.ModeFlag.AsVersion3) == true) return false;

            //perform some other type of check to see if you need to save any data...
            //If( IHaveDataToWrite() = False ) Then Return False

            return false;
        }

        //If any ON_BinaryArchive::Write*() functions return false than you should
        //immediately return false otherwise return true if all data was written
        //successfully.  Returning false will cause Rhino to stop writing this document.
        public override bool WriteDocument(MRhinoDoc doc, OnBinaryArchive archive, IRhinoFileWriteOptions options)
        {
            //This function is called because CallWriteDocument returned True.
            //Write your plug-in data to the document

            string date_string  = System.DateTime.Now.ToShortDateString();
            string time_string = System.DateTime.Now.ToShortTimeString();

            ///It is a good idea to always start with a version number
            //so you can modify your document read/write code in the future
            if (archive.Write3dmChunkVersion(1, 0) == false) return false;
            if (archive.WriteString(date_string) == false) return false;
            if (archive.WriteString(time_string) == false) return false;

            return true;
        }*/
        public override IRhinoCommand.result Render(RMA.Rhino.IRhinoCommandContext context, bool render_preview)
        {
            /*RenderSettings settings = new RenderSettings();
            if (settings.ShowDialog() == DialogResult.OK)*/

            {

                //use . instead of cz , for floats in String.Format
                System.Globalization.CultureInfo ci = System.Globalization.CultureInfo.CreateSpecificCulture("en");

                //todo: more elegant
                MRhinoObjectIterator it = new MRhinoObjectIterator(context.m_doc, IRhinoObjectIterator.object_state.normal_or_locked_objects,
                                                          IRhinoObjectIterator.object_category.active_and_reference_objects);
                it.IncludeLights(false);
                it.IncludePhantoms(false);

                //fill list with objects from iterator
                List<IRhinoObject> objs = new List<IRhinoObject>();
                foreach (MRhinoObject obj in it)
                {
                    objs.Add(obj);
                }

                //mesh selected objects from list
                IRhinoAppRenderMeshSettings rms = RhUtil.RhinoApp().AppSettings().RenderMeshSettings();
                OnMeshParameters mp = new OnMeshParameters(rms.FastMeshParameters());

                int ui_style = 1; // simple ui
                ArrayMRhinoObjectMesh meshes = new ArrayMRhinoObjectMesh();
                IRhinoCommand.result rc = RhUtil.RhinoMeshObjects(objs.ToArray(),
                                                                  ref mp,
                                                                  ref ui_style,
                                                                  ref meshes);
                //if anything was meshed:
                if (rc == IRhinoCommand.result.success)
                {

                    // open file
                    FileStream file = new FileStream("scene.xml", FileMode.Create, FileAccess.Write);
                    TextWriter tw = new StreamWriter(file);

                    tw.WriteLine("<?xml version=\"1.0\"?>");
                    tw.WriteLine("<scene type=\"triangle\">");

                    //materials
                    tw.WriteLine(materials.serialize());

                    /*if (materialDefinition.Trim() != "")
                    {
                        materialName = material.m_material_id.ToString();
                        tw.WriteLine(string.Format(ci, "<material name=\"{0}\">", materialName));
                        tw.WriteLine(materialDefinition);
                        tw.WriteLine("</material>");
                    }*/
                    /*tw.WriteLine("<material name=\"defaultMat\">");
                tw.WriteLine("	<type sval=\"shinydiffusemat\"/>");
                tw.WriteLine("</material>");*/

                    // write meshes geometry
                    // todo: normals
                    for (int i = 0; i < meshes.Count(); i++)
                    {
                        IRhinoMaterial material = meshes[i].m_parent_object.ObjectMaterial();
                        string materialName = "";
                        material.GetUserString("yafaray_material", ref materialName);
                        if (materialName == "") materialName = "defaultMat";
                        string meshObject = writeMeshObject(meshes[i], materialName);
                        tw.WriteLine(meshObject);
                        //TODO: get somewhere smoothing angle, or better rhino should generate normals...
                        tw.WriteLine(string.Format(ci, "<smooth ID=\"{0}\" angle=\"30\"/>", i + 1));

                    }

                    tw.WriteLine(cameraFromActiveViewport());

                    //todo: scene setting dialog
                    tw.WriteLine("<background name=\"world_background\">");
                    tw.WriteLine("	<a_var fval=\"1\"/>");
                    tw.WriteLine("	<add_sun bval=\"true\"/>");
                    tw.WriteLine("	<b_var fval=\"1\"/>");
                    tw.WriteLine("	<background_light bval=\"true\"/>");
                    tw.WriteLine("	<c_var fval=\"1\"/>");
                    tw.WriteLine("	<d_var fval=\"1\"/>");
                    tw.WriteLine("	<e_var fval=\"1\"/>");
                    tw.WriteLine("	<from x=\"1\" y=\"1\" z=\"1\"/>");
                    tw.WriteLine("	<light_samples ival=\"8\"/>");
                    tw.WriteLine("	<power fval=\"1\"/>");
                    tw.WriteLine("	<sun_power fval=\"1\"/>");
                    tw.WriteLine("	<turbidity fval=\"3\"/>");
                    tw.WriteLine("	<type sval=\"sunsky\"/>");
                    tw.WriteLine("</background>");
                    tw.WriteLine("");
                    tw.WriteLine("<integrator name=\"default\">");
                    tw.WriteLine("	<caustics bval=\"false\"/>");
                    tw.WriteLine("	<raydepth ival=\"4\"/>");
                    tw.WriteLine("	<shadowDepth ival=\"4\"/>");
                    tw.WriteLine("	<transpShad bval=\"false\"/>");
                    tw.WriteLine("	<type sval=\"directlighting\"/>");
                    tw.WriteLine("</integrator>");
                    tw.WriteLine("");
                    tw.WriteLine("<integrator name=\"default2\">");
                    tw.WriteLine("	<caustics bval=\"false\"/>");
                    tw.WriteLine("	<raydepth ival=\"4\"/>");
                    tw.WriteLine("	<shadowDepth ival=\"4\"/>");
                    tw.WriteLine("	<transpShad bval=\"false\"/>");
                    tw.WriteLine("	<type sval=\"directlighting\"/>");
                    tw.WriteLine("</integrator>");
                    tw.WriteLine("<integrator name=\"volintegr\">");
                    tw.WriteLine("	<type sval=\"none\"/>");
                    tw.WriteLine("</integrator>");
                    tw.WriteLine("<integrator name=\"default3\">");
                    tw.WriteLine("	<caustics bval=\"false\"/>");
                    tw.WriteLine("	<raydepth ival=\"4\"/>");
                    tw.WriteLine("	<shadowDepth ival=\"4\"/>");
                    tw.WriteLine("	<transpShad bval=\"false\"/>");
                    tw.WriteLine("	<type sval=\"directlighting\"/>");
                    tw.WriteLine("</integrator>");
                    tw.WriteLine("<integrator name=\"volintegr\">");
                    tw.WriteLine("	<type sval=\"none\"/>");
                    tw.WriteLine("</integrator>");
                    tw.WriteLine("<integrator name=\"default4\">");
                    tw.WriteLine("	<caustics bval=\"false\"/>");
                    tw.WriteLine("	<raydepth ival=\"4\"/>");
                    tw.WriteLine("	<shadowDepth ival=\"4\"/>");
                    tw.WriteLine("	<transpShad bval=\"false\"/>");
                    tw.WriteLine("	<type sval=\"directlighting\"/>");
                    tw.WriteLine("</integrator>");
                    tw.WriteLine("<integrator name=\"volintegr\">");
                    tw.WriteLine("	<type sval=\"none\"/>");
                    tw.WriteLine("</integrator>");
                    tw.WriteLine("<integrator name=\"default5\">");
                    tw.WriteLine("	<caustics bval=\"false\"/>");
                    tw.WriteLine("	<raydepth ival=\"4\"/>");
                    tw.WriteLine("	<shadowDepth ival=\"4\"/>");
                    tw.WriteLine("	<transpShad bval=\"false\"/>");
                    tw.WriteLine("	<type sval=\"directlighting\"/>");
                    tw.WriteLine("</integrator>");
                    tw.WriteLine("<integrator name=\"volintegr\">");
                    tw.WriteLine("	<type sval=\"none\"/>");
                    tw.WriteLine("</integrator>");
                    tw.WriteLine("<integrator name=\"default6\">");
                    tw.WriteLine("	<caustics bval=\"false\"/>");
                    tw.WriteLine("	<raydepth ival=\"4\"/>");
                    tw.WriteLine("	<shadowDepth ival=\"4\"/>");
                    tw.WriteLine("	<transpShad bval=\"false\"/>");
                    tw.WriteLine("	<type sval=\"directlighting\"/>");
                    tw.WriteLine("</integrator>");
                    tw.WriteLine("<integrator name=\"volintegr\">");
                    tw.WriteLine("	<type sval=\"none\"/>");
                    tw.WriteLine("</integrator>");
                    tw.WriteLine("<integrator name=\"default7\">");
                    tw.WriteLine("	<caustics bval=\"false\"/>");
                    tw.WriteLine("	<raydepth ival=\"4\"/>");
                    tw.WriteLine("	<shadowDepth ival=\"4\"/>");
                    tw.WriteLine("	<transpShad bval=\"false\"/>");
                    tw.WriteLine("	<type sval=\"directlighting\"/>");
                    tw.WriteLine("</integrator>");
                    tw.WriteLine("<integrator name=\"volintegr\">");
                    tw.WriteLine("	<type sval=\"none\"/>");
                    tw.WriteLine("</integrator>");

                    tw.WriteLine("");
                    tw.WriteLine("<render>");
                    tw.WriteLine("	<AA_inc_samples ival=\"1\"/>");
                    tw.WriteLine("	<AA_minsamples ival=\"1\"/>");
                    tw.WriteLine("	<AA_passes ival=\"1\"/>");
                    tw.WriteLine("	<AA_pixelwidth fval=\"1.5\"/>");
                    tw.WriteLine("	<AA_threshold fval=\"0.05\"/>");
                    tw.WriteLine("	<background_name sval=\"world_background\"/>");
                    tw.WriteLine("	<camera_name sval=\"cam\"/>");
                    tw.WriteLine("	<clamp_rgb bval=\"false\"/>");
                    tw.WriteLine("	<filter_type sval=\"box\"/>");
                    tw.WriteLine("	<gamma fval=\"1.8\"/>");
                    tw.WriteLine("	<height ival=\"600\"/>");
                    tw.WriteLine("	<integrator_name sval=\"default\"/>");
                    tw.WriteLine("	<threads ival=\"1\"/>");
                    tw.WriteLine("	<volintegrator_name sval=\"volintegr\"/>");
                    tw.WriteLine("	<width ival=\"800\"/>");
                    tw.WriteLine("	<xstart ival=\"0\"/>");
                    tw.WriteLine("	<ystart ival=\"0\"/>");
                    tw.WriteLine("	<z_channel bval=\"true\"/>");
                    tw.WriteLine("</render>");
                    tw.WriteLine("</scene>");

                    tw.Close();
                    file.Close();

                    //run yafaray
                    //todo: configurable path
                    System.Diagnostics.Process objProcess = new Process();
                    ProcessStartInfo psi = new ProcessStartInfo("cmd.exe", "/c \"c:\\Program Files\\YafaRay\\yafaray-xml.exe\" scene.xml");
                    Process.Start(psi);

                    context.m_doc.Redraw();
                }

            }
            return IRhinoCommand.result.success;
        }
Esempio n. 21
0
 public override IRhinoCommand.result RenderWindow(RMA.Rhino.IRhinoCommandContext context, bool render_preview, RMA.Rhino.MRhinoView view, System.Drawing.Rectangle rect, bool bInWindow)
 {
     //not supported for now -> just render
     return this.Render(context, render_preview);
 }
Esempio n. 22
0
 public virtual async Task <RMA> PostRMA(RMA rma)
 {
     return(await _rmaRepo.AddItemAsync(rma));
 }
Esempio n. 23
0
 public async Task <RMA> GenerateRMA(RMA rma, VerifiedUserContext verifiedUser)
 {
     return(await _rmaRepo.AddItemAsync(rma));
 }