Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .tests/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .access_tests import AccessTests
from .application_tests import ApplicationTests
from .category_tests import CategoryTests
from .item_tests import ItemTests
from .order_tests import OrderTests
from .pricing_tests import PricingTests
from .product_tests import ProductTests
Expand Down
36 changes: 36 additions & 0 deletions .tests/tests/item_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from utils.test_base import TestBase
from utils.auth import BearerAuth
from .audit_tests_helpers import AuditTestHelpers


class ItemTests(TestBase):
def setUp(self):
super().setUp()
self.set_authentication(BearerAuth("09876543210987654321"))
self.audit = AuditTestHelpers(self, 1, 3)

def test_get_items_sold(self):
response = self.get("items-sold")
self.expect(response.status_code).to.be.equal_to(200)

categories = response.json()
self.expect(categories).to.be.a(list)._and._not.empty()

for category in categories:
self.expect(category).to.have.an_item("name").of.type(str)
items = self.expect(category).to.have.an_item("items").value

self.expect(items).to.be.a(list)._and._not.empty()

for item in items:
self.expect(item).to.have.an_item("id").of.type(int)
self.expect(item).to.have.an_item("name").of.type(str)
self.expect(item).to.have.an_item("memberPrice").that.is_.a_number()
self.expect(item).to.have.an_item(
"nonMemberPrice"
).that.is_.none_or.a_number()
self.expect(item).to.have.an_item("isAvailable").of.type(bool)
self.expect(item).to.have.an_item("availableStock").that.is_.none_or.an(
int
)
self.expect(item).to.have.an_item("isBundle")
9 changes: 6 additions & 3 deletions .tests/utils/expectations.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,18 @@ def a(self, type):

def a_number(self):
is_a_number = isinstance(self.value, int) or isinstance(self.value, float)
is_a_number_or_none = is_a_number or self.value is None
if self.negation:
if self.nullable:
self.test_case.assertFalse(is_a_number_or_none, f"{self.value} is None")
self.test_case.assertFalse(is_a_number, f"{self.value} is a number")
self.test_case.assertFalse(self.value is None, f"{self.value} is None")
else:
self.test_case.assertFalse(is_a_number, f"{self.value} is a number")
else:
if self.nullable:
self.test_case.assertFalse(self.value is None, f"{self.value} is None")
self.test_case.assertTrue(
is_a_number or self.value is None,
f"{self.value} isn't a number and isn't None",
)
else:
self.test_case.assertTrue(is_a_number, f"{self.value} isn't a number")

Expand Down
8 changes: 0 additions & 8 deletions Core/Checkout/ItemSellingPrice.cs

This file was deleted.

41 changes: 0 additions & 41 deletions Core/Checkout/ItemSold.cs

This file was deleted.

30 changes: 0 additions & 30 deletions Core/Checkout/ItemsSoldCategory.cs

This file was deleted.

2 changes: 1 addition & 1 deletion Core/Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<ItemGroup>
<PackageReference Include="Humanizer.Core.fr" Version="2.14.1" />
<PackageReference Include="Konscious.Security.Cryptography.Argon2" Version="1.3.0" />
<PackageReference Include="Magick.NET-Q16-AnyCPU" Version="13.4.0" />
<PackageReference Include="Magick.NET-Q16-AnyCPU" Version="14.8.2" />
<PackageReference Include="Multiflag" Version="2.0.0" />
<PackageReference Include="Stubble.Core" Version="1.10.8" />
</ItemGroup>
Expand Down
49 changes: 49 additions & 0 deletions Core/Stocks/Item.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using KiwiQuery.Mapped;

namespace GalliumPlus.Core.Stocks;

/// <summary>
///
/// </summary>
public class Item
{
[PrimaryKey]
private int id;
private string name;
private bool isBundle;
private Availability isAvailable;
private int? currentStock;
private Category category;
private Category? group;
private string? picture;

public int Id => this.id;
public string Name => this.name;
public bool IsBundle => this.isBundle;
public Availability IsAvailable => this.isAvailable;
public int? CurrentStock => this.currentStock;
public Category Category => this.category;
public Category? Group => this.group;
public string? Picture => this.picture;

public Item(
int id,
string name,
bool isBundle,
Availability isAvailable,
int? currentStock,
Category category,
Category? group,
string? picture
)
{
this.id = id;
this.name = name;
this.isBundle = isBundle;
this.isAvailable = isAvailable;
this.currentStock = currentStock;
this.category = category;
this.group = group;
this.picture = picture;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using FluentMigrator;

namespace GalliumPlus.Data.MariaDb.Migrations.v1_04_00;

// ReSharper disable once InconsistentNaming
// ReSharper disable once UnusedType.Global
[Migration(1_04_00_001)]
public class AlterColumn_Client_allowed : Migration
{
public override void Up()
{
this.Alter.Table("Client").AlterColumn("allowed").AsInt32().NotNullable();
}

public override void Down()
{
this.Alter.Table("Client").AlterColumn("allowed").AsInt32().Nullable();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using FluentMigrator;

namespace GalliumPlus.Data.MariaDb.Migrations.v1_04_00;

// ReSharper disable once InconsistentNaming
// ReSharper disable once UnusedType.Global
[Migration(1_04_00_002)]
public class AlterColumn_Client_granted : Migration
{
public override void Up()
{
this.Alter.Table("Client").AlterColumn("granted").AsInt32().NotNullable();
}

public override void Down()
{
this.Alter.Table("Client").AlterColumn("granted").AsInt32().Nullable();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using FluentMigrator;

namespace GalliumPlus.Data.MariaDb.Migrations.v1_04_00;

// ReSharper disable once InconsistentNaming
// ReSharper disable once UnusedType.Global
[Migration(1_04_00_003)]
public class AlterColumn_Item_currentStock : Migration
{
public override void Up()
{
this.Alter.Table("Item").AlterColumn("currentStock").AsInt32().Nullable();
}

public override void Down()
{
this.Alter.Table("Item").AlterColumn("currentStock").AsInt32().NotNullable();
}
}
2 changes: 1 addition & 1 deletion KiwiQuery
Submodule KiwiQuery updated 41 files
+38 −0 KiwiQuery.Mapped/BelongsToAttribute.cs
+9 −3 KiwiQuery.Mapped/Commands/MappedDeleteCommand.cs
+4 −4 KiwiQuery.Mapped/Commands/MappedInsertCommand.cs
+1 −1 KiwiQuery.Mapped/Commands/MappedSelectCommand.cs
+6 −3 KiwiQuery.Mapped/Commands/MappedUpdateCommand.cs
+154 −0 KiwiQuery.Mapped/Commands/Table.cs
+1 −1 KiwiQuery.Mapped/Commands/UnbufferedReader.cs
+1 −1 KiwiQuery.Mapped/Commands/ValueOverloads/IValueOverload.cs
+1 −1 KiwiQuery.Mapped/Commands/ValueOverloads/ObjectOverload.cs
+1 −1 KiwiQuery.Mapped/Commands/ValueOverloads/SubQueryOverload.cs
+1 −1 KiwiQuery.Mapped/Commands/ValueOverloads/ValueOverload.cs
+15 −40 KiwiQuery.Mapped/ExtendedSchema.cs
+9 −14 KiwiQuery.Mapped/Extension/SharedMappers.cs
+38 −0 KiwiQuery.Mapped/HasManyAttribute.cs
+2 −2 KiwiQuery.Mapped/Mappers/Builtin/ConverterMapper.cs
+2 −2 KiwiQuery.Mapped/Mappers/Builtin/EnumMapper.cs
+2 −2 KiwiQuery.Mapped/Mappers/Builtin/NullableMapper.cs
+0 −28 KiwiQuery.Mapped/Mappers/Fields/DefaultMapperResolver.cs
+52 −0 KiwiQuery.Mapped/Mappers/Fields/FieldMapperCollection.cs
+2 −1 KiwiQuery.Mapped/Mappers/Fields/IFieldMapperCollection.cs
+1 −1 KiwiQuery.Mapped/Mappers/Fields/MappedField.cs
+29 −0 KiwiQuery.Mapped/Mappers/GenericMapper.cs
+60 −33 KiwiQuery.Mapped/Mappers/GenericMapperFactory.cs
+17 −0 KiwiQuery.Mapped/Mappers/MappersRegistry.cs
+41 −0 KiwiQuery.Mapped/Relationships/BelongsTo.cs
+36 −0 KiwiQuery.Mapped/Relationships/BelongsToFactory.cs
+41 −0 KiwiQuery.Mapped/Relationships/HasMany.cs
+36 −0 KiwiQuery.Mapped/Relationships/HasManyFactory.cs
+1 −1 KiwiQuery.Mapped/Relationships/HasOneFactory.cs
+1 −3 KiwiQuery.Mapped/Relationships/IRefValueFactory.cs
+3 −5 KiwiQuery.Mapped/Relationships/Ref.cs
+4 −4 KiwiQuery.Mapped/SchemaExtensions.cs
+2 −2 KiwiQuery.Mapped/Table.cs
+0 −6 KiwiQuery/Schema.cs
+14 −9 KiwiQuery/SelectCommand.cs
+35 −0 Tests/Mapped/Model/Comment.cs
+107 −3 Tests/Mapped/Model/Phone.cs
+85 −0 Tests/Mapped/Model/Post.cs
+109 −0 Tests/Mapped/Model/User.cs
+51 −0 Tests/Mapped/Relationships/JustHasMany.cs
+63 −97 Tests/Mapped/Relationships/OneToOne.cs
17 changes: 17 additions & 0 deletions WebService/Controllers/ItemController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using GalliumPlus.WebService.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace GalliumPlus.WebService.Controllers;

[Route("v1/items")]
[Authorize]
[ApiController]
public class ItemController(ItemService itemService) : GalliumController
{
[HttpGet("/v1/items-sold")]
public IActionResult GetItemsSold()
{
return this.Json(itemService.GetItemsSold());
}
}
59 changes: 59 additions & 0 deletions WebService/Dto/Checkout/ItemSold.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using GalliumPlus.Core.Stocks;

namespace GalliumPlus.WebService.Dto.Checkout;

/// <summary>
/// Un article disponible sur la caisse.
/// </summary>
public class ItemSold
{
/// <summary>
/// L'identifiant de l'article.
/// </summary>
public int Id { get; }

/// <summary>
/// La désignation de l'article.
/// </summary>
public string Name { get; }

/// <summary>
/// Le prix adhérent en euros.
/// </summary>
public decimal MemberPrice { get; }

/// <summary>
/// Le prix non-adhérent en euros. Une valeur <c>null</c> indique une
/// exclusivité pour les adhérents.
/// </summary>
public decimal? NonMemberPrice { get; }

/// <summary>
/// Indique si l'article peut être vendu ou non. Une valeur <c>false</c>
/// signifie que l'article est en rupture de stock et qu'il ne peut pas
/// être acheté.
/// </summary>
public bool IsAvailable { get; }

/// <summary>
/// La quantité restante disponible. Cette valeur peut être <c>null</c>
/// pour indiquer un stock indéfini.
/// </summary>
public int? AvailableStock { get; }

/// <summary>
/// Indique si l'article est une formule ou non.
/// </summary>
public bool IsBundle { get; }

public ItemSold(Product product)
{
this.Id = product.Id;
this.Name = product.Name;
this.MemberPrice = product.MemberPrice;
this.NonMemberPrice = product.NonMemberPrice;
this.IsAvailable = product.Availability == Availability.Always;
this.AvailableStock = product.Stock;
this.IsBundle = false;
}
}
25 changes: 25 additions & 0 deletions WebService/Dto/Checkout/ItemSoldCategory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using GalliumPlus.Core.Stocks;

namespace GalliumPlus.WebService.Dto.Checkout;

/// <summary>
/// Une catégorie d'articles disponibles sur la caisse.
/// </summary>
public class ItemSoldCategory
{
/// <summary>
/// Le nom de la catégorie.
/// </summary>
public string Name { get; }

/// <summary>
/// Les articles appartenant à la catégorie.
/// </summary>
public IList<ItemSold> Items { get; }

public ItemSoldCategory(string name, IEnumerable<Product> products)
{
this.Name = name;
this.Items = products.Select(p => new ItemSold(p)).ToList();
}
}
2 changes: 1 addition & 1 deletion WebService/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
app.UseAuthorization();
app.MapControllers();

ServerInfo.Current.SetVersion(1, 4, 1, "beta");
ServerInfo.Current.SetVersion(1, 5, 0, "beta");
Console.WriteLine(ServerInfo.Current);

#if !FAKE_DB
Expand Down
Loading