Yeah not sure just hope this doesn't happen when I move to the live database with over 6000 members.
On Tue, Feb 14, 2012 at 6:50 AM, Richard Vézina <[email protected] > wrote: > Surely a desynchronized sequence... > > :) > > Richard > > On Mon, Feb 13, 2012 at 7:45 PM, Bruce Wade <[email protected]> wrote: > >> Deleting the database looks to have fixed it. >> >> >> On Mon, Feb 13, 2012 at 2:24 PM, Bruce Wade <[email protected]> wrote: >> >>> Yeah I don't think that is the issue because it has worked several times >>> before, probably a bug in the database I will just rebuild it and try again. >>> >>> >>> On Mon, Feb 13, 2012 at 2:08 PM, Richard Vézina < >>> [email protected]> wrote: >>> >>>> Try db.commit() between your two insert... Maybe web2py is doing only >>>> one commit at the end of your function, but since you do insert by hand >>>> instead of let the form insert your maybe have to commit... >>>> >>>> Richard >>>> >>>> >>>> On Mon, Feb 13, 2012 at 4:51 PM, Bruce Wade <[email protected]>wrote: >>>> >>>>> Didn't touch psql. there is 3 records in that table already, so I was >>>>> not sure why it would even default to 1. >>>>> >>>>> Here is the code that processes after the form is accepted. My code >>>>> didn't increment anything just standard web2py calls. >>>>> >>>>> ---- >>>>> if ucashmethod.process(formname='ucash').accepted: >>>>> """ >>>>> 1) Check payment amount >>>>> 2) Check owing amount >>>>> 3) Make sure payment amount is not greater then owing amount >>>>> 4) Make sure member has enough ucash to cover the payment >>>>> amount >>>>> 5) Complete the order >>>>> 6) Add to the capital investments >>>>> 7) Give all the sponsor bonus >>>>> 8) Redirect to thank you page >>>>> """ >>>>> if float(ucash_available) >= >>>>> float(product_details['product_orders'].owing): >>>>> print "ucash amount is good" >>>>> payment_amount = product_details['product_orders'].owing >>>>> ucash_before = distributor.ucash_balance >>>>> distributor.ucash_balance -= int(payment_amount) >>>>> distributor.ucash_balance_available -= int(payment_amount) >>>>> ucash_after = distributor.ucash_balance >>>>> >>>>> product_details['product_orders'].owing -= >>>>> int(payment_amount) >>>>> product_details['product_orders'].update_record() >>>>> distributor.update_record() >>>>> >>>>> payment = db.payments.insert( >>>>> order_id = product_details['product_orders'].id, >>>>> ack = '', >>>>> transactionid = '', >>>>> paymentstatus = 'Completed', >>>>> pendingreason = 'None', >>>>> currencycode = 'USD', >>>>> taxamt = '0.00', >>>>> paymenttype = 'Youcash', >>>>> token = 'N/A', >>>>> version = 1, >>>>> build = 1, >>>>> feeamt = '', >>>>> reasoncode = 'None', >>>>> amt = payment_amount, >>>>> correlationid = 'CORRELATIONID', >>>>> transactiontype = 'Youcash' >>>>> ) >>>>> >>>>> db.cash_journal.insert( >>>>> transaction_type = UCashChangeType.buy_product, >>>>> distributor_id = distributor.id, >>>>> happen_amount = -int(payment_amount), >>>>> ucash_before = ucash_before, >>>>> ucash_after = ucash_after, >>>>> transaction_id = payment, >>>>> operator_id = distributor.id >>>>> ) >>>>> >>>>> if product_details['product_orders'].owing <= 0: >>>>> # 1) add product, do bonus calculations >>>>> x = distributor_engine.addProduct(distributor, >>>>> product_details['products']) >>>>> buy_time = >>>>> distributor_engine.get_valid_buy_times(distributor) >>>>> >>>>> if distributor.id == 1: >>>>> # place member as root >>>>> #distributor_engine.place_member(None, None, None) >>>>> >>>>> distributor_engine.member_purchase_prod_calc(distributor, >>>>> product_details['products']) >>>>> elif (db(db.capital_investments.member_id == >>>>> distributor.id).count() > 1 and x != -1) or ((buy_time==0 or >>>>> buy_time==1) and distributor.upline_id and distributor.sponsor_id): >>>>> print "Calculating bonuses" >>>>> >>>>> >>>>> distributor_engine.member_purchase_prod_calc(distributor, >>>>> product_details['products']) >>>>> else: >>>>> session.flash = T("Sorry there is not enough ucash in your >>>>> account to complete this purchase!") >>>>> redirect(URL('products','payment/%s' % purchase_uuid)) >>>>> >>>>> #session.flash = 'Congrats for your new product' >>>>> redirect(URL('products','index')) >>>>> >>>>> On Mon, Feb 13, 2012 at 1:46 PM, Ron McOuat <[email protected]>wrote: >>>>> >>>>>> It is like the sequence for that primary key has started over with a >>>>>> reset to initial value since the key value that causes the exception is >>>>>> 1. >>>>>> To do that I would think you would have to tweak the sequence with psql >>>>>> while there is data in the table. >>>>>> >>>>>> Ron >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> -- >>>>> Regards, >>>>> Bruce Wade >>>>> http://ca.linkedin.com/in/brucelwade >>>>> http://www.wadecybertech.com >>>>> http://www.warplydesigned.com >>>>> http://www.fitnessfriendsfinder.com >>>>> >>>> >>>> >>> >>> >>> -- >>> -- >>> Regards, >>> Bruce Wade >>> http://ca.linkedin.com/in/brucelwade >>> http://www.wadecybertech.com >>> http://www.warplydesigned.com >>> http://www.fitnessfriendsfinder.com >>> >> >> >> >> -- >> -- >> Regards, >> Bruce Wade >> http://ca.linkedin.com/in/brucelwade >> http://www.wadecybertech.com >> http://www.warplydesigned.com >> http://www.fitnessfriendsfinder.com >> > > -- -- Regards, Bruce Wade http://ca.linkedin.com/in/brucelwade http://www.wadecybertech.com http://www.warplydesigned.com http://www.fitnessfriendsfinder.com

