/// <summary> /// Parent Constructor. /// </summary> /// <param name="parent">parent batch</param> public MJournal(MJournalBatch parent) : this(parent.GetCtx(), 0, parent.Get_TrxName()) { //this (parent.getCtx(), 0, parent.get_TrxName()); SetClientOrg(parent); SetGL_JournalBatch_ID(parent.GetGL_JournalBatch_ID()); SetC_DocType_ID(parent.GetC_DocType_ID()); SetPostingType(parent.GetPostingType()); // SetDateDoc(parent.GetDateDoc()); SetC_Period_ID(parent.GetC_Period_ID()); SetDateAcct(parent.GetDateAcct()); SetC_Currency_ID(parent.GetC_Currency_ID()); } // MJournal
protected override string DoIt() { ds = new DataSet(); ds = DB.ExecuteDataset("SELECT C_Recurring_ID From C_Recurring Where IsActive='Y' AND AD_Client_ID=" + GetAD_Client_ID() + " AND TRUNC(DateNextRun)=" + GlobalVariable.TO_DATE(DateTime.Now, true)); if (ds != null && ds.Tables[0].Rows.Count > 0) { for (Int32 i = 0; i < ds.Tables[0].Rows.Count; i++) { Recurring = new MRecurring(GetCtx(), Util.GetValueOfInt(ds.Tables[0].Rows[i]["C_Recurring_ID"]), Get_Trx()); dateDoc = Recurring.GetDateNextRun(); if (dateDoc != null && Recurring.CalculateRuns()) { // throw new Exception("No Runs Left"); MRecurringRun run = new MRecurringRun(GetCtx(), Recurring); String msg = "@Created@ "; // if (Recurring.GetDateNextRun() == DateTime.Now.Date || Recurring.GetDateNextRun() == null) //{ // Copy if (Recurring.GetRecurringType().Equals(MRecurring.RECURRINGTYPE_Order)) { MOrder from = new MOrder(GetCtx(), Recurring.GetC_Order_ID(), Get_TrxName()); MOrder order = MOrder.CopyFrom(from, dateDoc, from.GetC_DocType_ID(), false, false, Get_TrxName()); run.SetC_Order_ID(order.GetC_Order_ID()); msg += order.GetDocumentNo(); } else if (Recurring.GetRecurringType().Equals(MRecurring.RECURRINGTYPE_Invoice)) { MInvoice from = new MInvoice(GetCtx(), Recurring.GetC_Invoice_ID(), Get_TrxName()); MInvoice invoice = MInvoice.CopyFrom(from, dateDoc, from.GetC_DocType_ID(), false, Get_TrxName(), false); run.SetC_Invoice_ID(invoice.GetC_Invoice_ID()); msg += invoice.GetDocumentNo(); } else if (Recurring.GetRecurringType().Equals(MRecurring.RECURRINGTYPE_Project)) { MProject project = MProject.CopyFrom(GetCtx(), Recurring.GetC_Project_ID(), dateDoc, Get_TrxName()); run.SetC_Project_ID(project.GetC_Project_ID()); msg += project.GetValue(); } else if (Recurring.GetRecurringType().Equals(MRecurring.RECURRINGTYPE_GLJournalBatch)) { MJournalBatch journal = MJournalBatch.CopyFrom(GetCtx(), Recurring.GetGL_JournalBatch_ID(), dateDoc, Get_TrxName()); run.SetGL_JournalBatch_ID(journal.GetGL_JournalBatch_ID()); msg += journal.GetDocumentNo(); } else if (Recurring.GetRecurringType().Equals(MRecurring.RECURRINGTYPE_GLJournal)) { MJournal Journal = MJournal.CopyFrom(GetCtx(), Recurring.GetGL_Journal_ID(), dateDoc, Get_TrxName()); run.SetGL_Journal_ID(Journal.GetGL_Journal_ID()); msg += Journal.GetDocumentNo(); } else if (Recurring.GetRecurringType().Equals(MRecurring.RECURRINGTYPE_Payment)) { MPayment from = new MPayment(GetCtx(), Recurring.GetC_Payment_ID(), Get_TrxName()); MPayment payment = MPayment.CopyFrom(from, dateDoc, from.GetC_DocType_ID(), Get_TrxName()); run.SetC_Payment_ID(payment.GetC_Payment_ID()); msg += payment.GetDocumentNo(); } //else // return "Invalid @RecurringType@ = " + Recurring.GetRecurringType(); if (run.Save(Get_TrxName())) { Recurring.SetDateLastRun(run.GetUpdated()); Recurring.SetRunsRemaining(Recurring.GetRunsRemaining() - 1); SetDateNextRun(); Recurring.Save(Get_TrxName()); } // } } } } DisposeVariables(); return(""); // throw new NotImplementedException(); }