@@ -4,7 +4,7 @@ import { parse } from "csv-parse/sync";
4
4
import fs from "fs" ;
5
5
import { DateTime } from "luxon" ;
6
6
import { execSync } from 'child_process' ;
7
- import { isEmpty } from 'lodash'
7
+ import isEmpty from 'lodash/isEmpty '
8
8
9
9
import { createInvoice } from "./createInvoice" ;
10
10
import { createPayment } from "./createPayment" ;
@@ -40,17 +40,19 @@ const orderWithEmail: Record<string, string> = parse(fs.readFileSync("input/even
40
40
const processedData : ProcessedData [ ] = ( orders as Order [ ] )
41
41
// filter subtotal 0 away
42
42
. filter ( o => Number ( o [ 'Subtotal' ] ) > 0 )
43
+ . filter ( o => o [ "Order #" ] === '#38704-3215128' )
43
44
// beautify data
44
45
. map ( item => {
45
46
const taxInfo = ordersWithTaxMap [ item [ "Order #" ] ]
47
+ console . log ( taxInfo )
46
48
47
49
return {
48
50
eventpopId : item [ 'Order #' ] ,
49
51
customer : {
50
- name : taxInfo ?. [ "Billing Name" ] ?? item [ "Buyer Name" ] ,
52
+ name : ! isEmpty ( taxInfo ?. [ "Billing Name" ] ) ? taxInfo ?. [ "Billing Name" ] : item [ "Buyer Name" ] ,
51
53
taxId : taxInfo ?. [ "Billing Tax ID" ] ?? null ,
52
54
address : taxInfo ?. [ "Billing Address" ] ?? null ,
53
- branch : taxInfo ?. [ "Billing Branch" ] ?? 'สำนักงานใหญ่ ' ,
55
+ branch : taxInfo ?. [ "Billing Branch" ] ?? '' ,
54
56
email : orderWithEmail [ item [ 'Order #' ] ]
55
57
} ,
56
58
ticket : {
@@ -78,20 +80,20 @@ fs.writeFileSync("output/processedData.json", JSON.stringify(processedData, null
78
80
// const pickedData = [processedData[0]]
79
81
// const pickedData = processedData
80
82
const pickedData = processedData
81
- . filter ( o =>
82
- [
83
- "#38704-3216014" , // credit, tax, withholding
84
- "#38704-3215164" , // bank, tax, withholding
85
- "#38704-3215100" , // credit, tax
86
- "#38704-3267295" , // bank, tax
87
- "#38704-3225968" , // credit
88
- "#38704-3215101" , // bank,
89
- "#38704-3288940" , // out of scope,
90
- "#38704-3251019" , // company
91
- "#38704-3215560" // company
92
-
93
- ] . includes ( o . eventpopId )
94
- )
83
+ // .filter(o =>
84
+ // [
85
+ // "#38704-3216014", // credit, tax, withholding
86
+ // "#38704-3215164", // bank, tax, withholding
87
+ // "#38704-3215100", // credit, tax
88
+ // "#38704-3267295", // bank, tax
89
+ // "#38704-3225968", // credit
90
+ // "#38704-3215101", // bank,
91
+ // "#38704-3288940", // out of scope,
92
+ // "#38704-3251019", // company
93
+ // "#38704-3215560" // company
94
+ //
95
+ // ].includes(o.eventpopId)
96
+ // )
95
97
96
98
; ( async ( ) => {
97
99
let index = 1
0 commit comments