2
0
mirror of https://github.com/frappe/books.git synced 2024-12-23 19:39:07 +00:00
books/models/regionalModels/in/Address.ts

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

50 lines
1.1 KiB
TypeScript
Raw Normal View History

import { FormulaMap, ListsMap } from 'fyo/model/types';
import { Address as BaseAddress } from 'models/baseModels/Address/Address';
2022-05-17 12:12:57 +00:00
import { codeStateMap } from 'regional/in';
export class Address extends BaseAddress {
formulas: FormulaMap = {
addressDisplay: {
formula: async () => {
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: async () => {
2022-05-17 12:12:57 +00:00
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: () => {
2022-05-17 12:12:57 +00:00
return Object.values(codeStateMap).sort();
},
};
}