Hello everybody!
I yesterday had another interesting day in the wonderful world of Sorax. The story starts with the quiet and marvelous girls of operations, who never use to open tickets or to come with complicated requests (I have just realized that you, lovely-and-probably-non-existent reader, are not able to get the sarcastic tone in my worlds, but in my mind there no room for doubts, I am being sarcastic, they always have the most complicated and imaginative ways to make my labour as hard as interesting. I would be nothing without them).
One of these girls, the manager indeed, had a simply-looked and nothing crazy request. Change the set up of a specific customer, she needed that, after this customer takes his fuel, to generate his invoice not this day, how is suppose to be, but 4 days after. "Ok", I think, "It's time to move some walls". But after I started my job she noticed me. "Now we are doing similar with other customers, you can do the same with this one".
Wow! My lucky day, This was going to be easy as a pie!. I just had to look for in the code (this is still kind of scaring) in which part this invoice date is generated and, hopefully find an exception to this other ones and copy and paste. In five minutes it would be done! Even there was a chance that in the customer window already exist a way to change that! (I feel the obligation to warn you, my lovely reader, that now I don't mean to be sarcastic at all. I actually thought that) My first try was this one, I look into the customer settings with the purpose to find this magic key to change the invoice configuration. Of course it wasn't, this should be kind of foresighted and in this application nothing is ready to be used. If they have needed some special configuration in a moment, they put the modification how it comes, with no taking the possibility of apply the same change to another different item, understanding item as customer, order or whatever.
Second try, look into the code to get the point of invoice date generation. This could be easy in any application but it never is in Sorax. But I was hoping it wouldn't be harder than other complicated changes I had to do. I was wrong. There is no place on Sorax where the date is calculated. There is no exception write in Sorax, this date is shown in a report and it is created dynamically when the report is created, this date is not stored or updated in any time, just get a couple of rules, and applied them in the stored procedure (this is a command, for foreign ones, which is placed on the database instead the code, and is not the best place to put business rules, in the other way this is the best way to get raw data from the database and it never happens, life is tough).
Ok, the date is calculated on the fly and the rules to do the exceptions are the craziest rules to do anything in the world.Seriously. I'm glad to explain, I'll put all my energies to explain it in the most simple and less technical way it can be possible.
Firstly I'll explain how I would've done it, in the strange scenario that I would've done in a stored procedure, perhaps in a parallel universe where I am forever drunk. I would've put a condition to know if the customer is an exception and if it is, I would've write a simple rule like "if the customer is an exception the date is 'usual date' plus 2" or better, "if the customer is this one, date is 'usual date' plus 2, if it is this other, date is 'usual date' plus 4, any other just get the 'usual bloody date'." write this in the code is as simple as it looks, really, as my girlfriend says: easy peasy.
Now I'll explain how it is done. In some part of the code (actually in the middle of an instruction to get data) there is a condition, similar than my condition in the structure, but not in the meaning. "If the customer is any of the special ones, just change in a non-permanent way, just to the report, the delivery method to this other delivery method which is being used for other things, but we are gonna use it for this too, for the other let the delivery method as it is" (this delivery method is a little related to the generation of the date, but actually it isn't that much, just different method had different payment rules, but it does not apply in this case... or it shouldn't). In other part of the code there is another condition, the one with the dates. "If delivery method is 2, calculate as usual, but if you don't have all the data to do it (because it is possible that some bastard put a fake delivery method in here) that means that this is one of the special customers. It this is happening, just check not the unique identifier of the customer but the payment term of it, if it is X add one day to the 'usual date' because this is the special among the special ones, but if the payment term is another just add 2 days" What??? C'mon!! Are you fucking serious? I had to read it through like ten bloody times to get that was actually what i was looking for. I got quite confused, I had to talk with the requester to be sure that I was understanding everything, after I read it again and repeat this chat-read process like three times.
Finally I changed the crazy way to a intermediate point between this one, and my drunk-parallel-universe way to make it just some kind of easy to add a new customer to the exceptions. Now, cross your fingers to haven't break any other place in this never-boring labyrinth. Maybe I have not been quite able to make you, my always lovely reader, such a crazy stuff was this, I have read the explanation like three times and looks like I am complaining about nothing. If it was the situation, please don't trust in the appearances, it has been quite mad.
I had time to do more interesting things, but no-one of them as remarkable to this one. Even the last problem with the invoices (of course, something is always happening with invoices), though it is not quite fixed yet after a whole week looking at it, has been so regular if you compare with this thing.
Never got bored in this place!
See you around!
No comments:
Post a Comment