Asociado de caja general reporta que no puede conciliar un cajero ya que le arroja error.
Al revisar el corte del cajero observamos que cuenta con 2 cortes finales los cuales están en aprobados o bien uno aprobado y otro rechazado o ambos rechazados.
Query: Balance – Verificación Corte de Cajeros
Para mitigar este incidente es necesario dejar solamente 1 corte final o bien borrar ambos y que el asociado genere un único corte final para que caja general puede conciliarlo y por ende hacer el cierre de caja general sin problemas.
DECLARE @Date datetime = ‘2024-07-16’ –Día de Operación
DECLARE @Cashier int = 9997 –Employee
DECLARE @Emp int = (Select employeeno from employee where employeeno = @Cashier or payrollid = @Cashier)
Select GETDATE() as ‘HORA ACTUAL’, ‘CIERRE DE TIENDA’, ProgStartTim, EOPStatus, AcctStatus, CurrentDate, CurRptDate, Progname,Lasttran,* FROM AcctPeriod order by getdate() desc
/* Cierre de caja general */
SELECT @@SERVERNAME AS ‘Server Name’
SELECT ‘CIERRE CAJA GENERAL’, * FROM STORE_FinalTenderTotals WHERE CAST(Date as date) = @Date
SELECT * FROM CashierBalances WHERE Date = @Date AND EmployeeNo = @Emp
SELECT TABadge, JobTitle, * FROM Employee WHERE EMPLOYEENO = @Emp OR PayrollId = @Emp
/* Encabezado del corte */
SELECT * FROM STORE_Withdrawals WHERE Cast(Date as date) = @Date and EmployeeNo = @Emp
SELECT @@SERVERNAME AS ‘Server Name’
BEGIN
SELECT TenderCode AS ‘Tipo de pago’, Cajas, Cortes–, convert(money,Cajas)-Isnull(convert(money,Cortes),0) ‘Diferencia’
FROM(
/* Información de cortes */
SELECT
CONCAT(DEN.TenderCode, ‘ – ‘, TN.[Description]) AS TenderCode,
FORMAT(SUM(WDE.TotalPrice), ‘C’, ‘en-us’) AS Amount,
‘Cortes’ AS Type
FROM STORE_Withdrawals AS WD
JOIN STORE_WithdrawalDenominations AS WDE ON WD.WithdrawalId = WDE.WithdrawalId
JOIN STORE_Denominations AS DEN ON WDE.DenominationId = DEN.DenominationId
JOIN TenderCntrl TN ON DEN.TenderCode = TN.TenderCode
WHERE WD.WithdrawalId IN (SELECT WithdrawalId FROM STORE_Withdrawals WHERE EmployeeNo = @Emp)
AND CAST(WD.Date as date) = @Date
GROUP BY DEN.TenderCode, TN.[Description]
UNION
/* Información de cajas */
SELECT
CONCAT(TTE.TenderCode, ‘ – ‘, TN.[Description]) AS TenderCode,
FORMAT(SUM(tte.TenderAmount), ‘C’, ‘en-us’) AS Amount,
‘Cajas’ AS Type
FROM TranTotal TT
JOIN TranTender TTE on TT.TranNumber = TTE.TranNumber and TT.TranDate = TTE.TranDate and TT.RegisterID = TTE.RegisterID
JOIN Employee AS EMP ON TT.EmployeeNo = EMP.EmployeeNo
JOIN TenderCntrl TN ON TTE.TenderCode = TN.TenderCode
WHERE TT.TranDate = @Date
AND TT.EmployeeNo = @Emp
AND TT.OperatMode = 0
AND TT.RecType = ‘N’
AND TT.TypeOfSale NOT IN (3,49,88)
AND TTE.TenderCode != 14
GROUP BY TTE.TenderCode, TN.[Description]
) M
PIVOT
(
MAX(Amount) FOR Type in (Cajas,Cortes)
) piv;
END
/* Detalle del corte final */
SELECT ‘DETALLE DE CORTE FINAL’, * FROM STORE_Withdrawaldenominations wd JOIN STORE_Withdrawals w ON wd.WithdrawalId = w.Withdrawalid
WHERE Cast(Date as date) = @Date and EmployeeNo = @Emp and w.DocumentType like ‘%final%’
/* Transacciones del cajero */
SELECT tt.posted, tt.Endtime, tt.RecType, tt.OperatMode, te.TranDate, tt.RegisterId, tt.TranNumber, tt.EmployeeNo, te.TenderCode, te.TenderAmount, SigSequence
FROM TranTotal tt LEFT JOIN TranTender te
ON te.TranDate = tt.TranDate and te.RegisterId = tt.RegisterId and te.TranNumber = tt.TranNumber
WHERE tt.TranDate = @Date and EmployeeNo = @Emp
ORDER BY EndTime
Si al ejecutar este query observamos que aparecen 2 cortes finales hay que eliminar alguno de los 2. En caso de que ambos finales estén aprobados hay que solicitar al asociado de caja general que rechace un corte final (el que no les sirve) o bien si lo prefieren pueden rechazar ambos finales y nosotros podemos eliminar ambos para que vuelvan a generar uno solo.
Para eliminar el corte procedemos a tomar el dato del campo withdrawalid de la tabla STORE_Withdrawaldenominations y ejecutamos el delete que viene en el query y ejecutamos solo esa línea. Al volver a consultar debería aparecer solo uno o ninguno en caso que se eliminen ambos.
–Depurar/ ELIMINAR corte de cajero final o parcial
–Declare @wdr int = 50663 — colocar el dato que se encuentra en el campo de withdrawalid
–DELETE FROM STORE_Withdrawaldenominations where withdrawalid = @wdr
–DELETE FROM STORE_Withdrawals where withdrawalid = @wdr
El ticket se deja como cancelado y se cierra con los siguientes datos:
Servicio: Gestión de Tiendas (SMS)
CI afectado: SMS – Balanceo de Efectivo