@@ -4,7 +4,7 @@ import { parse } from "csv-parse/sync";
44import fs from "fs" ;
55import { DateTime } from "luxon" ;
66import { execSync } from 'child_process' ;
7- import { isEmpty } from 'lodash'
7+ import isEmpty from 'lodash/isEmpty '
88
99import { createInvoice } from "./createInvoice" ;
1010import { createPayment } from "./createPayment" ;
@@ -40,17 +40,19 @@ const orderWithEmail: Record<string, string> = parse(fs.readFileSync("input/even
4040const processedData : ProcessedData [ ] = ( orders as Order [ ] )
4141 // filter subtotal 0 away
4242 . filter ( o => Number ( o [ 'Subtotal' ] ) > 0 )
43+ . filter ( o => o [ "Order #" ] === '#38704-3215128' )
4344 // beautify data
4445 . map ( item => {
4546 const taxInfo = ordersWithTaxMap [ item [ "Order #" ] ]
47+ console . log ( taxInfo )
4648
4749 return {
4850 eventpopId : item [ 'Order #' ] ,
4951 customer : {
50- name : taxInfo ?. [ "Billing Name" ] ?? item [ "Buyer Name" ] ,
52+ name : ! isEmpty ( taxInfo ?. [ "Billing Name" ] ) ? taxInfo ?. [ "Billing Name" ] : item [ "Buyer Name" ] ,
5153 taxId : taxInfo ?. [ "Billing Tax ID" ] ?? null ,
5254 address : taxInfo ?. [ "Billing Address" ] ?? null ,
53- branch : taxInfo ?. [ "Billing Branch" ] ?? 'สำนักงานใหญ่ ' ,
55+ branch : taxInfo ?. [ "Billing Branch" ] ?? '' ,
5456 email : orderWithEmail [ item [ 'Order #' ] ]
5557 } ,
5658 ticket : {
@@ -78,20 +80,20 @@ fs.writeFileSync("output/processedData.json", JSON.stringify(processedData, null
7880// const pickedData = [processedData[0]]
7981// const pickedData = processedData
8082const 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+ // )
9597
9698; ( async ( ) => {
9799 let index = 1
0 commit comments