예제 #1
0
        public static ReceiptStatu Create(Receipt receipt, DateTime transitionDateTime, ReceiptStatusType type)
        {
            ReceiptStatu newReceiptStatus = new ReceiptStatu();
            newReceiptStatus.IsActive = true;
            newReceiptStatus.Receipt = receipt;
            newReceiptStatus.TransitionDateTime = transitionDateTime;
            newReceiptStatus.ReceiptStatusTypeId = type.Id;

            return newReceiptStatus;
        }
예제 #2
0
        public static ReceiptStatu ChangeStatus(Receipt receipt, ReceiptStatusType receiptStatusTo, string remarks)
        {
            var statusFrom = GetActive(receipt);
            if (statusFrom != null && statusFrom.IsActive == true)
            {
                statusFrom.IsActive = false;
            }

            ReceiptStatu status = new ReceiptStatu();
            if (statusFrom == null || statusFrom.IsActive == false)
            {
                status = Create(receipt, DateTime.Now, receiptStatusTo, true);
                status.Remarks = remarks;
            }

            Context.ReceiptStatus.AddObject(status);
            return status;
        }
예제 #3
0
        protected void btnSave_onDirectEventClick(object sender, DirectEventArgs e)
        {
            int receiptId = int.Parse(hdnReceiptID.Text);
            int paymentId = Payment.GetReceiptPayment(receiptId).Id;
            var cancelledReceiptStatusTypeId = ReceiptStatusType.CancelledReceiptStatusType.Id;
            if(!EndCurrentReceiptStatus(receiptId, cancelledReceiptStatusTypeId)) return;

            ReceiptStatu newReceiptStatus = new ReceiptStatu();
            DateTime now = DateTime.Now;

            newReceiptStatus.TransitionDateTime = now;
            newReceiptStatus.IsActive = true;
            newReceiptStatus.ReceiptStatusTypeId = cancelledReceiptStatusTypeId;
            newReceiptStatus.ReceiptId = receiptId;
            newReceiptStatus.Remarks = txtComment.Text;

            var check = ObjectContext.Cheques.SingleOrDefault(entity => entity.PaymentId == paymentId);
            if (check != null)
            {
                var checkStatus = check.ChequeStatus.SingleOrDefault(entity => entity.IsActive == true && entity.CheckId == check.Id);
                checkStatus.IsActive = false;

                ChequeStatu newCheckStatus = new ChequeStatu();

                newCheckStatus.CheckId = check.Id;
                newCheckStatus.ChequeStatusType = ChequeStatusType.CancelledType;
                newCheckStatus.TransitionDateTime = now;
                newCheckStatus.Remarks = txtComment.Text;
                newCheckStatus.IsActive = true;

                ObjectContext.ChequeStatus.AddObject(newCheckStatus);
            }

            ObjectContext.ReceiptStatus.AddObject(newReceiptStatus);
            ObjectContext.SaveChanges();
        }
예제 #4
0
        public static void ChangeReceiptStatusFrom(Receipt receipt, DateTime today, decimal balance, ReceiptStatusType fromstatustype)
        {
            //var receiptstatus = receipt.CurrentStatus;
            ReceiptStatu newreceiptstatus = new ReceiptStatu();

            if (fromstatustype.Id == ReceiptStatusType.OpenReceiptStatusType.Id && balance == 0)
            {
                //create receipt status
                var validIndicator = Context.ReceiptStatusTypeAssocs.SingleOrDefault(entity =>
                  entity.FromStatusTypeId == ReceiptStatusType.OpenReceiptStatusType.Id &&
                  entity.ToStatusTypeId == ReceiptStatusType.AppliedReceiptStatusType.Id &&
                  entity.EndDate == null);
                if (validIndicator != null)
                {
                    newreceiptstatus.Receipt = receipt;
                    newreceiptstatus.ReceiptStatusType = ReceiptStatusType.AppliedReceiptStatusType;
                    newreceiptstatus.TransitionDateTime = today;
                    newreceiptstatus.IsActive = false;
                    Context.ReceiptStatus.AddObject(newreceiptstatus);
                }
                //create next receipt status
                var validIndicator1 = Context.ReceiptStatusTypeAssocs.SingleOrDefault(entity =>
                  entity.FromStatusTypeId == ReceiptStatusType.AppliedReceiptStatusType.Id &&
                  entity.ToStatusTypeId == ReceiptStatusType.ClosedReceiptStatusType.Id &&
                  entity.EndDate == null);
                if (validIndicator1 != null)
                {
                    ReceiptStatu nextreceiptstatus = new ReceiptStatu();
                    nextreceiptstatus.Receipt = receipt;
                    nextreceiptstatus.ReceiptStatusType = ReceiptStatusType.ClosedReceiptStatusType;
                    nextreceiptstatus.TransitionDateTime = today;
                    nextreceiptstatus.IsActive = true;
                    Context.ReceiptStatus.AddObject(newreceiptstatus);
                }
            }
            else if (fromstatustype.Id == ReceiptStatusType.OpenReceiptStatusType.Id && balance != 0)
            {
                var validIndicator = Context.ReceiptStatusTypeAssocs.SingleOrDefault(entity =>
                     entity.FromStatusTypeId == ReceiptStatusType.OpenReceiptStatusType.Id &&
                     entity.ToStatusTypeId == ReceiptStatusType.AppliedReceiptStatusType.Id &&
                     entity.EndDate == null);
                if (validIndicator != null)
                {
                    newreceiptstatus.Receipt = receipt;
                    newreceiptstatus.ReceiptStatusType = ReceiptStatusType.AppliedReceiptStatusType;
                    newreceiptstatus.TransitionDateTime = today;
                    newreceiptstatus.IsActive = true;
                    Context.ReceiptStatus.AddObject(newreceiptstatus);
                }
            }
            else if (fromstatustype.Id == ReceiptStatusType.AppliedReceiptStatusType.Id && balance == 0)
            {
                var validIndicator = Context.ReceiptStatusTypeAssocs.SingleOrDefault(entity =>
                      entity.FromStatusTypeId == ReceiptStatusType.AppliedReceiptStatusType.Id &&
                      entity.ToStatusTypeId == ReceiptStatusType.ClosedReceiptStatusType.Id &&
                      entity.EndDate == null);
                if (validIndicator != null)
                {
                    newreceiptstatus.Receipt = receipt;
                    newreceiptstatus.ReceiptStatusType = ReceiptStatusType.ClosedReceiptStatusType;
                    newreceiptstatus.TransitionDateTime = today;
                    newreceiptstatus.IsActive = true;
                    Context.ReceiptStatus.AddObject(newreceiptstatus);
                }
            }
        }