Ejemplo n.º 1
0
        /// <summary>
        /// Creates a line item.
        /// </summary>
        /// <param name="TransNode"></param>
        private void CreateLineItem(XmlNode TransNode, XmlDocument CurrentTransDocument)
        {
            LineNode = DestinationDocumentTemplate.SelectSingleNode("//L");

            string LineObject;
            string LineAction;

            LineNode.Attributes["Line_id"].Value = "100";

            if (TransNode.SelectSingleNode("//L10").Attributes["flgs_L10AVOID"].Value == "1")
            {
                LineObject = "1101";
                LineAction = "35";
                LineNode.Attributes["Voiding_reversal_flag"].Value = "1";
            }
            else if (TransNode.SelectSingleNode("//L10").Attributes["type"].Value == "83")
            {
                LineObject = "600";
                LineAction = "32";
            }
            else
            {
                LineObject = "1407";
                LineAction = "38";
            }
            LineNode.Attributes["Line_object"].Value = LineObject;
            LineNode.Attributes["Line_action"].Value = LineAction;

            AppendNode(LastParentNodeAppendedTo, CurrentTransDocument.ImportNode(LineNode, true));
            LineNode = null;
        }
Ejemplo n.º 2
0
        void TLogTranslateItem_OnAfterRuleLoad(object sender, TranslateEventArgs e)
        {
            TranslateRule transrule = (TranslateRule)sender;

            if (transrule.ID == "L30")
            {
                //When we reach the 30 record we reset the discount line number so we can reassign it later if the 30 record has a valid Line (L) item to create
                DiscountLineNumber = -1;
                //Reset out counter to keep track of the number of discount line items in the transaction.
                UniqueDiscountId = 0;
            }

            if (transrule.ID == "L60")
            {
                XPathNavigator nav = e.CurrentTranslateItem.CreateNavigator();
                if (Convert.ToBoolean(nav.Evaluate(GetXpathExpression("string(@type) = '2' and string(@seq_num) = '38'"))))
                {
                    if (String.IsNullOrEmpty(PolledNetSalesFile))
                    {
                        PolledNetSalesFile = base.PluginConfig.GetValue("PolledNetSalesFile");
                    }

                    //NetSales sales = new NetSales();

                    string   netsales  = nav.Evaluate(GetXpathExpression("string(@amount)")).ToString();
                    string   storeNum  = nav.Evaluate(GetXpathExpression("string(@store_num)")).ToString();
                    DateTime TransDate = Convert.ToDateTime(nav.Evaluate(GetXpathExpression("string(@trans_date)")).ToString());
                    WritePolledNetSales(storeNum, netsales, TransDate);
                }
            }
            //This will store the notes for bank deposit and will be added to the output when the translate hits the 52 record
            if (transrule.ID == "L51")
            {
                if (BankNotes == null)
                {
                    BankNotes = new List <XmlNode>();
                }

                XPathNavigator nav       = e.CurrentTranslateItem.CreateNavigator();
                int            transType = 10;
                while (transType <= 26)
                {
                    string strExpr = String.Format("count(following-sibling::L52[@Tender_id_sub1='{0}' and number(@tender_id) = 0]) > 0", transType);
                    if (Convert.ToBoolean(nav.Evaluate(GetXpathExpression(strExpr))))
                    {
                        string  LineNote = String.Format("number(following-sibling::L52[@Tender_id_sub1='{0}' and number(@tender_id) = 0]/@extended_amount)", transType);
                        string  NoteType = String.Format("number(100 + number(following-sibling::L52[@Tender_id_sub1='{0}' and number(@tender_id) = 0]/@Tender_id_sub1))", transType);
                        XmlNode BankNote = DestinationDocumentTemplate.SelectSingleNode("//N");
                        BankNote.Attributes["Line_id"].Value        = "0";
                        BankNote.Attributes["Line_Note"].Value      = Convert.ToString(nav.Evaluate(GetXpathExpression(LineNote)));
                        BankNote.Attributes["Line_note_type"].Value = Convert.ToString(nav.Evaluate(GetXpathExpression(NoteType)));
                        BankNotes.Add(BankNote);
                    }
                    transType++;
                }
            }
        }
Ejemplo n.º 3
0
        protected override void AppendNode(XmlElement Parent, XmlNode NodeToAppend)
        {
            //All cases here are specific rules that need to be applied for the translate and could not be obtained in the translate rules.
            //If we have a header record append it to the output document
            if (NodeToAppend.Name == "H")
            {
                //keep track of the header that was found for later processing if a header is found without a line item.
                HeadItemFound = true;
                XmlNode OriginalDateNote = null;
                //We need to check the transaction date and time to make sure we do not have multiple transactions with the same time.
                //This is an auditworks rule
                //DateTime CurrentTransTime = Convert.ToDateTime(NodeToAppend.Attributes["Entry_date_time"].Value);
                //DateTime TempDate = new DateTime(PreviousHeaderTime.Year, PreviousHeaderTime.Month, PreviousHeaderTime.Day, PreviousHeaderTime.Hour, PreviousHeaderTime.Minute, 0);
                //if the current transaction time is the same as the previous transaction time we increment the time by 1 and store it until the time no longer matches
                //if (CurrentTransTime == TempDate)
                //{
                //  NodeToAppend.Attributes["Entry_date_time"].Value = PreviousHeaderTime.AddSeconds(1).ToString("MM/dd/yyyy HH:mm:ss");
                //  PreviousHeaderTime = PreviousHeaderTime.AddSeconds(1);
                //}
                //else
                //Time no longer matches so reset it to the current transaction time
                //  PreviousHeaderTime = CurrentTransTime;

                //Custom rule that determines when the date cutoff is.  If a transaction is found in the tlog with a date > than this (Currently 3AM)
                //the date will be moved back to the previous day.  This will only happen if it is turned on in the configuration.
                if (PluginConfig.GetValue("ReDate").ToLower() == "true")
                {
                    DateTime TranslateCutOffTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 3, 0, 0);
                    DateTime HeaderTransDate     = Convert.ToDateTime(NodeToAppend.Attributes["Entry_date_time"].Value);
                    if (HeaderTransDate >= TranslateCutOffTime)
                    {
                        NodeToAppend.Attributes["Entry_date_time"].Value = HeaderTransDate.AddDays(-1).ToString("MM/dd/yyyy") + " 23:59:59";
                        OriginalDateNote = DestinationDocumentTemplate.SelectSingleNode("//N");
                        OriginalDateNote.Attributes["Line_note_type"].Value = "57";
                        OriginalDateNote.Attributes["Line_Note"].Value      = HeaderTransDate.ToString("MM/dd/yyyy HH:mm:ss");
                    }
                }

                //LineNode will be null if we have a header with a line item
                if (LineNode != null)
                {
                    Parent.InnerXml = Parent.InnerXml + LineNode.OuterXml;
                    LineNode        = null;
                }

                Parent.AppendChild(NodeToAppend);

                if (OriginalDateNote != null)
                {
                    Parent.InnerXml = Parent.InnerXml + OriginalDateNote.OuterXml;
                }
            }
            //if we have a L record append it
            else if (NodeToAppend.Name == "L")
            {
                //keep track of line items found for later processing if necessary.
                LineFound = true;

                Parent.AppendChild(NodeToAppend);

                //now if we have any items waiting to be added we can add them now
                if (List.Count <= 0)
                {
                    return;
                }

                for (int i = 0; i < List.Count; i++)
                {
                    Parent.InnerXml = Parent.InnerXml + List[i].OuterXml;
                }

                List.Clear();
            }
            //A line item has already been found so keep adding
            else if (LineFound)
            {
                Parent.AppendChild(NodeToAppend);
            }
            //base.AppendNode(Parent, NodeToAppend);

            LastParentNodeAppendedTo = Parent;
        }