From b067ee39a97598175f0f6a20b2b0aa0cac5029ed Mon Sep 17 00:00:00 2001 From: yixian Date: Tue, 21 Jul 2020 13:46:34 +1000 Subject: [PATCH] split companies in bttps file --- .../analysis/beans/ato/ATOCompanyConfig.java | 211 ++++++++++++++++++ .../analysis/beans/ato/AddressInfo.java | 12 +- .../analysis/beans/ato/ContactInfo.java | 4 +- .../beans/ato/ReportingPartyData.java | 22 +- .../core/ATOReportFinishedConsumer.java | 7 + .../analysis/core/ATOReportService.java | 2 +- .../core/impls/ATOReportServiceImpl.java | 98 +++++--- .../mappers/payment/TransactionMapper.java | 2 +- .../manage/mappers/system/ClientMapper.java | 2 +- .../merchants/beans/ClientRateConfig.java | 8 + src/main/resources/application-common.yml | 35 +++ .../mappers/payment/TransactionMapper.xml | 19 +- .../manage/mappers/system/ClientMapper.xml | 6 +- .../manage/process/ato/ExportATOReport.java | 4 +- 14 files changed, 365 insertions(+), 67 deletions(-) create mode 100644 src/main/java/au/com/royalpay/payment/manage/analysis/beans/ato/ATOCompanyConfig.java create mode 100644 src/main/java/au/com/royalpay/payment/manage/analysis/core/ATOReportFinishedConsumer.java diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/beans/ato/ATOCompanyConfig.java b/src/main/java/au/com/royalpay/payment/manage/analysis/beans/ato/ATOCompanyConfig.java new file mode 100644 index 000000000..b539806e0 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/beans/ato/ATOCompanyConfig.java @@ -0,0 +1,211 @@ +package au.com.royalpay.payment.manage.analysis.beans.ato; + +import au.com.royalpay.payment.tools.merchants.beans.BalanceGroup; +import org.joda.time.DateTime; +import org.springframework.boot.context.properties.ConfigurationProperties; + +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +@ConfigurationProperties(prefix = "app.atoreport") +public class ATOCompanyConfig { + private List companies; + + public List getCompanies() { + return companies; + } + + public ATOCompanyConfig setCompanies(List companies) { + this.companies = companies; + return this; + } + + public static class ATOCompany { + private String[] balanceGroups; + private String brand; + private String referencePrefix; + private String company; + private String abn; + private Contact contact; + private Addr address; + + public String reference() { + return referencePrefix + DateTime.now().toString("yyyyMMddHHmm"); + } + + public List balanceGroups() { + return Arrays.stream(balanceGroups).map(BalanceGroup::valueOf).collect(Collectors.toList()); + } + + public String getReferencePrefix() { + return referencePrefix; + } + + public ATOCompany setReferencePrefix(String referencePrefix) { + this.referencePrefix = referencePrefix; + return this; + } + + public String[] getBalanceGroups() { + return balanceGroups; + } + + public ATOCompany setBalanceGroups(String[] balanceGroups) { + this.balanceGroups = balanceGroups; + return this; + } + + public String getBrand() { + return brand; + } + + public ATOCompany setBrand(String brand) { + this.brand = brand; + return this; + } + + public String getAbn() { + return abn; + } + + public ATOCompany setAbn(String abn) { + this.abn = abn; + return this; + } + + public Contact getContact() { + return contact; + } + + public ContactInfo getContactInfo() { + return contact.convert(); + } + + public ATOCompany setContact(Contact contact) { + this.contact = contact; + return this; + } + + public Addr getAddress() { + return address; + } + + public ATOCompany setAddress(Addr address) { + this.address = address; + return this; + } + + public AddressInfo getAddressInfo() { + return address.convert(); + } + + public String getShortCompanyName() { + return company.replace(" PTY LTD", ""); + } + + public String getCompany() { + return company; + } + + public ATOCompany setCompany(String company) { + this.company = company; + return this; + } + } + + public static class Contact { + private String name; + private String phone; + private String email; + + public ContactInfo convert() { + return new ContactInfo(name, phone, email); + } + + public String getName() { + return name; + } + + public Contact setName(String name) { + this.name = name; + return this; + } + + + public String getPhone() { + return phone; + } + + public Contact setPhone(String phone) { + this.phone = phone; + return this; + } + + public String getEmail() { + return email; + } + + public Contact setEmail(String email) { + this.email = email; + return this; + } + } + + public static class Addr { + private String address; + private String suburb; + private String state; + private String postcode; + private String country; + + public AddressInfo convert() { + return new AddressInfo(address, suburb, state, postcode, country); + } + + public String getAddress() { + return address; + } + + public Addr setAddress(String address) { + this.address = address; + return this; + } + + public String getSuburb() { + return suburb; + } + + public Addr setSuburb(String suburb) { + this.suburb = suburb; + return this; + } + + public String getState() { + return state; + } + + public Addr setState(String state) { + this.state = state; + return this; + } + + public String getPostcode() { + return postcode; + } + + public Addr setPostcode(String postcode) { + this.postcode = postcode; + return this; + } + + public String getCountry() { + return country; + } + + public Addr setCountry(String country) { + this.country = country; + return this; + } + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/beans/ato/AddressInfo.java b/src/main/java/au/com/royalpay/payment/manage/analysis/beans/ato/AddressInfo.java index 0c79f941e..e816d5956 100644 --- a/src/main/java/au/com/royalpay/payment/manage/analysis/beans/ato/AddressInfo.java +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/beans/ato/AddressInfo.java @@ -4,11 +4,11 @@ package au.com.royalpay.payment.manage.analysis.beans.ato; * Create by yixian at 2018-08-30 21:17 */ public class AddressInfo { - private String address; - private String suburb; - private String state; - private String postCode; - private String country; + private final String address; + private final String suburb; + private final String state; + private final String postCode; + private final String country; public AddressInfo(String address, String suburb, String state, String postCode, String country) { this.address = address; @@ -27,6 +27,8 @@ public class AddressInfo { this.postCode = postCode; if (state != null) { this.state = state.toUpperCase(); + } else { + this.state = null; } this.country = country; } diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/beans/ato/ContactInfo.java b/src/main/java/au/com/royalpay/payment/manage/analysis/beans/ato/ContactInfo.java index bf2cbadf1..8a9a1918b 100644 --- a/src/main/java/au/com/royalpay/payment/manage/analysis/beans/ato/ContactInfo.java +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/beans/ato/ContactInfo.java @@ -6,10 +6,10 @@ import org.hibernate.validator.internal.constraintvalidators.hv.EmailValidator; * Create by yixian at 2018-08-30 21:19 */ public class ContactInfo { - private String contactName; + private final String contactName; private int phoneAreaCode; private String phoneNumber; - private String email; + private final String email; public ContactInfo(String contactName, String phoneNumber, String email) { this.contactName = contactName; diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/beans/ato/ReportingPartyData.java b/src/main/java/au/com/royalpay/payment/manage/analysis/beans/ato/ReportingPartyData.java index 751a88efe..588fc6bb9 100644 --- a/src/main/java/au/com/royalpay/payment/manage/analysis/beans/ato/ReportingPartyData.java +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/beans/ato/ReportingPartyData.java @@ -2,26 +2,28 @@ package au.com.royalpay.payment.manage.analysis.beans.ato; import org.apache.commons.lang3.time.DateUtils; -import java.util.*; +import java.util.Calendar; +import java.util.Date; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; /** * Create by yixian at 2018-08-30 21:13 */ public class ReportingPartyData implements ATOBulkLine { - private final String identifier = "RPDR"; - private Date periodStart; - private Date periodEnd; - private String abn; - private String branchNumber; - private String registerName; + private static final String IDENTIFIER = "RPDR"; + private final Date periodStart; + private final Date periodEnd; + private final String abn; + private final String branchNumber; + private final String registerName; private String tradingName; private AddressInfo address; private AddressInfo postalAddress; private ContactInfo contactInfo; - private String softwareProductType; + private final String softwareProductType; - private Map businesses = new ConcurrentHashMap<>(); + private final Map businesses = new ConcurrentHashMap<>(); public ReportingPartyData(Date periodStart, Date periodEnd, String abn, String branchNumber, String registerName, String softwareProductType) { this.periodStart = DateUtils.truncate(periodStart, Calendar.DATE); @@ -56,7 +58,7 @@ public class ReportingPartyData implements ATOBulkLine { public StringBuilder buildLine(StringBuilder builder) { StringBuilder line = new StringBuilder(); appendNParam(line, 1400, 4); - appendAParam(line, identifier, 4); + appendAParam(line, IDENTIFIER, 4); appendDParam(line, periodStart, 8); appendDParam(line, periodEnd, 8); appendNParam(line, abn, 11); diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/core/ATOReportFinishedConsumer.java b/src/main/java/au/com/royalpay/payment/manage/analysis/core/ATOReportFinishedConsumer.java new file mode 100644 index 000000000..8129587c3 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/core/ATOReportFinishedConsumer.java @@ -0,0 +1,7 @@ +package au.com.royalpay.payment.manage.analysis.core; + +import java.io.IOException; + +public interface ATOReportFinishedConsumer { + void accept(String brand, String content) throws IOException; +} diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/core/ATOReportService.java b/src/main/java/au/com/royalpay/payment/manage/analysis/core/ATOReportService.java index bfa668ac7..bf1d5f092 100644 --- a/src/main/java/au/com/royalpay/payment/manage/analysis/core/ATOReportService.java +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/core/ATOReportService.java @@ -11,7 +11,7 @@ import java.util.Date; */ public interface ATOReportService { - String exportBTTPSFile(Date from, Date to); + void exportBTTPSFile(Date from, Date to, ATOReportFinishedConsumer resultConsumer); void startExportTask(Date from, Date to); diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/ATOReportServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/ATOReportServiceImpl.java index 935c9f898..11bcf38c6 100644 --- a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/ATOReportServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/ATOReportServiceImpl.java @@ -1,6 +1,8 @@ package au.com.royalpay.payment.manage.analysis.core.impls; +import au.com.royalpay.payment.core.PaymentApi; import au.com.royalpay.payment.manage.analysis.beans.ato.*; +import au.com.royalpay.payment.manage.analysis.core.ATOReportFinishedConsumer; import au.com.royalpay.payment.manage.analysis.core.ATOReportService; import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper; import au.com.royalpay.payment.manage.mappers.system.ClientMapper; @@ -14,11 +16,11 @@ import org.apache.commons.codec.Charsets; import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.IOUtils; -import org.apache.commons.lang3.time.DateFormatUtils; import org.joda.time.DateTime; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.http.ContentDisposition; import org.springframework.http.HttpHeaders; @@ -36,17 +38,22 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import java.util.stream.Collectors; /** * Create by yixian at 2018-08-31 1:23 */ @Service +@EnableConfigurationProperties(ATOCompanyConfig.class) public class ATOReportServiceImpl implements ATOReportService { private Logger logger = LoggerFactory.getLogger(getClass()); @Resource private TransactionMapper transactionMapper; @Resource private ClientMapper clientMapper; + @Resource + private PaymentApi paymentApi; + private final ATOCompanyConfig atoCompanies; @Value("classpath:data/category/billbuddyindustry.json") private org.springframework.core.io.Resource industryResource; private Map industryMap; @@ -54,9 +61,10 @@ public class ATOReportServiceImpl implements ATOReportService { private final String prefix; private Progress progress; - public ATOReportServiceImpl(StringRedisTemplate redisTemplate, @Value("${app.redis.prefix}") String prefix) { + public ATOReportServiceImpl(StringRedisTemplate redisTemplate, @Value("${app.redis.prefix}") String prefix, ATOCompanyConfig atoCompanies) { this.redisTemplate = redisTemplate; this.prefix = prefix; + this.atoCompanies = atoCompanies; } @PostConstruct @@ -87,22 +95,27 @@ public class ATOReportServiceImpl implements ATOReportService { } @Override - public String exportBTTPSFile(Date from, Date to) { - String reference = "RPAY" + DateFormatUtils.format(new Date(), "yyyyMMddHHmm"); - String abn = "16601619685"; - String registerCompanyName = "Tunnel Show Pty Ltd"; - AddressInfo companyAddr = new AddressInfo("Level 11, 15 William St", "Melbourne", "VIC", "3000", "AUS"); - ContactInfo companyContact = new ContactInfo("Locky", "+61394488865", "info@royalpay.com.au"); - ATOBulkData.IntermediaryData intermediary = new ATOBulkData.IntermediaryData(abn, registerCompanyName, reference) - .setAddress(companyAddr) - .setContactInfo(companyContact); + public void exportBTTPSFile(Date from, Date to, ATOReportFinishedConsumer resultConsumer) { + atoCompanies.getCompanies().forEach(company -> exportBTTPS(company, from, to, resultConsumer)); + + } + + private void exportBTTPS(ATOCompanyConfig.ATOCompany company, Date from, Date to, ATOReportFinishedConsumer resultConsumer) { + if (progress != null) { + progress.setStatus("Init task"); + progress.setBrand(company.getBrand()); + synchronizeProgress(); + } + ATOBulkData.IntermediaryData intermediary = new ATOBulkData.IntermediaryData(company.getAbn(), company.getCompany(), company.reference()) + .setAddress(company.getAddressInfo()) + .setContactInfo(company.getContactInfo()); ATOBulkData data = new ATOBulkData(intermediary); - ReportingPartyData reportingParty = new ReportingPartyData(from, to, abn, "001", registerCompanyName, "INHOUSE Tunnel Show") - .setAddress(companyAddr) - .setPostalAddress(companyAddr) - .setContactInfo(companyContact) - .setTradingName("RoyalPay"); + ReportingPartyData reportingParty = new ReportingPartyData(from, to, company.getAbn(), "001", company.getCompany(), "INHOUSE " + company.getShortCompanyName()) + .setAddress(company.getAddressInfo()) + .setPostalAddress(company.getAddressInfo()) + .setContactInfo(company.getContactInfo()) + .setTradingName(company.getBrand()); intermediary.addReportingParty(reportingParty); DateTime fromDateTime = new DateTime(from).withTimeAtStartOfDay(); @@ -111,15 +124,19 @@ public class ATOReportServiceImpl implements ATOReportService { DateTime endOfMon = new DateTime(fromDateTime.plusMonths(1).withDayOfMonth(1)); while (endOfMon.isBefore(toDateTime)) { logger.debug("Exporting date range:{} ~ {}", startOfMon.toString("yyyy-MM-dd"), endOfMon.toString("yyyy-MM-dd")); - loadMonthTransactions(reportingParty, startOfMon, endOfMon); + loadMonthTransactions(company, reportingParty, startOfMon, endOfMon); startOfMon = new DateTime(endOfMon); endOfMon = new DateTime(endOfMon.plusMonths(1)); } endOfMon = new DateTime(toDateTime); logger.debug("Exporting date range:{} ~ {}", startOfMon.toString("yyyy-MM-dd"), endOfMon.toString("yyyy-MM-dd")); - loadMonthTransactions(reportingParty, startOfMon, endOfMon); + loadMonthTransactions(company, reportingParty, startOfMon, endOfMon); logger.info("output BTTPS file"); - return data.outputBTTPS(); + try { + resultConsumer.accept(company.getBrand(), data.outputBTTPS()); + } catch (IOException e) { + throw new ServerErrorException("Failed to export bttps file", e); + } } private String progressKey() { @@ -142,16 +159,18 @@ public class ATOReportServiceImpl implements ATOReportService { progress = new Progress(); synchronizeProgress(); try { - String content = exportBTTPSFile(from, to); - byte[] contentBytes = content.getBytes(StandardCharsets.UTF_8); - progress.setStatus("Uploading,filesize:" + contentBytes.length); - String filename = "royalpay_ato_report_" + new DateTime(from).toString("yyyyMMdd") + "_to_" + new DateTime(to).toString("yyyyMMdd") + ".bttps"; - File saveFile = new File("/var/log/payment/" + filename); - FileUtils.writeByteArrayToFile(saveFile, contentBytes); - String path = saveFile.getAbsolutePath(); - logger.info("uploaded ATO report to {}", path); - progress.setFileid(path); - redisTemplate.boundValueOps(reportFileKey()).set(path, Duration.ofDays(1)); + exportBTTPSFile(from, to, (brand, content) -> { + byte[] contentBytes = content.getBytes(StandardCharsets.UTF_8); + progress.setStatus(brand + " Uploading,filesize:" + contentBytes.length); + String filename = brand + "_ato_report_" + new DateTime(from).toString("yyyyMMdd") + "_to_" + new DateTime(to).toString("yyyyMMdd") + ".bttps"; + File saveFile = new File("/var/log/payment/" + filename); + FileUtils.writeByteArrayToFile(saveFile, contentBytes); + String path = saveFile.getAbsolutePath(); + logger.info("uploaded ATO report to {}", path); + progress.setFileid(path); + redisTemplate.boundValueOps(reportFileKey()).set(path, Duration.ofDays(1)); + }); + } catch (Exception e) { progress.setStatus(e.getMessage()); logger.error("output bttps file failed", e); @@ -198,16 +217,17 @@ public class ATOReportServiceImpl implements ATOReportService { } } - private void loadMonthTransactions(ReportingPartyData reportingParty, DateTime startOfMon, DateTime endOfMon) { - List clients = clientMapper.listClientsWithTransactionsSettled(startOfMon.toDate(), endOfMon.toDate()); + private void loadMonthTransactions(ATOCompanyConfig.ATOCompany company, ReportingPartyData reportingParty, DateTime startOfMon, DateTime endOfMon) { + List channels = company.balanceGroups().stream().flatMap(group -> paymentApi.channelsInGroup(group).stream()).distinct().collect(Collectors.toList()); + List clients = clientMapper.listClientsWithTransactionsSettled(channels, startOfMon.toDate(), endOfMon.toDate()); if (progress != null) { progress.setMonth(startOfMon, clients); synchronizeProgress(); } - clients.parallelStream().forEach(clientId -> loadClientMonthTransactions(reportingParty, clientId, startOfMon, endOfMon)); + clients.parallelStream().forEach(clientId -> loadClientMonthTransactions(channels, reportingParty, clientId, startOfMon, endOfMon)); } - private void loadClientMonthTransactions(ReportingPartyData reportingParty, Integer clientId, DateTime startOfMon, DateTime endOfMon) { + private void loadClientMonthTransactions(List channels, ReportingPartyData reportingParty, Integer clientId, DateTime startOfMon, DateTime endOfMon) { BusinessData biz = reportingParty.findBusiness(clientId); logger.debug("Exporting date range for client[{}]:{} ~ {}", clientId, startOfMon.toString("yyyy-MM-dd"), endOfMon.toString("yyyy-MM-dd")); if (biz == null) { @@ -224,7 +244,7 @@ public class ATOReportServiceImpl implements ATOReportService { .setContactInfo(contact); reportingParty.addBusiness(clientId, biz); } - List analysisList = transactionMapper.analysisForATOReport(clientId, startOfMon.toDate(), endOfMon.toDate()); + List analysisList = transactionMapper.analysisForATOReport(clientId, channels, startOfMon.toDate(), endOfMon.toDate()); for (JSONObject analysis : analysisList) { biz.addTransaction(new TransactionSummaryData(analysis, startOfMon, endOfMon)); } @@ -240,6 +260,7 @@ public class ATOReportServiceImpl implements ATOReportService { public static class Progress { private static final Logger logger = LoggerFactory.getLogger(ATOReportService.class); + private String brand; private String currentMonth; private Map clientsStatus; private final String server; @@ -253,6 +274,15 @@ public class ATOReportServiceImpl implements ATOReportService { server = PlatformEnvironment.getEnv().appName(); } + public String getBrand() { + return brand; + } + + public Progress setBrand(String brand) { + this.brand = brand; + return this; + } + public void setMonth(DateTime start, List clients) { currentMonth = start.toString("yyyy-MM"); clientsStatus = clients.stream().collect(ConcurrentHashMap::new, (map, cid) -> map.put(cid, false), Map::putAll); diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.java index a722db989..682fc0ccb 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.java @@ -130,7 +130,7 @@ public interface TransactionMapper { List getHfClearAmount(JSONObject params); - List analysisForATOReport(@Param("clientId") int clientId, @Param("from") Date startOfMon, @Param("to") Date endOfMon); + List analysisForATOReport(@Param("clientId") int clientId, @Param("channels") List channels, @Param("from") Date startOfMon, @Param("to") Date endOfMon); /** * 付款退款都是同一个退款单号 diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientMapper.java index 3f640b5c1..dda97f360 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientMapper.java @@ -116,7 +116,7 @@ public interface ClientMapper { List listBySubMerchantId(@Param("sub_merchant_id") String sub_merchant_id); - List listClientsWithTransactionsSettled(@Param("from") Date fromDate, @Param("to") Date toDate); + List listClientsWithTransactionsSettled(@Param("channels") List channels, @Param("from") Date fromDate, @Param("to") Date toDate); @AutoSql(SqlType.SELECT) List AllClients(); diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/beans/ClientRateConfig.java b/src/main/java/au/com/royalpay/payment/manage/merchants/beans/ClientRateConfig.java index d3b6f8a97..b927fbb89 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/beans/ClientRateConfig.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/beans/ClientRateConfig.java @@ -58,6 +58,10 @@ public class ClientRateConfig { this.rateValue = rateValue; } + public void setRateValue(double rateValue) { + this.rateValue = BigDecimal.valueOf(rateValue); + } + public void setActiveTime(Date activeTime) { this.activeTime = activeTime; } @@ -106,6 +110,10 @@ public class ClientRateConfig { this.transactionFee = transactionFee; } + public void setTransactionFee(double transactionFee) { + this.transactionFee = BigDecimal.valueOf(transactionFee); + } + public String getExtRates() { return extRates; } diff --git a/src/main/resources/application-common.yml b/src/main/resources/application-common.yml index 3b874c8e4..67381a520 100644 --- a/src/main/resources/application-common.yml +++ b/src/main/resources/application-common.yml @@ -28,6 +28,41 @@ app: enable: true tax: type: GST + atoreport: + companies: + - brand: RoyalPay + reference-prefix: RPAY + abn: 16601619685 + company: TUNNEL SHOW PTY LTD + balance-groups: + - NORMAL_CROSS_BORDER + contact: + name: Locky + phone: +61394488865 + email: info@royalpay.com.au + address: + address: Level 11, 15 William St + suburb: Melbourne + state: VIC + postcode: 3000 + country: AUS + - brand: UPay + reference-prefix: UPAY + abn: 62627588514 + company: UPAY PTY LTD + balance-groups: + - RPAY_SVC_CARD + - RPAY_SVC_DIRECTDEBIT + contact: + name: Locky + phone: +61394488865 + email: info@royalpay.com.au + address: + address: Level 11, 15 William St + suburb: Melbourne + state: VIC + postcode: 3000 + country: AUS logging: level: au: diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml index 1398b5a10..3da8d6bf8 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml @@ -1294,17 +1294,18 @@ sum(if(transaction_type = 'Debit', t.clearing_amount, 0)) total_refund, sum(if(transaction_type = 'Debit', 1, 0)) refund_count, min(t.transaction_time) period_start, - max(t.transaction_time) period_end, - cd.bsb_no, - cd.account_no, - cd.account_name + max(t.transaction_time) period_end, + cd.bsb_no, + cd.account_no, + cd.account_name from pmt_transactions t - inner join log_clearing_detail cd on cd.clear_detail_id = t.clearing_order + inner join log_clearing_detail cd on cd.clear_detail_id = t.clearing_order where t.client_id = #{clientId} - and t.system_generate = 0 - and t.clearing_status = 1 - and t.transaction_time between #{from} and #{to} - and t.channel != 'Settlement' + and t.system_generate = 0 + and t.clearing_status = 1 + and t.transaction_time between #{from} and #{to} + and t.channel in + #{channel} group by cd.bsb_no, cd.account_no order by period_start diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml index 67b6fe8f3..4492a60df 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientMapper.xml @@ -662,8 +662,10 @@ select distinct t.client_id from pmt_transactions t where t.clearing_status = 1 - and t.system_generate = 0 - and t.transaction_time between #{from} and #{to} + and t.system_generate = 0 + and t.transaction_time between #{from} and #{to} + and t.channel in + #{channel}