public master_daily_sale alter_master_daily_sale() { try { master_daily_sale prev_master_daily_sale = db.master_daily_sales.SingleOrDefault(a => a.id == master_daily_sale.id); prev_master_daily_sale.balance = master_daily_sale.balance; prev_master_daily_sale.cancelled = master_daily_sale.cancelled; prev_master_daily_sale.commision = master_daily_sale.commision; prev_master_daily_sale.date = master_daily_sale.date; prev_master_daily_sale.date_posted = master_daily_sale.date_posted; prev_master_daily_sale.islocked = master_daily_sale.islocked; prev_master_daily_sale.isverified = master_daily_sale.isverified; prev_master_daily_sale.net_balance = master_daily_sale.net_balance; prev_master_daily_sale.posted_by = master_daily_sale.posted_by; prev_master_daily_sale.sales = master_daily_sale.sales; prev_master_daily_sale.shop = master_daily_sale.shop; prev_master_daily_sale.stake = master_daily_sale.stake; prev_master_daily_sale.winnings = master_daily_sale.winnings; db.SubmitChanges(); return(master_daily_sale); } catch (Exception) { return(null); } }
public livesaleshelper(master_daily_sale master_daily_sales) { _master_daily_sales = master_daily_sales; sales_ = master_daily_sales.sales.Value; winnings_ = master_daily_sales.winnings.Value; commision_ = master_daily_sales.commision.Value; balance_ = master_daily_sales.net_balance.Value; netbalance_ = master_daily_sales.shop1.master_balance_sheets[0].sales_balance.Value; currentbalance_ = balance_ + netbalance_; shop_ = master_daily_sales.shop1.shop_code; shop1_ = master_daily_sales.shop1; }
public master_daily_sale find_master_daily_sale_By_AppId(string Appid) { try { master_daily_sale = db.master_daily_sales.SingleOrDefault(a => a.app_id == Appid); return(master_daily_sale); } catch (Exception) { return(null); } }
public master_daily_sale find_master_daily_sale_By_ID(int id) { try { master_daily_sale = db.master_daily_sales.SingleOrDefault(a => a.id == id); return(master_daily_sale); } catch (Exception) { return(null); } }
public master_daily_sale delete_master_daily_sale() { try { master_daily_sale prev_master_daily_sale = db.master_daily_sales.SingleOrDefault(a => a.id == master_daily_sale.id); db.master_daily_sales.DeleteOnSubmit(prev_master_daily_sale); return(master_daily_sale); } catch (Exception) { return(null); } }
public saleshelper(master_daily_sale sales) { this.shopcode_ = (sales.shop1 != null)?sales.shop1.shop_code : "ERROR SHOP"; this.stake = sales.stake.Value; this.cancelled = sales.cancelled.Value; this.single_sales = sales.single_stake_sales != null ? sales.single_stake_sales.Value : Decimal.Zero; this.single_comm = sales.single_stake_commision != null ? sales.single_stake_commision.Value : Decimal.Zero;; this.multi_sales = sales.sales.Value - this.single_sales; this.multi_comm = sales.commision.Value - this.single_comm; this.single_stake_perc = sales.single_stake_percent.ToString() + "%"; this.total_sales = sales.sales.Value; this.total_comm = sales.commision.Value; this.total_winnings = sales.winnings.Value; this.NetBalance_ = sales.sales.Value - sales.winnings.Value - sales.commision.Value; }
public balancesheethelper(master_balance_sheet existsheet, master_daily_sale sale, List <transaction_category> trancategory) { //dbmc = dbmc_; master_daily_sale = sale; this.trancategory = trancategory; sheet = existsheet; if (sheet == null) { application app = new application { app_id = Guid.NewGuid().ToString() }; sheet = new master_balance_sheet { App_id = app.app_id, shop = master_daily_sale.shop, netbalance = Decimal.Zero, sales_balance = Decimal.Zero, credit_balance = Decimal.Zero, online_credit = Decimal.Zero }; } }
public void computeSales() { if (hasMasterSale()) { mstake = (decimal)mastersales.Sum(a => a.stake); msales = (decimal)mastersales.Sum(a => a.sales); mwinnings = (decimal)mastersales.Sum(a => a.winnings); mcancelled = (decimal)mastersales.Sum(a => a.cancelled); mbalance = (decimal)mastersales.Sum(a => a.balance); mcommision = (decimal)mastersales.Sum(a => a.commision); mnetbalance = (decimal)mastersales.Sum(a => a.net_balance); msingle_sales = (decimal)mastersales.Sum(a => a.single_stake_sales); msingle_comm = (decimal)mastersales.Sum(a => a.single_stake_commision); mmulti_sales = msales - msingle_sales; mmulti_comm = mcommision - msingle_comm; msingle_percent = (decimal)mastersales.Average(a => a.single_stake_percent); } else { msales = mwinnings = mcancelled = mbalance = mcommision = mnetbalance = mstake = Decimal.Zero; } if (hasShopSale()) { sstake = (decimal)shopsales.Sum(a => a.stake); ssales = (decimal)shopsales.Sum(a => a.sales); swinnings = (decimal)shopsales.Sum(a => a.winnings); scancelled = (decimal)shopsales.Sum(a => a.cancelled); sbalance = (decimal)shopsales.Sum(a => a.balance); scommision = (decimal)shopsales.Sum(a => a.commision); snetbalance = (decimal)shopsales.Sum(a => a.net_balance); } else { ssales = swinnings = scancelled = sbalance = scommision = snetbalance = sstake = Decimal.Zero; } _combinedshopsales = new shop_daily_sale { stake = sstake, sales = ssales, winnings = swinnings, cancelled = scancelled, balance = sbalance, commision = scommision, net_balance = snetbalance, shop1 = shop }; _combinedmastersales = new master_daily_sale { stake = mstake, sales = msales, winnings = mwinnings, cancelled = mcancelled, balance = mbalance, commision = mcommision, net_balance = mnetbalance, shop1 = shop, single_stake_commision = msingle_comm, single_stake_percent = msingle_percent, single_stake_sales = msingle_sales }; cstake = Decimal.Subtract(mstake, sstake); csales = Decimal.Subtract(msales, ssales); cwinnings = Decimal.Subtract(mwinnings, swinnings); ccancelled = Decimal.Subtract(mcancelled, scancelled); cbalance = Decimal.Subtract(mbalance, sbalance); ccommision = Decimal.Subtract(mcommision, scommision); cnetbalance = Decimal.Subtract(mnetbalance, snetbalance); _combinedsale = new master_daily_sale { stake = cstake, sales = csales, winnings = cwinnings, cancelled = ccancelled, balance = cbalance, commision = ccommision, net_balance = cnetbalance, shop1 = _shop, single_stake_commision = msingle_comm, single_stake_percent = msingle_percent, single_stake_sales = msingle_sales }; //_combinedmastersales.shop1.shop_code }
public master_daily_sales_crud(master_daily_sale master_daily_sale_, List <transaction_category> trancategory, List <master_balance_sheet> sheets) { this.trancategory = trancategory; this.master_daily_sale_ = master_daily_sale_; this.sheets = sheets; }
public master_daily_sale insert_master_daily_sale() { bool isupdate = false; shop shop = find_shop_By_Code(master_daily_sale.shop1.shop_code); if (shop != null) { try { WgbSalesUpload.master_daily_sale prev_master_daily_sale = db.master_daily_sales.SingleOrDefault(u => u.shop1.id == shop.id && u.date == master_daily_sale.date); master_balance_sheet existsheet; try { existsheet = sheets.SingleOrDefault(a => a.shop == shop.id); } catch (Exception) { existsheet = null; } using (TransactionScope scope = new TransactionScope()) { if (prev_master_daily_sale != null) { isupdate = true; master_daily_sale negatesale = new master_daily_sale(); negatesale.balance = Math.Abs((decimal)prev_master_daily_sale.balance); negatesale.cancelled = Math.Abs((decimal)prev_master_daily_sale.cancelled); negatesale.commision = Math.Abs((decimal)prev_master_daily_sale.commision); negatesale.date_posted = DateTime.Now; negatesale.islocked = prev_master_daily_sale.islocked; negatesale.isverified = prev_master_daily_sale.isverified; negatesale.net_balance = Math.Abs((decimal)prev_master_daily_sale.net_balance); negatesale.posted_by = prev_master_daily_sale.posted_by; negatesale.sales = Math.Abs((decimal)prev_master_daily_sale.sales); negatesale.stake = Math.Abs((decimal)prev_master_daily_sale.stake); negatesale.winnings = Math.Abs((decimal)prev_master_daily_sale.winnings); negatesale.shop = prev_master_daily_sale.shop; negatesale.date = prev_master_daily_sale.date; negatesale.single_stake_commision = Math.Abs((decimal)prev_master_daily_sale.single_stake_commision); negatesale.single_stake_sales = Math.Abs((decimal)prev_master_daily_sale.single_stake_sales); negatesale.single_stake_percent = Math.Abs((decimal)prev_master_daily_sale.single_stake_percent); negatesale.other_stake_commision = Math.Abs((decimal)prev_master_daily_sale.other_stake_commision); application app2 = new application { app_id = Guid.NewGuid().ToString() }; negatesale.app_id = app2.app_id; //db.master_daily_sales.InsertOnSubmit(negatesale); bsh = new balancesheethelper(existsheet, negatesale, trancategory); List <master_transaction> translist = bsh.getDailySalestransactionsReversal(); //lodge commission for aunty bola if (shop.shop_ownership == "WGB") { transaction_category trancatcomm = trancategory.SingleOrDefault(a => a.code == "CR"); LodgeCommission(translist.SingleOrDefault(a => a.trans_category == trancatcomm.id), trancatcomm); } db.master_transactions.InsertAllOnSubmit(translist); master_balance_sheet sheet = bsh.balancesheet; // master_balance_sheet existsheet = db.master_balance_sheets.SingleOrDefault(a => a.shop == prev_master_daily_sale.shop); if (existsheet == null) { db.master_balance_sheets.InsertOnSubmit(sheet); } else { existsheet.netbalance = sheet.netbalance; existsheet.sales_balance = sheet.sales_balance; existsheet.online_credit = sheet.online_credit; existsheet.credit_balance = sheet.credit_balance; new CRUD.master_balance_sheet_crud(existsheet).alter_master_balance_sheet(); } prev_master_daily_sale.balance = master_daily_sale.balance; prev_master_daily_sale.cancelled = master_daily_sale.cancelled; prev_master_daily_sale.commision = master_daily_sale.commision; prev_master_daily_sale.date = master_daily_sale.date; prev_master_daily_sale.date_posted = master_daily_sale.date_posted; prev_master_daily_sale.islocked = master_daily_sale.islocked; prev_master_daily_sale.isverified = master_daily_sale.isverified; prev_master_daily_sale.net_balance = master_daily_sale.net_balance; prev_master_daily_sale.posted_by = master_daily_sale.posted_by; prev_master_daily_sale.sales = master_daily_sale.sales; // prev_master_daily_sale.shop = master_daily_sale.shop; prev_master_daily_sale.stake = master_daily_sale.stake; prev_master_daily_sale.winnings = master_daily_sale.winnings; prev_master_daily_sale.single_stake_sales = master_daily_sale.single_stake_sales; prev_master_daily_sale.single_stake_commision = master_daily_sale.single_stake_commision; prev_master_daily_sale.single_stake_percent = master_daily_sale.single_stake_percent; prev_master_daily_sale.other_stake_commision = master_daily_sale.other_stake_commision; // master_balance_sheet sheet = bsh.balancesheet; // master_balance_sheet existsheet = db.master_balance_sheets.SingleOrDefault(a => a.shop == master_daily_sale.shop); bsh = new balancesheethelper(existsheet, prev_master_daily_sale, trancategory); List <master_transaction> translist2 = bsh.getDailySalestransactions(); //lodge commission for aunty bola if (shop.shop_ownership == "WGB") { transaction_category trancatcomm = trancategory.SingleOrDefault(a => a.code == "C"); LodgeCommission(translist2.SingleOrDefault(a => a.trans_category == trancatcomm.id), trancatcomm); } db.master_transactions.InsertAllOnSubmit(translist2); master_balance_sheet sheet2 = bsh.balancesheet; if (existsheet == null) { db.master_balance_sheets.InsertOnSubmit(sheet2); } else { existsheet.netbalance = sheet.netbalance; existsheet.sales_balance = sheet.sales_balance; existsheet.online_credit = sheet.online_credit; existsheet.credit_balance = sheet.credit_balance; new CRUD.master_balance_sheet_crud(existsheet).alter_master_balance_sheet(); } db.SubmitChanges(); } if (!isupdate) { application app = new application { app_id = Guid.NewGuid().ToString() }; // app = new application_crud(app).insert_application(); db.SubmitChanges(); master_daily_sale.app_id = app.app_id; master_daily_sale.shop1 = shop; master_daily_sale.date_posted = DateTime.Today; if (master_daily_sale.shop1 != null) { db.master_daily_sales.InsertOnSubmit(master_daily_sale); bsh = new balancesheethelper(existsheet, master_daily_sale, trancategory); List <master_transaction> translist = bsh.getDailySalestransactions(); //lodge commission for aunty bola if (shop.shop_ownership == "WGB") { transaction_category trancatcomm = trancategory.SingleOrDefault(a => a.code == "C"); LodgeCommission(translist.SingleOrDefault(a => a.trans_category == trancatcomm.id), trancatcomm); } db.master_transactions.InsertAllOnSubmit(translist); master_balance_sheet sheet = bsh.balancesheet; //master_balance_sheet existsheet = db.master_balance_sheets.SingleOrDefault(a => a.shop == master_daily_sale.shop); if (existsheet == null) { db.master_balance_sheets.InsertOnSubmit(sheet); } else { existsheet.netbalance = sheet.netbalance; existsheet.sales_balance = sheet.sales_balance; existsheet.online_credit = sheet.online_credit; existsheet.credit_balance = sheet.credit_balance; new CRUD.master_balance_sheet_crud(existsheet).alter_master_balance_sheet(); } } // db.master_balance_sheets.InsertOnSubmit(sheet); db.SubmitChanges(); } scope.Complete(); } return(master_daily_sale); } catch (Exception) { return(null); } } else { return(null); } }