コード例 #1
0
        }   //	updateJournalTotal

        /// <summary>
        /// This functionis used to create Line Dimension Line
        /// </summary>
        /// <param name="fromJournal">object of old GL Journal Line from where we need to pick lines</param>
        /// <param name="newlineID">GL Journal Line ID - new record agsint which we copy lines</param>
        /// <param name="typeCR">Optional Parameter - When 'C' - its means Reverse record - amount to be negate in this case</param>
        /// <returns>count of line - which is created</returns>
        public int CopyLinesFrom(MJournalLine fromJournal, int newlineID, char typeCR = 'X')
        {
            if (IsProcessed() || fromJournal == null)
            {
                return(0);
            }
            int count     = 0;
            int lineCount = 0;

            MLineDimension[] fromLines = fromJournal.GetLines(false);
            for (int i = 0; i < fromLines.Length; i++)
            {
                MLineDimension toLine = new MLineDimension(GetCtx(), 0, fromJournal.Get_TrxName());
                PO.CopyValues(fromLines[i], toLine, GetAD_Client_ID(), GetAD_Org_ID());

                toLine.SetC_BPartner_ID(fromLines[i].GetC_BPartner_ID());
                toLine.SetC_Campaign_ID(fromLines[i].GetC_Campaign_ID());
                toLine.SetC_ElementValue_ID(fromLines[i].GetC_ElementValue_ID());
                toLine.SetC_Element_ID(fromLines[i].GetC_Element_ID());
                toLine.SetC_Location_ID(fromLines[i].GetC_Location_ID());
                toLine.SetC_Project_ID(fromLines[i].GetC_Project_ID());
                toLine.SetC_SalesRegion_ID(fromLines[i].GetC_SalesRegion_ID());
                toLine.SetM_Product_ID(fromLines[i].GetM_Product_ID());
                toLine.SetOrg_ID(fromLines[i].GetOrg_ID());
                toLine.SetSeqNo(fromLines[i].GetSeqNo());
                toLine.SetLineType(fromLines[i].GetLineType());
                toLine.SetGL_JournalLine_ID(newlineID);

                if (typeCR == 'C')
                {
                    toLine.SetAmount(Decimal.Negate(fromLines[i].GetAmount()));
                }
                else
                {
                    toLine.SetAmount(fromLines[i].GetAmount());
                }
                toLine.SetLine(fromLines[i].GetLine());

                if (toLine.Save(fromJournal.Get_TrxName()))
                {
                    count++;
                }
            }
            if (fromLines.Length != count)
            {
                log.Log(Level.SEVERE, "Line difference - LinesDimensionl=" + fromLines.Length + " <> Saved=" + count);
            }
            return(lineCount);
        }