/// <summary>
        ///
        /// </summary>
        /// <param name="voucherXml"></param>
        /// <returns>Total Voucher amount</returns>
        public static double CalculateAndFillInventoryEntryAmounts(XElement voucherXml)
        {
            float totalAmt = 0.0f;

            var allInventoryEntriesList = voucherXml.XPathSelectElements("./ALLINVENTORYENTRIES.LIST");

            foreach (var entry in allInventoryEntriesList)
            {
                float  inventoryEntryAmt;
                int    billedQty, actualQty;
                string isDeemedPositive;

                //Sum all the BatchAllocationsList values, and add them to the inventory entry xml...
                inventoryEntryAmt = entry.XPathSelectElements("./BATCHALLOCATIONS.LIST/AMOUNT")
                                    .Sum(x => float.Parse(x.Value));

                billedQty = entry.XPathSelectElements("./BATCHALLOCATIONS.LIST/BILLEDQTY")
                            .Sum(x => int.Parse(ComputationHelper.ExtractNumericQtyFromString(x.Value)));

                actualQty = entry.XPathSelectElements("./BATCHALLOCATIONS.LIST/ACTUALQTY")
                            .Sum(x => int.Parse(ComputationHelper.ExtractNumericQtyFromString(x.Value)));

                isDeemedPositive = ComputationHelper.IsDeemedPositive(inventoryEntryAmt);

                //...by filling all the {0} strings in the AllInventoryEntriesList xml
                entry.XPathSelectElement("./AMOUNT").Value =
                    string.Format(entry.XPathSelectElement("./AMOUNT").Value, inventoryEntryAmt.ToString("0.00"));

                entry.XPathSelectElement("./BILLEDQTY").Value =
                    string.Format(entry.XPathSelectElement("./BILLEDQTY").Value, billedQty.ToString());

                entry.XPathSelectElement("./ACTUALQTY").Value =
                    string.Format(entry.XPathSelectElement("./ACTUALQTY").Value, actualQty.ToString());

                entry.XPathSelectElement("./ISDEEMEDPOSITIVE").Value =
                    string.Format(entry.XPathSelectElement("./ISDEEMEDPOSITIVE").Value, isDeemedPositive);

                entry.XPathSelectElement("./ACCOUNTINGALLOCATIONS.LIST/AMOUNT").Value =
                    string.Format(entry.XPathSelectElement("./ACCOUNTINGALLOCATIONS.LIST/AMOUNT").Value, inventoryEntryAmt.ToString("0.00"));

                entry.XPathSelectElement("./ACCOUNTINGALLOCATIONS.LIST/ISDEEMEDPOSITIVE").Value =
                    string.Format(entry.XPathSelectElement("./ACCOUNTINGALLOCATIONS.LIST/ISDEEMEDPOSITIVE").Value, isDeemedPositive);


                //update the total voucher amount
                totalAmt += inventoryEntryAmt;
            }

            return(totalAmt);
        }
예제 #2
0
        public static void UpdateFinalAmtInVoucherXml(double voucherAmt, XElement voucherXml)
        {
            string isDeemedPositive = ComputationHelper.IsDeemedPositive((float)voucherAmt);

            var elmt = voucherXml.XPathSelectElement("./LEDGERENTRIES.LIST");

            elmt.XPathSelectElement("./AMOUNT").Value =
                string.Format(elmt.XPathSelectElement("./AMOUNT").Value, voucherAmt.ToString("0.00"));

            elmt.XPathSelectElement("./BILLALLOCATIONS.LIST/AMOUNT").Value =
                string.Format(elmt.XPathSelectElement("./BILLALLOCATIONS.LIST/AMOUNT").Value, voucherAmt.ToString("0.00"));

            elmt.XPathSelectElement("./ISDEEMEDPOSITIVE").Value =
                string.Format(elmt.XPathSelectElement("./ISDEEMEDPOSITIVE").Value, isDeemedPositive);
        }
예제 #3
0
        private void CreateTallyXmlsUsingItemsParams(string outputXmlFileName)
        {
            List <string> assignedBarcodesList = new List <string>();

            foreach (ItemsCSVParams itemParams in itemsCSVParams)
            {
                //Create and add Parent+Child Godown xmls
                if (!Godown.IsAlreadyCreated(itemParams.GodownParent, tallyXml))
                {
                    Godown.CreateGodownXml(tallyXml, "", itemParams.GodownParent);
                }

                if (!Godown.IsAlreadyCreated(itemParams.GodownChild, tallyXml))
                {
                    Godown.CreateGodownXml(tallyXml, itemParams.GodownParent, itemParams.GodownChild);
                }

                //Create and add Parent+Child StockGroup xmls
                if (!StockGroup.IsAlreadyCreated(itemParams.StockGroupParent, tallyXml))
                {
                    StockGroup.CreateStockGroupXml(tallyXml, "", itemParams.StockGroupParent);
                }

                if (!StockGroup.IsAlreadyCreated(itemParams.StockGroupChild, tallyXml))
                {
                    StockGroup.CreateStockGroupXml(tallyXml, itemParams.StockGroupParent,
                                                   itemParams.StockGroupChild);
                }

                //Create and add Parent+Child StockCategory xmls
                if (!StockCategory.IsAlreadyCreated(itemParams.StockCategoryParent, tallyXml))
                {
                    StockCategory.CreateStockCategoryXml(tallyXml, "", itemParams.StockCategoryParent);
                }

                if (!StockCategory.IsAlreadyCreated(itemParams.StockCategoryChild, tallyXml))
                {
                    StockCategory.CreateStockCategoryXml(tallyXml, itemParams.StockCategoryParent,
                                                         itemParams.StockCategoryChild);
                }

                //Create and add StockItem xml
                if (!StockItem.IsAlreadyCreated(itemParams.ItemName, tallyXml))
                {
                    //Get the next available barcode and assign it
                    itemParams.Barcode = BarcodeValueGen.Instance.GetMeNewBarcode().ToString();
                    assignedBarcodesList.Add(itemParams.Barcode);

                    StockItem.CreateStockItemXml(tallyXml, itemParams.ItemName, itemParams.PartNo,
                                                 itemParams.StockGroupChild, itemParams.StockCategoryChild, itemParams.Barcode,
                                                 itemParams.CP, itemParams.SP, itemParams.ImgPath, itemParams.Desc1,
                                                 itemParams.Desc2, itemParams.Desc3);
                }

                //Check if AllInventoryEntriesList has already been created for a stock item
                //and if not, create it (note that xml is being filled with {0} for values
                //that need to be computed during post-processing)
                if (!AllInventoryEntriesList.IsAlreadyCreated(itemParams.ItemName, voucherXmlElement))
                {
                    AllInventoryEntriesList.CreateAllInventoryEntriesListXml(voucherXmlElement, itemParams.Desc1,
                                                                             itemParams.Desc2, itemParams.Desc3, itemParams.ItemName, itemParams.CP, "{0}",
                                                                             headerCSVParams.PurchLedger);
                }

                //Create and add BatchAllocationsList xml
                float batchCP = -ComputationHelper.CalculateAmount(itemParams.CP, itemParams.BilledQty);
                BatchAllocationsList.CreateBatchAllocationsListXml(voucherXmlElement, itemParams.ItemName, itemParams.GodownChild,
                                                                   Math.Round(batchCP, 2).ToString("0.00"), itemParams.ActualQty, itemParams.BilledQty);
            }

            BarcodeCSVParams barcodesLogData = new BarcodeCSVParams();

            barcodesLogData.FirstBarcodeAssigned = assignedBarcodesList.First();
            barcodesLogData.LastBarcodeAssigned  = assignedBarcodesList.Last();
            barcodesLogData.AssociatedOutputXml  = outputXmlFileName;
            barcodesLogData.TimeStamp            = DateTime.Now.ToString();

            WriteToCSVFiles.WriteBarcodesDataToFile(barcodesLogData);
        }