public bool Savegenaralreceipt(RdReceiptDTO ObjRdReceiptDTO, NpgsqlTransaction trans, out string Receiptid)
        {
            bool                      IsSaved      = false;
            StringBuilder             sbQuery      = new StringBuilder();
            AccountingTransactionsDAL Accontstrans = new AccountingTransactionsDAL();

            try
            {
                GeneralreceiptDTO Objgeneralreceipt = new GeneralreceiptDTO();
                Objgeneralreceipt.preceiptid           = "";
                Objgeneralreceipt.ppartyid             = ObjRdReceiptDTO.pConid;
                Objgeneralreceipt.ppartyreferenceid    = ObjRdReceiptDTO.pContactid;
                Objgeneralreceipt.ppartyreftype        = "Recurring Deposit";
                Objgeneralreceipt.ppartyname           = ObjRdReceiptDTO.pMembername;
                Objgeneralreceipt.preceiptdate         = ObjRdReceiptDTO.pReceiptdate.ToString();
                Objgeneralreceipt.pmodofreceipt        = ObjRdReceiptDTO.pModeofreceipt;
                Objgeneralreceipt.ptotalreceivedamount = Convert.ToDecimal(ObjRdReceiptDTO.pReceivedamount);
                Objgeneralreceipt.pnarration           = ObjRdReceiptDTO.pNarration;
                Objgeneralreceipt.pbankname            = ObjRdReceiptDTO.pBank;
                Objgeneralreceipt.pBankId        = ObjRdReceiptDTO.pBankid;
                Objgeneralreceipt.pdepositbankid = ObjRdReceiptDTO.pdepositbankid;
                Objgeneralreceipt.pbranchname    = ObjRdReceiptDTO.pBranch;
                Objgeneralreceipt.ptranstype     = ObjRdReceiptDTO.pTranstype;
                Objgeneralreceipt.ptypeofpayment = ObjRdReceiptDTO.ptypeofpayment;
                Objgeneralreceipt.pChequenumber  = ObjRdReceiptDTO.pChequenumber;
                if (ObjRdReceiptDTO.ptypeofpayment == "Debit Card")
                {
                    Objgeneralreceipt.pchequedate = ObjRdReceiptDTO.pReceiptdate.ToString();
                }
                else if (ObjRdReceiptDTO.ptypeofpayment == "Credit Card")
                {
                    Objgeneralreceipt.pchequedate = ObjRdReceiptDTO.pReceiptdate.ToString();
                }
                else
                {
                    Objgeneralreceipt.pchequedate = ObjRdReceiptDTO.pchequedate;
                }

                Objgeneralreceipt.pCardNumber = ObjRdReceiptDTO.pCardnumber;
                Objgeneralreceipt.pUpiid      = ObjRdReceiptDTO.pUpiid;
                Objgeneralreceipt.pCreatedby  = ObjRdReceiptDTO.pCreatedby;
                List <ReceiptsDTO> preceiptslist = new List <ReceiptsDTO>();
                ReceiptsDTO        objpreceipts  = new ReceiptsDTO();
                objpreceipts.psubledgerid         = ObjRdReceiptDTO.pSubledgerid;
                objpreceipts.pledgername          = "Recurring Deposit";
                objpreceipts.ptdsamountindividual = Convert.ToDecimal(ObjRdReceiptDTO.pReceivedamount);
                objpreceipts.pamount = Convert.ToDecimal(ObjRdReceiptDTO.pReceivedamount);
                preceiptslist.Add(objpreceipts);
                Objgeneralreceipt.preceiptslist = preceiptslist;
                if (Accontstrans.CallsaveGeneralReceipt(Objgeneralreceipt, trans, out Receiptid))
                {
                    IsSaved = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(IsSaved);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> SaveRdReceipt([FromBody]  RdReceiptDTO ObjRdReceiptDTO)
        {
            try
            {
                string OUTReceiptid = string.Empty;
                if (objRdReceipt.SaveRdReceipt(ObjRdReceiptDTO, Con, out OUTReceiptid))
                {
                    if (!string.IsNullOrEmpty(OUTReceiptid))
                    {
                        if (ObjRdReceiptDTO.pModeofreceipt != "ADJUSTMENT")
                        {
                            _GeneralReceiptReportDTO = new GeneralReceiptReportDTO();
                            _GeneralReceiptReportDTO = await _AccountingTransactionsDAL.GetgeneralreceiptReportData1(OUTReceiptid, Con);

                            return(Ok(_GeneralReceiptReportDTO));
                        }
                        else
                        {
                            _JournalVoucherReportDTO = new List <JournalVoucherReportDTO>();
                            _JournalVoucherReportDTO = await _AccountingTransactionsDAL.GetJournalVoucherReportData(Con, OUTReceiptid);

                            return(Ok(_JournalVoucherReportDTO));
                        }
                    }
                    else
                    {
                        return(Ok(false));
                    }
                }
                else
                {
                    return(StatusCode(StatusCodes.Status304NotModified));
                }
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError));

                throw ex;
            }
        }
        public bool SaveRdReceipt(RdReceiptDTO ObjRdReceiptDTO, string ConnectionString, out string OUTReceiptid)
        {
            bool          Issaved        = false;
            StringBuilder sbInsert       = new StringBuilder();
            bool          IsAccountSaved = false;
            string        Referenceno    = string.Empty;

            try
            {
                con = new NpgsqlConnection(ConnectionString);
                if (con.State != ConnectionState.Open)
                {
                    con.Open();
                }
                trans = con.BeginTransaction();
                if (ObjRdReceiptDTO.pModeofreceipt != "ADJUSTMENT")
                {
                    if (Savegenaralreceipt(ObjRdReceiptDTO, trans, out OUTReceiptid))
                    {
                        IsAccountSaved = true;
                        Referenceno    = OUTReceiptid;
                    }
                }
                else
                {
                    string adjustrefno = string.Empty;
                    JournalVoucherNewDTO  objJournalVoucherDTO = new JournalVoucherNewDTO();
                    List <PaymentsNewDTO> _Paymentslist        = new List <PaymentsNewDTO>();
                    objJournalVoucherDTO.pjvdate           = ObjRdReceiptDTO.pReceiptdate;
                    objJournalVoucherDTO.pCreatedby        = ObjRdReceiptDTO.pCreatedby;
                    objJournalVoucherDTO.pnarration        = ObjRdReceiptDTO.pNarration;
                    objJournalVoucherDTO.pmodoftransaction = "MANUAL";
                    PaymentsNewDTO objPaymentsDTO = new PaymentsNewDTO
                    {
                        ppartyid     = null,
                        ptranstype   = "C",
                        psubledgerid = ObjRdReceiptDTO.pSubledgerid,
                        pamount      = Convert.ToDecimal(ObjRdReceiptDTO.pReceivedamount)
                    };
                    _Paymentslist.Add(objPaymentsDTO);
                    objPaymentsDTO = new PaymentsNewDTO
                    {
                        ptranstype        = "D",
                        ppartyid          = null,
                        ppartyname        = "",
                        ppartyreferenceid = "",
                        ppartyreftype     = ""
                    };
                    //  long creditaccountid = memberaccountid;
                    objPaymentsDTO.psubledgerid = ObjRdReceiptDTO.pSavingsMemberAccountid;
                    objPaymentsDTO.pamount      = Convert.ToDecimal(ObjRdReceiptDTO.pReceivedamount);
                    _Paymentslist.Add(objPaymentsDTO);
                    objJournalVoucherDTO.pJournalVoucherlist = _Paymentslist;
                    AccountingTransactionsDAL Accontstrans = new AccountingTransactionsDAL();
                    if (Accontstrans.SaveJournalVoucherNew(objJournalVoucherDTO, trans, out adjustrefno))
                    {
                        Referenceno = adjustrefno;
                    }
                }
                if (string.IsNullOrEmpty(ObjRdReceiptDTO.pRecordid.ToString()) || ObjRdReceiptDTO.pRecordid == 0)
                {
                    sbInsert.Append("INSERT INTO Rd_receipt(rd_receipt_date,member_id,rd_account_id,deposit_type, instalment_amount,penalty_amount, received_amount, mode_of_receipt,receipt_no)VALUES('" + FormatDate(ObjRdReceiptDTO.pReceiptdate) + "'," + ObjRdReceiptDTO.pMemberid + "," + ObjRdReceiptDTO.pAccountid + ",'" + ObjRdReceiptDTO.pDeposittype + "'," + ObjRdReceiptDTO.pInstalmentamount + ", " + ObjRdReceiptDTO.pPenaltyamount + "," + ObjRdReceiptDTO.pReceivedamount + ",'" + ObjRdReceiptDTO.pModeofreceipt + "','" + Referenceno + "');");
                }
                if (!string.IsNullOrEmpty(sbInsert.ToString()))
                {
                    NPGSqlHelper.ExecuteNonQuery(trans, CommandType.Text, sbInsert.ToString());
                }
                if (ObjRdReceiptDTO.pModeofreceipt == "CASH" || ObjRdReceiptDTO.pModeofreceipt == "ADJUSTMENT")
                {
                    NPGSqlHelper.ExecuteNonQuery(trans, CommandType.Text, "select fn_rd_instalments_update('" + ObjRdReceiptDTO.pAccountno + "','" + Referenceno + "')");
                }
                trans.Commit();
                Issaved      = true;
                OUTReceiptid = Referenceno;
            }
            catch (Exception ex)
            {
                trans.Rollback();
                throw ex;
            }
            finally
            {
                if (con.State == ConnectionState.Open)
                {
                    con.Dispose();
                    con.Close();
                    con.ClearPool();
                    trans.Dispose();
                }
            }
            return(Issaved);
        }