Ejemplo n.º 1
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (textDate.errorProvider1.GetError(textDate) != ""
                )
            {
                MessageBox.Show(Lan.g(this, "Please fix data entry errors first."));
                return;
            }
            if (tb2.SelectedIndices.Length == 0)
            {
                MessageBox.Show(Lan.g(this, "At least one item must be selected, or use the delete button."));
                return;
            }
            if (comboClinic.SelectedIndex == 0)
            {
                ClaimPaymentCur.ClinicNum = 0;
            }
            else
            {
                ClaimPaymentCur.ClinicNum = Clinics.List[comboClinic.SelectedIndex - 1].ClinicNum;
            }
            ClaimPaymentCur.CheckAmt    = PIn.PDouble(textAmount.Text);
            ClaimPaymentCur.CheckDate   = PIn.PDate(textDate.Text);
            ClaimPaymentCur.CheckNum    = textCheckNum.Text;
            ClaimPaymentCur.BankBranch  = textBankBranch.Text;
            ClaimPaymentCur.CarrierName = textCarrierName.Text;
            ClaimPaymentCur.Note        = textNote.Text;
            try{
                ClaimPayments.Update(ClaimPaymentCur);                //error thrown if trying to change amount and already attached to a deposit.
            }
            catch (ApplicationException ex) {
                MessageBox.Show(ex.Message);
                return;
            }
            //this could be optimized to only save changes.
            //Would require a starting AL to compare to.
            //But this isn't bad, since changes all saved at the very end
            ArrayList ALselected = new ArrayList();

            for (int i = 0; i < tb2.SelectedIndices.Length; i++)
            {
                ALselected.Add(tb2.SelectedIndices[i]);
            }
            for (int i = 0; i < splits.Length; i++)
            {
                if (ALselected.Contains(i))                //row is selected
                {
                    ClaimProcs.SetForClaim(splits[i].ClaimNum, ClaimPaymentCur.ClaimPaymentNum,
                                           ClaimPaymentCur.CheckDate, true);
                }
                else                 //row not selected
                {
                    ClaimProcs.SetForClaim(splits[i].ClaimNum, ClaimPaymentCur.ClaimPaymentNum,
                                           ClaimPaymentCur.CheckDate, false);
                }
            }
            DialogResult = DialogResult.OK;
        }
        /// <summary>Creates a check for the claim selected. Copied logic from FormClaimEdit.cs</summary>
        private void createCheckToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!Security.IsAuthorized(Permissions.InsPayCreate))             //date not checked here, but it will be checked when saving the check to prevent backdating
            {
                return;
            }
            if (PrefC.GetBool(PrefName.ClaimPaymentBatchOnly))
            {
                //Is there a permission in the manage module that would block this behavior? Are we sending the user into a TRAP?!
                MsgBox.Show(this, "Please use Batch Insurance in Manage Module to Finalize Payments.");
                return;
            }
            RpUnfinalizedInsPay.UnfinalizedInsPay unfinalPay = (RpUnfinalizedInsPay.UnfinalizedInsPay)gridMain.ListGridRows[gridMain.SelectedIndices[0]].Tag;
            if (unfinalPay.ClaimCur == null)
            {
                MsgBox.Show(this, "Unable to find claim for this partial payment.");
                return;
            }
            List <ClaimProc> listClaimProcForClaim = ClaimProcs.RefreshForClaim(unfinalPay.ClaimCur.ClaimNum);

            if (!listClaimProcForClaim.Any(x => x.Status.In(ClaimProcs.GetInsPaidStatuses())))
            {
                MessageBox.Show(Lan.g(this, "There are no valid received payments for this claim."));
                return;
            }
            ClaimPayment claimPayment = new ClaimPayment();

            claimPayment.CheckDate = MiscData.GetNowDateTime().Date;          //Today's date for easier tracking by the office and to avoid backdating before accounting lock dates.
            claimPayment.IsPartial = true;
            claimPayment.ClinicNum = unfinalPay.ClinicCur.ClinicNum;
            Family         famCur      = Patients.GetFamily(unfinalPay.PatientCur.PatNum);
            List <InsSub>  listInsSub  = InsSubs.RefreshForFam(famCur);
            List <InsPlan> listInsPlan = InsPlans.RefreshForSubList(listInsSub);

            claimPayment.CarrierName = Carriers.GetName(InsPlans.GetPlan(unfinalPay.ClaimCur.PlanNum, listInsPlan).CarrierNum);
            ClaimPayments.Insert(claimPayment);
            double amt = ClaimProcs.AttachAllOutstandingToPayment(claimPayment.ClaimPaymentNum, PrefC.DateClaimReceivedAfter);

            claimPayment.CheckAmt = amt;
            try {
                ClaimPayments.Update(claimPayment);
            }
            catch (ApplicationException ex) {
                MessageBox.Show(ex.Message);
                return;
            }
            FormClaimEdit.FormFinalizePaymentHelper(claimPayment, unfinalPay.ClaimCur, unfinalPay.PatientCur, famCur);
            LoadData();
            FillGrid();
        }
Ejemplo n.º 3
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (textDate.Text == "")
            {
                MsgBox.Show(this, "Please enter a date first.");
                return;
            }
            if (PIn.Date(textDate.Text).Date > DateTime.Today.Date && !PrefC.GetBool(PrefName.FutureTransDatesAllowed) &&
                !PrefC.GetBool(PrefName.AllowFutureInsPayments))
            {
                MsgBox.Show(this, "Payments cannot be for a date in the future.");
                return;                 //probably not necesasary since this is an old form, but just in case we use it again
            }
            if (textDate.errorProvider1.GetError(textDate) != "")
            {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return;
            }
            if (gridMain.SelectedIndices.Length == 0)
            {
                MessageBox.Show(Lan.g(this, "At least one item must be selected, or use the delete button."));
                return;
            }
            if (IsNew)
            {
                //prevents backdating of initial check
                if (!Security.IsAuthorized(Permissions.InsPayCreate, PIn.Date(textDate.Text)))
                {
                    return;
                }
                //prevents attaching claimprocs with a date that is older than allowed by security.
            }
            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.InsPayEdit, PIn.Date(textDate.Text)))
                {
                    return;
                }
            }
            if (comboClinic.SelectedIndex == 0)
            {
                ClaimPaymentCur.ClinicNum = 0;
            }
            else
            {
                ClaimPaymentCur.ClinicNum = _listClinics[comboClinic.SelectedIndex - 1].ClinicNum;
            }
            ClaimPaymentCur.CheckAmt    = PIn.Double(textAmount.Text);
            ClaimPaymentCur.CheckDate   = PIn.Date(textDate.Text);
            ClaimPaymentCur.CheckNum    = textCheckNum.Text;
            ClaimPaymentCur.BankBranch  = textBankBranch.Text;
            ClaimPaymentCur.CarrierName = textCarrierName.Text;
            ClaimPaymentCur.Note        = textNote.Text;
            try{
                ClaimPayments.Update(ClaimPaymentCur);                //error thrown if trying to change amount and already attached to a deposit.
            }
            catch (ApplicationException ex) {
                MessageBox.Show(ex.Message);
                return;
            }
            //this could be optimized to only save changes.
            //Would require a starting list to compare to.
            //But this isn't bad, since changes all saved at the very end
            List <int> selectedRows = new List <int>();

            for (int i = 0; i < gridMain.SelectedIndices.Length; i++)
            {
                selectedRows.Add(gridMain.SelectedIndices[i]);
            }
            for (int i = 0; i < splits.Count; i++)
            {
                if (selectedRows.Contains(i))                //row is selected
                {
                    ClaimProcs.SetForClaimOld(splits[i].ClaimNum, ClaimPaymentCur.ClaimPaymentNum, ClaimPaymentCur.CheckDate, true);
                    //Audit trail isn't perfect, since it doesn't make an entry if you remove a claim from a payment.
                    //And it always makes more audit trail entries when you click OK, even if you didn't actually attach new claims.
                    //But since this will cover the vast majority if situations.
                    if (IsNew)
                    {
                        SecurityLogs.MakeLogEntry(Permissions.InsPayCreate, splits[i].PatNum,
                                                  Patients.GetLim(splits[i].PatNum).GetNameLF() + ", "
                                                  + Lan.g(this, "Total Amt: ") + ClaimPaymentCur.CheckAmt.ToString("c") + ", "
                                                  + Lan.g(this, "Claim Split: ") + splits[i].InsPayAmt.ToString("c"));
                    }
                    else
                    {
                        SecurityLogs.MakeLogEntry(Permissions.InsPayEdit, splits[i].PatNum,
                                                  Patients.GetLim(splits[i].PatNum).GetNameLF() + ", "
                                                  + Lan.g(this, "Total Amt: ") + ClaimPaymentCur.CheckAmt.ToString("c") + ", "
                                                  + Lan.g(this, "Claim Split: ") + splits[i].InsPayAmt.ToString("c"));
                    }
                }
                else                 //row not selected
                                     //If user had not been attaching their inspayments to checks, then this will cause such payments to annoyingly have their
                                     //date changed to the current date.  This prompts them to call us.  Then, we tell them to attach to checks.
                {
                    ClaimProcs.SetForClaimOld(splits[i].ClaimNum, ClaimPaymentCur.ClaimPaymentNum, ClaimPaymentCur.CheckDate, false);
                }
            }
            DialogResult = DialogResult.OK;
        }
Ejemplo n.º 4
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     if (textDate.Text == "")
     {
         MsgBox.Show(this, "Please enter a date.");
         return;
     }
     if (textCarrierName.Text == "")
     {
         MsgBox.Show(this, "Please enter a carrier.");
         return;
     }
     if (textDate.errorProvider1.GetError(textDate) != "" ||
         textAmount.errorProvider1.GetError(textAmount) != "" ||
         textDateIssued.errorProvider1.GetError(textDateIssued) != "")
     {
         MsgBox.Show(this, "Please fix data entry errors first.");
         return;
     }
     if (PIn.Double(textAmount.Text) == 0)
     {
         MsgBox.Show(this, "Please enter an amount.");
         return;
     }
     if (IsNew)
     {
         //prevents backdating of initial check
         if (!Security.IsAuthorized(Permissions.InsPayCreate, PIn.Date(textDate.Text)))
         {
             return;
         }
         //prevents attaching claimprocs with a date that is older than allowed by security.
     }
     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.InsPayEdit, PIn.Date(textDate.Text)))
         {
             return;
         }
     }
     if (!PrefC.GetBool(PrefName.EasyNoClinics))
     {
         if (comboClinic.SelectedIndex == 0)
         {
             ClaimPaymentCur.ClinicNum = 0;
         }
         else
         {
             ClaimPaymentCur.ClinicNum = Clinics.List[comboClinic.SelectedIndex - 1].ClinicNum;
         }
     }
     ClaimPaymentCur.CheckDate   = PIn.Date(textDate.Text);
     ClaimPaymentCur.DateIssued  = PIn.Date(textDateIssued.Text);
     ClaimPaymentCur.CheckAmt    = PIn.Double(textAmount.Text);
     ClaimPaymentCur.CheckNum    = textCheckNum.Text;
     ClaimPaymentCur.BankBranch  = textBankBranch.Text;
     ClaimPaymentCur.CarrierName = textCarrierName.Text;
     ClaimPaymentCur.Note        = textNote.Text;
     try{
         if (IsNew)
         {
             ClaimPayments.Insert(ClaimPaymentCur);                    //error thrown if trying to change amount and already attached to a deposit.
         }
         else
         {
             ClaimPayments.Update(ClaimPaymentCur);                    //error thrown if trying to change amount and already attached to a deposit.
         }
     }
     catch (ApplicationException ex) {
         MessageBox.Show(ex.Message);
         return;
     }
     ClaimProcs.SynchDateCP(ClaimPaymentCur.ClaimPaymentNum, ClaimPaymentCur.CheckDate);
     DialogResult = DialogResult.OK;
 }
Ejemplo n.º 5
0
        ///<summary>Saves the selected rows to database.  MUST close window after this.</summary>
        private bool SaveToDB()
        {
            if (textDate.errorProvider1.GetError(textDate) != "")
            {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return(false);
            }
            //Prevent backdating----------------------------------------------------------------------------------------
            DateTime date = PIn.PDate(textDate.Text);

            if (IsNew)
            {
                if (!Security.IsAuthorized(Permissions.DepositSlips, date))
                {
                    return(false);
                }
            }
            else
            {
                //We enforce security here based on date displayed, not date entered
                if (!Security.IsAuthorized(Permissions.DepositSlips, date))
                {
                    return(false);
                }
            }
            DepositCur.DateDeposit = PIn.PDate(textDate.Text);
            //amount already handled.
            DepositCur.BankAccountInfo = PIn.PString(textBankAccountInfo.Text);
            if (IsNew)
            {
                Deposits.Insert(DepositCur);
                if (Accounts.DepositsLinked() && DepositCur.Amount > 0)
                {
                    //create a transaction here
                    Transaction trans = new Transaction();
                    trans.DepositNum = DepositCur.DepositNum;
                    trans.UserNum    = Security.CurUser.UserNum;
                    Transactions.Insert(trans);
                    //first the deposit entry
                    JournalEntry je = new JournalEntry();
                    je.AccountNum     = DepositAccounts[comboDepositAccount.SelectedIndex];
                    je.CheckNumber    = Lan.g(this, "DEP");
                    je.DateDisplayed  = DepositCur.DateDeposit;                 //it would be nice to add security here.
                    je.DebitAmt       = DepositCur.Amount;
                    je.Memo           = Lan.g(this, "Deposit");
                    je.Splits         = Accounts.GetDescript(PrefB.GetInt("AccountingIncomeAccount"));
                    je.TransactionNum = trans.TransactionNum;
                    JournalEntries.Insert(je);
                    //then, the income entry
                    je            = new JournalEntry();
                    je.AccountNum = PrefB.GetInt("AccountingIncomeAccount");
                    //je.CheckNumber=;
                    je.DateDisplayed  = DepositCur.DateDeposit;                 //it would be nice to add security here.
                    je.CreditAmt      = DepositCur.Amount;
                    je.Memo           = Lan.g(this, "Deposit");
                    je.Splits         = Accounts.GetDescript(DepositAccounts[comboDepositAccount.SelectedIndex]);
                    je.TransactionNum = trans.TransactionNum;
                    JournalEntries.Insert(je);
                }
            }
            else
            {
                Deposits.Update(DepositCur);
            }
            if (IsNew)            //never allowed to change or attach more checks after initial creation of deposit slip
            {
                for (int i = 0; i < gridPat.SelectedIndices.Length; i++)
                {
                    PatPayList[gridPat.SelectedIndices[i]].DepositNum = DepositCur.DepositNum;
                    Payments.Update(PatPayList[gridPat.SelectedIndices[i]]);
                }
                for (int i = 0; i < gridIns.SelectedIndices.Length; i++)
                {
                    ClaimPayList[gridIns.SelectedIndices[i]].DepositNum = DepositCur.DepositNum;
                    ClaimPayments.Update(ClaimPayList[gridIns.SelectedIndices[i]]);
                }
            }
            if (IsNew)
            {
                SecurityLogs.MakeLogEntry(Permissions.DepositSlips, 0,
                                          DepositCur.DateDeposit.ToShortDateString() + " New " + DepositCur.Amount.ToString("c"));
            }
            else
            {
                SecurityLogs.MakeLogEntry(Permissions.AdjustmentEdit, 0,
                                          DepositCur.DateDeposit.ToShortDateString() + " " + DepositCur.Amount.ToString("c"));
            }
            return(true);
        }
Ejemplo n.º 6
0
        ///<summary>Saves the selected rows to database.  MUST close window after this.</summary>
        private bool SaveToDB()
        {
            if (textDate.errorProvider1.GetError(textDate) != "")
            {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return(false);
            }
            //Prevent backdating----------------------------------------------------------------------------------------
            DateTime date = PIn.Date(textDate.Text);

            if (IsNew)
            {
                if (!Security.IsAuthorized(Permissions.DepositSlips, date))
                {
                    return(false);
                }
            }
            else
            {
                //We enforce security here based on date displayed, not date entered
                if (!Security.IsAuthorized(Permissions.DepositSlips, date))
                {
                    return(false);
                }
            }
            DepositCur.DateDeposit = PIn.Date(textDate.Text);
            //amount already handled.
            DepositCur.BankAccountInfo = PIn.String(textBankAccountInfo.Text);
            if (IsNew)
            {
                if (gridPat.SelectedIndices.Length + gridIns.SelectedIndices.Length > 18)
                {
                    if (!MsgBox.Show(this, MsgBoxButtons.YesNo, "No more than 18 items will fit on a QuickBooks deposit slip. Continue anyway?"))
                    {
                        return(false);
                    }
                }
                Deposits.Insert(DepositCur);
                if (Accounts.DepositsLinked() && DepositCur.Amount > 0)
                {
                    if (PrefC.GetInt(PrefName.AccountingSoftware) == (int)AccountingSoftware.QuickBooks)
                    {
                        //Create a deposit within QuickBooks.
                        try {
                            Cursor.Current = Cursors.WaitCursor;
                            QuickBooks.CreateDeposit(DepositAccountsQB[comboDepositAccount.SelectedIndex]
                                                     , PrefC.GetString(PrefName.QuickBooksIncomeAccount), DepositCur.Amount);
                            Cursor.Current = Cursors.Default;
                        }
                        catch (Exception ex) {
                            Cursor.Current = Cursors.Default;
                            if (MessageBox.Show(ex.Message + "\r\n\r\nA deposit has not been created in QuickBooks, continue anyway?", "QuickBooks Deposit Create Failed", MessageBoxButtons.YesNo) != DialogResult.Yes)
                            {
                                return(false);
                            }
                        }
                    }
                    else
                    {
                        //create a transaction here
                        Transaction trans = new Transaction();
                        trans.DepositNum = DepositCur.DepositNum;
                        trans.UserNum    = Security.CurUser.UserNum;
                        Transactions.Insert(trans);
                        //first the deposit entry
                        JournalEntry je = new JournalEntry();
                        je.AccountNum     = DepositAccounts[comboDepositAccount.SelectedIndex];
                        je.CheckNumber    = Lan.g(this, "DEP");
                        je.DateDisplayed  = DepositCur.DateDeposit;                     //it would be nice to add security here.
                        je.DebitAmt       = DepositCur.Amount;
                        je.Memo           = Lan.g(this, "Deposit");
                        je.Splits         = Accounts.GetDescript(PrefC.GetLong(PrefName.AccountingIncomeAccount));
                        je.TransactionNum = trans.TransactionNum;
                        JournalEntries.Insert(je);
                        //then, the income entry
                        je            = new JournalEntry();
                        je.AccountNum = PrefC.GetLong(PrefName.AccountingIncomeAccount);
                        //je.CheckNumber=;
                        je.DateDisplayed  = DepositCur.DateDeposit;                     //it would be nice to add security here.
                        je.CreditAmt      = DepositCur.Amount;
                        je.Memo           = Lan.g(this, "Deposit");
                        je.Splits         = Accounts.GetDescript(DepositAccounts[comboDepositAccount.SelectedIndex]);
                        je.TransactionNum = trans.TransactionNum;
                        JournalEntries.Insert(je);
                    }
                }
            }
            else
            {
                Deposits.Update(DepositCur);
            }
            if (IsNew)            //never allowed to change or attach more checks after initial creation of deposit slip
            {
                for (int i = 0; i < gridPat.SelectedIndices.Length; i++)
                {
                    PatPayList[gridPat.SelectedIndices[i]].DepositNum = DepositCur.DepositNum;
                    Payments.Update(PatPayList[gridPat.SelectedIndices[i]], false);
                }
                for (int i = 0; i < gridIns.SelectedIndices.Length; i++)
                {
                    ClaimPayList[gridIns.SelectedIndices[i]].DepositNum = DepositCur.DepositNum;
                    ClaimPayments.Update(ClaimPayList[gridIns.SelectedIndices[i]]);
                }
            }
            if (IsNew)
            {
                SecurityLogs.MakeLogEntry(Permissions.DepositSlips, 0,
                                          DepositCur.DateDeposit.ToShortDateString() + " New " + DepositCur.Amount.ToString("c"));
            }
            else
            {
                SecurityLogs.MakeLogEntry(Permissions.AdjustmentEdit, 0,
                                          DepositCur.DateDeposit.ToShortDateString() + " " + DepositCur.Amount.ToString("c"));
            }
            return(true);
        }