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
15 KiB
PHP

<?php
return [
'account_number' => 'លេខគណនី',
'add_payment' => 'បញ្ជូលរបៀបបង់ប្រាក់',
'amount_due' => 'ទឹកប្រាក់ដែលត្រូវបង់',
'amount_due_not_covered' => 'ការទូទាត់មិនគ្របដណ្តប់ចំនួនទឹកប្រាក់ដែលត្រូវបង់ទេ។',
'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' => 'ពិន្ទុដែលប្រើប្រាស់បាន',
'daily_sales' => '',
'date' => 'ថ្ងៃខែ លក់',
'date_range' => 'ចន្លោះ ថ្ងៃខែ',
'date_required' => "ត្រូវតែបញ្ជូល ថ្ងៃខែ\u{200b}ដែលត្រឹមត្រូវ",
'date_type' => "ត្រូវការបញ្ចូលថ្ងៃខែ\u{200b}ជាចាំបាច់។",
'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' => "ស្វែងរក ឬ\u{200b}ស្កេនទំនិញ ឬ វិក័យបត្រ",
'giftcard' => 'កាតអំណោយ',
'giftcard_balance' => 'សមតុល្យលើកាតអំណោយ',
'giftcard_filter' => '',
'giftcard_number' => 'លេខកាតអំណោយ',
'group_by_category' => '',
'group_by_type' => '',
'hsn' => '',
'id' => '',
'include_prices' => '',
'insufficient_giftcard_balance' => 'សមតុល្យលេខកូដឧបករណ៍ច្រើនគ្មាន់គ្រប់គ្រាន់សម្រាប់ការទូទាត់នេះ។',
'insufficient_reward_points' => 'ពិន្ទុរង្វាន់មិនគ្រប់គ្រាន់សម្រាប់ការទូទាត់នេះ។',
'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' => 'លេខយោង/ទាញយកត្រូវតែបញ្ចូល។',
'negative_amount_tendered' => 'ទឹកប្រាក់បានមកពីការបង់មិនអាចជាចំនួនអវិជ្ជមានបានទេ។',
'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' => '',
'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' => 'កូដយោងការទូទាត់',
'reference_code_invalid_characters' => 'កូដយោងត្រូវតែមានតែអក្សរ និងលេខប៉ុណ្ណោះ។',
'reference_code_length_error' => 'ប្រវែងកូដយោងមិនត្រឹមត្រូវ។',
'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' => '',
];