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
282 lines
11 KiB
C#
282 lines
11 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.CreditVouchers;
|
|
using Centron.Data.WebServices.Sales.Receipts.Invoices;
|
|
using Centron.Interfaces;
|
|
using Centron.Interfaces.Administration.Environment;
|
|
using Centron.Interfaces.BL;
|
|
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.Ticket106044
|
|
{
|
|
public class Ticket106044Test : EndToEndTest
|
|
{
|
|
public const string Barcode = "100072017";
|
|
public const int BarcodeI3D = 3678;
|
|
public const int ArticleI3D = 1256;
|
|
|
|
public Ticket106044Test(ITestOutputHelper testOutputHelper)
|
|
: base(testOutputHelper)
|
|
{
|
|
}
|
|
|
|
public override void Execute()
|
|
{
|
|
this.PrepareDatabase();
|
|
|
|
var invoiceI3D = this.CreateInvoice();
|
|
this.VerifyBarcodeTables("InvoiceCreated");
|
|
|
|
var creditVoucherI3D = this.ForwardInvoiceToCreditVoucher(invoiceI3D);
|
|
this.VerifyBarcodeTables("CreditVoucherCreated");
|
|
|
|
var secondInvoiceI3D = this.CreateInvoice();
|
|
this.VerifyBarcodeTables("SecondInvoiceCreated");
|
|
|
|
this.CompleteCreditVoucher(creditVoucherI3D);
|
|
this.VerifyBarcodeTables("CompletedCreditVoucher");
|
|
|
|
this.CreateNewVersion(creditVoucherI3D);
|
|
this.VerifyBarcodeTables("NewCreditVoucherVersion");
|
|
}
|
|
|
|
private void PrepareDatabase()
|
|
{
|
|
this.Sql("ALTER TABLE GutKopf DROP COLUMN LcmStatus");
|
|
|
|
// 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 CreateInvoice()
|
|
{
|
|
ReceiptInvoiceDTO invoice;
|
|
|
|
using (var session = new BLSession())
|
|
{
|
|
var user = session.GetBL<AppUserBL>().GetAppUser(f => f.I3D == 11);
|
|
var result = session.GetBL<ReceiptWebServiceBL>().CreateNewReceipt(
|
|
CentronObjectKindNumeric.InvoiceClass,
|
|
new LoggedInUser(user),
|
|
customerI3D: 10022,
|
|
new CreateReceiptData(),
|
|
addressI3D: null,
|
|
contactPersonI3D: null,
|
|
insertSalutationAndAgreement: true,
|
|
ignoreDefaultContract: false,
|
|
insertCustomerDiscount: true);
|
|
|
|
var receiptItem = session.GetBL<ReceiptItemWebServiceBL>().CreateArticleReceiptItems(
|
|
result.Data.Receipt,
|
|
isExternalArticle: false,
|
|
ArticleI3D,
|
|
externalArticleKind: null,
|
|
externalArticleId: null,
|
|
warehouseI3D: -1,
|
|
new LoggedInUser(user));
|
|
|
|
invoice = (ReceiptInvoiceDTO)result.Data.Receipt;
|
|
invoice.Items.AddRange(receiptItem.Data.ReceiptItems.Cast<ReceiptInvoiceItemDTO>());
|
|
|
|
var barcodeFilter = new BarcodeFilter
|
|
{
|
|
ArticleI3Ds = new List<int> { ArticleI3D }
|
|
};
|
|
var barcodes = session.GetBL<BarcodeWebServiceBL>().GetBarcodesThroughPaging(barcodeFilter, 1, 100);
|
|
|
|
var articlePosition = invoice.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
|
|
});
|
|
}
|
|
|
|
using (var saveSession = new BLSession())
|
|
{
|
|
var user = saveSession.GetBL<AppUserBL>().GetAppUser(f => f.I3D == 11);
|
|
|
|
var saveResult = saveSession.GetBL<ReceiptWebServiceBL>().SaveReceipt(
|
|
invoice,
|
|
user,
|
|
new SaveReceiptData
|
|
{
|
|
IgnoreCallbacks = true
|
|
},
|
|
autoLockIfNewReceipt: false,
|
|
CreatedThroughApplication.CentronNet,
|
|
receiptTemplateFolderI3D: null);
|
|
|
|
return saveResult.Data.Receipt.I3D;
|
|
}
|
|
}
|
|
|
|
private int ForwardInvoiceToCreditVoucher(int invoiceI3D)
|
|
{
|
|
ReceiptCreditVoucherDTO creditVoucher;
|
|
|
|
using (var session = new BLSession())
|
|
{
|
|
var user = session.GetBL<AppUserBL>().GetAppUser(f => f.I3D == 11);
|
|
|
|
var forwardResult = session.GetBL<ReceiptWebServiceBL>().ForwardReceipt(
|
|
CentronObjectKindNumeric.CreditVoucherClass,
|
|
user,
|
|
new ForwardReceiptData
|
|
{
|
|
CreateReceiptData = new CreateReceiptData
|
|
{
|
|
IgnoreCallbacks = true,
|
|
},
|
|
CreateReceiptItemsFromExistingItemsData = new List<CreateReceiptItemsFromExistingItemsData>
|
|
{
|
|
new()
|
|
{
|
|
IgnoreCallbacks = true,
|
|
},
|
|
},
|
|
IgnoreCallbacks = true
|
|
},
|
|
new List<ReceiptToForward>
|
|
{
|
|
new ReceiptToForward
|
|
{
|
|
ReceiptKind = CentronObjectKindNumeric.InvoiceClass,
|
|
ReceiptI3D = invoiceI3D
|
|
}
|
|
},
|
|
receiptProjectLayoutItemI3DsToForward: null,
|
|
InsertReceiptTakeoverOptions.Reference,
|
|
onlyTakeoverAvailableQuantity: true,
|
|
ignoreDefaultContract: false);
|
|
|
|
creditVoucher = (ReceiptCreditVoucherDTO)forwardResult.Data.Receipt;
|
|
}
|
|
|
|
using (var saveSession = new BLSession())
|
|
{
|
|
var user = saveSession.GetBL<AppUserBL>().GetAppUser(f => f.I3D == 11);
|
|
|
|
var saveCreditVoucherResult = saveSession.GetBL<ReceiptWebServiceBL>().SaveReceipt(
|
|
creditVoucher,
|
|
user,
|
|
new SaveReceiptData
|
|
{
|
|
IgnoreCallbacks = true
|
|
},
|
|
autoLockIfNewReceipt: false,
|
|
CreatedThroughApplication.CentronNet,
|
|
receiptTemplateFolderI3D: null);
|
|
|
|
return saveCreditVoucherResult.Data.Receipt.I3D;
|
|
}
|
|
}
|
|
|
|
private void CreateNewVersion(int creditVoucherI3D)
|
|
{
|
|
ReceiptCreditVoucherDTO newCreditVoucherVersion;
|
|
|
|
using (var session = new BLSession())
|
|
{
|
|
var user = session.GetBL<AppUserBL>().GetAppUser(f => f.I3D == 11);
|
|
|
|
var createNewVersionResult = session.GetBL<ReceiptWebServiceBL>().CreateNewVersion(
|
|
CentronObjectKindNumeric.CreditVoucherClass,
|
|
creditVoucherI3D,
|
|
version: null,
|
|
newContactPersonI3D: null,
|
|
user,
|
|
new CreateNewVersionData
|
|
{
|
|
IgnoreCallbacks = true
|
|
});
|
|
|
|
newCreditVoucherVersion = (ReceiptCreditVoucherDTO)createNewVersionResult.Data.Receipt;
|
|
}
|
|
|
|
using (var saveSession = new BLSession())
|
|
{
|
|
var user = saveSession.GetBL<AppUserBL>().GetAppUser(f => f.I3D == 11);
|
|
|
|
var saveCreditVoucherResult = saveSession.GetBL<ReceiptWebServiceBL>().SaveReceipt(
|
|
newCreditVoucherVersion,
|
|
user,
|
|
new SaveReceiptData
|
|
{
|
|
IgnoreCallbacks = true
|
|
},
|
|
autoLockIfNewReceipt: false,
|
|
CreatedThroughApplication.CentronNet,
|
|
receiptTemplateFolderI3D: null);
|
|
|
|
Assert.Equal(ResultStatus.Success, saveCreditVoucherResult.Status);
|
|
}
|
|
}
|
|
|
|
|
|
private void CompleteCreditVoucher(int creditVoucherI3D)
|
|
{
|
|
ReceiptCreditVoucherDTO creditVoucher;
|
|
|
|
using (var session = new BLSession())
|
|
{
|
|
var user = session.GetBL<AppUserBL>().GetAppUser(f => f.I3D == 11);
|
|
|
|
var creditVoucherResult = session.GetBL<ReceiptWebServiceBL>().GetReceiptByI3D(creditVoucherI3D, CentronObjectKindNumeric.CreditVoucherClass);
|
|
creditVoucher = (ReceiptCreditVoucherDTO)creditVoucherResult.Data;
|
|
}
|
|
|
|
creditVoucher.State = ReceiptState.Completed;
|
|
|
|
using (var saveSession = new BLSession())
|
|
{
|
|
var user = saveSession.GetBL<AppUserBL>().GetAppUser(f => f.I3D == 11);
|
|
|
|
var saveCreditVoucherResult = saveSession.GetBL<ReceiptWebServiceBL>().SaveReceipt(
|
|
creditVoucher,
|
|
user,
|
|
new SaveReceiptData
|
|
{
|
|
IgnoreCallbacks = true
|
|
},
|
|
autoLockIfNewReceipt: false,
|
|
CreatedThroughApplication.CentronNet,
|
|
receiptTemplateFolderI3D: null);
|
|
|
|
Assert.Equal(ResultStatus.Success, saveCreditVoucherResult.Status);
|
|
}
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|