ผลต่างระหว่างรุ่นของ "Common Functions"
ไม่มีความย่อการแก้ไข |
|||
บรรทัดที่ 1: | บรรทัดที่ 1: | ||
== | == Database Read Functions == | ||
'''<syntaxhighlight lang="python" id="grab_id"> | '''<syntaxhighlight lang="python" id="grab_id"> | ||
grab_id(bookcode, sch_kw, models, isgl=False, datatype="data", month=None, sch_col="docno") | grab_id(bookcode, sch_kw, models, isgl=False, datatype="data", month=None, sch_col="docno") | ||
บรรทัดที่ 51: | บรรทัดที่ 51: | ||
|} | |} | ||
'''<syntaxhighlight lang="python" id="prefetch_all_docs"> | |||
prefetch_all_docs(bookcode, master_spec, detail_specs, isgl=False, datatype="data", | |||
month=None, headid=None, id_col="id", return_instance=False, crossers=[]) | |||
</syntaxhighlight>''' | |||
{| style="margin-left:20px;" | |||
|- style="vertical-align:top;" | |||
| style="width:120px;" | '''Description''' || Retrieve one or any number of database entries. Since this function allows retrieval from a master table with sub-tables, it is mostly used with (and thus named) ''documents'', however using it with complex code tables is also valid. | |||
|- style="vertical-align:top;" | |||
| '''Parameters''' || | |||
* '''bookcode''' ''(str)'': The database name (usually a three-lettered string). | |||
* '''master_spec''' ''(CuneiModel or [CuneiModel, list])'': The specification for master entry retrieval. | |||
*# The given CuneiModel corresponds to the master table. | |||
*# When given as a list, its second member lists the ordering column(s) for the master table. If not given, the master table is sorted by {{code|lang=python|master_model.id}}. | |||
* '''detail_specs''' ''([CuneiModel,] or [[CuneiModel, list],])'': The list of specifications for sub-entry retrievals. | |||
*# The CuneiModels given in this argument correspond to the database sub-tables. | |||
*# The optional list sub-members hold the ordering column(s) for the sub-tables. If not given, each sub-table is sorted by {{code|lang=python|sub_model.id)}}. | |||
* '''isgl''' ''(bool)'': Whether the database is considered an accounting journal database. ''(One can also feed the argument '''bookcode''' in the format '''{{code|GL_XXX}}''' and ignore this argument.)'' | |||
* '''datatype''' ''(str: {{code|lang=python|'table'}}, {{code|lang=python|'data'}}, or {{code|lang=python|'report'}})'': The data type (location) of the database file. | |||
* '''month''' ''(str, date, or datetime)'': The data month (effective for {{code|lang=python|1= datatype='data'}}). If the argument is a string, it must be formatted either as {{code|YYYYMM}} or {{code|YYYYMMDD}}. | |||
* '''headid''' ''(value or list)'': ''(See explanation under '''idcol''' argument.)'' | |||
* '''idcol''' ''(str)'': This argument works with '''headid''' in 2 mode: | |||
** In simple mode, '''idcol''' is ''the name of the column'' to be screened by '''headid''' value. | |||
*** If '''headid''' is a list, any entry whose '''idcol''' match any of the members is considered a match. | |||
*** If '''headid''' is not a list, any entry whose '''idcol''' match the value is considered a match. | |||
** In raw-criteria mode, '''idcol''' is set to {{code|lang=python|'__raw_crits'}}. '''headid''' is the list of criteria (where-clause as interpreted by Peewee) to be directly applied to the query. | |||
* '''return_instance''' ''(bool)'': Whether to return only the first match as a CuneiModel instance. | |||
* '''crossers''' ''(list)'': '''Currently not-in-use.''' It is a part of the plan to expand the capacity of this function to allow something similar to [[CuneiModel#Cross-table references]]. | |||
|- style="vertical-align:top;" | |||
| '''Returns''' || 2 objects: | |||
* '''doccount''' ''(int)'': The total number of matching documents found. | |||
* '''doclist''' ''(list)'' or '''doc''' ''(CuneiModel instance or {{code|lang=python|None}})'': The matching document(s). The format of this returned value depends on the input argument '''return_instance'''. | |||
|} | |||
== Database Write Functions == | |||
'''<syntaxhighlight lang="python" id="gen_dbcommit_resp"> | '''<syntaxhighlight lang="python" id="gen_dbcommit_resp"> | ||
gen_dbcommit_resp(dbtype, tbname, model, form, perm_bit=None, allowed_action=None, | gen_dbcommit_resp(dbtype, tbname, model, form, perm_bit=None, allowed_action=None, | ||
บรรทัดที่ 86: | บรรทัดที่ 120: | ||
|} | |} | ||
== Copy-based Functions == | |||
'''<syntaxhighlight lang="python" id="prep_copy"> | '''<syntaxhighlight lang="python" id="prep_copy"> | ||
prep_copy(cp_form, bookcode, head_model, detail_models=[], isgl=False) | prep_copy(cp_form, bookcode, head_model, detail_models=[], isgl=False) | ||
บรรทัดที่ 158: | บรรทัดที่ 160: | ||
|} | |} | ||
== User Authentication Functions == | |||
'''<syntaxhighlight lang="python" id="check_modact_stat"> | '''<syntaxhighlight lang="python" id="check_modact_stat"> | ||
check_modact_stat(modid=None, modcode=None, mode="activate", response="return") | check_modact_stat(modid=None, modcode=None, mode="activate", response="return") | ||
บรรทัดที่ 176: | บรรทัดที่ 179: | ||
|} | |} | ||
'''<syntaxhighlight lang="python" id="process_beacon_args"> | '''<syntaxhighlight lang="python" id="process_beacon_args"> | ||
process_beacon_args(internal_args, request) | process_beacon_args(internal_args, request) | ||
บรรทัดที่ 444: | บรรทัดที่ 410: | ||
doc_mass_delete(dbtype, dbname, models, doc_objs=[], month=None, post_cmd=None, | doc_mass_delete(dbtype, dbname, models, doc_objs=[], month=None, post_cmd=None, | ||
job_token=None, addi_args=[], docno_to_skip=[]) | job_token=None, addi_args=[], docno_to_skip=[]) | ||
</syntaxhighlight>''' | |||
{| style="margin-left:20px;" | |||
|- style="vertical-align:top;" | |||
| style="width:120px;" | '''Description''' || XXXXXX | |||
|- style="vertical-align:top;" | |||
| '''Parameters''' || | |||
* '''xxx''' ''(xxx)'': | |||
* '''xxx''' ''(xxx)'': | |||
|- style="vertical-align:top;" | |||
| '''Returns''' || | |||
* '''xxx''' ''(xxx)'': | |||
* '''xxx''' ''(xxx)'': | |||
|- style="vertical-align:top;" | |||
| '''Notes''' || XXXXXX | |||
|} | |||
== Miscellaneous == | |||
'''<syntaxhighlight lang="python" id="process_doc_file"> | |||
process_doc_file(dbtype, tbname, model, at_form, isgl=False, month=None) | |||
</syntaxhighlight>''' | |||
{| style="margin-left:20px;" | |||
|- style="vertical-align:top;" | |||
| style="width:120px;" | '''Description''' || XXXXXX | |||
|- style="vertical-align:top;" | |||
| '''Parameters''' || | |||
* '''xxx''' ''(xxx)'': | |||
* '''xxx''' ''(xxx)'': | |||
|- style="vertical-align:top;" | |||
| '''Returns''' || | |||
* '''xxx''' ''(xxx)'': | |||
* '''xxx''' ''(xxx)'': | |||
|- style="vertical-align:top;" | |||
| '''Notes''' || XXXXXX | |||
|} | |||
'''<syntaxhighlight lang="python" id="gen_random_token"> | |||
gen_random_token(length=10, lower=True, upper=True, number=True) | |||
</syntaxhighlight>''' | </syntaxhighlight>''' | ||
{| style="margin-left:20px;" | {| style="margin-left:20px;" |
รุ่นแก้ไขเมื่อ 09:41, 24 กรกฎาคม 2567
Database Read Functions
grab_id(bookcode, sch_kw, models, isgl=False, datatype="data", month=None, sch_col="docno")
Description | Fetch the ID of the looked-up entry. Because this function is usually utilized in the page-level search function, it is designed to target string-based column by looking for values that starts-with the search keyword. In case of multiple matches, the ID of the first match (ordered by the search column). |
Parameters |
|
Returns |
|
grab_whole_doc(bookcode, identifiers, master_model, detail_models, isgl=False,
datatype="data", month=None)
Description | Retrieve a single document (along with all its sub-entries) to display on the client-side. This function is tailored to the client-side mass-populate routine, so its algorithm leans heavily in that direction. For a more server-friendly retrieval, use prefetch_all_docs instead. |
Parameters | DO NOT rely on argument order beyond detail_models.
|
Returns | 3 objects:
|
prefetch_all_docs(bookcode, master_spec, detail_specs, isgl=False, datatype="data",
month=None, headid=None, id_col="id", return_instance=False, crossers=[])
Description | Retrieve one or any number of database entries. Since this function allows retrieval from a master table with sub-tables, it is mostly used with (and thus named) documents, however using it with complex code tables is also valid. |
Parameters |
|
Returns | 2 objects:
|
Database Write Functions
gen_dbcommit_resp(dbtype, tbname, model, form, perm_bit=None, allowed_action=None,
suppress_success_msg=False, lock_on_add=True, head_id_col="id",
get_dict=None, skip_validation=False, month=None)
Description | Conduct form validation and, if passed, commit the form data to database. |
Parameters | DO NOT rely on argument order beyond perm_bit.
|
Returns |
|
Copy-based Functions
prep_copy(cp_form, bookcode, head_model, detail_models=[], isgl=False)
Description | Interpret and validate the Copy Form. If the validation is successful, retrieve the original document as well. |
Parameters |
|
Returns | 3 objects:
|
create_doc_copy(cp_form, copy_params, bookcode, orig_doc, head_model, detail_models={},
isgl=False, omit_cols=[])
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
User Authentication Functions
check_modact_stat(modid=None, modcode=None, mode="activate", response="return")
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
process_beacon_args(internal_args, request)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
process_doclock(beacon_args, module_name, perm_name, headmodel=None, paired_gl=None)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
change_datetime(form, reset=False, date_obj=None, time_obj=None)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
Thread Functions
init_task_db(job_token, overall_load, new_stat="", activity_str="",
suppress_request=True, further_action="")
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
update_task_db(job_token, finished_load=0, overall_load=None,
new_stat=None, activity_str=None, further_action=None)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
read_task_db(job_token)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
read_resus_import_file(job_token, will_abort=False)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
Printing Functions
print_in_thread(job_token, doc_objs, pseudo_mapper, modcode, template_name,
svg_name=None, stat_cols=[], skip_company_template=False,
make_pdfa3=False)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
gen_qr(num, qr_type="out", info=None)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
replace_printsvg(tbfm_mapper, modcode, bookname=None, svg_name=None, suffix=None,
job_data=None, clear_printed=True, skip_company_template=False,
make_pdfa3=False)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
Spreadsheet Export Functions
gen_spreadsheet(specs, round_all=None, col_desc=None, col_size={})
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
Import & Mass Delete Functions
docimport_to_db(file_path, dbtype, dbname, models, specs, month=None,
verify_cmd=None, post_cmd=None, addi_args=[], autorun_specs=None,
job_token=None, custom_datasets=None)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
doc_mass_delete(dbtype, dbname, models, doc_objs=[], month=None, post_cmd=None,
job_token=None, addi_args=[], docno_to_skip=[])
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
Miscellaneous
process_doc_file(dbtype, tbname, model, at_form, isgl=False, month=None)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |
gen_random_token(length=10, lower=True, upper=True, number=True)
Description | XXXXXX |
Parameters |
|
Returns |
|
Notes | XXXXXX |