public static DateTime GetLastLedgerClosureDateTime(ModelTMSContainer Context, string LedgerDescription)
        {
            DateTime LastClosure = GetSystemSettingDateTime(Context, "Last" + LedgerDescription + "ClosureDateTime", new DateTime(2000, 1, 1));

            if (LastClosure.Year == 2000)
            {
                // the date has not been set

                // assume today is the last closure datetime
                LastClosure = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day, 23, 59, 59);

                // check if this is correct
                try
                {
                    LedgerMutation mt = Context.LedgerMutationSet.OrderBy(o => o.CreateDateTime).First <LedgerMutation>();
                    if (mt != null)
                    {
                        // there have been earlier material mutations. Use that date.
                        LastClosure = new DateTime(mt.BookingDateTime.Year, mt.BookingDateTime.Month, mt.BookingDateTime.Day, 23, 59, 59);
                    }
                }
                catch
                {
                }
            }
            LastClosure = new DateTime(LastClosure.Year, LastClosure.Month, LastClosure.Day, 23, 59, 59);
            return(LastClosure);
        }
Beispiel #2
0
        void Page_PreRender(object sender, EventArgs e)
        {
            // enable the right controls if this is an editable mutation
            ButtonDelete.Enabled = false;
            TextBox_Description_Text.ReadOnly = true;
            TextBox_AmountEXVat.ReadOnly      = true;
            TextBox_TotalAmount.ReadOnly      = true;
            TextBox_VATAmount.ReadOnly        = true;

            LedgerMutation lm = DataItem as LedgerMutation;

            if ((lm.IsEditable) && (lm.BookingDateTime.Date == Common.CurrentClientDate(Session)))
            {
                ButtonDelete.Enabled = true;
                ButtonSave.Enabled   = true;
                ButtonCancel.Enabled = true;
                TextBox_Description_Text.ReadOnly = false;
                TextBox_AmountEXVat.ReadOnly      = false;
                TextBox_TotalAmount.ReadOnly      = false;
                TextBox_VATAmount.ReadOnly        = false;
            }

            // link to a popup which determines linked objects based on group id
            // TODO ! URLPopUpControlLink
        }
Beispiel #3
0
        protected void ButtonProcess_Click(object sender, EventArgs e)
        {
            double CorrectionAmount = 0;

            try
            {
                CorrectionAmount = Convert.ToDouble(TextBoxAmount.Text);
            }
            catch
            {
            }

            if (CorrectionAmount.ToString() != TextBoxAmount.Text)
            {
                Common.InformUser(Page, "Het opgegeven correctiebedrag kan niet worden herkend. Geef aub een correct bedrag op.");
                TextBoxAmount.Text = CorrectionAmount.ToString();
            }
            else
            {
                LedgerMutation lm = new LedgerMutation();
                Ledger         lb = (DataItem as Ledger);

                lm.Description  = "CORR / Correctie " + lb.Description;
                lm.IsCorrection = true;
                lm.BookingType  = RadioButtonListBuyOrSell.SelectedValue;
                lm.Ledger       = lb;

                if (lm.BookingType == "Sell")
                {
                    CorrectionAmount = -CorrectionAmount;
                }

                lm.AmountEXVat = CorrectionAmount;
                lm.VATAmount   = 0;
                lm.TotalAmount = lm.AmountEXVat;
                lm.Comments    = TextBoxComments.Text;

                lm.Process(ControlObjectContext);

                // store the correction amount as negated number so the book closures will function properly for Buy mutations as well
                if (lm.BookingType == "Buy")
                {
                    CorrectionAmount = -CorrectionAmount;
                }

                ControlObjectContext.SaveChanges();

                Common.InformUser(Page, "U heeft de mutatie succesvol doorgevoerd. U kunt deze popup nu sluiten of nog een mutatie doorvoeren.");
            }
        }
        protected void ButtonProcess_Click(object sender, EventArgs e)
        {
            double CorrectionAmount = 0;

            try
            {
                CorrectionAmount = Convert.ToDouble(TextBoxPaidAmount.Text);
            }
            catch
            {
            }

            if (CorrectionAmount.ToString() != TextBoxPaidAmount.Text)
            {
                Common.InformUser(Page, "Het bedrag wat u heeft ingevuld is niet juist. Controleer het bedrag.");
                TextBoxPaidAmount.Text = CorrectionAmount.ToString();
            }
            else
            {
                LedgerMutation lm = new LedgerMutation();
                ControlObjectContext.AddToLedgerMutationSet(lm);

                Invoice inv = (DataItem as Invoice);

                lm.Ledger      = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.LedgerSet", "Id", new Guid(DropDownListLedger.SelectedValue))) as Ledger;
                lm.Location    = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.LocationSet", "Id", new Guid(DropDownListLocation.SelectedValue))) as Location;
                lm.Description = "INV / PPaid / Vooruitbetaald bedrag factuur " + inv.InvoiceNumber.ToString();
                lm.GroupCode   = inv.GroupCode;
                lm.BookingType = inv.InvoiceType;
                lm.AmountEXVat = CorrectionAmount;
                lm.VATAmount   = 0;
                lm.TotalAmount = CorrectionAmount;
                lm.Process(ControlObjectContext);

                inv.AlreadyPaid   = inv.AlreadyPaid + CorrectionAmount;
                inv.InvoiceStatus = inv.AlreadyPaid != 0 ? "PPaid" : "Open";

                ControlObjectContext.SaveChanges();
                Common.InformUser(Page, "De vooruitbetaling is verwerkt. U kunt dit scherm nu sluiten.");
            }
        }
        protected void ButtonCorrectNow_Click(object sender, EventArgs e)
        {
            // first get the correction amount
            Double CorrectionAmount = 0;

            try
            {
                CorrectionAmount = Convert.ToDouble(TextBox_CorrectionAmount.Text);
            }
            catch
            {
            }

            // correct now
            if (CorrectionAmount.ToString() != TextBox_CorrectionAmount.Text)
            {
                Common.InformUser(Page, "Het correctiebedrag kan niet goed worden herkend. Voer dit opnieuw in en probeer het nogmaals.");
            }
            else
            {
                // start transaction
                using (TransactionScope TS = new TransactionScope())
                {
                    try
                    {
                        // save current record
                        StandardSaveHandler(null, null, false);

                        // update the ledgercheck & create the mutation
                        LedgerCheck lc = (DataItem as LedgerCheck);

                        LedgerBookingCode lbc         = null;
                        Ledger            lg          = null;
                        String            Description = "";

                        // get the ledger or ledgerbookingcode we have to link to
                        if (Request.Params["LedgerBookingCodeId"] != null)
                        {
                            lbc         = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.LedgerBookingCodeSet", "Id", new Guid(Request.Params["LedgerBookingCodeId"]))) as LedgerBookingCode;
                            Description = lbc.Description;
                        }
                        else
                        { // assume Id
                            lg          = ControlObjectContext.GetObjectByKey(new EntityKey("ModelTMSContainer.LedgerSet", "Id", new Guid(Request.Params["Id"]))) as Ledger;
                            Description = lg.Description;
                        }

                        LedgerMutation lm = new LedgerMutation();
                        ControlObjectContext.AddToLedgerMutationSet(lm);

                        lm.Description       = "CORR / Correctie " + Description;
                        lm.IsCorrection      = true;
                        lm.BookingType       = "Buy";
                        lm.LedgerBookingCode = lbc;
                        lm.Ledger            = lg;
                        lm.AmountEXVat       = CorrectionAmount;
                        lm.VATAmount         = 0;
                        lm.TotalAmount       = lm.AmountEXVat;
                        lm.Process(ControlObjectContext);

                        lc.IsLedgerCorrected = true;

                        ControlObjectContext.SaveChanges();

                        TS.Complete();

                        // relado data
                        RebindControls();
                        UpdateLedgerLevel();

                        // inform user
                        Common.InformUser(Page, "De correctie is succesvol verwerkt.");
                    }
                    catch (Exception ex) // commit or procedure failed somewhere
                    {
                        // rollback transaction
                        TS.Dispose();

                        // inform user
                        Common.InformUserOnTransactionFail(ex, Page);
                    }
                }
            }
        }