public WhenOneProductAndOrderDayIsSunday(DespatchDateFixture fixture) : base(fixture) { _result = Fixture.Controller.Get(new List <int>() { 3 }, Fixture.SundayOrderDate); }
public WhenOneProductWithLeadTimeOfThreeDay(DespatchDateFixture fixture) : base(fixture) { _result = Fixture.Controller.Get(new List <int>() { 3 }, Fixture.DefaultOrderDate); }
public WhenProductIsNotFound(DespatchDateFixture fixture) : base(fixture) { _exception = Record.Exception(() => _result = Fixture.Controller.Get(new List <int>() { Fixture.UnknownProductId }, Fixture.DefaultOrderDate)); }
public WhenSupplierHasSingleBlockedDate(DespatchDateFixture fixture) : base(fixture) { _exception = Record.Exception(() => _result = Fixture.Controller.Get(new List <int>() { 1 }, Fixture.SupplierOneBlockedDateStart)); }
public WhenSupplierBlockedDatesCauseLaterDespatchThanLargeLeadtimeSupplier(DespatchDateFixture fixture) : base(fixture) { _exception = Record.Exception(() => _result = Fixture.Controller.Get(new List <int>() { 1, 9 }, Fixture.SupplierOneBlockedDateStart)); }
public DespatchDate GetDespatchDate(List <int> productIds, DateTime orderDate) { if ((orderDate.DayOfWeek == DayOfWeek.Saturday) || (orderDate.DayOfWeek == DayOfWeek.Sunday)) { orderDate = orderDate.GetNextWorkDay(); } var maxLeadTime = orderDate; foreach (var Id in productIds) { DbContext dbContext = new DbContext(); var product = productService.GetProductById(Id); if (product == null) { return(null); } var supplierId = product.SupplierId; var leadTime = supplierService.GetSupplierById(supplierId).LeadTime; if (orderDate.AddWorkdays(leadTime) > maxLeadTime) { maxLeadTime = orderDate.AddWorkdays(leadTime); } } var despatchDate = new DespatchDate(); if ((maxLeadTime.DayOfWeek == DayOfWeek.Saturday) || (maxLeadTime.DayOfWeek == DayOfWeek.Sunday)) { despatchDate.Date = maxLeadTime.GetNextWorkDay(); } else { despatchDate.Date = maxLeadTime; } return(despatchDate); }
static void Main(string[] args) { #region Console Info Console.Clear(); Console.Title = "FoodStuffs Export"; Console.WriteLine(" FoodStuffs ODBC Converter \n"); Console.WriteLine("----(c)2019 Business Applications----\n"); #endregion #region Data Readers (ODBCReaderInvoices) OdbcDataReader ODBCReaderInvoices; // DataReader for Inventory (Stock InvoiceItems) #endregion #region Output Info string OutputFolder = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); //Folder for output string FileType = ".csv"; //Output filetype string InvoiceFile = "InvoiceItems" + FileType; //filename string InvoiceOut = Path.Combine(OutputFolder, InvoiceFile); //Generate output path #endregion #region ODBC Definitions OdbcConnection AttacheLink; OdbcCommand cmd; #endregion #region Global String Initialisation string DSN = "dsn=PROPHET;"; string GetLines = "" + "SELECT OIHEAD.CustomerCode, OIHEAD.InvoiceNumber, OIHEAD.Salesperson, OILINE.StockCode, OILINE.Description, OILINE.String1, OILINE.Date1, OILINE.QuantitySupplied, OILINE.Unit, " + "OILINE.SellingPrice, OILINE.Discount, OILINE.Amount, OILINE.Tax, OIHEAD.Net, OIHEAD.Charge1, OIHEAD.Charge2, OIHEAD.Gross, OIHEAD.InvoiceOrderDate, OIHEAD.InvoiceCreditOrd, OIHEAD.InternalCode, OILINE.ParentCode, OIHEAD.InternalRef " + "FROM OIHEAD OIHEAD " + "LEFT JOIN OILINE OILINE ON(OIHEAD.InternalCode = OILINE.ParentCode) " + "WHERE((OIHEAD.CustomerCode = 'AFC') OR(OIHEAD.CustomerCode = 'AFL') OR(OIHEAD.CustomerCode = 'RRC') OR(OIHEAD.CustomerCode = 'RRD') OR(OIHEAD.CustomerCode = 'RRF') OR(OIHEAD.CustomerCode = 'RRT')) AND " + "(OIHEAD.InvoiceOrderDate >={d'" + "2019-04-01" + "'} AND OIHEAD.InvoiceOrderDate <={d'" + "2019-04-30" + "'}) AND(OILINE.StockCode Not Like '\\%')"; #endregion #region Open ODBC Connection AttacheLink = new OdbcConnection(DSN); try { AttacheLink.Open(); Console.WriteLine("Connected to ODBC Data Source\r\n"); } catch (OdbcException ex) { Console.WriteLine(ex.Message); } finally { } #endregion #region ODBC Commands cmd = new OdbcCommand(GetLines, AttacheLink); ODBCReaderInvoices = cmd.ExecuteReader(); #endregion #region Outputs TextWriter InvoiceItems = new StreamWriter(InvoiceOut); Console.WriteLine("Retrieving Invoice Lines"); #endregion #region Write Headers //InvoiceItems.WriteLine("Code,Description,ProductGroup,SupplierCode,SupplierPartNum,Comment"); #endregion #region Item Count int LineCount = 0; #endregion #region Connection output while (ODBCReaderInvoices.Read()) { #region Number of Lines LineCount++; #endregion #region String adjustment string DespatchDate; // Read strings from PROPHET ODBC into memory for item adjustments. // Converting numerical items to strings for post-processing. string CustCode = (string)ODBCReaderInvoices["CustomerCode"]; string InvNumber = (string)ODBCReaderInvoices["InvoiceNumber"]; string Salesperson = (string)ODBCReaderInvoices["Salesperson"]; string StockCode = (string)ODBCReaderInvoices["StockCode"]; string Description = (string)ODBCReaderInvoices["Description"]; string OrderNumber = (string)ODBCReaderInvoices["String1"]; try { DespatchDate = ODBCReaderInvoices["Date1"].ToString(); //need to represent datetime? } catch { DespatchDate = "01/01/1900"; } //string DespatchDate = (string)ODBCReaderInvoices["Date1"]; //need to represent datetime? string Quantity = (string)ODBCReaderInvoices["QuantitySupplied"]; string Unit = (string)ODBCReaderInvoices["Unit"]; string SellingPrice = (string)ODBCReaderInvoices["SellingPrice"]; string Discount = (string)ODBCReaderInvoices["Discount"]; string Amount = (string)ODBCReaderInvoices["Amount"]; string Tax = (string)ODBCReaderInvoices["Tax"]; string Net = (string)ODBCReaderInvoices["Net"]; string Charge1 = (string)ODBCReaderInvoices["Charge1"]; //FAF string Charge2 = (string)ODBCReaderInvoices["Charge2"]; //SI string Gross = (string)ODBCReaderInvoices["Gross"]; string InvoiceOrderDate = (string)ODBCReaderInvoices["InvoiceOrderDate"]; string InvoiceCreditOrder = (string)ODBCReaderInvoices["InvoiceCreditOrd"]; string InternalCode = (string)ODBCReaderInvoices["InternalCode"]; string ParentCode = (string)ODBCReaderInvoices["ParentCode"]; string InternalRef = (string)ODBCReaderInvoices["InternalRef"]; // Run conversion on strings that might break if we have illegal characters in them. // A Comma is ASCII 44 and a Speech Mark is ASCII 34 (decimal). #region Adjustments //CustCode = Code.Replace(@"""", ""); //Code = Code.Replace(",", ""); CustCode = CustCode.Trim(); InvNumber = InvNumber.Trim(); Salesperson = Salesperson.Trim(); StockCode = StockCode.Trim(); Description = Description.Trim(); OrderNumber = OrderNumber.Trim(); DespatchDate = DespatchDate.Trim(); Quantity = Quantity.Trim(); Unit = Unit.Trim(); SellingPrice = SellingPrice.Trim(); Discount = Discount.Trim(); Amount = Amount.Trim(); Tax = Tax.Trim(); Net = Net.Trim(); Charge1 = Charge1.Trim(); Charge2 = Charge2.Trim(); Gross = Gross.Trim(); InvoiceOrderDate = InvoiceOrderDate.Trim(); InvoiceCreditOrder = InvoiceCreditOrder.Trim(); InternalCode = InternalCode.Trim(); ParentCode = ParentCode.Trim(); InternalRef = InternalRef.Trim(); #endregion #endregion #region Display number of lines Console.SetCursorPosition(30, 6); Console.WriteLine("Analysing invoice line: " + Convert.ToString(LineCount)); #endregion #region Write lines InvoiceItems.Write(CustCode + ","); InvoiceItems.Write(InvNumber + ","); InvoiceItems.Write(Salesperson + ","); InvoiceItems.Write(StockCode + ","); InvoiceItems.Write(Description + ","); InvoiceItems.Write(OrderNumber + ","); InvoiceItems.Write(DespatchDate + ","); InvoiceItems.Write(Quantity + ","); InvoiceItems.Write(Unit + ","); InvoiceItems.Write(SellingPrice + ","); InvoiceItems.Write(Discount + ","); InvoiceItems.Write(Amount + ","); InvoiceItems.Write(Tax + ","); InvoiceItems.Write(Net + ","); InvoiceItems.Write(Charge1 + ","); InvoiceItems.Write(Charge2 + ","); InvoiceItems.Write(Gross + ","); InvoiceItems.Write(InvoiceOrderDate + ","); InvoiceItems.Write(InvoiceCreditOrder + ","); InvoiceItems.Write(InternalCode + ","); InvoiceItems.Write(ParentCode + ","); InvoiceItems.Write(InternalRef + "\r\n"); #endregion } #endregion #region Close ODBC Connection AttacheLink.Close(); #endregion #region Close Streams InvoiceItems.Close(); #endregion #region Wait for close Console.WriteLine("Press the Enter key to exit."); Console.ReadLine(); #endregion }