-
Notifications
You must be signed in to change notification settings - Fork 717
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: #151 Add quote object and allow create invoice from it
Also allow changing a print template type, necessary to create a custom print template for this.
- Loading branch information
Showing
23 changed files
with
318 additions
and
12 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,65 @@ | ||
import { Fyo } from 'fyo'; | ||
import { Action, ListViewSettings } from 'fyo/model/types'; | ||
import { LedgerPosting } from 'models/Transactional/LedgerPosting'; | ||
import { ModelNameEnum } from 'models/types'; | ||
import { getQuoteActions, getTransactionStatusColumn } from '../../helpers'; | ||
import { Invoice } from '../Invoice/Invoice'; | ||
import { SalesQuoteItem } from '../SalesQuoteItem/SalesQuoteItem'; | ||
|
||
export class SalesQuote extends Invoice { | ||
items?: SalesQuoteItem[]; | ||
|
||
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 = { | ||
...this, | ||
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 | ||
}); | ||
} | ||
|
||
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,58 @@ | ||
{ | ||
"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": "account", | ||
"drop": true | ||
}, | ||
{ | ||
"fieldname": "stockNotTransferred", | ||
"drop": true | ||
}, | ||
{ | ||
"fieldname": "backReference", | ||
"drop": true | ||
}, | ||
{ | ||
"fieldname": "makeAutoStockTransfer", | ||
"drop": true | ||
}, | ||
{ | ||
"fieldname": "returnAgainst", | ||
"drop": true | ||
}, | ||
{ | ||
"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"] | ||
} |
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.