PageSourceSearch

https://thaineqas.com/js/common/payment.js

js thaineqas.com collected 2026-10-09 00:35:55 UTC 6,503 bytes, 221 lines download raw bytes

1
2import * as gql from './graphql.js';
3import * as common from './common.js';
4
5// addPayment
6// ================
7// create the payment form according to the user
8// this starts after registration or recurring.
9/* subscribePayment(participant_code: ID, testing_type: Int): Payment */
10export async function addPayment(config) {
11    let { participant_code, testing_type, year } = config;
12
13    let query = `mutation {
14        subscribePayment(participant_code: "${ participant_code }", testing_type: ${ testing_type }, year: "${ year }") {
15            testing_id
16            }
17        }`;
18
19    try {
20        let ret = await gql.sendMutation({ query });
21
22        if(ret['status'] == 'success') {
23            let testing = ret['response']['data']['subscribePayment'];
24            return testing['testing_id'];
25        }
26    } catch(error) {
27        console.error(error);
28    }
29
30    return null;
31}
32
33// updatePayment
34// ================
35// update the payment parameter to be the specified lab sending type (PT/APTT/INR, FactorVIII)
36/* updatePayment(testing_id: ID, testing_type: Int): Payment */
37export async function updatePayment(config) {
38    let { testing_id, testing_type } = config;
39
40    let query = `mutation {
41        updatePayment(testing_id: "${ testing_id }", testing_type: ${ testing_type }) {
42            testing_id
43            }
44        }`;
45
46    try {
47        let ret = await gql.sendMutation({ query });
48
49        if(ret['status'] == 'success') {
50            let testing = ret['response']['data']['updatePayment'];
51            return testing['testing_id'];
52        }
53    } catch(error) {
54        console.error(error);
55    }
56
57    return null;
58}
59
60// getPayment
61// ================
62// get the list that user subscribed to the system by sending the specific lab type (PT/APTT/INR, FactorVIII)
63// this find according to participant_code
64export async function getPayment(participant_code) 
65{
66    let gql_code = `{
67        getPayment(participant_code: "${ participant_code }") {
68            testing_id
69            year
70            testing_type
71        }
72    }`
73
74    try {
75        let ret = await gql.sendGQL('query', gql_code);
76        if(ret['status'] == 'success') {
77            let payment_list = ret['response']['data']['getPayment'];
78            return payment_list; //.length > 0;
79        }
80    } catch(error) {
81        console.error(error);
82    }
83
84    return false;
85}
86
87// addReceipt
88// ================
89// addReceipt to the system
90/* addReceipt(participant_code: ID,
91        name: String,
92        address: String,
93        tambon: String,
94        district: String,
95        province: String,
96        postcode: String
97        year: String) : Receipt */
98export async function addReceipt(config)
99{
100    let { participant_code, name, address, tambon, district, province, postcode, year } = config;
101
102    let query = `mutation {
103        addReceipt(participant_code: "${ common.escapeGraphQL(participant_code) }", name: "${ common.escapeGraphQL(name) }", address: "${ common.escapeGraphQL(address) }", tambon: "${ common.escapeGraphQL(tambon) }", district: "${ common.escapeGraphQL(district) }", province: "${ common.escapeGraphQL(province) }", postcode: "${ common.escapeGraphQL(postcode) }", year: "${ common.escapeGraphQL(year) }") {
104            receipt_code
105            }
106        }`;
107
108    try {
109        let ret = await gql.sendMutation({ query });
110
111        if(ret['status'] == 'success') {
112            let participant = ret['response']['data']['addReceipt'];
113            return participant['receipt_code'];
114        }
115    } catch(error) {
116        console.error(error);
117    }
118
119    return null;
120}
121
122// updateReceipt
123// ================
124// updateReceipt to the system
125/* updateReceipt(receipt_code: ID,
126        name: String,
127        address: String,
128        tambon: String,
129        district: String,
130        province: String,
131        postcode: String
132        year: String) : Receipt */
133export async function updateReceipt(config)
134{
135    let { receipt_code, name, address, tambon, district, province, postcode } = config;
136
137    let query = `mutation {
138        updateReceipt(receipt_code: "${ common.escapeGraphQL(receipt_code) }", name: "${ common.escapeGraphQL(name) }", address: "${ common.escapeGraphQL(address) }", tambon: "${ common.escapeGraphQL(tambon) }", district: "${ common.escapeGraphQL(district) }", province: "${ common.escapeGraphQL(province) }", postcode: "${ common.escapeGraphQL(postcode) }") {
139            receipt_code
140            }
141        }`;
142
143    try {
144        let ret = await gql.sendMutation({ query });
145
146        if(ret['status'] == 'success') {
147            let participant = ret['response']['data']['updateReceipt'];
148            return participant['receipt_code'];
149        }
150    } catch(error) {
151        console.error(error);
152    }
153
154    return null;
155}
156
157// getReceipt
158// ==================
159// get the receipt data according to the participant_code
160export async function getReceipt(participant_code) 
161{
162    let gql_code = `{
163        getReceipt(participant_code: "${ participant_code }") {
164            receipt_code
165            year
166            name
167            address
168            tambon
169            province
170            district
171            postcode
172            transfer_img_path
173            receipt_img_path
174        }
175    }`
176
177    try {
178        let ret = await gql.sendGQL('query', gql_code);
179        if(ret['status'] == 'success') {
180            let receipt_list = ret['response']['data']['getReceipt'];
181            return receipt_list; //.length > 0;
182        }
183    } catch(error) {
184        console.error(error);
185    }
186
187    return false;
188}
189
190// listReceipt
191// =======================
192// list all of the receipt from the servers.
193export async function listReceipt()
194{
195    let gql_code = `{
196        listReceipt {
197            participant_code
198            name
199            year
200            address
201            tambon
202            province
203            district
204            postcode
205            transfer_img_path
206            receipt_img_path
207        }
208    }`;
209    
210    try {
211        let ret = await gql.sendGQL('query', gql_code);
212        if(ret['status'] == 'success') {
213            let receipt_list = ret['response']['data']['listReceipt'];
214            return receipt_list; //.length > 0;
215        }
216    } catch(error) {
217        console.error(error);
218    }
219
220    return null;
221}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.