mirror of
https://github.com/kuhyx/ARAI.git
synced 2026-11-24 10:46:20 +01:00
feat: correctly show costs
This commit is contained in:
parent
2dcfa46fc3
commit
6f5ba91446
@ -16,15 +16,14 @@ def recommended_mediators():
|
|||||||
|
|
||||||
input = data.get('request_data', {})
|
input = data.get('request_data', {})
|
||||||
|
|
||||||
{liczba_miesiecy, koszt} = calc_stats("2", 25000, True)
|
liczba_miesiecy, koszt = calc_stats("2", 25000, True)
|
||||||
print(result)
|
|
||||||
|
|
||||||
top_5 = {
|
top_5 = {
|
||||||
"response_type": "recommended_mediators",
|
"response_type": "recommended_mediators",
|
||||||
"response_data": [{
|
"response_data": {"first": {
|
||||||
"cost_of_trial": koszt,
|
"cost_of_trial": koszt,
|
||||||
"time_of_trial": liczba_miesiecy
|
"time_of_trial": liczba_miesiecy
|
||||||
}, [{
|
}, "second": [{
|
||||||
"name": "Mateusz Szpyruk",
|
"name": "Mateusz Szpyruk",
|
||||||
"specialization": "Prawo podatkowe",
|
"specialization": "Prawo podatkowe",
|
||||||
"location": input.get("location"),
|
"location": input.get("location"),
|
||||||
@ -45,7 +44,7 @@ def recommended_mediators():
|
|||||||
"ai_rating": 90,
|
"ai_rating": 90,
|
||||||
"user_rating": 99,
|
"user_rating": 99,
|
||||||
"number_of_opinions": 5
|
"number_of_opinions": 5
|
||||||
}]]
|
}]}
|
||||||
}
|
}
|
||||||
|
|
||||||
return jsonify(top_5)
|
return jsonify(top_5)
|
||||||
@ -99,34 +98,10 @@ def calc_stats(typ,kwota,biegly):
|
|||||||
else:
|
else:
|
||||||
koszt = koszt_sadu + koszt_adwokata
|
koszt = koszt_sadu + koszt_adwokata
|
||||||
print(f"Średni czas trwania rozprawy typu {mapka[typ]} wynosi {round(liczba_miesiecy,0).to_string(index=False)} miesięcy, a {procent.to_string(index=False)}% spraw trwa dłuzej niz rok, jej minimalny koszt wyniesie {koszt}")
|
print(f"Średni czas trwania rozprawy typu {mapka[typ]} wynosi {round(liczba_miesiecy,0).to_string(index=False)} miesięcy, a {procent.to_string(index=False)}% spraw trwa dłuzej niz rok, jej minimalny koszt wyniesie {koszt}")
|
||||||
|
returnMiesiace = round(liczba_miesiecy,0).to_string(index=False)
|
||||||
|
print(returnMiesiace, koszt)
|
||||||
|
return returnMiesiace, koszt
|
||||||
|
|
||||||
elif kwota > 100000:
|
|
||||||
df = pd.read_excel(danePath,sheet_name='okreg')
|
|
||||||
mask = df['RODZAJ'] == int(typ)
|
|
||||||
liczba_miesiecy = df[mask]['mean']
|
|
||||||
procent = (1 - df[mask]['procent do 12 miesięcy']) * 100
|
|
||||||
|
|
||||||
if kwota <= 200000:
|
|
||||||
koszt_adwokata = 5400
|
|
||||||
elif kwota > 200000 and kwota <= 2000000:
|
|
||||||
koszt_adwokata = 10800
|
|
||||||
elif kwota > 2000000 and kwota <= 5000000:
|
|
||||||
koszt_adwokata = 15000
|
|
||||||
elif kwota > 500000:
|
|
||||||
koszt_adwokata = 25000
|
|
||||||
|
|
||||||
koszt_sadu = kwota * 0.05
|
|
||||||
if koszt_sadu > 20000:
|
|
||||||
koszt_sadu = 20000
|
|
||||||
|
|
||||||
if biegly == 'True':
|
|
||||||
koszt = koszt_sadu + koszt_adwokata + koszt_bieglego
|
|
||||||
else:
|
|
||||||
koszt = koszt_sadu + koszt_adwokata
|
|
||||||
|
|
||||||
return_string = f"Średni czas trwania rozprawy typu {mapka[TYP]} wynosi {round(liczba_miesiecy,0).to_string(index=False)} miesięcy, a {procent.to_string(index=False)}% spraw trwa krócej niz rok, a jej minimalny koszt wynosi {koszt}"
|
|
||||||
print(return_string)
|
|
||||||
|
|
||||||
return {liczba_miesiecy, koszt}
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(debug=True)
|
app.run(debug=True)
|
||||||
@ -1,5 +1,5 @@
|
|||||||
import { EventEmitter, Injectable } from '@angular/core';
|
import { EventEmitter, Injectable } from '@angular/core';
|
||||||
import { GenericRequest, GenericResponse, RecommendedMediatorsResponse, StatisticsOutputResponse, UserInputRequest } from './requests-responses';
|
import { GenericRequest, GenericResponse, RecommendedMediatorsResponse, ReturnResponse, StatisticsOutputResponse, UserInputRequest } from './requests-responses';
|
||||||
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
@ -32,7 +32,7 @@ export class BackendService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public sendMessage(message: GenericRequest): Promise<GenericResponse> {
|
public sendMessage(message: GenericRequest): Promise<ReturnResponse> {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (message.request_type === "user_input") {
|
if (message.request_type === "user_input") {
|
||||||
this.userInputArray.push(message as UserInputRequest);
|
this.userInputArray.push(message as UserInputRequest);
|
||||||
@ -41,7 +41,7 @@ export class BackendService {
|
|||||||
|
|
||||||
console.log(`request: `, JSON.stringify(message));
|
console.log(`request: `, JSON.stringify(message));
|
||||||
|
|
||||||
this.http.post<GenericResponse>(this.address, JSON.stringify(message), { headers }).subscribe({
|
this.http.post<ReturnResponse>(this.address, JSON.stringify(message), { headers }).subscribe({
|
||||||
next: (response) => {
|
next: (response) => {
|
||||||
console.log(`response: `, response);
|
console.log(`response: `, response);
|
||||||
resolve(response);
|
resolve(response);
|
||||||
|
|||||||
@ -4,8 +4,9 @@ import { MatInputModule } from '@angular/material/input'
|
|||||||
import { MatCheckboxModule } from '@angular/material/checkbox'
|
import { MatCheckboxModule } from '@angular/material/checkbox'
|
||||||
import { MatButtonModule } from '@angular/material/button'
|
import { MatButtonModule } from '@angular/material/button'
|
||||||
import { BackendService } from '../backend.service';
|
import { BackendService } from '../backend.service';
|
||||||
import { GenericRequest, UserInputRequest, userInput } from '../requests-responses';
|
import { GenericRequest, ReturnResponse, UserInputRequest, userInput } from '../requests-responses';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
import { KosztaService } from '../koszta.service';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -24,7 +25,7 @@ export class CaseInputComponent {
|
|||||||
userInputForm: FormGroup;
|
userInputForm: FormGroup;
|
||||||
userInput: userInput | null = null;
|
userInput: userInput | null = null;
|
||||||
|
|
||||||
constructor(private fb: FormBuilder, private readonly backendService: BackendService, private readonly router: Router) {
|
constructor(private fb: FormBuilder, private readonly backendService: BackendService, private readonly router: Router, private readonly kosztaService: KosztaService) {
|
||||||
this.userInputForm = this.fb.group({
|
this.userInputForm = this.fb.group({
|
||||||
generic_input: [''],
|
generic_input: [''],
|
||||||
trial_value: [],
|
trial_value: [],
|
||||||
@ -37,8 +38,9 @@ export class CaseInputComponent {
|
|||||||
async onSubmit() {
|
async onSubmit() {
|
||||||
this.userInput = this.userInputForm.value;
|
this.userInput = this.userInputForm.value;
|
||||||
if(this.userInput !== null) {
|
if(this.userInput !== null) {
|
||||||
const result = await this.backendService.sendMessage(new UserInputRequest(this.userInput));
|
const result = await this.backendService.sendMessage(new UserInputRequest(this.userInput)) as ReturnResponse;
|
||||||
console.log(`result: `, result);
|
this.kosztaService.czas = String(result.response_data.first.time_of_trial);
|
||||||
|
this.kosztaService.koszta = String(result.response_data.first.cost_of_trial);
|
||||||
this.router.navigate(['koszt']);
|
this.router.navigate(['koszt']);
|
||||||
} else {
|
} else {
|
||||||
console.error(`caseInputComponent, onSubmit, userInput is null!`)
|
console.error(`caseInputComponent, onSubmit, userInput is null!`)
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import { StatisticsOutputInterface } from '../requests-responses';
|
|||||||
import { DatePipe } from '@angular/common';
|
import { DatePipe } from '@angular/common';
|
||||||
import { MatButtonModule } from '@angular/material/button';
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
import { KosztaService } from '../koszta.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-cost-view',
|
selector: 'app-cost-view',
|
||||||
@ -17,7 +18,14 @@ export class CostViewComponent {
|
|||||||
time_of_trial: Date.UTC(0, 6, 0, 0, 0, 0, 0)
|
time_of_trial: Date.UTC(0, 6, 0, 0, 0, 0, 0)
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(private readonly router: Router) {}
|
constructor(private readonly router: Router, private readonly kosztaService: KosztaService) {}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.costData = {
|
||||||
|
cost_of_trial: Number(this.kosztaService.koszta),
|
||||||
|
time_of_trial: Number(this.kosztaService.czas),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public calculateTimeDifference(utcDateNumber: number): string {
|
public calculateTimeDifference(utcDateNumber: number): string {
|
||||||
const currentDate = new Date();
|
const currentDate = new Date();
|
||||||
|
|||||||
16
arai-frontend/src/app/koszta.service.spec.ts
Normal file
16
arai-frontend/src/app/koszta.service.spec.ts
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { KosztaService } from './koszta.service';
|
||||||
|
|
||||||
|
describe('KosztaService', () => {
|
||||||
|
let service: KosztaService;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({});
|
||||||
|
service = TestBed.inject(KosztaService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
expect(service).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
9
arai-frontend/src/app/koszta.service.ts
Normal file
9
arai-frontend/src/app/koszta.service.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
|
@Injectable({
|
||||||
|
providedIn: 'root'
|
||||||
|
})
|
||||||
|
export class KosztaService {
|
||||||
|
public koszta: string = "";
|
||||||
|
public czas: string = "";
|
||||||
|
}
|
||||||
@ -63,6 +63,19 @@ export class RecommendedMediatorsResponse extends GenericResponse {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface response {
|
||||||
|
first: {
|
||||||
|
cost_of_trial: number,
|
||||||
|
time_of_trial: number
|
||||||
|
},
|
||||||
|
second: RecommendedMediatorsInterface[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export class ReturnResponse {
|
||||||
|
"response_type" = "recommended_mediators";
|
||||||
|
"response_data": response
|
||||||
|
}
|
||||||
|
|
||||||
export interface StatisticsOutputInterface {
|
export interface StatisticsOutputInterface {
|
||||||
"cost_of_trial": number,
|
"cost_of_trial": number,
|
||||||
"time_of_trial": number
|
"time_of_trial": number
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user