示例#1
0
        public void Map_NoInvoice_SingleDummyInvoice()
        {
            var referenceNumber = "ref";
            var supplier        = new SupplierInformation
            {
                ForRemittance     = true,
                GstNumber         = "gst123",
                LegalBusinessName = "legal name of supplier 1",
                Name          = "supplier1",
                Location      = "location",
                ContactPerson = new Contact
                {
                    FirstName = "first",
                    LastName  = "last",
                    Email     = "*****@*****.**",
                    Fax       = "1234",
                    Phone     = "2345"
                },
                Address = new Address
                {
                    AddressLine1  = "addr 1",
                    AddressLine2  = "addr 2",
                    City          = "city",
                    Country       = "country",
                    StateProvince = "state1"
                }
            };

            var mappedInvoices = new Invoice[0].MapInvoices(referenceNumber, supplier, null);

            Assert.Single(mappedInvoices);
        }
示例#2
0
        public SupplierInformation GetWeatherInformation(string location)
        {
            SupplierInformation supplierInfo = new SupplierInformation {
                Name = "AccuWeather"
            };

            try
            {
                // Get the location information from AccuWeather (we need the location key to get the weather data).
                string locationInformation = GetLocationKey("Middlesbrough");
                // Deserialise the location information in to a usable response for us to utilise the key.
                List <AccuWeatherLocationResponse> locationResponse = JsonConvert.DeserializeObject <List <AccuWeatherLocationResponse> >(locationInformation);

                // Get the weather data from AccuWeather based upon the location key
                string weatherData = GetAccuWeatherData(locationResponse[0].Key);

                // Convert the weather data response to a usable object
                List <AccuWeatherResponse> returnedAccuWeatherData = JsonConvert.DeserializeObject <List <AccuWeatherResponse> >(weatherData);

                supplierInfo.WeatherInformation = $"The temperature in your selected location is:{returnedAccuWeatherData[0].Temperature.Metric.Value}°C";
            }
            catch (Exception ex)
            {
                supplierInfo.WeatherInformation = "There was an error retrieving weather information from AccuWeather. Please try again later. ErrorDetail: Maximum number of API requests received.";

                // Log exception to cosmos db error container
            }
            return(supplierInfo);
        }
        private void LoadData()
        {
            var poHeader = PurchaseOrderService.GetPurchaseOrder(RowID);

            Detail                = PurchaseOrderService.GetPurchaseOrderDetail(RowID).ToList();
            txtDocumentNo.Text    = poHeader.DocumentNo;
            lblBranch.Text        = poHeader.Branch.Name;
            ViewState["BranchID"] = poHeader.BranchID;
            lblSupplierName.Text  = SupplierService.GetSupplier(poHeader.SupplierID).Name;
            lblDate.Text          = poHeader.DocumentDate.ToString("dd/MM/yyyy");
            lblExpectedDate.Text  = Convert.ToDateTime(poHeader.ExpectedDate).ToString("dd/MM/yyyy");
            txtNotes.Text         = poHeader.Notes;
            SupplierInformation.LoadSupplierInformation(poHeader.SupplierID);
            lblTerms.Text      = poHeader.Terms;
            lblDiscValue.Text  = poHeader.DiscountValue.ToString("#0.00");
            lblPONo.Text       = String.Format("{0} - {1}", poHeader.DocumentNo, PurchaseOrderService.TranslateStatus(Convert.ToString(poHeader.Status)));
            btnApprove.Enabled = true;
            RefreshDetail();


            if (poHeader.VoidWhen.HasValue || poHeader.ApprovedByEmployeeID.HasValue)
            {
                btnApprove.Enabled = false;
                btnVoid.Enabled    = false;
            }
        }
        public override void ExecuteCRMWorkFlowActivity(CodeActivityContext context, LocalWorkflowContext crmWorkflowContext)
        {
            crmWorkflowContext.TracingService.Trace("Loaded Supplier Information Workflow Activity");

            var supplierInformationUtil = new SupplierInformation(crmWorkflowContext.OrganizationService,
                                                                  crmWorkflowContext.TracingService);

            var socialInsuranceNumber = SIN.Get(context);

            if (string.IsNullOrEmpty(socialInsuranceNumber))
            {
                throw new ArgumentNullException("Social Insurance Number cannot be null or blank");
            }

            var supplierInfo = supplierInformationUtil.GetSupplierInformation(SIN.Get(context));

            LastName.Set(context, supplierInfo.LastName);
            crmWorkflowContext.TracingService.Trace($"Last Found: {supplierInfo.LastName}");

            SupplierNumber.Set(context, supplierInfo.SupplierNumber);
            crmWorkflowContext.TracingService.Trace($"Supplier Number: {supplierInfo.SupplierNumber}");

            SiteNumber.Set(context, supplierInfo.SupplierSiteNumber);
            crmWorkflowContext.TracingService.Trace($"Supplier Site Number: {supplierInfo.SupplierSiteNumber}");

            MethodOfPayment.Set(context, supplierInfo.MethodOfPayment);
            crmWorkflowContext.TracingService.Trace($"Method of Payment: {supplierInfo.MethodOfPayment}");

            crmWorkflowContext.TracingService.Trace("Custom Workflow Activity Finished");
        }
        public ActionResult DeleteConfirmed(int id)
        {
            SupplierInformation supplierinformation = db.SupplierInformations.Find(id);

            db.SupplierInformations.Remove(supplierinformation);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
示例#6
0
 public SupplierDialog(SupplierInformation billInfo)
 {
     InitializeComponent();
     //var bounds = Window.Current.Bounds;
     //this.Height = bounds.Height;
     //  LoadData();
     info             = billInfo;
     this.DataContext = info;
 }
        protected void cboSupplier_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        {
            int supplierID = 0;

            if (Int32.TryParse(e.Value, out supplierID))
            {
                SupplierInformation.LoadSupplierInformation(supplierID);
            }
        }
示例#8
0
        public void Delete(SupplierInformation ObjToSave)
        {
            var ObjToDelete = _context.SupplierInformation.FirstOrDefault(m => m.AccountNumber == ObjToSave.AccountNumber &&
                                                                          m.CompanyID == ObjToSave.CompanyID);

            if (ObjToDelete != null)
            {
                _context.SupplierInformation.Remove(ObjToDelete);
            }
        }
 public ActionResult Edit([Bind(Include = "SupplierInformationId,SupplierCode,SupplierName,ContactPerson,Address,Email,MobileNumber")] SupplierInformation supplierinformation)
 {
     supplierinformation.CreatedDateTime = DateTime.Now;
     if (ModelState.IsValid)
     {
         db.Entry(supplierinformation).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(supplierinformation));
 }
        private void LoadData()
        {
            var poHeader = PurchaseOrderService.GetPurchaseOrder(RowID);

            Detail                       = PurchaseOrderService.GetPurchaseOrderDetail(RowID).ToList();
            txtDocumentNo.Text           = poHeader.DocumentNo;
            lblBranch.Text               = poHeader.Branch.Name;
            ViewState["BranchID"]        = poHeader.BranchID;
            ddlTerms.SelectedValue       = poHeader.Terms;
            cboSupplier.SelectedValue    = poHeader.SupplierID.ToString();
            dtpDate.SelectedDate         = poHeader.DocumentDate;
            dtpExpectedDate.SelectedDate = poHeader.ExpectedDate;
            txtNotes.Text                = poHeader.Notes;
            SupplierInformation.LoadSupplierInformation(poHeader.SupplierID);
            lblPONo.Text     = String.Format("{0} - {1}", poHeader.DocumentNo, PurchaseOrderService.TranslateStatus(Convert.ToString(poHeader.Status)));
            btnVoid.Enabled  = true;
            btnPrint.Enabled = true;
            RefreshDetail();

            if (poHeader.VoidWhen.HasValue || poHeader.Status == 'N' || poHeader.Status == 'A')
            {
                btnSave.Enabled = false;
                btnVoid.Enabled = false;
            }

            if (poHeader.Status != 'A')
            {
                btnPrint.Enabled = false;
            }

            switch (poHeader.Status)
            {
            case 'A':
                lblPOStatus.Text = "Approved";
                break;

            case 'N':
                lblPOStatus.Text = "Not Approved";
                break;

            case 'V':
                lblPOStatus.Text = "Void";
                break;

            default:
                lblPOStatus.Text = "Open";
                break;
            }
            //btnPrint.Attributes.Add("onclick",
            //    String.Format("showSimplePopUp('ReportPreview.aspx?ReportName={0}&DocumentNo={1}'); return false;",
            //        "SlipPurchaseOrder",
            //        poHeader.DocumentNo));
        }
示例#11
0
        public override void ExecuteCRMWorkFlowActivity(CodeActivityContext context, LocalWorkflowContext crmWorkflowContext)
        {
            crmWorkflowContext.TracingService.Trace("Loaded Supplier Information Workflow Activity");

            var supplierInformationUtil = new SupplierInformation(crmWorkflowContext.OrganizationService,
                                                                  crmWorkflowContext.TracingService);

            var socialInsuranceNumber = SIN.Get(context);

            if (string.IsNullOrEmpty(socialInsuranceNumber))
            {
                throw new ArgumentNullException("Social Insurance Number cannot be null or blank");
            }

            var supplierInfo = supplierInformationUtil.GetSupplierInformation(SIN.Get(context));

            crmWorkflowContext.TracingService.Trace($"SupplierInfo: {supplierInfo.ID}");

            if (supplierInfo.ID == Guid.Empty)
            {
                crmWorkflowContext.TracingService.Trace("SIN not found in the CAS Supplier Lookup records");

                //Populate entity reference with random GUID to avoid the workflow crash. Dynamics Bug. Microsoft needs to make fix.
                EntityReference CASSupplierLookupRef = new EntityReference("educ_cassupplierlookup", Guid.NewGuid());

                CASSupplierRef.Set(context, CASSupplierLookupRef);
                crmWorkflowContext.TracingService.Trace($"CASSupplierLookupRef: {supplierInfo.ID}");
                PartyId.Set(context, -1);
            }
            else
            {
                EntityReference CASSupplierLookupRef = new EntityReference("educ_cassupplierlookup", supplierInfo.ID);
                CASSupplierRef.Set(context, CASSupplierLookupRef);
                crmWorkflowContext.TracingService.Trace($"CASSupplierLookupRef: {supplierInfo.ID}");

                PartyId.Set(context, supplierInfo.PartyID);
                crmWorkflowContext.TracingService.Trace($"PartyID: {supplierInfo.PartyID}");

                LastName.Set(context, supplierInfo.LastName);
                crmWorkflowContext.TracingService.Trace($"Last Found: {supplierInfo.LastName}");

                SupplierNumber.Set(context, supplierInfo.SupplierNumber);
                crmWorkflowContext.TracingService.Trace($"Supplier Number: {supplierInfo.SupplierNumber}");

                SiteNumber.Set(context, supplierInfo.SupplierSiteNumber);
                crmWorkflowContext.TracingService.Trace($"Supplier Site Number: {supplierInfo.SupplierSiteNumber}");

                MethodOfPayment.Set(context, supplierInfo.MethodOfPayment);
                crmWorkflowContext.TracingService.Trace($"Method of Payment: {supplierInfo.MethodOfPayment}");

                crmWorkflowContext.TracingService.Trace("Custom Workflow Activity Finished");
            }
        }
        // GET: /SupplierInformation/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            SupplierInformation supplierinformation = db.SupplierInformations.Find(id);

            if (supplierinformation == null)
            {
                return(HttpNotFound());
            }
            return(View(supplierinformation));
        }
示例#13
0
        private void Initialize()
        {
            m_productList = new ProductList();
            m_items       = new List <InvoiceItem>();
            m_border      = new Border();
            supplierInfo  = new SupplierInformation();

            //Load price list from XML document
            m_productList.LoadFromXml();

            strFolioOrden = strFolio();
            txtFolio.Text = "Folio:" + strFolioOrden;

            //Set Billing information
            this.Name.Text           = supplierInfo.Name;    // = "Fran Wilson";
            this.BillingAddress.Text = supplierInfo.Address; // = "89, Chiaroscuro Road, Portland, 97219.";

            this.DATE.Text          = (supplierInfo.Date = DateTime.Now.Date).ToString("dd/MMM/yy");
            this.InvoiceNumber.Text = supplierInfo.InvoiceNumber;// = new Random().Next(100, 10000).ToString();
            this.DueDate.Text       = (supplierInfo.DueDate = DateTime.Now.Date).ToString("dd/MMM/yy");

            InvoiceItem defaultItem = new InvoiceItem()
            {
                CodeID = m_productList[0].CodeID, ItemName = m_productList[0].Name, Quantity = 1, UnitPrice = m_productList[0].Price
            };
            // defaultItem.Taxes = m_productList[0].Rate * 0.07;
            //Add an item by default
            // AddItem(defaultItem, false);
            ////m_productList = new ProductList();
            //m_items = new List<InvoiceItem>();
            //m_border = new Border();
            //supplierInfo = new SupplierInformation();
            ////Load price list from XML document
            //m_productList.LoadFromXml();

            ////Set Billing information
            //this.Name.Text = supplierInfo.Name = "Fran Wilson";
            //this.BillingAddress.Text = supplierInfo.Address = "89, Chiaroscuro Road, Portland, 97219.";
            //this.DATE.Text = (supplierInfo.Date = DateTime.Now.Date).ToString("d");
            //this.InvoiceNumber.Text = supplierInfo.InvoiceNumber = new Random().Next(100, 10000).ToString();
            //this.DueDate.Text = (supplierInfo.DueDate = DateTime.Now.Date).ToString("d");

            //InvoiceItem defaultItem = new InvoiceItem() { CodeID = "10570", Description = "MICHELIN LTX", Quantity = 1, Rate = 5 };
            //defaultItem.Taxes = 5 * 0.07;

            //Add an item by default
            //AddItem(defaultItem, false);
        }
示例#14
0
        public void Add(SupplierInformation ObjToSave)
        {
            var ObjToUpdate = _context.SupplierInformation.SingleOrDefault
                                  (m => m.CompanyID == ObjToSave.CompanyID && m.AccountNumber == ObjToSave.AccountNumber);

            if (ObjToUpdate != null)
            {
                ObjToUpdate.Address           = ObjToSave.Address;
                ObjToUpdate.BankAccountNumber = ObjToSave.BankAccountNumber;
                ObjToUpdate.BankAdderss       = ObjToSave.BankAdderss;
                ObjToUpdate.BeneficiaryName   = ObjToSave.BeneficiaryName;
                ObjToUpdate.IBAN                 = ObjToSave.IBAN;
                ObjToUpdate.SwiftCode            = ObjToSave.SwiftCode;
                ObjToUpdate.Mobile               = ObjToSave.Mobile;
                ObjToUpdate.NameOfPersonInCharge = ObjToSave.NameOfPersonInCharge;

                ObjToUpdate.PaymnetMethodTypeID   = ObjToSave.PaymnetMethodTypeID;
                ObjToUpdate.PhoneOfPersonInCharge = ObjToSave.PhoneOfPersonInCharge;

                ObjToUpdate.SupplierTypeID        = ObjToSave.SupplierTypeID;
                ObjToUpdate.SupplierCityID        = ObjToSave.SupplierCityID;
                ObjToUpdate.SupplierCountryID     = ObjToSave.SupplierCountryID;
                ObjToUpdate.SupplierCityBankID    = ObjToSave.SupplierCityBankID;
                ObjToUpdate.SupplierCountryBankID = ObjToSave.SupplierCountryBankID;
                ObjToUpdate.SupplierBranchBankID  = ObjToSave.SupplierBranchBankID;
                ObjToUpdate.SupplierBankID        = ObjToSave.SupplierBankID;
                ObjToUpdate.TeleFax   = ObjToSave.TeleFax;
                ObjToUpdate.Telephone = ObjToSave.Telephone;
                ObjToUpdate.Website   = ObjToSave.Website;

                ObjToUpdate.AccountNumber = ObjToSave.AccountNumber;
                ObjToUpdate.DebitPeriod   = ObjToSave.DebitPeriod;
                ObjToUpdate.Email         = ObjToSave.Email;
            }
            else
            {
                _context.SupplierInformation.Add(ObjToSave);
            }
        }
示例#15
0
        public void CanMapInvoice()
        {
            var referenceNumber = "ref";
            var supplier        = new SupplierInformation
            {
                ForRemittance     = true,
                GstNumber         = "gst123",
                LegalBusinessName = "legal name of supplier 1",
                Name          = "supplier1",
                Location      = "location",
                ContactPerson = new Contact
                {
                    FirstName = "first",
                    LastName  = "last",
                    Email     = "*****@*****.**",
                    Fax       = "1234",
                    Phone     = "2345"
                },
                Address = new Address
                {
                    AddressLine1  = "addr 1",
                    AddressLine2  = "addr 2",
                    City          = "city",
                    Country       = "country",
                    StateProvince = "state1"
                }
            };
            var srcInvoice = new Invoice {
            };

            var mappedInvoices = new[] { srcInvoice }.MapInvoices(referenceNumber, supplier, null);

            var mappedInvoice = Assert.Single(mappedInvoices);
            var typeProperty  = TypeDescriptor.GetProperties(mappedInvoice).Find("type", true);

            Assert.True(typeProperty.Attributes.Contains(new JsonPropertyAttribute("@odata.type")));
            Assert.Equal("Microsoft.Dynamics.CRM.era_supplierinvoice", typeProperty.GetValue(mappedInvoice));
        }
示例#16
0
        public SupplierInformation GetWeatherInformation(string location)
        {
            SupplierInformation supplierInfo = new SupplierInformation {
                Name = "Google UK"
            };

            try
            {
                var          html        = $"https://www.google.co.uk/search?q=weather+{location}%20UK";
                HtmlDocument htmlDoc     = new HtmlWeb().Load(html);
                HtmlNode     node        = htmlDoc.DocumentNode.SelectSingleNode("//body");
                string       innerText   = node.InnerText;
                decimal      temperature = Convert.ToDecimal(innerText.Substring(innerText.IndexOf("Weather") + 7, 2));
                ;
                supplierInfo.WeatherInformation = "The temperature in your selected location is: " + ApplyTempBugFix(temperature) + "°C";
            }
            catch (Exception ex)
            {
                supplierInfo.WeatherInformation = "There was an error retrieving weather information from Google. Please try again later.";
                // Log exception {to-do}
            }
            return(supplierInfo);
        }
 public JsonResult EmailExist(SupplierInformation aSupplierInformation)
 {
     return(Json(!db.SupplierInformations.Where(c => c.SupplierInformationId != aSupplierInformation.SupplierInformationId)
                 .Any(c => c.Email == aSupplierInformation.Email),
                 JsonRequestBehavior.AllowGet));
 }
 public JsonResult MobileNumberExist(SupplierInformation aSupplierInformation)
 {
     return(Json(!db.SupplierInformations.Where(c => c.SupplierInformationId != aSupplierInformation.SupplierInformationId)
                 .Any(c => c.MobileNumber == aSupplierInformation.MobileNumber),
                 JsonRequestBehavior.AllowGet));
 }
示例#19
0
        public static IEnumerable <InvoiceEntity> MapInvoices(this IEnumerable <Invoice> invoices, string referenceNumber, SupplierInformation supplierInformation, SupplierInformation supplierRemittanceInformation)
        {
            if (!invoices.Any())
            {
                //dummy invoice for Dynamics when no invoices in submission
                invoices = new[]
                {
                    new Invoice()
                };
            }

            return(invoices.Select((i, n) => new InvoiceEntity
            {
                era_invoicedate = i.Date,
                era_invoiceref = i.InvoiceNumber,
                era_referencenumber = referenceNumber,
                era_remitpaymenttootherbusiness = supplierRemittanceInformation != null,
                era_totalgst = i.TotalGST,
                era_totalinvoiceamount = i.TotalAmount,
                era_invoicetype = 174360100, //fire and forget
                era_supplierinvoicenumber = i.InvoiceNumber,
                era_suppliername = supplierInformation.Name,
                era_supplierlegalname = supplierInformation.LegalBusinessName,
                era_storenumber = supplierInformation.Location,
                era_gstnumber = supplierInformation.GstNumber,
                era_addressline1 = supplierInformation.Address.AddressLine1,
                era_addressline2 = supplierInformation.Address.AddressLine2,
                era_city = supplierInformation.Address.City,
                era_RelatedJurisdiction = supplierInformation.Address.CityCode.MapToDynamicsReferencedEntity("era_jurisdictions"),
                era_postalcode = supplierInformation.Address.PostalCode,
                era_province = supplierInformation.Address.StateProvinceCode.MapToDynamicsReferencedEntity("era_provinceterritorieses"),
                era_country = supplierInformation.Address.Country,
                era_legalbusinessname = supplierRemittanceInformation?.LegalBusinessName,
                era_remitcountry = supplierRemittanceInformation?.Address?.Country,
                era_remitcity = supplierRemittanceInformation?.Address?.City,
                era_remitaddress1 = supplierRemittanceInformation?.Address?.AddressLine1,
                era_remitaddress2 = supplierRemittanceInformation?.Address?.AddressLine2,
                era_remitprovincestate = supplierRemittanceInformation?.Address?.StateProvince,
                era_remitpostalcode = supplierRemittanceInformation?.Address?.PostalCode,
                era_contactfirstname = supplierInformation.ContactPerson.FirstName,
                era_contactlastname = supplierInformation.ContactPerson.LastName,
                era_contactemail = supplierInformation.ContactPerson.Email,
                era_contactnumber = supplierInformation.ContactPerson.Phone,
                era_contactfax = supplierInformation.ContactPerson.Fax
            }));
        }