@go-avro/avro-js 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/types/api/Job.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Task } from "../../types/api/Task";
|
|
|
2
2
|
import { _Event } from "../../types/api/_Event";
|
|
3
3
|
import { RouteJob } from "../../types/api/RouteJob";
|
|
4
4
|
import { Subscription } from "../../types/api/Subscription";
|
|
5
|
+
import { Route } from "../../types/api/Route";
|
|
5
6
|
declare module '../../types/api/Job' {
|
|
6
7
|
interface Job {
|
|
7
8
|
address: string;
|
|
@@ -34,6 +35,6 @@ export declare class Job {
|
|
|
34
35
|
getOverdueLabel: () => string;
|
|
35
36
|
getStatus(): "PENDING_CUSTOMER" | "PENDING_COMPANY" | "ACTIVE" | "ARCHIVED" | "DRAFT" | "PENDING_PAYMENT" | "PENDING_ACTIVATION";
|
|
36
37
|
getStatusLabel(): "Active" | "Draft" | "Archived" | "Pending Activation" | "Customer Approval" | "Company Approval" | "Awaiting Payment";
|
|
37
|
-
portionDone: (
|
|
38
|
-
isDone: (
|
|
38
|
+
portionDone: (route: Route) => number;
|
|
39
|
+
isDone: (route: Route) => boolean;
|
|
39
40
|
}
|
package/dist/types/api/Job.js
CHANGED
|
@@ -21,15 +21,22 @@ export class Job {
|
|
|
21
21
|
return `${Math.floor(maxOverdueTime / 86400)}d overdue`;
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
|
-
this.portionDone = (
|
|
24
|
+
this.portionDone = (route) => {
|
|
25
25
|
if (!this.tasks || this.tasks.length === 0) {
|
|
26
26
|
return 0;
|
|
27
27
|
}
|
|
28
|
-
const
|
|
29
|
-
|
|
28
|
+
const routeJob = this.routes.find(r => r.job_id === this.id);
|
|
29
|
+
if (!routeJob) {
|
|
30
|
+
return 0;
|
|
31
|
+
}
|
|
32
|
+
const contextTasks = this.tasks.filter(t => !t.id || routeJob.tasks.includes(t.id));
|
|
33
|
+
if (contextTasks.length === 0) {
|
|
34
|
+
return 0;
|
|
35
|
+
}
|
|
36
|
+
return contextTasks.filter(t => t.isDone?.(route)).length / contextTasks.length;
|
|
30
37
|
};
|
|
31
|
-
this.isDone = (
|
|
32
|
-
return this.portionDone(
|
|
38
|
+
this.isDone = (route) => {
|
|
39
|
+
return this.portionDone(route) === 1;
|
|
33
40
|
};
|
|
34
41
|
Object.assign(this, init);
|
|
35
42
|
if (init?.tasks) {
|
package/dist/types/api/Task.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { UserCompanyAssociation } from "../../types/api/UserCompanyAssociation";
|
|
|
2
2
|
import { Prepayment } from "../../types/api/Prepayment";
|
|
3
3
|
import { PaymentOption } from "../../types/api/PaymentOption";
|
|
4
4
|
import { _Event } from "../../types/api/_Event";
|
|
5
|
+
import { Route } from "../../types/api/Route";
|
|
5
6
|
export declare const TaskStatus: {
|
|
6
7
|
readonly PENDING_CUSTOMER: "PENDING_CUSTOMER";
|
|
7
8
|
readonly PENDING_COMPANY: "PENDING_COMPANY";
|
|
@@ -58,5 +59,5 @@ export declare class Task {
|
|
|
58
59
|
computeNextTaskState: (isCustomer: boolean, action: "accept" | "modify" | "reject") => TaskStatus;
|
|
59
60
|
getPrepaidEventsRemaining: () => number;
|
|
60
61
|
getPrepaidMonthsRemaining: () => number;
|
|
61
|
-
isDone: (
|
|
62
|
+
isDone: (route: Route) => boolean;
|
|
62
63
|
}
|
package/dist/types/api/Task.js
CHANGED
|
@@ -95,16 +95,12 @@ export class Task {
|
|
|
95
95
|
return acc;
|
|
96
96
|
}, 0);
|
|
97
97
|
};
|
|
98
|
-
this.isDone = (
|
|
98
|
+
this.isDone = (route) => {
|
|
99
99
|
if (!this.status || this.status !== TaskStatus.ACTIVE) {
|
|
100
|
-
return
|
|
100
|
+
return true;
|
|
101
101
|
}
|
|
102
102
|
if (this.frequency > 0) {
|
|
103
|
-
return this.
|
|
104
|
-
}
|
|
105
|
-
else if (fallback) {
|
|
106
|
-
// If frequency is 0, use fallback
|
|
107
|
-
return new Date((this.last_completed_event?.time_ended ?? 0) * 1000) > (fallback);
|
|
103
|
+
return (this.last_completed_event?.time_ended ?? 0) > route.start_time;
|
|
108
104
|
}
|
|
109
105
|
else {
|
|
110
106
|
return this.last_completed_event?.time_ended ? true : false;
|