2
0
mirror of https://github.com/frappe/books.git synced 2024-11-14 17:34:04 +00:00
books/models/regionalModels/in/Address.ts
18alantom de7e5ba807 refactor: rename 'frappe' to 'fyo' outside src
- cause now most of it is different from what it was
2022-05-23 16:18:22 +05:30

38 lines
918 B
TypeScript

import { FormulaMap, ListsMap } from 'fyo/model/types';
import { Address as BaseAddress } from 'models/baseModels/Address/Address';
import { stateCodeMap } from 'regional/in';
import { titleCase } from 'utils';
export class Address extends BaseAddress {
formulas: FormulaMap = {
addressDisplay: async () => {
return [
this.addressLine1,
this.addressLine2,
this.city,
this.state,
this.country,
this.postalCode,
]
.filter(Boolean)
.join(', ');
},
pos: async () => {
const stateList = Object.keys(stateCodeMap).map(titleCase).sort();
const state = this.state as string;
if (stateList.includes(state)) {
return state;
}
return '';
},
};
static lists: ListsMap = {
...BaseAddress.lists,
pos: () => {
return Object.keys(stateCodeMap).map(titleCase).sort();
},
};
}