Ejemplo n.º 1
0
        private OrderPaymentStatus EvaluatePaymentStatus(Order o, OrderPaymentSummary s)
        {
            OrderPaymentStatus result = OrderPaymentStatus.Unknown;

            if (s.AmountDue < 0)
            {
                // Refund Due = Overpaid
                result = OrderPaymentStatus.Overpaid;
            }
            else
            {
                if (s.AmountDue == 0)
                {
                    result = OrderPaymentStatus.Paid;
                }
                else
                {
                    // Amount Due = positive at this point
                    if (s.TotalCredit > 0)
                    {
                        result = OrderPaymentStatus.PartiallyPaid;
                    }
                    else
                    {
                        result = OrderPaymentStatus.Unpaid;
                    }
                }
            }

            o.PaymentStatus = result;
            return(result);
        }
Ejemplo n.º 2
0
 public async Task <bool> Delete(OrderPaymentStatus OrderPaymentStatus)
 {
     if (await ValidateId(OrderPaymentStatus))
     {
     }
     return(OrderPaymentStatus.IsValidated);
 }
Ejemplo n.º 3
0
        public static string OrderPaymentStatus(OrderPaymentStatus e)
        {
            var result = string.Empty;

            switch (e)
            {
            case Orders.OrderPaymentStatus.Overpaid:
                result = "Overpaid";
                break;

            case Orders.OrderPaymentStatus.Paid:
                result = "Paid";
                break;

            case Orders.OrderPaymentStatus.PartiallyPaid:
                result = "Partially Paid";
                break;

            case Orders.OrderPaymentStatus.Unknown:
                result = "Unknown";
                break;

            case Orders.OrderPaymentStatus.Unpaid:
                result = "Unpaid";
                break;
            }

            return(result);
        }
Ejemplo n.º 4
0
 private void OnPaymentChanged(OrderPaymentStatus previousPaymentStatus, Order o, MerchantTribeApplication app)
 {
     BusinessRules.OrderTaskContext context = new BusinessRules.OrderTaskContext(app);
     context.Order  = o;
     context.UserId = o.UserID;
     context.Inputs.Add("bvsoftware", "PreviousPaymentStatus", previousPaymentStatus.ToString());
     BusinessRules.Workflow.RunByName(context, BusinessRules.WorkflowNames.PaymentChanged);
 }
Ejemplo n.º 5
0
        public virtual IActionResult GetAllOrders(OrderPaymentStatus status)
        {
            var orders = _orderService.GetAll(status);

            var dtos = orders.ToList().Select(x => x.ToDto()).ToList();

            return(new JsonResult(dtos));
        }
Ejemplo n.º 6
0
        public async Task <OrderPaymentStatus> Get(long Id)
        {
            OrderPaymentStatus OrderPaymentStatus = await UOW.OrderPaymentStatusRepository.Get(Id);

            if (OrderPaymentStatus == null)
            {
                return(null);
            }
            return(OrderPaymentStatus);
        }
Ejemplo n.º 7
0
        public static string GetOrderPaymentStatus(OrderPaymentStatus paymentStatus, string culture = null)
        {
            var value = OrderPaymentStatusesLocalization.GetFormattedString(paymentStatus.ToString(), culture);

            if (string.IsNullOrEmpty(value))
            {
                value = OrderPaymentStatusesLocalization.GetString(OrderPaymentStatus.Unknown.ToString(), culture);
            }
            return(value);
        }
Ejemplo n.º 8
0
        public OrderPaymentStatus EvaluatePaymentStatus(Order o)
        {
            OrderPaymentSummary s = new OrderPaymentSummary();

            s.Populate(o, this);
            OrderPaymentStatus result = EvaluatePaymentStatus(o, s);

            s = null;
            return(result);
        }
Ejemplo n.º 9
0
        public Company_OrderPaymentStatusDTO(OrderPaymentStatus OrderPaymentStatus)
        {
            this.Id = OrderPaymentStatus.Id;

            this.Code = OrderPaymentStatus.Code;

            this.Name = OrderPaymentStatus.Name;

            this.Errors = OrderPaymentStatus.Errors;
        }
Ejemplo n.º 10
0
        public CustomerSalesOrder_OrderPaymentStatusDTO(OrderPaymentStatus OrderPaymentStatus)
        {
            this.Id = OrderPaymentStatus.Id;

            this.Code = OrderPaymentStatus.Code;

            this.Name = OrderPaymentStatus.Name;

            this.Errors = OrderPaymentStatus.Errors;
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Counts the number of orders for given search criteria
        /// </summary>
        /// <param name="orderStatusId">order status Id of the orders to search</param>
        /// <param name="paymentStatus">payment status of the orders to search</param>
        /// <param name="shipmentStatus">shipment status of the orders to search</param>
        /// <param name="startDate">starting date for search</param>
        /// <param name="endDate">ending date for search</param>
        /// <returns>The number of orders for given search criteria</returns>
        public static int SearchCount(int orderStatusId, OrderPaymentStatus paymentStatus, OrderShipmentStatus shipmentStatus, DateTime startDate, DateTime endDate)
        {
            //COUNT ORDER IDS THAT FIT THE CRITERIA
            StringBuilder countQuery = new StringBuilder();

            countQuery.Append("SELECT COUNT(*) AS SearchCount");
            countQuery.Append(" FROM ac_Orders");
            countQuery.Append(" WHERE StoreId = @storeId");
            if (orderStatusId != 0)
            {
                countQuery.Append(" AND OrderStatusId = @orderStatusId");
            }
            if (paymentStatus != OrderPaymentStatus.Unspecified)
            {
                countQuery.Append(" AND PaymentStatusId = @paymentStatusId");
            }
            if (shipmentStatus != OrderShipmentStatus.Unspecified)
            {
                countQuery.Append(" AND ShipmentStatusId = @shipmentStatusId");
            }
            if (startDate > DateTime.MinValue)
            {
                countQuery.Append(" AND OrderDate >= @startDate");
            }
            if (endDate > DateTime.MinValue)
            {
                countQuery.Append(" AND OrderDate <= @endDate");
            }
            Database  database     = Token.Instance.Database;
            DbCommand countCommand = database.GetSqlStringCommand(countQuery.ToString());

            database.AddInParameter(countCommand, "@storeId", System.Data.DbType.Int32, Token.Instance.StoreId);
            if (orderStatusId != 0)
            {
                database.AddInParameter(countCommand, "@orderStatusId", System.Data.DbType.Int32, orderStatusId);
            }
            if (startDate > DateTime.MinValue)
            {
                database.AddInParameter(countCommand, "@startDate", System.Data.DbType.DateTime, startDate);
            }
            if (endDate > DateTime.MinValue)
            {
                database.AddInParameter(countCommand, "@endDate", System.Data.DbType.DateTime, endDate);
            }
            if (paymentStatus != OrderPaymentStatus.Unspecified)
            {
                database.AddInParameter(countCommand, "@paymentStatus", System.Data.DbType.Byte, paymentStatus);
            }
            if (shipmentStatus != OrderShipmentStatus.Unspecified)
            {
                database.AddInParameter(countCommand, "@shipmentStatus", System.Data.DbType.Byte, shipmentStatus);
            }
            return(AlwaysConvert.ToInt(database.ExecuteScalar(countCommand)));
        }
Ejemplo n.º 12
0
        private void OnPaymentChanged(OrderPaymentStatus previousPaymentStatus, Order o)
        {
            var context = new OrderTaskContext(Context)
            {
                Order  = o,
                UserId = o.UserID,
                PreviousPaymentStatus = previousPaymentStatus
            };

            Workflow.RunByName(context, WorkflowNames.PaymentChanged);
        }
Ejemplo n.º 13
0
        public async Task <bool> UpdateOrderPaymentStatus(string paymentIntentId, OrderPaymentStatus order_pymnt_status)
        {
            var sql = @"UPDATE customer_orders SET  order_pymnt_status = @order_pymnt_status  WHERE paymentIntentId = @paymentIntentId";

            using (var connection = this.GetOpenConnection())
            {
                int rows = await connection.ExecuteAsync(sql, new { order_pymnt_status = order_pymnt_status.ToString(), paymentIntentId = paymentIntentId });

                return(rows != 0);
            }
        }
Ejemplo n.º 14
0
 /// <summary>
 /// Initializes a new instance of the OrderFilter class.
 /// </summary>
 public OrderFilter()
 {
     _OrderDateStart   = DateTime.MinValue;
     _OrderDateEnd     = DateTime.MaxValue;
     _OrderIdRange     = string.Empty;
     _OrderNumberRange = string.Empty;
     _PaymentStatus    = OrderPaymentStatus.Unspecified;
     _ShipmentStatus   = OrderShipmentStatus.Unspecified;
     _OrderStatus      = new IdList();
     _Keyword          = string.Empty;
     _KeywordField     = KeywordFieldType.All;
 }
Ejemplo n.º 15
0
        /// <summary>
        /// Helper to convert enum to a valid string sent/received in from the API
        /// <returns>String</returns>
        /// </summary>
        public static String OrderPaymentStatusToString(OrderPaymentStatus value)
        {
            switch (value)
            {
            case OrderPaymentStatus.Pending: return("0");

            case OrderPaymentStatus.Authorized: return("100");

            case OrderPaymentStatus.Captured: return("200");

            case OrderPaymentStatus.PartiallyCaptured: return("201");
            }
            return("");
        }
Ejemplo n.º 16
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public OrderSearchCriteria()
 {
     _OrderDateStart   = DateTime.MinValue;
     _OrderDateEnd     = DateTime.MaxValue;
     _OrderIdRange     = string.Empty;
     _OrderIdStart     = 0;
     _OrderIdEnd       = 0;
     _OrderNumberRange = string.Empty;
     _OrderNumberStart = 0;
     _OrderNumberEnd   = 0;
     _PaymentStatus    = OrderPaymentStatus.Unspecified;
     _ShipmentStatus   = OrderShipmentStatus.Unspecified;
     _OrderStatus      = new IdList();
     _Filter           = new Collection <MatchCriteria>();
 }
Ejemplo n.º 17
0
        internal static void UpdatePaymentStatus(Order order, OrderPaymentStatus paymentStatus)
        {
            bool saveDirty = order.IsDirty;

            order.PaymentStatus = paymentStatus;
            string   updateQuery = "UPDATE ac_Orders SET PaymentStatusId = @paymentStatus WHERE OrderId = @orderId";
            Database database    = Token.Instance.Database;

            using (System.Data.Common.DbCommand updateCommand = database.GetSqlStringCommand(updateQuery))
            {
                database.AddInParameter(updateCommand, "@paymentStatus", System.Data.DbType.Byte, (byte)paymentStatus);
                database.AddInParameter(updateCommand, "@orderId", System.Data.DbType.Int32, order.OrderId);
                if (database.ExecuteNonQuery(updateCommand) > 0)
                {
                    order.IsDirty = saveDirty;
                }
            }
        }
Ejemplo n.º 18
0
        public async Task <OrderPaymentStatus> Get(long Id)
        {
            OrderPaymentStatus OrderPaymentStatus = await DataContext.OrderPaymentStatus.AsNoTracking()
                                                    .Where(x => x.Id == Id)
                                                    .Select(x => new OrderPaymentStatus()
            {
                Id   = x.Id,
                Code = x.Code,
                Name = x.Name,
            }).FirstOrDefaultAsync();

            if (OrderPaymentStatus == null)
            {
                return(null);
            }

            return(OrderPaymentStatus);
        }
Ejemplo n.º 19
0
        public bool AddPaymentTransactionToOrder(Order o, OrderTransaction t, MerchantTribeApplication app)
        {
            // Save Order First if no bvin
            Orders.Upsert(o);

            t.OrderId     = o.bvin;
            t.OrderNumber = o.OrderNumber;
            t.StoreId     = o.StoreId;

            if (Transactions.Create(t))
            {
                OrderPaymentStatus previous = o.PaymentStatus;
                EvaluatePaymentStatus(o);
                OnPaymentChanged(previous, o, app);
                return(Orders.Update(o));
            }

            return(false);
        }
Ejemplo n.º 20
0
        public virtual IList <Order> GetAll(OrderPaymentStatus status)
        {
            var OrdersQuery = _orderRepo.TableNoTracking;

            switch (status)
            {
            case OrderPaymentStatus.paid:
                OrdersQuery = OrdersQuery.Where(o => o.IsPaid == true);
                break;

            case OrderPaymentStatus.notpaid:
                OrdersQuery = OrdersQuery.Where(o => o.IsPaid == false);
                break;

            default:
                break;
            }

            return(OrdersQuery.ToList());
        }
Ejemplo n.º 21
0
        public async Task <bool> ValidateId(OrderPaymentStatus OrderPaymentStatus)
        {
            OrderPaymentStatusFilter OrderPaymentStatusFilter = new OrderPaymentStatusFilter
            {
                Skip = 0,
                Take = 10,
                Id   = new IdFilter {
                    Equal = OrderPaymentStatus.Id
                },
                Selects = OrderPaymentStatusSelect.Id
            };

            int count = await UOW.OrderPaymentStatusRepository.Count(OrderPaymentStatusFilter);

            if (count == 0)
            {
                OrderPaymentStatus.AddError(nameof(OrderPaymentStatusValidator), nameof(OrderPaymentStatus.Id), ErrorCode.IdNotExisted);
            }
            return(count == 1);
        }
Ejemplo n.º 22
0
 public async Task <bool> Create(OrderPaymentStatus OrderPaymentStatus)
 {
     return(OrderPaymentStatus.IsValidated);
 }
Ejemplo n.º 23
0
 public Order(OrderPaymentStatus paymentStatus)
 {
     PaymentStatus = paymentStatus.ToString().ToLower();
 }
Ejemplo n.º 24
0
 public static OrderCollection Search(int orderStatusId, OrderPaymentStatus paymentStatus, OrderShipmentStatus shipmentStatus, DateTime startDate, DateTime endDate, string sortExpression)
 {
     return(OrderDataSource.Search(orderStatusId, paymentStatus, shipmentStatus, startDate, endDate, 0, 0, sortExpression));
 }
Ejemplo n.º 25
0
 public async Task <bool> UpdateOrderPaymentStatus(string paymentIntentId, OrderPaymentStatus order_payment_status)
 {
     return(await unitOfWork.Orders.UpdateOrderPaymentStatus(paymentIntentId, order_payment_status));
 }
Ejemplo n.º 26
0
 private void OnPaymentChanged(OrderPaymentStatus previousPaymentStatus, Order o, MerchantTribeApplication app)
 {
     BusinessRules.OrderTaskContext context = new BusinessRules.OrderTaskContext(app);
     context.Order = o;
     context.UserId = o.UserID;
     context.Inputs.Add("bvsoftware", "PreviousPaymentStatus", previousPaymentStatus.ToString());
     BusinessRules.Workflow.RunByName(context, BusinessRules.WorkflowNames.PaymentChanged);
 }
Ejemplo n.º 27
0
        public static OrderCollection Search(int orderStatusId, OrderPaymentStatus paymentStatus, OrderShipmentStatus shipmentStatus, DateTime startDate, DateTime endDate, int maximumRows, int startRowIndex, string sortExpression)
        {
            //SET DEFAULT SORT
            if (string.IsNullOrEmpty(sortExpression))
            {
                sortExpression = "OrderDate DESC";
            }
            //CREATE THE DYNAMIC SQL TO LOAD OBJECT
            StringBuilder selectQuery = new StringBuilder();

            selectQuery.Append("SELECT");
            if (maximumRows > 0)
            {
                selectQuery.Append(" TOP " + (startRowIndex + maximumRows).ToString());
            }
            selectQuery.Append(" " + Order.GetColumnNames(string.Empty));
            selectQuery.Append(" FROM ac_Orders");
            selectQuery.Append(" WHERE StoreId = @storeId");
            if (orderStatusId != 0)
            {
                selectQuery.Append(" AND OrderStatusId = @orderStatusId");
            }
            if (paymentStatus != OrderPaymentStatus.Unspecified)
            {
                selectQuery.Append(" AND PaymentStatusId = @paymentStatus");
            }
            if (shipmentStatus != OrderShipmentStatus.Unspecified)
            {
                selectQuery.Append(" AND ShipmentStatusId = @shipmentStatus");
            }
            if (startDate > DateTime.MinValue)
            {
                selectQuery.Append(" AND OrderDate >= @startDate");
            }
            if (endDate > DateTime.MinValue)
            {
                selectQuery.Append(" AND OrderDate <= @endDate");
            }
            selectQuery.Append(" ORDER BY " + sortExpression);
            //BUILD THE COMMAND
            Database  database      = Token.Instance.Database;
            DbCommand selectCommand = database.GetSqlStringCommand(selectQuery.ToString());

            database.AddInParameter(selectCommand, "@storeId", System.Data.DbType.Int32, Token.Instance.StoreId);
            if (orderStatusId != 0)
            {
                database.AddInParameter(selectCommand, "@orderStatusId", System.Data.DbType.Int32, orderStatusId);
            }
            if (startDate > DateTime.MinValue)
            {
                database.AddInParameter(selectCommand, "@startDate", System.Data.DbType.DateTime, startDate);
            }
            if (endDate > DateTime.MinValue)
            {
                database.AddInParameter(selectCommand, "@endDate", System.Data.DbType.DateTime, endDate);
            }
            if (paymentStatus != OrderPaymentStatus.Unspecified)
            {
                database.AddInParameter(selectCommand, "@paymentStatus", System.Data.DbType.Byte, paymentStatus);
            }
            if (shipmentStatus != OrderShipmentStatus.Unspecified)
            {
                database.AddInParameter(selectCommand, "@shipmentStatus", System.Data.DbType.Byte, shipmentStatus);
            }
            //EXECUTE THE COMMAND
            OrderCollection results   = new OrderCollection();
            int             thisIndex = 0;
            int             rowCount  = 0;

            using (IDataReader dr = database.ExecuteReader(selectCommand))
            {
                while (dr.Read() && ((maximumRows < 1) || (rowCount < maximumRows)))
                {
                    if (thisIndex >= startRowIndex)
                    {
                        Order order = new Order();
                        Order.LoadDataReader(order, dr);
                        results.Add(order);
                        rowCount++;
                    }
                    thisIndex++;
                }
                dr.Close();
            }
            return(results);
        }
Ejemplo n.º 28
0
 public async Task <bool> UpdateOrderPaymentStatus(string paymentIntentId, OrderPaymentStatus order_payment_status)
 {
     return(await customerService.UpdateOrderPaymentStatus(paymentIntentId, order_payment_status));
 }