diff --git a/backend/src/Faktur.Contracts/Receipts/ReceiptTax.cs b/backend/src/Faktur.Contracts/Receipts/ReceiptTax.cs
index a8d4632e..8d73cae7 100644
--- a/backend/src/Faktur.Contracts/Receipts/ReceiptTax.cs
+++ b/backend/src/Faktur.Contracts/Receipts/ReceiptTax.cs
@@ -3,16 +3,18 @@
public record ReceiptTax
{
public string Code { get; set; }
+ public string Flags { get; set; }
public double Rate { get; set; }
public decimal TaxableAmount { get; set; }
public decimal Amount { get; set; }
- public ReceiptTax() : this(string.Empty)
+ public ReceiptTax() : this(string.Empty, string.Empty)
{
}
- public ReceiptTax(string code)
+ public ReceiptTax(string code, string flags)
{
Code = code;
+ Flags = flags;
}
}
diff --git a/backend/src/Faktur.EntityFrameworkCore.PostgreSQL/Migrations/20240409152500_Release_2_0_0.Designer.cs b/backend/src/Faktur.EntityFrameworkCore.PostgreSQL/Migrations/20240420185953_Release_2_0_0.Designer.cs
similarity index 99%
rename from backend/src/Faktur.EntityFrameworkCore.PostgreSQL/Migrations/20240409152500_Release_2_0_0.Designer.cs
rename to backend/src/Faktur.EntityFrameworkCore.PostgreSQL/Migrations/20240420185953_Release_2_0_0.Designer.cs
index 755c412c..ffc264b8 100644
--- a/backend/src/Faktur.EntityFrameworkCore.PostgreSQL/Migrations/20240409152500_Release_2_0_0.Designer.cs
+++ b/backend/src/Faktur.EntityFrameworkCore.PostgreSQL/Migrations/20240420185953_Release_2_0_0.Designer.cs
@@ -11,7 +11,7 @@
namespace Faktur.EntityFrameworkCore.PostgreSQL.Migrations
{
[DbContext(typeof(FakturContext))]
- [Migration("20240409152500_Release_2_0_0")]
+ [Migration("20240420185953_Release_2_0_0")]
partial class Release_2_0_0
{
///
@@ -598,6 +598,11 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
b.Property("Amount")
.HasColumnType("money");
+ b.Property("Flags")
+ .IsRequired()
+ .HasMaxLength(10)
+ .HasColumnType("character varying(10)");
+
b.Property("Rate")
.HasColumnType("double precision");
@@ -610,6 +615,8 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
b.HasIndex("Code");
+ b.HasIndex("Flags");
+
b.HasIndex("Rate");
b.HasIndex("TaxableAmount");
diff --git a/backend/src/Faktur.EntityFrameworkCore.PostgreSQL/Migrations/20240409152500_Release_2_0_0.cs b/backend/src/Faktur.EntityFrameworkCore.PostgreSQL/Migrations/20240420185953_Release_2_0_0.cs
similarity index 99%
rename from backend/src/Faktur.EntityFrameworkCore.PostgreSQL/Migrations/20240409152500_Release_2_0_0.cs
rename to backend/src/Faktur.EntityFrameworkCore.PostgreSQL/Migrations/20240420185953_Release_2_0_0.cs
index 16008a5b..424bfcbc 100644
--- a/backend/src/Faktur.EntityFrameworkCore.PostgreSQL/Migrations/20240409152500_Release_2_0_0.cs
+++ b/backend/src/Faktur.EntityFrameworkCore.PostgreSQL/Migrations/20240420185953_Release_2_0_0.cs
@@ -254,6 +254,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
{
ReceiptId = table.Column(type: "integer", nullable: false),
Code = table.Column(type: "character varying(4)", maxLength: 4, nullable: false),
+ Flags = table.Column(type: "character varying(10)", maxLength: 10, nullable: false),
Rate = table.Column(type: "double precision", nullable: false),
TaxableAmount = table.Column(type: "money", nullable: false),
Amount = table.Column(type: "money", nullable: false)
@@ -709,6 +710,11 @@ protected override void Up(MigrationBuilder migrationBuilder)
table: "ReceiptTaxes",
column: "Code");
+ migrationBuilder.CreateIndex(
+ name: "IX_ReceiptTaxes_Flags",
+ table: "ReceiptTaxes",
+ column: "Flags");
+
migrationBuilder.CreateIndex(
name: "IX_ReceiptTaxes_Rate",
table: "ReceiptTaxes",
diff --git a/backend/src/Faktur.EntityFrameworkCore.PostgreSQL/Migrations/FakturContextModelSnapshot.cs b/backend/src/Faktur.EntityFrameworkCore.PostgreSQL/Migrations/FakturContextModelSnapshot.cs
index e6e4fbb5..2ff87103 100644
--- a/backend/src/Faktur.EntityFrameworkCore.PostgreSQL/Migrations/FakturContextModelSnapshot.cs
+++ b/backend/src/Faktur.EntityFrameworkCore.PostgreSQL/Migrations/FakturContextModelSnapshot.cs
@@ -595,6 +595,11 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property("Amount")
.HasColumnType("money");
+ b.Property("Flags")
+ .IsRequired()
+ .HasMaxLength(10)
+ .HasColumnType("character varying(10)");
+
b.Property("Rate")
.HasColumnType("double precision");
@@ -607,6 +612,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.HasIndex("Code");
+ b.HasIndex("Flags");
+
b.HasIndex("Rate");
b.HasIndex("TaxableAmount");
diff --git a/backend/src/Faktur.EntityFrameworkCore.Relational/Configurations/ReceiptTaxConfiguration.cs b/backend/src/Faktur.EntityFrameworkCore.Relational/Configurations/ReceiptTaxConfiguration.cs
index d783f67f..b176f53d 100644
--- a/backend/src/Faktur.EntityFrameworkCore.Relational/Configurations/ReceiptTaxConfiguration.cs
+++ b/backend/src/Faktur.EntityFrameworkCore.Relational/Configurations/ReceiptTaxConfiguration.cs
@@ -1,4 +1,5 @@
-using Faktur.Domain.Taxes;
+using Faktur.Domain.Products;
+using Faktur.Domain.Taxes;
using Faktur.EntityFrameworkCore.Relational.Entities;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
@@ -13,10 +14,12 @@ public void Configure(EntityTypeBuilder builder)
builder.HasKey(x => new { x.ReceiptId, x.Code });
builder.HasIndex(x => x.Code);
+ builder.HasIndex(x => x.Flags);
builder.HasIndex(x => x.Rate);
builder.HasIndex(x => x.TaxableAmount);
builder.HasIndex(x => x.Amount);
+ builder.Property(x => x.Flags).HasMaxLength(FlagsUnit.MaximumLength);
builder.Property(x => x.Code).HasMaxLength(TaxCodeUnit.MaximumLength);
builder.Property(x => x.TaxableAmount).HasColumnType("money");
builder.Property(x => x.Amount).HasColumnType("money");
diff --git a/backend/src/Faktur.EntityFrameworkCore.Relational/Entities/ReceiptTaxEntity.cs b/backend/src/Faktur.EntityFrameworkCore.Relational/Entities/ReceiptTaxEntity.cs
index a78558a0..c8fc581d 100644
--- a/backend/src/Faktur.EntityFrameworkCore.Relational/Entities/ReceiptTaxEntity.cs
+++ b/backend/src/Faktur.EntityFrameworkCore.Relational/Entities/ReceiptTaxEntity.cs
@@ -8,6 +8,7 @@ internal class ReceiptTaxEntity
public int ReceiptId { get; private set; }
public string Code { get; private set; } = string.Empty;
+ public string Flags { get; private set; } = string.Empty;
public double Rate { get; private set; }
public decimal TaxableAmount { get; private set; }
public decimal Amount { get; private set; }
@@ -28,6 +29,7 @@ private ReceiptTaxEntity()
public void Update(ReceiptTaxUnit tax)
{
+ Flags = tax.Flags.Value;
Rate = tax.Rate;
TaxableAmount = tax.TaxableAmount;
Amount = tax.Amount;
diff --git a/backend/src/Faktur.EntityFrameworkCore.Relational/Mapper.cs b/backend/src/Faktur.EntityFrameworkCore.Relational/Mapper.cs
index a80b4004..76b62c2a 100644
--- a/backend/src/Faktur.EntityFrameworkCore.Relational/Mapper.cs
+++ b/backend/src/Faktur.EntityFrameworkCore.Relational/Mapper.cs
@@ -141,7 +141,7 @@ public Receipt ToReceipt(ReceiptEntity source, bool includeItems)
foreach (ReceiptTaxEntity tax in source.Taxes)
{
- destination.Taxes.Add(new ReceiptTax(tax.Code)
+ destination.Taxes.Add(new ReceiptTax(tax.Code, tax.Flags)
{
Rate = tax.Rate,
TaxableAmount = tax.TaxableAmount,
diff --git a/backend/src/Faktur.EntityFrameworkCore.SqlServer/Migrations/20240409151915_Release_2_0_0.Designer.cs b/backend/src/Faktur.EntityFrameworkCore.SqlServer/Migrations/20240420185826_Release_2_0_0.Designer.cs
similarity index 99%
rename from backend/src/Faktur.EntityFrameworkCore.SqlServer/Migrations/20240409151915_Release_2_0_0.Designer.cs
rename to backend/src/Faktur.EntityFrameworkCore.SqlServer/Migrations/20240420185826_Release_2_0_0.Designer.cs
index 615290f5..3eadf0e9 100644
--- a/backend/src/Faktur.EntityFrameworkCore.SqlServer/Migrations/20240409151915_Release_2_0_0.Designer.cs
+++ b/backend/src/Faktur.EntityFrameworkCore.SqlServer/Migrations/20240420185826_Release_2_0_0.Designer.cs
@@ -11,7 +11,7 @@
namespace Faktur.EntityFrameworkCore.SqlServer.Migrations
{
[DbContext(typeof(FakturContext))]
- [Migration("20240409151915_Release_2_0_0")]
+ [Migration("20240420185826_Release_2_0_0")]
partial class Release_2_0_0
{
///
@@ -600,6 +600,11 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
b.Property("Amount")
.HasColumnType("money");
+ b.Property("Flags")
+ .IsRequired()
+ .HasMaxLength(10)
+ .HasColumnType("nvarchar(10)");
+
b.Property("Rate")
.HasColumnType("float");
@@ -612,6 +617,8 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder)
b.HasIndex("Code");
+ b.HasIndex("Flags");
+
b.HasIndex("Rate");
b.HasIndex("TaxableAmount");
diff --git a/backend/src/Faktur.EntityFrameworkCore.SqlServer/Migrations/20240409151915_Release_2_0_0.cs b/backend/src/Faktur.EntityFrameworkCore.SqlServer/Migrations/20240420185826_Release_2_0_0.cs
similarity index 99%
rename from backend/src/Faktur.EntityFrameworkCore.SqlServer/Migrations/20240409151915_Release_2_0_0.cs
rename to backend/src/Faktur.EntityFrameworkCore.SqlServer/Migrations/20240420185826_Release_2_0_0.cs
index e12fc050..59e64add 100644
--- a/backend/src/Faktur.EntityFrameworkCore.SqlServer/Migrations/20240409151915_Release_2_0_0.cs
+++ b/backend/src/Faktur.EntityFrameworkCore.SqlServer/Migrations/20240420185826_Release_2_0_0.cs
@@ -253,6 +253,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
{
ReceiptId = table.Column(type: "int", nullable: false),
Code = table.Column(type: "nvarchar(4)", maxLength: 4, nullable: false),
+ Flags = table.Column(type: "nvarchar(10)", maxLength: 10, nullable: false),
Rate = table.Column(type: "float", nullable: false),
TaxableAmount = table.Column(type: "money", nullable: false),
Amount = table.Column(type: "money", nullable: false)
@@ -710,6 +711,11 @@ protected override void Up(MigrationBuilder migrationBuilder)
table: "ReceiptTaxes",
column: "Code");
+ migrationBuilder.CreateIndex(
+ name: "IX_ReceiptTaxes_Flags",
+ table: "ReceiptTaxes",
+ column: "Flags");
+
migrationBuilder.CreateIndex(
name: "IX_ReceiptTaxes_Rate",
table: "ReceiptTaxes",
diff --git a/backend/src/Faktur.EntityFrameworkCore.SqlServer/Migrations/FakturContextModelSnapshot.cs b/backend/src/Faktur.EntityFrameworkCore.SqlServer/Migrations/FakturContextModelSnapshot.cs
index 0bc53cfe..a2f10a50 100644
--- a/backend/src/Faktur.EntityFrameworkCore.SqlServer/Migrations/FakturContextModelSnapshot.cs
+++ b/backend/src/Faktur.EntityFrameworkCore.SqlServer/Migrations/FakturContextModelSnapshot.cs
@@ -597,6 +597,11 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property("Amount")
.HasColumnType("money");
+ b.Property("Flags")
+ .IsRequired()
+ .HasMaxLength(10)
+ .HasColumnType("nvarchar(10)");
+
b.Property("Rate")
.HasColumnType("float");
@@ -609,6 +614,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.HasIndex("Code");
+ b.HasIndex("Flags");
+
b.HasIndex("Rate");
b.HasIndex("TaxableAmount");
diff --git a/frontend/src/components/receipts/ReceiptCategorization.vue b/frontend/src/components/receipts/ReceiptCategorization.vue
index 3fe16ef8..6b02f486 100644
--- a/frontend/src/components/receipts/ReceiptCategorization.vue
+++ b/frontend/src/components/receipts/ReceiptCategorization.vue
@@ -7,7 +7,6 @@ import AppBackButton from "@/components/shared/AppBackButton.vue";
import ReceiptItemCard from "./ReceiptItemCard.vue";
import ReceiptTotal from "./ReceiptTotal.vue";
import type { Receipt, ReceiptItem, ReceiptTotal as TReceiptTotal } from "@/types/receipts";
-import type { Tax } from "@/types/taxes";
import { isTaxable } from "@/helpers/taxUtils";
import { orderBy } from "@/helpers/arrayUtils";
import { useCategoryStore } from "@/stores/categories";
@@ -24,7 +23,6 @@ const props = withDefaults(
defineProps<{
processing?: boolean;
receipt: Receipt;
- taxes: Tax[]; // TODO(fpion): should be included in receipt.taxes
}>(),
{
processing: false,
@@ -47,11 +45,7 @@ const groupedItems = computed(() => {
});
const taxFlags = computed