Ax localized SP2 overrides the Chinese-style credential system and adopts a more loosely coupled approach to minimize modificationsCodeTo avoid bugs caused by too many modifications to the Sys-layer code. This article describes how to use ax to localize the sp2 Chinese-style credential system from the perspective of using the sp2 Chinese-style credential system and learning code.
I. Use
In SP1, we know which encoding rule is used by each business module to generate a credential number through the General Ledger-> Settings-> log-> credential type settings-> credential type-> relationship, there are many transfer types, which are implemented by setting many transfer types. This is not complicated. In fact, localization only involves transferring the credential type to the class according to the receipt and payment, if it is associated with different types of transfers, some modules will be developed by myself in the future.
SP2 uses accounting subjects to determine the type of creden used for remittance. This is also suitable for the actual situation in China. Only cash and bank accounts in China are used for receipt and payment, and the rest are used for transfer, therefore, it is easier to set the type of creden used by accounts.
The first few fields on this interface can be seen at a Glance. The priority and default values of the following two fields must be tested to understand their meanings. Let's take a look at the rules first. After the rules are completed, we will introduce the meanings of these two fields.
we can see that the above eight Rules are available. For receipt creden, we can set that the borrower must have cash and bank accounts. For payment creden, we can set credit to have cash and banking subjects. OK, so there is a problem if it is withdrawal from the bank
borrow: Cash
loan: bank deposits
This satisfies both the receipt credential (the borrower must have cash and bank accounts) and the payment credential (the lender must have cash and bank accounts ). In general, withdrawal from a bank or deposit cash into a bank is treated as payment. How can we convert such business to use payment creden? The priority mentioned above has a chance to show your skills. Well, yes, it is okay to set the priority of the payment credential higher than the receipt credential.
the other types of transactions should all use the creden of the transfer type. How can this problem be solved? The default value of the transfer credential is used. If the conditions of the receipt and payment credential (neither the borrower has cash or the bank deposit account) are met, the default value of the transfer credential is used.
of course, this is just a few simple cases. If there are other cases, you can set them as needed.
2. code learning:
1. in terms of data storage, ax SP2 adds the voucher_cn and vouchertypeid_cn fields to ledgertrans and uses these two fields to store the localization credential number, in the past, the creden at the Sys layer were generated using their own logic. As you go through your yangguan Road, I will go through my zhuqiao, and the two will not affect each other.
2. Improved numberseq_voucher class in the business logic layer and added newgetvoucherfromcode, release, and used methods for encoding allocation, release, and use. The generation of Chinese-style creden of the business module is implemented by adding a piece of code in the POST method of ledgervoucherobject, in addition, the getvouchertype_cn method is added to this class to obtain the credential type used for the current transaction to generate the credential number.
in this way, two sets of creden are displayed in the system, one is the creden at the Sys layer and the other is the localized creden at the Gls layer. The two are parallel and mutually independent.
You can regard the field of the Credential as a serial number, and the Chinese credential as the real credential number. Of course, if you think that a mountain cannot accommodate two tigers, you can try it quickly, the voucher of ledgertrans can be completely hidden, and the eyes will not bother.
In addition, the sp2 credential system enables the function of assigning a number when the credential name is transferred to take effect. The credential number is not generated when the Financial log is created, therefore, you can ensure that the creden number after the transfer is continuous.
this article only briefly introduces how you feel about using the sp2 Chinese-style credential system. If you have any mistakes, please correct them.
thanks to the mbscn user lxw6 for your advice.