ledger123 / runmyaccounts

SQL-Ledger Customizations by Run My Accounts
GNU General Public License v2.0
16 stars 9 forks source link

[IBP-487/IBP-1278] Add validation for date fields #561

Closed barworobiec closed 1 month ago

barworobiec commented 1 month ago

Hi @ledger123 we noticed that, few customers by mistake might put the wrong value in date fields, for example we found few dates like: 20023. Could you please add validation to all date fields with checking if year of the date is greater than current_year + offset, and put the offset as a variable in configuration file. If the value is greater than, just throw an error.

ledger123 commented 1 month ago

Hi @barworobiec ,

I have added validation with offset days defined in Form.pm (to avoid changing all isvaldate calls).

Also I have added validation for new transactions only so that any existing transactions with dates outside offset don't get disturbed when user tries to edit them.

Test and let me know any issues.

Regards

barworobiec commented 1 month ago

@ledger123 we have a issue, when we are now saving the customer to ledger we are getting the error: Error! Day '2024' out of range 1..30 at SL/Form.pm line 4686.

This's the request: ct.pl?login=user password=pw action=save path=bin%2Fmozilla ARAP=AR db=customer id=0 addressid=0 contactid=0 typeofcontact=company gender=M update_contact=1 customernumber=20349 name=dummy+dummy+Postman+REG+110+EN+ startdate=2024-09-24 enddate= salutation= firstname=dummy+dummy lastname=Postman+REG+110+EN+ address1=dummy+4 address2= post_office= zipcode=1234 city=Vessy state= country= is_migrated=1 phone= fax= mobile= email= contacttitle= occupation= cc= bcc= taxnumber= notes= language_code= remittancevoucher=1 payment_accno=1020--dummy+4+%281020%29 arap_accno=1100--dummy curr=CHF creditlimit=0.0 threshold=0.0 sic_code= discount=0.0 bankname= bankaddress1= bankaddress2= bankpost_office= bankzipcode= bankcity= bankcountry= bankis_migrated=1 bankstate= bic= iban= tax_2201=1 tax_2202=1 tax_2203=1 taxaccounts=2201+2202+2203login=user password=pw action=save path=bin%2Fmozilla ARAP=AR db=customer id=0 addressid=0 contactid=0 typeofcontact=company gender=M update_contact=1 customernumber=20349 name=dummy+dummy+Postman+REG+110+EN+ startdate=2024-09-24 enddate= salutation= firstname=dummy+dummy lastname=Postman+REG+110+EN+ address1=dummy+4 address2= post_office= zipcode=1234 city=Vessy state= country= is_migrated=1 phone= fax= mobile= email= contacttitle= occupation= cc= bcc= taxnumber= notes= language_code= remittancevoucher=1 payment_accno=1020--dummy+4+%281020%29 arap_accno=1100--dummy curr=CHF creditlimit=0.0 threshold=0.0 sic_code= discount=0.0 bankname= bankaddress1= bankaddress2= bankpost_office= bankzipcode= bankcity= bankcountry= bankis_migrated=1 bankstate= bic= iban= tax_2201=1 tax_2202=1 tax_2203=1 taxaccounts=2201+2202+2203login=user password=pw action=save path=bin%2Fmozilla ARAP=AR db=customer id=0 addressid=0 contactid=0 typeofcontact=company gender=M update_contact=1 customernumber=20349 name=dummy+dummy+Postman+REG+110+EN+ startdate=2024-09-24 enddate= salutation= firstname=dummy+dummy lastname=Postman+REG+110+EN+ address1=dummy+4 address2= post_office= zipcode=1234 city=Vessy state= country= is_migrated=1 phone= fax= mobile= email= contacttitle= occupation= cc= bcc= taxnumber= notes= language_code= remittancevoucher=1 payment_accno=1020--dummy+4+%281020%29 arap_accno=1100--dummy curr=CHF creditlimit=0.0 threshold=0.0 sic_code= discount=0.0 bankname= bankaddress1= bankaddress2= bankpost_office= bankzipcode= bankcity= bankcountry= bankis_migrated=1 bankstate= bic= iban= tax_2201=1 tax_2202=1 tax_2203=1 taxaccounts=2201+2202+2203

The problematic here is the date format: 2024-09-24, but on master branch it works fine.

ledger123 commented 1 month ago

This issue is corrected.

You can test it by sending request to my server.

Regards

barworobiec commented 1 month ago

@ledger123 works fine. Thanks.