Tára, error fix
This commit is contained in:
parent
13a1eb204c
commit
76f0994d9f
|
|
@ -216,9 +216,9 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Areas.Admin.Controllers
|
|||
}
|
||||
|
||||
string analysisPrompt = "Extract the document identification number from this document, determine the type of the " +
|
||||
"document from the available list, and return them as JSON: documentNumber, documentType. " +
|
||||
$"Available filetypes: {nameof(DocumentType.Invoice)}, {nameof(DocumentType.ShippingDocument)} , {nameof(DocumentType.OrderConfirmation)}, {nameof(DocumentType.Unknown)}" +
|
||||
"If you can't find information of any of these, return null value for that field.";
|
||||
"document from the available list, and return them as JSON: documentNumber, documentType. " +
|
||||
$"Available filetypes: {nameof(DocumentType.Invoice)}, {nameof(DocumentType.ShippingDocument)} , {nameof(DocumentType.OrderConfirmation)}, {nameof(DocumentType.Unknown)}" +
|
||||
"If you can't find information of any of these, return null value for that field.";
|
||||
|
||||
//here I can start preparing the file entity
|
||||
var metaAnalyzis = await _aiCalculationService.GetOpenAIPDFAnalysisFromText(pdfText.ToString(), analysisPrompt);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Components
|
|||
public class ProductAttributesViewComponent : NopViewComponent
|
||||
{
|
||||
private const string NET_WEIGHT_KEY = nameof(IMeasuringAttributeValues.NetWeight);
|
||||
private const string GROSS_WEIGHT_KEY = nameof(IMeasuringAttributeValues.GrossWeight);
|
||||
private const string TARE_KEY = nameof(ITare.Tare);
|
||||
private const string IS_MEASURABLE_KEY = nameof(IMeasuringAttributeValues.IsMeasurable);
|
||||
|
||||
private readonly IGenericAttributeService _genericAttributeService;
|
||||
|
|
@ -61,10 +61,13 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Components
|
|||
.GetAttributeAsync<bool>(dbProduct, IS_MEASURABLE_KEY, storeScope.Id);
|
||||
|
||||
model.NetWeight = await _genericAttributeService
|
||||
.GetAttributeAsync<decimal?>(dbProduct, NET_WEIGHT_KEY, storeScope.Id);
|
||||
.GetAttributeAsync<double>(dbProduct, NET_WEIGHT_KEY, storeScope.Id);
|
||||
|
||||
model.IncomingQuantity = await _genericAttributeService
|
||||
.GetAttributeAsync<int?>(dbProduct, "IncomingQuantity", storeScope.Id);
|
||||
|
||||
model.Tare = await _genericAttributeService
|
||||
.GetAttributeAsync<double>(dbProduct, TARE_KEY, storeScope.Id);
|
||||
}
|
||||
|
||||
return View("~/Plugins/Misc.FruitBankPlugin/Views/ProductAttributes.cshtml", model);
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ using Nop.Plugin.Misc.FruitBankPlugin.Domains.DataLayer;
|
|||
using Nop.Plugin.Misc.FruitBankPlugin.Services;
|
||||
using Nop.Services.Common;
|
||||
using Nop.Services.Events;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Domains.EventConsumers;
|
||||
|
||||
|
|
@ -64,23 +65,24 @@ public class FruitBankEventConsumer(IHttpContextAccessor httpContextAccessor, Fr
|
|||
if (form == null || !form.Any())
|
||||
return;
|
||||
|
||||
var isMeasurable = form["IsMeasurable"].ToString().Contains("true");
|
||||
var store = await storeContext.GetCurrentStoreAsync();
|
||||
|
||||
// Save IsMeasurable
|
||||
if (form.ContainsKey("IsMeasurable"))
|
||||
if (form.ContainsKey(nameof(IMeasuringAttributeValues.IsMeasurable)))
|
||||
{
|
||||
await genericAttributeService.SaveAttributeAsync(product, "IsMeasurable", isMeasurable);
|
||||
var isMeasurable = form[nameof(IMeasuringAttributeValues.IsMeasurable)].ToString().Contains("true");
|
||||
await genericAttributeService.SaveAttributeAsync(product, nameof(IMeasuringAttributeValues.IsMeasurable), isMeasurable, store.Id);
|
||||
//Akkor ez kell? - Á.
|
||||
//await fruitBankAttributeService.InsertOrUpdateMeasuringAttributeValuesAsync<Product>(product.Id, 0, 0, isMeasurable, false);
|
||||
}
|
||||
|
||||
// Save NetWeight
|
||||
if (form.ContainsKey("NetWeight"))
|
||||
if (form.ContainsKey(nameof(IMeasuringAttributeValues.NetWeight)))
|
||||
{
|
||||
var netWeightStr = form["NetWeight"].ToString();
|
||||
if (!string.IsNullOrWhiteSpace(netWeightStr) && decimal.TryParse(netWeightStr, out var netWeight))
|
||||
var netWeightStr = form[nameof(IMeasuringAttributeValues.NetWeight)].ToString();
|
||||
if (!string.IsNullOrWhiteSpace(netWeightStr) && double.TryParse(netWeightStr, NumberStyles.Float, CultureInfo.InvariantCulture, out var netWeight))
|
||||
{
|
||||
await genericAttributeService.SaveAttributeAsync(product, "NetWeight", netWeight);
|
||||
await genericAttributeService.SaveAttributeAsync(product, nameof(IMeasuringAttributeValues.NetWeight), netWeight, store.Id);
|
||||
//Akkor ez kell? - Á.
|
||||
//await fruitBankAttributeService.InsertOrUpdateMeasuringAttributeValuesAsync<Product>(product.Id, 0, 0, , false);
|
||||
}
|
||||
|
|
@ -92,7 +94,17 @@ public class FruitBankEventConsumer(IHttpContextAccessor httpContextAccessor, Fr
|
|||
var incomingQtyStr = form["IncomingQuantity"].ToString();
|
||||
if (!string.IsNullOrWhiteSpace(incomingQtyStr) && int.TryParse(incomingQtyStr, out var incomingQuantity))
|
||||
{
|
||||
await genericAttributeService.SaveAttributeAsync(product, "IncomingQuantity", incomingQuantity);
|
||||
await genericAttributeService.SaveAttributeAsync(product, "IncomingQuantity", incomingQuantity, store.Id);
|
||||
}
|
||||
}
|
||||
|
||||
if (form.ContainsKey(nameof(ITare.Tare)))
|
||||
{
|
||||
var tareStr = form[nameof(ITare.Tare)].ToString();
|
||||
if (!string.IsNullOrWhiteSpace(tareStr) &&
|
||||
double.TryParse(tareStr, NumberStyles.Float, CultureInfo.InvariantCulture, out var tare))
|
||||
{
|
||||
await genericAttributeService.SaveAttributeAsync(product, nameof(ITare.Tare), tare, store.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
using Nop.Web.Framework.Models;
|
||||
using FruitBank.Common.Interfaces;
|
||||
using Nop.Web.Framework.Models;
|
||||
using Nop.Web.Framework.Mvc.ModelBinding;
|
||||
|
||||
namespace Nop.Plugin.Misc.FruitBankPlugin.Models
|
||||
{
|
||||
public record ProductAttributesModel : BaseNopModel
|
||||
public record ProductAttributesModel : BaseNopModel, IMeasurable, IMeasuringWeights, ITare
|
||||
{
|
||||
public int ProductId { get; set; }
|
||||
|
||||
|
|
@ -11,9 +12,15 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Models
|
|||
public bool IsMeasurable { get; set; }
|
||||
|
||||
[NopResourceDisplayName("Plugins.YourCompany.ProductAttributes.Fields.NetWeight")]
|
||||
public decimal? NetWeight { get; set; }
|
||||
public double NetWeight { get; set; }
|
||||
|
||||
[NopResourceDisplayName("Plugins.YourCompany.ProductAttributes.Fields.NetWeight")]
|
||||
public double GrossWeight { get; set; }
|
||||
|
||||
[NopResourceDisplayName("Plugins.YourCompany.ProductAttributes.Fields.IncomingQuantity")]
|
||||
public int? IncomingQuantity { get; set; }
|
||||
|
||||
[NopResourceDisplayName("Plugins.YourCompany.ProductAttributes.Fields.Tare")]
|
||||
public double Tare { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -37,5 +37,15 @@
|
|||
<span asp-validation-for="IncomingQuantity"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<div class="col-md-3">
|
||||
<nop-label asp-for="Tare" />
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
<nop-editor asp-for="Tare" />
|
||||
<span asp-validation-for="Tare"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Loading…
Reference in New Issue