mirror of
https://github.com/frappe/books.git
synced 2024-12-22 19:09:01 +00:00
fix: show return payments in the belonged list
This commit is contained in:
parent
04faff1f6f
commit
67f9232160
@ -36,6 +36,7 @@ export class Payment extends Transactional {
|
|||||||
amount?: Money;
|
amount?: Money;
|
||||||
writeoff?: Money;
|
writeoff?: Money;
|
||||||
paymentType?: PaymentType;
|
paymentType?: PaymentType;
|
||||||
|
referenceType?: ModelNameEnum.SalesInvoice | ModelNameEnum.PurchaseInvoice;
|
||||||
for?: PaymentFor[];
|
for?: PaymentFor[];
|
||||||
_accountsMap?: AccountTypeMap;
|
_accountsMap?: AccountTypeMap;
|
||||||
|
|
||||||
@ -529,6 +530,14 @@ export class Payment extends Transactional {
|
|||||||
formula: () => this.amount!.sub(this.writeoff!),
|
formula: () => this.amount!.sub(this.writeoff!),
|
||||||
dependsOn: ['amount', 'writeoff', 'for'],
|
dependsOn: ['amount', 'writeoff', 'for'],
|
||||||
},
|
},
|
||||||
|
referenceType: {
|
||||||
|
formula: () => {
|
||||||
|
if (this.referenceType) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
return this.for![0].referenceType;
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
validations: ValidationMap = {
|
validations: ValidationMap = {
|
||||||
|
@ -98,11 +98,13 @@ export function getMakePaymentAction(fyo: Fyo): Action {
|
|||||||
condition: (doc: Doc) =>
|
condition: (doc: Doc) =>
|
||||||
doc.isSubmitted && !(doc.outstandingAmount as Money).isZero(),
|
doc.isSubmitted && !(doc.outstandingAmount as Money).isZero(),
|
||||||
action: async (doc, router) => {
|
action: async (doc, router) => {
|
||||||
|
const schemaName = doc.schema.name;
|
||||||
const payment = (doc as Invoice).getPayment();
|
const payment = (doc as Invoice).getPayment();
|
||||||
if (!payment) {
|
if (!payment) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await payment?.set('referenceType', schemaName);
|
||||||
const currentRoute = router.currentRoute.value.fullPath;
|
const currentRoute = router.currentRoute.value.fullPath;
|
||||||
payment.once('afterSync', async () => {
|
payment.once('afterSync', async () => {
|
||||||
await payment.submit();
|
await payment.submit();
|
||||||
|
@ -155,6 +155,24 @@
|
|||||||
"label": "Attachment",
|
"label": "Attachment",
|
||||||
"fieldtype": "Attachment",
|
"fieldtype": "Attachment",
|
||||||
"section": "References"
|
"section": "References"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "referenceType",
|
||||||
|
"label": "Type",
|
||||||
|
"placeholder": "Type",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"options": [
|
||||||
|
{
|
||||||
|
"value": "SalesInvoice",
|
||||||
|
"label": "Sales"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"value": "PurchaseInvoice",
|
||||||
|
"label": "Purchase"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"hidden": true,
|
||||||
|
"required": true
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"quickEditFields": [
|
"quickEditFields": [
|
||||||
|
@ -1,9 +1,15 @@
|
|||||||
|
import { ModelNameEnum } from 'models/types';
|
||||||
|
|
||||||
export const routeFilters = {
|
export const routeFilters = {
|
||||||
SalesItems: { for: ['in', ['Sales', 'Both']] },
|
SalesItems: { for: ['in', ['Sales', 'Both']] },
|
||||||
PurchaseItems: { for: ['in', ['Purchases', 'Both']] },
|
PurchaseItems: { for: ['in', ['Purchases', 'Both']] },
|
||||||
Items: { for: 'Both' },
|
Items: { for: 'Both' },
|
||||||
PurchasePayments: { paymentType: 'Pay' },
|
PurchasePayments: {
|
||||||
SalesPayments: { paymentType: 'Receive' },
|
referenceType: ModelNameEnum.PurchaseInvoice,
|
||||||
|
},
|
||||||
|
SalesPayments: {
|
||||||
|
referenceType: ModelNameEnum.SalesInvoice,
|
||||||
|
},
|
||||||
Suppliers: { role: ['in', ['Supplier', 'Both']] },
|
Suppliers: { role: ['in', ['Supplier', 'Both']] },
|
||||||
Customers: { role: ['in', ['Customer', 'Both']] },
|
Customers: { role: ['in', ['Customer', 'Both']] },
|
||||||
Party: { role: 'Both' },
|
Party: { role: 'Both' },
|
||||||
|
Loading…
Reference in New Issue
Block a user