/// <summary>
 /// Function to check party balance with reference
 /// </summary>
 /// <returns></returns>
 public int PartyBalanceCheckWithReference()
 {
     int inF1 = 0;
     decimal decPartyBalanceAmount = 0;
     decimal decGrandTotal = 0;
     try
     {
         bool isRef = false;
         AccountLedgerBll bllAccountLedger = new AccountLedgerBll();
         //PartyBalanceSP spPartyBalance = new PartyBalanceSP();
         PartyBalanceBll BllPartyBalance = new PartyBalanceBll();
         isRef = bllAccountLedger.PartyBalanceAgainstReferenceCheck(strVoucherNo, decPurchaseInvoiceVoucherTypeId);
         if (isRef)
         {
             decPartyBalanceAmount = BllPartyBalance.PartyBalanceAmountViewByVoucherNoVoucherTypeIdAndReferenceType
                 (strVoucherNo, decPurchaseInvoiceVoucherTypeId, "Against");
             decGrandTotal = Convert.ToDecimal(txtGrandTotal.Text);
             if (decGrandTotal >= decPartyBalanceAmount)
             {
                 inF1 = 1;
             }
             else
             {
                 inF1 = 0;
                 Messages.InformationMessage("There is a payment voucher against this invoice so grand total should not be less than " + decPartyBalanceAmount);
             }
         }
         else
         {
             inF1 = 1;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PI36:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     return inF1;
 }