def create(self, vm): try: self.validate_code(vm) self.validate_name(vm) if vm.pwd == None or len(vm.pwd) < 1: raise Exception("You must enter a Password.") self.validate_account_type(vm) self.validate_comm_per(vm) # init data vm.bal_amt = 0 da = AgentDataAccess() da.create(vm) except Exception as ex: audit_da = UserAuditTrailDataAccess() audit_da.create(vm.user_code, 'Create Agent', 'Fail. Error=%s' % str(ex)) raise ex audit_da = UserAuditTrailDataAccess() audit_da.create(vm.user_code, 'Create Agent', 'Ok.')
def __create(self, vm): # get master seq master_da = MasterDataAccess() master = master_da.get('Deposit') master.seq += 1 master.put() # insert deposit tran_code = Deposit.get_tran_code(master.seq) vm.tran_code = tran_code data = Deposit(parent=self.get_key(vm.tran_date, vm.agent_code), id=tran_code) data.tran_code = tran_code data.tran_type = vm.tran_type data.tran_date = vm.tran_date data.seq = master.seq data.agent_code = vm.agent_code data.agent = vm.agent.key data.remark = vm.remark data.amt = vm.amt data.payment_date = vm.payment_date data.payment_type = vm.payment_type data.payment_ref_no = vm.payment_ref_no data.payment_file_name = vm.payment_file_name data.payment_url = vm.payment_url data.verified_by = '' data.verified_date = None data.verify_status = 0 data.created_by = vm.user_code data.created_date = DateTime.malaysia_now() data.modified_by = '' data.modified_date = None data.void_by = '' data.void_date = None data.void = False data.last_modified = str(data.created_date) data.put() # insert tran tran_obj = TranViewModel() tran_obj.tran_code = data.tran_code tran_obj.tran_date = data.tran_date tran_obj.tran_type = data.tran_type tran_obj.agent_code = data.agent_code tran_da = TranDataAccess() tran_da.create(tran_obj) # update agent bal amt agent_da = AgentDataAccess() agent = agent_da.get(vm.agent_code) agent.bal_amt += vm.amt agent.bal_amt = round(agent.bal_amt, 2) agent.put()
def create(self, buy_obj): # get agent agent_da = AgentDataAccess() agent = agent_da.get(buy_obj.agent_code) if agent is None: raise Exception('Agent not found.') buy_obj.agent = agent self.__create(buy_obj)
def create(self, vm): # get agent agent_da = AgentDataAccess() agent = agent_da.get(vm.agent_code) if agent is None: raise Exception('Agent not found.') vm.agent = agent self.__create(vm)
def change_pwd(self, vm): try: da = AgentDataAccess() da.change_pwd(vm) except Exception as ex: audit_da = AgentAuditTrailDataAccess() audit_da.create(vm.code, 'Change Agent Password', 'Fail. Error=%s' % str(ex)) raise ex audit_da = AgentAuditTrailDataAccess() audit_da.create(vm.code, 'Change Agent Password', 'Ok.')
def update(self, vm): try: self.valiate(vm) da = AgentDataAccess() da.account_update(vm) except Exception as ex: audit_da = AgentAuditTrailDataAccess() audit_da.create(vm.code, 'Update Agent', 'Fail. Error=%s' % str(ex)) raise ex audit_da = AgentAuditTrailDataAccess() audit_da.create(vm.code, 'Update Agent', 'Ok.')
def update(self, vm): try: self.validate_code(vm) self.validate_name(vm) self.validate_account_type(vm) self.validate_comm_per(vm) da = AgentDataAccess() da.update(vm) except Exception as ex: audit_da = UserAuditTrailDataAccess() audit_da.create(vm.user_code, 'Update Agent', 'Fail. Error=%s' % str(ex)) raise ex audit_da = UserAuditTrailDataAccess() audit_da.create(vm.user_code, 'Update Agent', 'Ok.')
def create(self, vm): # get agent agent_da = AgentDataAccess() agent = agent_da.get(vm.agent_code) if agent is None: raise Exception('Agent not found.') vm.agent = agent # get car car_da = CarDataAccess() car = car_da.get(vm.car_reg_no) if car is None: raise Exception('Car not found.') vm.car = car self.__create(vm)
def create(self, vm): # get agent agent_da = AgentDataAccess() agent = agent_da.get(vm.agent_code) if agent is None: raise Exception('Agent not found.') vm.agent = agent # save customer customer_vm = CustomerViewModel() customer_vm.ic = vm.customer_ic customer_vm.name = vm.customer_name customer_vm.address = vm.customer_address customer_vm.tel = vm.customer_tel customer_vm.hp = vm.customer_hp customer_vm.email = vm.customer_email customer_da = CustomerDataAccess() vm.customer = customer_da.save_register(customer_vm) self.__create(vm)
def __create(self, vm): # get master seq master_da = MasterDataAccess() master = master_da.get('TopUp') master.seq += 1 master.put() # insert deposit tran_code = TopUp.get_tran_code(master.seq) vm.tran_code = tran_code data = TopUp(parent=self.get_key(vm.tran_date, vm.agent_code), id=tran_code) data.tran_code = tran_code data.tran_type = vm.tran_type data.tran_date = vm.tran_date data.seq = master.seq data.agent_code = vm.agent_code data.agent = vm.agent.key data.remark = vm.remark data.car_reg_no = vm.car_reg_no data.car = vm.car.key data.sub_total = vm.sub_total data.comm_per = vm.comm_per data.comm_amt = vm.comm_amt data.amt = vm.amt data.created_by = vm.user_code data.created_date = DateTime.malaysia_now() data.modified_by = '' data.modified_date = None data.void_by = '' data.void_date = None data.void = False data.last_modified = str(data.created_date) data.put() # insert tran tran_obj = TranViewModel() tran_obj.tran_code = data.tran_code tran_obj.tran_date = data.tran_date tran_obj.tran_type = data.tran_type tran_obj.agent_code = data.agent_code tran_obj.car_reg_no = data.car_reg_no tran_da = TranDataAccess() tran_da.create(tran_obj) # update agent bal amt agent_da = AgentDataAccess() agent = agent_da.get(vm.agent_code) agent.bal_amt -= vm.amt agent.bal_amt = round(agent.bal_amt, 2) if agent.bal_amt < agent.credit_limit: raise Exception('You have no more Credits.') agent.put() # update car bal amt car_da = CarDataAccess() car = car_da.get(vm.car_reg_no) car.bal_amt += vm.sub_total car.bal_amt = round(car.bal_amt, 2) car.put()
def __create(self, vm): # get master seq master_da = MasterDataAccess() master = master_da.get('Deposit') master.seq += 1 master.put() # insert deposit tran_code = Deposit.get_tran_code(master.seq) vm.tran_code = tran_code data = Deposit( parent=self.get_key(vm.tran_date, vm.agent_code), id=tran_code ) data.tran_code = tran_code data.tran_type = vm.tran_type data.tran_date = vm.tran_date data.seq = master.seq data.agent_code = vm.agent_code data.agent = vm.agent.key data.remark = vm.remark data.amt = vm.amt data.payment_date = vm.payment_date data.payment_type = vm.payment_type data.payment_ref_no = vm.payment_ref_no data.payment_file_name = vm.payment_file_name data.payment_url = vm.payment_url data.verified_by = '' data.verified_date = None data.verify_status = 0 data.created_by = vm.user_code data.created_date = DateTime.malaysia_now() data.modified_by = '' data.modified_date = None data.void_by = '' data.void_date = None data.void = False data.last_modified = str(data.created_date) data.put() # insert tran tran_obj = TranViewModel() tran_obj.tran_code = data.tran_code tran_obj.tran_date = data.tran_date tran_obj.tran_type = data.tran_type tran_obj.agent_code = data.agent_code tran_da = TranDataAccess() tran_da.create(tran_obj) # update agent bal amt agent_da = AgentDataAccess() agent = agent_da.get(vm.agent_code) agent.bal_amt += vm.amt agent.bal_amt = round(agent.bal_amt, 2) agent.put()