Skip to content

[Feature]: Debit/Credit transaction number field #4093

Open

Description

@retechp

Type of Feature

✨ New Feature

OpensourcePOS Version

opensourcepos 3.3.9

Description

I would like to have a field added to all receipts and transactions named transaction auth #. This field would appear when the checkout option of credit/debit card is selected.

This field should also be mandatory and not allow the transaction to be completed unless this field is populated
Image (4)

Currently in my testing, I can track this auth code using the comments fieldhowever, it does not appear on the customer invoice when printed.
authcode

What files can I modify so that we can include the auth code to be printed on the receipt and, I would like a field in the database to store this information.

Additional Information

No response

Verify you searched open requests in OpensourcePOS

  • I agree I have searched Open Requests

Activity

  1. andriux1990 commented on Oct 25, 2024

    @andriux1990
    Member

    To implement what you're aiming for, some work is required on both the backend and the frontend.

    In the backend, an additional table needs to be created in sales_payments to store transaction references. On the frontend, you can use JavaScript to set a condition: if payment is made by card, the "Add Payment" button should remain disabled until a value is entered in the reference input field. This ensures that the process cannot be completed without a valid reference.
    Screenshot 2024-10-24 at 19-29-40 NPos

  2. andriux1990 commented on Oct 25, 2024

    @andriux1990
    Member

    Javascript code:

                    $(document).ready(function() {
                        // Lista de métodos de pago que deben bloquear el botón si no hay valor en el input
                        var restrictedPayments = [
                            'Tarjeta Bac NIO', 
                            'Tarjeta Bac USD', 
                            'Tarjeta Banpro NIO', 
                            'Tarjeta Banpro USD', 
                            'Tarjeta Lafise NIO', 
                            'Tarjeta Lafise USD'
                        ];
    
                        // Lista de métodos de pago que permiten que el botón esté siempre activo
                        var allowedPayments = [
                            'Efectivo', 
                            'Transferencias', 
                            'USD', 
                            'NIO'
                        ];
    
                        // Función para validar el estado del botón
                        function validateButtonState() {
                            var selectedPayment = $('#payment_types').val();
                            var inputValue = $('#payment_ref').val();
                            var creditValue = $('#exinput6').val();
    
                            // Si el método de pago es A Credito, verificar el valor de exinput6
                            if (selectedPayment === 'A Credito') {
                                if (creditValue !== '') {
                                    $('#add_payment_button').prop('disabled', false); // Activar el botón si hay un valor en el input de crédito
                                } else {
                                    $('#add_payment_button').prop('disabled', true); // Bloquear el botón si no hay valor en el input de crédito
                                }
                            }
                            // Si el método seleccionado está en la lista permitida, habilitar siempre el botón
                            else if (allowedPayments.includes(selectedPayment)) {
                                $('#add_payment_button').prop('disabled', false);
                            }
                            // Si el método seleccionado está en la lista restringida y no hay valor en el input
                            else if (restrictedPayments.includes(selectedPayment) && inputValue === '') {
                                $('#add_payment_button').prop('disabled', true); // Bloquear el botón
                            } else if (inputValue !== '') {
                                $('#add_payment_button').prop('disabled', false); // Activar el botón si hay un valor en el input
                            } else {
                                $('#add_payment_button').prop('disabled', true); // Bloquear si no cumple las condiciones
                            }
                        }
    
                        // Llamar la función de validación al cargar la página
                        validateButtonState();
    
                        // Escuchar cambios en el dropdown
                        $('#payment_types').on('change', function() {
                            validateButtonState(); // Validar el botón al cambiar el dropdown
                        });
    
                        // Escuchar cambios en el input de pago
                        $('#payment_ref').on('input', function() {
                            validateButtonState(); // Validar el botón al escribir en el input
                        });
    
                        // Escuchar cambios en el input de crédito
                        $('#exinput6').on('input', function() {
                            validateButtonState(); // Validar el botón al escribir en el input de crédito
                        });
    
                        // Si recargas contenido por AJAX, asegúrate de llamar a validateButtonState después de que se actualice el DOM.
                        $(document).ajaxComplete(function() {
                            validateButtonState(); // Validar el botón después de una recarga AJAX
                        });
                    });
    
  3. andriux1990 commented on Oct 25, 2024

    @andriux1990
    Member

    SQL:
    ALTER TABLE ospos_sales_payments
    ADD COLUMN IF NOT EXISTS payment_ref varchar(40) NOT NULL;

  4. retechp commented on Oct 25, 2024

    @retechp
    Author

    Thanks for this. What file do edit with this

    Javascript code:

                    $(document).ready(function() {
                        // Lista de métodos de pago que deben bloquear el botón si no hay valor en el input
                        var restrictedPayments = [
                            'Tarjeta Bac NIO', 
                            'Tarjeta Bac USD', 
                            'Tarjeta Banpro NIO', 
                            'Tarjeta Banpro USD', 
                            'Tarjeta Lafise NIO', 
                            'Tarjeta Lafise USD'
                        ];
    
                        // Lista de métodos de pago que permiten que el botón esté siempre activo
                        var allowedPayments = [
                            'Efectivo', 
                            'Transferencias', 
                            'USD', 
                            'NIO'
                        ];
    
                        // Función para validar el estado del botón
                        function validateButtonState() {
                            var selectedPayment = $('#payment_types').val();
                            var inputValue = $('#payment_ref').val();
                            var creditValue = $('#exinput6').val();
    
                            // Si el método de pago es A Credito, verificar el valor de exinput6
                            if (selectedPayment === 'A Credito') {
                                if (creditValue !== '') {
                                    $('#add_payment_button').prop('disabled', false); // Activar el botón si hay un valor en el input de crédito
                                } else {
                                    $('#add_payment_button').prop('disabled', true); // Bloquear el botón si no hay valor en el input de crédito
                                }
                            }
                            // Si el método seleccionado está en la lista permitida, habilitar siempre el botón
                            else if (allowedPayments.includes(selectedPayment)) {
                                $('#add_payment_button').prop('disabled', false);
                            }
                            // Si el método seleccionado está en la lista restringida y no hay valor en el input
                            else if (restrictedPayments.includes(selectedPayment) && inputValue === '') {
                                $('#add_payment_button').prop('disabled', true); // Bloquear el botón
                            } else if (inputValue !== '') {
                                $('#add_payment_button').prop('disabled', false); // Activar el botón si hay un valor en el input
                            } else {
                                $('#add_payment_button').prop('disabled', true); // Bloquear si no cumple las condiciones
                            }
                        }
    
                        // Llamar la función de validación al cargar la página
                        validateButtonState();
    
                        // Escuchar cambios en el dropdown
                        $('#payment_types').on('change', function() {
                            validateButtonState(); // Validar el botón al cambiar el dropdown
                        });
    
                        // Escuchar cambios en el input de pago
                        $('#payment_ref').on('input', function() {
                            validateButtonState(); // Validar el botón al escribir en el input
                        });
    
                        // Escuchar cambios en el input de crédito
                        $('#exinput6').on('input', function() {
                            validateButtonState(); // Validar el botón al escribir en el input de crédito
                        });
    
                        // Si recargas contenido por AJAX, asegúrate de llamar a validateButtonState después de que se actualice el DOM.
                        $(document).ajaxComplete(function() {
                            validateButtonState(); // Validar el botón después de una recarga AJAX
                        });
                    });
    

    Thanks for this. What file do edit with this

  5. objecttothis commented on Nov 4, 2026

    @objecttothis
    Member

    Claude Issue Checker Agent (cc @objecttothis)

    Investigated against current master.

    Status: Appears resolved by a later, more general feature.

    This 2024 request asked for a transaction-reference-number field tied to debit/credit payments. master now has a generalized Payment Reference Code feature: app/Controllers/Config.php::postSaveLocale() validates payment_reference_code_min/payment_reference_code_max, app/Views/configs/locale_config.php exposes a configurable length-limit slider, and (per the related work noted in issue #4548's thread) the register view/JS gates a reference-code input field for the payment types that need it (originally Credit/Debit, later extended to Bank Transfer/Wallet/UPI) via a get_reference_code_payment_types() helper, validated server-side in Sales::postAddPayment(). This covers the underlying need from this issue (configurable, validated reference code captured alongside non-cash payments), implemented more generally than the ad-hoc JS/SQL patch suggested in the original comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions