Currently I have a script that checks to make sure that a test card was not submitted in production (since Authorize.net accepts test credit cards in live mode) and I add an error message to the credit card number if the one submitted is in the Test_Credit_Cards array like so:
TEST_CREDIT_CARDS = ['370000000000002', '6011000000000012', '4007000000027', '4012888818888']
validate :not_a_test_credit_card
def not_a_test_credit_card
self.errors[:cc_number] << "number is invalid!" if TEST_CREDIT_CARDS.include?(cc_number) and Rails.env.production?
end
Now on the front end the error message appears like so:
Credit card cc number is invalid!
Is there anyway to change the message to read Credit Card number is invalid! I just want to remove the cc portion from the message.
First, remove the number from the error message:
self.errors[:cc_number] << "is invalid!" if TEST_CREDIT_CARDS.include?(cc_number) and Rails.env.production?
Next, put a translation for cc_number in config/locales/en.yml:
en:
activerecord:
attributes:
credit_card:
cc_number: "number"
I prefer this answer over Anthony Alberto's answer for three reasons:
It is always a good idea to use ActiveRecord existing translation engine.
This way, cc_number will be translated to number whenever you add errors on it.
It is not true that the error is on the CreditCard instance itself, it is specifically related to the cc_number field.
That should do it :
self.errors[:base] << "number is invalid!" if TEST_CREDIT_CARDS.include?(cc_number) and Rails.env.production?
base refers to the object as a whole, not a specific attribute.
Related
I am simulating the passenger changeover process in metros using the Anylogic Pedestrian Library.
When passengers enter the vehicle, a seat is assigned to them from the seats available near the door (within a given distance) they entered the vehicle through, using a function called lookForSeat. If there is no more free seat available, their boolean parameter wantToSit is set to false and they will stay standing.
The parameter wantToSit is predefined for the Passenger Agent, with default value randomtrue(0.8). But even if I set it to default value = 1, I get the same error.
Then, passengers are separated using a PedSelectOutput block:
Condition 1: if ped.WantToSit = true --> they are sent to their
assigned seat coordinates (PointNode 'seatPoint', null by default)
Condition 2: true (thus, ped.WantToSit = false) --> they stay in the
standing area in the vehicle, no assigned seatPoint necessary in this case.
Now, it works pretty well, but when the majority of the seats is already occupied, suddenly the PedSelectOutput block directs a passenger with ped.wantToSit to its seating point, which gives null and I get the NullPointerException error.
Attached you find the function, the settings of PedSelectOutput and the log from the command.
As it can be seen, the PedSelectOutput sends the passenger through exit 1 (which gives the error due to calling the coordinates of a "null"), despite ped.wantToSit = false.
Any ideas, what is going wrong? For me it really looks like the function is working properly - I have been changing it the whole day until I realized that something in the PedSelectOutput block goes wrong.
Thank you in advance!
Pic 1: pedSelectOutput block and the command with the log
Pic 2: the function lookForSeat assigning the seats from the seat Collection
The problem here is a subtle one, which has caused me many hours of debugging as well. What you need to understand is that the on exit code is only executed once the agent already has a path to which it is going to exit. i.e. the selectOutput and subsequent blocks are already evaluated and only once it is determined that the agent can move to the next block then the on exit code is called. But the agent will continue on its chosen path that has been determined before the on exit code has been executed.
See the small example below:
I have a pedestrian with a variable that is true by default and a select output that checks this value
If I ran the model all pedestrians exit at the top option, as expected
If I change the variable to false on the On Exit code I might expect that all pedestrians will now exit at the second option
But they don't there is no change....
If I add the code to the on enter code then it does..
After I checkout choosing instamojo as my payment option, the following error shows up. I filled in the email field in the billing details and yet, it shows up. How do I fix this?
Notice: Undefined index: email in /home/thecoxiy/public_html/catalog/controller/payment/instamojo.php on line 42
/This is the instamojo.php file
This is the error
I tried commenting the email line (line 42) in which case 'this field may not be blank' still shows up except without the error message
I think the quick fix to this would be to push the email to session data and fetching it from there instead of order_info array, before you send it to instamojo.. I hope that should help.
How to change the default currency in Odoo 10.0 without exchange rate ?
I tried the method from http://www.surekhatech.com/blog/change-currency-in-pos-in-odoo-10
But I got the errors such as
When in POS, I tried to "Validate Closing & Post Entries", I got Odoo warning There is no account defined on the journal Cash for Profit involved in a cash difference and can not post the POS transaction.
While in POS checkout, the unsolved problems on https://www.odoo.com/forum/help-1/question/10-0-a-transaction-can-t-have-a-0-amount-none-error-on-validate-odoo-pos-payment-121554
How to fix them ?
I also includeed the recorded screen on youtube at : https://youtu.be/IahubLwnDDE
In solution of your 1st error you need to define opening and closing account in payment methods define in POS front. For that POS >> Configuraion >> Payment Methods. In that choose payment method which active in POS and from that there are 2 fields name "Default Debit Account" and "Default Credit Account" define accounts here. By adding accounts here your 1st error is resolved. Don't know much about second error if you know then late me know. :)
I've copied Vu's Script, (and of course renamed it) which have access to another DB, and when I run it I have in the output the old transaction name of the old script.
here is the old transaction name which are to seen in the output : MDM_GetAssociations
Here is the renamed transaction:MDM_GET_ASSOCIATIONS_Otmann
After renaming the transaction, I run the script, I got 2 errors:
1)
Error 14 undeclared identifier `MDM_GET_ASSOCIATIONS_Otmann' Action.c C:\GCDM_Test\Scripts\MDM\MDM_Get_POSTGRE_Otmann MDM_Get_POSTGRE_Otmann
2)
Error 15 type error in argument 1 to web_custom_request'; foundint' expected `pointer to const char' Action.c C:\GCDM_Test\Scripts\MDM\MDM_Get_POSTGRE_Otmann MDM_Get_POSTGRE_Otmann
and this is my script :
//########## start the test scenario ############
web_set_max_html_param_len("8000");
web_set_sockets_option("SSL_VERSION", "TLS");
web_add_auto_header("Content-Type","application/xml");
web_add_auto_header("Accept","application/json");
web_add_auto_header("Authorization",lr_eval_string("{AUTHORIZATION}"));
//GetAssociations, NOTE: our dummy customers have often NO associations!
web_reg_save_param("RESPONSE", "LB=", "RB=", "Search=Body", LAST);
lr_start_transaction((char*)MDM_GENERIC_TRANSACTION);
lr_start_transaction((char*)MDM_GET_ASSOCIATIONS);
web_custom_request(MDM_GET_ASSOCIATIONS,
"URL={TEST_ENV_HOSTNAME}/api/v3/clients/{BUSINESS_CONTEXT}/customers/{GCID}/associations",
"Method=GET",
"Resource=1", // => We are retrieving a ressource,
// which implies that it is not critical for the success of the script.
// Any failures (HTTP 404 - Not found etc.) in downloading the resource
// will be considered as warnings rather than errors.
"EncType=application/xml",
"Referer=Loadrunner",
LAST);
lr_end_transaction((char*)MDM_GET_ASSOCIATIONS, LR_AUTO);
lr_end_transaction((char*)MDM_GENERIC_TRANSACTION, LR_AUTO);
return 0;
}
and this is the output where the old transaction name apeared (MDM_GetAssociations), but I don't know where is she coded or from where she came, and as I said before when I try to change it in all position which has to do with Transactions,I got the errors mentioned above.
Here ist the output of the script, where you can see the name of the old the transaction(MDM_GetAssociations).
Action.c(13): Notify: Transaction "MDM_GenericServiceCall_ALL" started.
Action.c(14): Notify: Transaction "MDM_GetAssociations" started.
Action.c(15): web_custom_request("MDM_GetAssociations") started
Action.c(15): web_custom_request("MDM_GetAssociations") highest severity level was "warning", 505 body bytes, 1971 header bytes [MsgId: MMSG-26388]
Action.c(25): Notify: Transaction "MDM_GetAssociations" ended with "Pass" status (Duration: 1,8408 Wasted Time: 1,2668).
Action.c(26): Notify: Transaction "MDM_GenericServiceCall_ALL" ended with "Pass" status (Duration: 2,4066 Wasted Time: 1,2668).
Ending action Action.
Ending iteration 1.
You have two variables. You do not have their declarations here. You do not have their contents. And you appear to be casting them from another data type to a pointer to a character.
Does this pass with a literal, "My_Test_Transaction"? If so, then you are likely looking at oddities on how your variable is declared, populated and referenced.
I'm trying to handle UDH data for multipart messages and I want to use an appropriate error code when there's a problem with the multipart fields. There are several error codes for bad TLV's, but I don't see anything except generic failure messages that I could use for UDH. Is that the best I can do here, or is there a more direct message I could use?
Your observation is correct - there is not a single error defined for UDH.
If you want, you can use error codes from reserved section and assign specific meaning to one/some of them. I think the "Reserved for SMSC vendor specific errors" (0x400-0x4FF) can be a good candidate.
Actually it looks to me like ESME_RX_R_APPN = 0x66 "ESME receiver reject message error." is the best error code to throw here.
It should correspond to a permanent error for this message only and let further messages be processed.