public bool DeleteLedger(Ledger entity)
 {
     if (entity == null) return false;
     _unitOfWork.LedgerRepository.Delete(entity);
     _unitOfWork.Save();
     return true;
 }
Exemple #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            Ledger ledger = new Ledger();
            bool gate = true;

            while (gate)
            {
                try
                {
                    ledger.Amount = Math.Round(Convert.ToDecimal(textBoxLedgerAmount.Text), 2);
                    gate = false;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Please enter a valid amount");
                    return;
                }
            }
            ledger.DateTime = DateTime.Now;
            ledger.Id = Guid.NewGuid();
            ledger.Memo = textBoxLedgerMemo.Text;
            ledger.CheckNumber = textBoxLedgerCheckNumber.Text;
            ledger.InvoiceNumber = textBoxLedgerInvoiceNumber.Text;
            ledger.Balance = Convert.ToDecimal(labelLedgerBalanceAmount.Text) + ledger.Amount;

            try
            {

                int indexCon = comboBoxLedgerContactList.SelectedIndex;
                ledger.ContactId = _contacts[indexCon].Id;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Contact ID empty or invalid. Setting default", "Invalid Contact ID",
            MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            int indexCat = comboBoxLedgerCategoryList.SelectedIndex;
            ledger.CategoryId = _categories[indexCat].Id;

            _ledgers.Add(ledger);

            BindingList<Ledger> blist = new BindingList<Ledger>(_ledgers);
            dataGridView1.DataSource = blist;

            SaveLedgers();
            LoadLedgers();

            calculateBalance();
            if (runningBalance < 0)
            {
                MessageBox.Show("You've overdrawn your account!", "Overdrawn Warning",
                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
 private Ledger GetLedger(Record record, ref double previousBalance)
 {
     BankRecord bankRecord = GetBankRecord(record.ID);
     double newBalance = previousBalance + record.Debit - record.Credit;
     Ledger ledger = new Ledger
                            {
                                Credit = record.Credit,
                                Debit = record.Debit,
                                Date = record.Date,
                                VoucherNo = record.VoucherType + "-" + record.VoucherSerialNo,
                                Particular = bankRecord != null ? "Bank" : "Cash",
                                ChequeNo = bankRecord != null ? bankRecord.ChequeNo : "",
                                Remarks = record.Narration,
                                Balance = newBalance
                            };
     previousBalance = newBalance;
     return ledger;
 }
 public bool EditLedger(Ledger entity)
 {
     _unitOfWork.LedgerRepository.Edit(entity);
     _unitOfWork.Save();
     return true;
 }
Exemple #5
0
        public override bool ExecuteAction(ActionProgramRun ap)
        {
            string res;

            if (ap.functions.ExpandString(UserData, out res) != BaseUtils.Functions.ExpandResult.Failed)
            {
                StringParser sp = new StringParser(res);

                string prefix  = "L_";
                string cmdname = sp.NextWord();

                if (cmdname != null && cmdname.Equals("PREFIX", StringComparison.InvariantCultureIgnoreCase))
                {
                    prefix = sp.NextWord();

                    if (prefix == null)
                    {
                        ap.ReportError("Missing name after Prefix in Ledger");
                        return(true);
                    }

                    cmdname = sp.NextWord();
                }

                bool nextvalidentry = false;

                if (cmdname != null && cmdname.Equals("ATORBEFORE", StringComparison.InvariantCultureIgnoreCase))
                {
                    nextvalidentry = true;  // means, find next ledger entry BEFORE this JID..
                    cmdname        = sp.NextWord();
                }

                if (cmdname != null)
                {
                    long jid;
                    if (!cmdname.InvariantParse(out jid))
                    {
                        ap.ReportError("Non integer JID in Ledger");
                        return(true);
                    }

                    Ledger             ml = (ap.actioncontroller as ActionController).HistoryList.CashLedger;
                    Ledger.Transaction tx = ml.Transactions.Find(x => x.jid == jid);                                                               // try and find it in the ledger
                    int jidindex          = (ap.actioncontroller as ActionController).HistoryList.EntryOrder().FindIndex(x => x.Journalid == jid); // find it in the journal

                    if (tx == null && nextvalidentry)                                                                                              // if not directly found..
                    {
                        while (jidindex > 0)                                                                                                       // go back, to 0.  if jidindex is -1 above, nothing happens
                        {
                            jidindex--;                                                                                                            // predec so we don't test first one
                            jid = (ap.actioncontroller as ActionController).HistoryList.EntryOrder()[jidindex].Journalid;
                            tx  = ml.Transactions.Find(x => x.jid == jid);
                            if (tx != null)
                            {
                                break;
                            }
                        }
                    }

                    if (tx == null)
                    {
                        ap.ReportError("Cannot find entry in Ledger");
                        return(true);
                    }

                    ap[prefix + "JID"]       = jid.ToString(System.Globalization.CultureInfo.InvariantCulture);
                    ap[prefix + "IndexOf"]   = (ap.actioncontroller as ActionController).HistoryList.EntryOrder()[jidindex].Indexno.ToString(System.Globalization.CultureInfo.InvariantCulture);
                    ap[prefix + "UTCTime"]   = tx.utctime.ToStringUS();
                    ap[prefix + "EntryType"] = tx.jtype.ToString();
                    ap[prefix + "Notes"]     = tx.notes;
                    ap[prefix + "Value"]     = tx.cashadjust.ToString(System.Globalization.CultureInfo.InvariantCulture);
                    ap[prefix + "PPU"]       = tx.profitperunit.ToString(System.Globalization.CultureInfo.InvariantCulture);
                    ap[prefix + "Credits"]   = tx.cash.ToString(System.Globalization.CultureInfo.InvariantCulture);
                }
                else
                {
                    ap.ReportError("Missing JID in Ledger");
                }
            }
            else
            {
                ap.ReportError(res);
            }

            return(true);
        }
 public bool AddLedger(Ledger entity)
 {
     _unitOfWork.LedgerRepository.Add(entity);
     _unitOfWork.Save();
     return true;
 }
Exemple #7
0
        public ActionResult GetDetails(List <HG_OrderItem> CompletedItems)
        {
            JournalEntry                  jObj          = new JournalEntry();
            List <JournalEntry>           jObjList      = new List <JournalEntry>();
            List <HG_Orders>              OrdersDetails = new List <HG_Orders>();
            List <HG_OrganizationDetails> OrgList       = new List <HG_OrganizationDetails>();
            double totalAmount = 0.00;

            for (int i = 0; i < CompletedItems.Count; i++)
            {
                jObj         = new JournalEntry();
                totalAmount += CompletedItems[i].Count * CompletedItems[i].Price;
                if (CompletedItems[i].TaxInItm == 5)
                {
                    Ledger LedgerDetails = Ledger.GetAllList().Where(x => x.ParentGroup == 5 && x.Name == "GST Local Sale 5%").FirstOrDefault();
                    jObj.CRLedgerId = LedgerDetails.ID;
                    jObj.JEDAmount  = CompletedItems[i].CostPrice;

                    //HG_OrganizationDetails org = OrgList.FindAll(x => x.OrgID == CompletedItems[i].OrgId).FirstOrDefault();

                    //if(org.State=="17")
                    //{

                    //}
                }
                if (CompletedItems[i].TaxInItm == 12)
                {
                    Ledger LedgerDetails = Ledger.GetAllList().Where(x => x.ParentGroup == 5 && x.Name == "GST Local Sale 12%").FirstOrDefault();
                    jObj.CRLedgerId = LedgerDetails.ID;
                    jObj.JEDAmount  = CompletedItems[i].CostPrice;
                }
                if (CompletedItems[i].TaxInItm == 18)
                {
                    Ledger LedgerDetails = Ledger.GetAllList().Where(x => x.ParentGroup == 5 && x.Name == "GST Local Sale 18%").FirstOrDefault();
                    jObj.CRLedgerId = LedgerDetails.ID;
                    jObj.JEDAmount  = CompletedItems[i].CostPrice;
                }
                if (CompletedItems[i].TaxInItm == 28)
                {
                    Ledger LedgerDetails = Ledger.GetAllList().Where(x => x.ParentGroup == 5 && x.Name == "GST Local Sale 28%").FirstOrDefault();
                    jObj.CRLedgerId = LedgerDetails.ID;
                    jObj.JEDAmount  = CompletedItems[i].CostPrice;
                }

                jObjList.Add(jObj);
            }
            jObj.Date    = DateTime.Now;
            jObj.Amount  = totalAmount;
            jObj.GroupId = 5;
            HG_Orders ord = new HG_Orders().GetOne(CompletedItems[0].OID);

            if (ord.Status == "1")
            {
                jObj.Narration = "Payment of Order No." + CompletedItems[0].OID;
            }
            else
            {
                jObj.Narration = "Online Payment of Order No." + CompletedItems[0].OID;
            }


            jObj.Save(jObjList);

            return(Json(new { data = jObj }, JsonRequestBehavior.AllowGet));
        }
 public decimal GetAccountBalance()
 {
     return(Ledger.Sum(ledger => ledger.Amount));
 }
Exemple #9
0
 public void Ledger(Ledger mcl, DB.SQLiteConnectionUser conn)
 {
     mcl.AddEvent(Id, EventTimeUTC, EventTypeID, "Amount " + Amount.ToString() + "t", -Cost);
 }
 public void Ledger(Ledger mcl)
 {
     mcl.AddEvent(Id, EventTimeUTC, EventTypeID, System, -Cost);
 }
        public void Ledger(Ledger mcl)
        {
            string s = (StoredItemLocalised.Length > 0) ? StoredItemLocalised : StoredItem;

            mcl.AddEvent(Id, EventTimeUTC, EventTypeID, s + " on ".T(EDTx.JournalEntry_on) + Ship, -Cost);
        }
 public void Ledger(Ledger mcl)
 {
     mcl.AddEvent(Id, EventTimeUTC, EventTypeID, StoredItemLocalised + " on " + Ship, -TransferCost);
 }
        public void Ledger(Ledger mcl)
        {
            string s = (SellItemLocalised.Length > 0) ? SellItemLocalised : SellItem;

            mcl.AddEvent(Id, EventTimeUTC, EventTypeID, SellItemLocalised + " on " + Ship, SellPrice);
        }
        public void Ledger(Ledger mcl)
        {
            string s = (RetrievedItemLocalised.Length > 0) ? RetrievedItemLocalised : RetrievedItem;

            mcl.AddEvent(Id, EventTimeUTC, EventTypeID, s + " on " + Ship, -Cost);
        }
        public void Ledger(Ledger mcl)
        {
            string s = (BuyItemLocalised.Length > 0) ? BuyItemLocalised : BuyItem;

            mcl.AddEvent(Id, EventTimeUTC, EventTypeID, s + " on " + Ship, -BuyPrice + (SellPrice ?? 0));
        }
 public void Ledger(Ledger mcl)
 {
     mcl.AddEvent(Id, EventTimeUTC, EventTypeID, Option, -Cost);
 }
        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);
                    }
                }
            }
        }
Exemple #18
0
 protected void Given_the_other_shows_a_zero_balance()
 {
     LedgerB = new Ledger();
 }
 public void Ledger(Ledger mcl, DB.SQLiteConnectionUser conn)
 {
     mcl.AddEvent(Id, EventTimeUTC, EventTypeID, FriendlyType + " " + Count + " Avg " + AvgPricePaid, TotalSale, (double)(SellPrice - AvgPricePaid));
 }
Exemple #20
0
 public LedgerEntry(Ledger other, decimal balance)
 {
     Source = other;
     Amount = balance;
 }
Exemple #21
0
 public Ledger Add(Ledger pt)
 {
     _LedgerRepository.Insert(pt);
     return(pt);
 }
 public async Task TestBuildAttribRequestWorksForInvalidIdentifier()
 {
     var ex = await Assert.ThrowsExceptionAsync <InvalidStructureException>(() =>
                                                                            Ledger.BuildAttribRequestAsync("invalid_base58_identifier", _dest, null, _endpoint, null)
                                                                            );
 }
Exemple #23
0
 public Ledger Create(Ledger pt)
 {
     pt.ObjectState = ObjectState.Added;
     _LedgerRepository.Insert(pt);
     return(pt);
 }
Exemple #24
0
 public void Ledger(Ledger mcl, DB.SQLiteConnectionUser conn)
 {
     mcl.AddEvent(Id, EventTimeUTC, EventTypeID, Option, -Cost);
 }
Exemple #25
0
 public void Delete(Ledger pt)
 {
     _LedgerRepository.Delete(pt);
 }
 public void Ledger(Ledger mcl, DB.SQLiteConnectionUser conn)
 {
     mcl.AddEvent(Id, EventTimeUTC, EventTypeID, Type + " " + Count.ToString(), -Cost);
 }
Exemple #27
0
 public void Update(Ledger pt)
 {
     pt.ObjectState = ObjectState.Modified;
     _LedgerRepository.Update(pt);
 }
Exemple #28
0
 public void LedgerNC(Ledger mcl, DB.SQLiteConnectionUser conn)
 {
     mcl.AddEventNoCash(Id, EventTimeUTC, EventTypeID, FriendlyType);
 }
Exemple #29
0
 public void Ledger(Ledger mcl, DB.SQLiteConnectionUser conn)
 {
     mcl.AddEvent(Id, EventTimeUTC, EventTypeID, StoredItemLocalised + " on " + Ship, -TransferCost);
 }
 public void Ledger(Ledger mcl)
 {
     mcl.AddEvent(Id, EventTimeUTC, EventTypeID, "Wages for ".T(EDTx.JournalEntry_Wagesfor) + Name, -Amount);
 }
 public void Ledger(Ledger mcl, DB.SQLiteConnectionUser conn)
 {
     mcl.AddEvent(Id, EventTimeUTC, EventTypeID, FriendlyType + " " + Count, -TotalCost);
 }
Exemple #32
0
 public BigInteger GetGasPerBlock(DataCache snapshot)
 {
     return(GetSortedGasRecords(snapshot, Ledger.CurrentIndex(snapshot) + 1).First().GasPerBlock);
 }
 public ActionResult Create(Models.LedgerCreateModel model)
 {
     if (!ModelState.IsValid)
     {
         return View(model);
     }
     using (db00ccd2da5aff4a5983c0a17b010f53a6Entities context = new db00ccd2da5aff4a5983c0a17b010f53a6Entities())
     {
         UserProfile theUser = context.UserProfiles.First(u => u.UserName == User.Identity.Name);
         Ledger theLedger = new Ledger();
         theLedger.LedgerName = model.Name;
         theLedger.User_UserId = theUser.UserId;
         context.Ledgers.Add(theLedger);
         context.SaveChanges();
         return RedirectToAction("Detail", new { id=theLedger.LedgerId });
     }
 }
Exemple #34
0
 protected void Given_one_ledger_shows_a_liability()
 {
     LedgerA = new Ledger(Liability);
 }
Exemple #35
0
        public void Ledger(Ledger mcl, DB.SQLiteConnectionUser conn)
        {
            string s = (RetrievedItemLocalised.Length > 0) ? RetrievedItemLocalised : RetrievedItem;

            mcl.AddEvent(Id, EventTimeUTC, EventTypeID, s + " on " + Ship, -Cost);
        }
Exemple #36
0
 protected void Given_two_ledgers()
 {
     LedgerA = new Ledger();
     LedgerB = new Ledger();
 }
        public async Task TestSendAttribRequestWorksWithoutSignature()
        {
            var trusteeDidResult = await Did.CreateAndStoreMyDidAsync(wallet, TRUSTEE_IDENTITY_JSON);

            var trusteeDid = trusteeDidResult.Did;

            var attribRequest = await Ledger.BuildAttribRequestAsync(trusteeDid, trusteeDid, null, _endpoint, null);

            var ex = await Assert.ThrowsExceptionAsync <InvalidLedgerTransactionException>(() =>
                                                                                           Ledger.SubmitRequestAsync(pool, attribRequest)
                                                                                           );
        }
Exemple #38
0
 public void Save(Ledger l)
 {
     mBMSEntities.Ledgers.Add(l);
     mBMSEntities.SaveChanges();
 }
 public void Ledger(Ledger mcl, DB.SQLiteConnectionUser conn)
 {
     mcl.AddEvent(Id, EventTimeUTC, EventTypeID, ShipType, -TransferPrice);
 }
 public async Task TestBuildAttribRequestWorksForMissedAttribute()
 {
     var ex = await Assert.ThrowsExceptionAsync <InvalidStructureException>(() =>
                                                                            Ledger.BuildAttribRequestAsync(_identifier, _dest, null, null, null)
                                                                            );
 }
        private void MainFrame_Load(object sender, System.EventArgs e)
        {
            _timer = new Timer();
            _timer.Interval = Constants.defaultTimerPeriod;
            _timer.Tick += new System.EventHandler(MainFrame_Tick);

            _zoom = Constants.ZoomDefault;

            WorldGeneration generator = new WorldGeneration(907);

            _currentMap = generator.GenerateVillage(Constants.MapSize, Constants.MapSize);
            _painter = new Painter(this, _currentMap, _zoom);

            _currentMap.AnalyzeTileAccessibility();

            Team team1 = new Team(Color.Red);
            Team team2 = new Team(Color.Blue);

            for (int j = 0; j < 2; ++j)
            {
                for (int i = 0; i < 5; ++i)
                {
                    _currentMap.SpawnCreature(new Coords(CoordsType.Tile, i, j), team1, Constants.CreatureGeneratorGnome);
                }
            }

            for (int j = 0; j < 2; ++j)
            {
                for (int i = 0; i < 5; ++i)
                {
                    _currentMap.SpawnCreature(new Coords(CoordsType.Tile, i, _currentMap.BoundY-1-j), team2, Constants.CreatureGeneratorGnome);
                }
            }

            _currentMap.SpawnPlayer(Constants.PlayerStartPos);
            //_player = _currentMap.PlayerReference;

            //_screenAnchor = this.TransformCenterAtPlayer();

            _scheduler = new Scheduler(_currentMap);
            _ledger = new Ledger(_scheduler);
            _timer.Start();
        }