ผลต่างระหว่างรุ่นของ "Common Functions"
บรรทัดที่ 138: | บรรทัดที่ 138: | ||
* '''return_dict''' ''(dict)'': A starter for the reply of a non-redirecting form submit request ''(see [[CuneiForm#Non-redirecting Form]])''. This function takes care of the dict's '''{{code|lang=python|'err'}} key in case of CuneiForm ValidationError or when the original document cannot be retrieve. | * '''return_dict''' ''(dict)'': A starter for the reply of a non-redirecting form submit request ''(see [[CuneiForm#Non-redirecting Form]])''. This function takes care of the dict's '''{{code|lang=python|'err'}} key in case of CuneiForm ValidationError or when the original document cannot be retrieve. | ||
* '''orig_doc''' ''(CuneiModel instance or None)'': The original document. When not all values are copied verbatim, this object is meant to be manipulated before being fed to '''create_doc_copy'''. | * '''orig_doc''' ''(CuneiModel instance or None)'': The original document. When not all values are copied verbatim, this object is meant to be manipulated before being fed to '''create_doc_copy'''. | ||
* ''' | * '''copy_params''' ''(dict)'': The data from the Copy Form extracted to a dict form for easier access. | ||
|} | |} | ||
บรรทัดที่ 151: | บรรทัดที่ 151: | ||
| '''Parameters''' || | | '''Parameters''' || | ||
* '''cp_form''' ''(CuneiForm)'': The Copy Form to be read and validated. | * '''cp_form''' ''(CuneiForm)'': The Copy Form to be read and validated. | ||
* ''' | * '''copy_params''' ''(dict)'': The copy parameters. The function expects the argument to include keys {{code|lang=python|'docno'}}, {{code|lang=python|'docdate'}}, {{code|lang=python|'section_stid'}}, {{code|lang=python|'section_code'}}, and {{code|lang=python|'section_name'}}. ''(The dict returned from {{code|prep_copy}} can be fed directly here.)'' | ||
* '''bookcode''' ''(str)'': The database name (usually a three-lettered string). | * '''bookcode''' ''(str)'': The database name (usually a three-lettered string). | ||
* ''' | * '''orig_doc''' ''(CuneiModel instance)'': The instance to be committed to the target database. Note that all the values ''except those read from '''copy_params''''' are copied verbatim in this function. If that is not the requirement, modify the instance before feeding it here. | ||
* '''head_model''' ''(CuneiModel)'': The model corresponding to the master table. | * '''head_model''' ''(CuneiModel)'': The model corresponding to the master table. | ||
* '''detail_models''' ''([CuneiModel,])'': The models corresponding to the sub-tables. | * '''detail_models''' ''([CuneiModel,])'': The models corresponding to the sub-tables. | ||
* '''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.)'' | * '''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.)'' | ||
* ''' | * '''omit_cols''' ''([str,])'': The list of columns not to be copied from '''orig_doc'''. The default value of each column is used instead. | ||
|- style="vertical-align:top;" | |- style="vertical-align:top;" | ||
| '''Returns''' || The newly copied document (if successfully copied) or {{code|lang=python|None}} (if copying failed). | | '''Returns''' || The newly copied document (if successfully copied) or {{code|lang=python|None}} (if copying failed). | ||
|- style="vertical-align:top;" | |||
| '''Notes''' || A notable kink in this function is that the '''cp_form''' and '''copy_params''' arguments are quite redundant. In the algorithm, '''cp_form''' is only used for its automatic document number attribute. If the function {{code|assign_autorun}} is well modified, the need for '''cp_form''' might cease to exist. | |||
|} | |} | ||
รุ่นแก้ไขเมื่อ 10:32, 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 | Commit the document copying to the proper database. |
Parameters |
|
Returns | The newly copied document (if successfully copied) or None (if copying failed).
|
Notes | A notable kink in this function is that the cp_form and copy_params arguments are quite redundant. In the algorithm, cp_form is only used for its automatic document number attribute. If the function assign_autorun is well modified, the need for cp_form might cease to exist.
|
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 |