add purchase and sold price

This commit is contained in:
DESKTOP-GENO133\IvanPlex
2024-03-27 08:21:02 -06:00
parent 345eb65c3a
commit a92d422972
6 changed files with 55 additions and 11 deletions

View File

@@ -1568,9 +1568,7 @@ namespace CarCareTracker.Controllers
List<ReminderRecordViewModel> results = _reminderHelper.GetReminderRecordViewModels(reminders, currentMileage, dateCompare);
return results;
}
[TypeFilter(typeof(CollaboratorFilter))]
[HttpGet]
public IActionResult GetVehicleHaveUrgentOrPastDueReminders(int vehicleId)
private bool GetAndUpdateVehicleUrgentOrPastDueReminders(int vehicleId)
{
var result = GetRemindersAndUrgency(vehicleId, DateTime.Now);
//check if user wants auto-refresh past-due reminders
@@ -1597,9 +1595,16 @@ namespace CarCareTracker.Controllers
var pastDueAndUrgentReminders = result.Where(x => x.Urgency == ReminderUrgency.VeryUrgent || x.Urgency == ReminderUrgency.PastDue);
if (pastDueAndUrgentReminders.Any())
{
return Json(true);
return true;
}
return Json(false);
return false;
}
[TypeFilter(typeof(CollaboratorFilter))]
[HttpGet]
public IActionResult GetVehicleHaveUrgentOrPastDueReminders(int vehicleId)
{
var result = GetAndUpdateVehicleUrgentOrPastDueReminders(vehicleId);
return Json(result);
}
[TypeFilter(typeof(CollaboratorFilter))]
[HttpGet]

View File

@@ -10,6 +10,8 @@
public string LicensePlate { get; set; }
public string PurchaseDate { get; set; }
public string SoldDate { get; set; }
public decimal PurchasePrice { get; set; }
public decimal SoldPrice { get; set; }
public bool IsElectric { get; set; } = false;
public bool UseHours { get; set; } = false;
public List<ExtraField> ExtraFields { get; set; } = new List<ExtraField>();

View File

@@ -46,10 +46,6 @@
}
</div>
<div class="col-12 col-md-6">
<label for="inputPurchaseDate">@translator.Translate(userLanguage, "Purchased Date(optional)")</label>
<input type="text" id="inputPurchaseDate" class="form-control" placeholder="@translator.Translate(userLanguage, "Purchased Date")" value="@Model.PurchaseDate">
<label for="inputSoldDate">@translator.Translate(userLanguage, "Sold Date(optional)")</label>
<input type="text" id="inputSoldDate" class="form-control" placeholder="@translator.Translate(userLanguage, "Sold Date")" value="@Model.SoldDate">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" role="switch" id="inputIsElectric" checked="@Model.IsElectric">
<label class="form-check-label" for="inputIsElectric">@translator.Translate(userLanguage, "Electric Vehicle")</label>
@@ -70,6 +66,25 @@
<input type="text" id="inputOdometerDifference" class="form-control" placeholder="@translator.Translate(userLanguage, "Odometer Difference")" value="@Model.OdometerDifference">
</div>
</div>
<div class="accordion accordion-flush" id="vehicleModalAccordion">
<div class="accordion-item">
<div class="accordion-header">
<button class="accordion-button skinny collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#collapsePurchaseInfo">
@translator.Translate(userLanguage, "Purchase/Sold Information(optional)")
</button>
</div>
<div id="collapsePurchaseInfo" class="accordion-collapse collapse" data-bs-parent="#vehicleModalAccordion">
<label for="inputPurchaseDate">@translator.Translate(userLanguage, "Purchased Date(optional)")</label>
<input type="text" id="inputPurchaseDate" class="form-control" placeholder="@translator.Translate(userLanguage, "Purchased Date")" value="@Model.PurchaseDate">
<label for="inputSoldDate">@translator.Translate(userLanguage, "Sold Date(optional)")</label>
<input type="text" id="inputSoldDate" class="form-control" placeholder="@translator.Translate(userLanguage, "Sold Date")" value="@Model.SoldDate">
<label for="inputPurchasePrice">@translator.Translate(userLanguage, "Purchased Price(optional)")</label>
<input type="text" inputmode="decimal" id="inputPurchasePrice" class="form-control" placeholder="@translator.Translate(userLanguage, "Purchased Price")" value="@(Model.PurchasePrice == default ? "" : Model.PurchasePrice)">
<label for="inputSoldPrice">@translator.Translate(userLanguage, "Sold Price(optional)")</label>
<input type="text" inputmode="decimal" id="inputSoldPrice" class="form-control" placeholder="@translator.Translate(userLanguage, "Sold Price")" value="@(Model.SoldPrice == default ? "" : Model.SoldPrice)">
</div>
</div>
</div>
<label for="inputTag">@translator.Translate(userLanguage, "Tags(optional)")</label>
<select multiple class="form-select" id="inputTag">
@foreach (string tag in Model.Tags)

View File

@@ -374,3 +374,7 @@ input[type="file"] {
.copyable{
cursor: pointer;
}
.accordion-button.skinny {
padding: 0.438rem 0rem !important;
background-color: inherit !important;
}

File diff suppressed because one or more lines are too long

View File

@@ -45,6 +45,8 @@ function saveVehicle(isEdit) {
var vehicleHasOdometerAdjustment = $("#inputHasOdometerAdjustment").is(':checked');
var vehicleOdometerMultiplier = $("#inputOdometerMultiplier").val();
var vehicleOdometerDifference = parseInt(globalParseFloat($("#inputOdometerDifference").val())).toString();
var vehiclePurchasePrice = $("#inputPurchasePrice").val();
var vehicleSoldPrice = $("#inputSoldPrice").val();
var extraFields = getAndValidateExtraFields(true);
//validate
var hasError = false;
@@ -92,6 +94,20 @@ function saveVehicle(isEdit) {
$("#inputOdometerDifference").removeClass("is-invalid");
}
}
if (vehiclePurchasePrice.trim() != '' && !isValidMoney(vehiclePurchasePrice)) {
hasError = true;
$("#inputPurchasePrice").addClass("is-invalid");
$("#collapsePurchaseInfo").collapse('show');
} else {
$("#inputPurchasePrice").removeClass("is-invalid");
}
if (vehicleSoldPrice.trim() != '' && !isValidMoney(vehicleSoldPrice)) {
hasError = true;
$("#inputSoldPrice").addClass("is-invalid");
$("#collapsePurchaseInfo").collapse('show');
} else {
$("#inputSoldPrice").removeClass("is-invalid");
}
if (hasError) {
return;
}
@@ -110,7 +126,9 @@ function saveVehicle(isEdit) {
soldDate: vehicleSoldDate,
hasOdometerAdjustment: vehicleHasOdometerAdjustment,
odometerMultiplier: vehicleOdometerMultiplier,
odometerDifference: vehicleOdometerDifference
odometerDifference: vehicleOdometerDifference,
purchasePrice: vehiclePurchasePrice,
soldPrice: vehicleSoldPrice
}, function (data) {
if (data) {
if (!isEdit) {