Skip to content

Commit

Permalink
Merge pull request #220 from george0st/change
Browse files Browse the repository at this point in the history
Prepare for outgoing payments
  • Loading branch information
george0st authored Aug 22, 2024
2 parents 486a47f + 44f091c commit 545f212
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 105 deletions.
6 changes: 2 additions & 4 deletions docs/todo_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
The list of expected/future improvements:

0. Extend transaction, add outgoing transactions also
0.1 generate salary income till 20 of the month (but each month)
+ addition income in range 0..4
0.2 add outgoing income, 1..5
0.1 add outgoing income, 1..5

1. Add list of supported types see rules.md
1. Add list of supported types in featureset see rules.md

2. Extend communications sentences

Expand Down
119 changes: 18 additions & 101 deletions generator/basic_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,109 +56,28 @@ def generate(self, count):
dif_date = self.MAX_EVENT_HISTORY_MONTHS

for month in range(dif_date):
# INCOME - regular income (one per month till)
new_date=self.change_date(date_to.year,
date_to.month,
int(self.rnd_int(1,21)),
- month)
if new_date > date_to:
continue
self.model.append(self._create_transaction(account, new_date, True))
# INCOME - regular income (0..1 times)
for _ in range(int(self.rnd_choose([0,1],[0.001, 0.999]))):
new_date=self.change_date(date_to.year,
date_to.month,
int(self.rnd_int(1,21)),
- month)
if new_date > date_to:
continue
self.model.append(self._create_transaction(account, new_date, True))

# INCOME - addition income (0..2 times)
for _ in range(int(self.rnd_choose([0,1,2],[0.9, 0.08, 0.02]))):
new_date = self.change_date(date_to.year,
date_to.month,
int(self.rnd_int(1, 29)),
- month)
if new_date > date_to:
continue
self.model.append(self._create_transaction(account, new_date, True))

# OUTCOME


#
# model=self.model_item()
#
# # "name": "transaction_id",
# # "description": "Unique transaction identificator",
# model['transaction_id']=str(uuid.uuid4())
#
# # "name": "account_id",
# # "description": "Relation to account identificator",
# model['account_id']=account['account_id']
#
# # "name": "transaction_direction",
# # "description": "Transaction direction e.g. incoming, outgoing",
# # TODO: Add both directions
# model['transaction_direction'] = "Incoming"
#
# # "name": "transaction_type",
# # "description": "Transaction type",
# model['transaction_type'] = self.rnd_choose(["Standard", "Instant"], [0.7, 0.3])
# self.apply_none_value(model, 'transaction_type', "Instant", probability_multiplicator=0.25)
#
# # "name": "transaction_value",
# # "description": "Transaction value",
# #TODO: generate negative items also for outgoing paymants also
# model['transaction_value']=self.rnd_choose(range(1000, 5000))
#
# # "name": "transaction_currency",
# # "description": "Transaction currency",
# model['transaction_currency']="USD"
#
# # "name": "transaction_description",
# # "description": "Transaction description (note: empty value is valid)",
# #TODO: generate description for outgoing paymants also
# model["transaction_description"] = self._transaction_description(True)
# # probability_empty=0.25
# # self.apply_none_value(model, 'transaction_description', "",lower_probability=0.2)
#
# # "name": "transaction_date",
# # "description": "Transaction date",
# model['transaction_date']=new_date
#
# # "name": "counterparty_name",
# # "description": "Transaction counterparty name",
# model["counterparty_name"] = self.fake.name()
#
# # "name": "counterparty_iban",
# # "description": "Transaction counterparty IBAN",
# if int(self.rnd_choose([0,1],[0.998, 0.002]))==0:
# iban=self.fake.iban()
# else:
# tmp_fake=self.rnd_choose([self.fake_at, self.fake_de, self.fake_ch,
# self.fake_pl, self.fake_it, self.fake_es,
# self.fake_tr, self.fake_az, self.fake_ru],
# [0.3, 0.2, 0.2, 0.1, 0.1, 0.025, 0.025, 0.025, 0.025])
# iban=tmp_fake.iban()
# model["counterparty_iban"]=iban
#
# # "name": "counterparty_other",
# # "description": "Transaction counterparty other information",
# # TODO: Add relevant value
# model["counterparty_other"] = ""
#
# fraud=False
# fraud_anomaly=0
# if self.rnd_choose([False, True],[0.95, 0.05]):
# fraud_anomaly = self.rnd_float(0,1,4)
# if self.rnd_choose([False, True],[0.95, 0.05]):
# if self.rnd_bool():
# fraud=True
#
# # "name": "transaction_fraudanomaly",
# # "description": "Possible fraud anomaly detection (min. 0 - without anomaly detection, max. 1)",
# model["transaction_fraudanomaly"] = float(fraud_anomaly)
#
# # "name": "transaction_fraud",
# # "description": "Identification of fraud (True - fraud, False - without fraud)",
# model["transaction_fraud"] = int(fraud)
#
# # "name": "record_date",
# # "description": "The date when the record was created",
# model['record_date']=self.gmodel["NOW"]
#
# self.model.append(model)
# TODO: add code

def _create_transaction(self, account, new_date, income=True):
model = self.model_item()
Expand All @@ -173,8 +92,7 @@ def _create_transaction(self, account, new_date, income=True):

# "name": "transaction_direction",
# "description": "Transaction direction e.g. incoming, outgoing",
# TODO: Add both directions
model['transaction_direction'] = "Incoming"
model['transaction_direction'] = "Incoming" if income else "Outgoing"

# "name": "transaction_type",
# "description": "Transaction type",
Expand All @@ -183,19 +101,18 @@ def _create_transaction(self, account, new_date, income=True):

# "name": "transaction_value",
# "description": "Transaction value",
# TODO: generate negative items also for outgoing paymants also
model['transaction_value'] = self.rnd_choose(range(1000, 5000))
if income:
model['transaction_value'] = self.rnd_choose(range(1500, 5000))
else:
model['transaction_value'] = self.rnd_choose(range(200, 1000))

# "name": "transaction_currency",
# "description": "Transaction currency",
model['transaction_currency'] = "USD"

# "name": "transaction_description",
# "description": "Transaction description (note: empty value is valid)",
# TODO: generate description for outgoing paymants also
model["transaction_description"] = self._transaction_description(True)
# probability_empty=0.25
# self.apply_none_value(model, 'transaction_description', "",lower_probability=0.2)
model["transaction_description"] = self._transaction_description(income)

# "name": "transaction_date",
# "description": "Transaction date",
Expand Down

0 comments on commit 545f212

Please sign in to comment.