Ejemplo n.º 1
0
        public void TestToAssembled_BasicScenario()
        {
            S5Inventory InvRaw = Get_Sample_S5Inventory_for_one_Inventory_Item();

            IEnumerable <IS5InvAssembled> InvAss = InvRaw.ToAssembled();
            var First = InvAss.First();

            Assert.AreEqual(12018, First.Inv.InvUnique);
            Assert.AreEqual(12018, First.AltSuplies_PerInventry_27.First().Part);
            Assert.AreEqual(12018, First.CommentsLines_PerInventry_27.First().RecordNo);
            Assert.AreEqual(12018, First.InvPrices_PerInventry_27.First().PartUnique);
            Assert.AreEqual(12018, First.StokLines_PerInventry_27.First().PartPtr);

            // right padding removed from 211545, ff2, and ANOTHERBARCODE examples below
            Assert.AreEqual("211545", First.Inv.Part);
            Assert.AreEqual("Y", First.Inv.Ecommerce);
            Assert.AreEqual("ff2", First.CommentsLines_PerInventry_27.Last().Comment);

            Assert.AreEqual(new DateTime(2020, 10, 15), First.InvPrices_PerInventry_27.Where(p => p.InvUnique == 435900).First().StartDate);
            Assert.AreEqual("ANOTHERBARCODE", First.AltSuplies_PerInventry_27.Where(a => a.AUnique == 3).First().PartNumber); Assert.AreEqual("ANOTHERBARCODE", First.AltSuplies_PerInventry_27.Where(a => a.AUnique == 3).First().PartNumber);
            Assert.AreEqual("211545", First.AltSuplies_PerInventry_27.Where(a => a.AUnique == 2).First().PartNumber);

            //435898 is the older price and should have been filtered out
            Assert.AreEqual(0, First.InvPrices_PerInventry_27.Where(p => p.InvUnique == 435898).Count());

            // additional assertions based on future scenarios for cleaned data go here

            // Filtered data like todays prices still hasn't happened
            // Calculating quantity still hasn't happened
        }
Ejemplo n.º 2
0
        public void Test_Calculating_Prices_Simple()
        {
            S5Inventory InvRaw = Get_Sample_S5Inventory_for_one_Inventory_Item();

            IEnumerable <IS5InvAssembled> InvAss = InvRaw.ToAssembled();
            var FirstRecord = InvAss.First();

            var Bases = FirstRecord.InvPrices_PerInventry_27.PopulateBasePriceSchedInfo_NoPrice(FirstRecord.Inv, 0, 0, 0);
            // in CalculateBasePriceSchedules the prices for those base price schedules aren't calculated, but should be
            var prices = Bases.CalculatePrices(FirstRecord.InvPrices_PerInventry_27);

            const decimal sched0 = (decimal)69.99;

            Assert.AreEqual(sched0, prices.First().Price);
            const decimal sched1 = (decimal)59.99;

            Assert.AreEqual(sched1, prices.Last().Price);
        }
        public void Test_facade_to_wrap_InvAss_Wholesaler_pairs_to_a_data_load_format()
        {
            // C: create a facade to go from InvAss, wholesaler pairs to a data load format
            // Data load fields (ICommonFields + InvUnique, Cat, and PartNumber): InvUnique, Cat, PartNumber
            // ICommonFields: SupplierName, SupplierPartNumber, SupplierCode WholesaleCost, PriceSchedule1_MSRP
            //      , PriceSchedule2_MinPrice
            const int    commonId = 3;
            const string matching_supplier_code = "matching_code";
            const string supp_part_num          = "SamplePartNum";
            const string supp_name = "Some Supplier Name";

            S5Inventory InvRaw = Get_Sample_S5Inventory_for_one_Inventory_Item();

            IEnumerable <IS5InvAssembled> InvAss = InvRaw.ToAssembled();
            var First = InvAss.First();

            First.Inv.Supplier = commonId;
            First.Inv.SuppPart = supp_part_num;

            QryAccount acct = new QryAccount();

            acct.AName    = supp_name;
            acct.AUnique  = commonId;
            acct.BankInfo = matching_supplier_code;

            (IS5InvAssembled InvAss, QryAccount ExtraInfo)pair = new ValueTuple <IS5InvAssembled, QryAccount>(First, acct);

            IDataLoadFormat       DataLoadRecord;
            AdaptToDataLoadFormat adapter = new AdaptToDataLoadFormat();

            adapter.Init(pair);
            DataLoadRecord = adapter;

            Assert.AreEqual(matching_supplier_code, adapter.SupplierCode);
            Assert.AreEqual("211545", adapter.PartNumber);
            Assert.AreEqual(12018, adapter.InvUnique);
            //confirm that the prices below are correct by geting real data to sample
            Assert.AreEqual((decimal)59.99, adapter.PriceSchedule1_MSRP);
            Assert.AreEqual((decimal)69.99, adapter.PriceSchedule2_MinPrice);
            Assert.AreEqual(supp_name, adapter.SupplierName);
            Assert.AreEqual(supp_part_num, adapter.SupplierPartNumber);
            Assert.AreEqual(29, adapter.WholesaleCost);
        }
Ejemplo n.º 4
0
        private static IEnumerable <IS5InvAssembled> GetDataFromSystemFive(IConfiguration config)
        {
            string DSN = config["System5DSN"];

            Options opt = OdbcOptions.GetOptions(DSN);
            OdbcContext_S5Inventory context = new OdbcContext_S5Inventory(opt);

            // Assemble Inventory
            S5Inventory InvRaw = new S5Inventory
                                 (
                AltSuply_Records: context.AltSuplies
                , Comments_Records: context.CommentsLines
                , Inventry_27_Records: context.Inventry_27s
                , InvPrice_Records: context.InvPrices
                , Stok_Records: context.StokLines
                                 );
            IEnumerable <IS5InvAssembled> InvAss = InvRaw.ToAssembled();

            return(InvAss);
        }
Ejemplo n.º 5
0
        private static IEnumerable <IS5InvAssembled> GetDataFromJson(IConfiguration config)
        {
            string CachedFilesDirectory = config["SourceDirectory"];

            Options opt = PagedJsonOptions_S5Inventory.GetOptions(CachedFilesDirectory, new List <string>());
            OdbcContext_S5Inventory context = new OdbcContext_S5Inventory(opt);

            // Assemble Inventory
            S5Inventory InvRaw = new S5Inventory
                                 (
                AltSuply_Records: context.AltSuplies
                , Comments_Records: context.CommentsLines
                , Inventry_27_Records: context.Inventry_27s
                , InvPrice_Records: context.InvPrices
                , Stok_Records: context.StokLines
                                 );
            IEnumerable <IS5InvAssembled> InvAss = InvRaw.ToAssembled();

            return(InvAss);
        }
        public void Test_creating_Tuples_as_a_way_of_attaching_wholesaler_to_Assembled_Inventory()
        {
            // B: Attach BankInfo / wholesaler to Assembled Inventory to make InvAss, wholesaler pairs
            //   - UpdateProcess<TCommon, TKey> usage via example here: Test_GetUpdatesByCommonFields_OneOfTwoRecordsChanges()

            // UpdateProcess isn't what we use here as the pattern is different.

            // Use the Generic Join functionality that creates tuples instead
            const int    commonId = 3;
            const string matching_supplier_code = "matching_code";

            S5Inventory InvRaw = Get_Sample_S5Inventory_for_one_Inventory_Item();

            IEnumerable <IS5InvAssembled> InvAss = InvRaw.ToAssembled();
            var First = InvAss.First();

            First.Inv.Supplier = commonId;
            Assert.AreEqual(commonId, InvAss.First().Inv.Supplier); // confirm source has change

            QryAccount acct = new QryAccount();

            acct.AName    = "Test Matching Supplier";
            acct.AUnique  = commonId; // save as above
            acct.BankInfo = matching_supplier_code;

            List <QryAccount> accts = new List <QryAccount>();

            accts.Add(acct);

            Func <QryAccount, int> QryAccount_Index = (record) =>
            {
                return(record.AUnique);
            };

            IEnumerable <Tuple <IS5InvAssembled, QryAccount> > result = GenericJoins <IS5InvAssembled, QryAccount, int>
                                                                        .InnerJoin(InvAss, accts, IS5InvAssembled_Indexes.SupplierUnique_Key, QryAccount_Index);

            Assert.AreEqual(1, result.Count());
            Assert.AreEqual(commonId, result.First().Item1.Inv.Supplier);
            Assert.AreEqual(matching_supplier_code, result.First().Item2.BankInfo);
        }
Ejemplo n.º 7
0
 public void Test_ToAssembled_empty_lists_shouldnt_fail()
 {
     S5Inventory InvRaw = new S5Inventory();
     IEnumerable <IS5InvAssembled> InvAss = InvRaw.ToAssembled();
 }