From 7c81922e0e59d4a669bc28f4d8420b841347068f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Manuel=20Cota?= Date: Tue, 28 Dec 2021 15:05:08 -0500 Subject: [PATCH] USE_IFRS_ACCOUNTS_CHART guard added --- Vouchers/Data/VoucherData.cs | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/Vouchers/Data/VoucherData.cs b/Vouchers/Data/VoucherData.cs index 583c18b8..51547b4d 100644 --- a/Vouchers/Data/VoucherData.cs +++ b/Vouchers/Data/VoucherData.cs @@ -16,7 +16,13 @@ namespace Empiria.FinancialAccounting.Vouchers.Data { /// Data access layer for accounting vouchers. static internal class VoucherData { + static private readonly bool USE_IFRS_ACCOUNTS_CHART = + ConfigurationData.Get("Use.IFRS.Accounts.Chart", false); + static internal void CloseVoucher(Voucher o) { + + EnsureIFRSIsActiveGuard(o); + var dataOperation = DataOperation.Parse("do_close_cof_transaccion", o.Id, o.Ledger.Id, o.Number, o.AuthorizedBy.IsEmptyInstance ? 0 : o.AuthorizedBy.Id, @@ -72,13 +78,15 @@ static internal Voucher GetVoucher(long id) { return DataReader.GetPlainObject(dataOperation); } + static internal string GetVoucherNumberFor(Voucher voucher) { + // Please check do_close_transaction stored procedure validation code + var prefix = $"{voucher.AccountingDate.Year}-{voucher.AccountingDate.Month.ToString("00")}"; var sql = "SELECT MAX(NUMERO_TRANSACCION) " + $"FROM COF_TRANSACCION " + - //$"WHERE ID_MAYOR = {voucher.Ledger.Id} AND " + - $"WHERE " + + $"WHERE ID_MAYOR = {voucher.Ledger.Id} AND " + $"NUMERO_TRANSACCION LIKE '{prefix}-%' AND ESTA_ABIERTA = 0"; var dataOperation = DataOperation.Parse(sql); @@ -96,7 +104,7 @@ static internal FixedList GetVouchers(string filter, string sort, int p "SELECT * FROM VW_COF_TRANSACCION " + $"WHERE {filter} " + $"ORDER BY {sort}) " + - $"WHERE ROWNUM <= {pageSize}"; + $"WHERE ROWNUM <= {pageSize}"; var dataOperation = DataOperation.Parse(sql); @@ -146,6 +154,8 @@ static internal Voucher TryGetVoucher(Ledger ledger, string voucherNumber) { static internal void WriteVoucher(Voucher o) { Assertion.Assert(o.IsOpened, "Voucher must be opened to be modified in the database."); + EnsureIFRSIsActiveGuard(o); + var op = DataOperation.Parse("write_cof_transaccion", o.Id, o.Number, o.Ledger.Id, o.FunctionalArea.Id, o.TransactionType.Id, o.VoucherType.Id, @@ -172,6 +182,16 @@ static internal void WriteVoucherEntry(VoucherEntry o) { DataWriter.Execute(op); } + + static private void EnsureIFRSIsActiveGuard(Voucher o) { + if (USE_IFRS_ACCOUNTS_CHART) { + return; + } + if (o.Ledger.AccountsChart.Equals(AccountsChart.IFRS)) { + Assertion.AssertFail("Por ahora, SICOFIN ha sido configurado para NO permitir el registro de pólizas con el catálogo IFRS9 2022."); + } + } + } // class VoucherData } // namespace Empiria.FinancialAccounting.Vouchers.Data