Commit 903a9c68 authored by neo's avatar neo

[DEV] fixed upate taxpay rule settint

parent 5da74e7d
......@@ -2402,7 +2402,14 @@ public class OrganizationServiceImpl {
newRule.setTaxPayerType(newTaxPayerType); // Use tax payer type related to template group
newRule.setCreateTime(now);
newRule.setUpdateTime(now);
taxPayerReportRuleMapper.insertSelective(newRule);
TaxPayerReportRuleExample exam = new TaxPayerReportRuleExample();
exam.createCriteria().andOrganizationIdEqualTo(orgDto.getId()).andTemplateGroupIdEqualTo(vatSetting.getTemplateGroupId());
List<TaxPayerReportRule> rules = taxPayerReportRuleMapper.selectByExample(exam);
if (!rules.isEmpty()) {
newRule.setId(rules.get(0).getId());
taxPayerReportRuleMapper.updateByPrimaryKeySelective(newRule);
} else
taxPayerReportRuleMapper.insertSelective(newRule);
} else {
activeRule.setTemplateGroupId(vatSetting.getTemplateGroupId());
activeRule.setTaxPayerType(newTaxPayerType);
......@@ -2417,7 +2424,15 @@ public class OrganizationServiceImpl {
newRule.setTaxPayerType(newTaxPayerType); // Use tax payer type related to template group
newRule.setCreateTime(now);
newRule.setUpdateTime(now);
taxPayerReportRuleMapper.insertSelective(newRule);
TaxPayerReportRuleExample exam = new TaxPayerReportRuleExample();
exam.createCriteria().andOrganizationIdEqualTo(orgDto.getId()).andTemplateGroupIdEqualTo(vatSetting.getTemplateGroupId());
List<TaxPayerReportRule> rules = taxPayerReportRuleMapper.selectByExample(exam);
if (!rules.isEmpty()) {
newRule.setId(rules.get(0).getId());
taxPayerReportRuleMapper.updateByPrimaryKeySelective(newRule);
} else
taxPayerReportRuleMapper.insertSelective(newRule);
}
} else if (activeRule != null) { // If no setting, remove non-default rule
taxPayerReportRuleMapper.deleteByPrimaryKey(activeRule.getId());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment