2
0
mirror of https://github.com/frappe/books.git synced 2024-11-15 01:44:04 +00:00
books/models/baseModels/Lead/Lead.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

52 lines
1.2 KiB
TypeScript
Raw Normal View History

2024-08-09 05:11:54 +00:00
import { Fyo } from 'fyo';
import { Doc } from 'fyo/model/doc';
import {
Action,
LeadStatus,
ListViewSettings,
ValidationMap,
} from 'fyo/model/types';
import { getLeadActions, getLeadStatusColumn } from 'models/helpers';
import {
validateEmail,
validatePhoneNumber,
} from 'fyo/model/validationFunction';
2024-08-09 10:26:10 +00:00
import { ModelNameEnum } from 'models/types';
2024-08-09 05:11:54 +00:00
export class Lead extends Doc {
status?: LeadStatus;
validations: ValidationMap = {
email: validateEmail,
mobile: validatePhoneNumber,
};
2024-08-09 10:26:10 +00:00
createCustomer() {
return this.fyo.doc.getNewDoc(ModelNameEnum.Party, {
...this.getValidDict(),
fromLead: this.name,
phone: this.mobile as string,
role: 'Customer',
});
}
createSalesQuote() {
const data: { party: string | undefined; referenceType: string } = {
party: this.name,
referenceType: ModelNameEnum.Lead,
};
return this.fyo.doc.getNewDoc(ModelNameEnum.SalesQuote, data);
}
2024-08-09 05:11:54 +00:00
static getActions(fyo: Fyo): Action[] {
return getLeadActions(fyo);
}
static getListViewSettings(): ListViewSettings {
return {
columns: ['name', getLeadStatusColumn(), 'email', 'mobile'],
};
}
}