Customs Dox Module (tendril.dox.customs)

This module generates the customs document sets.

The functions here use the tendril.dox.render module to actually produce the output files after constructing the appropriate stage.

Hint

The functions and templates here are made for and in the Indian Customs formats. This probably doesn’t translate well to any other country. As such, this module itself doesn’t do much of the heavy lifting. Instead, it relies on the tendril.sourcing.customs module. Porting it to another country would probably start from reimplementing that class and rewriting the templates.

Document Set Generators

generate_docs(invoice[, target_folder, ...]) Generates all the Customs related documentation given a CustomsInvoice (or subclass) instance.
gen_submitdocs(invoice, target_folder, serialno) Generates collated PDF files containing the submittable documents.
gen_verificationdocs(invoice, target_folder, ...) Generates customs verification documents.

Document Generators

gen_declaration(invoice, target_folder, ...) Generates a copy of the Customs Declaration for Imports.
gen_valuation(invoice, target_folder, serialno) Generates the Customs Valuation Note.
gen_rsp_declaration(invoice, target_folder, ...) Generates the Customs Retail Sales Price Declaration.
gen_authorization(invoice, target_folder, ...) Generates the Customs CHA Authorization Letter.
gen_tech_writeup(invoice, target_folder, ...) Generates the Customs Technical Writeup.
gen_verification_sections(invoice, ...) Generates the Customs Sections Verification document.
gen_verification_checklist(invoice, ...) Generates the Customs Duties / Checklist Verification document.
tendril.dox.customs.gen_declaration(invoice, target_folder, copyt, serialno)[source]

Generates a copy of the Customs Declaration for Imports.

Parameters:
  • invoice (tendril.sourcing.customs.CustomsInvoice) – The invoice object with customs information
  • target_folder – The folder in which the generated files should be written to
  • copyt (str) – A string specifying which copy it is (“ORIGINAL”, “DUPLICATE”, so on)
  • serialno (str) – The serial number of the Customs documentation set
Returns:

The output file path

Template Used

tendril/dox/templates/customs/decl.tex (Included version)

Stage Keys Provided

date The date the documents were generated at, from datetime.date.today().
signatory The name of the person who ‘signs’ the document, from tendril.utils.config.COMPANY_GOVT_POINT.
inv_no The vendor’s invoice number.
inv_date The date of the vendor’s invoice.
given_data A dict containing various facts about the invoice. See tendril.sourcing.customs.CustomsInvoice.given_data
currency The symbol of the currency of the invoice.
inv_total The total value of the invoice, in vendor currency.
exchrate The applicable exchange rate.
exchnotif The government notification number specifying the exchange rate.
exchnotifdt The date of the exchange rate notification.
extended_total_sc The extended total invoice value, in the vendor’s currency.
assessable_total_sc The assessable total invoice value, in the vendor’s currency.
assessable_total_nc The assessable total invoice value, in the vendor’s currency.
copyt The string specifying which copy it is.
sno The serial number of the document.
tendril.dox.customs.gen_valuation(invoice, target_folder, serialno)[source]

Generates the Customs Valuation Note.

Parameters:
  • invoice (tendril.sourcing.customs.CustomsInvoice) – The invoice object with customs information
  • target_folder – The folder in which the generated files should be written to
  • serialno (str) – The serial number of the Customs documentation set
Returns:

The output file path

Template Used

tendril/dox/templates/customs/valuation.tex (Included version)

Stage Keys Provided

date The date the documents were generated at, from datetime.date.today().
signatory The name of the person who ‘signs’ the document, from tendril.utils.config.COMPANY_GOVT_POINT.
inv_no The vendor’s invoice number.
inv_date The date of the vendor’s invoice.
given_data A dict containing various facts about the invoice. See tendril.sourcing.customs.CustomsInvoice.given_data
currency The symbol of the currency of the invoice.
inv_total The total value of the invoice, in vendor currency.
exchrate The applicable exchange rate.
exchnotif The government notification number specifying the exchange rate.
exchnotifdt The date of the exchange rate notification.
note1 A note mentioning the inclusion of freight.
note2 A list of strings mentioning other additions to the valuation.
include_note2 Boolean, whether or not to include note2.
extended_total_sc The extended total invoice value, in the vendor’s currency.
assessable_total_sc The assessable total invoice value, in the vendor’s currency.
assessable_total_nc The assessable total invoice value, in the vendor’s currency.
copyt The string specifying which copy it is.
sno The serial number of the document.
is_wire Bool, whether the payment was made by a wire transfer.
tendril.dox.customs.gen_rsp_declaration(invoice, target_folder, serialno)[source]

Generates the Customs Retail Sales Price Declaration.

Parameters:
  • invoice (tendril.sourcing.customs.CustomsInvoice) – The invoice object with customs information
  • target_folder – The folder in which the generated files should be written to
  • serialno (str) – The serial number of the Customs documentation set
Returns:

The output file path

Template Used

tendril/dox/templates/customs/rsp-declaration.tex (Included version)

Stage Keys Provided

date The date the documents were generated at, from datetime.date.today().
signatory The name of the person who ‘signs’ the document, from tendril.utils.config.COMPANY_GOVT_POINT.
inv_no The vendor’s invoice number.
inv_date The date of the vendor’s invoice.
given_data A dict containing various facts about the invoice. See tendril.sourcing.customs.CustomsInvoice.given_data
sno The serial number of the document.
tendril.dox.customs.gen_authorization(invoice, target_folder, serialno)[source]

Generates the Customs CHA Authorization Letter.

Parameters:
  • invoice (tendril.sourcing.customs.CustomsInvoice) – The invoice object with customs information
  • target_folder – The folder in which the generated files should be written to
  • serialno (str) – The serial number of the Customs documentation set
Returns:

The output file path

Template Used

This function uses a different template for each CHA, in the format that the CHA asks for it.

Template Filename : tendril/dox/templates/customs/authorization.<cha>.tex

Included Templates :

FedEx India tendril/dox/templates/customs/authorization.fedex.tex (Included version)
DHL India tendril/dox/templates/customs/authorization.dhl.tex (Included version)

Stage Keys Provided

date The date the documents were generated at, from datetime.date.today().
signatory The name of the person who ‘signs’ the document, from tendril.utils.config.COMPANY_GOVT_POINT.
inv_no The vendor’s invoice number.
inv_date The date of the vendor’s invoice.
given_data A dict containing various facts about the invoice. See tendril.sourcing.customs.CustomsInvoice.given_data
sno The serial number of the document.
tendril.dox.customs.gen_tech_writeup(invoice, target_folder, serialno)[source]

Generates the Customs Technical Writeup.

Parameters:
  • invoice (tendril.sourcing.customs.CustomsInvoice) – The invoice object with customs information
  • target_folder – The folder in which the generated files should be written to
  • serialno (str) – The serial number of the Customs documentation set
Returns:

The output file path

Template Used

Template Filename : tendril/dox/templates/customs/technical-writeup.tex (Included version)

Stage Keys Provided

date The date the documents were generated at, from datetime.date.today().
signatory The name of the person who ‘signs’ the document, from tendril.utils.config.COMPANY_GOVT_POINT.
inv_no The vendor’s invoice number.
inv_date The date of the vendor’s invoice.
given_data A dict containing various facts about the invoice. See tendril.sourcing.customs.CustomsInvoice.given_data
sno The serial number of the document.
linecount The number of lines in the invoice.
tqty The total quantity.
tvalue The total value.
unclassified Lines in the invoice which could not be classified
sectable The secion table, containing a list of section lines, described below. The ‘sections’ here are Customs HS Codes.
Section line keys
code The HS section code.
name The HS section name.
idxs Line numbers classified into this line.
qty Total quantity of all lines classified into this line.
value Total value of all lines classified into this line.
tendril.dox.customs.gen_submitdocs(invoice, target_folder, serialno)[source]

Generates collated PDF files containing the submittable documents. Two PDF files are generated - one for printing on the company letterhead and one on regular paper.

Parameters:
  • invoice (tendril.sourcing.customs.CustomsInvoice) – The invoice object with customs information
  • target_folder – The folder in which the generated files should be written to
  • serialno (str) – The serial number of the Customs documentation set
Returns:

List of output file tuples (path, type)

Included Documents - For Letterhead Printing

Included Documents - For Plain Paper Printing

tendril.dox.customs.gen_verification_sections(invoice, target_folder, serialno)[source]

Generates the Customs Sections Verification document.

Parameters:
  • invoice (tendril.sourcing.customs.CustomsInvoice) – The invoice object with customs information
  • target_folder – The folder in which the generated files should be written to
  • serialno (str) – The serial number of the Customs documentation set
Returns:

The output file tuple (path, type)

Template Used

tendril/dox/templates/customs/verification-sections.tex (Included version)

Stage Keys Provided

date The date the documents were generated at, from datetime.date.today().
signatory The name of the person who ‘signs’ the document, from tendril.utils.config.COMPANY_GOVT_POINT.
inv_no The vendor’s invoice number.
inv_date The date of the vendor’s invoice.
given_data A dict containing various facts about the invoice. See tendril.sourcing.customs.CustomsInvoice.given_data.
lines A list of tendril.sourcing.customs.CustomsInvoiceLine instances.
sno The serial number of the document.
tendril.dox.customs.gen_verification_checklist(invoice, target_folder, serialno)[source]

Generates the Customs Duties / Checklist Verification document.

Parameters:
  • invoice (tendril.sourcing.customs.CustomsInvoice) – The invoice object with customs information
  • target_folder – The folder in which the generated files should be written to
  • serialno (str) – The serial number of the Customs documentation set
Returns:

The output file tuple (path, type)

Template Used

tendril/dox/templates/customs/verification-duties.tex (Included version)

Stage Keys Provided

date The date the documents were generated at, from datetime.date.today().
signatory The name of the person who ‘signs’ the document, from tendril.utils.config.COMPANY_GOVT_POINT.
inv_no The vendor’s invoice number.
inv_date The date of the vendor’s invoice.
given_data A dict containing various facts about the invoice. See tendril.sourcing.customs.CustomsInvoice.given_data.
lines A list of tendril.sourcing.customs.CustomsInvoiceLine instances.
invoice The tendril.sourcing.customs.CustomsInvoice instance.
sno The serial number of the document.
summary A list of dicts containing the summary of the customs duties applicable against a particular section, as described below
Summary keys
section The HS section, a tendril.sourcing.customs.CustomsSection` instance.
code The HS section code.
name The HS section name.
idxs Line numbers classified into this line.
qty Total quantity of all lines classified into this line.
assessablevalue Total assessable value of all lines classified into this line.
bcd Total Basic Customs Duty applicable against this section.
cvd Total Countervailing Duty applicable against this section.
acvd Total Additional Countervailing Duty applicable against this section.
cec Total Education Cess on Customs Duty applicable against this section.
cshec Total Secondary and Higher Education Cess on Customs Duty applicable against this section.
cvdec Total Education Cess on Countervailing Duty applicable against this section.
cvdshec Total Secondary and Higher Education Cess on Countervailing Duty applicable against this section.
tendril.dox.customs.gen_verificationdocs(invoice, target_folder, serialno)[source]

Generates customs verification documents.

Parameters:
  • invoice (tendril.sourcing.customs.CustomsInvoice) – The invoice object with customs information
  • target_folder – The folder in which the generated files should be written to
  • serialno (str) – The serial number of the Customs documentation set
Returns:

List of output file tuples (path, type)

Included Documents

tendril.dox.customs.generate_docs(invoice, target_folder=None, serialno=None, register=False, efield=None)[source]

Generates all the Customs related documentation given a CustomsInvoice (or subclass) instance.

Parameters:
  • invoice (tendril.sourcing.customs.CustomsInvoice) – The invoice object with customs information
  • target_folder (str) – The folder in which the generated files should be written to. Auto sets to Instance scratch folder if None
  • serialno (str) – The serial number of the Customs documentation set. Autogenerates if None.
  • register (bool) – Whether or not to register in the docstore. Default False.
  • efield (str) – Additional short note to identify the document in the store. Autogenerates from invoice if None.
Returns:

The serial number of the generated document set.

Included Document Sets

tendril.dox.customs.get_all_customs_invoice_serialnos(session=None, **kwargs)[source]
tendril.dox.customs.get_customs_invoice(serialno)[source]