Skip to content

Commit e6466d6

Browse files
Version 11.5.5
1 parent 32546ad commit e6466d6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+45984
-43664
lines changed

Src/Android/StyloQ/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ android {
2323
applicationId "ru.petroglif.styloq"
2424
minSdkVersion 28
2525
targetSdkVersion 30
26-
versionCode 43
27-
versionName '0.3.3'
26+
versionCode 45
27+
versionName '0.3.5'
2828
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2929
signingConfig signingConfigs.release
3030
}

Src/Android/StyloQ/app/src/main/java/ru/petroglif/styloq/BusinessEntity.java

Lines changed: 104 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,20 @@ public static class DebtEntry {
434434
Amount = 0.0;
435435
Debt = 0.0;
436436
}
437+
public static DebtEntry Copy(final DebtEntry s)
438+
{
439+
DebtEntry result = null;
440+
if(s != null) {
441+
result = new DebtEntry();
442+
result.BillID = s.BillID;
443+
result.BillDate = SLib.LDATE.Copy(s.BillDate);
444+
result.BillCode = SLib.Copy(s.BillCode);
445+
result.AgentID = s.AgentID;
446+
result.Amount = s.Amount;
447+
result.Debt = s.Debt;
448+
}
449+
return result;
450+
}
437451
public boolean FromJson(JSONObject jsObj)
438452
{
439453
boolean ok = false;
@@ -499,14 +513,39 @@ public static class ArDebtList {
499513
Debt = 0.0;
500514
List = null;
501515
}
516+
public static ArDebtList Copy(final ArDebtList s)
517+
{
518+
ArDebtList result = null;
519+
if(s != null) {
520+
result = new ArDebtList();
521+
result.ArID = s.ArID;
522+
result.ArName = SLib.Copy(s.ArName);
523+
result.SvcTime = SLib.LDATETIME.Copy(s.SvcTime);
524+
result.CliTime = SLib.LDATETIME.Copy(s.CliTime);
525+
result.Debt = s.Debt;
526+
if(s.List != null) {
527+
result.List = new ArrayList<DebtEntry>();
528+
for(DebtEntry iter : s.List)
529+
result.List.add(DebtEntry.Copy(iter));
530+
}
531+
}
532+
return result;
533+
}
502534
public boolean FromJson(JSONObject jsObj)
503535
{
504536
boolean ok = false;
505537
int items_count = 0;
506538
if(jsObj != null) {
507539
{
508540
String time_text = jsObj.optString("time", null);
509-
// SvcTime
541+
SvcTime = SLib.strtodatetime(time_text, SLib.DATF_ISO8601|SLib.DATF_CENTURY, 0);
542+
}
543+
{
544+
String time_text = jsObj.optString("clitime", null);
545+
if(SLib.GetLen(time_text) > 0)
546+
CliTime = SLib.strtodatetime(time_text, SLib.DATF_ISO8601|SLib.DATF_CENTURY, 0);
547+
if(CliTime == null)
548+
CliTime = new SLib.LDATETIME(System.currentTimeMillis());
510549
}
511550
ArID = jsObj.optInt("arid", 0);
512551
ArName = jsObj.optString("arname", null);
@@ -588,11 +627,36 @@ public static class ShortReplyEntry {
588627
{
589628
ArID = 0;
590629
Debt = 0.0;
591-
IsExpired = false;
630+
Timestamp = null;
631+
}
632+
public boolean IsExpired(final StyloQCommand.Item cmdQueryDebt)
633+
{
634+
boolean result = false;
635+
final int expiry_time_sec = (cmdQueryDebt != null && cmdQueryDebt.BaseCmdId == StyloQCommand.sqbcDebtList && cmdQueryDebt.ResultExpiryTimeSec > 0) ?
636+
cmdQueryDebt.ResultExpiryTimeSec : (3600 * 24);
637+
if(Timestamp != null) {
638+
SLib.LDATETIME expiry_time = SLib.plusdatetimesec(Timestamp, expiry_time_sec);
639+
if(expiry_time != null && SLib.Cmp(expiry_time, new SLib.LDATETIME(System.currentTimeMillis())) < 0)
640+
result = true;
641+
}
642+
return result;
592643
}
593644
int ArID;
594645
double Debt;
595-
boolean IsExpired;
646+
SLib.LDATETIME Timestamp;
647+
}
648+
public static DebtList Copy(final DebtList s)
649+
{
650+
DebtList result = null;
651+
if(s != null) {
652+
result = new DebtList();
653+
if(s.List != null) {
654+
result.List = new ArrayList<ArDebtList>();
655+
for(ArDebtList iter : s.List)
656+
result.List.add(ArDebtList.Copy(iter));
657+
}
658+
}
659+
return result;
596660
}
597661
DebtList()
598662
{
@@ -609,12 +673,48 @@ ShortReplyEntry GetDebt(int arID)
609673
result = new ShortReplyEntry();
610674
result.ArID = entry.ArID;
611675
result.Debt = entry.Debt;
612-
result.IsExpired = false; // @todo
676+
result.Timestamp = (entry.CliTime != null) ? entry.CliTime : entry.SvcTime;
613677
}
614678
}
615679
}
616680
return result;
617681
}
682+
ArDebtList GetDebtDetail(int arID)
683+
{
684+
ArDebtList result = null;
685+
if(arID > 0) {
686+
final int _c = SLib.GetCount(List);
687+
for(int i = 0; result == null && i < _c; i++) {
688+
ArDebtList entry = List.get(i);
689+
if(entry != null && entry.ArID == arID)
690+
result = entry;
691+
}
692+
}
693+
return result;
694+
}
695+
int Include(ArDebtList newEntry)
696+
{
697+
int result_idx = -1;
698+
if(newEntry != null && newEntry.ArID > 0) {
699+
if(List != null) {
700+
int i = List.size();
701+
if(i > 0) do {
702+
i--;
703+
ArDebtList entry = List.get(i);
704+
if(entry == null || entry.ArID <= 0 || entry.ArID == newEntry.ArID) {
705+
List.remove(i);
706+
}
707+
} while(i > 0);
708+
}
709+
else
710+
List = new ArrayList<ArDebtList>();
711+
if(List.add(newEntry)) {
712+
assert(List.size() > 0);
713+
result_idx = List.size()-1;
714+
}
715+
}
716+
return result_idx;
717+
}
618718
boolean FromJson(JSONObject jsObj)
619719
{
620720
boolean ok = false;

Src/Android/StyloQ/app/src/main/java/ru/petroglif/styloq/CmdRAttendancePrereqActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ private void MakeSimpleSearchIndex()
751751
int id = entry.JsItem.optInt("id", 0);
752752
if(id > 0) {
753753
String nm = entry.JsItem.optString("nm");
754-
CPM.AddSimpleIndexEntry(SLib.PPOBJ_PROCESSOR, id, SLib.PPOBJATTR_NAME, nm, null);
754+
CPM.AddSimpleIndexEntry(SLib.PPOBJ_PROCESSOR, id, SLib.PPOBJATTR_NAME, nm, nm);
755755
}
756756
}
757757
}

Src/Android/StyloQ/app/src/main/java/ru/petroglif/styloq/CmdROrderPrereqActivity.java

Lines changed: 145 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,97 @@ Object GetDTS()
338338
return result;
339339
}
340340
}
341+
static class DebtDetailDialog extends SLib.SlDialog {
342+
CmdROrderPrereqActivity ActivityCtx;
343+
public DebtDetailDialog(Context ctx, Object data)
344+
{
345+
super(ctx, R.id.DLG_DEBTDETAILLIST, data);
346+
if(ctx instanceof CmdROrderPrereqActivity)
347+
ActivityCtx = (CmdROrderPrereqActivity)ctx;
348+
if(data instanceof BusinessEntity.ArDebtList)
349+
Data = data;
350+
}
351+
@Override public Object HandleEvent(int ev, Object srcObj, Object subj)
352+
{
353+
Object result = null;
354+
switch(ev) {
355+
case SLib.EV_CREATE:
356+
requestWindowFeature(Window.FEATURE_NO_TITLE);
357+
setContentView(R.layout.dialog_debtdetaillist);
358+
SetDTS(Data);
359+
break;
360+
case SLib.EV_COMMAND:
361+
if(srcObj != null && srcObj instanceof View) {
362+
final int view_id = ((View) srcObj).getId();
363+
if(view_id == R.id.STDCTL_CLOSEBUTTON) {
364+
this.dismiss();
365+
}
366+
}
367+
break;
368+
case SLib.EV_LISTVIEWCOUNT:
369+
{
370+
SLib.RecyclerListAdapter a = (SLib.RecyclerListAdapter)srcObj;
371+
if(a.GetListRcId() == R.id.CTL_DEBTDETAILLIST_LIST) {
372+
BusinessEntity.ArDebtList _data = (Data != null && Data instanceof BusinessEntity.ArDebtList) ? (BusinessEntity.ArDebtList)Data : null;
373+
result = new Integer((_data != null && _data.List != null) ? _data.List.size() : 0);
374+
}
375+
}
376+
break;
377+
case SLib.EV_GETLISTITEMVIEW:
378+
{
379+
SLib.ListViewEvent ev_subj = (subj instanceof SLib.ListViewEvent) ? (SLib.ListViewEvent) subj : null;
380+
if(ev_subj != null && ev_subj.ItemIdx >= 0) {
381+
if(ev_subj.RvHolder != null) {
382+
// RecyclerView
383+
if(SLib.IsRecyclerListAdapter(srcObj)) {
384+
SLib.RecyclerListAdapter a = (SLib.RecyclerListAdapter)srcObj;
385+
if(a.GetListRcId() == R.id.CTL_DEBTDETAILLIST_LIST) {
386+
BusinessEntity.ArDebtList _data = (Data != null && Data instanceof BusinessEntity.ArDebtList) ? (BusinessEntity.ArDebtList)Data : null;
387+
if(_data != null && _data.List != null && ev_subj.ItemIdx < _data.List.size()) {
388+
//CPM.FindGoodsItemByGoodsID()
389+
BusinessEntity.DebtEntry cur_entry = _data.List.get(ev_subj.ItemIdx);
390+
View iv = ev_subj.RvHolder.itemView;
391+
SLib.SetCtrlString(iv, R.id.CTL_DEBTDETAILLISTITEM_CODE, cur_entry.BillCode);
392+
SLib.SetCtrlString(iv, R.id.CTL_DEBTDETAILLISTITEM_DATE, cur_entry.BillDate.Format(SLib.DATF_DMY));
393+
SLib.SetCtrlString(iv, R.id.CTL_DEBTDETAILLISTITEM_AMOUNT, SLib.formatdouble(cur_entry.Amount, 2));
394+
SLib.SetCtrlString(iv, R.id.CTL_DEBTDETAILLISTITEM_DEBT, SLib.formatdouble(cur_entry.Debt, 2));
395+
}
396+
}
397+
}
398+
}
399+
}
400+
}
401+
break;
402+
403+
}
404+
return result;
405+
}
406+
boolean SetDTS(Object objData)
407+
{
408+
boolean ok = true;
409+
StyloQApp app_ctx = (ActivityCtx != null) ? ActivityCtx.GetAppCtx() : null;
410+
if(app_ctx != null) {
411+
//Context ctx = getContext();
412+
BusinessEntity.ArDebtList _data = (Data != null && Data instanceof BusinessEntity.ArDebtList) ? (BusinessEntity.ArDebtList)Data : null;
413+
if(_data != null) {
414+
String hint_text = _data.ArName; // @todo
415+
SLib.SetCtrlString(this, R.id.CTL_DEBTDETAILLIST_HEADER, hint_text);
416+
View lv = findViewById(R.id.CTL_DEBTDETAILLIST_LIST);
417+
if(lv != null && lv instanceof RecyclerView) {
418+
((RecyclerView)lv).setLayoutManager(new LinearLayoutManager(ActivityCtx));
419+
SLib.RecyclerListAdapter adapter = new SLib.RecyclerListAdapter(ActivityCtx, this, R.id.CTL_DEBTDETAILLIST_LIST, R.layout.li_debtdetaillist);
420+
((RecyclerView) lv).setAdapter(adapter);
421+
}
422+
}
423+
}
424+
return ok;
425+
}
426+
Object GetDTS()
427+
{
428+
Object result = Data;
429+
return result;
430+
}
431+
}
341432
int FindClientItemIndexByID(int id)
342433
{
343434
int result = -1;
@@ -907,20 +998,36 @@ else if(vg_id == R.id.LAYOUT_ORDERPREPREQ_ORDR) {
907998
CommonPrereqModule.CliEntry cur_entry = (CommonPrereqModule.CliEntry)CPM.CliListData.get(ev_subj.ItemIdx);
908999
final int cur_cli_id = cur_entry.JsItem.optInt("id", 0);
9091000
SLib.SetCtrlString(iv, R.id.LVITEM_GENERICNAME, cur_entry.JsItem.optString("nm", ""));
910-
if(DbtL != null) {
911-
SLib.SetCtrlVisibility(iv, R.id.LAYOUT_ORDERPREREQ_CLI_DEBT, View.VISIBLE);
912-
BusinessEntity.DebtList.ShortReplyEntry de = DbtL.GetDebt(cur_cli_id);
913-
String text;
914-
if(de != null) {
915-
text = "debt" + ": " + SLib.formatdouble(de.Debt, 2);
1001+
{
1002+
View v_debt_text = iv.findViewById(R.id.CTL_ORDERPREREQ_CLI_DEBT);
1003+
if(DbtL != null) {
1004+
SLib.SetCtrlVisibility(iv, R.id.LAYOUT_ORDERPREREQ_CLI_DEBT, View.VISIBLE);
1005+
BusinessEntity.DebtList.ShortReplyEntry de = DbtL.GetDebt(cur_cli_id);
1006+
if(v_debt_text != null) {
1007+
String text;
1008+
int shaperc = 0;
1009+
if(de != null) {
1010+
final boolean is_expired = de.IsExpired(CmdQueryDebt);
1011+
if(de.Debt > 0) {
1012+
shaperc = is_expired ? R.drawable.shape_debtvalue_undef : R.drawable.shape_debtvalue_positive;
1013+
text = SLib.formatdouble(de.Debt, 2);
1014+
}
1015+
else {
1016+
shaperc = is_expired ? R.drawable.shape_debtvalue_undef : R.drawable.shape_debtvalue_zero;
1017+
text = is_expired ? "0" : "";
1018+
}
1019+
}
1020+
else {
1021+
shaperc = R.drawable.shape_debtvalue_undef;
1022+
text = "";
1023+
}
1024+
v_debt_text.setBackground(getResources().getDrawable(shaperc, getTheme()));
1025+
SLib.SetCtrlString(iv, R.id.CTL_ORDERPREREQ_CLI_DEBT, text);
1026+
}
9161027
}
9171028
else {
918-
text = "???";
1029+
SLib.SetCtrlVisibility(iv, R.id.LAYOUT_ORDERPREREQ_CLI_DEBT, View.GONE);
9191030
}
920-
SLib.SetCtrlString(iv, R.id.CTL_ORDERPREREQ_CLI_DEBT, text);
921-
}
922-
else {
923-
SLib.SetCtrlVisibility(iv, R.id.LAYOUT_ORDERPREREQ_CLI_DEBT, View.GONE);
9241031
}
9251032
SetListBackground(iv, a, ev_subj.ItemIdx, SLib.PPOBJ_PERSON, cur_cli_id);
9261033
{
@@ -1383,7 +1490,7 @@ else if(ev_subj.ItemView.getId() == R.id.CTL_ORDERPREREQ_CLI_DEBT) {
13831490
final int cur_cli_id = item.JsItem.optInt("id", 0);
13841491
if(cur_cli_id > 0) {
13851492
BusinessEntity.DebtList.ShortReplyEntry de = DbtL.GetDebt(cur_cli_id);
1386-
if(de == null) {
1493+
if(de == null || de.IsExpired(CmdQueryDebt)) {
13871494
if(CmdQueryDebt != null) {
13881495
// query
13891496
boolean force_query = true;
@@ -1401,6 +1508,13 @@ else if(ev_subj.ItemView.getId() == R.id.CTL_ORDERPREREQ_CLI_DEBT) {
14011508
}
14021509
else {
14031510
// detail
1511+
if(de.Debt > 0.0) {
1512+
BusinessEntity.ArDebtList debt_detail = DbtL.GetDebtDetail(cur_cli_id);
1513+
if(debt_detail != null) {
1514+
DebtDetailDialog dialog = new DebtDetailDialog(this, debt_detail);
1515+
dialog.show();
1516+
}
1517+
}
14041518
}
14051519
}
14061520
}
@@ -1724,7 +1838,25 @@ else if(srcObj instanceof CommonPrereqModule.RegistryFiltDialog) {
17241838
StyloQApp.InterchangeResult ir = (StyloQApp.InterchangeResult)subj;
17251839
StyloQApp app_ctx = GetAppCtx();
17261840
if(ir.OriginalCmdItem != null) {
1727-
if(ir.OriginalCmdItem.Name.equalsIgnoreCase("PostDocument")) {
1841+
if(ir.OriginalCmdItem.BaseCmdId == StyloQCommand.sqbcDebtList) {
1842+
if(ir.ResultTag == StyloQApp.SvcQueryResult.SUCCESS) {
1843+
if(ir.InfoReply != null && ir.InfoReply instanceof SecretTagPool) {
1844+
JSONObject js_reply = ((SecretTagPool)ir.InfoReply).GetJsonObject(SecretTagPool.tagRawData);
1845+
BusinessEntity.ArDebtList ard_list = new BusinessEntity.ArDebtList();
1846+
if(ard_list.FromJson(js_reply)) {
1847+
if(DbtL.Include(ard_list) >= 0) {
1848+
app_ctx.StoreDebtList(CPM.SvcIdent, DbtL);
1849+
// @todo Здесь достаточно обновить только одну позицию списка, а не весь список!
1850+
NotifyTabContentChanged(CommonPrereqModule.Tab.tabClients, R.id.orderPrereqClientsListView);
1851+
}
1852+
}
1853+
}
1854+
}
1855+
else {
1856+
// @todo
1857+
}
1858+
}
1859+
else if(ir.OriginalCmdItem.Name.equalsIgnoreCase("PostDocument")) {
17281860
CPM.CurrentDocument_RemoteOp_Finish();
17291861
ScheduleRTmr(null, 0, 0);
17301862
if(ir.ResultTag == StyloQApp.SvcQueryResult.SUCCESS) {

0 commit comments

Comments
 (0)