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