Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete the phone-based approvals process #27

Open
pdestefanis opened this issue Feb 3, 2012 · 2 comments
Open

Complete the phone-based approvals process #27

pdestefanis opened this issue Feb 3, 2012 · 2 comments

Comments

@pdestefanis
Copy link
Owner

The approvals process does not seem to be completely implemented as specified in the design:

OK [Item ID] : Approves the aggregate count of [Item ID] at the facility to which the phone is registered. The phone sending the message must be assigned to a user linked to the facility.

The approval should insert a record indicating that an authorized user approved the current [aggregated] quantity for a given facility at a given moment in time. The information below seems to provide some of that functionality.

For an approval to be accepted by the system, it needs to originate from a phone associated with a user. The facility associated with the user (not with the phone) will indicate the level at which the aggregate counts are approved. If the sending phone is not associated with any user, then system returns an error.

/* Find the phone ID of the sender
SELECT phones.id as pid FROM phones WHERE substring(phones.phonenumber FROM -8)=substring(' 251923799639' FROM -8) limit 1

/* Find if the sending phone is active
SELECT CASE WHEN phones.deleted = 1 THEN 0 ELSE phones.active END as status FROM phones WHERE phones.id='86' limit 1

/* Finds the location ID associated with the phone
SELECT locationLongitude, locationLatitude, locations.id as lid, phones.id as pid FROM locations, phones WHERE location_id = locations.id and phones.id='86' limit 1

/* Finds the item whose quantity we want to approve
SELECT items.id as did FROM items WHERE items.code = UPPER('TEO') limit 1

/* Finds the last quantity reported for that item in that location
/* This will not work if the sender is associated with an upstream facility, as it is usually the case
/* We need to mark approval for all the quantities for the given item in the child facilities
SELECT quantity_after FROM stats s WHERE s.item_id = 24 AND s.location_id = 191 AND s.id = (select max(st.id) from stats st where st.item_id = s.item_id AND location_id = 191 ) ORDER by created DESC

/* Stores the message received
INSERT INTO messagereceiveds (phone_id, created, rawmessage) VALUES (86, '2012-02-04 00:17:38', 'OK TEO 251923799639')

There is no indication that the approval process is storing information related to the approval in the approvals or approvals_stats tables.
Need to verify if the system is checking that the user can actually post an approval

@lachko
Copy link
Collaborator

lachko commented Feb 4, 2012

There is storing into the database, line $dbManip->approveAll($sum, $smsManip->getApprovalId()); for approve all and $dbManip->approveOne($smsManip->getItemId(), $sum, $smsManip->getApprovalId()); for approve one. Lines 61 and 71 from process sms

@pdestefanis
Copy link
Owner Author

Hi Lachko, glad to see that you are still monitoring this! :)
I was testing this yesterday just to see what needs may need updating, the SQL lines above are from the MySQL query log, and I did not look into the code (just reverse engineering what was going on).

I see that this is only present in the orbis-dev instance (where I don't even get a message with the results of the operation). Will check with Noble to see what happened.

@ghost ghost assigned beyondprograms Feb 4, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants