zaviagodev / frappe

MIT License
0 stars 1 forks source link

OverflowError: data value out of range /app/sales-invoice #134

Closed chomchuen closed 11 months ago

chomchuen commented 11 months ago

Can't submit sales invoice. Please investigate what caused this. (13/12/23 - Can submit sales invoice normally.) Image

--

App Versions

{
    "apps_maintainer": "0.0.1",
    "business_automations": "0.0.1",
    "erpnext": "15.5.0",
    "frappe": "15.4.1",
    "test_app": "0.0.1"
}

Route

Form/Sales Invoice/ACC-SINV-2023-00005

Traceback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 110, in application
    response = frappe.api.handle(request)
  File "apps/frappe/frappe/api/__init__.py", line 49, in handle
    data = endpoint(**arguments)
  File "apps/frappe/frappe/api/v1.py", line 36, in handle_rpc_call
    return frappe.handler.handle()
  File "apps/frappe/frappe/handler.py", line 49, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/handler.py", line 85, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "apps/frappe/frappe/__init__.py", line 1715, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
  File "apps/frappe/frappe/desk/form/save.py", line 37, in savedocs
    doc.submit()
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1038, in submit
    return self._submit()
  File "apps/frappe/frappe/model/document.py", line 1019, in _submit
    return self.save()
  File "apps/frappe/frappe/model/document.py", line 334, in save
    return self._save(*args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 386, in _save
    self.run_post_save_methods()
  File "apps/frappe/frappe/model/document.py", line 1121, in run_post_save_methods
    self.run_method("on_submit")
  File "apps/frappe/frappe/model/document.py", line 950, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1316, in composer
    return composed(self, method, *args, **kwargs)
  File "apps/frappe/frappe/model/document.py", line 1298, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "apps/frappe/frappe/model/document.py", line 947, in fn
    return method_object(*args, **kwargs)
  File "apps/erpnext/erpnext/accounts/doctype/sales_invoice/sales_invoice.py", line 475, in on_submit
    self.make_loyalty_point_entry()
  File "apps/erpnext/erpnext/accounts/doctype/sales_invoice/sales_invoice.py", line 1739, in make_loyalty_point_entry
    "expiry_date": add_days(self.posting_date, lp_details.expiry_duration),
  File "apps/frappe/frappe/utils/data.py", line 264, in add_days
    return add_to_date(date, days=days)
  File "apps/frappe/frappe/utils/data.py", line 250, in add_to_date
    date = date + relativedelta(
  File "env/lib/python3.10/site-packages/dateutil/relativedelta.py", line 405, in __radd__
    return self.__add__(other)
  File "env/lib/python3.10/site-packages/dateutil/relativedelta.py", line 387, in __add__
    ret = (other.replace(**repl)
OverflowError: date value out of range

Request Data

{
    "type": "POST",
    "args": {
        "doc": "{\"name\":\"ACC-SINV-2023-00005\",\"owner\":\"Administrator\",\"creation\":\"2023-12-13 14:56:56.273925\",\"modified\":\"2023-12-13 15:01:33.354712\",\"modified_by\":\"Administrator\",\"docstatus\":0,\"idx\":0,\"custom_customer_5\":\"\",\"custom_payment_type\":\"Recieve\",\"custom_channel23232\":\"Unpaid\",\"custom_channel\":\"Shopee\",\"customer\":\"Muzammal rasool\",\"due_date\":\"2023-12-13\",\"posting_date\":\"2023-12-13\",\"posting_time\":\"15:01:33.664397\",\"shipping_address_name\":\"Muzammal rasool-Billing\",\"shipping_address\":\"Street 3<br>\\nChak Jhumra<br>Faisalabad<br>\\nPunjab<br>0007<br>Pakistan<br>\\n<br>\\n\",\"title\":\"Muzammal rasool\",\"naming_series\":\"ACC-SINV-.YYYY.-\",\"customer_name\":\"Muzammal rasool\",\"company\":\"Zaviago\",\"set_posting_time\":0,\"is_pos\":0,\"is_consolidated\":0,\"is_return\":0,\"update_billed_amount_in_sales_order\":0,\"update_billed_amount_in_delivery_note\":1,\"is_debit_note\":0,\"currency\":\"THB\",\"conversion_rate\":1,\"selling_price_list\":\"Standard Selling\",\"price_list_currency\":\"THB\",\"plc_conversion_rate\":1,\"ignore_pricing_rule\":0,\"update_stock\":1,\"set_warehouse\":\"Stores - Z\",\"base_total\":48000,\"base_net_total\":43200,\"custom_is_cod\":0,\"total_net_weight\":0,\"total_qty\":1,\"total\":48000,\"net_total\":43200,\"tax_category\":\"\",\"base_total_taxes_and_charges\":4024,\"total_taxes_and_charges\":4024,\"apply_discount_on\":\"Net Total\",\"base_discount_amount\":4800,\"is_cash_or_non_trade_discount\":0,\"additional_discount_percentage\":10,\"discount_amount\":4800,\"base_grand_total\":47224,\"base_rounding_adjustment\":0,\"base_rounded_total\":47224,\"base_in_words\":\"\",\"grand_total\":47224,\"rounding_adjustment\":0,\"use_company_roundoff_cost_center\":0,\"rounded_total\":47224,\"in_words\":\"\",\"total_advance\":0,\"outstanding_amount\":47224,\"disable_rounded_total\":0,\"other_charges_calculation\":\"<div class=\\\"tax-break-up\\\" style=\\\"overflow-x: auto;\\\">\\n\\t<table class=\\\"table table-bordered table-hover\\\">\\n\\t\\t<thead>\\n\\t\\t\\t<tr>\\n\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t<th class=\\\"text-left\\\">Item</th>\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t<th class=\\\"text-right\\\">Taxable Amount</th>\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t<th class=\\\"text-right\\\">VAT</th>\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t<th class=\\\"text-right\\\">Freight and Forwarding Charges</th>\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\n\\t\\t\\t</tr>\\n\\t\\t</thead>\\n\\t\\t<tbody>\\n\\t\\t\\t\\n\\t\\t\\t\\t<tr>\\n\\t\\t\\t\\t\\t<td>apple15</td>\\n\\t\\t\\t\\t\\t<td class=\\\"text-right\\\">\\n\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t\\t฿ 43,200.00\\n\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t</td>\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t\\t<td class=\\\"text-right\\\">\\n\\t\\t\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t(7.0%)\\n\\t\\t\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t฿ 3,024.00\\n\\t\\t\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t\\t</td>\\n\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t\\t<td class=\\\"text-right\\\">\\n\\t\\t\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t\\t\\t\\t฿ 1,000.00\\n\\t\\t\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\t\\t</td>\\n\\t\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t\\t\\n\\t\\t\\t\\t</tr>\\n\\t\\t\\t\\n\\t\\t</tbody>\\n\\t</table>\\n</div>\",\"total_billing_hours\":0,\"total_billing_amount\":0,\"custom_paid_amount____thb_\":0,\"custom_outstanding_amount__thb\":0,\"base_paid_amount\":0,\"paid_amount\":0,\"base_change_amount\":0,\"change_amount\":0,\"allocate_advances_automatically\":0,\"only_include_allocated_payments\":0,\"write_off_amount\":0,\"base_write_off_amount\":0,\"write_off_outstanding_amount_automatically\":0,\"redeem_loyalty_points\":0,\"loyalty_amount\":0,\"custom_shipping_provider\":\"J&T Express\",\"custom_provider_status\":\"Awaiting Collection\",\"address_display\":\"Street 3<br>\\nChak Jhumra<br>Faisalabad<br>\\nPunjab<br>0007<br>Pakistan<br>\\n<br>\\n\",\"customer_address\":\"Muzammal rasool-Billing\",\"contact_person\":\"Muzammal rasool-Muzammal rasool\",\"contact_display\":\"Muzammal rasool\",\"contact_mobile\":\"03015935652\",\"contact_email\":\"muzammal@zaviago.com\",\"territory\":\"All Territories\",\"loyalty_program\":\"Zaviago Club\",\"loyalty_points\":0,\"ignore_default_payment_terms_template\":0,\"po_no\":\"\",\"debit_to\":\"Debtors - Z\",\"party_account_currency\":\"THB\",\"is_opening\":\"No\",\"against_income_account\":\"Sales - Z\",\"amount_eligible_for_commission\":43200,\"commission_rate\":0,\"total_commission\":0,\"group_same_items\":0,\"language\":\"en\",\"status\":\"Draft\",\"customer_group\":\"Government\",\"is_internal_customer\":0,\"is_discounted\":0,\"remarks\":\"No Remarks\",\"repost_required\":0,\"custom_custom_average_order_value_2\":0,\"custom_lifetime_value_1\":0,\"doctype\":\"Sales Invoice\",\"advances\":[],\"payments\":[],\"payment_schedule\":[{\"name\":\"aeb5fd9f25\",\"owner\":\"Administrator\",\"creation\":\"2023-12-13 14:56:56.595321\",\"modified\":\"2023-12-13 15:01:33.354712\",\"modified_by\":\"Administrator\",\"docstatus\":0,\"idx\":1,\"due_date\":\"2023-12-13\",\"invoice_portion\":100,\"discount\":0,\"payment_amount\":47224,\"outstanding\":47224,\"paid_amount\":0,\"discounted_amount\":0,\"base_payment_amount\":47224,\"parent\":\"ACC-SINV-2023-00005\",\"parentfield\":\"payment_schedule\",\"parenttype\":\"Sales Invoice\",\"doctype\":\"Payment Schedule\"}],\"taxes\":[{\"name\":\"465b3f15ac\",\"owner\":\"Administrator\",\"creation\":\"2023-12-13 14:56:56.273925\",\"modified\":\"2023-12-13 15:01:33.354712\",\"modified_by\":\"Administrator\",\"docstatus\":0,\"idx\":1,\"charge_type\":\"On Net Total\",\"account_head\":\"VAT - Z\",\"description\":\"VAT\",\"included_in_print_rate\":0,\"included_in_paid_amount\":0,\"cost_center\":\"Main - Z\",\"rate\":7,\"tax_amount\":3024,\"total\":46224,\"tax_amount_after_discount_amount\":3024,\"base_tax_amount\":3024,\"base_total\":46224,\"base_tax_amount_after_discount_amount\":3024,\"item_wise_tax_detail\":\"{\\\"apple15\\\":[7,3024]}\",\"dont_recompute_tax\":0,\"parent\":\"ACC-SINV-2023-00005\",\"parentfield\":\"taxes\",\"parenttype\":\"Sales Invoice\",\"doctype\":\"Sales Taxes and Charges\"},{\"name\":\"961a354300\",\"owner\":\"Administrator\",\"creation\":\"2023-12-13 14:56:56.273925\",\"modified\":\"2023-12-13 15:01:33.354712\",\"modified_by\":\"Administrator\",\"docstatus\":0,\"idx\":2,\"charge_type\":\"Actual\",\"account_head\":\"Freight and Forwarding Charges - Z\",\"description\":\"Freight and Forwarding Charges\",\"included_in_print_rate\":0,\"included_in_paid_amount\":0,\"cost_center\":\"Main - Z\",\"rate\":0,\"account_currency\":\"THB\",\"tax_amount\":1000,\"total\":47224,\"tax_amount_after_discount_amount\":1000,\"base_tax_amount\":1000,\"base_total\":47224,\"base_tax_amount_after_discount_amount\":1000,\"item_wise_tax_detail\":\"{\\\"apple15\\\":[0,1000]}\",\"dont_recompute_tax\":0,\"parent\":\"ACC-SINV-2023-00005\",\"parentfield\":\"taxes\",\"parenttype\":\"Sales Invoice\",\"doctype\":\"Sales Taxes and Charges\"}],\"sales_team\":[],\"packed_items\":[],\"custom_payment_details\":[],\"custom_past_orders_1\":[],\"pricing_rules\":[],\"custom_add_tracking_number_table\":[],\"timesheets\":[],\"items\":[{\"name\":\"612cba15db\",\"owner\":\"Administrator\",\"creation\":\"2023-12-13 14:56:56.273925\",\"modified\":\"2023-12-13 15:01:33.354712\",\"modified_by\":\"Administrator\",\"docstatus\":0,\"idx\":1,\"has_item_scanned\":0,\"item_code\":\"apple15\",\"item_name\":\"iPhone 15 Pro Max\",\"description\":\"iPhone 15 Pro Max\",\"item_group\":\"All Item Groups\",\"image\":\"/files/iphone15_pro_max.png\",\"qty\":1,\"stock_uom\":\"Unit\",\"uom\":\"Unit\",\"conversion_factor\":1,\"stock_qty\":1,\"price_list_rate\":48000,\"base_price_list_rate\":48000,\"margin_type\":\"\",\"margin_rate_or_amount\":0,\"rate_with_margin\":0,\"discount_percentage\":0,\"discount_amount\":0,\"base_rate_with_margin\":0,\"rate\":48000,\"amount\":48000,\"base_rate\":48000,\"base_amount\":48000,\"pricing_rules\":\"\",\"stock_uom_rate\":48000,\"is_free_item\":0,\"grant_commission\":1,\"net_rate\":43200,\"net_amount\":43200,\"base_net_rate\":43200,\"base_net_amount\":43200,\"delivered_by_supplier\":0,\"income_account\":\"Sales - Z\",\"is_fixed_asset\":0,\"expense_account\":\"Cost of Goods Sold - Z\",\"enable_deferred_revenue\":0,\"weight_per_unit\":0,\"total_weight\":0,\"warehouse\":\"Stores - Z\",\"incoming_rate\":35000,\"allow_zero_valuation_rate\":0,\"item_tax_rate\":\"{}\",\"actual_batch_qty\":0,\"actual_qty\":97,\"delivered_qty\":0,\"cost_center\":\"Main - Z\",\"page_break\":0,\"parent\":\"ACC-SINV-2023-00005\",\"parentfield\":\"items\",\"parenttype\":\"Sales Invoice\",\"doctype\":\"Sales Invoice Item\"}],\"__onload\":{\"make_payment_via_journal_entry\":0},\"__last_sync_on\":\"2023-12-14T03:56:01.507Z\"}",
        "action": "Submit"
    },
    "btn": {
        "jQuery370047883728363955691": {
            "events": {
                "click": [
                    {
                        "type": "click",
                        "origType": "click",
                        "guid": 2805,
                        "namespace": ""
                    }
                ]
            }
        }
    },
    "freeze": true,
    "headers": {},
    "error_handlers": {},
    "url": "/api/method/frappe.desk.form.save.savedocs",
    "request_id": null
}

Response Data

{
    "exception": "OverflowError: date value out of range",
    "exc_type": "OverflowError",
    "_exc_source": "erpnext (app)"
}
umer2001 commented 11 months ago

@chomchuen It was not a bug, it was caused by a misconfiguration in the Loyalty Program Expiry Duration (in days) field. the maximum value that can is 999999 you had 9999999 (1 extra digit) which caused the issue.