Files
Christoph Schwörer f045b99a25 Codebasis als Dateien ins Arbeitsrepo statt als Gitlink
QuellCode/CentronERP war nur als Gitlink (Submodul-Referenz auf 79c1142)
getrackt, ohne .gitmodules und ohne erreichbares Remote. Der
Untersuchungsgegenstand der Versuchsreihe war damit nicht reproduzierbar
gesichert: Ein Klon haette ein leeres Verzeichnis erhalten, und die Belege
der 3.287 Anforderungen waeren nicht ueberpruefbar gewesen.

Umstellung:
- Historie nach c:\DEV\CentronERP_git_snapshot_79c1142 ausgelagert
  (vollstaendig lesbar, enthaelt 79c1142 und Vorgaenger 89ccfd6)
- Gitlink aus dem Index entfernt
- Dateiinhalt aufgenommen: 24.557 Dateien, rund 333 MB

Die verschachtelte .gitignore der Codebasis gilt weiter, Build-Artefakte
bleiben ausgeschlossen. Details in Versuche/Versuch_01/_Codebasis-Nachweis.md
2026-08-26 07:43:51 +02:00

167 lines
7.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using Centron.BusinessLogic.Sales.CustomerAssets.Shared;
using Centron.BusinessLogic.Sales.Customers;
using Centron.BusinessLogic.Sales.Receipts.Internal;
using Centron.BusinessLogic.WebServices.Accounts.SpecialPrices;
using Centron.BusinessLogic.WebServices.Sales.CustomerAssets.Shared;
using Centron.BusinessLogic.WebServices.Sales.Receipts;
using Centron.Data.WebServices.Warehousing;
using Centron.Interfaces;
using Centron.Interfaces.BL;
using Centron.Tests.EndToEnd.Infrastructure;
using CentronSoftware.Centron.WebServices.Entities.Accounts.SpecialPrices;
using CentronSoftware.Centron.WebServices.Entities.Warehousing;
using Xunit;
using Xunit.Abstractions;
namespace Centron.Tests.EndToEnd.TicketTests.Ticket136129;
public class Ticket136129Test : EndToEndTest
{
public Ticket136129Test(ITestOutputHelper testOutputHelper)
: base(testOutputHelper)
{
}
public const int ArticleI3D = 12;
public const int CustomerI3D = 10000;
public override void Execute()
{
// In this ticket the problem was, that the globally configured default project-prices (SpecialAgreement in code)
// for offers/orders/etc were not used in all cases
// They were only used, when the project-price was for specific articles
// Now it seems like, it should also work, if it's for all articles
//
// I talked with Steve Marek about it, and we decided on the following logic
// 1. If the project-price is assigned to a customer, then it should only be used, if the article is in the project-price
// 2. If the project-price is setup as a default one for offers/orders/etc, then it should always be used
//
// That's it, nothing more
// There was a 3. level to it, all project-prices that had the "Is Global" flag set, but we don't want that anymore
this.ExecuteMatrix(
new[] { false, true },
new[] { ProjectPriceAssignment.None, ProjectPriceAssignment.Customer, ProjectPriceAssignment.GlobalDefault, ProjectPriceAssignment.IsGlobal },
(includeArticleInProjectPrice, assignment) =>
{
bool expectProjectPriceToBeUsed = (includeArticleInProjectPrice, assignment) switch
{
(_, ProjectPriceAssignment.GlobalDefault) => true,
(true, ProjectPriceAssignment.Customer) => true,
_ => false,
};
SetupProjectPrices(includeArticleInProjectPrice, assignment);
this.WithSession(s =>
{
var customer = s.GetBL<CustomerBL>().GetCustomer(CustomerI3D);
var projectPrice = s.GetBL<ReceiptItemPriceBL>().GetSpecialAgreement(ArticleI3D, customer, CentronObjectKindNumeric.OfferClass);
if (expectProjectPriceToBeUsed)
{
Assert.NotNull(projectPrice);
}
else
{
Assert.Null(projectPrice);
}
});
});
}
private void SetupProjectPrices(bool includeArticleInProjectPrice, ProjectPriceAssignment assignment)
{
ClearAllProjectPrices();
var projectPrice = CreateProjectPrice();
TryAssignProjectPriceToCustomer(projectPrice);
TryAssignProjectPriceGlobally(projectPrice);
void ClearAllProjectPrices()
{
// Drop all those tables to reset everything about project-prices
this.Sql($"DELETE FROM KundenSonderpreise");
this.Sql($"DELETE FROM SondervereinbarungsArtikel");
this.Sql($"DELETE FROM Sondervereinbarung");
var receiptSettings = this.WithSession(s => s.GetBL<ReceiptWebServiceBL>().GetReceiptSettings(this.GetLoggedInUser().User));
receiptSettings.OfferHasGlobalSpecialAgreement = false;
receiptSettings.OfferGlobalSpecialAgreementI3D = 0;
receiptSettings.OrderHasGlobalSpecialAgreement = false;
receiptSettings.OrderGlobalSpecialAgreementI3D = 0;
receiptSettings.DeliveryListHasGlobalSpecialAgreement = false;
receiptSettings.DeliveryListGlobalSpecialAgreementI3D = 0;
receiptSettings.InvoiceHasGlobalSpecialAgreement = false;
receiptSettings.InvoiceGlobalSpecialAgreementI3D = 0;
this.WithSession(s => s.GetBL<ReceiptWebServiceBL>().UpdateReceiptSettings(receiptSettings, this.GetLoggedInUser().User)).ThrowIfError();
}
SpecialAgreementDTO CreateProjectPrice()
{
var newProjectPrice = this.WithSession(s => s.GetBL<SpecialAgreementWebServiceBL>().CreateNew(this.GetLoggedInUser().User));
newProjectPrice.Text = "Test Project Price";
newProjectPrice.Number = "123";
newProjectPrice.IsProjectPrice = true;
newProjectPrice.Articles = new List<SpecialAgreementArticleDTO>();
newProjectPrice.IsGlobal = assignment is ProjectPriceAssignment.IsGlobal;
if (includeArticleInProjectPrice)
{
newProjectPrice.Articles.Add(new SpecialAgreementArticleDTO
{
Article = new ArticleDTO { I3D = ArticleI3D },
State = 1,
});
}
return this.WithSession(s => s.GetBL<SpecialAgreementWebServiceBL>().SaveOrUpdate(newProjectPrice, this.GetLoggedInUser().User)).ThrowIfError();
}
void TryAssignProjectPriceToCustomer(SpecialAgreementDTO projectPrice)
{
if (assignment is not ProjectPriceAssignment.Customer)
return;
var accountSpecialPrice = new AccountSpecialPriceDTO
{
ObjectKind = CentronObjectKindNumeric.CustomerClass,
ObjectI3D = CustomerI3D,
SpecialAgreementI3D = projectPrice.I3D,
SpecialAgreementCaption = projectPrice.Text,
};
this.WithSession(s => s.GetBL<AccountSpecialPriceWebServiceBL>().SaveAccountSpecialPrice(this.GetLoggedInUser().User, accountSpecialPrice));
}
void TryAssignProjectPriceGlobally(SpecialAgreementDTO projectPrice)
{
if (assignment is not ProjectPriceAssignment.GlobalDefault)
return;
var receiptSettings = this.WithSession(s => s.GetBL<ReceiptWebServiceBL>().GetReceiptSettings(this.GetLoggedInUser().User));
receiptSettings.OfferHasGlobalSpecialAgreement = true;
receiptSettings.OfferGlobalSpecialAgreementI3D = projectPrice.I3D;
this.WithSession(s => s.GetBL<ReceiptWebServiceBL>().UpdateReceiptSettings(receiptSettings, this.GetLoggedInUser().User)).ThrowIfError();
}
}
public enum ProjectPriceAssignment
{
None,
Customer,
GlobalDefault,
IsGlobal,
}
}