Compare commits

...

11 Commits

403 changed files with 33493 additions and 229 deletions

6
.vscode/launch.json vendored
View File

@ -4,6 +4,12 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "C#: <project-name> Debug",
"type": "dotnet",
"request": "launch",
"projectPath": "${workspaceFolder}/active-allocator/bin/Debug/net7.0/linux-x64/active-allocator.dll"
},
{
"name": ".NET Core Launch (web)",
"type": "coreclr",

131
README.md
View File

@ -32,9 +32,138 @@ Use [layoutit.com](https://www.layoutit.com/build).
* Timescale of App (month? 2-week? quarter?)
* Choose statistical metrics for estimating allocation amount (default to simple average (with lookback range))
### Guides
Easy background worker [guide](https://dev.to/htissink/easy-guide-to-worker-services-in-net-core-oc1)
### Back-end Functions
*
### Accounts & Envelopes
Each transaction has these fields, all nullable:
```
Debit Account (DA)
Credit Account (CA)
Debit Envelope (DE)
Credit Envelope (CE)
```
```Debit``` denotes that the entity is having value removed from it.
```Credit``` denotes that the entity is having value added to it.
If an account or envelope is ```null``` we call it ```(void)```, a placeholder entity that isn't tracked.
#### Scenarios
```
Conflicting Debit & Credit Entities
If (DA != null && DE.Account != DA)
If (CA != null && CE.Account != CA)
If (DE.Account != DA)
If (DE.Account != DA)
If (DE.Account != DA)
```
```
Envelopes Affecting Accounts
If Envelope Accounts differ, account transfer is performed as well as envelope value adjusting.
If Envelopes use the same Account (or null envelope) Account value is unaffected.
Operations with Envelopes should always trigger an update to the virtual balance of the underlying account.
```
```
DA -> CA
DE -> CE
Value is deducted from DA
Value is added to CA
Value is deducted from DE
Value is added to CE
DE.A Value isn't necessarily changed
CE.A Value isn't necessarily changed
```
```csharp
if (DA != null)
{
addAmount(DA, -amount);
}
if (DE != null)
{
addAmount(DE, -amount);
}
if (CA != null)
{
addAmount(CA, amount);
}
if (CE != null)
{
addAmount(CE, amount);
}
```
```
DA -> CA
null -> null
Value is deducted from DA
Value is added to CA
```
```
DA -> null
null -> null
Value is deducted from DA
```
```
null -> CA
null -> null
Value is added to CA
```
```
null -> null
DE -> CE
Value is deducted from DE
If DE Account differs from CE Account,
then value must also be transferred between accounts
Value is added to CE
```
```
null -> null
DE -> null
Value is deducted from DE
Virtual Value is returned to Envelope Account
```
Add virtual balance to account
Debit Account -> Credit Envelope = true
Debit Envelope -> Credit Account = true
Debit Account -> (void) = false
(void) -> Credit Account = false
Debit Envelope -> (void) = false
(void) -> Credit Envelope = false
Debit Account & Debit Envelope -> Credit Envelope = error
## Dev Environment Setup

View File

@ -0,0 +1,29 @@
namespace active_allocator.Tests;
public class AccountServiceTests
{
[Fact]
public void PassingTest()
{
// Arrange
int a = 2;
int b = 2;
// Act
int result = Add(2, 2);
// Assert
Assert.Equal(4, result);
}
[Fact]
public void FailingTest()
{
Assert.Equal(5, Add(2, 2));
}
int Add(int x, int y)
{
return x + y;
}
}

View File

@ -0,0 +1,14 @@
public class DatabaseFixture : IDisposable
{
// Constructor: Set up your fixture.
public DatabaseFixture()
{
// Initialize your test database or any other resources.
}
// IDisposable implementation: Clean up your fixture.
public void Dispose()
{
// Dispose of or release any resources used by your fixture.
}
}

View File

@ -0,0 +1 @@
global using Xunit;

View File

@ -0,0 +1,29 @@
namespace active_allocator.Tests;
public class MathTests
{
[Fact]
public void PassingTest()
{
// Arrange
int a = 2;
int b = 2;
// Act
int result = Add(2, 2);
// Assert
Assert.Equal(4, result);
}
[Fact]
public void FailingTest()
{
Assert.Equal(5, Add(2, 2));
}
int Add(int x, int y)
{
return x + y;
}
}

View File

@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<RootNamespace>active_allocator.Tests</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\active-allocator\active-allocator.csproj" />
</ItemGroup>
</Project>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,18 @@
{
"runtimeOptions": {
"tfm": "net7.0",
"frameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "7.0.0"
},
{
"name": "Microsoft.AspNetCore.App",
"version": "7.0.0"
}
],
"configProperties": {
"System.Reflection.NullabilityInfoContext.IsSupported": true
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,20 @@
{
"runtimeOptions": {
"tfm": "net7.0",
"includedFrameworks": [
{
"name": "Microsoft.NETCore.App",
"version": "7.0.15"
},
{
"name": "Microsoft.AspNetCore.App",
"version": "7.0.15"
}
],
"configProperties": {
"System.GC.Server": true,
"System.Reflection.NullabilityInfoContext.IsSupported": true,
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}

View File

@ -0,0 +1,10 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.AspNetCore.SpaProxy": "Information",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

View File

@ -0,0 +1,16 @@
{
"ConnectionStrings": {
"PSQLConnection": "Server=localhost;Port=15432;Database=aadb;User Id=postgres;Password=nqA3UV3CliLLHpLL"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*",
"AppSettings": {
"Secret": "5de80277015f9fd564c4d1cc2cf827dbb1774cd66e7d79aa258d9c35a9f67f32fc6cf0dc24244242bd9501288e0fd69e315b"
}
}

Some files were not shown because too many files have changed in this diff Show More