2
0
mirror of https://github.com/frappe/books.git synced 2024-12-22 10:58:59 +00:00
books/models/regionalModels/in/Address.ts
18alantom d0571a2450 chore: fix all fixable eslint errors in remaining non vue files
- update files to ignore
- delete babel.config.js
2023-06-22 14:22:54 +05:30

50 lines
1.1 KiB
TypeScript

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