Skip to content

Commit

Permalink
docs: hook argument types
Browse files Browse the repository at this point in the history
  • Loading branch information
barredterra committed Nov 6, 2024
1 parent 1ce6b5e commit a2fa848
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,19 @@ doc_events = {
And your `myapp/einvoice.py` like this:

```python
def before_einvoice_generation(doc):
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from drafthorse.models.document import Document
from erpnext.accounts.doctype.sales_invoice.sales_invoice import SalesInvoice


def before_einvoice_generation(doc: "SalesInvoice", event: str):
"""Modify the Sales Invoice object before generating the eInvoice."""
doc.customer_name = "Special Customer Name, only for eInvoices"

def after_einvoice_generation(doc, einvoice):

def after_einvoice_generation(doc: "SalesInvoice", event: str, einvoice: "Document"):
"""Modify the generated eInvoice after it was created."""
einvoice.trade.agreement.buyer.name = "Special Customer Name, only for eInvoices"
```
Expand Down

0 comments on commit a2fa848

Please sign in to comment.