Esempio n. 1
0
        /// <summary>Returns true if a finance charge is added, false if one is not added</summary>
        private bool AddFinanceCharge(long PatNum, DateTime date, string APR, string atLeast, string ifOver, double OverallBalance, long PriProv, long adjType)
        {
            if (date > DateTime.Today && !PrefC.GetBool(PrefName.FutureTransDatesAllowed))
            {
                MsgBox.Show(this, "Adjustments cannot be made for future dates. Finance charge was not added.");
                return(false);
            }
            InstallmentPlan installPlan = InstallmentPlans.GetOneForFam(PatNum);

            if (installPlan != null)           //Patient has an installment plan so use that APR instead.
            {
                APR = installPlan.APR.ToString();
            }
            Adjustment AdjustmentCur = new Adjustment();

            AdjustmentCur.PatNum = PatNum;
            //AdjustmentCur.DateEntry=PIn.PDate(textDate.Text);//automatically handled
            AdjustmentCur.AdjDate  = date;
            AdjustmentCur.ProcDate = date;
            AdjustmentCur.AdjType  = adjType;
            AdjustmentCur.AdjNote  = "";           //"Finance Charge";
            AdjustmentCur.AdjAmt   = Math.Round(((PIn.Double(APR) * .01d / 12d) * OverallBalance), 2);
            if (AdjustmentCur.AdjAmt.IsZero() || AdjustmentCur.AdjAmt < PIn.Double(ifOver))
            {
                //Don't add the charge if it is less than FinanceChargeOnlyIfOver; if the charge is exactly equal to FinanceChargeOnlyIfOver,
                //the charge will be added. Ex., AdjAmt=2.00 and FinanceChargeOnlyIfOver=2.00, the charge will be added.
                //Unless AdjAmt=0.00, in which case don't add a $0.00 finance charge
                return(false);
            }
            //Add an amount that is at least the amount of FinanceChargeAtLeast
            AdjustmentCur.AdjAmt  = Math.Max(AdjustmentCur.AdjAmt, PIn.Double(atLeast));
            AdjustmentCur.ProvNum = PriProv;
            Adjustments.Insert(AdjustmentCur);
            return(true);
        }
Esempio n. 2
0
        private void butOK_Click(object sender, EventArgs e)
        {
            bool hasNegAmt = false;

            foreach (MultiAdjEntry mae in _listGridEntries)
            {
                if (mae.Adj == null)
                {
                    continue;                    //Procedures
                }
                decimal remAfter = (decimal)mae.AmtRemBefore + (decimal)mae.Adj.AdjAmt;
                if (remAfter.IsLessThanZero())
                {
                    hasNegAmt = true;
                    break;
                }
            }
            if (hasNegAmt && !MsgBox.Show(this, MsgBoxButtons.OKCancel, "Remaining amount on a procedure is negative.  Continue?", "Overpaid Procedure Warning"))
            {
                return;
            }
            foreach (MultiAdjEntry row in _listGridEntries)
            {
                if (row.Adj == null)               //skip over Procedure rows
                {
                    continue;
                }
                Adjustments.Insert(row.Adj);
            }
            DialogResult = DialogResult.OK;
        }
Esempio n. 3
0
        private void AddBillingCharge(long PatNum, DateTime date, string BillingChargeAmount, long PriProv)
        {
            Adjustment AdjustmentCur = new Adjustment();

            AdjustmentCur.PatNum = PatNum;
            //AdjustmentCur.DateEntry=PIn.PDate(textDate.Text);//automatically handled
            AdjustmentCur.AdjDate  = date;
            AdjustmentCur.ProcDate = date;
            AdjustmentCur.AdjType  = PrefC.GetLong(PrefName.BillingChargeAdjustmentType);
            AdjustmentCur.AdjNote  = "";           //"Billing Charge";
            AdjustmentCur.AdjAmt   = PIn.Double(BillingChargeAmount);
            AdjustmentCur.ProvNum  = PriProv;
            Adjustments.Insert(AdjustmentCur);
        }
Esempio n. 4
0
        private void AddFinanceCharge(long PatNum, DateTime date, string APR, double OverallBalance, long PriProv)
        {
            Adjustment AdjustmentCur = new Adjustment();

            AdjustmentCur.PatNum = PatNum;
            //AdjustmentCur.DateEntry=PIn.PDate(textDate.Text);//automatically handled
            AdjustmentCur.AdjDate  = date;
            AdjustmentCur.ProcDate = date;
            AdjustmentCur.AdjType  = PrefC.GetLong(PrefName.FinanceChargeAdjustmentType);
            AdjustmentCur.AdjNote  = "";           //"Finance Charge";
            AdjustmentCur.AdjAmt   = Math.Round(((PIn.Double(APR) * .01d / 12d) * OverallBalance), 2);
            AdjustmentCur.ProvNum  = PriProv;
            Adjustments.Insert(AdjustmentCur);
        }
Esempio n. 5
0
 private void butOK_Click(object sender, EventArgs e)
 {
     if (_listGridEntries.Any(x => x.RemAfter.IsLessThan(0)) &&
         !MsgBox.Show(this, MsgBoxButtons.OKCancel, "Remaining amount on a procedure is negative.  Continue?", "Overpaid Procedure Warning"))
     {
         return;
     }
     foreach (MultiAdjEntry row in _listGridEntries)
     {
         if (row.Adj == null)               //skip over Procedure rows
         {
             continue;
         }
         Adjustments.Insert(row.Adj);
     }
     DialogResult = DialogResult.OK;
 }
Esempio n. 6
0
        private void AddBillingCharge(long PatNum, DateTime date, string BillingChargeAmount, long PriProv)
        {
            if (date > DateTime.Today && !PrefC.GetBool(PrefName.FutureTransDatesAllowed))
            {
                MsgBox.Show(this, "Adjustments cannot be made for future dates");
                return;
            }
            Adjustment AdjustmentCur = new Adjustment();

            AdjustmentCur.PatNum = PatNum;
            //AdjustmentCur.DateEntry=PIn.PDate(textDate.Text);//automatically handled
            AdjustmentCur.AdjDate  = date;
            AdjustmentCur.ProcDate = date;
            AdjustmentCur.AdjType  = PrefC.GetLong(PrefName.BillingChargeAdjustmentType);
            AdjustmentCur.AdjNote  = "";           //"Billing Charge";
            AdjustmentCur.AdjAmt   = PIn.Double(BillingChargeAmount);
            AdjustmentCur.ProvNum  = PriProv;
            Adjustments.Insert(AdjustmentCur);
        }
Esempio n. 7
0
        private void AddFinanceCharge(long PatNum, DateTime date, string APR, double OverallBalance, long PriProv)
        {
            InstallmentPlan installPlan = InstallmentPlans.GetOneForFam(PatNum);

            if (installPlan != null)           //Patient has an installment plan so use that APR instead.
            {
                APR = installPlan.APR.ToString();
            }
            Adjustment AdjustmentCur = new Adjustment();

            AdjustmentCur.PatNum = PatNum;
            //AdjustmentCur.DateEntry=PIn.PDate(textDate.Text);//automatically handled
            AdjustmentCur.AdjDate  = date;
            AdjustmentCur.ProcDate = date;
            AdjustmentCur.AdjType  = PrefC.GetLong(PrefName.FinanceChargeAdjustmentType);
            AdjustmentCur.AdjNote  = "";           //"Finance Charge";
            AdjustmentCur.AdjAmt   = Math.Round(((PIn.Double(APR) * .01d / 12d) * OverallBalance), 2);
            AdjustmentCur.ProvNum  = PriProv;
            Adjustments.Insert(AdjustmentCur);
        }
Esempio n. 8
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     if (textAdjDate.errorProvider1.GetError(textAdjDate) != "" ||
         textProcDate.errorProvider1.GetError(textProcDate) != "" ||
         textAmount.errorProvider1.GetError(textAmount) != ""
         )
     {
         MsgBox.Show(this, "Please fix data entry errors first.");
         return;
     }
     if (textAmount.Text == "")
     {
         MessageBox.Show(Lan.g(this, "Please enter an amount."));
         return;
     }
     if (listTypeNeg.SelectedIndex == -1 && listTypePos.SelectedIndex == -1)
     {
         MsgBox.Show(this, "Please select a type first.");
         return;
     }
     if (IsNew)
     {
         //prevents backdating of initial adjustment
         if (!Security.IsAuthorized(Permissions.AdjustmentCreate, PIn.Date(textAdjDate.Text), true)) //Give message later.
         {
             if (!checkZeroAmount)                                                                   //Let user create as long as Amount is zero and has edit zero permissions.  This was checked on load.
             {
                 MessageBox.Show(Lans.g("Security", "Not authorized for") + "\r\n" + GroupPermissions.GetDesc(Permissions.AdjustmentCreate));
                 return;
             }
         }
     }
     else
     {
         //Editing an old entry will already be blocked if the date was too old, and user will not be able to click OK button
         //This catches it if user changed the date to be older.
         if (!Security.IsAuthorized(Permissions.AdjustmentEdit, PIn.Date(textAdjDate.Text)))
         {
             return;
         }
     }
     //DateEntry not allowed to change
     AdjustmentCur.AdjDate  = PIn.Date(textAdjDate.Text);
     AdjustmentCur.ProcDate = PIn.Date(textProcDate.Text);
     if (comboProv.SelectedIndex == -1)           //might be a hidden provider, so don't change.
     //	AdjustmentCur.ProvNum=PatCur.PriProv;
     {
     }
     else
     {
         AdjustmentCur.ProvNum = ProviderC.ListShort[comboProv.SelectedIndex].ProvNum;
     }
     if (!PrefC.GetBool(PrefName.EasyNoClinics))
     {
         if (comboClinic.SelectedIndex == 0)
         {
             AdjustmentCur.ClinicNum = 0;
         }
         else
         {
             AdjustmentCur.ClinicNum = Clinics.List[comboClinic.SelectedIndex - 1].ClinicNum;
         }
     }
     if (listTypePos.SelectedIndex != -1)
     {
         AdjustmentCur.AdjType = DefC.Short[(int)DefCat.AdjTypes][(int)PosIndex[listTypePos.SelectedIndex]].DefNum;
     }
     if (listTypeNeg.SelectedIndex != -1)
     {
         AdjustmentCur.AdjType = DefC.Short[(int)DefCat.AdjTypes][(int)NegIndex[listTypeNeg.SelectedIndex]].DefNum;
     }
     if (DefC.GetValue(DefCat.AdjTypes, AdjustmentCur.AdjType) == "+")         //pos
     {
         AdjustmentCur.AdjAmt = PIn.Double(textAmount.Text);
     }
     else             //neg
     {
         AdjustmentCur.AdjAmt = -PIn.Double(textAmount.Text);
     }
     if (checkZeroAmount)
     {
         if (AdjustmentCur.AdjAmt != 0)
         {
             MsgBox.Show(this, "Amount has to be 0.00 due to security permission.");
             return;
         }
     }
     AdjustmentCur.AdjNote = textNote.Text;
     try{
         if (IsNew)
         {
             Adjustments.Insert(AdjustmentCur);
         }
         else
         {
             Adjustments.Update(AdjustmentCur);
         }
     }
     catch (Exception ex) {          //even though it doesn't currently throw any exceptions
         MessageBox.Show(ex.Message);
         return;
     }
     if (IsNew)
     {
         SecurityLogs.MakeLogEntry(Permissions.AdjustmentCreate, AdjustmentCur.PatNum,
                                   Patients.GetLim(AdjustmentCur.PatNum).GetNameLF() + ", "
                                   + AdjustmentCur.AdjAmt.ToString("c"));
     }
     else
     {
         SecurityLogs.MakeLogEntry(Permissions.AdjustmentEdit, AdjustmentCur.PatNum,
                                   Patients.GetLim(AdjustmentCur.PatNum).GetNameLF() + ", "
                                   + AdjustmentCur.AdjAmt.ToString("c"));
     }
     DialogResult = DialogResult.OK;
 }
Esempio n. 9
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            bool isDiscountPlanAdj = (Defs.GetValue(DefCat.AdjTypes, _adjustmentCur.AdjType) == "dp");

            if (textAdjDate.errorProvider1.GetError(textAdjDate) != "" ||
                textProcDate.errorProvider1.GetError(textProcDate) != "" ||
                textAmount.errorProvider1.GetError(textAmount) != "")
            {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return;
            }
            if (PIn.Date(textAdjDate.Text).Date > DateTime.Today.Date && !PrefC.GetBool(PrefName.FutureTransDatesAllowed))
            {
                MsgBox.Show(this, "Adjustment date can not be in the future.");
                return;
            }
            if (textAmount.Text == "")
            {
                MessageBox.Show(Lan.g(this, "Please enter an amount."));
                return;
            }
            if (!isDiscountPlanAdj && listTypeNeg.SelectedIndex == -1 && listTypePos.SelectedIndex == -1)
            {
                MsgBox.Show(this, "Please select a type first.");
                return;
            }
            if (IsNew && AvaTax.IsEnabled() && listTypePos.SelectedIndex > -1 &&
                (_listAdjPosCats[listTypePos.SelectedIndex].DefNum == AvaTax.SalesTaxAdjType || _listAdjPosCats[listTypePos.SelectedIndex].DefNum == AvaTax.SalesTaxReturnAdjType) &&
                !Security.IsAuthorized(Permissions.SalesTaxAdjEdit))
            {
                return;
            }
            if (PrefC.GetInt(PrefName.RigorousAdjustments) == 0 && _adjustmentCur.ProcNum == 0)
            {
                MsgBox.Show(this, "You must attach a procedure to the adjustment.");
                return;
            }
            if (_adjRemAmt < 0)
            {
                if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Remaining amount is negative.  Continue?", "Overpaid Procedure Warning"))
                {
                    return;
                }
            }
            bool            changeAdjSplit         = false;
            List <PaySplit> listPaySplitsForAdjust = new List <PaySplit>();

            if (IsNew)
            {
                //prevents backdating of initial adjustment
                if (!Security.IsAuthorized(Permissions.AdjustmentCreate, PIn.Date(textAdjDate.Text), true)) //Give message later.
                {
                    if (!_checkZeroAmount)                                                                  //Let user create as long as Amount is zero and has edit zero permissions.  This was checked on load.
                    {
                        MessageBox.Show(Lans.g("Security", "Not authorized for") + "\r\n" + GroupPermissions.GetDesc(Permissions.AdjustmentCreate));
                        return;
                    }
                }
            }
            else
            {
                //Editing an old entry will already be blocked if the date was too old, and user will not be able to click OK button
                //This catches it if user changed the date to be older.
                if (!Security.IsAuthorized(Permissions.AdjustmentEdit, PIn.Date(textAdjDate.Text)))
                {
                    return;
                }
                if (_adjustmentCur.ProvNum != comboProv.GetSelectedProvNum())
                {
                    listPaySplitsForAdjust = PaySplits.GetForAdjustments(new List <long>()
                    {
                        _adjustmentCur.AdjNum
                    });
                    foreach (PaySplit paySplit in listPaySplitsForAdjust)
                    {
                        if (!Security.IsAuthorized(Permissions.PaymentEdit, Payments.GetPayment(paySplit.PayNum).PayDate))
                        {
                            return;
                        }
                        if (comboProv.GetSelectedProvNum() != paySplit.ProvNum && PrefC.GetInt(PrefName.RigorousAccounting) == (int)RigorousAdjustments.EnforceFully)
                        {
                            changeAdjSplit = true;
                            break;
                        }
                    }
                    if (changeAdjSplit &&
                        !MsgBox.Show(this, MsgBoxButtons.OKCancel, "The provider for the associated payment splits will be changed to match the provider on the "
                                     + "adjustment."))
                    {
                        return;
                    }
                }
            }
            //DateEntry not allowed to change
            DateTime datePreviousChange = _adjustmentCur.SecDateTEdit;

            _adjustmentCur.AdjDate   = PIn.Date(textAdjDate.Text);
            _adjustmentCur.ProcDate  = PIn.Date(textProcDate.Text);
            _adjustmentCur.ProvNum   = comboProv.GetSelectedProvNum();
            _adjustmentCur.ClinicNum = comboClinic.SelectedClinicNum;
            if (listTypePos.SelectedIndex != -1)
            {
                _adjustmentCur.AdjType = _listAdjPosCats[listTypePos.SelectedIndex].DefNum;
                _adjustmentCur.AdjAmt  = PIn.Double(textAmount.Text);
            }
            if (listTypeNeg.SelectedIndex != -1)
            {
                _adjustmentCur.AdjType = _listAdjNegCats[listTypeNeg.SelectedIndex].DefNum;
                _adjustmentCur.AdjAmt  = -PIn.Double(textAmount.Text);
            }
            if (isDiscountPlanAdj)
            {
                //AdjustmentCur.AdjType is already set to a "discount plan" adj type.
                _adjustmentCur.AdjAmt = -PIn.Double(textAmount.Text);
            }
            if (_checkZeroAmount && _adjustmentCur.AdjAmt != 0)
            {
                MsgBox.Show(this, "Amount has to be 0.00 due to security permission.");
                return;
            }
            _adjustmentCur.AdjNote = textNote.Text;
            try{
                if (IsNew)
                {
                    Adjustments.Insert(_adjustmentCur);
                    SecurityLogs.MakeLogEntry(Permissions.AdjustmentCreate, _adjustmentCur.PatNum,
                                              _patCur.GetNameLF() + ", "
                                              + _adjustmentCur.AdjAmt.ToString("c"));
                    TsiTransLogs.CheckAndInsertLogsIfAdjTypeExcluded(_adjustmentCur, _isTsiAdj);
                }
                else
                {
                    Adjustments.Update(_adjustmentCur);
                    SecurityLogs.MakeLogEntry(Permissions.AdjustmentEdit, _adjustmentCur.PatNum, _patCur.GetNameLF() + ", " + _adjustmentCur.AdjAmt.ToString("c"), 0
                                              , datePreviousChange);
                }
            }
            catch (Exception ex) {          //even though it doesn't currently throw any exceptions
                MessageBox.Show(ex.Message);
                return;
            }
            if (changeAdjSplit)
            {
                PaySplits.UpdateProvForAdjust(_adjustmentCur, listPaySplitsForAdjust);
            }
            DialogResult = DialogResult.OK;
        }
Esempio n. 10
0
        private void butOK_Click(object sender, EventArgs e)
        {
            if (_listGridEntries.FindAll(x => x.Adj != null).Count == 0)         //no adjustments have been added. Attempt to add adjustments with the current info.
            //get the list of selected procedures to add adjustments to (if there are any). Will make one for unattached if none exist.
            {
                List <MultiAdjEntry> listSelectedEntries = new List <MultiAdjEntry>();
                for (int i = 0; i < gridMain.SelectedIndices.Count(); i++)
                {
                    listSelectedEntries.Add((MultiAdjEntry)(gridMain.ListGridRows[gridMain.SelectedIndices[i]].Tag));
                }
                if (!IsValid(listSelectedEntries.Count))
                {
                    return;
                }
                AddAdjustments(listSelectedEntries);
                FillGrid();                //In case they get stopped at the msgBox below, they should see the new adjustments added.
            }
            //now we should be guaranteed to have adjustments
            bool hasNegAmt = false;

            foreach (MultiAdjEntry mae in _listGridEntries)
            {
                if (mae.Adj == null || mae.Proc == null)
                {
                    continue;                    //Procedures or unattached adjustments
                }
                decimal remAfter = (decimal)mae.AmtRemBefore + (decimal)mae.Adj.AdjAmt;
                if (remAfter.IsLessThanZero())
                {
                    hasNegAmt = true;
                    break;
                }
            }
            if (hasNegAmt && !MsgBox.Show(this, MsgBoxButtons.OKCancel, "Remaining amount on a procedure is negative.  Continue?", "Overpaid Procedure Warning"))
            {
                return;
            }
            if (!Security.IsAuthorized(Permissions.AdjustmentCreate, true))            //User does not have full edit permission.
            //Therefore the user only has the ability to edit $0 adjustments (see Load()).
            {
                foreach (MultiAdjEntry row in _listGridEntries)
                {
                    if (row.Adj == null)                   //skip over Procedure rows
                    {
                        continue;
                    }
                    if (!row.Adj.AdjAmt.IsZero())
                    {
                        MsgBox.Show(this, "Amount has to be 0.00 due to security permission.");
                        return;
                    }
                }
            }
            List <string> listAdjustmentAmounts = new List <string>();

            foreach (MultiAdjEntry row in _listGridEntries)
            {
                if (row.Adj == null)               //skip over Procedure rows
                {
                    continue;
                }
                Adjustments.Insert(row.Adj);
                TsiTransLogs.CheckAndInsertLogsIfAdjTypeExcluded(row.Adj);
                listAdjustmentAmounts.Add(row.Adj.AdjAmt.ToString("c"));
            }
            if (listAdjustmentAmounts.Count > 0)
            {
                string log = Lan.g(this, "Adjustment(s) created from Multiple Adjustments window:") + " ";
                SecurityLogs.MakeLogEntry(Permissions.AdjustmentCreate, _patCur.PatNum, log + string.Join(",", listAdjustmentAmounts));
            }
            DialogResult = DialogResult.OK;
        }