-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Threading: Add Support for Threading for all Functions
- Loading branch information
Showing
3 changed files
with
124 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import threading | ||
|
||
|
||
class threader(threading.Thread): | ||
def __init__(self, function, **arguments): | ||
threading.Thread.__init__(self) | ||
self.func = function | ||
self.arguments = arguments | ||
self.return_val = None | ||
|
||
def run(self): | ||
self.return_val = self.func(**self.arguments) | ||
|
||
def join(self): | ||
threading.Thread.join(self) | ||
return self.return_val |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,54 @@ | ||
from app.common.helpers import generate_invoices_list | ||
from openpyxl import workbook | ||
import csv | ||
from pathlib import Path | ||
|
||
def generate_csv_template(): | ||
pass | ||
|
||
def get_paths(): | ||
csv_write_path = Path( | ||
input("\nEnter the Dir to which the Format CSV Has to be Saved? ").lower() | ||
) | ||
return csv_write_path | ||
|
||
|
||
def generate_csv_template(write_path): | ||
with open( | ||
file=Path(f"{write_path}/ledger_data_format.csv"), mode="w", newline="" | ||
) as csv_file: | ||
headers = [ | ||
"Date", | ||
"Particulars", | ||
"Type", | ||
"GSTIN/UIN", | ||
"Taxability", | ||
"Invoice Value", | ||
"Taxable", | ||
"Integrated Tax", | ||
"Central Tax", | ||
"State Tax", | ||
"Total Tax", | ||
"Rate", | ||
"Month", | ||
] | ||
writer = csv.DictWriter(csv_file, fieldnames=headers) | ||
|
||
writer.writeheader() | ||
writer.writerow( | ||
{ | ||
"Date": "01-04-2018", | ||
"Particulars": "Supplier name", | ||
"Type": "Taxable", | ||
"GSTIN/UIN": "09BIOPA1154J1Z9", | ||
"Taxability": "TRUE", | ||
"Invoice Value": 79868.30, | ||
"Taxable": 67685.00, | ||
"Integrated Tax": 0, | ||
"Central Tax": 6091.65, | ||
"State Tax": 6091.65, | ||
"Total Tax": 12183.30, | ||
"Rate": 0.18, | ||
"Month": "Apr-18", | ||
} | ||
) | ||
|
||
|
||
paths = get_paths() | ||
generate_csv_template(write_path=paths) |