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
292 lines
12 KiB
C#
292 lines
12 KiB
C#
using Centron.BusinessLogic;
|
|
using Centron.BusinessLogic.EmployeeArea;
|
|
using Centron.BusinessLogic.Sales.Receipts.DataAndResults;
|
|
using Centron.BusinessLogic.Warehousing;
|
|
using Centron.BusinessLogic.WebServices.Sales.Receipts;
|
|
using Centron.BusinessLogic.WebServices.Warehousing;
|
|
using Centron.Data.Entities.Administration.Logins;
|
|
using Centron.Data.WebServices.Sales.Receipts.DeliveryLists;
|
|
using Centron.Data.WebServices.Sales.Receipts.Invoices;
|
|
using Centron.Interfaces;
|
|
using Centron.Interfaces.Administration.Environment;
|
|
using Centron.Interfaces.Sales.Receipts;
|
|
using Centron.Interfaces.Sales.Receipts.InsertReceipts;
|
|
using Centron.Interfaces.Warehousing;
|
|
using Centron.Tests.EndToEnd.Infrastructure;
|
|
using Centron.Tests.EndToEnd.Infrastructure.Verifier;
|
|
using CentronSoftware.Centron.WebServices.EntitiesWrongPlace.Sales.Receipts.DataAndResults;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Xunit;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace Centron.Tests.EndToEnd.TicketTests.Ticket104691
|
|
{
|
|
/// <summary>
|
|
/// When you did the following actions, you would run into a problem:
|
|
/// 1. Create delivery-list with a barcode
|
|
/// 2. Save delivery-list
|
|
/// 3. Forward to invoice and save the invoice
|
|
/// 4. Create new version in the delivery-list and save it
|
|
///
|
|
/// Now you will have an issue with the barcode, the SeriennummerToPosition IsActive is in the invoice.
|
|
/// And of course, there will be one more SeriennummerToPosition entry for the delivery-list in version 1.
|
|
/// BUT, because we created a new version 2 of the delivery-list after the invoice was created, there was no SeriennummerToPosition for the delivery-list version 2.
|
|
///
|
|
/// This test makes sure that we create the SeriennummerToPosition for version 2.
|
|
/// </summary>
|
|
public class Ticket104691Test : EndToEndTest
|
|
{
|
|
public const string Barcode = "100072017";
|
|
public const int BarcodeI3D = 3678;
|
|
public const int ArticleI3D = 1256;
|
|
|
|
public Ticket104691Test(ITestOutputHelper testOutputHelper)
|
|
: base(testOutputHelper)
|
|
{
|
|
// We have a bit of flakiness with this property, if the code is VERY FAST, it will be the same value as CreatedDate and ChangedDate
|
|
// But if the code is a bit slower, it will get a different value, and the Verifier will treat it as an error
|
|
// It's annoying, and I don't wanna deal with this issue right now, so ignore the property for now
|
|
this.Verifier.Settings.IgnoreProperty<ReceiptInvoiceDTO>(f => f.VariableDateField);
|
|
}
|
|
|
|
public override void Execute()
|
|
{
|
|
this.PrepareDatabase();
|
|
|
|
var deliveryListI3D = this.CreateDeliveryList();
|
|
this.VerifyBarcodeTables("AfterDeliveryListCreated");
|
|
|
|
this.ForwardDeliveryListToInvoice(deliveryListI3D);
|
|
this.VerifyBarcodeTables("AfterForwardToInvoice");
|
|
|
|
this.CreateNewVersion(deliveryListI3D);
|
|
this.VerifyBarcodeTables("AfterNewDeliveryListVersion");
|
|
|
|
this.VerifyBarcodeIsStillInDeliveryList(deliveryListI3D);
|
|
}
|
|
|
|
private void PrepareDatabase()
|
|
{
|
|
// There is no Bankverbindung for the customer 10022 - but we are creating invoices for him
|
|
// So we just move the existing Bankverbindung to customer 10022, so he can use it for this test
|
|
this.Sql("UPDATE dbo.Bankverbindungen SET ObjectI3D = 10022");
|
|
}
|
|
|
|
private int CreateDeliveryList()
|
|
{
|
|
ReceiptDeliveryListDTO deliveryList;
|
|
|
|
using (var session = new BLSession())
|
|
{
|
|
var user = session.GetBL<AppUserBL>().GetAppUser(f => f.I3D == 11);
|
|
var result = session.GetBL<ReceiptWebServiceBL>().CreateNewReceipt(
|
|
CentronObjectKindNumeric.DeliveryListClass,
|
|
new LoggedInUser(user),
|
|
customerI3D: 10022,
|
|
new CreateReceiptData(),
|
|
addressI3D: null,
|
|
contactPersonI3D: null,
|
|
insertSalutationAndAgreement: true,
|
|
ignoreDefaultContract: false,
|
|
insertCustomerDiscount: true);
|
|
|
|
this.Verifier.Verify("NewDeliveryList", result);
|
|
|
|
var receiptItem = session.GetBL<ReceiptItemWebServiceBL>().CreateArticleReceiptItems(
|
|
result.Data.Receipt,
|
|
isExternalArticle: false,
|
|
ArticleI3D,
|
|
externalArticleKind: null,
|
|
externalArticleId: null,
|
|
warehouseI3D: -1,
|
|
new LoggedInUser(user));
|
|
this.Verifier.Verify("DeliveryListReceiptItem", receiptItem);
|
|
|
|
deliveryList = (ReceiptDeliveryListDTO)result.Data.Receipt;
|
|
deliveryList.VariableComboBoxFieldI3D = 10;
|
|
deliveryList.Items.AddRange(receiptItem.Data.ReceiptItems.Cast<ReceiptDeliveryListItemDTO>());
|
|
this.Verifier.Verify("DeliveryListWithReceiptItem", deliveryList);
|
|
|
|
var barcodeFilter = new BarcodeFilter
|
|
{
|
|
ArticleI3Ds = new List<int> { ArticleI3D }
|
|
};
|
|
var barcodes = session.GetBL<BarcodeWebServiceBL>().GetBarcodesThroughPaging(barcodeFilter, 1, 100);
|
|
this.Verifier.Verify("Barcodes", barcodes);
|
|
|
|
var articlePosition = deliveryList.Items.Single(f => f.ArticleI3D == ArticleI3D);
|
|
var barcode = barcodes.Result.Single(f => f.Name == Barcode);
|
|
|
|
articlePosition.Barcodes.Add(new ReceiptItemBarcode
|
|
{
|
|
WarehouseI3D = barcode.SecondaryStockI3D,
|
|
WarehouseCaption = "Doesn't matter",
|
|
CurrentBarcodeState = (BarcodeState)barcode.State,
|
|
BarcodeCaption = barcode.Name,
|
|
BarcodeI3D = barcode.I3D,
|
|
IsActive = true,
|
|
CreatedAt = barcode.CreatedAt
|
|
});
|
|
this.Verifier.Verify("ReceiptItemWithBarcode", articlePosition);
|
|
}
|
|
|
|
using (var saveSession = new BLSession())
|
|
{
|
|
var user = saveSession.GetBL<AppUserBL>().GetAppUser(f => f.I3D == 11);
|
|
|
|
var saveResult = saveSession.GetBL<ReceiptWebServiceBL>().SaveReceipt(
|
|
deliveryList,
|
|
user,
|
|
new SaveReceiptData
|
|
{
|
|
IgnoreCallbacks = true
|
|
},
|
|
autoLockIfNewReceipt: false,
|
|
CreatedThroughApplication.CentronNet,
|
|
receiptTemplateFolderI3D: null);
|
|
|
|
this.Verifier.Verify("SavedDeliveryList", saveResult);
|
|
|
|
return saveResult.Data.Receipt.I3D;
|
|
}
|
|
}
|
|
|
|
private void ForwardDeliveryListToInvoice(int deliveryListI3D)
|
|
{
|
|
ReceiptInvoiceDTO invoice;
|
|
|
|
using (var session = new BLSession())
|
|
{
|
|
var user = session.GetBL<AppUserBL>().GetAppUser(f => f.I3D == 11);
|
|
|
|
var forwardResult = session.GetBL<ReceiptWebServiceBL>().ForwardReceipt(
|
|
CentronObjectKindNumeric.InvoiceClass,
|
|
user,
|
|
new ForwardReceiptData
|
|
{
|
|
CreateReceiptData = new CreateReceiptData
|
|
{
|
|
IgnoreCallbacks = true,
|
|
},
|
|
CreateReceiptItemsFromExistingItemsData = new List<CreateReceiptItemsFromExistingItemsData>
|
|
{
|
|
new()
|
|
{
|
|
IgnoreCallbacks = true,
|
|
},
|
|
},
|
|
IgnoreCallbacks = true
|
|
},
|
|
new List<ReceiptToForward>
|
|
{
|
|
new ReceiptToForward
|
|
{
|
|
ReceiptKind = CentronObjectKindNumeric.DeliveryListClass,
|
|
ReceiptI3D = deliveryListI3D
|
|
}
|
|
},
|
|
receiptProjectLayoutItemI3DsToForward:null,
|
|
InsertReceiptTakeoverOptions.Reference,
|
|
onlyTakeoverAvailableQuantity: true,
|
|
ignoreDefaultContract: false);
|
|
|
|
this.Verifier.Verify("ForwardDeliveryListToInvoiceResult", forwardResult);
|
|
|
|
invoice = (ReceiptInvoiceDTO)forwardResult.Data.Receipt;
|
|
}
|
|
|
|
using (var saveSession = new BLSession())
|
|
{
|
|
var user = saveSession.GetBL<AppUserBL>().GetAppUser(f => f.I3D == 11);
|
|
|
|
var saveInvoiceResult = saveSession.GetBL<ReceiptWebServiceBL>().SaveReceipt(
|
|
invoice,
|
|
user,
|
|
new SaveReceiptData
|
|
{
|
|
IgnoreCallbacks = false,
|
|
InsertFreightArticle = false
|
|
},
|
|
autoLockIfNewReceipt: false,
|
|
CreatedThroughApplication.CentronNet,
|
|
receiptTemplateFolderI3D: null);
|
|
|
|
this.Verifier.Verify("SaveInvoiceResult", saveInvoiceResult);
|
|
}
|
|
}
|
|
|
|
private void CreateNewVersion(int deliveryListI3D)
|
|
{
|
|
ReceiptDeliveryListDTO newDeliveryListVersion;
|
|
|
|
using (var session = new BLSession())
|
|
{
|
|
var user = session.GetBL<AppUserBL>().GetAppUser(f => f.I3D == 11);
|
|
|
|
var createNewVersionResult = session.GetBL<ReceiptWebServiceBL>().CreateNewVersion(
|
|
CentronObjectKindNumeric.DeliveryListClass,
|
|
deliveryListI3D,
|
|
version: null,
|
|
newContactPersonI3D: null,
|
|
user,
|
|
new CreateNewVersionData
|
|
{
|
|
IgnoreCallbacks = true,
|
|
});
|
|
|
|
this.Verifier.Verify("NewDeliveryListVersion", createNewVersionResult);
|
|
|
|
newDeliveryListVersion = (ReceiptDeliveryListDTO)createNewVersionResult.Data.Receipt;
|
|
}
|
|
|
|
using (var saveSession = new BLSession())
|
|
{
|
|
var user = saveSession.GetBL<AppUserBL>().GetAppUser(f => f.I3D == 11);
|
|
|
|
var saveDeliveryListResult = saveSession.GetBL<ReceiptWebServiceBL>().SaveReceipt(
|
|
newDeliveryListVersion,
|
|
user,
|
|
new SaveReceiptData
|
|
{
|
|
IgnoreCallbacks = false,
|
|
InsertFreightArticle = false
|
|
},
|
|
autoLockIfNewReceipt: false,
|
|
CreatedThroughApplication.CentronNet,
|
|
receiptTemplateFolderI3D: null);
|
|
|
|
this.Verifier.Verify("NewDeliveryListVersionSaved", saveDeliveryListResult);
|
|
}
|
|
}
|
|
|
|
private void VerifyBarcodeTables(string name)
|
|
{
|
|
var settings = new CentronVerifierSettings();
|
|
settings.IgnoreColumn("Datum");
|
|
|
|
this.Verifier.VerifyTable($"{name}_Table_Barcode", tableName:"Barcode", where:$"I3D = {BarcodeI3D}");
|
|
this.Verifier.VerifyTable($"{name}_Table_SeriennummerToPosition", "SeriennummerToPosition", $"SNI3D = {BarcodeI3D}", settings);
|
|
this.Verifier.VerifyTable($"{name}_Table_BarcodeHistory", "BarcodeHistory", $"BarcodeI3D = {BarcodeI3D}", settings);
|
|
}
|
|
|
|
private void VerifyBarcodeIsStillInDeliveryList(int deliveryListI3D)
|
|
{
|
|
using (var session = new BLSession())
|
|
{
|
|
var deliveryListResult = session.GetBL<ReceiptWebServiceBL>().GetReceiptByI3D(deliveryListI3D, CentronObjectKindNumeric.DeliveryListClass);
|
|
this.Verifier.Verify("Result_DeliveryList", deliveryListResult);
|
|
|
|
var deliveryList = (ReceiptDeliveryListDTO)deliveryListResult.Data;
|
|
var barcodes = deliveryList.Items.SelectMany(f => f.Barcodes).ToList();
|
|
|
|
// Checks that the delivery list still has the barcode
|
|
Assert.Collection(barcodes, barcode =>
|
|
{
|
|
this.Verifier.Verify("Result_BarcodeInDeliveryList", barcode);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|