mirror of
https://github.com/frappe/books.git
synced 2025-03-19 17:42:23 +00:00
fix: from account not found
- add a bunch of Payment validations - add inline form error message display
This commit is contained in:
parent
ef4e934bfd
commit
7c03b98d67
@ -70,7 +70,7 @@ export class DocHandler {
|
|||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
doc = this.getNewDoc(schemaName, { name });
|
doc = this.getNewDoc(schemaName, { name }, false);
|
||||||
await doc.load();
|
await doc.load();
|
||||||
this.#addToCache(doc);
|
this.#addToCache(doc);
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import { ConflictError, MandatoryError, NotFoundError } from 'fyo/utils/errors';
|
|||||||
import Observable from 'fyo/utils/observable';
|
import Observable from 'fyo/utils/observable';
|
||||||
import { Money } from 'pesa';
|
import { Money } from 'pesa';
|
||||||
import {
|
import {
|
||||||
|
DynamicLinkField,
|
||||||
Field,
|
Field,
|
||||||
FieldTypeEnum,
|
FieldTypeEnum,
|
||||||
OptionField,
|
OptionField,
|
||||||
@ -60,7 +61,7 @@ export class Doc extends Observable<DocValue | Doc[]> {
|
|||||||
parentFieldname?: string;
|
parentFieldname?: string;
|
||||||
parentSchemaName?: string;
|
parentSchemaName?: string;
|
||||||
|
|
||||||
_links?: Record<string, Doc>;
|
links?: Record<string, Doc>;
|
||||||
_dirty: boolean = true;
|
_dirty: boolean = true;
|
||||||
_notInserted: boolean = true;
|
_notInserted: boolean = true;
|
||||||
|
|
||||||
@ -512,41 +513,67 @@ export class Doc extends Observable<DocValue | Doc[]> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async loadLinks() {
|
async loadLinks() {
|
||||||
this._links = {};
|
this.links ??= {};
|
||||||
const linkFields = this.schema.fields.filter(
|
const linkFields = this.schema.fields.filter(
|
||||||
(f) => f.fieldtype === FieldTypeEnum.Link || f.inline
|
({ fieldtype }) =>
|
||||||
|
fieldtype === FieldTypeEnum.Link ||
|
||||||
|
fieldtype === FieldTypeEnum.DynamicLink
|
||||||
);
|
);
|
||||||
|
|
||||||
for (const f of linkFields) {
|
for (const field of linkFields) {
|
||||||
await this.loadLink(f.fieldname);
|
await this._loadLink(field);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async loadLink(fieldname: string) {
|
async _loadLink(field: Field) {
|
||||||
this._links ??= {};
|
if (field.fieldtype === FieldTypeEnum.Link) {
|
||||||
const field = this.fieldMap[fieldname] as TargetField;
|
return await this._loadLinkField(field as TargetField);
|
||||||
if (field === undefined) {
|
}
|
||||||
|
|
||||||
|
if (field.fieldtype === FieldTypeEnum.DynamicLink) {
|
||||||
|
return await this._loadDynamicLinkField(field as DynamicLinkField);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async _loadLinkField(field: TargetField) {
|
||||||
|
const { fieldname, target } = field;
|
||||||
|
const value = this.get(fieldname) as string | undefined;
|
||||||
|
if (!value || !target) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const value = this.get(fieldname);
|
await this._loadLinkDoc(fieldname, target, value);
|
||||||
if (getIsNullOrUndef(value) || field.target === undefined) {
|
}
|
||||||
|
|
||||||
|
async _loadDynamicLinkField(field: DynamicLinkField) {
|
||||||
|
const { fieldname, references } = field;
|
||||||
|
const value = this.get(fieldname) as string | undefined;
|
||||||
|
const reference = this.get(references) as string | undefined;
|
||||||
|
if (!value || !reference) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._links[fieldname] = await this.fyo.doc.getDoc(
|
await this._loadLinkDoc(fieldname, reference, value);
|
||||||
field.target,
|
}
|
||||||
value as string
|
|
||||||
);
|
async _loadLinkDoc(fieldname: string, schemaName: string, name: string) {
|
||||||
|
this.links![fieldname] = await this.fyo.doc.getDoc(schemaName, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
getLink(fieldname: string): Doc | null {
|
getLink(fieldname: string): Doc | null {
|
||||||
const link = this._links?.[fieldname];
|
return this.links?.[fieldname] ?? null;
|
||||||
if (link === undefined) {
|
}
|
||||||
|
|
||||||
|
async loadAndGetLink(fieldname: string): Promise<Doc | null> {
|
||||||
|
if (!this?.[fieldname]) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return link;
|
if (this.links?.[fieldname]?.name !== this[fieldname]) {
|
||||||
|
await this.loadLinks();
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.links?.[fieldname] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
async _syncValues(data: DocValueMap) {
|
async _syncValues(data: DocValueMap) {
|
||||||
@ -672,8 +699,8 @@ export class Doc extends Observable<DocValue | Doc[]> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async _applyFormulaForFields(doc: Doc, fieldname?: string) {
|
async _applyFormulaForFields(doc: Doc, fieldname?: string) {
|
||||||
const formulaFields = Object.keys(this.formulas).map(
|
const formulaFields = this.schema.fields.filter(
|
||||||
(fn) => this.fieldMap[fn]
|
({ fieldname }) => this.formulas?.[fieldname]
|
||||||
);
|
);
|
||||||
|
|
||||||
let changed = false;
|
let changed = false;
|
||||||
|
@ -15,6 +15,8 @@ import { Money } from 'pesa';
|
|||||||
import { PartyRole } from './types';
|
import { PartyRole } from './types';
|
||||||
|
|
||||||
export class Party extends Doc {
|
export class Party extends Doc {
|
||||||
|
role?: PartyRole;
|
||||||
|
defaultAccount?: string;
|
||||||
outstandingAmount?: Money;
|
outstandingAmount?: Money;
|
||||||
async updateOutstandingAmount() {
|
async updateOutstandingAmount() {
|
||||||
/**
|
/**
|
||||||
|
@ -23,16 +23,22 @@ import { LedgerPosting } from 'models/Transactional/LedgerPosting';
|
|||||||
import { Transactional } from 'models/Transactional/Transactional';
|
import { Transactional } from 'models/Transactional/Transactional';
|
||||||
import { ModelNameEnum } from 'models/types';
|
import { ModelNameEnum } from 'models/types';
|
||||||
import { Money } from 'pesa';
|
import { Money } from 'pesa';
|
||||||
|
import { QueryFilter } from 'utils/db/types';
|
||||||
|
import { AccountTypeEnum } from '../Account/types';
|
||||||
import { Invoice } from '../Invoice/Invoice';
|
import { Invoice } from '../Invoice/Invoice';
|
||||||
import { Party } from '../Party/Party';
|
import { Party } from '../Party/Party';
|
||||||
import { PaymentFor } from '../PaymentFor/PaymentFor';
|
import { PaymentFor } from '../PaymentFor/PaymentFor';
|
||||||
import { PaymentMethod, PaymentType } from './types';
|
import { PaymentMethod, PaymentType } from './types';
|
||||||
|
|
||||||
|
type AccountTypeMap = Record<AccountTypeEnum, string[] | undefined>;
|
||||||
|
|
||||||
export class Payment extends Transactional {
|
export class Payment extends Transactional {
|
||||||
party?: string;
|
party?: string;
|
||||||
amount?: Money;
|
amount?: Money;
|
||||||
writeoff?: Money;
|
writeoff?: Money;
|
||||||
paymentType?: PaymentType;
|
paymentType?: PaymentType;
|
||||||
|
for?: PaymentFor[];
|
||||||
|
_accountsMap?: AccountTypeMap;
|
||||||
|
|
||||||
async change({ changed }: ChangeArg) {
|
async change({ changed }: ChangeArg) {
|
||||||
if (changed === 'for') {
|
if (changed === 'for') {
|
||||||
@ -100,12 +106,44 @@ export class Payment extends Transactional {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await this.validateFor();
|
||||||
this.validateAccounts();
|
this.validateAccounts();
|
||||||
this.validateTotalReferenceAmount();
|
this.validateTotalReferenceAmount();
|
||||||
this.validateWriteOffAccount();
|
this.validateWriteOffAccount();
|
||||||
await this.validateReferences();
|
await this.validateReferences();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async validateFor() {
|
||||||
|
for (const childDoc of this.for ?? []) {
|
||||||
|
const referenceName = childDoc.referenceName;
|
||||||
|
const referenceType = childDoc.referenceType;
|
||||||
|
|
||||||
|
const refDoc = (await this.fyo.doc.getDoc(
|
||||||
|
childDoc.referenceType!,
|
||||||
|
childDoc.referenceName
|
||||||
|
)) as Invoice;
|
||||||
|
|
||||||
|
if (referenceName && referenceType && !refDoc) {
|
||||||
|
throw new ValidationError(
|
||||||
|
t`${referenceType} of type ${this.fyo.schemaMap?.[referenceType]
|
||||||
|
?.label!} does not exist`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
console.log(refDoc);
|
||||||
|
|
||||||
|
if (!refDoc) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (refDoc?.party !== this.party) {
|
||||||
|
throw new ValidationError(
|
||||||
|
t`${refDoc.name!} party ${refDoc.party!} is different from ${this
|
||||||
|
.party!}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
validateAccounts() {
|
validateAccounts() {
|
||||||
if (this.paymentAccount !== this.account || !this.account) {
|
if (this.paymentAccount !== this.account || !this.account) {
|
||||||
return;
|
return;
|
||||||
@ -319,46 +357,118 @@ export class Payment extends Transactional {
|
|||||||
|
|
||||||
static defaults: DefaultMap = { date: () => new Date().toISOString() };
|
static defaults: DefaultMap = { date: () => new Date().toISOString() };
|
||||||
|
|
||||||
|
async _getAccountsMap(): Promise<AccountTypeMap> {
|
||||||
|
if (this._accountsMap) {
|
||||||
|
return this._accountsMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
const accounts = (await this.fyo.db.getAll(ModelNameEnum.Account, {
|
||||||
|
fields: ['name', 'accountType'],
|
||||||
|
filters: {
|
||||||
|
accountType: [
|
||||||
|
'in',
|
||||||
|
[
|
||||||
|
AccountTypeEnum.Bank,
|
||||||
|
AccountTypeEnum.Cash,
|
||||||
|
AccountTypeEnum.Payable,
|
||||||
|
AccountTypeEnum.Receivable,
|
||||||
|
],
|
||||||
|
],
|
||||||
|
},
|
||||||
|
})) as { name: string; accountType: AccountTypeEnum }[];
|
||||||
|
|
||||||
|
return (this._accountsMap = accounts.reduce((acc, ac) => {
|
||||||
|
acc[ac.accountType] ??= [];
|
||||||
|
acc[ac.accountType]!.push(ac.name);
|
||||||
|
return acc;
|
||||||
|
}, {} as AccountTypeMap));
|
||||||
|
}
|
||||||
|
|
||||||
|
async _getReferenceAccount() {
|
||||||
|
const account = await this._getAccountFromParty();
|
||||||
|
if (!account) {
|
||||||
|
return await this._getAccountFromFor();
|
||||||
|
}
|
||||||
|
|
||||||
|
return account;
|
||||||
|
}
|
||||||
|
|
||||||
|
async _getAccountFromParty() {
|
||||||
|
const party = (await this.loadAndGetLink('party')) as Party | null;
|
||||||
|
if (!party || party.role === 'Both') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return party.defaultAccount ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
async _getAccountFromFor() {
|
||||||
|
const reference = this?.for?.[0];
|
||||||
|
if (!reference) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const refDoc = (await reference.loadAndGetLink(
|
||||||
|
'referenceName'
|
||||||
|
)) as Invoice | null;
|
||||||
|
|
||||||
|
return (refDoc?.account ?? null) as string | null;
|
||||||
|
}
|
||||||
|
|
||||||
formulas: FormulaMap = {
|
formulas: FormulaMap = {
|
||||||
account: {
|
account: {
|
||||||
formula: async () => {
|
formula: async () => {
|
||||||
const hasCash = await this.fyo.db.exists(ModelNameEnum.Account, 'Cash');
|
const accountsMap = await this._getAccountsMap();
|
||||||
if (
|
if (this.paymentType === 'Receive') {
|
||||||
this.paymentMethod === 'Cash' &&
|
return (
|
||||||
this.paymentType === 'Pay' &&
|
(await this._getReferenceAccount()) ??
|
||||||
hasCash
|
accountsMap[AccountTypeEnum.Receivable]?.[0] ??
|
||||||
) {
|
null
|
||||||
return 'Cash';
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.paymentMethod === 'Cash') {
|
||||||
|
return accountsMap[AccountTypeEnum.Cash]?.[0] ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.paymentMethod !== 'Cash') {
|
||||||
|
return accountsMap[AccountTypeEnum.Bank]?.[0] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
dependsOn: ['paymentMethod', 'paymentType'],
|
dependsOn: ['paymentMethod', 'paymentType', 'party'],
|
||||||
},
|
},
|
||||||
paymentAccount: {
|
paymentAccount: {
|
||||||
formula: async () => {
|
formula: async () => {
|
||||||
const hasCash = await this.fyo.db.exists(ModelNameEnum.Account, 'Cash');
|
const accountsMap = await this._getAccountsMap();
|
||||||
if (
|
if (this.paymentType === 'Pay') {
|
||||||
this.paymentMethod === 'Cash' &&
|
return (
|
||||||
this.paymentType === 'Receive' &&
|
(await this._getReferenceAccount()) ??
|
||||||
hasCash
|
accountsMap[AccountTypeEnum.Payable]?.[0] ??
|
||||||
) {
|
null
|
||||||
return 'Cash';
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.paymentMethod === 'Cash') {
|
||||||
|
return accountsMap[AccountTypeEnum.Cash]?.[0] ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.paymentMethod !== 'Cash') {
|
||||||
|
return accountsMap[AccountTypeEnum.Bank]?.[0] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
dependsOn: ['paymentMethod', 'paymentType'],
|
dependsOn: ['paymentMethod', 'paymentType', 'party'],
|
||||||
},
|
},
|
||||||
paymentType: {
|
paymentType: {
|
||||||
formula: async () => {
|
formula: async () => {
|
||||||
if (!this.party) {
|
if (!this.party) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const partyDoc = await this.fyo.doc.getDoc(
|
|
||||||
ModelNameEnum.Party,
|
const partyDoc = (await this.loadAndGetLink('party')) as Party;
|
||||||
this.party
|
|
||||||
);
|
|
||||||
if (partyDoc.role === 'Supplier') {
|
if (partyDoc.role === 'Supplier') {
|
||||||
return 'Pay';
|
return 'Pay';
|
||||||
} else if (partyDoc.role === 'Customer') {
|
} else if (partyDoc.role === 'Customer') {
|
||||||
@ -426,6 +536,18 @@ export class Payment extends Transactional {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static filters: FiltersMap = {
|
static filters: FiltersMap = {
|
||||||
|
party: (doc: Doc) => {
|
||||||
|
const paymentType = (doc as Payment).paymentType;
|
||||||
|
if (paymentType === 'Pay') {
|
||||||
|
return { role: ['in', ['Supplier', 'Both']] } as QueryFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (paymentType === 'Receive') {
|
||||||
|
return { role: ['in', ['Customer', 'Both']] } as QueryFilter;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
},
|
||||||
numberSeries: () => {
|
numberSeries: () => {
|
||||||
return { referenceType: 'Payment' };
|
return { referenceType: 'Payment' };
|
||||||
},
|
},
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
|
import { t } from 'fyo';
|
||||||
|
import { DocValue } from 'fyo/core/types';
|
||||||
import { Doc } from 'fyo/model/doc';
|
import { Doc } from 'fyo/model/doc';
|
||||||
import { FiltersMap, FormulaMap } from 'fyo/model/types';
|
import { FiltersMap, FormulaMap, ValidationMap } from 'fyo/model/types';
|
||||||
|
import { NotFoundError } from 'fyo/utils/errors';
|
||||||
import { ModelNameEnum } from 'models/types';
|
import { ModelNameEnum } from 'models/types';
|
||||||
import { Money } from 'pesa';
|
import { Money } from 'pesa';
|
||||||
import { PartyRoleEnum } from '../Party/types';
|
import { PartyRoleEnum } from '../Party/types';
|
||||||
@ -18,24 +21,37 @@ export class PaymentFor extends Doc {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const party = this.parentdoc!.party;
|
const party = await this.parentdoc?.loadAndGetLink('party');
|
||||||
if (party === undefined) {
|
if (!party) {
|
||||||
return ModelNameEnum.SalesInvoice;
|
return ModelNameEnum.SalesInvoice;
|
||||||
}
|
}
|
||||||
|
|
||||||
const role = await this.fyo.getValue(
|
if (party.role === PartyRoleEnum.Supplier) {
|
||||||
ModelNameEnum.Party,
|
|
||||||
party,
|
|
||||||
'role'
|
|
||||||
);
|
|
||||||
|
|
||||||
if (role === PartyRoleEnum.Supplier) {
|
|
||||||
return ModelNameEnum.PurchaseInvoice;
|
return ModelNameEnum.PurchaseInvoice;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ModelNameEnum.SalesInvoice;
|
return ModelNameEnum.SalesInvoice;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
referenceName: {
|
||||||
|
formula: async () => {
|
||||||
|
if (!this.referenceName || !this.referenceType) {
|
||||||
|
return this.referenceName;
|
||||||
|
}
|
||||||
|
|
||||||
|
const exists = await this.fyo.db.exists(
|
||||||
|
this.referenceType,
|
||||||
|
this.referenceName
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!exists) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.referenceName;
|
||||||
|
},
|
||||||
|
dependsOn: ['referenceType'],
|
||||||
|
},
|
||||||
amount: {
|
amount: {
|
||||||
formula: async () => {
|
formula: async () => {
|
||||||
if (!this.referenceName) {
|
if (!this.referenceName) {
|
||||||
@ -74,4 +90,24 @@ export class PaymentFor extends Doc {
|
|||||||
return { ...baseFilters, party };
|
return { ...baseFilters, party };
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
validations: ValidationMap = {
|
||||||
|
referenceName: async (value: DocValue) => {
|
||||||
|
console.log(value);
|
||||||
|
const exists = await this.fyo.db.exists(
|
||||||
|
this.referenceType!,
|
||||||
|
value as string
|
||||||
|
);
|
||||||
|
if (exists) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new NotFoundError(
|
||||||
|
t`${this.fyo.schemaMap[this.referenceType!]?.label!} ${
|
||||||
|
value as string
|
||||||
|
} does not exist`,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ export function getInvoiceActions(
|
|||||||
await openQuickEdit({
|
await openQuickEdit({
|
||||||
schemaName: 'Payment',
|
schemaName: 'Payment',
|
||||||
name: payment.name as string,
|
name: payment.name as string,
|
||||||
hideFields: ['party', 'date', hideAccountField, 'paymentType', 'for'],
|
hideFields: ['party', 'date', 'paymentType', 'for'],
|
||||||
defaults: {
|
defaults: {
|
||||||
party,
|
party,
|
||||||
[hideAccountField]: doc.account,
|
[hideAccountField]: doc.account,
|
||||||
|
@ -27,14 +27,6 @@
|
|||||||
"fieldtype": "Date",
|
"fieldtype": "Date",
|
||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname": "account",
|
|
||||||
"label": "From Account",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"target": "Account",
|
|
||||||
"create": true,
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname": "paymentType",
|
"fieldname": "paymentType",
|
||||||
"label": "Payment Type",
|
"label": "Payment Type",
|
||||||
@ -52,15 +44,6 @@
|
|||||||
],
|
],
|
||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"fieldname": "paymentAccount",
|
|
||||||
"label": "To Account",
|
|
||||||
"placeholder": "To Account",
|
|
||||||
"fieldtype": "Link",
|
|
||||||
"target": "Account",
|
|
||||||
"create": true,
|
|
||||||
"required": true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"fieldname": "numberSeries",
|
"fieldname": "numberSeries",
|
||||||
"label": "Number Series",
|
"label": "Number Series",
|
||||||
@ -92,6 +75,23 @@
|
|||||||
"default": "Cash",
|
"default": "Cash",
|
||||||
"required": true
|
"required": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "account",
|
||||||
|
"label": "From Account",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"target": "Account",
|
||||||
|
"create": true,
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "paymentAccount",
|
||||||
|
"label": "To Account",
|
||||||
|
"placeholder": "To Account",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"target": "Account",
|
||||||
|
"create": true,
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"fieldname": "referenceId",
|
"fieldname": "referenceId",
|
||||||
"label": "Ref. / Cheque No.",
|
"label": "Ref. / Cheque No.",
|
||||||
|
@ -135,7 +135,7 @@ export default {
|
|||||||
doc.once('afterSync', () => {
|
doc.once('afterSync', () => {
|
||||||
this.$emit('new-doc', doc);
|
this.$emit('new-doc', doc);
|
||||||
this.$router.back();
|
this.$router.back();
|
||||||
this.results = []
|
this.results = [];
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
async getCreateFilters() {
|
async getCreateFilters() {
|
||||||
|
@ -4,10 +4,10 @@ export default {
|
|||||||
props: { doc: Object, printSettings: Object },
|
props: { doc: Object, printSettings: Object },
|
||||||
data: () => ({ party: null, companyAddress: null, partyAddress: null }),
|
data: () => ({ party: null, companyAddress: null, partyAddress: null }),
|
||||||
async mounted() {
|
async mounted() {
|
||||||
await this.printSettings.loadLink('address');
|
await this.printSettings.loadLinks();
|
||||||
this.companyAddress = this.printSettings.getLink('address');
|
this.companyAddress = this.printSettings.getLink('address');
|
||||||
|
|
||||||
await this.doc.loadLink('party');
|
await this.doc.loadLinks();
|
||||||
this.party = this.doc.getLink('party');
|
this.party = this.doc.getLink('party');
|
||||||
this.partyAddress = this.party.getLink('address')?.addressDisplay ?? null;
|
this.partyAddress = this.party.getLink('address')?.addressDisplay ?? null;
|
||||||
|
|
||||||
|
@ -265,7 +265,12 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.inlineEditDoc.sync();
|
try {
|
||||||
|
await this.inlineEditDoc.sync();
|
||||||
|
} catch (error) {
|
||||||
|
return await handleErrorWithDialog(error, this.inlineEditDoc)
|
||||||
|
}
|
||||||
|
|
||||||
await this.onChangeCommon(df, this.inlineEditDoc.name);
|
await this.onChangeCommon(df, this.inlineEditDoc.name);
|
||||||
await this.doc.loadLinks();
|
await this.doc.loadLinks();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user