From 4357c2484a21a46a9df6a5a7b2636585a2139f3f Mon Sep 17 00:00:00 2001 From: Frede Hundewadt Date: Thu, 13 Apr 2023 18:40:02 +0200 Subject: [PATCH] WIP: EAN --- Wonky.Client/Models/Ean13Validator.cs | 57 +++++++++ .../Pages/AdvisorActivityCreatePage.razor.cs | 16 ++- .../Pages/AdvisorCustomerViewEditPage.razor | 51 ++++++++- Wonky.Client/wwwroot/appsettings.json | 2 +- Wonky.Client/wwwroot/css/app.css | 108 ++++++++++++++++++ Wonky.Client/wwwroot/index.html | 1 + Wonky.Entity/DTO/CompanyDto.cs | 10 ++ 7 files changed, 234 insertions(+), 11 deletions(-) create mode 100644 Wonky.Client/Models/Ean13Validator.cs diff --git a/Wonky.Client/Models/Ean13Validator.cs b/Wonky.Client/Models/Ean13Validator.cs new file mode 100644 index 00000000..d999fc0b --- /dev/null +++ b/Wonky.Client/Models/Ean13Validator.cs @@ -0,0 +1,57 @@ +namespace Wonky.Client.Models; + +public class Ean13Validator +{ + private const int Size = 12; + + public static bool Validate(string number) + { + if (number.Length != Size + 1) + return false; + return number == ParsedNumber(number[..12]); + } + + private static string Ean13(int[]? firstDigits) + { + var summedProduct = 0; + var randomDigits = new Random(); + bool isNull; + if (firstDigits == null) + { + firstDigits = new int[Size]; + isNull = true; + } + else + isNull = false; + for (var idx = 0; idx < Size; idx++) + { + var alt = idx % 2 == 0 ? 1 : 3; + int digit; + if (isNull) + { + digit = randomDigits.Next(10); + firstDigits[idx] = digit; + } + else + digit = firstDigits[idx]; + summedProduct += digit * alt; + } + var checkDigit = 10 - summedProduct % 10; + if (checkDigit == 10) + checkDigit = 0; + return string.Join("", firstDigits) + checkDigit; + } + + private static string ParsedNumber(string number) + { + var firstDigits = new int[Size]; + if (number.Length != Size | !long.TryParse(number, out _)) + return null; + for (var idx = 0; idx < Size; idx++) + { + var digit = int.Parse(number[idx].ToString()); + firstDigits[idx] = digit; + } + return Ean13(firstDigits); + } +} \ No newline at end of file diff --git a/Wonky.Client/Pages/AdvisorActivityCreatePage.razor.cs b/Wonky.Client/Pages/AdvisorActivityCreatePage.razor.cs index ee186637..7147f244 100644 --- a/Wonky.Client/Pages/AdvisorActivityCreatePage.razor.cs +++ b/Wonky.Client/Pages/AdvisorActivityCreatePage.razor.cs @@ -163,13 +163,16 @@ public partial class AdvisorActivityCreatePage : IDisposable Activity.DlvAddress2 = Company.Address2; Activity.DlvZipCode = Company.ZipCode; Activity.DlvCity = Company.City; + // Initialize date variable Logger.LogDebug("AdvisorActivityCreatePage => DateTime parser => {}", UserPreference.WorkDate); SelectedDate = string.IsNullOrWhiteSpace(UserPreference.WorkDate) ? DateTime.Now : DateTime.Parse(UserPreference.WorkDate); + // raise flag if report is closed ReportClosed = await ReportRepo.ReportExist($"{SelectedDate:yyyy-MM-dd}"); + // Ask for confirmation of date Logger.LogDebug("Preferences.DateConfirmed => {}", UserPreference.DateConfirmed); if (!UserPreference.DateConfirmed) @@ -299,6 +302,7 @@ public partial class AdvisorActivityCreatePage : IDisposable // ############################################################# // callbacks + // pricelist callback private async Task PriceListCallback(SelectedSku sku) { // get selected item @@ -311,7 +315,7 @@ public partial class AdvisorActivityCreatePage : IDisposable StateHasChanged(); } - + // price history callback private void PriceHistoryCallback(decimal price) { if (price == 0) @@ -320,7 +324,7 @@ public partial class AdvisorActivityCreatePage : IDisposable StateHasChanged(); } - + // inventory callback private void OnInventoryCallback(DraftItem item) { Activity.ActivityStatusEnum = "order"; @@ -329,7 +333,7 @@ public partial class AdvisorActivityCreatePage : IDisposable StateHasChanged(); } - + // confirm product check callback private async Task ConfirmProductCheckCallback() { ConfirmationCheckOverlay.Hide(); @@ -338,11 +342,10 @@ public partial class AdvisorActivityCreatePage : IDisposable { item.Check = false; } - await Storage.SetItemAsync($"{CompanyId}-products", CheckList); } - + // workdate confirm callback private async Task WorkDateConfirmCallback() { await PreferenceService.SetDateConfirmed(true); @@ -351,7 +354,7 @@ public partial class AdvisorActivityCreatePage : IDisposable StateHasChanged(); } - + // workdate changed callback private async Task WorkDateChangedCallback(string workDate) { ReportClosed = await ReportRepo.ReportExist(workDate); @@ -362,6 +365,7 @@ public partial class AdvisorActivityCreatePage : IDisposable // ################################################################################################ // fetch invoices for customer + // save invoices to storage private async Task FetchCompanyInvoices() { // no need to do for kanvas entry diff --git a/Wonky.Client/Pages/AdvisorCustomerViewEditPage.razor b/Wonky.Client/Pages/AdvisorCustomerViewEditPage.razor index eddf638e..49e121a0 100644 --- a/Wonky.Client/Pages/AdvisorCustomerViewEditPage.razor +++ b/Wonky.Client/Pages/AdvisorCustomerViewEditPage.razor @@ -21,6 +21,27 @@ @page "/advisor/customers/{CompanyId}" Kundekort for @Company.Name +@* +
+
+
+

Green LED

+
+
+
+

Yellow LED

+
+
+
+

Red LED

+
+
+
+

Blue LED

+
+
+*@ + @if (!string.IsNullOrWhiteSpace(Company.Account)) { @if (!string.IsNullOrWhiteSpace(Company.Blocked)) @@ -95,8 +116,30 @@ @if (!Kanvas) { -
@* ---- placeholder --- *@
- + @if (AppInfo.Value.Rc) + { + +
+ + + + + + @* *@ +
+
+
+
+
+
+ } + else + { +
+ @* placeholder *@ +
+ } + @* Enable edit/save *@
@@ -110,7 +153,7 @@
@* vat number*@ - +
@@ -122,7 +165,7 @@
@* Enable edit/save vatnumber *@
- +
@* vat lookup *@
diff --git a/Wonky.Client/wwwroot/appsettings.json b/Wonky.Client/wwwroot/appsettings.json index 49110f38..a0f287f8 100644 --- a/Wonky.Client/wwwroot/appsettings.json +++ b/Wonky.Client/wwwroot/appsettings.json @@ -1,7 +1,7 @@ { "appInfo": { "name": "Wonky Online", - "version": "0.135.1", + "version": "0.135.4", "rc": true, "sandBox": false, "image": "grumpy-coder.png" diff --git a/Wonky.Client/wwwroot/css/app.css b/Wonky.Client/wwwroot/css/app.css index 87c8016c..dffd0ce8 100644 --- a/Wonky.Client/wwwroot/css/app.css +++ b/Wonky.Client/wwwroot/css/app.css @@ -103,6 +103,114 @@ a, .btn-link { /* end state elements */ +/* led elements */ +.led-box { + height: 24px; + width: 24px; + margin: auto; + float: left; +} + +.led-red { + margin: 5px; + width: 24px; + height: 24px; + background-color: #F00; + border-radius: 50%; + box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #441313 0 -1px 9px, rgba(255, 0, 0, 0.5) 0 2px 12px; + -webkit-animation: blinkRed 0.5s infinite; + -moz-animation: blinkRed 0.5s infinite; + -ms-animation: blinkRed 0.5s infinite; + -o-animation: blinkRed 0.5s infinite; + animation: blinkRed 0.5s infinite; + animation-iteration-count: infinite; +} + +@-webkit-keyframes blinkRed { + from { background-color: #F00; } + 50% { background-color: #A00; box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #441313 0 -1px 9px, rgba(255, 0, 0, 0.5) 0 2px 0;} + to { background-color: #F00; } +} +@-moz-keyframes blinkRed { + from { background-color: #F00; } + 50% { background-color: #A00; box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #441313 0 -1px 9px, rgba(255, 0, 0, 0.5) 0 2px 0;} + to { background-color: #F00; } +} +@-ms-keyframes blinkRed { + from { background-color: #F00; } + 50% { background-color: #A00; box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #441313 0 -1px 9px, rgba(255, 0, 0, 0.5) 0 2px 0;} + to { background-color: #F00; } +} +@-o-keyframes blinkRed { + from { background-color: #F00; } + 50% { background-color: #A00; box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #441313 0 -1px 9px, rgba(255, 0, 0, 0.5) 0 2px 0;} + to { background-color: #F00; } +} +@keyframes blinkRed { + from { background-color: #F00; } + 50% { background-color: #A00; box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #441313 0 -1px 9px, rgba(255, 0, 0, 0.5) 0 2px 0;} + to { background-color: #F00; } +} + +.led-yellow { + margin: 0 auto; + width: 24px; + height: 24px; + background-color: #FF0; + border-radius: 50%; + box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #808002 0 -1px 9px, #FF0 0 2px 12px; + -webkit-animation: blinkYellow 1s infinite; + -moz-animation: blinkYellow 1s infinite; + -ms-animation: blinkYellow 1s infinite; + -o-animation: blinkYellow 1s infinite; + animation: blinkYellow 1s infinite; +} + +@-webkit-keyframes blinkYellow { + from { background-color: #FF0; } + 50% { background-color: #AA0; box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #808002 0 -1px 9px, #FF0 0 2px 0; } + to { background-color: #FF0; } +} +@-moz-keyframes blinkYellow { + from { background-color: #FF0; } + 50% { background-color: #AA0; box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #808002 0 -1px 9px, #FF0 0 2px 0; } + to { background-color: #FF0; } +} +@-ms-keyframes blinkYellow { + from { background-color: #FF0; } + 50% { background-color: #AA0; box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #808002 0 -1px 9px, #FF0 0 2px 0; } + to { background-color: #FF0; } +} +@-o-keyframes blinkYellow { + from { background-color: #FF0; } + 50% { background-color: #AA0; box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #808002 0 -1px 9px, #FF0 0 2px 0; } + to { background-color: #FF0; } +} +@keyframes blinkYellow { + from { background-color: #FF0; } + 50% { background-color: #AA0; box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #808002 0 -1px 9px, #FF0 0 2px 0; } + to { background-color: #FF0; } +} + +.led-green { + margin: 0 auto; + width: 24px; + height: 24px; + background-color: #ABFF00; + border-radius: 50%; + box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #304701 0 -1px 9px, #89FF00 0 2px 12px; +} + +.led-blue { + margin: 0 auto; + width: 24px; + height: 24px; + background-color: #24E0FF; + border-radius: 50%; + box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #006 0 -1px 9px, #3F8CFF 0 2px 14px; +} + +/* end led elements */ /*#blazor-error-ui {*/ /* background: lightyellow;*/ diff --git a/Wonky.Client/wwwroot/index.html b/Wonky.Client/wwwroot/index.html index 9374b8fd..3700645d 100644 --- a/Wonky.Client/wwwroot/index.html +++ b/Wonky.Client/wwwroot/index.html @@ -18,6 +18,7 @@ + diff --git a/Wonky.Entity/DTO/CompanyDto.cs b/Wonky.Entity/DTO/CompanyDto.cs index 196cd4dc..57954a81 100644 --- a/Wonky.Entity/DTO/CompanyDto.cs +++ b/Wonky.Entity/DTO/CompanyDto.cs @@ -61,6 +61,11 @@ public class CompanyDto [MaxLength(30, ErrorMessage = "Du kan højst bruge 30 tegn")] public string City { get; set; } = ""; + /// + /// Customer Group + /// + public string Segment { get; set; } = ""; + /// /// Company Id /// @@ -75,6 +80,11 @@ public class CompanyDto /// Crm note /// public string CrmNotes { get; set; } = ""; + + /// + /// Ean number + /// + public string EanNumber { get; set; } = ""; /// /// Office email