alexandraroze commited on
Commit
3f7d898
·
1 Parent(s): 1961add

fixed calculations

Browse files
Files changed (1) hide show
  1. src/pipelines.py +2 -1
src/pipelines.py CHANGED
@@ -94,7 +94,8 @@ class InvoiceGenerator:
94
  lines = generated_invoice.split("\n")[first_cost_line:last_cost_line]
95
  cost_lines = [[line.strip() for line in cost_line.split("|")] for cost_line in lines]
96
  print(f"Cost lines: \n{cost_lines}\n")
97
- costs = [int(line[1]) + int(line[2]) * int(line[3]) for line in cost_lines]
 
98
  cost_lines = list(map(lambda x, y: [x[0], x[1], x[2], x[3], str(y)], cost_lines, costs))
99
  total_cost = sum(costs)
100
  total_cost_line = re.sub(r"\d+", f"{total_cost}", total_cost_line)
 
94
  lines = generated_invoice.split("\n")[first_cost_line:last_cost_line]
95
  cost_lines = [[line.strip() for line in cost_line.split("|")] for cost_line in lines]
96
  print(f"Cost lines: \n{cost_lines}\n")
97
+ start_index = 1 if cost_lines[0][0] != "" else 2
98
+ costs = [int(line[start_index]) + int(line[start_index + 1]) * int(line[start_index + 2]) for line in cost_lines]
99
  cost_lines = list(map(lambda x, y: [x[0], x[1], x[2], x[3], str(y)], cost_lines, costs))
100
  total_cost = sum(costs)
101
  total_cost_line = re.sub(r"\d+", f"{total_cost}", total_cost_line)