Changeset 2714
- Timestamp:
- 03/08/2016 05:22:20 PM (9 years ago)
- Location:
- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/includes/payment-request.php
r2711 r2714 1342 1342 return ob_get_clean(); 1343 1343 } 1344 1345 /** 1346 * Wires via JP Morgan 1347 * 1348 * @param array $args 1349 * 1350 * @return string 1351 */ 1352 public static function _generate_payment_report_jpm_wires( $args ) { 1353 $args = wp_parse_args( $args, array( 1354 'data' => array(), 1355 'status' => '', 1356 'post_type' => '', 1357 ) ); 1358 1359 ob_start(); 1360 $report = fopen( 'php://output', 'w' ); 1361 1362 // JPM Header 1363 fputcsv( $report, array( 'HEADER', gmdate( 'YmdHis' ), '1' ) ); 1364 1365 $total = 0; 1366 $count = 0; 1367 1368 foreach ( $args['data'] as $entry ) { 1369 switch_to_blog( $entry->blog_id ); 1370 $post = get_post( $entry->post_id ); 1371 1372 if ( $args['status'] && $post->post_status != $args['status'] ) { 1373 restore_current_blog(); 1374 continue; 1375 } elseif ( $post->post_type != self::POST_TYPE ) { 1376 restore_current_blog(); 1377 continue; 1378 } elseif ( get_post_meta( $post->ID, '_camppayments_payment_method', true ) != 'Wire' ) { 1379 restore_current_blog(); 1380 continue; 1381 } 1382 1383 $amount = round( floatval( get_post_meta( $post->ID, '_camppayments_payment_amount', true ) ), 2); 1384 $total += $amount; 1385 $count += 1; 1386 1387 // If account starts with two letters, it's most likely an IBAN 1388 $account = get_post_meta( $post->ID, '_camppayments_beneficiary_account_number', true ); 1389 $account = WCP_Encryption::maybe_decrypt( $account ); 1390 $account = preg_replace( '#\s#','', $account ); 1391 $account_type = preg_match( '#^[a-z]{2}#i', $account ) ? 'IBAN' : 'ACCT'; 1392 1393 $row = array( 1394 '1-input-type' => 'P', 1395 '2-payment-method' => 'WIRES', 1396 '3-debit-bank-id' => apply_filters( 'wcb_payment_req_bank_id', '' ), // external file 1397 '4-account-number' => apply_filters( 'wcb_payment_req_bank_number', '' ), // external file 1398 '5-bank-to-bank' => 'N', 1399 '6-txn-currency' => get_post_meta( $post->ID, '_camppayments_currency', true ), 1400 '7-txn-amount' => number_format( $amount, 2, '.', '' ), 1401 '8-equiv-amount' => '', 1402 '9-clearing' => '', 1403 '10-ben-residence' => '', 1404 '11-rate-type' => '', 1405 '12-blank' => '', 1406 '13-value-date' => '', 1407 1408 '14-id-type' => $account_type, 1409 '15-id-value' => $account, 1410 '16-ben-name' => substr( WCP_Encryption::maybe_decrypt( 1411 get_post_meta( $post->ID, '_camppayments_beneficiary_name', true ) ), 0, 35 ), 1412 '17-address-1' => substr( WCP_Encryption::maybe_decrypt( 1413 get_post_meta( $post->ID, '_camppayments_beneficiary_street_address', true ) ), 0, 35 ), 1414 '18-address-2' => '', 1415 '19-city-state-zip' => substr( sprintf( '%s %s %s', 1416 WCP_Encryption::maybe_decrypt( get_post_meta( $post->ID, '_camppayments_beneficiary_city', true ) ), 1417 WCP_Encryption::maybe_decrypt( get_post_meta( $post->ID, '_camppayments_beneficiary_state', true ) ), 1418 WCP_Encryption::maybe_decrypt( get_post_meta( $post->ID, '_camppayments_beneficiary_zip_code', true ) ) 1419 ), 0, 32 ), 1420 '20-blank' => '', 1421 '21-country' => WCP_Encryption::maybe_decrypt( 1422 get_post_meta( $post->ID, '_camppayments_beneficiary_country_iso3166', true ) ), 1423 '22-blank' => '', 1424 '23-blank' => '', 1425 1426 '24-id-type' => 'SWIFT', 1427 '25-id-value' => get_post_meta( $post->ID, '_camppayments_bank_bic', true ), 1428 '26-ben-bank-name' => substr( get_post_meta( $post->ID, '_camppayments_bank_name', true ), 0, 35 ), 1429 '27-ben-bank-address-1' => substr( get_post_meta( $post->ID, '_camppayments_bank_street_address', true ), 0, 35 ), 1430 '28-ben-bank-address-2' => '', 1431 '29-ben-bank-address-3' => substr( sprintf( '%s %s %s', 1432 get_post_meta( $post->ID, '_camppayments_bank_city', true ), 1433 get_post_meta( $post->ID, '_camppayments_bank_state', true ), 1434 get_post_meta( $post->ID, '_camppayments_bank_zip_code', true ) 1435 ), 0, 35 ), 1436 '30-ben-bank-country' => get_post_meta( $post->ID, '_camppayments_bank_country_iso3166', true ), 1437 '31-supl-id-type' => '', 1438 '32-supl-id-value' => '', 1439 1440 '33-blank' => '', 1441 '34-blank' => '', 1442 '35-blank' => '', 1443 '36-blank' => '', 1444 '37-blank' => '', 1445 '38-blank' => '', 1446 '39-blank' => '', 1447 1448 // Filled out later if not empty. 1449 '40-id-type' => '', 1450 '41-id-value' => '', 1451 '42-interm-bank-name' => '', 1452 '43-interm-bank-address-1' => '', 1453 '44-interm-bank-address-2' => '', 1454 '45-interm-bank-address-3' => '', 1455 '46-interm-bank-country' => '', 1456 '47-supl-id-type' => '', 1457 '48-supl-id-value' => '', 1458 1459 '49-id-type' => '', 1460 '50-id-value' => '', 1461 '51-party-name' => '', 1462 '52-party-address-1' => '', 1463 '53-party-address-2' => '', 1464 '54-party-address-3' => '', 1465 '55-party-country' => '', 1466 1467 '56-blank' => '', 1468 '57-blank' => '', 1469 '58-blank' => '', 1470 '59-blank' => '', 1471 '60-blank' => '', 1472 '61-blank' => '', 1473 '62-blank' => '', 1474 '63-blank' => '', 1475 '64-blank' => '', 1476 '65-blank' => '', 1477 '66-blank' => '', 1478 '67-blank' => '', 1479 '68-blank' => '', 1480 '69-blank' => '', 1481 '70-blank' => '', 1482 '71-blank' => '', 1483 '72-blank' => '', 1484 '73-blank' => '', 1485 1486 '74-ref-text' => substr( get_post_meta( $post->ID, '_camppayments_invoice_number', true ), 0, 16 ), 1487 '75-internal-ref' => '', 1488 '76-on-behalf-of' => '', 1489 1490 '77-detial-1' => '', 1491 '78-detial-2' => '', 1492 '79-detial-3' => '', 1493 '80-detail-4' => '', 1494 1495 '81-blank' => '', 1496 '82-blank' => '', 1497 '83-blank' => '', 1498 '84-blank' => '', 1499 '85-blank' => '', 1500 '86-blank' => '', 1501 '87-blank' => '', 1502 '88-blank' => '', 1503 1504 '89-reporting-code' => '', 1505 '90-country' => '', 1506 '91-inst-1' => '', 1507 '92-inst-2' => '', 1508 '93-inst-3' => '', 1509 '94-inst-code-1' => '', 1510 '95-inst-text-1' => '', 1511 '96-inst-code-2' => '', 1512 '97-inst-text-2' => '', 1513 '98-inst-code-3' => '', 1514 '99-inst-text-3' => '', 1515 1516 '100-stor-code-1' => '', 1517 '101-stor-line-2' => '', // Hmm? 1518 '102-stor-code-2' => '', 1519 '103-stor-line-2' => '', 1520 '104-stor-code-3' => '', 1521 '105-stor-line-3' => '', 1522 '106-stor-code-4' => '', 1523 '107-stor-line-4' => '', 1524 '108-stor-code-5' => '', 1525 '109-stor-line-5' => '', 1526 '110-stor-code-6' => '', 1527 '111-stor-line-6' => '', 1528 1529 '112-priority' => '', 1530 '113-blank' => '', 1531 '114-charges' => '', 1532 '115-blank' => '', 1533 '116-details' => '', 1534 '117-note' => substr( sprintf( 'wcb-%d-%d', $entry->blog_id, $entry->post_id ), 0, 70 ), 1535 ); 1536 1537 // If an intermediary bank is given. 1538 $interm_swift = get_post_meta( $post->ID, '_camppayments_interm_bank_swift', true ); 1539 if ( ! empty( $iterm_swift ) ) { 1540 $row['40-id-type'] = 'SWIFT'; 1541 $row['41-id-value'] = $interm_swift; 1542 1543 $row['42-interm-bank-name'] = substr( get_post_meta( $post->ID, '_camppayments_interm_bank_name', true ), 0, 35 ); 1544 $row['43-interm-bank-address-1'] = substr( get_post_meta( $post->ID, '_camppayments_interm_bank_street_address', true ), 0, 35 ); 1545 1546 $row['44-interm-bank-address-2'] = ''; 1547 $row['45-interm-bank-address-3'] = substr( sprintf( '%s %s %s', 1548 get_post_meta( $post->ID, '_camppayments_interm_bank_city', true ), 1549 get_post_meta( $post->ID, '_camppayments_interm_bank_state', true ), 1550 get_post_meta( $post->ID, '_camppayments_interm_bank_zip_code', true ) 1551 ), 0, 32 ); 1552 1553 $row['46-interm-bank-country'] = get_post_meta( $post->ID, '_camppayments_interm_bank_country_iso3166', true ); 1554 1555 $row['47-supl-id-type'] = 'ACCT'; 1556 $row['48-supl-id-value'] = get_post_meta( $post->ID, '_camppayments_interm_bank_account', true ); 1557 } 1558 1559 // Use for debugging. 1560 // print_r( $row ); 1561 1562 fputcsv( $report, array_values( $row ) ); 1563 restore_current_blog(); 1564 } 1565 1566 // JPM Trailer 1567 fputcsv( $report, array( 'TRAILER', $count, $total ) ); 1568 1569 fclose( $report ); 1570 $results = ob_get_clean(); 1571 1572 // JPM chokes on accents and non-latin characters. 1573 $results = remove_accents( $results ); 1574 return $results; 1575 } 1344 1576 } -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/includes/reimbursement-request.php
r2711 r2714 1145 1145 return ob_get_clean(); 1146 1146 } 1147 1148 /** 1149 * Wires via JP Morgan 1150 * 1151 * @param array $args 1152 * 1153 * @return string 1154 */ 1155 function _generate_payment_report_jpm_wires( $args ) { 1156 $args = wp_parse_args( $args, array( 1157 'data' => array(), 1158 'status' => '', 1159 'post_type' => '', 1160 ) ); 1161 1162 ob_start(); 1163 $report = fopen( 'php://output', 'w' ); 1164 1165 // JPM Header 1166 fputcsv( $report, array( 'HEADER', gmdate( 'YmdHis' ), '1' ) ); 1167 1168 $total = 0; 1169 $count = 0; 1170 1171 foreach ( $args['data'] as $entry ) { 1172 switch_to_blog( $entry->blog_id ); 1173 $post = get_post( $entry->request_id ); 1174 1175 if ( $args['status'] && $post->post_status != $args['status'] ) { 1176 restore_current_blog(); 1177 continue; 1178 } elseif ( $post->post_type != POST_TYPE ) { 1179 restore_current_blog(); 1180 continue; 1181 } elseif ( get_post_meta( $post->ID, '_wcbrr_payment_method', true ) != 'Wire' ) { 1182 restore_current_blog(); 1183 continue; 1184 } 1185 1186 $amount = 0; 1187 $expenses = get_post_meta( $post->ID, '_wcbrr_expenses', true ); 1188 foreach ( $expenses as $expense ) { 1189 if ( ! empty( $expense['_wcbrr_amount'] ) ) { 1190 $amount += floatval( $expense['_wcbrr_amount'] ); 1191 } 1192 } 1193 1194 $amount = round( $amount, 2 ); 1195 $total += $amount; 1196 $count += 1; 1197 1198 // If account starts with two letters, it's most likely an IBAN 1199 $account = get_post_meta( $post->ID, '_wcbrr_beneficiary_account_number', true ); 1200 $account = \WCP_Encryption::maybe_decrypt( $account ); 1201 $account = preg_replace( '#\s#','', $account ); 1202 $account_type = preg_match( '#^[a-z]{2}#i', $account ) ? 'IBAN' : 'ACCT'; 1203 1204 $row = array( 1205 '1-input-type' => 'P', 1206 '2-payment-method' => 'WIRES', 1207 '3-debit-bank-id' => apply_filters( 'wcb_payment_req_bank_id', '' ), // external file 1208 '4-account-number' => apply_filters( 'wcb_payment_req_bank_number', '' ), // external file 1209 '5-bank-to-bank' => 'N', 1210 '6-txn-currency' => get_post_meta( $post->ID, '_wcbrr_currency', true ), 1211 '7-txn-amount' => number_format( $amount, 2, '.', '' ), 1212 '8-equiv-amount' => '', 1213 '9-clearing' => '', 1214 '10-ben-residence' => '', 1215 '11-rate-type' => '', 1216 '12-blank' => '', 1217 '13-value-date' => '', 1218 1219 '14-id-type' => $account_type, 1220 '15-id-value' => $account, 1221 '16-ben-name' => substr( \WCP_Encryption::maybe_decrypt( 1222 get_post_meta( $post->ID, '_wcbrr_beneficiary_name', true ) ), 0, 35 ), 1223 '17-address-1' => substr( \WCP_Encryption::maybe_decrypt( 1224 get_post_meta( $post->ID, '_wcbrr_beneficiary_street_address', true ) ), 0, 35 ), 1225 '18-address-2' => '', 1226 '19-city-state-zip' => substr( sprintf( '%s %s %s', 1227 \WCP_Encryption::maybe_decrypt( get_post_meta( $post->ID, '_wcbrr_beneficiary_city', true ) ), 1228 \WCP_Encryption::maybe_decrypt( get_post_meta( $post->ID, '_wcbrr_beneficiary_state', true ) ), 1229 \WCP_Encryption::maybe_decrypt( get_post_meta( $post->ID, '_wcbrr_beneficiary_zip_code', true ) ) 1230 ), 0, 32 ), 1231 '20-blank' => '', 1232 '21-country' => \WCP_Encryption::maybe_decrypt( 1233 get_post_meta( $post->ID, '_wcbrr_beneficiary_country_iso3166', true ) ), 1234 '22-blank' => '', 1235 '23-blank' => '', 1236 1237 '24-id-type' => 'SWIFT', 1238 '25-id-value' => get_post_meta( $post->ID, '_wcbrr_bank_bic', true ), 1239 '26-ben-bank-name' => substr( get_post_meta( $post->ID, '_wcbrr_bank_name', true ), 0, 35 ), 1240 '27-ben-bank-address-1' => substr( get_post_meta( $post->ID, '_wcbrr_bank_street_address', true ), 0, 35 ), 1241 '28-ben-bank-address-2' => '', 1242 '29-ben-bank-address-3' => substr( sprintf( '%s %s %s', 1243 get_post_meta( $post->ID, '_wcbrr_bank_city', true ), 1244 get_post_meta( $post->ID, '_wcbrr_bank_state', true ), 1245 get_post_meta( $post->ID, '_wcbrr_bank_zip_code', true ) 1246 ), 0, 35 ), 1247 '30-ben-bank-country' => get_post_meta( $post->ID, '_wcbrr_bank_country_iso3166', true ), 1248 '31-supl-id-type' => '', 1249 '32-supl-id-value' => '', 1250 1251 '33-blank' => '', 1252 '34-blank' => '', 1253 '35-blank' => '', 1254 '36-blank' => '', 1255 '37-blank' => '', 1256 '38-blank' => '', 1257 '39-blank' => '', 1258 1259 // Filled out later if not empty. 1260 '40-id-type' => '', 1261 '41-id-value' => '', 1262 '42-interm-bank-name' => '', 1263 '43-interm-bank-address-1' => '', 1264 '44-interm-bank-address-2' => '', 1265 '45-interm-bank-address-3' => '', 1266 '46-interm-bank-country' => '', 1267 '47-supl-id-type' => '', 1268 '48-supl-id-value' => '', 1269 1270 '49-id-type' => '', 1271 '50-id-value' => '', 1272 '51-party-name' => '', 1273 '52-party-address-1' => '', 1274 '53-party-address-2' => '', 1275 '54-party-address-3' => '', 1276 '55-party-country' => '', 1277 1278 '56-blank' => '', 1279 '57-blank' => '', 1280 '58-blank' => '', 1281 '59-blank' => '', 1282 '60-blank' => '', 1283 '61-blank' => '', 1284 '62-blank' => '', 1285 '63-blank' => '', 1286 '64-blank' => '', 1287 '65-blank' => '', 1288 '66-blank' => '', 1289 '67-blank' => '', 1290 '68-blank' => '', 1291 '69-blank' => '', 1292 '70-blank' => '', 1293 '71-blank' => '', 1294 '72-blank' => '', 1295 '73-blank' => '', 1296 1297 '74-ref-text' => 'Reimbursement', 1298 '75-internal-ref' => '', 1299 '76-on-behalf-of' => '', 1300 1301 '77-detial-1' => '', 1302 '78-detial-2' => '', 1303 '79-detial-3' => '', 1304 '80-detail-4' => '', 1305 1306 '81-blank' => '', 1307 '82-blank' => '', 1308 '83-blank' => '', 1309 '84-blank' => '', 1310 '85-blank' => '', 1311 '86-blank' => '', 1312 '87-blank' => '', 1313 '88-blank' => '', 1314 1315 '89-reporting-code' => '', 1316 '90-country' => '', 1317 '91-inst-1' => '', 1318 '92-inst-2' => '', 1319 '93-inst-3' => '', 1320 '94-inst-code-1' => '', 1321 '95-inst-text-1' => '', 1322 '96-inst-code-2' => '', 1323 '97-inst-text-2' => '', 1324 '98-inst-code-3' => '', 1325 '99-inst-text-3' => '', 1326 1327 '100-stor-code-1' => '', 1328 '101-stor-line-2' => '', // Hmm? 1329 '102-stor-code-2' => '', 1330 '103-stor-line-2' => '', 1331 '104-stor-code-3' => '', 1332 '105-stor-line-3' => '', 1333 '106-stor-code-4' => '', 1334 '107-stor-line-4' => '', 1335 '108-stor-code-5' => '', 1336 '109-stor-line-5' => '', 1337 '110-stor-code-6' => '', 1338 '111-stor-line-6' => '', 1339 1340 '112-priority' => '', 1341 '113-blank' => '', 1342 '114-charges' => '', 1343 '115-blank' => '', 1344 '116-details' => '', 1345 '117-note' => substr( sprintf( 'wcb-%d-%d', $entry->blog_id, $entry->request_id ), 0, 70 ), 1346 ); 1347 1348 // If an intermediary bank is given. 1349 $interm_swift = get_post_meta( $post->ID, '_wcbrr_interm_bank_swift', true ); 1350 if ( ! empty( $iterm_swift ) ) { 1351 $row['40-id-type'] = 'SWIFT'; 1352 $row['41-id-value'] = $interm_swift; 1353 1354 $row['42-interm-bank-name'] = substr( get_post_meta( $post->ID, '_wcbrr_interm_bank_name', true ), 0, 35 ); 1355 $row['43-interm-bank-address-1'] = substr( get_post_meta( $post->ID, '_wcbrr_interm_bank_street_address', true ), 0, 35 ); 1356 1357 $row['44-interm-bank-address-2'] = ''; 1358 $row['45-interm-bank-address-3'] = substr( sprintf( '%s %s %s', 1359 get_post_meta( $post->ID, '_wcbrr_interm_bank_city', true ), 1360 get_post_meta( $post->ID, '_wcbrr_interm_bank_state', true ), 1361 get_post_meta( $post->ID, '_wcbrr_interm_bank_zip_code', true ) 1362 ), 0, 32 ); 1363 1364 $row['46-interm-bank-country'] = get_post_meta( $post->ID, '_wcbrr_interm_bank_country_iso3166', true ); 1365 1366 $row['47-supl-id-type'] = 'ACCT'; 1367 $row['48-supl-id-value'] = get_post_meta( $post->ID, '_wcbrr_interm_bank_account', true ); 1368 } 1369 1370 // Use for debugging. 1371 // print_r( $row ); 1372 1373 fputcsv( $report, array_values( $row ) ); 1374 restore_current_blog(); 1375 } 1376 1377 // JPM Trailer 1378 fputcsv( $report, array( 'TRAILER', $count, $total ) ); 1379 1380 fclose( $report ); 1381 $results = ob_get_clean(); 1382 1383 // JPM chokes on accents and non-latin characters. 1384 $results = remove_accents( $results ); 1385 return $results; 1386 }
Note: See TracChangeset
for help on using the changeset viewer.