private async void GetTimeTable(int weekChange) { IsBusy = true; OnPropertyChangedModel(nameof(IsBusy)); FromDate = FromDate.AddDays(weekChange); ToDate = ToDate.AddDays(weekChange); TimeTable = await _model.GetTimeTable(cookerID, FromDate); OnPropertyChangedModel(nameof(TimeTable)); OnPropertyChangedModel(nameof(FromDate)); OnPropertyChangedModel(nameof(ToDate)); IsBusy = false; OnPropertyChangedModel(nameof(IsBusy)); }
public InvoiceHistoryViewModel(IInvoiceHistoryView view) : base(view) { ThisView = view; bAvoidDoubleRefresh = true; ToDateAll = ToDate = DateTime.Now; FromDateAll = FromDate = ToDate.AddDays(-90); bAvoidDoubleRefresh = false; InvoiceTarget = Spheris.Billing.Data.BillingDataFactory.NewInstance().CreateInvoiceRepository(); InvoiceGroupTarget = Spheris.Billing.Data.BillingDataFactory.NewInstance().CreateInvoiceGroupRepository(); PreparePrinterList(); Loading = hidden; SearchMethod = asBatch; ReportType = ReportTypes.BillOnly; }
public void UpdateEntries(ShowtimeGroup updatedGroup) { if (updatedGroup.FromDate < FromDate) { foreach (ShowtimeGroupEntry entry in ShowtimeGroupEntries) { DateTime earlier = updatedGroup.ToDate < FromDate.AddDays(-1) ? ToDate : FromDate.AddDays(-1); entry.GenerateShowtimes(Movie, updatedGroup.FromDate, earlier); } } else if (updatedGroup.FromDate > FromDate) { foreach (ShowtimeGroupEntry entry in ShowtimeGroupEntries) { entry.RemoveShowtimes(FromDate, updatedGroup.FromDate.AddDays(-1)); } } FromDate = updatedGroup.FromDate; if (updatedGroup.ToDate < ToDate) { foreach (ShowtimeGroupEntry entry in ShowtimeGroupEntries) { entry.RemoveShowtimes(updatedGroup.ToDate.AddDays(1), ToDate); } } else if (updatedGroup.ToDate > ToDate) { foreach (ShowtimeGroupEntry entry in ShowtimeGroupEntries) { DateTime later = ToDate.AddDays(1) > updatedGroup.FromDate ? ToDate.AddDays(1) : updatedGroup.FromDate; entry.GenerateShowtimes(Movie, later, updatedGroup.ToDate); } } ToDate = updatedGroup.ToDate; UpdateGroupEntries(updatedGroup); }
private async void LoadVatReport() { DateTime FromDate, ToDate; if (txtDateFrm.Text == string.Empty) { FromDate = DateTime.Today; FromDate = FromDate.AddDays(1 - FromDate.Day); // first day in current month } else { FromDate = localFromDate = txtDateFrm.DateTime.Date; } if (txtDateTo.Text == string.Empty) { ToDate = DateTime.Today.AddMonths(1); ToDate = ToDate.AddDays(-ToDate.Day); // last day in current month } else { ToDate = localToDate = txtDateTo.DateTime.Date; } busyIndicator.IsBusy = true; var qapi = api; var country = qapi.CompanyEntity._CountryId; var rapi = new ReportAPI(qapi); string journal = cmbJournal.Text; var vatTask = rapi.VatCodeSum(FromDate, ToDate, journal); SQLCache accounts = qapi.GetCache(typeof(Uniconta.DataModel.GLAccount)) ?? await qapi.LoadCache(typeof(Uniconta.DataModel.GLAccount)); SQLCache vats = qapi.GetCache(typeof(Uniconta.DataModel.GLVat)) ?? await qapi.LoadCache(typeof(Uniconta.DataModel.GLVat)); SQLCache vattypes = qapi.GetCache(typeof(Uniconta.DataModel.GLVatType)) ?? await qapi.LoadCache(typeof(Uniconta.DataModel.GLVatType)); FinancialBalance[] sumVat = await vatTask; if (sumVat == null || accounts == null || vats == null || vattypes == null) { busyIndicator.IsBusy = false; UtilDisplay.ShowErrorCode(rapi.LastError); return; } Array.Sort(sumVat, new AccountSorter()); VatReportLine v; var lst = new List <VatReportLine>(sumVat.Length); int decm = 2; bool RoundTo100 = false; if (!qapi.CompanyEntity.HasDecimals) { CalculatedVAT.HasDecimals = PostedVAT.HasDecimals = WithoutVAT.HasDecimals = Accumulated.HasDecimals = false; RoundTo100 = true; decm = 0; } var countrySelected = (CountryCode)Math.Max(0, vatCountry.SelectedIndex); var AccsFound = new HashSet <int>(); GLAccount Account; GLVat Vat; int i; bool HasOffsetType0 = false, HasOffsetType1 = false; int PrevAccount = 0; for (i = 0; (i < sumVat.Length); i++) { var sum = sumVat[i]; Account = (GLAccount)accounts.Get(sum.AccountRowId); if (Account == null) // || Account._SystemAccount == (byte)SystemAccountTypes.SalesTaxOffset) { continue; } //if (sum._Debit == 0 && sum._Credit == 0) // continue; Vat = (GLVat)vats.Get(sum.VatRowId); if (Vat == null) { continue; } var acStr = Account._Account; v = new VatReportLine(); v.AmountWithVat = sum.Debit; v._PostedVAT = sum.Credit; v._BaseVAT = sum.AmountBase; v.AccountNumber = acStr; v.Account = Account; v.AccountIsVat = Account._SystemAccount == (byte)SystemAccountTypes.SalesTaxPayable || Account._SystemAccount == (byte)SystemAccountTypes.SalesTaxReceiveable ? (byte)1 : (byte)0; if (Vat._Account == acStr || Vat._OffsetAccount == acStr) { if (Vat._Account == acStr) { v.AccountIsVat = 1; v.IsOffsetAccount = 0; } else { v.AccountIsVat = 1; v.IsOffsetAccount = 1; if (Vat._VatType == 0) { HasOffsetType0 = true; } else { HasOffsetType1 = true; } } } else { foreach (var va in (IEnumerable <GLVat>)vats.GetNotNullArray) { if (va._Account == acStr) { v.AccountIsVat = 1; v.IsOffsetAccount = 0; break; } if (va._OffsetAccount == acStr) { v.AccountIsVat = 1; v.IsOffsetAccount = 1; if (va._VatType == 0) { HasOffsetType0 = true; } else { HasOffsetType1 = true; } // do not break in case we foind the same account as _Account } } } v.Vat = Vat; v.VatType = (byte)Vat._VatType; if (v.IsOffsetAccount == 1 && Vat._OffsetVatOperation != null) { v._VatOperation = (byte)vattypes.Get(Vat._OffsetVatOperation).RowId; } else { v._VatOperation = sum.VatOperation != 0 ? sum.VatOperation : Vat._VatOperationCode; } v._CalculatedVAT = Vat.VatAmount1(v.AmountWithVat, FromDate, RoundTo100, GLVatCalculationMethod.Netto); v.FromDate = FromDate; v.CalcRate(RoundTo100); var vattp = (GLVatType)vattypes.Get(v._VatOperation); if (vattp != null) { v.VatOpr = vattp; v.vatOperation = vattp._Code; v.BaseVatText = vattp._Name; } lst.Add(v); if (PrevAccount != sum.AccountRowId) { PrevAccount = sum.AccountRowId; AccsFound.Add(sum.AccountRowId); } } foreach (var acc in (GLAccount[])accounts.GetNotNullArray) { if (acc._Vat != null) { Vat = (GLVat)vats.Get(acc._Vat); if (Vat == null) { continue; } if (countrySelected != 0 && countrySelected != (Vat._VatCountry != 0 ? Vat._VatCountry : country)) { continue; } AccsFound.Add(acc.RowId); } } List <int> AccLst = AccsFound.ToList(); AccsFound.Clear(); FinancialBalance[] AccTotals = await rapi.GenerateTotal(AccLst, FromDate, ToDate, journal, null, 0, true, false); SQLCacheTemplate <FinancialBalance> AccLookup = null; if (AccTotals != null && AccTotals.Length > 0) { AccLookup = new SQLCacheTemplate <FinancialBalance>(AccTotals, false); } lst.Sort(new VatAccountSort()); FinancialBalance AccTotal; int AccountRowId = 0; double AmountDif = 0d; VatReportLine vDif = new VatReportLine(); for (i = lst.Count; (--i >= 0);) { v = lst[i]; if (v.Account.RowId != AccountRowId) { if (AmountDif > 0.005d || AmountDif < -0.005d) { vDif.AmountWithout = GLVat.Round(AmountDif); lst.Add(vDif); vDif = new VatReportLine(); } AccountRowId = v.Account.RowId; AccTotal = AccLookup?.Get(AccountRowId); if (AccTotal != null) { AmountDif = (AccTotal._Debit - AccTotal._Credit) / 100d; } else { AmountDif = 0d; } AccsFound.Add(AccountRowId); } AmountDif -= v.AmountWithVat; vDif.Account = v.Account; vDif.AccountNumber = v.AccountNumber; vDif.VatType = v.VatType; vDif.AccountIsVat = v.AccountIsVat; vDif.IsOffsetAccount = v.IsOffsetAccount; } if (AmountDif > 0.005d || AmountDif < -0.005d) { vDif.AmountWithout = GLVat.Round(AmountDif); lst.Add(vDif); } if (AccLookup != null) { // Add account, that has a VAT-code but no transactios with VAT. for (i = 0; (i < AccTotals.Length); i++) { AccTotal = AccTotals[i]; if (!AccsFound.Contains(AccTotal.RowId) && (AccTotal._Debit - AccTotal._Credit) != 0) { Account = (GLAccount)accounts.Get(AccTotal.RowId); if (Account?._Vat == null) { continue; } Vat = (GLVat)vats.Get(Account._Vat); if (Vat == null) { continue; } vDif = new VatReportLine(); vDif.AmountWithout = (AccTotal._Debit - AccTotal._Credit) / 100d; vDif.Account = Account; vDif.AccountNumber = Account._Account; vDif.VatType = (byte)Vat._VatType; lst.Add(vDif); } } } if (countrySelected != 0) { for (i = lst.Count; (--i >= 0);) { Vat = (GLVat)vats.Get(lst[i].VatCode); if (Vat != null) { if (countrySelected != (Vat._VatCountry != 0 ? Vat._VatCountry : country)) { lst.RemoveAt(i); continue; } } } } vDif = null; for (int k = 0; (k < 4); k++) { string helptext; if (k == 0) { helptext = "sales"; } else if (k == 1) { helptext = "buy"; } else if (k == 2) { helptext = "sales vat"; } else { helptext = "buy vat"; } for (int n = 0; n < 3; n++) { vDif = new VatReportLine(); vDif.helptext = helptext; vDif.Order = (n > 0) ? n : -1; // header, total, empty vDif.VatType = (byte)(k % 2); vDif.AccountIsVat = (byte)(k / 2); vDif.isvatotal = (k >= 2 && n == 1); lst.Add(vDif); if (vDif.AccountIsVat == 1) { if ((HasOffsetType0 && vDif.VatType == 0) || (HasOffsetType1 && vDif.VatType == 1)) { vDif = new VatReportLine(); vDif.helptext = "import vat"; vDif.Order = (n > 0) ? n : -1; // header, total, empty vDif.VatType = (byte)(k % 2); vDif.AccountIsVat = 1; vDif.IsOffsetAccount = 1; vDif.isvatotal = true; lst.Add(vDif); } } } } vDif = null; lst.Sort(new VatTotalsSort()); double d1 = 0d, d2 = 0d, d3 = 0d, d4 = 0d; double[] VatOperationValues = new double[256]; double[] VatOperationBases = new double[256]; double[] VatValues = new double[256]; double[] VatBases = new double[256]; VatSumOperationReport[] vatReportSum = new VatSumOperationReport[127]; for (i = 0; (i < lst.Count); i++) { v = lst[i]; if (v.Order == 1) // total { v.AmountWithVat = Math.Round(d1, decm); var AmountWithout = Math.Round(d2, decm); v.AmountWithout = AmountWithout; v._CalculatedVAT = Math.Round(d3, decm); v._PostedVAT = Math.Round(d4, decm); d1 = d2 = d3 = d4 = 0d; if (country == CountryCode.Denmark && AmountWithout != 0 && v.AccountIsVat == 1) { if (v.IsOffsetAccount == 0) { // here we sum up the amount without vatcodes if (v.VatType == 0) { var sumLine = CreateSum(vatReportSum, 33); sumLine._Amount -= AmountWithout; } else { var sumLine = CreateSum(vatReportSum, 23); sumLine._Amount += AmountWithout; sumLine = CreateSum(vatReportSum, 31); sumLine._Amount += AmountWithout; } } else { if (v.VatType == 1) { var sumLine = CreateSum(vatReportSum, 34); sumLine._Amount -= AmountWithout; } } } } else { d1 += v.AmountWithVat; d2 += v.AmountWithout; d3 += v._CalculatedVAT; d4 += v._PostedVAT; if (v.AccountIsVat == 1) { if (v.IsOffsetAccount == 0) { VatOperationValues[v._VatOperation] += v.AmountWithVat; if (v.Vat != null) { VatValues[v.Vat.RowId] += v.AmountWithVat; } } } else { VatOperationBases[v._VatOperation] += v.AmountWithVat; if (v.Vat != null) { VatBases[v.Vat.RowId] += v.AmountWithVat; } } } } vDif = new VatReportLine(); vDif.Text = string.Format("{0}: {1}, {2}", Uniconta.ClientTools.Localization.lookup("FinalVatStatus"), Uniconta.ClientTools.Localization.lookup("AmountBase"), Uniconta.ClientTools.Localization.lookup("VATamount")); lst.Add(vDif); foreach (var c in (GLVatType[])vattypes.GetNotNullArray) { if (c == null) { continue; } vDif = new VatReportLine(); vDif.vatOperation = c._Code; vDif._Rate = c._Pct1; vDif.Text = string.Concat(c._Code, ", ", c._Name); vDif.AmountWithVat = VatOperationBases[c._RowNo]; vDif._PostedVAT = VatOperationValues[c._RowNo]; vDif.AccountIsVat = 1; lst.Add(vDif); int pos = c._Position1; if (pos > 0) { UpdateSum(vatReportSum, vDif, pos, c._Position2, c._Position3); } pos = c._Position4; if (pos > 0) { UpdateSum(vatReportSum, vDif, pos, c._Position5, c._Position6); } pos = c._Position7; if (pos > 0) { UpdateSum(vatReportSum, vDif, pos, c._Position8, c._Position9); } pos = c._Position10; if (pos > 0) { UpdateSum(vatReportSum, vDif, pos, c._Position11, c._Position12); } pos = c._Position13; if (pos > 0) { UpdateSum(vatReportSum, vDif, pos, c._Position14, c._Position15); } } List <VatReportLine> vatlst = new List <VatReportLine>(); this.vatlst = vatlst; for (int k = 0; (k < 2); k++) { vDif = new VatReportLine(); vDif.Text = string.Empty; lst.Add(vDif); vDif = new VatReportLine(); vDif.VatType = (byte)k; vDif.Order = -1; vDif.AccountIsVat = 1; lst.Add(vDif); foreach (var c in (GLVat[])vats.GetNotNullArray) { if (c != null && (int)c._VatType == k) { if (countrySelected != 0 && countrySelected != (c._VatCountry != 0 ? c._VatCountry : country)) { continue; } vDif = new VatReportLine(); vDif.Vat = c; vDif.Text = string.Concat(c._Vat, ", ", c._Name); vDif.AmountWithVat = VatBases[c.RowId]; vDif._PostedVAT = VatValues[c.RowId]; vDif.AccountIsVat = 1; vDif.FromDate = FromDate; vDif.CalcRate(RoundTo100); lst.Add(vDif); vatlst.Add(vDif); } } } dgVatReport.ItemsSource = lst; if (lst.Count > 0) { SetMenuItem(); } if (country == CountryCode.Denmark) { AccLst.Clear(); foreach (var acc in (GLAccount[])accounts.GetNotNullArray) { if (acc._SystemAccount == (byte)SystemAccountTypes.OtherTax) { AccLst.Add(acc.RowId); } } if (AccLst != null && AccLst.Count > 0) { AccTotals = await rapi.GenerateTotal(AccLst, FromDate, ToDate); if (AccTotals != null && AccTotals.Length > 0) { var otherTaxList = new ReportDataDenmark[AccTotals.Length]; i = 14; foreach (var acTot in AccTotals) { var Acc = accounts.Get(acTot.AccountRowId); var lin = new VatSumOperationReport() { _Text = Acc.KeyName, _Amount = (acTot._Debit - acTot._Credit) / 100d, _Line = i }; vatReportSum[i] = lin; i++; if (i == 19) { break; } } } } } for (i = vatReportSumSize + 1; (--i >= 1);) { if (vatReportSum[i] == null) { vatReportSum[i] = new VatSumOperationReport() { _Line = i } } } ; this.vatReportSum = vatReportSum.Where(r => r != null).ToList(); dgVatReport.Visibility = Visibility.Visible; busyIndicator.IsBusy = false; }
public void SearchByDate() { var Tasks = RawTasks.Where(d => d.StartDate >= FromDate.Date && d.StartDate <= ToDate.AddDays(1)); Navigate(0, Tasks.ToList()); }
private void butOK_Click(object sender, System.EventArgs e) { if (textDateFrom.errorProvider1.GetError(textDateFrom) != "" || textDateTo.errorProvider1.GetError(textDateTo) != "" ) { MessageBox.Show(Lan.g(this, "Please fix data entry errors first.")); return; } DateTime FromDate; DateTime ToDate; if (textDateFrom.Text == "") { MessageBox.Show(Lan.g(this, "From Date cannot be left blank.")); return; } FromDate = PIn.PDate(textDateFrom.Text); if (textDateTo.Text == "") { ToDate = DateTime.MaxValue.AddDays(-1); } else { ToDate = PIn.PDate(textDateTo.Text); } //Create the file and first row-------------------------------------------------------- ArrayList ForProgram = ProgramProperties.GetForProgram(ProgramCur.ProgramNum); ProgramProperty PPCur = ProgramProperties.GetCur(ForProgram, "Export Path"); string fileName = PPCur.PropertyValue + "Appt.txt"; if (!Directory.Exists(PPCur.PropertyValue)) { Directory.CreateDirectory(PPCur.PropertyValue); } StreamWriter sr = File.CreateText(fileName); sr.WriteLine("\"LastName\",\"FirstName\",\"PatientNumber\",\"HomePhone\",\"WorkNumber\"," + "\"EmailAddress\",\"SendEmail\",\"Address\",\"Address2\",\"City\",\"State\",\"Zip\"," + "\"ApptDate\",\"ApptTime\",\"ApptReason\",\"DoctorNumber\",\"DoctorName\",\"IsNewPatient\""); //now, the query-------------------------------------------------------------------------- //Appointment Reminder Fields- numbers are as they come back from db----------------------- //0-LastName //1-FirstName (or we substitute 2-Preferred Name if exists) // PatientNumber (Can be 3-PatNum or 4-ChartNumber, depending on what user selected) //5-HomePhone //6-WorkNumber //7-EmailAddress // SendEmail (this will be true if email address exists. Might change later) //8-Address //9-Address2 (although they did not offer this as an option) //10-City //11-State //12-Zip //13-ApptDate //13-ApptTime //14-ApptReason (procedures descriptions-user can't edit) //15-DoctorNumber (for the Doctor, we currently use the patient primary provider. Otherwise, we would run into trouble with appointments assigned to a specific hygienist.) //15-DoctorName //16-IsNewPatient string command = @"SELECT patient.LName,patient.FName,patient.Preferred ,patient.PatNum,patient.ChartNumber,patient.HmPhone,patient.WkPhone ,patient.Email,patient.Address,patient.Address2,patient.City,patient.State ,patient.Zip ,appointment.AptDateTime,appointment.ProcDescript ,patient.PriProv ,appointment.IsNewPatient FROM patient,appointment WHERE patient.PatNum=appointment.PatNum " + "AND (appointment.AptStatus=1 OR appointment.AptStatus=4) " //sched or ASAP + "AND appointment.AptDateTime > " + POut.PDate(FromDate) //> midnight + " AND appointment.AptDateTime < " + POut.PDate(ToDate.AddDays(1)); //< midnight DataTable table = General.GetTable(command); bool usePatNum = false; PPCur = ProgramProperties.GetCur(ForProgram, "Enter 0 to use PatientNum, or 1 to use ChartNum");; if (PPCur.PropertyValue == "0") { usePatNum = true; } DateTime aptDT; for (int i = 0; i < table.Rows.Count; i++) { sr.Write("\"" + Dequote(PIn.PString(table.Rows[i][0].ToString())) + "\","); //0-LastName if (table.Rows[i][2].ToString() != "") //if Preferred Name exists { sr.Write("\"" + Dequote(PIn.PString(table.Rows[i][2].ToString())) + "\","); //2-PrefName } else { sr.Write("\"" + Dequote(PIn.PString(table.Rows[i][1].ToString())) + "\","); //1-FirstName } if (usePatNum) { sr.Write("\"" + table.Rows[i][3].ToString() + "\","); //3-PatNum } else { sr.Write("\"" + Dequote(PIn.PString(table.Rows[i][4].ToString())) + "\","); //4-ChartNumber } sr.Write("\"" + Dequote(PIn.PString(table.Rows[i][5].ToString())) + "\","); //5-HomePhone sr.Write("\"" + Dequote(PIn.PString(table.Rows[i][6].ToString())) + "\","); //6-WorkNumber sr.Write("\"" + Dequote(PIn.PString(table.Rows[i][7].ToString())) + "\","); //7-EmailAddress if (table.Rows[i][7].ToString() != "") //if an email exists { sr.Write("\"T\","); //SendEmail } else { sr.Write("\"F\","); } sr.Write("\"" + Dequote(PIn.PString(table.Rows[i][8].ToString())) + "\","); //8-Address sr.Write("\"" + Dequote(PIn.PString(table.Rows[i][9].ToString())) + "\","); //9-Address2 sr.Write("\"" + Dequote(PIn.PString(table.Rows[i][10].ToString())) + "\","); //10-City sr.Write("\"" + Dequote(PIn.PString(table.Rows[i][11].ToString())) + "\","); //11-State sr.Write("\"" + Dequote(PIn.PString(table.Rows[i][12].ToString())) + "\","); //12-Zip aptDT = PIn.PDateT(table.Rows[i][13].ToString()); sr.Write("\"" + aptDT.ToString("MM/dd/yyyy") + "\","); //13-ApptDate sr.Write("\"" + aptDT.ToString("hh:mm tt") + "\","); //13-ApptTime eg 01:30 PM sr.Write("\"" + Dequote(PIn.PString(table.Rows[i][14].ToString())) + "\","); //14-ApptReason sr.Write("\"" + table.Rows[i][15].ToString() + "\","); //15-DoctorNumber. might possibly be 0 //15-DoctorName. Can handle 0 without any problem. sr.Write("\"" + Dequote(Providers.GetLName(PIn.PInt(table.Rows[i][15].ToString()))) + "\","); if (table.Rows[i][16].ToString() == "1") //16-IsNewPatient { sr.WriteLine("\"T\""); //SendEmail } else { sr.WriteLine("\"F\""); } } sr.Close(); MessageBox.Show("Done"); DialogResult = DialogResult.OK; }
public async Task WhenIAskForEventsOutsideTheEventsDateRange_ItReturnsTheEvent() { var events = await Client.QueryEventsAndAssertOK(fromDate : FromDate.AddDays(-1), toDate : ToDate.AddDays(1)); Assert.NotEmpty(events); }
public async Task WhenIAskForEventsFromAfterThatDate_ItReturnsNoEvents() { var events = await Client.QueryEventsAndAssertOK(fromDate : ToDate.AddDays(1)); Assert.Empty(events); }