This commit is contained in:
160
server/AyaNova/Controllers/TaxCodeController.cs
Normal file
160
server/AyaNova/Controllers/TaxCodeController.cs
Normal file
@@ -0,0 +1,160 @@
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using AyaNova.Models;
|
||||
using AyaNova.Api.ControllerHelpers;
|
||||
using AyaNova.Biz;
|
||||
|
||||
|
||||
|
||||
namespace AyaNova.Api.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[ApiVersion("8.0")]
|
||||
[Route("api/v{version:apiVersion}/tax-code")]
|
||||
[Produces("application/json")]
|
||||
[Authorize]
|
||||
public class TaxCodeController : ControllerBase
|
||||
{
|
||||
private readonly AyContext ct;
|
||||
private readonly ILogger<TaxCodeController> log;
|
||||
private readonly ApiServerState serverState;
|
||||
|
||||
/// <summary>
|
||||
/// ctor
|
||||
/// </summary>
|
||||
/// <param name="dbcontext"></param>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="apiServerState"></param>
|
||||
public TaxCodeController(AyContext dbcontext, ILogger<TaxCodeController> logger, ApiServerState apiServerState)
|
||||
{
|
||||
ct = dbcontext;
|
||||
log = logger;
|
||||
serverState = apiServerState;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create TaxCode
|
||||
/// </summary>
|
||||
/// <param name="newObject"></param>
|
||||
/// <param name="apiVersion">From route path</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> PostTaxCode([FromBody] TaxCode newObject, ApiVersion apiVersion)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
TaxCodeBiz biz = TaxCodeBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
TaxCode o = await biz.CreateAsync(newObject);
|
||||
if (o == null)
|
||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
else
|
||||
return CreatedAtAction(nameof(TaxCodeController.GetTaxCode), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Duplicate TaxCode
|
||||
/// (Wiki and Attachments are not duplicated)
|
||||
/// </summary>
|
||||
/// <param name="id">Source object id</param>
|
||||
/// <param name="apiVersion">From route path</param>
|
||||
/// <returns>TaxCode</returns>
|
||||
[HttpPost("duplicate/{id}")]
|
||||
public async Task<IActionResult> DuplicateTaxCode([FromRoute] long id, ApiVersion apiVersion)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
TaxCodeBiz biz = TaxCodeBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
TaxCode o = await biz.DuplicateAsync(id);
|
||||
if (o == null)
|
||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
else
|
||||
return CreatedAtAction(nameof(TaxCodeController.GetTaxCode), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get TaxCode
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns>TaxCode</returns>
|
||||
[HttpGet("{id}")]
|
||||
public async Task<IActionResult> GetTaxCode([FromRoute] long id)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
TaxCodeBiz biz = TaxCodeBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasReadFullRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
var o = await biz.GetAsync(id);
|
||||
if (o == null) return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
|
||||
return Ok(ApiOkResponse.Response(o));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Put (update) TaxCode
|
||||
/// </summary>
|
||||
/// <param name="updatedObject"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPut]
|
||||
public async Task<IActionResult> PutTaxCode([FromBody] TaxCode updatedObject)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
TaxCodeBiz biz = TaxCodeBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
var o = await biz.PutAsync(updatedObject);//In future may need to return entire object, for now just concurrency token
|
||||
if (o == null)
|
||||
{
|
||||
if (biz.Errors.Exists(z => z.Code == ApiErrorCode.CONCURRENCY_CONFLICT))
|
||||
return StatusCode(409, new ApiErrorResponse(biz.Errors));
|
||||
else
|
||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
}
|
||||
return Ok(ApiOkResponse.Response(new { Concurrency = o.Concurrency })); ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete TaxCode
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns>NoContent</returns>
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<IActionResult> DeleteTaxCode([FromRoute] long id)
|
||||
{
|
||||
if (!serverState.IsOpen)
|
||||
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(new ApiErrorResponse(ModelState));
|
||||
TaxCodeBiz biz = TaxCodeBiz.GetBiz(ct, HttpContext);
|
||||
if (!Authorized.HasDeleteRole(HttpContext.Items, biz.BizType))
|
||||
return StatusCode(403, new ApiNotAuthorizedResponse());
|
||||
if (!await biz.DeleteAsync(id))
|
||||
return BadRequest(new ApiErrorResponse(biz.Errors));
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//------------
|
||||
|
||||
|
||||
}//eoc
|
||||
}//eons
|
||||
@@ -549,8 +549,8 @@ namespace AyaNova.Biz
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "Attachments", FieldKey = "Attachments" });
|
||||
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "RateAccountNumber", FieldKey = "RateAccountNumber" });
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "Cost", FieldKey = "Cost" });
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "RateCharge", FieldKey = "RateCharge" });
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "Cost", FieldKey = "Cost", Hideable = false });
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "RateCharge", FieldKey = "RateCharge", Hideable = false });
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "RateUnitChargeDescriptionID", FieldKey = "RateUnitChargeDescriptionID" });
|
||||
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "ServiceRateCustom1", FieldKey = "ServiceRateCustom1", IsCustomField = true });
|
||||
@@ -586,8 +586,8 @@ namespace AyaNova.Biz
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "Attachments", FieldKey = "Attachments" });
|
||||
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "RateAccountNumber", FieldKey = "RateAccountNumber" });
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "Cost", FieldKey = "Cost" });
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "RateCharge", FieldKey = "RateCharge" });
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "Cost", FieldKey = "Cost", Hideable = false });
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "RateCharge", FieldKey = "RateCharge", Hideable = false });
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "RateUnitChargeDescriptionID", FieldKey = "RateUnitChargeDescriptionID" });
|
||||
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "TravelRateCustom1", FieldKey = "TravelRateCustom1", IsCustomField = true });
|
||||
@@ -608,6 +608,42 @@ namespace AyaNova.Biz
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "TravelRateCustom16", FieldKey = "TravelRateCustom16", IsCustomField = true });
|
||||
_ayaFormFields.Add(AyaType.TravelRate.ToString(), l);
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region TaxCode
|
||||
{
|
||||
|
||||
List<AyaFormFieldDefinition> l = new List<AyaFormFieldDefinition>();
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "Name", FieldKey = "Name", Hideable = false });
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "TaxCodeNotes", FieldKey = "TaxCodeNotes" });
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "Active", FieldKey = "Active", Hideable = false });
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "Tags", FieldKey = "Tags" });
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "Wiki", FieldKey = "Wiki" });
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "Attachments", FieldKey = "Attachments" });
|
||||
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "TaxCodeTaxA", FieldKey = "TaxCodeTaxA", Hideable = false });
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "TaxCodeTaxB", FieldKey = "TaxCodeTaxB", Hideable = false });
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "TaxCodeTaxOnTax", FieldKey = "TaxCodeTaxOnTax", Hideable = false });
|
||||
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "TaxCodeCustom1", FieldKey = "TaxCodeCustom1", IsCustomField = true });
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "TaxCodeCustom2", FieldKey = "TaxCodeCustom2", IsCustomField = true });
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "TaxCodeCustom3", FieldKey = "TaxCodeCustom3", IsCustomField = true });
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "TaxCodeCustom4", FieldKey = "TaxCodeCustom4", IsCustomField = true });
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "TaxCodeCustom5", FieldKey = "TaxCodeCustom5", IsCustomField = true });
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "TaxCodeCustom6", FieldKey = "TaxCodeCustom6", IsCustomField = true });
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "TaxCodeCustom7", FieldKey = "TaxCodeCustom7", IsCustomField = true });
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "TaxCodeCustom8", FieldKey = "TaxCodeCustom8", IsCustomField = true });
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "TaxCodeCustom9", FieldKey = "TaxCodeCustom9", IsCustomField = true });
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "TaxCodeCustom10", FieldKey = "TaxCodeCustom10", IsCustomField = true });
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "TaxCodeCustom11", FieldKey = "TaxCodeCustom11", IsCustomField = true });
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "TaxCodeCustom12", FieldKey = "TaxCodeCustom12", IsCustomField = true });
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "TaxCodeCustom13", FieldKey = "TaxCodeCustom13", IsCustomField = true });
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "TaxCodeCustom14", FieldKey = "TaxCodeCustom14", IsCustomField = true });
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "TaxCodeCustom15", FieldKey = "TaxCodeCustom15", IsCustomField = true });
|
||||
l.Add(new AyaFormFieldDefinition { TKey = "TaxCodeCustom16", FieldKey = "TaxCodeCustom16", IsCustomField = true });
|
||||
_ayaFormFields.Add(AyaType.TaxCode.ToString(), l);
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -125,7 +125,9 @@ namespace AyaNova.Biz
|
||||
[CoreBizObject]
|
||||
ServiceRate = 62,
|
||||
[CoreBizObject]
|
||||
TravelRate = 63
|
||||
TravelRate = 63,
|
||||
[CoreBizObject]
|
||||
TaxCode = 64
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -259,6 +259,22 @@ namespace AyaNova.Biz
|
||||
Select = AuthorizationRoles.All
|
||||
});
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//TaxCode
|
||||
//
|
||||
roles.Add(AyaType.TaxCode, new BizRoleSet()
|
||||
{
|
||||
Change = AuthorizationRoles.BizAdminFull | AuthorizationRoles.AccountingFull,
|
||||
ReadFullRecord = AuthorizationRoles.DispatchFull
|
||||
| AuthorizationRoles.SalesFull
|
||||
| AuthorizationRoles.TechFull
|
||||
| AuthorizationRoles.BizAdminLimited
|
||||
| AuthorizationRoles.DispatchLimited
|
||||
| AuthorizationRoles.SalesLimited
|
||||
| AuthorizationRoles.TechLimited,
|
||||
Select = AuthorizationRoles.All
|
||||
});
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
//Quote
|
||||
@@ -733,9 +749,9 @@ namespace AyaNova.Biz
|
||||
|
||||
//GENERATE CLIENT COMPATIBLE JSON FROM ROLES OUTPUT TO DEBUG LOG
|
||||
//And seperately, set the JSON variable so can copy from debug variable "value" property for lastRoles here to compare
|
||||
// string json = Newtonsoft.Json.JsonConvert.SerializeObject(roles, Newtonsoft.Json.Formatting.None);
|
||||
// System.Diagnostics.Debugger.Log(1, "JSONFRAGMENTFORCLIENT", "BizRoles.cs -> biz-role-rights.js Client roles JSON fragment:\n\n");
|
||||
// System.Diagnostics.Debugger.Log(1, "JSONFRAGMENTFORCLIENT", json + "\n\n");
|
||||
string json = Newtonsoft.Json.JsonConvert.SerializeObject(roles, Newtonsoft.Json.Formatting.None);
|
||||
System.Diagnostics.Debugger.Log(1, "JSONFRAGMENTFORCLIENT", "BizRoles.cs -> biz-role-rights.js Client roles JSON fragment:\n\n");
|
||||
System.Diagnostics.Debugger.Log(1, "JSONFRAGMENTFORCLIENT", json + "\n\n");
|
||||
|
||||
//ONGOING VALIDATION TO CATCH MISMATCH WHEN NEW ROLES ADDED (wont' catch changes to existing unfortunately)
|
||||
var lastRoles = "{\"Customer\":{\"Change\":33098,\"ReadFullRecord\":65669,\"Select\":131071},\"CustomerNote\":{\"Change\":33098,\"ReadFullRecord\":65669,\"Select\":131071},\"Contract\":{\"Change\":33098,\"ReadFullRecord\":65669,\"Select\":131071},\"HeadOffice\":{\"Change\":33098,\"ReadFullRecord\":65669,\"Select\":131071},\"LoanUnit\":{\"Change\":33098,\"ReadFullRecord\":65669,\"Select\":131071},\"Part\":{\"Change\":98,\"ReadFullRecord\":29,\"Select\":131071},\"PurchaseOrder\":{\"Change\":98,\"ReadFullRecord\":29,\"Select\":131071},\"PM\":{\"Change\":33098,\"ReadFullRecord\":65669,\"Select\":131071},\"PMItem\":{\"Change\":33098,\"ReadFullRecord\":65669,\"Select\":131071},\"PMTemplate\":{\"Change\":33098,\"ReadFullRecord\":65669,\"Select\":131071},\"PMTemplateItem\":{\"Change\":33098,\"ReadFullRecord\":65669,\"Select\":131071},\"Project\":{\"Change\":33098,\"ReadFullRecord\":65669,\"Select\":131071},\"ServiceRate\":{\"Change\":66,\"ReadFullRecord\":98701,\"Select\":131071},\"TravelRate\":{\"Change\":66,\"ReadFullRecord\":98701,\"Select\":131071},\"Quote\":{\"Change\":33098,\"ReadFullRecord\":65669,\"Select\":131071},\"QuoteItem\":{\"Change\":33098,\"ReadFullRecord\":65669,\"Select\":131071},\"QuoteTemplate\":{\"Change\":33098,\"ReadFullRecord\":65669,\"Select\":131071},\"QuoteTemplateItem\":{\"Change\":33098,\"ReadFullRecord\":65669,\"Select\":131071},\"Unit\":{\"Change\":33098,\"ReadFullRecord\":65669,\"Select\":131071},\"UnitModel\":{\"Change\":33098,\"ReadFullRecord\":65669,\"Select\":131071},\"Vendor\":{\"Change\":33098,\"ReadFullRecord\":65669,\"Select\":131071},\"WorkOrder\":{\"Change\":1354,\"ReadFullRecord\":105093,\"Select\":131071},\"WorkOrderItem\":{\"Change\":1354,\"ReadFullRecord\":105093,\"Select\":131071},\"WorkOrderItemExpense\":{\"Change\":1354,\"ReadFullRecord\":98949,\"Select\":131071},\"WorkOrderItemLabor\":{\"Change\":1354,\"ReadFullRecord\":98949,\"Select\":131071},\"WorkOrderItemLoan\":{\"Change\":1354,\"ReadFullRecord\":98949,\"Select\":131071},\"WorkOrderItemPart\":{\"Change\":1354,\"ReadFullRecord\":98949,\"Select\":131071},\"WorkOrderItemPartRequest\":{\"Change\":298,\"ReadFullRecord\":149,\"Select\":131071},\"WorkOrderItemScheduledUser\":{\"Change\":1354,\"ReadFullRecord\":98949,\"Select\":131071},\"WorkOrderItemTask\":{\"Change\":1354,\"ReadFullRecord\":98949,\"Select\":131071},\"WorkOrderItemTravel\":{\"Change\":1354,\"ReadFullRecord\":98949,\"Select\":131071},\"WorkOrderItemUnit\":{\"Change\":1354,\"ReadFullRecord\":98949,\"Select\":131071},\"WorkOrderTemplate\":{\"Change\":33098,\"ReadFullRecord\":65669,\"Select\":131071},\"WorkOrderTemplateItem\":{\"Change\":33098,\"ReadFullRecord\":65669,\"Select\":131071},\"Global\":{\"Change\":2,\"ReadFullRecord\":1,\"Select\":0},\"GlobalOps\":{\"Change\":16384,\"ReadFullRecord\":8192,\"Select\":0},\"User\":{\"Change\":2,\"ReadFullRecord\":1,\"Select\":131071},\"UserOptions\":{\"Change\":2,\"ReadFullRecord\":1,\"Select\":0},\"Widget\":{\"Change\":34,\"ReadFullRecord\":17,\"Select\":131071},\"ServerState\":{\"Change\":16384,\"ReadFullRecord\":131071,\"Select\":0},\"License\":{\"Change\":2,\"ReadFullRecord\":1,\"Select\":0},\"TrialSeeder\":{\"Change\":16386,\"ReadFullRecord\":8193,\"Select\":0},\"LogFile\":{\"Change\":0,\"ReadFullRecord\":24576,\"Select\":0},\"Backup\":{\"Change\":16384,\"ReadFullRecord\":8195,\"Select\":0},\"FileAttachment\":{\"Change\":2,\"ReadFullRecord\":3,\"Select\":0},\"ServerJob\":{\"Change\":16384,\"ReadFullRecord\":8195,\"Select\":0},\"OpsNotificationSettings\":{\"Change\":16384,\"ReadFullRecord\":8195,\"Select\":0},\"ServerMetrics\":{\"Change\":16384,\"ReadFullRecord\":24576,\"Select\":0},\"Translation\":{\"Change\":2,\"ReadFullRecord\":1,\"Select\":131071},\"DataListView\":{\"Change\":2,\"ReadFullRecord\":131071,\"Select\":0},\"FormCustom\":{\"Change\":2,\"ReadFullRecord\":131071,\"Select\":0},\"PickListTemplate\":{\"Change\":2,\"ReadFullRecord\":131071,\"Select\":0},\"BizMetrics\":{\"Change\":2,\"ReadFullRecord\":98369,\"Select\":0},\"Notification\":{\"Change\":131071,\"ReadFullRecord\":131071,\"Select\":0},\"NotifySubscription\":{\"Change\":131071,\"ReadFullRecord\":131071,\"Select\":0},\"Report\":{\"Change\":3,\"ReadFullRecord\":131071,\"Select\":131071},\"CustomerServiceRequest\":{\"Change\":4106,\"ReadFullRecord\":2437,\"Select\":131071},\"Memo\":{\"Change\":124927,\"ReadFullRecord\":124927,\"Select\":124927},\"Reminder\":{\"Change\":124927,\"ReadFullRecord\":124927,\"Select\":124927},\"Review\":{\"Change\":124927,\"ReadFullRecord\":124927,\"Select\":124927}}";
|
||||
|
||||
457
server/AyaNova/biz/TaxCodeBiz.cs
Normal file
457
server/AyaNova/biz/TaxCodeBiz.cs
Normal file
@@ -0,0 +1,457 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Linq;
|
||||
using AyaNova.Util;
|
||||
using AyaNova.Api.ControllerHelpers;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using AyaNova.Models;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace AyaNova.Biz
|
||||
{
|
||||
internal class TaxCodeBiz : BizObject, IJobObject, ISearchAbleObject, IReportAbleObject, IExportAbleObject, IImportAbleObject, INotifiableObject
|
||||
{
|
||||
internal TaxCodeBiz(AyContext dbcontext, long currentUserId, long userTranslationId, AuthorizationRoles UserRoles)
|
||||
{
|
||||
ct = dbcontext;
|
||||
UserId = currentUserId;
|
||||
UserTranslationId = userTranslationId;
|
||||
CurrentUserRoles = UserRoles;
|
||||
BizType = AyaType.TaxCode;
|
||||
}
|
||||
|
||||
internal static TaxCodeBiz GetBiz(AyContext ct, Microsoft.AspNetCore.Http.HttpContext httpContext = null)
|
||||
{
|
||||
if (httpContext != null)
|
||||
return new TaxCodeBiz(ct, UserIdFromContext.Id(httpContext.Items), UserTranslationIdFromContext.Id(httpContext.Items), UserRolesFromContext.Roles(httpContext.Items));
|
||||
else
|
||||
return new TaxCodeBiz(ct, 1, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, AuthorizationRoles.BizAdminFull);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//EXISTS
|
||||
internal async Task<bool> ExistsAsync(long id)
|
||||
{
|
||||
return await ct.TaxCode.AnyAsync(z => z.Id == id);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//CREATE
|
||||
//
|
||||
internal async Task<TaxCode> CreateAsync(TaxCode newObject)
|
||||
{
|
||||
await ValidateAsync(newObject, null);
|
||||
if (HasErrors)
|
||||
return null;
|
||||
else
|
||||
{
|
||||
newObject.Tags = TagBiz.NormalizeTags(newObject.Tags);
|
||||
newObject.CustomFields = JsonUtil.CompactJson(newObject.CustomFields);
|
||||
await ct.TaxCode.AddAsync(newObject);
|
||||
await ct.SaveChangesAsync();
|
||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct);
|
||||
await SearchIndexAsync(newObject, true);
|
||||
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null);
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Created, newObject);
|
||||
return newObject;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//DUPLICATE
|
||||
//
|
||||
internal async Task<TaxCode> DuplicateAsync(long id)
|
||||
{
|
||||
TaxCode dbObject = await GetAsync(id, false);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND, "id");
|
||||
return null;
|
||||
}
|
||||
TaxCode newObject = new TaxCode();
|
||||
CopyObject.Copy(dbObject, newObject, "Wiki");
|
||||
string newUniqueName = string.Empty;
|
||||
bool NotUnique = true;
|
||||
long l = 1;
|
||||
do
|
||||
{
|
||||
newUniqueName = Util.StringUtil.UniqueNameBuilder(dbObject.Name, l++, 255);
|
||||
NotUnique = await ct.TaxCode.AnyAsync(m => m.Name == newUniqueName);
|
||||
} while (NotUnique);
|
||||
newObject.Name = newUniqueName;
|
||||
newObject.Id = 0;
|
||||
newObject.Concurrency = 0;
|
||||
await ct.TaxCode.AddAsync(newObject);
|
||||
await ct.SaveChangesAsync();
|
||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct);
|
||||
await SearchIndexAsync(newObject, true);
|
||||
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null);
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Created, newObject);
|
||||
return newObject;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//GET
|
||||
//
|
||||
internal async Task<TaxCode> GetAsync(long id, bool logTheGetEvent = true)
|
||||
{
|
||||
var ret = await ct.TaxCode.SingleOrDefaultAsync(m => m.Id == id);
|
||||
if (logTheGetEvent && ret != null)
|
||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, id, BizType, AyaEvent.Retrieved), ct);
|
||||
return ret;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//UPDATE
|
||||
//
|
||||
internal async Task<TaxCode> PutAsync(TaxCode putObject)
|
||||
{
|
||||
TaxCode dbObject = await ct.TaxCode.SingleOrDefaultAsync(m => m.Id == putObject.Id);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND, "id");
|
||||
return null;
|
||||
}
|
||||
TaxCode SnapshotOfOriginalDBObj = new TaxCode();
|
||||
CopyObject.Copy(dbObject, SnapshotOfOriginalDBObj);
|
||||
CopyObject.Copy(putObject, dbObject, "Id");
|
||||
dbObject.Tags = TagBiz.NormalizeTags(dbObject.Tags);
|
||||
dbObject.CustomFields = JsonUtil.CompactJson(dbObject.CustomFields);
|
||||
ct.Entry(dbObject).OriginalValues["Concurrency"] = putObject.Concurrency;
|
||||
await ValidateAsync(dbObject, SnapshotOfOriginalDBObj);
|
||||
if (HasErrors) return null;
|
||||
try
|
||||
{
|
||||
await ct.SaveChangesAsync();
|
||||
}
|
||||
catch (DbUpdateConcurrencyException)
|
||||
{
|
||||
if (!await ExistsAsync(putObject.Id))
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
else
|
||||
AddError(ApiErrorCode.CONCURRENCY_CONFLICT);
|
||||
return null;
|
||||
}
|
||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, BizType, AyaEvent.Modified), ct);
|
||||
await SearchIndexAsync(dbObject, false);
|
||||
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags);
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Modified, dbObject, SnapshotOfOriginalDBObj);
|
||||
return dbObject;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//DELETE
|
||||
//
|
||||
internal async Task<bool> DeleteAsync(long id)
|
||||
{
|
||||
using (var transaction = await ct.Database.BeginTransactionAsync())
|
||||
{
|
||||
try
|
||||
{
|
||||
TaxCode dbObject = await ct.TaxCode.SingleOrDefaultAsync(m => m.Id == id);
|
||||
if (dbObject == null)
|
||||
{
|
||||
AddError(ApiErrorCode.NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
ValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.TaxCode.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Log event
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
await Search.ProcessDeletedObjectKeywordsAsync(dbObject.Id, BizType, ct);
|
||||
await TagBiz.ProcessDeleteTagsInRepositoryAsync(ct, dbObject.Tags);
|
||||
await FileUtil.DeleteAttachmentsForObjectAsync(BizType, dbObject.Id, ct);
|
||||
await transaction.CommitAsync();
|
||||
await HandlePotentialNotificationEvent(AyaEvent.Deleted, dbObject);
|
||||
}
|
||||
catch
|
||||
{
|
||||
//Just re-throw for now, let exception handler deal, but in future may want to deal with this more here
|
||||
throw;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//SEARCH
|
||||
//
|
||||
private async Task SearchIndexAsync(TaxCode obj, bool isNew)
|
||||
{
|
||||
var SearchParams = new Search.SearchIndexProcessObjectParameters(UserTranslationId, obj.Id, BizType);
|
||||
DigestSearchText(obj, SearchParams);
|
||||
if (isNew)
|
||||
await Search.ProcessNewObjectKeywordsAsync(SearchParams);
|
||||
else
|
||||
await Search.ProcessUpdatedObjectKeywordsAsync(SearchParams);
|
||||
}
|
||||
|
||||
public async Task<Search.SearchIndexProcessObjectParameters> GetSearchResultSummary(long id)
|
||||
{
|
||||
var obj = await ct.TaxCode.SingleOrDefaultAsync(z => z.Id == id);
|
||||
var SearchParams = new Search.SearchIndexProcessObjectParameters();
|
||||
DigestSearchText(obj, SearchParams);
|
||||
return SearchParams;
|
||||
}
|
||||
|
||||
public void DigestSearchText(TaxCode obj, Search.SearchIndexProcessObjectParameters searchParams)
|
||||
{
|
||||
if (obj != null)
|
||||
searchParams.AddText(obj.Notes)
|
||||
.AddText(obj.Name)
|
||||
.AddText(obj.Wiki)
|
||||
.AddText(obj.Tags)
|
||||
.AddText(obj.TaxA)
|
||||
.AddText(obj.TaxB)
|
||||
.AddCustomFields(obj.CustomFields);
|
||||
}
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//VALIDATION
|
||||
//
|
||||
|
||||
private async Task ValidateAsync(TaxCode proposedObj, TaxCode currentObj)
|
||||
{
|
||||
|
||||
bool isNew = currentObj == null;
|
||||
|
||||
//Name required
|
||||
if (string.IsNullOrWhiteSpace(proposedObj.Name))
|
||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, "Name");
|
||||
|
||||
|
||||
|
||||
//If name is otherwise OK, check that name is unique
|
||||
if (!PropertyHasErrors("Name"))
|
||||
{
|
||||
//Use Any command is efficient way to check existance, it doesn't return the record, just a true or false
|
||||
if (await ct.TaxCode.AnyAsync(m => m.Name == proposedObj.Name && m.Id != proposedObj.Id))
|
||||
{
|
||||
AddError(ApiErrorCode.VALIDATION_NOT_UNIQUE, "Name");
|
||||
}
|
||||
}
|
||||
|
||||
//MIGRATE_OUTSTANDING - Biz rule needs porting
|
||||
//BrokenRules.Assert("DefaultMustBeActive", "TaxCode.Error.Default","Active",value==false && AyaBizUtils.GlobalSettings.TaxCodeIsADefault(this.mID));
|
||||
|
||||
|
||||
//Any form customizations to validate?
|
||||
var FormCustomization = await ct.FormCustom.AsNoTracking().SingleOrDefaultAsync(x => x.FormKey == AyaType.TaxCode.ToString());
|
||||
if (FormCustomization != null)
|
||||
{
|
||||
//Yeppers, do the validation, there are two, the custom fields and the regular fields that might be set to required
|
||||
|
||||
//validate users choices for required non custom fields
|
||||
RequiredFieldsValidator.Validate(this, FormCustomization, proposedObj);
|
||||
|
||||
//validate custom fields
|
||||
CustomFieldsValidator.Validate(this, FormCustomization, proposedObj.CustomFields);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void ValidateCanDelete(TaxCode inObj)
|
||||
{
|
||||
//whatever needs to be check to delete this object
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//REPORTING
|
||||
//
|
||||
public async Task<JArray> GetReportData(long[] idList)
|
||||
{
|
||||
JArray ReportData = new JArray();
|
||||
while (idList.Any())
|
||||
{
|
||||
var batch = idList.Take(IReportAbleObject.REPORT_DATA_BATCH_SIZE);
|
||||
idList = idList.Skip(IReportAbleObject.REPORT_DATA_BATCH_SIZE).ToArray();
|
||||
//query for this batch, comes back in db natural order unfortunately
|
||||
var batchResults = await ct.TaxCode.Where(z => batch.Contains(z.Id)).ToArrayAsync();
|
||||
//order the results back into original
|
||||
var orderedList = from id in batch join z in batchResults on id equals z.Id select z;
|
||||
foreach (TaxCode w in orderedList)
|
||||
{
|
||||
var jo = JObject.FromObject(w);
|
||||
if (!JsonUtil.JTokenIsNullOrEmpty(jo["CustomFields"]))
|
||||
jo["CustomFields"] = JObject.Parse((string)jo["CustomFields"]);
|
||||
ReportData.Add(jo);
|
||||
}
|
||||
}
|
||||
return ReportData;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// IMPORT EXPORT
|
||||
//
|
||||
|
||||
|
||||
public async Task<JArray> GetExportData(long[] idList)
|
||||
{
|
||||
//for now just re-use the report data code
|
||||
//this may turn out to be the pattern for most biz object types but keeping it seperate allows for custom usage from time to time
|
||||
return await GetReportData(idList);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public async Task<List<string>> ImportData(JArray ja)
|
||||
{
|
||||
List<string> ImportResult = new List<string>();
|
||||
string ImportTag = $"imported-{FileUtil.GetSafeDateFileName()}";
|
||||
|
||||
var jsset = JsonSerializer.CreateDefault(new JsonSerializerSettings { ContractResolver = new AyaNova.Util.JsonUtil.ShouldSerializeContractResolver(new string[] { "Concurrency", "Id", "CustomFields" }) });
|
||||
foreach (JObject j in ja)
|
||||
{
|
||||
var w = j.ToObject<TaxCode>(jsset);
|
||||
if (j["CustomFields"] != null)
|
||||
w.CustomFields = j["CustomFields"].ToString();
|
||||
w.Tags.Add(ImportTag);//so user can find them all and revert later if necessary
|
||||
var res = await CreateAsync(w);
|
||||
if (res == null)
|
||||
{
|
||||
ImportResult.Add($"* {w.Name} - {this.GetErrorsAsString()}");
|
||||
this.ClearErrors();
|
||||
}
|
||||
else
|
||||
{
|
||||
ImportResult.Add($"{w.Name} - ok");
|
||||
}
|
||||
}
|
||||
return ImportResult;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//JOB / OPERATIONS
|
||||
//
|
||||
public async Task HandleJobAsync(OpsJob job)
|
||||
{
|
||||
//Hand off the particular job to the corresponding processing code
|
||||
//NOTE: If this code throws an exception the caller (JobsBiz::ProcessJobsAsync) will automatically set the job to failed and log the exeption so
|
||||
//basically any error condition during job processing should throw up an exception if it can't be handled
|
||||
switch (job.JobType)
|
||||
{
|
||||
case JobType.BatchCoreObjectOperation:
|
||||
await ProcessBatchJobAsync(job);
|
||||
break;
|
||||
default:
|
||||
throw new System.ArgumentOutOfRangeException($"TaxCodeBiz.HandleJob-> Invalid job type{job.JobType.ToString()}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private async Task ProcessBatchJobAsync(OpsJob job)
|
||||
{
|
||||
await JobsBiz.UpdateJobStatusAsync(job.GId, JobStatus.Running);
|
||||
await JobsBiz.LogJobAsync(job.GId, $"LT:StartJob {job.SubType}");
|
||||
List<long> idList = new List<long>();
|
||||
long FailedObjectCount = 0;
|
||||
JObject jobData = JObject.Parse(job.JobInfo);
|
||||
if (jobData.ContainsKey("idList"))
|
||||
idList = ((JArray)jobData["idList"]).ToObject<List<long>>();
|
||||
else
|
||||
idList = await ct.TaxCode.Select(z => z.Id).ToListAsync();
|
||||
bool SaveIt = false;
|
||||
foreach (long id in idList)
|
||||
{
|
||||
try
|
||||
{
|
||||
SaveIt = false;
|
||||
ClearErrors();
|
||||
TaxCode o = null;
|
||||
//save a fetch if it's a delete
|
||||
if (job.SubType != JobSubType.Delete)
|
||||
o = await GetAsync(id, false);
|
||||
switch (job.SubType)
|
||||
{
|
||||
case JobSubType.TagAddAny:
|
||||
case JobSubType.TagAdd:
|
||||
case JobSubType.TagRemoveAny:
|
||||
case JobSubType.TagRemove:
|
||||
case JobSubType.TagReplaceAny:
|
||||
case JobSubType.TagReplace:
|
||||
SaveIt = TagBiz.ProcessBatchTagOperation(o.Tags, (string)jobData["tag"], jobData.ContainsKey("toTag") ? (string)jobData["toTag"] : null, job.SubType);
|
||||
break;
|
||||
case JobSubType.Delete:
|
||||
if (!await DeleteAsync(id))
|
||||
{
|
||||
await JobsBiz.LogJobAsync(job.GId, $"LT:Errors {GetErrorsAsString()} id {id}");
|
||||
FailedObjectCount++;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new System.ArgumentOutOfRangeException($"ProcessBatchJobAsync -> Invalid job Subtype{job.SubType}");
|
||||
}
|
||||
if (SaveIt)
|
||||
{
|
||||
o = await PutAsync(o);
|
||||
if (o == null)
|
||||
{
|
||||
await JobsBiz.LogJobAsync(job.GId, $"LT:Errors {GetErrorsAsString()} id {id}");
|
||||
FailedObjectCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await JobsBiz.LogJobAsync(job.GId, $"LT:Errors id({id})");
|
||||
await JobsBiz.LogJobAsync(job.GId, ExceptionUtil.ExtractAllExceptionMessages(ex));
|
||||
}
|
||||
}
|
||||
await JobsBiz.LogJobAsync(job.GId, $"LT:BatchJob {job.SubType} {idList.Count}{(FailedObjectCount > 0 ? " - LT:Failed " + FailedObjectCount : "")}");
|
||||
await JobsBiz.UpdateJobStatusAsync(job.GId, JobStatus.Completed);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// NOTIFICATION PROCESSING
|
||||
//
|
||||
public async Task HandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel proposedObj, ICoreBizObjectModel currentObj = null)
|
||||
{
|
||||
ILogger log = AyaNova.Util.ApplicationLogging.CreateLogger<TaxCodeBiz>();
|
||||
if (ServerBootConfig.SEEDING) return;
|
||||
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{this.BizType}, AyaEvent:{ayaEvent}]");
|
||||
|
||||
bool isNew = currentObj == null;
|
||||
|
||||
|
||||
//STANDARD EVENTS FOR ALL OBJECTS
|
||||
await NotifyEventHelper.ProcessStandardObjectEvents(ayaEvent, proposedObj, ct);
|
||||
|
||||
//SPECIFIC EVENTS FOR THIS OBJECT
|
||||
|
||||
}//end of process notifications
|
||||
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
}//eoc
|
||||
|
||||
|
||||
}//eons
|
||||
|
||||
@@ -53,6 +53,7 @@ namespace AyaNova.Models
|
||||
public virtual DbSet<Unit> Unit { get; set; }
|
||||
public virtual DbSet<UnitModel> UnitModel { get; set; }
|
||||
public virtual DbSet<Vendor> Vendor { get; set; }
|
||||
public virtual DbSet<TaxCode> TaxCode { get; set; }
|
||||
public virtual DbSet<ServiceRate> ServiceRate { get; set; }
|
||||
public virtual DbSet<TravelRate> TravelRate { get; set; }
|
||||
|
||||
|
||||
58
server/AyaNova/models/TaxCode.cs
Normal file
58
server/AyaNova/models/TaxCode.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using AyaNova.Biz;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace AyaNova.Models
|
||||
{
|
||||
//NOTE: Any non required field (nullable in DB) sb nullable here, i.e. decimal? not decimal,
|
||||
//otherwise the server will call it an invalid record if the field isn't sent from client
|
||||
|
||||
public class TaxCode : ICoreBizObjectModel
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public uint Concurrency { get; set; }
|
||||
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
public bool Active { get; set; }
|
||||
public string Notes { get; set; }
|
||||
public string Wiki { get; set; }
|
||||
public string CustomFields { get; set; }
|
||||
public List<string> Tags { get; set; }
|
||||
|
||||
[Required]
|
||||
public decimal TaxA { get; set; }
|
||||
[Required]
|
||||
public decimal TaxB { get; set; }
|
||||
public bool TaxOnTax { get; set; }
|
||||
|
||||
public TaxCode()
|
||||
{
|
||||
Tags = new List<string>();
|
||||
}
|
||||
|
||||
[NotMapped, JsonIgnore]
|
||||
public AyaType AyaType { get => AyaType.TaxCode; }
|
||||
|
||||
}//eoc
|
||||
|
||||
}//eons
|
||||
/*
|
||||
CREATE TABLE [dbo].[ATAXCODE](
|
||||
[AID] [uniqueidentifier] NOT NULL,
|
||||
[ACREATED] [datetime] NOT NULL,
|
||||
[AMODIFIED] [datetime] NOT NULL,
|
||||
[AACTIVE] [bit] NOT NULL,
|
||||
[ACREATOR] [uniqueidentifier] NOT NULL,
|
||||
[AMODIFIER] [uniqueidentifier] NOT NULL,
|
||||
[ANAME] [nvarchar](255) NOT NULL,
|
||||
[ATAXA] [decimal](19, 5) NOT NULL,
|
||||
[ATAXB] [decimal](19, 5) NOT NULL,
|
||||
[ATAXAEXEMPT] [bit] NOT NULL,//remove
|
||||
[ATAXBEXEMPT] [bit] NOT NULL,//remove
|
||||
[ATAXONTAX] [bit] NOT NULL,
|
||||
PRIMARY KEY NONCLUSTERED
|
||||
*/
|
||||
@@ -2063,5 +2063,21 @@
|
||||
"TravelRateCustom13": "Angepasstes Feld 13",
|
||||
"TravelRateCustom14": "Angepasstes Feld 14",
|
||||
"TravelRateCustom15": "Angepasstes Feld 15",
|
||||
"TravelRateCustom16": "Angepasstes Feld 16"
|
||||
"TravelRateCustom16": "Angepasstes Feld 16",
|
||||
"TaxCodeCustom1": "Angepasstes Feld 1",
|
||||
"TaxCodeCustom2": "Angepasstes Feld 2",
|
||||
"TaxCodeCustom3": "Angepasstes Feld 3",
|
||||
"TaxCodeCustom4": "Angepasstes Feld 4",
|
||||
"TaxCodeCustom5": "Angepasstes Feld 5",
|
||||
"TaxCodeCustom6": "Angepasstes Feld 6",
|
||||
"TaxCodeCustom7": "Angepasstes Feld 7",
|
||||
"TaxCodeCustom8": "Angepasstes Feld 8",
|
||||
"TaxCodeCustom9": "Angepasstes Feld 9",
|
||||
"TaxCodeCustom10": "Angepasstes Feld 10",
|
||||
"TaxCodeCustom11": "Angepasstes Feld 11",
|
||||
"TaxCodeCustom12": "Angepasstes Feld 12",
|
||||
"TaxCodeCustom13": "Angepasstes Feld 13",
|
||||
"TaxCodeCustom14": "Angepasstes Feld 14",
|
||||
"TaxCodeCustom15": "Angepasstes Feld 15",
|
||||
"TaxCodeCustom16": "Angepasstes Feld 16"
|
||||
}
|
||||
@@ -2063,5 +2063,21 @@
|
||||
"TravelRateCustom13": "Custom13",
|
||||
"TravelRateCustom14": "Custom14",
|
||||
"TravelRateCustom15": "Custom15",
|
||||
"TravelRateCustom16": "Custom16"
|
||||
"TravelRateCustom16": "Custom16",
|
||||
"TaxCodeCustom1": "Custom1",
|
||||
"TaxCodeCustom2": "Custom2",
|
||||
"TaxCodeCustom3": "Custom3",
|
||||
"TaxCodeCustom4": "Custom4",
|
||||
"TaxCodeCustom5": "Custom5",
|
||||
"TaxCodeCustom6": "Custom6",
|
||||
"TaxCodeCustom7": "Custom7",
|
||||
"TaxCodeCustom8": "Custom8",
|
||||
"TaxCodeCustom9": "Custom9",
|
||||
"TaxCodeCustom10": "Custom10",
|
||||
"TaxCodeCustom11": "Custom11",
|
||||
"TaxCodeCustom12": "Custom12",
|
||||
"TaxCodeCustom13": "Custom13",
|
||||
"TaxCodeCustom14": "Custom14",
|
||||
"TaxCodeCustom15": "Custom15",
|
||||
"TaxCodeCustom16": "Custom16"
|
||||
}
|
||||
@@ -2063,5 +2063,21 @@
|
||||
"TravelRateCustom13": "Campo personalizado 13",
|
||||
"TravelRateCustom14": "Campo personalizado 14",
|
||||
"TravelRateCustom15": "Campo personalizado 15",
|
||||
"TravelRateCustom16": "Campo personalizado 16"
|
||||
"TravelRateCustom16": "Campo personalizado 16",
|
||||
"TaxCodeCustom1": "Campo personalizado 1",
|
||||
"TaxCodeCustom2": "Campo personalizado 2",
|
||||
"TaxCodeCustom3": "Campo personalizado 3",
|
||||
"TaxCodeCustom4": "Campo personalizado 4",
|
||||
"TaxCodeCustom5": "Campo personalizado 5",
|
||||
"TaxCodeCustom6": "Campo personalizado 6",
|
||||
"TaxCodeCustom7": "Campo personalizado 7",
|
||||
"TaxCodeCustom8": "Campo personalizado 8",
|
||||
"TaxCodeCustom9": "Campo personalizado 9",
|
||||
"TaxCodeCustom10": "Campo personalizado 10",
|
||||
"TaxCodeCustom11": "Campo personalizado 11",
|
||||
"TaxCodeCustom12": "Campo personalizado 12",
|
||||
"TaxCodeCustom13": "Campo personalizado 13",
|
||||
"TaxCodeCustom14": "Campo personalizado 14",
|
||||
"TaxCodeCustom15": "Campo personalizado 15",
|
||||
"TaxCodeCustom16": "Campo personalizado 16"
|
||||
}
|
||||
@@ -2063,5 +2063,21 @@
|
||||
"TravelRateCustom13": "Champ personnalisé 13",
|
||||
"TravelRateCustom14": "Champ personnalisé 14",
|
||||
"TravelRateCustom15": "Champ personnalisé 15",
|
||||
"TravelRateCustom16": "Champ personnalisé 16"
|
||||
"TravelRateCustom16": "Champ personnalisé 16",
|
||||
"TaxCodeCustom1": "Champ personnalisé 1",
|
||||
"TaxCodeCustom2": "Champ personnalisé 2",
|
||||
"TaxCodeCustom3": "Champ personnalisé 3",
|
||||
"TaxCodeCustom4": "Champ personnalisé 4",
|
||||
"TaxCodeCustom5": "Champ personnalisé 5",
|
||||
"TaxCodeCustom6": "Champ personnalisé 6",
|
||||
"TaxCodeCustom7": "Champ personnalisé 7",
|
||||
"TaxCodeCustom8": "Champ personnalisé 8",
|
||||
"TaxCodeCustom9": "Champ personnalisé 9",
|
||||
"TaxCodeCustom10": "Champ personnalisé 10",
|
||||
"TaxCodeCustom11": "Champ personnalisé 11",
|
||||
"TaxCodeCustom12": "Champ personnalisé 12",
|
||||
"TaxCodeCustom13": "Champ personnalisé 13",
|
||||
"TaxCodeCustom14": "Champ personnalisé 14",
|
||||
"TaxCodeCustom15": "Champ personnalisé 15",
|
||||
"TaxCodeCustom16": "Champ personnalisé 16"
|
||||
}
|
||||
@@ -22,8 +22,8 @@ namespace AyaNova.Util
|
||||
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!!
|
||||
private const int DESIRED_SCHEMA_LEVEL = 15;
|
||||
|
||||
internal const long EXPECTED_COLUMN_COUNT = 560;
|
||||
internal const long EXPECTED_INDEX_COUNT = 167;
|
||||
internal const long EXPECTED_COLUMN_COUNT = 570;
|
||||
internal const long EXPECTED_INDEX_COUNT = 171;
|
||||
|
||||
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!!
|
||||
|
||||
@@ -315,8 +315,8 @@ END;
|
||||
$BODY$;
|
||||
");
|
||||
|
||||
//Name fetcher function
|
||||
await ExecQueryAsync(@"
|
||||
//Name fetcher function
|
||||
await ExecQueryAsync(@"
|
||||
CREATE OR REPLACE FUNCTION PUBLIC.AYGETNAME(IN AYOBJECTID bigint, IN AYOBJECTTYPE integer) RETURNS text AS $BODY$
|
||||
DECLARE
|
||||
aytable TEXT DEFAULT '';
|
||||
@@ -388,6 +388,9 @@ BEGIN
|
||||
when 59 then aytable = 'acustomernote';
|
||||
when 60 then aytable = 'amemo';
|
||||
when 61 then aytable = 'areview';
|
||||
when 62 then aytable = 'aservicerate';
|
||||
when 63 then aytable = 'atravelrate';
|
||||
when 64 then aytable = 'ataxcode';
|
||||
else
|
||||
RETURN format('??PUBLIC.AYGETNAME-UNKNOWN_TYPE:%S',ayobjecttype);-- This should not happen unless dev forgot to update this
|
||||
end case;
|
||||
@@ -396,7 +399,7 @@ BEGIN
|
||||
END;
|
||||
$BODY$ LANGUAGE PLPGSQL STABLE");
|
||||
|
||||
//Usage: select created, textra, AYGETNAME(aevent.ayid, aevent.ayatype) as name from aevent order by created
|
||||
//Usage: select created, textra, AYGETNAME(aevent.ayid, aevent.ayatype) as name from aevent order by created
|
||||
|
||||
|
||||
//create translation text tables
|
||||
@@ -565,7 +568,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
|
||||
{
|
||||
LogUpdateMessage(log);
|
||||
|
||||
//SERVICERATE
|
||||
//SERVICERATE
|
||||
await ExecQueryAsync("CREATE TABLE aservicerate (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name text not null unique, active bool, " +
|
||||
"notes text, wiki text, customfields text, tags varchar(255) ARRAY, " +
|
||||
"accountnumber text, unit text, cost decimal(19,4) not null default 0, charge decimal(19,4) not null default 0)");
|
||||
@@ -579,6 +582,13 @@ $BODY$ LANGUAGE PLPGSQL STABLE");
|
||||
await ExecQueryAsync("CREATE UNIQUE INDEX atravelrate_name_id_idx ON atravelrate (id, name);");
|
||||
await ExecQueryAsync("CREATE INDEX atravelrate_tags ON atravelrate using GIN(tags)");
|
||||
|
||||
//TAXCODE
|
||||
await ExecQueryAsync("CREATE TABLE ataxcode (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name text not null unique, active bool, " +
|
||||
"notes text, wiki text, customfields text, tags varchar(255) ARRAY, " +
|
||||
"taxa decimal(19,4) not null default 0, taxb decimal(19,4) not null default 0, taxontax bool not null default false)");
|
||||
await ExecQueryAsync("CREATE UNIQUE INDEX ataxcode_name_id_idx ON ataxcode (id, name);");
|
||||
await ExecQueryAsync("CREATE INDEX ataxcode_tags ON ataxcode using GIN(tags)");
|
||||
|
||||
//MEMO
|
||||
await ExecQueryAsync("CREATE TABLE amemo (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name text not null, " +
|
||||
"notes text, wiki text, customfields text, tags varchar(255) ARRAY, " +
|
||||
|
||||
@@ -367,6 +367,8 @@ namespace AyaNova.Util
|
||||
await EraseTableAsync("aservicerate", conn);
|
||||
await EraseTableAsync("atravelrate", conn);
|
||||
|
||||
await EraseTableAsync("ataxcode", conn);
|
||||
|
||||
|
||||
//Delete from user options table first
|
||||
using (var cmd = new Npgsql.NpgsqlCommand())
|
||||
|
||||
Reference in New Issue
Block a user