Esempio n. 1
0
        public static List <string> UpdateOrder(int orderID, DateTime collectFromDate, DateTime?collectFromTime, DateTime collectByDate, DateTime?collectByTime, int collectionTimeType,
                                                DateTime deliverFromDate, DateTime?deliverFromTime, DateTime deliverToDate, DateTime?deliverToTime, int deliveryTimeType,
                                                decimal rate, string deliveryNotes, string userID)
        {
            List <string> result = new List <string>();

            result.Add(true.ToString());

            Orchestrator.EF.DataContext data  = EF.DataContext.Current;
            Orchestrator.EF.Order       order = data.OrderSet.First(o => o.OrderId == orderID);

            //determine the date(s) to use

            order.CollectionDateTime = collectFromDate.Add(collectFromTime.HasValue ? new TimeSpan(collectFromTime.Value.Hour, collectFromTime.Value.Minute, 0) : new TimeSpan(23, 59, 0));
            if (collectionTimeType == 1)
            {
                order.CollectionByDateTime = order.CollectionDateTime;
            }
            else
            {
                order.CollectionByDateTime = collectByDate.Add(collectByTime.HasValue ? new TimeSpan(collectByTime.Value.Hour, collectByTime.Value.Minute, 0) : new TimeSpan(23, 59, 0));
            }

            order.DeliveryFromDateTime = deliverFromDate.Add(deliverFromTime.HasValue ? new TimeSpan(deliverFromTime.Value.Hour, deliverFromTime.Value.Minute, 0) : new TimeSpan(23, 59, 0));
            if (deliveryTimeType == 1)
            {
                order.DeliveryDateTime = order.DeliveryFromDateTime.Value;
            }
            else
            {
                order.DeliveryDateTime = deliverToDate.Add(deliverToTime.HasValue ? new TimeSpan(deliverToTime.Value.Hour, deliverToTime.Value.Minute, 0) : new TimeSpan(23, 59, 0));
            }

            order.LastUpdateDate   = DateTime.Now;
            order.LastUpdateUserID = userID;

            order.DeliveryNotes = deliveryNotes;
            order.ForeignRate   = rate;

            Facade.IExchangeRates facER         = new Facade.ExchangeRates();
            CultureInfo           nativeCulture = new CultureInfo(Orchestrator.Globals.Configuration.NativeCulture);

            if (order.LCID != nativeCulture.LCID)
            {
                order.ExchangeRateID = facER.GetCurrentExchangeRateID(Facade.Culture.GetCurrencySymbol(order.LCID.Value), order.CollectionDateTime);
                order.Rate           = facER.GetConvertedRate(order.ExchangeRateID.Value, order.ForeignRate.Value);
            }
            else
            {
                order.Rate = decimal.Round(order.ForeignRate.Value, 4, MidpointRounding.AwayFromZero);
            }

            data.SaveChanges();

            result.Add(orderID.ToString());


            return(result);
        }
Esempio n. 2
0
        Entities.JobSubContractor GetJobSubContract(Entities.Instruction selected)
        {
            Facade.IExchangeRates facER = new Facade.ExchangeRates();
            decimal rate = Decimal.Parse(rntSubContractRate.Text, System.Globalization.NumberStyles.Currency);

            Entities.JobSubContractor jobSubContract = new Entities.JobSubContractor(int.Parse(cboSubContractor.SelectedValue), rate, chkUseSubContractorTrailer.Checked);
            jobSubContract.LCID = rntSubContractRate.Culture.LCID;

            CultureInfo culture = new CultureInfo(Orchestrator.Globals.Configuration.NativeCulture);

            if (jobSubContract.LCID != culture.LCID) // Default
            {
                jobSubContract.ExchangeRateID = facER.GetCurrentExchangeRateID(Facade.Culture.GetCurrencySymbol(jobSubContract.LCID), selected.PlannedArrivalDateTime);
                jobSubContract.Rate           = facER.GetConvertedRate((int)jobSubContract.ExchangeRateID, jobSubContract.ForeignRate);
            }
            else
            {
                jobSubContract.Rate = decimal.Round(jobSubContract.ForeignRate, 4, MidpointRounding.AwayFromZero);
            }

            return(jobSubContract);
        }
        ///	<summary>
        /// Populate CreditNote
        ///	</summary>
        private void populateCreditNote()
        {
            if (ViewState["CreditNote"] == null)
            {
                m_CreditNote = new Entities.CreditNote();
            }
            else
            {
                m_CreditNote = (Entities.CreditNote)ViewState["CreditNote"];
            }

            if (lblCreditNoteNo.Text != "To Be Issued ... (This Credit Note has not yet been saved, add Credit Note to allocate Credit Note No.)")
            {
                m_CreditNote.CreditNoteId = Convert.ToInt32(lblCreditNoteNo.Text);
            }

            //m_CreditNote.CreditNoteType = eCreditNoteType.OneLiner;
            m_CreditNote.ClientId = Convert.ToInt32(cboClient.SelectedValue);

            m_CreditNote.CreditNoteDetails = rtbTxtReason.Text;


            if (chkPostToExchequer.Checked)
            {
                m_CreditNote.Posted = true;
            }
            else
            {
                m_CreditNote.Posted = false;
            }

            int     vatNo   = 0;
            decimal vatRate = 0.00M;

            //Get VAT Rate for VAT Type
            Facade.IInvoice facInv  = new Facade.Invoice();
            eVATType        vatType = (eVATType)int.Parse(cboVATType.SelectedValue);

            facInv.GetVatRateForVatType(vatType, this.rdiCreditNoteDate.SelectedDate.Value, out vatNo, out vatRate);

            m_CreditNote.VatNo   = vatNo;
            m_CreditNote.VatRate = vatRate;

            Facade.IExchangeRates facER = new Facade.ExchangeRates();

            if (this.txtNETAmount.Culture.LCID != 2057)
            {
                m_CreditNote.LCID = this.txtNETAmount.Culture.LCID;

                m_CreditNote.ExchangeRateID =
                    facER.GetCurrentExchangeRateID(Facade.Culture.GetCurrencySymbol(m_CreditNote.LCID),
                                                   this.rdiCreditNoteDate.SelectedDate.Value);
            }
            else
            {
                m_CreditNote.ExchangeRateID = null;
                m_CreditNote.LCID           = 2057; //English
            }

            //Calculate VATamount and GrossAmount
            //#16479 Round all amounts to 2 decimal places
            m_CreditNote.ForeignNetAmount   = Math.Round(Decimal.Parse(txtNETAmount.Text, System.Globalization.NumberStyles.Currency), 2);
            m_CreditNote.ForeignVATAmount   = Math.Round((m_CreditNote.ForeignNetAmount * m_CreditNote.VatRate) / 100, 2);
            m_CreditNote.ForeignGrossAmount = Math.Round(m_CreditNote.ForeignNetAmount + m_CreditNote.ForeignVATAmount, 2);

            if (m_CreditNote.ExchangeRateID != null)
            {
                m_CreditNote.NetAmount = facER.GetConvertedRate((int)m_CreditNote.ExchangeRateID,
                                                                m_CreditNote.ForeignNetAmount);
                m_CreditNote.VATamount = facER.GetConvertedRate((int)m_CreditNote.ExchangeRateID,
                                                                m_CreditNote.ForeignVATAmount);
                m_CreditNote.GrossAmount = facER.GetConvertedRate((int)m_CreditNote.ExchangeRateID,
                                                                  m_CreditNote.ForeignGrossAmount);
            }
            else
            {
                m_CreditNote.NetAmount   = m_CreditNote.ForeignNetAmount;
                m_CreditNote.VATamount   = m_CreditNote.ForeignVATAmount;
                m_CreditNote.GrossAmount = m_CreditNote.ForeignGrossAmount;
            }

            m_CreditNote.AccountCode = lblAccountCode.Text;
            m_CreditNote.NominalCode = cboNominalCode.SelectedValue;

            m_CreditNote.CreditNoteDate = rdiCreditNoteDate.SelectedDate.Value;
        }
Esempio n. 4
0
        ///	<summary>
        /// Populate Invoice
        ///	</summary>
        private void populateInvoice()
        {
            if (ViewState["invoice"] == null)
            {
                m_Invoice = new Entities.Invoice();
            }
            else
            {
                m_Invoice = (Entities.Invoice)ViewState["invoice"];
            }

            if (lblInvoiceNo.Text != "To Be Issued ... (This invoice has not yet been saved, add invoice to allocate Invoice No.)")
            {
                m_Invoice.InvoiceId = Convert.ToInt32(lblInvoiceNo.Text);
            }

            m_Invoice.InvoiceType = eInvoiceType.OneLiner;

            m_Invoice.InvoiceDetails = rtbTxtReason.Text;

            m_Invoice.InvoiceDate = rdiInvoiceDate.SelectedDate.Value;

            Facade.IExchangeRates facER = new Facade.ExchangeRates();

            int exchangeRateId = -1;

            // the txtNetAmount textbox has had its culture set by the client.
            if (this.txtNETAmount.Culture.LCID != 2057)
            {
                exchangeRateId = facER.GetCurrentExchangeRateID(Facade.Culture.GetCurrencySymbol(this.txtNETAmount.Culture.LCID), this.rdiInvoiceDate.SelectedDate.Value);
            }

            m_Invoice.ClientInvoiceAmount = Decimal.Parse(txtNETAmount.Text, System.Globalization.NumberStyles.Currency);

            if (chkPostToExchequer.Checked)
            {
                m_Invoice.Posted = true;
            }
            else
            {
                m_Invoice.Posted = false;
            }

            int     vatNo   = 0;
            decimal vatRate = 0.00M;

            //Get VAT Rate and Vat Type
            Facade.IInvoice facInv  = new Facade.Invoice();
            eVATType        vatType = (eVATType)int.Parse(cboVATType.SelectedValue);

            facInv.GetVatRateForVatType(vatType, m_Invoice.InvoiceDate, out vatNo, out vatRate);

            m_Invoice.VatRate = vatRate;
            m_Invoice.VatNo   = vatNo;

            m_Invoice.AccountCode = lblAccountCode.Text;
            m_Invoice.NominalCode = cboNominalCode.SelectedValue;

            // Deleted checked not required until the Invoice's are allowed to be deleted
            if (chkDelete.Checked)
            {
                m_Invoice.ForCancellation = true;
            }
            else
            {
                m_Invoice.ForCancellation = false;
            }
        }