예제 #1
0
        public static RecurringCharge CreateRecurringCharge(long patNum, RecurringChargeStatus status, double chargeAmt, long creditCardNum,
                                                            DateDefaultToday dateCharge = default(DateDefaultToday))
        {
            RecurringCharge charge = new RecurringCharge {
                ChargeAmt      = chargeAmt,
                ChargeStatus   = status,
                CreditCardNum  = creditCardNum,
                PatNum         = patNum,
                DateTimeCharge = dateCharge.Date,
            };

            RecurringCharges.Insert(charge);
            return(charge);
        }
예제 #2
0
        private void menuItemDeletePending_Click(object sender, EventArgs e)
        {
            RecurringCharge charge = gridMain.SelectedTag <RecurringCharge>();

            if (charge == null || !MsgBox.Show(this, MsgBoxButtons.OKCancel, "Delete this pending recurring charge?"
                                               + "\r\n\r\nAnother user or service may be processing this card right now."))
            {
                return;
            }
            RecurringCharge chargeDb = RecurringCharges.GetOne(charge.RecurringChargeNum);

            if (chargeDb == null || chargeDb.ChargeStatus != RecurringChargeStatus.NotYetCharged)
            {
                MsgBox.Show(this, "This recurring charge is no longer pending. Unable to delete.");
                return;
            }
            RecurringCharges.Delete(charge.RecurringChargeNum);
            RefreshRecurringCharges();
            FillGrid();
        }
예제 #3
0
        ///<summary>Gets recurring charges from the database.</summary>
        private void RefreshRecurringCharges()
        {
            Cursor = Cursors.WaitCursor;
            List <SQLWhere> listWheres = new List <SQLWhere> {
                SQLWhere.CreateBetween(nameof(RecurringCharge.DateTimeCharge), datePicker.GetDateTimeFrom(), datePicker.GetDateTimeTo(), true)
            };

            if (PrefC.HasClinicsEnabled)
            {
                listWheres.Add(SQLWhere.CreateIn(nameof(RecurringCharge.ClinicNum), comboClinics.ListSelectedClinicNums));
            }
            _listRecurringCharges = RecurringCharges.GetMany(listWheres);
            if (_listRecurringCharges.Any(x => !_dictPatNames.ContainsKey(x.PatNum)))
            {
                Dictionary <long, string> dictPatNames = Patients.GetPatientNames(_listRecurringCharges.Select(x => x.PatNum).ToList());
                dictPatNames.ForEach(x => _dictPatNames[x.Key] = x.Value);
            }
            _previousDateRange      = new DateRange(datePicker.GetDateTimeFrom(), datePicker.GetDateTimeTo());
            _listPreviousClinicNums = comboClinics.ListSelectedClinicNums;
            Cursor = Cursors.Default;
        }
예제 #4
0
        ///<summary>The DataTable used to fill the grid will only be refreshed from the db if isFromDb is true.  Otherwise the grid will be refilled using
        ///the existing table.  Only get from the db on load or if the Refresh button is pressed, not when the user is selecting the clinic(s).</summary>
        private void FillGrid(bool isFromDb = false)
        {
            Cursor = Cursors.WaitCursor;
            if (isFromDb)
            {
                _charger.FillCharges(_listUserClinics);
            }
            List <long> listSelectedClinicNums = listClinics.SelectedIndices.OfType <int>().Select(x => _listUserClinics[x].ClinicNum).ToList();
            List <RecurringChargeData> listChargesCur;

            if (PrefC.HasClinicsEnabled)
            {
                listChargesCur = _charger.ListRecurringChargeData.Where(x => listSelectedClinicNums.Contains(x.RecurringCharge.ClinicNum)).ToList();
            }
            else
            {
                listChargesCur = _charger.ListRecurringChargeData;
            }
            gridMain.BeginUpdate();
            gridMain.ListGridColumns.Clear();
            gridMain.ListGridColumns.Add(new GridColumn(Lan.g("TableRecurring", "PatNum"), 55));
            gridMain.ListGridColumns.Add(new GridColumn(Lan.g("TableRecurring", "Name"), PrefC.HasClinicsEnabled?190:220));
            if (PrefC.HasClinicsEnabled)
            {
                gridMain.ListGridColumns.Add(new GridColumn(Lan.g("TableRecurring", "Clinic"), 65));
            }
            gridMain.ListGridColumns.Add(new GridColumn(Lan.g("TableRecurring", "Date"), PrefC.HasClinicsEnabled?80:80, HorizontalAlignment.Right));
            gridMain.ListGridColumns.Add(new GridColumn(Lan.g("TableRecurring", "Family Bal"), PrefC.HasClinicsEnabled?70:85, HorizontalAlignment.Right));
            gridMain.ListGridColumns.Add(new GridColumn(Lan.g("TableRecurring", "PayPlan Due"), PrefC.HasClinicsEnabled?75:85, HorizontalAlignment.Right));
            gridMain.ListGridColumns.Add(new GridColumn(Lan.g("TableRecurring", "Total Due"), PrefC.HasClinicsEnabled?65:80, HorizontalAlignment.Right));
            gridMain.ListGridColumns.Add(new GridColumn(Lan.g("TableRecurring", "Repeat Amt"), PrefC.HasClinicsEnabled?75:90, HorizontalAlignment.Right));         //RptChrgAmt
            gridMain.ListGridColumns.Add(new GridColumn(Lan.g("TableRecurring", "Charge Amt"), PrefC.HasClinicsEnabled?85:100, HorizontalAlignment.Right));
            if (Programs.HasMultipleCreditCardProgramsEnabled())
            {
                if (Programs.IsEnabled(ProgramName.Xcharge))
                {
                    gridMain.ListGridColumns.Add(new GridColumn("X-Charge", PrefC.HasClinicsEnabled ? 70 : 80, HorizontalAlignment.Center));
                }
                if (Programs.IsEnabled(ProgramName.PayConnect))
                {
                    gridMain.ListGridColumns.Add(new GridColumn("PayConnect", PrefC.HasClinicsEnabled ? 85 : 95, HorizontalAlignment.Center));
                }
                if (Programs.IsEnabled(ProgramName.PaySimple))
                {
                    gridMain.ListGridColumns.Add(new GridColumn("PaySimple", PrefC.HasClinicsEnabled ? 80 : 90, HorizontalAlignment.Center));
                }
            }
            gridMain.ListGridRows.Clear();
            GridRow row;

            foreach (RecurringChargeData chargeCur in listChargesCur)
            {
                row = new GridRow();
                double famBalTotal  = chargeCur.RecurringCharge.FamBal;             //pat bal+payplan due, but if pat bal<0 and payplan due>0 then just payplan due
                double payPlanDue   = chargeCur.RecurringCharge.PayPlanDue;
                double chargeAmt    = chargeCur.RecurringCharge.ChargeAmt;
                double rptChargeAmt = chargeCur.RecurringCharge.RepeatAmt;              //includes repeat charge (from procs if ODHQ) and attached payplan
                row.Cells.Add(chargeCur.RecurringCharge.PatNum.ToString());
                row.Cells.Add(chargeCur.PatName);
                if (PrefC.HasClinicsEnabled)
                {
                    Clinic clinicCur = _listUserClinics.FirstOrDefault(x => x.ClinicNum == chargeCur.RecurringCharge.ClinicNum);
                    row.Cells.Add(clinicCur != null?clinicCur.Description:"");                  //get description from cache if clinics are enabled
                }
                int billingDay = 0;
                if (PrefC.GetBool(PrefName.BillingUseBillingCycleDay))
                {
                    billingDay = chargeCur.BillingCycleDay;
                }
                else
                {
                    billingDay = chargeCur.RecurringChargeDate.Day;
                }
                DateTime startBillingCycle = DateTimeOD.GetMostRecentValidDate(DateTime.Today.Year, DateTime.Today.Month, billingDay);
                if (startBillingCycle > DateTime.Today)
                {
                    startBillingCycle = startBillingCycle.AddMonths(-1);             //Won't give a date with incorrect day.  AddMonths will give the end of the month if needed.
                }
                DateTime dateExcludeIfBefore = PIn.Date(textDate.Text);              //If entry is invalid, all charges will be included because this will be MinDate.
                if (startBillingCycle < dateExcludeIfBefore)
                {
                    continue;                    //Don't show row in grid
                }
                row.Cells.Add(startBillingCycle.ToShortDateString());
                row.Cells.Add(famBalTotal.ToString("c"));
                if (!payPlanDue.IsZero())
                {
                    row.Cells.Add(payPlanDue.ToString("c"));
                }
                else
                {
                    row.Cells.Add("");
                }
                row.Cells.Add(chargeCur.RecurringCharge.TotalDue.ToString("c"));
                row.Cells.Add(rptChargeAmt.ToString("c"));
                row.Cells.Add(chargeAmt.ToString("c"));
                if (!checkHideBold.Checked)
                {
                    double diff = (Math.Max(famBalTotal, 0) + Math.Max(payPlanDue, 0)) - rptChargeAmt;
                    if (diff.IsZero() || (diff < 0 && RecurringCharges.CanChargeWhenNoBal(chargeCur.CanChargeWhenNoBal)))
                    {
                        //don't bold anything
                    }
                    else if (diff > 0)
                    {
                        row.Cells[6].Bold = YN.Yes;                      //"Repeating Amt"
                        row.Cells[7].Bold = YN.Yes;                      //"Charge Amt"
                    }
                    else if (diff < 0)
                    {
                        row.Cells[5].Bold = YN.Yes;                      //"Total Due"
                        row.Cells[7].Bold = YN.Yes;                      //"Charge Amt"
                    }
                }
                if (Programs.HasMultipleCreditCardProgramsEnabled())
                {
                    if (Programs.IsEnabled(ProgramName.Xcharge))
                    {
                        row.Cells.Add(!string.IsNullOrEmpty(chargeCur.XChargeToken) ? "X" : "");
                    }
                    if (Programs.IsEnabled(ProgramName.PayConnect))
                    {
                        row.Cells.Add(!string.IsNullOrEmpty(chargeCur.PayConnectToken) ? "X" : "");
                    }
                    if (Programs.IsEnabled(ProgramName.PaySimple))
                    {
                        row.Cells.Add(!string.IsNullOrEmpty(chargeCur.PaySimpleToken) ? "X" : "");
                    }
                }
                row.Tag = chargeCur;
                gridMain.ListGridRows.Add(row);
            }
            gridMain.EndUpdate();
            labelTotal.Text    = Lan.g(this, "Total=") + gridMain.ListGridRows.Count.ToString();
            labelSelected.Text = Lan.g(this, "Selected=") + gridMain.SelectedIndices.Length.ToString();
            Cursor             = Cursors.Default;
        }