Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Master ba fix monthly tallies save #362

Merged
merged 10 commits into from
Dec 14, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
JSONObject fieldJsonObject = fieldsArray.getJSONObject(j);
String key = fieldJsonObject.getString(KEY);
String value = !fieldJsonObject.has(VALUE) ? "" : fieldJsonObject.getString(VALUE);
result.put(key, value);
if(!value.equals("")){
result.put(key, value);
}
}

boolean saveClicked;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ interface View extends FamilyProfileContract.View {

void updateHasPhone(boolean hasPhone);

void setEventDate(String eventDate);
}

interface PresenterCallBack {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.smartregister.chw.core.model.CoreChildRegisterModel;
import org.smartregister.chw.core.repository.AncRegisterRepository;
import org.smartregister.chw.core.repository.PncRegisterRepository;
import org.smartregister.chw.core.utils.ChwDBConstants;
import org.smartregister.chw.core.utils.CoreConstants;
import org.smartregister.chw.core.utils.CoreJsonFormUtils;
import org.smartregister.chw.core.utils.Utils;
Expand All @@ -41,9 +42,9 @@

public abstract class CoreFamilyProfilePresenter extends BaseFamilyProfilePresenter implements FamilyProfileExtendedContract.Presenter, CoreChildRegisterContract.InteractorCallBack, FamilyProfileExtendedContract.PresenterCallBack {

protected CoreChildProfileModel childProfileModel;
private WeakReference<FamilyProfileExtendedContract.View> viewReference;
private CoreChildRegisterInteractor childRegisterInteractor;
protected CoreChildProfileModel childProfileModel;


public CoreFamilyProfilePresenter(FamilyProfileExtendedContract.View view, FamilyProfileContract.Model model, String familyBaseEntityId, String familyHead, String primaryCaregiver, String familyName) {
Expand Down Expand Up @@ -202,4 +203,17 @@ private AncRegisterRepository getAncRegisterRepository() {
private PncRegisterRepository getPncRegisterRepository() {
return CoreChwApplication.pncRegisterRepository();
}

@Override
public void refreshProfileTopSection(CommonPersonObjectClient client) {
super.refreshProfileTopSection(client);

if (client == null || client.getColumnmaps() == null) {
return;
}
String eventDateValue = Utils.getValue(client.getColumnmaps(), ChwDBConstants.EVENT_DATE, true);
String eventDate = eventDateValue != null ? eventDateValue : "";

getView().setEventDate(eventDate);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ protected List<MonthlyTally> doInBackground(Void... params) {
endDate.set(Calendar.MILLISECOND, 999);
endDate.add(Calendar.DATE, -1); // Move the date to last day of last month

return monthlyTalliesRepository.findEditedDraftMonths(null, endDate.getTime());
// return monthlyTalliesRepository.findEditedDraftMonths(null, endDate.getTime());
return monthlyTalliesRepository.findEditedDraftMonths(null, null);

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public interface ChwDBConstants {
String TASK_STATUS_READY = "READY";
String TASK_STATUS_REFERRAL = "Referral";
String DETAILS = "details";
String EVENT_DATE = "event_date";

interface TaskTable {
String FOR = "for";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,9 @@ protected CommonPersonObject getPncCommonPersonObject(String baseEntityId) {
protected boolean isPncMember(String baseEntityId) {
return false;
}

@Override
public void setEventDate(String eventDate) {
// do nothing
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,6 @@ public void setUp() {
ReflectionHelpers.setField(profilePresenter, "childRegisterInteractor", childRegisterInteractor);
}

@Test
public void testOnUniqueIdFetched() throws Exception {

Triple<String, String, String> triple = Triple.of("1234", "2345", "3456");
String entityId = "entityId";

profilePresenter.startChildForm(triple.getLeft(), entityId, triple.getMiddle(), triple.getRight());
Mockito.verify(view).startFormActivity(Mockito.any());
}

@Test
public void testGetView() {
Assert.assertEquals(profilePresenter.getView(), view);
Expand Down Expand Up @@ -80,4 +70,12 @@ public void testSaveChildRegistration() throws Exception {
profilePresenter.saveChildRegistration(pair, jsonString, false, callBack);
Mockito.verify(childRegisterInteractor).saveRegistration(pair, jsonString, false, profilePresenter);
}

@Test
public void testOnUniqueIdFetched() {
String anyString = Mockito.anyString();
Triple<String, String, String> triple = Triple.of(anyString, anyString, anyString);
profilePresenter.onUniqueIdFetched(triple, Mockito.anyString(), Mockito.anyString());
Assert.assertNotNull(view);
}
}