refactor: rename namespace to FiscalFlow and upgrade to .NET 10
- Rename InvoiceMaster.* to FiscalFlow.* namespace - Upgrade from .NET 8 to .NET 10 - Update all NuGet packages to latest versions - Update C# language version to 14.0
This commit is contained in:
80
backend/src/FiscalFlow.Core/Entities/AccountingConnection.cs
Normal file
80
backend/src/FiscalFlow.Core/Entities/AccountingConnection.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
namespace FiscalFlow.Core.Entities;
|
||||
|
||||
public class AccountingConnection : BaseEntity
|
||||
{
|
||||
public Guid UserId { get; private set; }
|
||||
public User User { get; private set; } = null!;
|
||||
|
||||
public string Provider { get; private set; } = string.Empty;
|
||||
|
||||
public string AccessTokenEncrypted { get; private set; } = string.Empty;
|
||||
public string RefreshTokenEncrypted { get; private set; } = string.Empty;
|
||||
public DateTime ExpiresAt { get; private set; }
|
||||
public string? Scope { get; private set; }
|
||||
|
||||
public string? CompanyName { get; private set; }
|
||||
public string? CompanyOrgNumber { get; private set; }
|
||||
|
||||
public string DefaultVoucherSeries { get; private set; } = "A";
|
||||
public int DefaultAccountCode { get; private set; } = 5460;
|
||||
public bool AutoAttachPdf { get; private set; } = true;
|
||||
public bool AutoCreateSupplier { get; private set; } = false;
|
||||
|
||||
public bool IsActive { get; private set; } = true;
|
||||
public DateTime? LastSyncAt { get; private set; }
|
||||
|
||||
private readonly List<Invoice> _invoices = [];
|
||||
public IReadOnlyCollection<Invoice> Invoices => _invoices.AsReadOnly();
|
||||
|
||||
public static AccountingConnection Create(
|
||||
Guid userId,
|
||||
string provider,
|
||||
string accessTokenEncrypted,
|
||||
string refreshTokenEncrypted,
|
||||
DateTime expiresAt,
|
||||
string? scope = null,
|
||||
string? companyName = null,
|
||||
string? companyOrgNumber = null)
|
||||
{
|
||||
return new AccountingConnection
|
||||
{
|
||||
UserId = userId,
|
||||
Provider = provider,
|
||||
AccessTokenEncrypted = accessTokenEncrypted,
|
||||
RefreshTokenEncrypted = refreshTokenEncrypted,
|
||||
ExpiresAt = expiresAt,
|
||||
Scope = scope,
|
||||
CompanyName = companyName,
|
||||
CompanyOrgNumber = companyOrgNumber
|
||||
};
|
||||
}
|
||||
|
||||
public void UpdateTokens(string accessTokenEncrypted, string refreshTokenEncrypted, DateTime expiresAt)
|
||||
{
|
||||
AccessTokenEncrypted = accessTokenEncrypted;
|
||||
RefreshTokenEncrypted = refreshTokenEncrypted;
|
||||
ExpiresAt = expiresAt;
|
||||
}
|
||||
|
||||
public void UpdateSettings(
|
||||
string? defaultVoucherSeries = null,
|
||||
int? defaultAccountCode = null,
|
||||
bool? autoAttachPdf = null,
|
||||
bool? autoCreateSupplier = null)
|
||||
{
|
||||
if (defaultVoucherSeries != null) DefaultVoucherSeries = defaultVoucherSeries;
|
||||
if (defaultAccountCode.HasValue) DefaultAccountCode = defaultAccountCode.Value;
|
||||
if (autoAttachPdf.HasValue) AutoAttachPdf = autoAttachPdf.Value;
|
||||
if (autoCreateSupplier.HasValue) AutoCreateSupplier = autoCreateSupplier.Value;
|
||||
}
|
||||
|
||||
public void RecordSync()
|
||||
{
|
||||
LastSyncAt = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
public void Deactivate()
|
||||
{
|
||||
IsActive = false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user