-
Notifications
You must be signed in to change notification settings - Fork 620
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #788 from frappe/mildred/151-quotations
feat: #151 Quotations
- Loading branch information
Showing
22 changed files
with
321 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { Fyo } from 'fyo'; | ||
import { DocValueMap } from 'fyo/core/types'; | ||
import { Action, ListViewSettings } from 'fyo/model/types'; | ||
import { ModelNameEnum } from 'models/types'; | ||
import { getQuoteActions, getTransactionStatusColumn } from '../../helpers'; | ||
import { Invoice } from '../Invoice/Invoice'; | ||
import { SalesQuoteItem } from '../SalesQuoteItem/SalesQuoteItem'; | ||
import { Defaults } from '../Defaults/Defaults'; | ||
|
||
export class SalesQuote extends Invoice { | ||
items?: SalesQuoteItem[]; | ||
|
||
// This is an inherited method and it must keep the async from the parent | ||
// class | ||
// eslint-disable-next-line @typescript-eslint/require-await | ||
async getPosting() { | ||
return null; | ||
} | ||
|
||
async getInvoice(): Promise<Invoice | null> { | ||
if (!this.isSubmitted) { | ||
return null; | ||
} | ||
|
||
const schemaName = ModelNameEnum.SalesInvoice; | ||
const defaults = (this.fyo.singles.Defaults as Defaults) ?? {}; | ||
const terms = defaults.salesInvoiceTerms ?? ''; | ||
const numberSeries = defaults.salesInvoiceNumberSeries ?? undefined; | ||
|
||
const data: DocValueMap = { | ||
...this.getValidDict(false, true), | ||
date: new Date().toISOString(), | ||
terms, | ||
numberSeries, | ||
quote: this.name, | ||
items: [], | ||
}; | ||
|
||
const invoice = this.fyo.doc.getNewDoc(schemaName, data) as Invoice; | ||
for (const row of this.items ?? []) { | ||
await invoice.append('items', row.getValidDict(false, true)); | ||
} | ||
|
||
if (!invoice.items?.length) { | ||
return null; | ||
} | ||
|
||
return invoice; | ||
} | ||
|
||
static getListViewSettings(): ListViewSettings { | ||
return { | ||
columns: [ | ||
'name', | ||
getTransactionStatusColumn(), | ||
'party', | ||
'date', | ||
'baseGrandTotal', | ||
'outstandingAmount', | ||
], | ||
}; | ||
} | ||
|
||
static getActions(fyo: Fyo): Action[] { | ||
return getQuoteActions(fyo, ModelNameEnum.SalesQuote); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { InvoiceItem } from '../InvoiceItem/InvoiceItem'; | ||
|
||
export class SalesQuoteItem extends InvoiceItem {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"name": "SalesQuote", | ||
"label": "Quote", | ||
"extends": "Invoice", | ||
"naming": "numberSeries", | ||
"showTitle": true, | ||
"fields": [ | ||
{ | ||
"fieldname": "numberSeries", | ||
"label": "Number Series", | ||
"fieldtype": "Link", | ||
"target": "NumberSeries", | ||
"create": true, | ||
"required": true, | ||
"default": "SQUOT-", | ||
"section": "Default" | ||
}, | ||
{ | ||
"fieldname": "party", | ||
"label": "Customer", | ||
"fieldtype": "Link", | ||
"target": "Party", | ||
"create": true, | ||
"required": true, | ||
"section": "Default" | ||
}, | ||
{ | ||
"fieldname": "items", | ||
"label": "Items", | ||
"fieldtype": "Table", | ||
"target": "SalesQuoteItem", | ||
"required": true, | ||
"edit": true, | ||
"section": "Items" | ||
} | ||
], | ||
"keywordFields": ["name", "party"], | ||
"removeFields": [ | ||
"account", | ||
"stockNotTransferred", | ||
"backReference", | ||
"makeAutoStockTransfer", | ||
"returnAgainst", | ||
"isReturned" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "SalesQuoteItem", | ||
"label": "Sales Quote Item", | ||
"extends": "InvoiceItem" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.