def testRenegotiated(self): branch = self.create_branch(name=u'Branch') client = self.create_client(name=u'TestClient') renegotiation = PaymentRenegotiation(branch=branch, client=client) rows = self.store.find(PaymentRenegotiation, branch_id=branch.id, client=client, status=renegotiation.STATUS_RENEGOTIATED).count() self.assertEquals(rows, 0) renegotiation.status = renegotiation.STATUS_RENEGOTIATED rows = self.store.find(PaymentRenegotiation, branch_id=branch.id, client=client, status=renegotiation.STATUS_RENEGOTIATED).count() self.assertEquals(rows, 1)
def create_payment_renegotiation(self, group=None): from stoqlib.domain.payment.renegotiation import PaymentRenegotiation return PaymentRenegotiation(responsible=get_current_user(self.store), branch=get_current_branch(self.store), group=group or self.create_payment_group(), client=self.create_client(), store=self.store)
def testRenegotiation(self): branch = self.create_branch(name=u'Branch') client = self.create_client(name=u'TestClient') rows = self.store.find(PaymentRenegotiation, branch_id=branch.id, client=client).count() self.assertEquals(rows, 0) PaymentRenegotiation(branch=branch, client=client) rows = self.store.find(PaymentRenegotiation, branch_id=branch.id, client=client).count() self.assertEquals(rows, 1)
def _create_model(self, store): value = 0 # will be updated in the first step. branch = api.get_current_branch(store) user = api.get_current_user(store) client = self.groups[0].get_parent().client # Set person as None to allow renegotiate payments without client. person = None if client: person = client.person group = PaymentGroup(payer=person, store=store) model = PaymentRenegotiation(total=value, branch=branch, responsible=user, client=client, group=group, store=store) return model
def renegotiated(self): if self.renegotiated_id: return PaymentRenegotiation.get(self.renegotiated_id, store=self.store)