/// <summary>
        ///  Create Gl Journal
        /// </summary>
        /// <param name="revenueRecognitionPlan">Revenue Recognition Plan</param>
        /// <returns>Journal object</returns>
        public MJournal CreateJournalHDR(MRevenueRecognitionPlan revenueRecognitionPlan)
        {
            journal.SetClientOrg(revenueRecognitionPlan.GetAD_Client_ID(), revenueRecognitionPlan.GetAD_Org_ID());
            journal.SetC_AcctSchema_ID(revenueRecognitionPlan.GetC_AcctSchema_ID());
            journal.SetDescription(Msg.GetMsg(GetCtx(), "ReversedRecognitionRun"));
            journal.SetPostingType(MJournal.POSTINGTYPE_Actual);

            int GL_Category_ID = Util.GetValueOfInt(DB.ExecuteScalar(@"SELECT GL_Category_ID From GL_Category Where CategoryType='M' 
            AND  AD_Client_ID= " + revenueRecognitionPlan.GetAD_Client_ID() + " AND IsActive='Y' ORDER BY GL_Category_ID desc"));

            journal.SetGL_Category_ID(GL_Category_ID);
            journal.SetDateDoc(DateTime.Now);
            journal.SetDateAcct(DateTime.Now);
            DateTime?Today = DateTime.Now;


            string periodSql = "SELECT C_Period_ID From C_Period pr  INNER JOIN c_year yr ON (yr.c_year_id = pr.c_year_id AND yr.c_calendar_id= " +
                               "(CASE WHEN (SELECT NVL(C_Calendar_ID,0) FROM AD_Orginfo WHERE AD_org_ID =" + revenueRecognitionPlan.GetAD_Org_ID() + " ) =0 THEN (SELECT  NVL(C_Calendar_ID,0) FROM AD_ClientInfo WHERE AD_Client_ID =" + revenueRecognitionPlan.GetAD_Client_ID() + ") ELSE " +
                               "(SELECT NVL(C_Calendar_ID,0) FROM AD_Orginfo WHERE AD_org_ID =" + revenueRecognitionPlan.GetAD_Org_ID() + ") END ) ) WHERE " + GlobalVariable.TO_DATE(Today, true) + " BETWEEN StartDate and EndDate";

            C_Period_ID = Util.GetValueOfInt(DB.ExecuteScalar(periodSql));
            journal.SetC_Period_ID(C_Period_ID);
            journal.SetC_Currency_ID(revenueRecognitionPlan.GetC_Currency_ID());
            int C_ConversionType_ID = Util.GetValueOfInt(DB.ExecuteScalar("Select C_ConversionType_ID From C_ConversionType where IsDefault='Y'"));

            journal.SetC_ConversionType_ID(C_ConversionType_ID);
            journal.SetTotalCr(revenueRecognitionPlan.GetTotalAmt());
            journal.SetTotalDr(revenueRecognitionPlan.GetTotalAmt());
            journal.SetDocStatus("DR");
            journal.SetDocAction("CO");

            return(journal);
        }
Пример #2
0
        public VAdvantage.Model.MJournal CreateJournalHDR(MRevenueRecognitionPlan revenueRecognitionPlan, MRevenueRecognitionRun revenurecognitionRun)
        {
            journal.SetClientOrg(revenueRecognitionPlan.GetAD_Client_ID(), revenueRecognitionPlan.GetAD_Org_ID());
            journal.SetC_AcctSchema_ID(revenueRecognitionPlan.GetC_AcctSchema_ID());
            journal.SetDescription("Revenue Recognition Run");
            journal.SetPostingType("A");
            int C_Doctype_ID = Util.GetValueOfInt(DB.ExecuteScalar("Select C_Doctype_ID From C_Doctype Where DocBaseType='GLJ'"));

            journal.SetC_DocType_ID(C_Doctype_ID);
            int GL_Category_ID = Util.GetValueOfInt(DB.ExecuteScalar("Select GL_Category_ID From GL_Category Where CategoryType='M' Order by GL_Category_ID desc"));

            journal.SetGL_Category_ID(GL_Category_ID);
            journal.SetDateDoc(DateTime.Now);
            journal.SetDateAcct(revenurecognitionRun.GetINT15_RecognitionDate());


            C_Period_ID = Util.GetValueOfInt(DB.ExecuteScalar("Select C_Period_ID From C_Period pr INNER JOIN ad_clientinfo cl ON cl.ad_client_id = " + GetAD_Client_ID() + " INNER JOIN c_year yr ON (yr.c_year_id = pr.c_year_id" +
                                                              " AND cl.c_calendar_id=yr.c_calendar_id) Where " + GlobalVariable.TO_DATE(revenurecognitionRun.GetINT15_RecognitionDate(), true) + " between StartDate and EndDate"));

            journal.SetC_Period_ID(C_Period_ID);
            journal.SetC_Currency_ID(revenueRecognitionPlan.GetC_Currency_ID());
            int C_ConversionType_ID = Util.GetValueOfInt(DB.ExecuteScalar("Select C_ConversionType_ID From C_ConversionType where IsDefault='Y'"));

            journal.SetC_ConversionType_ID(C_ConversionType_ID);
            journal.SetTotalCr(revenueRecognitionPlan.GetTotalAmt());
            journal.SetTotalDr(revenueRecognitionPlan.GetTotalAmt());
            journal.SetDocStatus("DR");
            journal.SetDocAction("CO");

            return(journal);
        }
        /// <summary>
        /// Create Gl Journal
        /// </summary>
        /// <param name="revenueRecognitionPlan">Revenue Recognition Plan</param>
        /// <param name="revenurecognitionRun">Revenue Recognition Run</param>
        /// <param name="recFrequency">Frequency</param>
        /// <returns>Journal object</returns>
        public MJournal CreateJournalHDR(MRevenueRecognitionPlan revenueRecognitionPlan, MRevenueRecognitionRun revenurecognitionRun, string recFrequency)
        {
            journal.SetClientOrg(revenueRecognitionPlan.GetAD_Client_ID(), revenueRecognitionPlan.GetAD_Org_ID());
            journal.SetC_AcctSchema_ID(revenueRecognitionPlan.GetC_AcctSchema_ID());
            journal.SetDescription("Revenue Recognition Run");
            journal.SetPostingType(MJournal.POSTINGTYPE_Actual);

            int GL_Category_ID = Util.GetValueOfInt(DB.ExecuteScalar(@"SELECT GL_Category_ID From GL_Category Where CategoryType='M' 
            AND  AD_Client_ID= " + revenueRecognitionPlan.GetAD_Client_ID() + " Order by GL_Category_ID desc"));

            journal.SetGL_Category_ID(GL_Category_ID);

            journal.SetDateDoc(DateTime.Now);
            DateTime firstOfNextMonth = new DateTime(revenurecognitionRun.GetRecognitionDate().Value.Year, revenurecognitionRun.GetRecognitionDate().Value.Month, 1).AddMonths(1);
            DateTime lastOfThisMonth  = firstOfNextMonth.AddDays(-1);

            if (recFrequency.Equals("D")) //DAY
            {
                //in case of DAY , Account date would be same as Recoganize date
                journal.SetDateAcct(revenurecognitionRun.GetRecognitionDate());
            }
            else
            {
                journal.SetDateAcct(lastOfThisMonth);
            }

            string periodSql = "SELECT C_Period_ID From C_Period pr  INNER JOIN c_year yr ON (yr.c_year_id = pr.c_year_id AND yr.c_calendar_id= " +
                               "(CASE WHEN (SELECT NVL(C_Calendar_ID,0) FROM AD_Orginfo WHERE AD_org_ID =" + revenueRecognitionPlan.GetAD_Org_ID() + " ) =0 THEN (SELECT  NVL(C_Calendar_ID,0) FROM AD_ClientInfo WHERE AD_Client_ID =" + revenueRecognitionPlan.GetAD_Client_ID() + ") ELSE " +
                               "(SELECT NVL(C_Calendar_ID,0) FROM AD_Orginfo WHERE AD_org_ID =" + revenueRecognitionPlan.GetAD_Org_ID() + ") END ) ) WHERE " + GlobalVariable.TO_DATE(revenurecognitionRun.GetRecognitionDate(), true) + " BETWEEN StartDate and EndDate";

            C_Period_ID = Util.GetValueOfInt(DB.ExecuteScalar(periodSql));

            journal.SetC_Period_ID(C_Period_ID);
            journal.SetC_Currency_ID(revenueRecognitionPlan.GetC_Currency_ID());
            int C_ConversionType_ID = Util.GetValueOfInt(DB.ExecuteScalar("SELECT C_ConversionType_ID From C_ConversionType WHERE IsDefault='Y'"));

            journal.SetC_ConversionType_ID(C_ConversionType_ID);
            journal.SetTotalCr(revenueRecognitionPlan.GetTotalAmt());
            journal.SetTotalDr(revenueRecognitionPlan.GetTotalAmt());
            journal.SetDocStatus("DR");
            journal.SetDocAction("CO");

            return(journal);
        }