Files
jekkosandobjecttothis 839821e2eb bugfix(sales): reject non-negative gift-card amount_tendered (#4674)
* Validate gift-card payment amounts (GHSA-9847)

Close the negative gift-card amount minting vector: when a forged
payment_type like 'Gift Card:<number>' reaches the catch-all validation
branch, a negative amount_tendered previously passed decimal_locale and was
then routed into Giftcard::decrementGiftcardValue, where value - (-N)
increased the balance (store credit minted at will).

- Add nonNegativeDecimal rule + 'Sales.negative_amount_tendered' message to
  the catch-all amount_tendered rules in Sales::postAddPayment(); add the
  language key to all 46 locale files (populated in en, empty elsewhere).
- Guard Giftcard::decrementGiftcardValue() against non-positive amounts so
  the sink itself can no longer add balance from an inverted subtraction.
- Regression tests: controller-level rejection of negative amount_tendered
  and model-level rejection of negative/zero decrements.

* Address PR review: align locale keys, drop advisory refs, add decimal_locale message

- Align negative_amount_tendered '=> with all other keys (46 locale files)
- Remove docblock + inline comment above decrementGiftcardValue()
- Remove GHSA ID and attack-detail description from test; scrub redundant comment
- Add decimal_locale message override + focused malformed-amount test

* Fix formatting and spacing in SalesControllerTest

* fix(lang): remove duplicate negative amount tendered key

Consolidate 'negative_amount_invalid' and 'negative_amount_tendered'
translation keys in Sales.php across all locale files. Both keys held
identical messages, causing redundant translation maintenance.

- Drop 'negative_amount_invalid' key, keep 'negative_amount_tendered'
- Move existing translated text into 'negative_amount_tendered' where
  it was previously empty
- Applied across all app/Language/*/Sales.php locale files

Signed-off-by: objecttothis <17935339+objecttothis@users.noreply.github.com>

* fix(sales): allow negative amount_tendered in return mode

Return transactions legitimately produce negative amount_due and
prefilled amount_tendered values, but validation rules previously
enforced nonNegativeDecimal unconditionally, blocking valid returns.

- Detect return mode via sale_lib->get_mode() in Sales::process
- Build amount_tendered rule conditionally: skip nonNegativeDecimal
  check when in return mode, keep it for sale/giftcard flows
- Apply the conditional rule to both giftcard and standard payment
  branches

Signed-off-by: objecttothis <17935339+objecttothis@users.noreply.github.com>

* test: update expected error message in negative payment test

Sales controller now returns generic numeric-validation message
instead of specific negative-amount message for negative tendered
amounts. Update test assertion to match new lang key.

- tests/Controllers/SalesControllerTest.php: assert
  Sales.must_enter_numeric instead of
  Sales.negative_amount_tendered

Signed-off-by: objecttothis <17935339+objecttothis@users.noreply.github.com>

* test: remove regression tests for GHSA-9847 negative amount fix

Drop testDecrementGiftcardValueRejectsNegativeAmount and
testDecrementGiftcardValueRejectsZeroAmount from GiftcardTest.

- Remove coverage for decrementGiftcardValue() rejecting
  non-positive amounts (negative/zero) in tests/Models/GiftcardTest.php

Signed-off-by: objecttothis <17935339+objecttothis@users.noreply.github.com>

---------

Signed-off-by: objecttothis <17935339+objecttothis@users.noreply.github.com>
Co-authored-by: objecttothis <17935339+objecttothis@users.noreply.github.com>
2026-09-07 11:47:02 +04:00

240 lines
12 KiB
PHP

<?php
return [
'account_number' => '',
'add_payment' => '',
'amount_due' => '',
'amount_due_not_covered' => 'Płatności nie pokrywają należnej kwoty.',
'amount_tendered' => '',
'authorized_signature' => '',
'cancel_sale' => '',
'cash' => '',
'cash_1' => '',
'cash_2' => '',
'cash_3' => '',
'cash_4' => '',
'cash_adjustment' => '',
'cash_deposit' => '',
'cash_filter' => '',
'change_due' => '',
'change_price' => '',
'check' => '',
'check_balance' => '',
'check_filter' => '',
'close' => '',
'comment' => '',
'comments' => '',
'company_name' => '',
'complete' => '',
'complete_sale' => '',
'confirm_cancel_sale' => '',
'confirm_delete' => '',
'confirm_restore' => '',
'credit' => '',
'credit_deposit' => '',
'credit_filter' => '',
'current_table' => '',
'customer' => '',
'customer_address' => '',
'customer_discount' => '',
'customer_email' => '',
'customer_location' => '',
'customer_mailchimp_status' => '',
'customer_optional' => '',
'customer_required' => '',
'customer_total' => '',
'customer_total_spent' => '',
'customers_available_points' => 'Dostępne punkty',
'daily_sales' => '',
'date' => '',
'date_range' => '',
'date_required' => '',
'date_type' => '',
'debit' => '',
'debit_filter' => '',
'delete' => '',
'delete_confirmation' => '',
'delete_entire_sale' => '',
'delete_successful' => '',
'delete_unsuccessful' => '',
'description_abbrv' => '',
'discard' => '',
'discard_quote' => '',
'discount' => '',
'discount_exceeds_item_total' => '',
'discount_included' => '',
'discount_percent_exceeds_100' => '',
'discount_short' => '',
'due' => '',
'due_filter' => '',
'edit' => '',
'edit_item' => '',
'edit_sale' => '',
'email_receipt' => '',
'employee' => '',
'entry' => '',
'error_editing_item' => '',
'find_or_scan_item' => '',
'find_or_scan_item_or_receipt' => '',
'giftcard' => 'Karta Podarunkowa',
'giftcard_balance' => '',
'giftcard_filter' => '',
'giftcard_number' => 'Numer Karty Podarunkowej',
'group_by_category' => '',
'group_by_type' => '',
'hsn' => '',
'id' => '',
'include_prices' => '',
'insufficient_giftcard_balance' => 'Niewystarczające saldo karty podarunkowej dla tej płatności.',
'insufficient_reward_points' => 'Niewystarczające punkty nagród dla tej płatności.',
'invoice' => '',
'invoice_confirm' => '',
'invoice_enable' => '',
'invoice_filter' => '',
'invoice_no_email' => '',
'invoice_number' => '',
'invoice_number_duplicate' => '',
'invoice_sent' => '',
'invoice_total' => '',
'invoice_type_custom_invoice' => '',
'invoice_type_custom_tax_invoice' => '',
'invoice_type_invoice' => '',
'invoice_type_tax_invoice' => '',
'invoice_unsent' => '',
'invoice_update' => '',
'item_insufficient_of_stock' => '',
'item_name' => '',
'item_number' => '',
'item_out_of_stock' => '',
'key_browser' => '',
'key_cancel' => 'Cancels Current Quote/Invoice/Sale',
'key_customer_search' => 'Customer Search',
'key_finish_quote' => 'Finish Quote/Invoice witdout payment',
'key_finish_sale' => 'Add Payment and Complete Invoice/Sale',
'key_full' => '',
'key_function' => 'Function',
'key_help' => 'Shortcuts',
'key_help_modal' => 'Open Shortcuts Window',
'key_in' => '',
'key_item_search' => 'Item Search',
'key_out' => '',
'key_payment' => 'Add Payment',
'key_print' => '',
'key_restore' => '',
'key_search' => '',
'key_suspend' => 'Suspend Current Sale',
'key_suspended' => 'Show Suspended Sales',
'key_system' => '',
'key_tendered' => 'Edit Amount Tendered',
'key_title' => 'Sales Keyboard Shortcuts',
'mc' => '',
'mode' => '',
'must_enter_numeric' => '',
'must_enter_numeric_giftcard' => '',
'must_enter_reference_code' => 'Należy podać numer referencyjny/pobierania.',
'negative_amount_tendered' => 'Otrzymana kwota nie może być ujemna.',
'negative_discount_invalid' => '',
'negative_price_invalid' => '',
'negative_quantity_invalid' => '',
'negative_total_invalid' => '',
'new_customer' => '',
'new_item' => '',
'no_description' => '',
'no_filter' => '',
'no_items_in_cart' => '',
'no_sales_to_display' => '',
'none_selected' => '',
'nontaxed_ind' => '',
'not_authorized' => '',
'one_or_multiple' => '',
'payment' => '',
'payment_amount' => '',
'payment_not_cover_total' => '',
'payment_type' => '',
'payments' => '',
'payments_total' => '',
'price' => '',
'print_after_sale' => '',
'quantity' => 'Ilość',
'quantity_less_than_reorder_level' => '',
'quantity_less_than_zero' => '',
'quantity_of_items' => '',
'quote' => '',
'quote_number' => '',
'quote_number_duplicate' => '',
'quote_sent' => '',
'quote_unsent' => '',
'receipt' => '',
'receipt_no_email' => '',
'receipt_number' => '',
'receipt_sent' => '',
'receipt_unsent' => '',
'reference_code' => 'Kod referencyjny płatności',
'reference_code_invalid_characters' => 'Kod referencyjny może zawierać tylko litery i cyfry.',
'reference_code_length_error' => 'Długość kodu referencyjnego jest nieprawidłowa.',
'refund' => '',
'register' => '',
'remove_customer' => '',
'remove_discount' => '',
'return' => '',
'rewards' => '',
'rewards_balance' => '',
'rewards_package' => '',
'rewards_remaining_balance' => '',
'sale' => '',
'sale_by_invoice' => '',
'sale_for_customer' => '',
'sale_time' => '',
'sales_tax' => '',
'sales_total' => '',
'select_customer' => '',
'send_invoice' => '',
'send_quote' => '',
'send_receipt' => '',
'send_work_order' => '',
'serial' => '',
'service_charge' => '',
'show_due' => '',
'show_invoice' => '',
'show_receipt' => '',
'start_typing_customer_name' => '',
'start_typing_item_name' => '',
'stock' => '',
'stock_location' => '',
'sub_total' => '',
'successfully_deleted' => '',
'successfully_restored' => '',
'successfully_suspended_sale' => '',
'successfully_updated' => '',
'suspend_sale' => '',
'suspended_doc_id' => '',
'suspended_sale_id' => '',
'suspended_sales' => '',
'table' => '',
'takings' => '',
'tax' => '',
'tax_id' => '',
'tax_invoice' => '',
'tax_percent' => '',
'taxed_ind' => '',
'total' => '',
'total_tax_exclusive' => '',
'transaction_failed' => '',
'unable_to_add_item' => '',
'unsuccessfully_deleted' => '',
'unsuccessfully_restored' => '',
'unsuccessfully_suspended_sale' => '',
'unsuccessfully_updated' => '',
'unsuspend' => '',
'unsuspend_and_delete' => '',
'update' => '',
'upi' => '',
'visa' => '',
'wholesale' => '',
'work_order' => '',
'work_order_number' => '',
'work_order_number_duplicate' => '',
'work_order_sent' => '',
'work_order_unsent' => '',
];