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

<?php
return [
'account_number' => '',
'add_payment' => 'Add Payment',
'amount_due' => 'Amount Due',
'amount_due_not_covered' => 'ການຊຳລະເງິນບໍ່ຄຸ້ມຈຳນວນທີ່ຕ້ອງຈ່າຍ.',
'amount_tendered' => 'Amount Tendered',
'authorized_signature' => '',
'cancel_sale' => 'Cancel',
'cash' => 'Cash',
'cash_1' => '',
'cash_2' => '',
'cash_3' => '',
'cash_4' => '',
'cash_adjustment' => '',
'cash_deposit' => 'Cash Deposit',
'cash_filter' => 'Cash',
'change_due' => 'Change Due',
'change_price' => '',
'check' => 'Check',
'check_balance' => 'Check remainder',
'check_filter' => 'Check',
'close' => '',
'comment' => 'Comment',
'comments' => 'Comments',
'company_name' => '',
'complete' => '',
'complete_sale' => 'Complete',
'confirm_cancel_sale' => 'Are you sure you want to clear this sale? All items will cleared.',
'confirm_delete' => 'Are you sure you want to delete the selected Sale(s)?',
'confirm_restore' => 'Are you sure you want to restore the selected Sale(s)?',
'credit' => 'Credit Card',
'credit_deposit' => 'Credit Deposit',
'credit_filter' => '',
'current_table' => '',
'customer' => 'Name',
'customer_address' => 'Address',
'customer_discount' => 'Discount',
'customer_email' => 'Email',
'customer_location' => 'Location',
'customer_mailchimp_status' => 'Mailchimp status',
'customer_optional' => '',
'customer_required' => '',
'customer_total' => 'Total',
'customer_total_spent' => '',
'customers_available_points' => 'Available Points',
'daily_sales' => '',
'date' => 'Sale Date',
'date_range' => 'Date Range',
'date_required' => 'A correct date must be entered.',
'date_type' => 'Date is a required field.',
'debit' => 'Debit Card',
'debit_filter' => '',
'delete' => 'Allow Delete',
'delete_confirmation' => 'Are you sure you want to delete this sale? This action cannot be undone.',
'delete_entire_sale' => 'Delete Entire Sale',
'delete_successful' => 'Sale delete successful.',
'delete_unsuccessful' => 'Sale delete failed.',
'description_abbrv' => 'Desc.',
'discard' => 'Discard',
'discard_quote' => '',
'discount' => 'Disc %',
'discount_exceeds_item_total' => '',
'discount_included' => '% Discount',
'discount_percent_exceeds_100' => '',
'discount_short' => '%',
'due' => 'Due',
'due_filter' => 'Due',
'edit' => 'Edit',
'edit_item' => 'Edit Item',
'edit_sale' => 'Edit Sale',
'email_receipt' => 'Email Receipt',
'employee' => 'Employee',
'entry' => 'Entry',
'error_editing_item' => 'Error editing item',
'find_or_scan_item' => 'Find or Scan Item',
'find_or_scan_item_or_receipt' => 'Find or Scan Item or Receipt',
'giftcard' => 'Gift Card',
'giftcard_balance' => 'Gift Card Balance',
'giftcard_filter' => '',
'giftcard_number' => 'Gift Card Number',
'group_by_category' => 'Group by Category',
'group_by_type' => 'Group by Type',
'hsn' => '',
'id' => 'Sale ID',
'include_prices' => 'Include Prices?',
'insufficient_giftcard_balance' => 'ຍອດເງິນບັດຂອງຂວັນບໍ່ພຽງພໍສໍາລັບການຊໍາລະນີ້.',
'insufficient_reward_points' => 'ຄະແນນລາງວັນບໍ່ພຽງພໍສໍາລັບການຊໍາລະນີ້.',
'invoice' => 'Invoice',
'invoice_confirm' => 'This invoice will be sent to',
'invoice_enable' => 'Create Invoice',
'invoice_filter' => 'Invoices',
'invoice_no_email' => 'This customer does not have a valid email address',
'invoice_number' => 'Invoice #',
'invoice_number_duplicate' => 'Invoice Number must be unique.',
'invoice_sent' => 'Invoice sent to',
'invoice_total' => '',
'invoice_type_custom_invoice' => '',
'invoice_type_custom_tax_invoice' => '',
'invoice_type_invoice' => '',
'invoice_type_tax_invoice' => '',
'invoice_unsent' => 'Invoice failed to be sent to',
'invoice_update' => 'Recount',
'item_insufficient_of_stock' => 'Item has insufficient stock.',
'item_name' => 'Item Name',
'item_number' => 'Item #',
'item_out_of_stock' => 'Item is 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' => 'Register Mode',
'must_enter_numeric' => 'Amount Tendered must be a number.',
'must_enter_numeric_giftcard' => 'Gift Card Number must be a number.',
'must_enter_reference_code' => 'ຕ້ອງປ້ອນໝາຍເລກອ້າງອີງ/ດຶງຂໍ້ມູນ.',
'negative_amount_tendered' => 'ຈຳນວນເງິນທີ່ຈ່າຍບໍ່ສາມາດເປັນຄ່າລົບໄດ້.',
'negative_discount_invalid' => '',
'negative_price_invalid' => '',
'negative_quantity_invalid' => '',
'negative_total_invalid' => '',
'new_customer' => 'New Customer',
'new_item' => 'New Item',
'no_description' => 'None',
'no_filter' => 'All',
'no_items_in_cart' => 'There are no Items in the cart.',
'no_sales_to_display' => 'No Sales to display.',
'none_selected' => 'You have not selected any Sale(s) to delete.',
'nontaxed_ind' => '',
'not_authorized' => 'This action is not authorized.',
'one_or_multiple' => 'Sale(s)',
'payment' => 'Payment Type',
'payment_amount' => 'Amount',
'payment_not_cover_total' => 'Payment Amount must be greater than or equal to Total.',
'payment_type' => 'Type',
'payments' => '',
'payments_total' => 'Payments Total',
'price' => 'Price',
'print_after_sale' => 'Print after Sale',
'quantity' => 'Quantity',
'quantity_less_than_reorder_level' => 'Warning: Desired Quantity is below Reorder Level for that Item.',
'quantity_less_than_zero' => 'Warning: Desired Quantity is insufficient. You can still process the sale, but audit your inventory.',
'quantity_of_items' => 'Quantity of {0} Items',
'quote' => 'Quote',
'quote_number' => 'Quote Number',
'quote_number_duplicate' => 'Quote Number must be unique.',
'quote_sent' => 'Quote sent to',
'quote_unsent' => 'Quote failed to be sent to',
'receipt' => 'Sales Receipt',
'receipt_no_email' => '',
'receipt_number' => 'Sale #',
'receipt_sent' => 'Receipt sent to',
'receipt_unsent' => 'Receipt failed to be sent to',
'reference_code' => 'ລະຫັດອ້າງອີງການຊຳລະເງິນ',
'reference_code_invalid_characters' => 'ລະຫັດອ້າງອີງຕ້ອງມີແຕ່ຕົວອັກສອນ ແລະ ຕົວເລກເທົ່ານັ້ນ.',
'reference_code_length_error' => 'ຄວາມຍາວຂອງລະຫັດອ້າງອີງບໍ່ຖືກຕ້ອງ.',
'refund' => '',
'register' => 'Sales Register',
'remove_customer' => 'Remove Customer',
'remove_discount' => '',
'return' => 'Return',
'rewards' => 'Reward Points',
'rewards_balance' => 'Reward Points Balance',
'rewards_package' => 'Rewards',
'rewards_remaining_balance' => 'Reward Points remaining value is ',
'sale' => 'Sale',
'sale_by_invoice' => 'Sale by Invoice',
'sale_for_customer' => 'Customer:',
'sale_time' => 'Time',
'sales_tax' => 'Sales Tax',
'sales_total' => '',
'select_customer' => 'Select Customer (Optional)',
'send_invoice' => 'Send Invoice',
'send_quote' => 'Send Quote',
'send_receipt' => 'Send Receipt',
'send_work_order' => 'Send Work Order',
'serial' => 'Serial',
'service_charge' => '',
'show_due' => '',
'show_invoice' => 'Show Invoice',
'show_receipt' => 'Show Receipt',
'start_typing_customer_name' => 'Start typing customer details...',
'start_typing_item_name' => 'Start typing Item Name or scan Barcode...',
'stock' => 'Stock',
'stock_location' => 'Stock Location',
'sub_total' => 'Subtotal',
'successfully_deleted' => 'You have successfully deleted',
'successfully_restored' => 'You have successfully restored',
'successfully_suspended_sale' => 'Sale suspend successful.',
'successfully_updated' => 'Sale update successful.',
'suspend_sale' => 'Suspend',
'suspended_doc_id' => 'Document',
'suspended_sale_id' => 'ID',
'suspended_sales' => 'Suspended',
'table' => 'Table',
'takings' => 'Daily Sales',
'tax' => 'Tax',
'tax_id' => '',
'tax_invoice' => '',
'tax_percent' => 'Tax %',
'taxed_ind' => '',
'total' => 'Total',
'total_tax_exclusive' => 'Tax excluded',
'transaction_failed' => 'Sales Transaction failed.',
'unable_to_add_item' => 'Item add to Sale failed',
'unsuccessfully_deleted' => 'Sale(s) delete failed.',
'unsuccessfully_restored' => 'Sale(s) restore failed.',
'unsuccessfully_suspended_sale' => 'Sale suspend failed.',
'unsuccessfully_updated' => 'Sale update failed.',
'unsuspend' => 'Unsuspend',
'unsuspend_and_delete' => 'Action',
'update' => 'Update',
'upi' => '',
'visa' => '',
'wholesale' => '',
'work_order' => 'Work Order',
'work_order_number' => 'Work Order Number',
'work_order_number_duplicate' => 'Work Order Number must be unique.',
'work_order_sent' => 'Work Order sent to',
'work_order_unsent' => 'Work Order failed to be sent to',
];