mirror of
https://github.com/hargata/lubelog.git
synced 2025-12-10 00:46:08 -06:00
Merge pull request #813 from hargata/Hargata/755
add days as an interval for recurring tax records and reminders
This commit is contained in:
commit
e26869b30b
@ -156,6 +156,7 @@ namespace CarCareTracker.Controllers
|
||||
ReminderMonthInterval = result.ReminderMonthInterval,
|
||||
CustomMileageInterval = result.CustomMileageInterval,
|
||||
CustomMonthInterval = result.CustomMonthInterval,
|
||||
CustomMonthIntervalUnit = result.CustomMonthIntervalUnit,
|
||||
Tags = result.Tags
|
||||
};
|
||||
return PartialView("_ReminderRecordModal", convertedResult);
|
||||
|
||||
@ -90,6 +90,7 @@ namespace CarCareTracker.Controllers
|
||||
IsRecurring = result.IsRecurring,
|
||||
RecurringInterval = result.RecurringInterval,
|
||||
CustomMonthInterval = result.CustomMonthInterval,
|
||||
CustomMonthIntervalUnit = result.CustomMonthIntervalUnit,
|
||||
Files = result.Files,
|
||||
Tags = result.Tags,
|
||||
ExtraFields = StaticHelper.AddExtraFields(result.ExtraFields, _extraFieldDataAccess.GetExtraFieldsById((int)ImportMode.TaxRecord).ExtraFields)
|
||||
|
||||
8
Enum/ReminderIntervalUnit.cs
Normal file
8
Enum/ReminderIntervalUnit.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace CarCareTracker.Models
|
||||
{
|
||||
public enum ReminderIntervalUnit
|
||||
{
|
||||
Months = 1,
|
||||
Days = 2
|
||||
}
|
||||
}
|
||||
@ -24,9 +24,16 @@ namespace CarCareTracker.Helper
|
||||
{
|
||||
existingReminder.Date = newDate.AddMonths((int)existingReminder.ReminderMonthInterval);
|
||||
} else
|
||||
{
|
||||
if (existingReminder.CustomMonthIntervalUnit == ReminderIntervalUnit.Months)
|
||||
{
|
||||
existingReminder.Date = newDate.Date.AddMonths(existingReminder.CustomMonthInterval);
|
||||
}
|
||||
else if (existingReminder.CustomMonthIntervalUnit == ReminderIntervalUnit.Days)
|
||||
{
|
||||
existingReminder.Date = newDate.Date.AddDays(existingReminder.CustomMonthInterval);
|
||||
}
|
||||
}
|
||||
|
||||
if (existingReminder.ReminderMileageInterval != ReminderMileageInterval.Other)
|
||||
{
|
||||
@ -54,9 +61,16 @@ namespace CarCareTracker.Helper
|
||||
existingReminder.Date = newDate.AddMonths((int)existingReminder.ReminderMonthInterval);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (existingReminder.CustomMonthIntervalUnit == ReminderIntervalUnit.Months)
|
||||
{
|
||||
existingReminder.Date = newDate.AddMonths(existingReminder.CustomMonthInterval);
|
||||
}
|
||||
else if (existingReminder.CustomMonthIntervalUnit == ReminderIntervalUnit.Days)
|
||||
{
|
||||
existingReminder.Date = newDate.AddDays(existingReminder.CustomMonthInterval);
|
||||
}
|
||||
}
|
||||
}
|
||||
return existingReminder;
|
||||
}
|
||||
|
||||
@ -340,7 +340,8 @@ namespace CarCareTracker.Logic
|
||||
bool RecurringTaxIsOutdated(TaxRecord taxRecord)
|
||||
{
|
||||
var monthInterval = taxRecord.RecurringInterval != ReminderMonthInterval.Other ? (int)taxRecord.RecurringInterval : taxRecord.CustomMonthInterval;
|
||||
return DateTime.Now > taxRecord.Date.AddMonths(monthInterval);
|
||||
bool addDays = taxRecord.RecurringInterval == ReminderMonthInterval.Other && taxRecord.CustomMonthIntervalUnit == ReminderIntervalUnit.Days;
|
||||
return addDays ? DateTime.Now > taxRecord.Date.AddDays(monthInterval) : DateTime.Now > taxRecord.Date.AddMonths(monthInterval);
|
||||
}
|
||||
var result = _taxRecordDataAccess.GetTaxRecordsByVehicleId(vehicleId);
|
||||
var outdatedRecurringFees = result.Where(x => x.IsRecurring && RecurringTaxIsOutdated(x));
|
||||
@ -351,6 +352,7 @@ namespace CarCareTracker.Logic
|
||||
{
|
||||
var monthInterval = recurringFee.RecurringInterval != ReminderMonthInterval.Other ? (int)recurringFee.RecurringInterval : recurringFee.CustomMonthInterval;
|
||||
bool isOutdated = true;
|
||||
bool addDays = recurringFee.RecurringInterval == ReminderMonthInterval.Other && recurringFee.CustomMonthIntervalUnit == ReminderIntervalUnit.Days;
|
||||
//update the original outdated tax record
|
||||
recurringFee.IsRecurring = false;
|
||||
_taxRecordDataAccess.SaveTaxRecordToVehicle(recurringFee);
|
||||
@ -361,9 +363,9 @@ namespace CarCareTracker.Logic
|
||||
{
|
||||
try
|
||||
{
|
||||
var nextDate = originalDate.AddMonths(monthInterval * monthMultiplier);
|
||||
var nextDate = addDays ? originalDate.AddDays(monthInterval * monthMultiplier) : originalDate.AddMonths(monthInterval * monthMultiplier);
|
||||
monthMultiplier++;
|
||||
var nextnextDate = originalDate.AddMonths(monthInterval * monthMultiplier);
|
||||
var nextnextDate = addDays ? originalDate.AddDays(monthInterval * monthMultiplier) : originalDate.AddMonths(monthInterval * monthMultiplier);
|
||||
recurringFee.Date = nextDate;
|
||||
recurringFee.Id = default; //new record
|
||||
recurringFee.IsRecurring = DateTime.Now <= nextnextDate;
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
public ReminderUrgencyConfig CustomThresholds { get; set; } = new ReminderUrgencyConfig();
|
||||
public int CustomMileageInterval { get; set; } = 0;
|
||||
public int CustomMonthInterval { get; set; } = 0;
|
||||
public ReminderIntervalUnit CustomMonthIntervalUnit { get; set; } = ReminderIntervalUnit.Months;
|
||||
public ReminderMileageInterval ReminderMileageInterval { get; set; } = ReminderMileageInterval.FiveThousandMiles;
|
||||
public ReminderMonthInterval ReminderMonthInterval { get; set; } = ReminderMonthInterval.OneYear;
|
||||
public ReminderMetric Metric { get; set; } = ReminderMetric.Date;
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
public ReminderUrgencyConfig CustomThresholds { get; set; } = new ReminderUrgencyConfig();
|
||||
public int CustomMileageInterval { get; set; } = 0;
|
||||
public int CustomMonthInterval { get; set; } = 0;
|
||||
public ReminderIntervalUnit CustomMonthIntervalUnit { get; set; } = ReminderIntervalUnit.Months;
|
||||
public ReminderMileageInterval ReminderMileageInterval { get; set; } = ReminderMileageInterval.FiveThousandMiles;
|
||||
public ReminderMonthInterval ReminderMonthInterval { get; set; } = ReminderMonthInterval.OneYear;
|
||||
public ReminderMetric Metric { get; set; } = ReminderMetric.Date;
|
||||
@ -34,6 +35,7 @@
|
||||
ReminderMonthInterval = ReminderMonthInterval,
|
||||
CustomMileageInterval = CustomMileageInterval,
|
||||
CustomMonthInterval = CustomMonthInterval,
|
||||
CustomMonthIntervalUnit = CustomMonthIntervalUnit,
|
||||
Notes = Notes,
|
||||
Tags = Tags
|
||||
};
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
public bool IsRecurring { get; set; } = false;
|
||||
public ReminderMonthInterval RecurringInterval { get; set; } = ReminderMonthInterval.OneYear;
|
||||
public int CustomMonthInterval { get; set; } = 0;
|
||||
public ReminderIntervalUnit CustomMonthIntervalUnit { get; set; } = ReminderIntervalUnit.Months;
|
||||
public List<UploadedFiles> Files { get; set; } = new List<UploadedFiles>();
|
||||
public List<string> Tags { get; set; } = new List<string>();
|
||||
public List<ExtraField> ExtraFields { get; set; } = new List<ExtraField>();
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
public bool IsRecurring { get; set; } = false;
|
||||
public ReminderMonthInterval RecurringInterval { get; set; } = ReminderMonthInterval.ThreeMonths;
|
||||
public int CustomMonthInterval { get; set; } = 0;
|
||||
public ReminderIntervalUnit CustomMonthIntervalUnit { get; set; } = ReminderIntervalUnit.Months;
|
||||
public List<UploadedFiles> Files { get; set; } = new List<UploadedFiles>();
|
||||
public List<string> Tags { get; set; } = new List<string>();
|
||||
public List<ExtraField> ExtraFields { get; set; } = new List<ExtraField>();
|
||||
@ -25,6 +26,7 @@
|
||||
IsRecurring = IsRecurring,
|
||||
RecurringInterval = RecurringInterval,
|
||||
CustomMonthInterval = CustomMonthInterval,
|
||||
CustomMonthIntervalUnit = CustomMonthIntervalUnit,
|
||||
Files = Files,
|
||||
Tags = Tags,
|
||||
ExtraFields = ExtraFields
|
||||
|
||||
@ -82,9 +82,9 @@
|
||||
<!option value="OneHundredThousandMiles" @(Model.ReminderMileageInterval == ReminderMileageInterval.OneHundredThousandMiles ? "selected" : "")>100000 mi. / Km</!option>
|
||||
<!option value="OneHundredFiftyThousandMiles" @(Model.ReminderMileageInterval == ReminderMileageInterval.OneHundredFiftyThousandMiles ? "selected" : "")>150000 mi. / Km</!option>
|
||||
</select>
|
||||
<label for="reminderRecurringMonth">@translator.Translate(userLanguage, "Month")</label>
|
||||
<label for="reminderRecurringMonth">@translator.Translate(userLanguage, "Time")</label>
|
||||
<select class="form-select" onchange="checkCustomMonthInterval()" id="reminderRecurringMonth" @(Model.IsRecurring && (Model.Metric == ReminderMetric.Date || Model.Metric == ReminderMetric.Both) ? "" : "disabled")>
|
||||
<!option value="Other" @(Model.ReminderMonthInterval == ReminderMonthInterval.Other ? "selected" : "")>@(Model.ReminderMonthInterval == ReminderMonthInterval.Other && Model.CustomMonthInterval > 0 ? $"{translator.Translate(userLanguage, "Other")}: {Model.CustomMonthInterval}" : $"{translator.Translate(userLanguage, "Other")}") </!option>
|
||||
<!option value="Other" @(Model.ReminderMonthInterval == ReminderMonthInterval.Other ? "selected" : "")>@(Model.ReminderMonthInterval == ReminderMonthInterval.Other && Model.CustomMonthInterval > 0 ? $"{translator.Translate(userLanguage, "Other")}: {Model.CustomMonthInterval} {Model.CustomMonthIntervalUnit}" : $"{translator.Translate(userLanguage, "Other")}") </!option>
|
||||
<!option value="OneMonth" @(Model.ReminderMonthInterval == ReminderMonthInterval.OneMonth ? "selected" : "")>@translator.Translate(userLanguage, "1 Month")</!option>
|
||||
<!option value="ThreeMonths" @(Model.ReminderMonthInterval == ReminderMonthInterval.ThreeMonths || isNew ? "selected" : "")>@translator.Translate(userLanguage,"3 Months")</!option>
|
||||
<!option value="SixMonths" @(Model.ReminderMonthInterval == ReminderMonthInterval.SixMonths ? "selected" : "")>@translator.Translate(userLanguage,"6 Months")</!option>
|
||||
@ -136,6 +136,7 @@
|
||||
<script>
|
||||
var customMileageInterval = @Model.CustomMileageInterval;
|
||||
var customMonthInterval = @Model.CustomMonthInterval;
|
||||
var customMonthIntervalUnit = decodeHTMLEntities('@Model.CustomMonthIntervalUnit');
|
||||
function getReminderRecordModelData() {
|
||||
return { id: @Model.Id, mileageInterval: decodeHTMLEntities('@Model.ReminderMileageInterval.ToString()'), monthInterval: decodeHTMLEntities('@Model.ReminderMonthInterval.ToString()')}
|
||||
}
|
||||
|
||||
@ -57,9 +57,9 @@
|
||||
<input class="form-check-input" type="checkbox" onChange="enableTaxRecurring()" role="switch" id="taxIsRecurring" checked="@Model.IsRecurring">
|
||||
<label class="form-check-label" for="taxIsRecurring">@translator.Translate(userLanguage,"Is Recurring")</label>
|
||||
</div>
|
||||
<label for="taxRecurringMonth">@translator.Translate(userLanguage,"Month")</label>
|
||||
<label for="taxRecurringMonth">@translator.Translate(userLanguage,"Time")</label>
|
||||
<select class="form-select" onchange="checkCustomMonthIntervalForTax()" id="taxRecurringMonth" @(Model.IsRecurring ? "" : "disabled")>
|
||||
<!option value="Other" @(Model.RecurringInterval == ReminderMonthInterval.Other ? "selected" : "")>@(Model.RecurringInterval == ReminderMonthInterval.Other && Model.CustomMonthInterval > 0 ? $"{translator.Translate(userLanguage, "Other")}: {Model.CustomMonthInterval}" : $"{translator.Translate(userLanguage, "Other")}") </!option>
|
||||
<!option value="Other" @(Model.RecurringInterval == ReminderMonthInterval.Other ? "selected" : "")>@(Model.RecurringInterval == ReminderMonthInterval.Other && Model.CustomMonthInterval > 0 ? $"{translator.Translate(userLanguage, "Other")}: {Model.CustomMonthInterval} {Model.CustomMonthIntervalUnit}" : $"{translator.Translate(userLanguage, "Other")}") </!option>
|
||||
<!option value="OneMonth" @(Model.RecurringInterval == ReminderMonthInterval.OneMonth ? "selected" : "")>@translator.Translate(userLanguage,"1 Month")</!option>
|
||||
<!option value="ThreeMonths" @(Model.RecurringInterval == ReminderMonthInterval.ThreeMonths || isNew ? "selected" : "")>@translator.Translate(userLanguage, "3 Months")</!option>
|
||||
<!option value="SixMonths" @(Model.RecurringInterval == ReminderMonthInterval.SixMonths ? "selected" : "")>@translator.Translate(userLanguage, "6 Months")</!option>
|
||||
@ -116,6 +116,7 @@
|
||||
<script>
|
||||
var uploadedFiles = [];
|
||||
var customMonthInterval = @Model.CustomMonthInterval;
|
||||
var customMonthIntervalUnit = decodeHTMLEntities('@Model.CustomMonthIntervalUnit');
|
||||
var recurringReminderRecordId = [];
|
||||
getUploadedFilesFromModel();
|
||||
function getUploadedFilesFromModel() {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -21,23 +21,29 @@ function checkCustomMonthInterval() {
|
||||
if (selectedValue == "Other") {
|
||||
$("#workAroundInput").show();
|
||||
Swal.fire({
|
||||
title: 'Specify Custom Month Interval',
|
||||
title: 'Specify Custom Time Interval',
|
||||
html: `
|
||||
<input type="text" inputmode="numeric" id="inputCustomMileage" class="swal2-input" placeholder="Months" onkeydown="handleSwalEnter(event)">
|
||||
<input type="text" inputmode="numeric" id="inputCustomMonth" class="swal2-input" placeholder="Time" onkeydown="handleSwalEnter(event)">
|
||||
<select class="swal2-select" id="inputCustomMonthUnit">
|
||||
<option value="Months">Months</option>
|
||||
<option value="Days">Days</option>
|
||||
</select>
|
||||
`,
|
||||
confirmButtonText: 'Set',
|
||||
focusConfirm: false,
|
||||
preConfirm: () => {
|
||||
const customMonth = $("#inputCustomMileage").val();
|
||||
const customMonth = $("#inputCustomMonth").val();
|
||||
if (!customMonth || isNaN(parseInt(customMonth)) || parseInt(customMonth) <= 0) {
|
||||
Swal.showValidationMessage(`Please enter a valid number`);
|
||||
}
|
||||
return { customMonth }
|
||||
const customMonthUnit = $("#inputCustomMonthUnit").val();
|
||||
return { customMonth, customMonthUnit }
|
||||
},
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
customMonthInterval = result.value.customMonth;
|
||||
$("#reminderRecurringMonth > option[value='Other']").text(`Other: ${result.value.customMonth}`);
|
||||
customMonthIntervalUnit = result.value.customMonthUnit;
|
||||
$("#reminderRecurringMonth > option[value='Other']").text(`Other: ${result.value.customMonth} ${result.value.customMonthUnit}`);
|
||||
} else {
|
||||
$("#reminderRecurringMonth").val(getReminderRecordModelData().monthInterval);
|
||||
}
|
||||
@ -276,6 +282,7 @@ function getAndValidateReminderRecordValues() {
|
||||
reminderMonthInterval: reminderRecurringMonth,
|
||||
customMileageInterval: customMileageInterval,
|
||||
customMonthInterval: customMonthInterval,
|
||||
customMonthIntervalUnit: customMonthIntervalUnit,
|
||||
tags: reminderTags
|
||||
}
|
||||
}
|
||||
|
||||
@ -102,23 +102,29 @@ function checkCustomMonthIntervalForTax() {
|
||||
if (selectedValue == "Other") {
|
||||
$("#workAroundInput").show();
|
||||
Swal.fire({
|
||||
title: 'Specify Custom Month Interval',
|
||||
title: 'Specify Custom Time Interval',
|
||||
html: `
|
||||
<input type="text" inputmode="numeric" id="inputCustomMileage" class="swal2-input" placeholder="Months" onkeydown="handleSwalEnter(event)">
|
||||
<input type="text" inputmode="numeric" id="inputCustomMonth" class="swal2-input" placeholder="Months" onkeydown="handleSwalEnter(event)">
|
||||
<select class="swal2-select" id="inputCustomMonthUnit">
|
||||
<option value="Months">Months</option>
|
||||
<option value="Days">Days</option>
|
||||
</select>
|
||||
`,
|
||||
confirmButtonText: 'Set',
|
||||
focusConfirm: false,
|
||||
preConfirm: () => {
|
||||
const customMonth = $("#inputCustomMileage").val();
|
||||
const customMonth = $("#inputCustomMonth").val();
|
||||
if (!customMonth || isNaN(parseInt(customMonth)) || parseInt(customMonth) <= 0) {
|
||||
Swal.showValidationMessage(`Please enter a valid number`);
|
||||
}
|
||||
return { customMonth }
|
||||
const customMonthUnit = $("#inputCustomMonthUnit").val();
|
||||
return { customMonth, customMonthUnit }
|
||||
},
|
||||
}).then(function (result) {
|
||||
if (result.isConfirmed) {
|
||||
customMonthInterval = result.value.customMonth;
|
||||
$("#taxRecurringMonth > option[value='Other']").text(`Other: ${result.value.customMonth}`);
|
||||
customMonthIntervalUnit = result.value.customMonthUnit;
|
||||
$("#taxRecurringMonth > option[value='Other']").text(`Other: ${result.value.customMonth} ${result.value.customMonthUnit}`);
|
||||
} else {
|
||||
$("#taxRecurringMonth").val(getTaxRecordModelData().monthInterval);
|
||||
}
|
||||
@ -172,6 +178,7 @@ function getAndValidateTaxRecordValues() {
|
||||
isRecurring: taxIsRecurring,
|
||||
recurringInterval: taxRecurringMonth,
|
||||
customMonthInterval: customMonthInterval,
|
||||
customMonthIntervalUnit: customMonthIntervalUnit,
|
||||
tags: taxTags,
|
||||
files: uploadedFiles,
|
||||
addReminderRecord: addReminderRecord,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user